The bash tool lives in packages/coding-agent/src/core/tools/bash.ts and is still a full implementation exported via createBashToolDefinition and createLocalBashOperations, even though it is no longer registered as a built-in ToolName in the tools index — it remains available for extensions that import it directly.[1] createLocalBashOperations is the standard local-shell backend, intended for extensions that intercept user_bash but still want prime-agent's standard shell behavior while wrapping or rewriting commands.[1]
The BashToolInput schema accepts a required command: string and an optional timeout: number (in seconds; no default timeout is applied).[1] The tool description exposed to the model states that output is truncated to the last DEFAULT_MAX_LINES lines or DEFAULT_MAX_BYTES / 1024 KB — whichever is hit first — and that the full output is saved to a temp file when truncated.[1]
The BashToolOptions interface supports four extension points: operations (pluggable exec backend), commandPrefix (prepended to every command), shellPath (explicit shell binary), and spawnHook (mutate command, cwd, or env before execution).[1] BashSpawnHook is typed as (context: BashSpawnContext) => BashSpawnContext, where BashSpawnContext carries command, cwd, and env; the hook can rewrite any of these fields before the process is spawned.[1]
createLocalBashOperations rejects command execution with an error if the working directory does not exist at spawn time.[1] Local bash processes are spawned with detached: process.platform !== 'win32', and their PIDs are tracked via trackDetachedChildPid / untrackDetachedChildPid to prevent the parent from hanging on stdio handles inherited by detached descendants.[1] Abort signals sent to the local bash backend kill the entire process tree via killProcessTree, not just the immediate child process.[1] The bash tool's kernel-side implementation is asynchronous, executing shell commands through a Python-side backend so that long-running commands do not block the event loop, enabling non-blocking REPL operations. Asynchronous bash execution and orphan-process tracking required updates across src/core/kernel/bootstrap.ts, src/core/kernel/state-snapshot.ts, src/modes/daemon/daemon-supervisor.ts, src/cli/owned-session-worker.ts, and orphan-process-journal.ts. The Python-side bash tool in prime-agent-runtime/src/rlm/bash.py emits an ordered completion sentinel at the end of command output; without it, output lines could arrive out of order relative to the completion signal, causing apparent truncation of results. In packages/coding-agent/src/core/agent-session.ts, each executeBash call receives a dedicated AbortController instance, so aborting one command does not cancel sibling or subsequent commands in the same session.
Sources