Expand description
PersistentSubprocessController: manages agent CLI as a long-running process with bidirectional NDJSON streaming via stdin/stdout.
Architecture: A single CLI process is spawned on first message and kept alive for the entire session. User messages are written as NDJSON lines to stdin without closing it. This enables mid-turn input (redirecting the agent while it is still processing).
State machine: INIT ─(first message)─> RUNNING ─(idle between turns)─> RUNNING RUNNING ─(kill/stop)─> DONE RUNNING ─(process crash)─> DONE (auto-restart possible via session_id)
I/O model (3 async tasks per session):
- stdin_writer: mpsc channel → process stdin (NDJSON lines)
- stdout_reader: process stdout → .jsonl persistence + WPS blockfile events
- process_waiter: wait for exit, update status
Structs§
- Persistent
Inner 🔒 - Inner state protected by mutex.
- Persistent
Spawn Config - Configuration for spawning the persistent process.
- Persistent
Subprocess Controller - PersistentSubprocessController keeps a long-running CLI process alive, sending user messages as NDJSON lines on stdin.
Constants§
- BLOCK_
CONTROLLER_ PERSISTENT - Controller type constant.
- PERSISTENT_
OUTPUT_ SUBJECT - WPS file subject name for persistent subprocess output.