Module persistent

Module persistent 

Source
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):

  1. stdin_writer: mpsc channel → process stdin (NDJSON lines)
  2. stdout_reader: process stdout → .jsonl persistence + WPS blockfile events
  3. process_waiter: wait for exit, update status

Structs§

PersistentInner 🔒
Inner state protected by mutex.
PersistentSpawnConfig
Configuration for spawning the persistent process.
PersistentSubprocessController
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.