Commit graph

106 commits

Author SHA1 Message Date
dullfig
6790c7a46c Add shared backend for multiprocess pipeline support
Introduces SharedBackend Protocol for cross-process state sharing:
- InMemoryBackend: default single-process storage
- ManagerBackend: multiprocessing.Manager for local multi-process
- RedisBackend: distributed deployments with TTL auto-GC

Adds ProcessPoolExecutor support for CPU-bound handlers:
- worker.py: worker process entry point
- stream_pump.py: cpu_bound handler dispatch
- Config: backend and process_pool sections in organism.yaml

ContextBuffer and ThreadRegistry now accept optional backend
parameter while maintaining full backward compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:18:22 -08:00
dullfig
f87d9f80e9 Move console, auth, server to Nextra (v0.4.0)
These modules are now proprietary and live in the Nextra SaaS product.
xml-pipeline remains the OSS core with:
- Message pump and pipeline steps
- Handler contract and responses
- LLM router abstraction
- Native tools
- Config loading
- Memory/context buffer

Removed:
- xml_pipeline/console/ → nextra/console/
- xml_pipeline/auth/ → nextra/auth/
- xml_pipeline/server/ → nextra/server/
- Legacy files: agentserver.py, main.py, xml_listener.py

The simple console example remains in examples/console/.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 22:37:21 -08:00
dullfig
d53bc1dfbe Fix XSD path for installed package (v0.3.1)
Use __file__-based path resolution for envelope.xsd so the schema
loads correctly when xml-pipeline is installed via pip.

Also:
- Add build artifacts to .gitignore
- Bump version to 0.3.1

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 22:24:36 -08:00
dullfig
6b9c378e52 Bump version to 0.3.0
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 21:54:58 -08:00
dullfig
947cd5838a Fix termcolor compatibility in vendored xmlable
Remove unused Color type import from termcolor.termcolor which doesn't
exist in newer termcolor versions. Change type hints from Color to str.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 21:53:32 -08:00
dullfig
0553ec294f Update README and pyproject.toml for PyPI release
README.md:
- Rebrand from AgentServer to xml-pipeline
- Library-focused introduction with pip install
- Quick start guide with code examples
- Console example documentation
- Concise feature overview

pyproject.toml:
- Update authors to "xml-pipeline contributors"
- Update URLs to xml-pipeline.org

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 21:48:52 -08:00
dullfig
3cae862d7a Update .gitignore for package rename
- Add .claude/ (Claude Code config)
- Update paths from agentserver/ to xml_pipeline/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 21:44:44 -08:00
dullfig
e653d63bc1 Rename agentserver to xml_pipeline, add console example
OSS restructuring for open-core model:
- Rename package from agentserver/ to xml_pipeline/
- Update all imports (44 Python files, 31 docs/configs)
- Update pyproject.toml for OSS distribution (v0.3.0)
- Move prompt_toolkit from core to optional [console] extra
- Remove auth/server/lsp from core optional deps (-> Nextra)

New console example in examples/console/:
- Self-contained demo with handlers and config
- Uses prompt_toolkit (optional, falls back to input())
- No password auth, no TUI, no LSP — just the basics
- Shows how to use xml-pipeline as a library

Import changes:
- from agentserver.* -> from xml_pipeline.*
- CLI entry points updated: xml_pipeline.cli:main

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 21:41:19 -08:00
dullfig
3ffab8a3dd fixing docs 2026-01-18 18:00:11 -08:00
dullfig
0fb35da5dd Add /configure command with full-screen editor
- AgentConfigStore: Per-agent YAML configs in ~/.xml-pipeline/agents/
- Full-screen editor using prompt_toolkit with YAML highlighting
- /configure: Edit organism.yaml (swarm wiring)
- /configure @agent: Edit agent config (prompt, model, temperature)

