Skip to main content

Module monitor

Module monitor 

Source
Expand description

Background monitor daemon.

Spawns a detached child process that owns the coding agent: it launches the agent, captures its stdout and exit code into .devflow/, and — when the agent exits — runs devflow advance to advance the stage machine.

Owning the agent is the key fix over a CLI-scoped capture thread: because the monitor outlives devflow start, the agent’s stdout keeps flowing into the capture file and its exit code is still reaped after the CLI exits.

This is the core automation primitive — no cron, no scheduler, no agent cooperation needed.

Enums§

MonitorError
Errors produced by monitor operations.

Functions§

spawn_monitor
Spawn a background monitor that owns the agent for the given workflow state.
spawn_monitor_no_advance
Spawn a monitor that owns the agent and records its capture files but does NOT advance the stage machine when the agent exits. Used by sequentagent, which drives its own synchronous handoff loop: the CLI blocks on the exit file (see wait_for_agent_exit) while the monitor guarantees capture survives even if the CLI dies.
wait_for_agent_exit
Block until the monitor records the agent’s exit code, returning it.
wait_for_agent_pid
Poll for the agent PID that the monitor records, for up to ~1 second.