Skip to main content

Module shell_handlers

Module shell_handlers 

Source

ConstantsΒ§

MAX_OUTPUT πŸ”’
1 MB cap per stream β€” bounds memory for runaway commands (! yes, ! dd if=/dev/zero).
TIMEOUT_SECS πŸ”’
300s process timeout matches the frontend’s RPC timeout so the client sees a clean error rather than a silent EC-TIME.

FunctionsΒ§

collect_host_output πŸ”’
Reads both streams (capped) and waits for the child, all under the timeout. The outer Err is the timeout.
container_exec_collect πŸ”’
Runs command in the agent’s container and collects both streams, capped at MAX_OUTPUT + 1 bytes each. Returns the exec id (for the exit code) and the two buffers.
format_output πŸ”’
Shared output formatter: if we accumulated more than MAX_OUTPUT bytes, the stream was truncated β€” append a notice.
host_command πŸ”’
The sh -c <command> process for a host !cmd, with its stdio, kill and process-group settings.
host_working_dir πŸ”’
The working directory a host !cmd runs in: absolute, symlinks resolved.
register_shell_handlers
shell_exec πŸ”’
shellexec β†’ run a shell command and return output. Invoked by the !cmd prefix in the agent pane composer.
shell_exec_container πŸ”’
── Container agents ─────────────────────────────────────────
shell_exec_host πŸ”’
── Host agents ───────────────────────────────────────────────
shell_status πŸ”’
shellstatus β†’ query a shell’s current running state. Used by useShellNodeStream to resolve the TRUE status of a shell whose shell_node_create event is being replayed on pane mount/reconnect (persist:64 ring), instead of assuming β€œrunning” β€” the frontend can’t otherwise tell a live spawn apart from a replay of an already-long- exited shell, which was flashing stale rows in the Activity Dock. See docs/retro/retro-activity-dock-stale-shell-flash-on-load-2026-08-22.md.
shell_stop πŸ”’
shellstop β†’ tree-kill a running persistent shell node (Phase 3). Invoked by the UI stop button on a running PersistentShellBlock. The runner then publishes a stopped exit event.