Expand description
Shell/process manager.
Runs commands from the workspace root with output streaming, timeouts, cancellation, and a process registry that tracks active commands.
§Design
- Commands run from the workspace root by default. An optional
cwdcan be specified relative to the root; paths escaping the root are rejected. - Output is captured from piped stdout/stderr. The blocking read happens on a worker thread; the TUI drains the result through the normal tool event channel so it never blocks.
- Timeouts kill the process and produce a
Timeoutstatus. - Cancellation is cooperative: a shared
CancelTokenis checked by the worker thread between reads; when signalled the process is killed and the result is recorded asCancelled. - A
ProcessRegistrytracks active commands, separating one-shot commands (waited on for completion) from long-lived background processes. A background child gets an independent cancellation handle, stays owned by the registry after the tool call returns, and is reaped on completion, explicit cancellation, application quit, or registry drop.
§Safety
fd --exec,rg --pre,sed -i,awk system()and arbitrary shell-string execution are not exposed by this module — the model provides an argv array, never a shell string.- The command runs via
std::process::Commandargv; no/bin/sh -c. - stdout/stderr bytes are capped at
MAX_OUTPUT_BYTES; lines truncate atMAX_LINE_LEN. - Paths are contained to the workspace root.
Structs§
- Active
Process - A process snapshot returned by the registry.
- Process
Output - A bounded snapshot of output retained for an active process.
- Process
Registry - Registry of active processes.
- Process
Result - Structured result of a process execution.
- Shell
Args - Arguments for a shell command execution.
Enums§
- Process
Kind - Whether a command is a one-shot (waited for completion) or a long-lived background process (tracked separately by the registry).
- Process
Status - Process lifecycle status recorded by the registry and in the transcript.
Constants§
Functions§
- definition
- Provider-visible definition for
run_shell. - execute_
request - Execute a registry request for
run_shell. - execute_
request_ with_ cancel - Execute a
run_shellrequest with the cancellation token for its enclosing agent run. - execute_
request_ with_ cancel_ and_ registry - Execute a
run_shellrequest with cancellation and an optional application-owned background-process registry. - parse_
arguments - Parse provider JSON arguments for
run_shell. - redact_
secrets - Redact known secret patterns from a line of command output.
- run_
command - Run a shell command with streaming output capture, timeout, and cancellation.
- run_
command_ with_ registry - Execute a shell command, handing background ownership to
registry.