Bash
Run a command via bash -c. Foreground mode blocks until completion or timeout. Background mode returns a shell_id immediately and the command keeps running until it finishes or is killed.
Schema
Section titled “Schema”| Param | Type | Required | Default | Notes |
|---|---|---|---|---|
command | string | yes | — | The command to run. |
description | string | yes | — | 5–10 word description. Recorded for agent context only. |
timeout | number | no | 120 (fg) | Seconds. Clamped to 600. Ignored in background mode. |
run_in_background | boolean | no | false | If true, returns a shell_id and runs asynchronously. |
Foreground mode
Section titled “Foreground mode”- Runs from the workspace root.
stdinis closed.- Environment inherits the server process (the container runtime is responsible for scrubbing secrets at launch).
Setpgid+cmd.Cancelwithsyscall.Kill(-pid, SIGKILL)means the whole process group is killed on timeout — backgrounded children won’t survive.cmd.WaitDelay = 2slets pipes drain after SIGKILL.- Output is
CombinedOutput-merged stdout+stderr, capped at 100 KiB. - A trailing
exit: Nline is emitted for non-zero exits. - On timeout:
bash: timed out after Nsmarker andexit: 124(matchestimeout(1)).
Output example (failure + timeout)
Section titled “Output example (failure + timeout)”some stdoutsome stderr interleavedbash: timed out after 2sexit: 124Background mode
Section titled “Background mode”Set run_in_background: true. The handler:
- Runs the denylist check.
- Spawns the command with
Setpgidso the whole descendant group can be killed together. - Registers a
BackgroundShellin the per-sandboxShellRegistrywith a fresh UUID. - Starts goroutines draining stdout/stderr into capped (1 MiB each) buffers.
- Returns immediately:
shell_id: 2b1d94c0-...-e6started in background: npm run buildUse BashOutput to poll the shell’s status and KillShell to terminate it.
Denylist
Section titled “Denylist”A regex guard rejects commands that look like obvious footguns BEFORE they run. Tokens caught at plausible command positions (start-of-string, after ;, &, |, ():
sudo,sushutdown,reboot,halt,poweroffchrootmount,umountmkfs(and variants likemkfs.ext4)
Limits:
- Quoted subcommands (
bash -c "sudo ...") are deliberately NOT caught to avoid false positives onecho "don't sudo". $(echo sudo)whoamibypasses trivially — the container is the real trust boundary.- Case-sensitive. Non-ASCII whitespace isn’t matched as a boundary.
Related
Section titled “Related”- BashOutput — poll a background shell.
- KillShell — terminate a background shell.
- Bash denylist — full list and bypass discussion.