Skip to main content

Module turn_steps

Module turn_steps 

Source
Expand description

The steps of run_agent_turn_joining (input.rs), one function each, in the order it runs them. Moved from it unchanged.

Structs§

SpawnBase 🔒
What a pane’s meta says to run.
Turn 🔒
One turn, ready to hand to the controller that will run it.

Constants§

CONTAINER_ATTACHMENTS_SUBDIR 🔒
The subfolder, under a container’s working folder, that rehomed attachments live in.

Functions§

attachment_destination 🔒
Where this turn’s attachments land, or why they can’t: Ok(None) for a host agent (nothing to rehome — the host path already means something to it); Ok(Some(cwd)) for a container agent with a working folder to copy into; Err for a runtime that refuses attachments and isn’t a container (none does today; kept so a future one still refuses cleanly), or a container with no working folder yet.
dispatch_app_server 🔒
App Server owns a persistent thread/turn process and has its own typed protocol path. Keep it ahead of the legacy stream-json branches.
dispatch_persistent 🔒
Dispatch to a persistent controller: it starts (or respawns) the CLI and carries the message on its input.
dispatch_session_agent 🔒
ACP agents (Copilot, OpenClaw, Pi) and Muse Code (MSP): the message becomes a prompt (a turn) on the agent’s running session. If the agent’s process exited or crashed, this starts it again from the pane’s meta; the message waits for the new session.
dispatch_subprocess 🔒
Dispatch to a per-turn subprocess controller (a host CLI, or a Docker exec for a container agent).
gated_spawn_env 🔒
The spawn environment, after the single-live-instance check and the identity gate.
id_bearing_suffix 🔒
The trailing part of a send-copy’s host path that carries its attachment id: <sha256>.… for an image or other derived file (prompt.rs’s module doc), or named/<sha256>/<realname> for any other kind. None for a path with neither shape — a send-copy always has one, so this only trips on a path this function doesn’t recognize, which must not be guessed at.
is_sha256_hex 🔒
prepare_attachments 🔒
The attachments of a message: a numbered list appended to the text, and the inline images for a persistent Claude.
refuse_retired_harness 🔒
A pane opened with a harness AgentMux no longer offers runs no more turns: it is told why, in the pane, and nothing starts. The pane records the provider and the output format it was opened with, so a pane that was running before the harness was removed (or restored from a layout saved before) is recognised without its agent definition. Every turn path asks this first: subprocess, persistent, app-server and ACP alike.
register_turn_agent 🔒
Register the agent with the cloud subscriber and the reactive handler, so cloud-injected messages reach it.
rehome_for_container 🔒
Copy each resolved attachment’s send-copy from its host path into host_cwd (the pane’s working folder) and point it at the container-side path instead (narko #198 piece 2): a container agent can open a file under its workspace mount, never a bare host path. The copy keeps the exact trailing path id_bearing_suffix finds — <sha256>.… for an image/derived file, named/<sha256>/<realname> for any other kind — the same two shapes the composer’s reload parser (ID_RE, attached-images.ts) and the image counter (images_in_text, transcript/images.rs) already recognize (#7434): renaming to the display name instead would make every container attachment unrecognizable to both on reload. A path with neither shape, or a copy that fails, joins missing, the same treatment a send-copy swept by retention gets.
rehome_one 🔒
Copies host_path’s send-copy into host_cwd’s CONTAINER_ATTACHMENTS_SUBDIR, keeping the exact id-bearing suffix id_bearing_suffix finds, and returns the container-side path string. None when host_path carries no recognizable id, or the copy fails — logged either way, so a caller that only has a name to report (missing) still has the reason in the log.
rehome_text_companion 🔒
Rewrites a text version: <path> segment of a document’s note to the container-side path rehome_one copied it to, keeping the rest of the note (page count, “contains macros”) as is. Drops just that segment, rather than leaving a host path, when the companion carries no recognizable id or its copy fails. Matches only a segment that STARTS WITH the marker, never a bare substring: file_note’s failure note reads “no text version: {e}”, which contains “text version: “ too but names no path to rehome — matching that would delete the error text instead (#2586). A note with neither segment shape (an image’s note is always None) is unchanged.
runtime_for_turn 🔒
The container runtime a container agent’s turn runs in, or the reason there is none. The reason is written to the pane like every other refusal before a process starts: otherwise the turn returns an error nobody sees and the pane shows work that never happens.
spawn_base 🔒
Re-read the spawn config from block metadata.
surface_refusal 🔒
Show a refusal that happened before any process ran in the pane: the raw frame in the output log, plus the classified failure the recovery row reads.