Documentation
¶
Overview ¶
Package shellrun is the one runner for every sh -c command celeste starts: the bash tool (through builtin.RunShell, which checks the denylist first), user-authored custom tools and the agent's --verify-cmd; Args runs a program directly (the agent's artifact git calls). Each run gets its own process group, killed whole on timeout, a bounded wait for whatever still holds the output pipe, and an output cap.
Index ¶
Constants ¶
const DefaultMaxOutput = 64_000
DefaultMaxOutput applies when Options.MaxOutput is not set.
const DefaultTimeout = 20 * time.Second
DefaultTimeout applies when Options.Timeout is not set.
const WaitDelay = 2 * time.Second
WaitDelay bounds how long a finished or killed shell's output pipes may stay open (a grandchild holding them).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Dir string
Command string // run with sh -c
Args []string // non-empty: run Args[0] with Args[1:] directly, no shell; Command is ignored
Stdin []byte // nil: no stdin
Env []string // nil: this process's environment
Timeout time.Duration // <= 0: DefaultTimeout
MaxOutput int // <= 0: DefaultMaxOutput
// Policy, when enabled and an OS sandbox is available, runs Command
// inside it (2.0 W4). nil or disabled: plain sh -c. Ignored with Args.
Policy *sandbox.Policy
}
Options is one shell command for Run.
type Result ¶
type Result struct {
Output string // combined stdout+stderr, capped at MaxOutput
Truncated bool
ExitCode int // -1 when the command was blocked, did not start or was killed
TimedOut bool
Blocked string // set only by callers that check a denylist first; nothing ran
Err error // start or wait error other than a non-zero exit or the timeout
Sandbox string // the OS sandbox the command ran in ("seatbelt", "bubblewrap"); "" for none
Hint string // a failed sandboxed command that looks blocked: the sandbox and the key to change
}
Result is what Run observed.
func Run ¶
Run runs Command with sh -c (or Args directly) in its own process group, killed whole on timeout. It applies no denylist: callers that run model-chosen commands check one first (builtin.RunShell). A background process still holding the output pipes after the shell exits gets WaitDelay, whatever the shell's exit status; then the group is killed, the pipe is closed, and Err says so. A background process that redirected its output does not hold the pipes and keeps running.