Expand description
SubprocessController: manages agent CLI as stateless per-turn subprocess invocations.
Architecture:
Each user message spawns a fresh claude -p process.
Multi-turn continuity uses --resume <session-id>.
The process reads one JSON message from stdin, runs the agentic loop,
streams NDJSON on stdout, then exits.
State machine: INIT ─(spawn)─> RUNNING ─(process exits)─> DONE DONE ─(new message)─> RUNNING (re-spawn with –resume)
I/O model (2 async tasks per turn):
- stdout_reader: piped stdout → .jsonl persistence + WPS blockfile events on “output” subject
- process_waiter: wait for exit, update status, publish lifecycle event
Structs§
- Subprocess
Controller - SubprocessController manages per-turn subprocess lifecycle for agent blocks.
- Subprocess
Controller 🔒Inner - Inner state protected by mutex.
- Subprocess
Spawn Config - Configuration for spawning a subprocess turn.
Constants§
- BLOCK_
CONTROLLER_ SUBPROCESS - Controller type constant.
- SUBPROCESS_
OUTPUT_ SUBJECT - WPS file subject name for subprocess output (replaces “term” from PTY).