Skip to main content

Module agent_attach

Module agent_attach 

Source

Constants§

DESIRED_RUNNING 🔒
DESIRED_STOPPED 🔒
META_DESIRED 🔒
Block meta: whether the agent should be running, running or stopped. Open, start and a message that starts it set running; an explicit stop sets stopped.
START_PARKED 🔒
Marks an open that is a start: the block it makes is parked, not placed in a layout.

Statics§

DESIRED_WRITE 🔒
Held while a desired state is decided and written, so the record in STOPPED_THIS_RUN and the block’s meta change together: a conditional start (set_running_unless_stopped_since) cannot overwrite a stop that lands between its check and its write. Never held across a store transaction’s own work (nothing inside one calls these).
STOPPED_THIS_RUN 🔒
The blocks whose agent was set to stopped since this srv started and not started again, and when (unix ms). A recorded stopped read from the database at startup is not in it: it may be stale (something started the agent without recording it), while one in here was decided in this run, so it is binding.

Functions§

controller_type_of 🔒
The controller an agent’s pane runs. A container agent’s turns are docker execs of a subprocess controller, whatever its provider defaults to (claude’s is persistent, which skips the container exec).
desired_of 🔒
The desired state a block records, if any.
dispatch_all 🔒
Dispatch to the reducer, mirror to SQLite and publish: what agent.open does for a block.
ensure_controller 🔒
Register the block’s controller when it has none (a pane the frontend made, or a parked block after a restart), resuming the agent’s session. With revive, a controller whose process has ended is resynced too, which resumes it (a start, or an open with the setting on). tab_id is empty for a parked block.
focus_shown 🔒
Bring the window to the pane that shows block_id in tab_id: block.reveal makes it its pane’s visible member and tells its window to restore, un-magnify and focus it; where that finds no open window, its tab is made active and its pane focused here.
park_new 🔒
A new block made by a start: out of its tab at once, so it is the agent’s parked block.
reuse_existing_pane 🔒
What agent.open (or a start, headless) does when the agent already has a block. The agent has one pane: super::agent_block::decide_agent_pane says which, and every path that would add one asks it, so no open makes a second (task #5419):
set_desired 🔒
Record the agent’s desired state on its block. Best effort: a failed write costs a restart’s resume, not the start or stop itself. A stopped is logged with the caller that decided it: an agent that comes back from a restart stopped has to be traceable to the code that stopped it.
set_running_unless_stopped_since 🔒
Record the agent as wanted running, unless a stop was decided as, or after, started_at_ms: the turn that began then is the one the stop ended or the agent quit in. The check and the write are one step against set_desired, so a stop that lands in between is not undone. Returns whether it wrote.
start_admitted 🔒
The start itself, once admitted: a failure gives the admission’s room back.
start_agent 🔒
Start the agent with no pane: its block (made and parked if it has none) with its process running and its session resumed. Returns the block. Admission, the spawn gate and the lease apply as for agent.open. Needs an active tab to create a first block in.
start_agent_without_eviction 🔒
start_agent that never stops another agent to make room: over the cap or the commit limit it is refused (Err("capacity: ...")). Restart resume starts the agents that were running this way.
start_markers 🔒
What a start tells agent.open: it makes no pane.
stopped_at_ms 🔒
When block_id’s agent was set to stopped in this run (unix ms), if it was and has not been started since.
stopped_this_run 🔒
Whether block_id’s agent was set to stopped in this run and not started since.
tab_or_reuse 🔒
The tab agent.open works in, or the agent’s existing pane when it has one (Err: nothing more to do). A start of a terminal-tier CLI is refused: its term view starts it, and a start has none. A start needs no tab to run an agent that already has a block, so with no tab left it only reuses that block; a first block still needs a tab.
write_desired 🔒