Commit graph

85 commits

Author SHA1 Message Date
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
dullfig
379f5a0258 Use BufferSlot as single source of truth for handler dispatch
Handlers now receive payload references directly from the context
buffer slot rather than independent copies. Metadata is derived
via slot_to_handler_metadata() ensuring consistency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 17:51:38 -08:00
dullfig
f195835bea Update secure console design: simplify detached mode
When detached, console changes prompt from '>' to '#' and rejects
@messages while still accepting /commands. Simpler than the ring
buffer approach - operator can still check status and re-attach.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 17:44:57 -08:00
dullfig
fc8b6608cf Add secure console design doc (v3.0)
Design for keyboard-only privileged interface:
- OOB port eliminated — privileged ops via keyboard only
- Argon2id password protection for destructive commands
- Attach/detach model with idle timeout
- Ring buffer for messages while detached

Key security properties:
- No network attack surface for privileged operations
- Password required for /restart, /kill
- Handler returns None on timeout → organism continues headless
- /attach + password to reconnect

Commands: /status /listeners /threads /buffer /config /restart
          /kill /pause /resume /attach /detach /timeout /quit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 17:40:05 -08:00
dullfig
fc7170a02e Add context buffer - virtual memory manager for AI agents
Implements thread-scoped, append-only storage for validated payloads.
Handlers receive immutable references; messages cannot be modified
after insertion.

Core components:
- BufferSlot: frozen dataclass holding payload + metadata
- ThreadContext: append-only buffer per thread
- ContextBuffer: global manager with GC and limits

Design parallels OS virtual memory:
- Thread ID = virtual address space
- Buffer slot = memory page
- Immutable reference = read-only mapping
- Thread isolation = process isolation

Integration:
- Incoming messages appended after pipeline validation
- Outgoing responses appended before serialization
- Full audit trail preserved

This is incremental - handlers still receive copies for backward
compatibility. Next step: skip serialization for internal routing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 17:20:43 -08:00
dullfig
a5e2ab22da Add thread registry, LLM router, console handler, and docs updates
Thread Registry:
- Root thread initialization at boot
- Thread chain tracking for message flow
- register_thread() for external message UUIDs

LLM Router:
- Multi-backend support with failover strategy
- Token bucket rate limiting per backend
- Async completion API with retries

Console Handler:
- Message-driven REPL (not separate async loop)
- ConsolePrompt/ConsoleInput payloads
- Handler returns None to disconnect

Boot System:
- System primitives module
- Boot message injected at startup
- Initializes root thread context

Documentation:
- Updated v2.1 docs for new architecture
- LLM router documentation
- Gap analysis cross-check

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 16:53:38 -08:00
dullfig
8aa58715df Add TodoUntil watcher system for async confirmation tracking
Implements an observer pattern where agents can register watchers
for conditions on their thread. When the condition is met, the
agent gets "nagged" on subsequent invocations until it explicitly
closes the todo.

Key components:
- TodoRegistry: thread-scoped watcher tracking with eyebrow state
- TodoUntil/TodoComplete payloads and system handlers
- HandlerMetadata.todo_nudge for delivering raised eyebrow notices
- Integration in StreamPump dispatch to check and nudge

Greeter now demonstrates the pattern:
1. Registers watcher for ShoutedResponse from shouter
2. On next invocation, sees nudge and closes completed todos
3. Includes nudge in LLM prompt for awareness

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 16:51:59 -08:00
dullfig
8fa92b8f56 Add multi-agent flow demo with shouter listener
Demonstrates message chaining: user -> greeter -> shouter -> user

- Add ShoutedResponse payload class (ALL CAPS response)
- Add handle_shout handler that forwards to original sender
- Update GreetingResponse to track original_sender
- Fix wrap_in_envelope to add xmlns="" to payloads
- Update organism.yaml with shouter listener
- Update tests for 2-listener configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 10:47:09 -08:00
dullfig
82b5fcdd78 Replace MessageBus with aiostream-based StreamPump
Major refactor of the message pump architecture:

- Replace bus.py with stream_pump.py using aiostream for composable
  stream processing with natural fan-out via flatmap
- Add to_id field to MessageState for explicit routing
- Fix routing to use to_id.class format (e.g., "greeter.greeting")
- Generate XSD schemas from xmlified payload classes
- Fix xmlable imports (absolute -> relative) and parse_element ctx

New features:
- handlers/hello.py: Sample Greeting/GreetingResponse handler
- config/organism.yaml: Sample organism configuration
- 41 tests (31 unit + 10 integration) all passing

Schema changes:
- envelope.xsd: Allow any namespace payloads (##other -> ##any)

Dependencies added to pyproject.toml:
- aiostream>=0.5 (core dependency)
- pyhumps, termcolor (for xmlable)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 10:41:17 -08:00
dullfig
dc16316aed fixing docs 2026-01-08 15:49:07 -08:00
dullfig
a1e1b9a1c0 fixing docs 2026-01-08 15:35:36 -08:00
dullfig
ab207d8f0b fixing docs 2026-01-08 12:30:58 -08:00
dullfig
e314bb01e8 fixing docs 2026-01-07 20:58:31 -08:00
dullfig
f2758e5c49 fixing docs 2026-01-07 16:39:55 -08:00
dullfig
3105648fd1 fixing docs 2026-01-07 13:12:08 -08:00
dullfig
6696c06e4f fixing docs 2026-01-07 12:31:47 -08:00
dullfig
86ad3c7eb2 fixing docs 2026-01-06 19:28:25 -08:00
dullfig
e6aa9cbd61 Merge remote-tracking branch 'origin/main' 2026-01-06 19:25:47 -08:00
dullfig
2e8ed88e42 fixing docs 2026-01-06 19:24:41 -08:00
dullfig
9ae2fb608d fixing docs 2026-01-06 19:23:40 -08:00
dullfig
ed66b16821 fixing docs 2026-01-04 23:33:46 -08:00
dullfig
67c77d568e added rant 2026-01-04 22:22:17 -08:00