Agent configs separate behavior (prompt, model) from wiring (peers, routing).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:17:43 -08:00
dullfig
0796e45412 Add SystemPipeline for external message injection
- SystemPipeline: Entry point for console/webhook/API messages
- TextInput/TextOutput: Generic primitives for human text I/O
- Server: WebSocket "send" command routes through SystemPipeline
- Console: @target message now injects into pipeline

Flow: Console → WebSocket → SystemPipeline → XML envelope → pump

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:07:28 -08:00
dullfig
ebf72c1f8c Add authentication system and HTTP/WebSocket server
- auth/users.py: User store with Argon2id password hashing
- auth/sessions.py: Token-based session management with expiry
- server/app.py: aiohttp server with auth middleware and WebSocket
- console/client.py: SSH-style login console client

Server endpoints: /auth/login, /auth/logout, /auth/me, /health, /ws

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 20:50:53 -08:00
dullfig
986db2e79b Implement native tools and infrastructure
Tools (18 total):
- calculate: Safe AST-based math expression evaluator
- fetch: Async HTTP with SSRF protection
- files: Sandboxed read/write/list/delete
- shell: Command execution with blocklist
- search: Web search (SerpAPI, Google, Bing)
- keyvalue: In-memory key-value store
- librarian: exist-db XML database integration
- convert: XML↔JSON conversion + XPath extraction

Infrastructure:
- CLI with run/init/check/version commands
- Config loader for organism.yaml
- Feature detection for optional dependencies
- Optional extras in pyproject.toml

LLM:
- Fixed llm_connection.py to wrap working router

WASM:
- Documented WASM listener interface
- Stub implementation for future work

MCP:
- Reddit sentiment MCP server example

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 20:25:48 -08:00
dullfig
3764c30628 Add tool stubs for native agent tools
Stub implementations for:
- base.py: Tool, ToolResult, @tool decorator, registry
- calculate.py: Math expressions (simpleeval)
- fetch.py: HTTP requests (aiohttp)
- files.py: read_file, write_file, list_dir
- shell.py: run_command (sandboxed)
- search.py: web_search
- keyvalue.py: key_value_get/set/delete (in-memory stub)
- librarian.py: exist-db integration (store, get, query, search)

All stubs return "Not implemented" - ready for real implementation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:40:58 -08:00
dullfig
7950be66f3 Add native tools specification
Core tools:
- calculate (simpleeval) - math expressions in Python syntax
- fetch_url - HTTP requests with security controls
- read_file / write_file / list_dir - sandboxed file ops
- run_command - sandboxed shell execution
- web_search - web search integration
- key_value_store - persistent agent state
- send_email / webhook - notifications

Librarian tools (exist-db):
- librarian_store - store XML documents
- librarian_get - retrieve by path
- librarian_query - XQuery execution
- librarian_search - full-text search

Includes permission model and implementation checklist.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:37:40 -08:00
dullfig
1de6a1249e fixing docs 2026-01-12 22:31:06 -08:00
dullfig
398fd5ac23 Add Lua listeners proposal and message log stream
Lua proposal covers:
- Sandboxed Lua handlers for SaaS custom logic
- XML <-> Lua table bridging with XSD validation
- Security sandbox (restricted stdlib, resource limits)
- Schema DSL alternative to raw XSD
- Hot reload mechanism

API spec updated with:
- Dedicated /ws/messages endpoint for message log streaming
- Filter by agent/thread/payload type
- Example for reconstructing agent buffers client-side

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:30:45 -08:00
dullfig
a29c6f8321 Add security considerations document
Covers authentication (TOTP, WebAuthn, mTLS, OAuth), authorization
(RBAC, resource permissions), transport security, secrets management,
audit logging, prompt injection defense, and rate limiting.

