Description
Claude Code v2.1.100+ added a Monitor tool that allows the agent to subscribe to streaming stdout events from background processes and receive notifications as events arrive. This enables the agent to watch long-running scripts without polling.
Pattern
The Monitor tool works in conjunction with background script execution:
- Start a background process (e.g., a test runner, build, or server)
- Call Monitor with the process reference to receive a stream of stdout lines as tool events
- Agent reacts to events (e.g., test failure, build complete) without sleeping or polling
Relevance to Zeph
Zeph's zeph-tools provides ShellExecutor which currently blocks until completion. Adding a Monitor-style streaming mode would enable:
- Long-running tool outputs streamed into context as they arrive
- TUI status updates from background builds / test runs
- Hook-based reactions to specific stdout patterns (e.g., fire a PostToolUse hook when output contains "error")
Implementation Sketch
Add ShellExecutorMode::Streaming variant to ToolExecutor:
- Spawn process, return
AsyncStream<ToolEvent>
- Each stdout line = one
ToolEvent::Partial
- On process exit:
ToolEvent::Complete with exit code
Expose in TUI as a spinner with live output tail.
Source
Description
Claude Code v2.1.100+ added a Monitor tool that allows the agent to subscribe to streaming stdout events from background processes and receive notifications as events arrive. This enables the agent to watch long-running scripts without polling.
Pattern
The Monitor tool works in conjunction with background script execution:
Relevance to Zeph
Zeph's
zeph-toolsprovidesShellExecutorwhich currently blocks until completion. Adding a Monitor-style streaming mode would enable:Implementation Sketch
Add
ShellExecutorMode::Streamingvariant toToolExecutor:AsyncStream<ToolEvent>ToolEvent::PartialToolEvent::Completewith exit codeExpose in TUI as a spinner with live output tail.
Source