Skip to main content

Module spawn

Module spawn 

Source
Expand description

Agent spawn orchestration.

Renders the full system prompt, writes it to a per-agent file under ~/.netsky/state/prompts/<session>.md, writes a per-agent MCP config, asks the configured runtime to assemble its claude/codex/… command line, then delegates to netsky_sh::tmux to create the detached tmux session with AGENT_N + NETSKY_PROMPT_FILE (the path, not the content) propagated via -e.

The shell that tmux launches reads the prompt content at exec time via $(cat "$NETSKY_PROMPT_FILE"). This indirection exists because tmux’s command parser rejects oversized argv elements with “command too long” — passing the 20KB+ rendered prompt directly through -e NETSKY_PROMPT=<content> took down every agent0 restart in session-11 (see INFINITY_EMERGENCY_FIX.md).

Single code path for agent0, clones, and agentinfinity. Per-agent differences (MCP servers, channel flags) live here; runtime-flavor differences (CLI syntax) live in crate::runtime.

Structs§

SpawnOptions
Per-spawn options. Runtime-agnostic: the runtime field owns flavor-specific config (claude model + effort, codex knobs, …).

Enums§

SpawnOutcome
Spawn outcome for idempotent callers.

Functions§

dismiss_tos
Dismiss the Claude dev-channels TOS dialog on session by sending Enter once the prompt is visible. Polls for up to timeout at 1Hz. Returns true iff the prompt was seen and Enter was delivered.
is_up
True if the tmux session for agent already exists.
kill
Tear down agent’s tmux session if present. Idempotent.
require_deps
Verify the runtime deps the default claude runtime requires. Kept for call sites (e.g. the restart path) that don’t yet thread a SpawnOptions through.
require_deps_for
Verify the runtime deps the configured flavor requires.
spawn
Idempotently spawn agent in a detached tmux session.