Includes open questions and implementation checklist.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 22:52:55 -08:00
dullfig
5ccffece60 Add agentserver API specification
Defines the GUI-agnostic API for monitoring and controlling the organism:
- REST endpoints for queries and control
- WebSocket for real-time push events
- Data models for agents, messages, threads
- Example usage for 3D office GUI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 22:47:57 -08:00
dullfig
a6b83f2dbc fixing docs 2026-01-11 16:16:25 -08:00
dullfig
a9035d34d8 fixing docs 2026-01-11 16:01:04 -08:00
dullfig
fff43f1a78 fixing docs 2026-01-11 16:00:03 -08:00
dullfig
573caaa681 Fix bottom detection - consider last 3 lines as "at bottom"
- is_at_bottom() now checks if on last 3 lines (not exact end)
- Page Down snaps to bottom when within 3 lines of end
- Added scroll_to_bottom() helper method

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:30:53 -08:00
dullfig
45d6eea4ac Dynamic spacer and silent append when scrolled up
- Spacer only shows when output is at bottom (disappears when scrolled up)
- New content appends silently when user has scrolled up (preserves position)
- is_at_bottom() helper to check scroll state

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:27:21 -08:00
dullfig
4dcc726280 Fix command history with history_backward/forward methods
auto_up/auto_down were wrong - use history_backward/history_forward
for proper command history navigation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:23:41 -08:00
dullfig
8e98e98bf1 Add command history (Up/Down) and spacer above separator
- Up/Down arrows now navigate command history via auto_up/auto_down
- Added blank line spacer between output and separator for clarity

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:21:07 -08:00
dullfig
35b3381b7c Simplify scroll: Page Up/Down always, Up/Down for history
Standard CLI behavior:
- Up/Down = command history (always)
- Page Up/Down = scroll output (no focus needed)
- Ctrl+Home/End = jump to top/bottom
- Mouse/scrollbar works too

Removed Tab focus switching - not intuitive for CLI users.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:15:53 -08:00
dullfig
ed02281513 Fix filter lambda causing TUI to fail
Use Condition wrapper with try/except to handle case where
self.app doesn't exist yet during key binding setup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:12:44 -08:00
dullfig
10daf0ce70 Add arrow key scrolling for output when focused
- Up/Down move cursor one line (scrolls view)
- Page Up/Down move 20 lines at a time
- Home/End jump to top/bottom
- Keys only active when output buffer is focused (Tab to switch)
- Updated help text with scroll shortcuts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:11:07 -08:00
dullfig
fbb6c28ab7 Rewrite output to use Buffer for native scrolling
FormattedTextControl doesn't support scrolling - always renders from top.
Switch to Buffer + BufferControl which has proper scroll support:
- Output buffer uses read-only Buffer with cursor at end
- Tab/Shift-Tab to switch focus between output and input
- Arrow keys scroll when output is focused
- Scrollbar margin shows position
- Auto-scroll on new content (cursor stays at end)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:07:07 -08:00
dullfig
f58197c83f Fix scroll with custom scroll_offset mechanism
Window.vertical_scroll is read-only in prompt_toolkit.
Use custom scroll_offset to track position and slice output lines.
- scroll_offset=0 shows newest content (auto-scroll)
- Page Up increases offset (scroll into history)
- Page Down decreases offset (towards newest)
- Home/End jump to top/bottom

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:04:04 -08:00
dullfig
92e663d6a2 Add scrollable output history to TUI console
- Add Page Up/Down, Home/End key bindings for manual scrolling
- Track user_scrolled flag to preserve position when user scrolls
- Remove visible_lines limit to show full history
- Auto-scroll to bottom on new content (unless user scrolled up)
- Update help text with scroll shortcuts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:00:36 -08:00
dullfig
e254ac7bf6 Force output window to scroll to bottom
- Set vertical_scroll=999999 to always show newest content
- Update scroll position on every invalidate
- Reduced visible_lines to 20 for safety

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:55:12 -08:00
dullfig
ce37278dcd Fix output area to show content at bottom
- Use HSplit with filler + output to push content to bottom
- Output window uses dont_extend_height so it only takes needed space
- Empty filler expands to fill remaining space above

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:52:33 -08:00
dullfig
d59dd4968d Fix output scrolling - show only last 50 lines
Instead of trying to scroll the window, just display the most
recent lines that fit on screen. Full history is kept but only
the last 50 lines are rendered.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:50:07 -08:00
dullfig
80f8226b1d Add threads list to context buffer get_stats() 2026-01-11 14:46:27 -08:00
dullfig
abc5902b60 Fix console registry for cross-module access
- Create separate console_registry module to avoid __main__ vs module import issue
- Handler now correctly finds TUI console instance
- Response output should now appear in TUI output area

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:44:10 -08:00
dullfig
161ddee138 Add debug output to trace console routing 2026-01-11 14:42:25 -08:00
dullfig
3e5803d41b Fix FormattedText newline handling 2026-01-11 14:39:21 -08:00
dullfig
5a76797613 Add refresh loop for reliable TUI output updates
- Remove patch_stdout (was buffering until exit)
- Add 100ms refresh loop that periodically invalidates the app
- Ensures output buffer changes are displayed in real-time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:37:02 -08:00
dullfig
cc5257d342 Fix TUI output with patch_stdout
- Add patch_stdout to capture external prints in TUI mode
- Any stdout from handlers/pump appears in output area, not prompt
- Simplify response handler logic

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:34:03 -08:00
dullfig
01598bd708 Remove fallback print from response handler to debug TUI output 2026-01-11 14:33:29 -08:00
dullfig
ad507cd54a Fix TUI console response display
- Add thread-safe invalidation for cross-task updates
- Fix response handler to properly route to TUI output
- Add debug output if console hook fails

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:30:36 -08:00
dullfig
6a5c047d1e Add split-screen TUI console with prompt_toolkit
New console features:
- Scrolling output area above separator line
- Status bar with organism name
- Input area at bottom
- Color-coded messages by source
- Command history with up/down arrows
- Graceful fallback to simple mode on unsupported terminals

Usage:
  python run_organism.py           # TUI mode (or fallback)
  python run_organism.py --simple  # Force simple mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:23:19 -08:00
dullfig
ad081d412c Fix platform.complete() to use correct LLM router API
- Import `complete` not `generate` from agentserver.llm
- Pass `model` parameter required by router
- Return response.content (string) not response object

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:05:53 -08:00
dullfig
987c6aa214 Add platform-managed PromptRegistry and LLM API
Platform architecture for trusted orchestration:
- PromptRegistry: immutable system prompts per agent, loaded at bootstrap
- platform.complete(): assembles LLM calls (prompt + history + user msg)
- Handlers use platform API, cannot see/modify prompts
- organism.yaml now supports prompt field per listener

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 13:57:51 -08:00
dullfig
d7825335eb fixing docs 2026-01-11 13:50:05 -08:00
dullfig
e23fa6a2a9 Add platform architecture design doc
Documents the trust model for context and prompt management:
- Platform as trusted orchestration layer
- Context buffer: pure message history, keyed by UUID, auto-GC
- Prompt registry: immutable, invisible to agents
- LLM call assembly: platform controls, agents request
- Handler sandbox: what agents can/cannot do

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 13:49:42 -08:00
dullfig
5fe63bf943 Add /monitor command to show recent thread messages
Shows last 20 messages from a specific thread or last 5 per thread
when using /monitor *. Color-coded by direction (console=green,
responses=cyan).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:32:32 -08:00
dullfig
f75aa3eee6 Add SecureConsole v3.0 with password authentication
- SecureConsole with Argon2id password hashing
- Password stored in ~/.xml-pipeline/console.key
- Protected commands require password re-entry
- Attach/detach model with idle timeout
- Fallback to simple input for incompatible terminals
- @listener message injection into pump
- Boot handler no longer sends to old console
- Response handler prints to stdout with prompt refresh

Dependencies: argon2-cffi, prompt_toolkit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:24:24 -08:00