Documentation
¶
Overview ¶
Package runshell implements the sandboxed run_shell tool definition and executor. The unsandboxed run_unsafe_shell tool lives in internal/tools/rununsafeshell.
Execute runs a bash command inside the sandbox. Output is truncated at maxOutputBytes (preserving valid UTF-8 boundaries) and each command is killed after commandTimeout.
Index ¶
Constants ¶
const ( // CommandTimeout is the maximum wall-clock time a single shell // command is allowed to run before being killed. CommandTimeout = 30 * time.Second // MaxOutputBytes limits captured stdout+stderr to avoid sending // excessively large tool results back to the API. MaxOutputBytes = 10240 )
const ToolName = "run_shell"
ToolName is the model-facing name of the sandboxed shell tool.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute(ctx context.Context, sb sandbox.Sandbox, command string, restart bool, timeoutSeconds int) (output string, isError bool)
Execute runs a sandboxed shell command. If restart is true, command is ignored and a restart acknowledgment is returned. timeoutSeconds is the per-invocation override in seconds; zero or negative falls back to CommandTimeout (see Timeout). Errors from the underlying process surface as (output, isError=true); timeout output is substituted for the command's own output when the deadline fires.
func Run ¶
Run executes cmd, killing it if ctx fires before it finishes. timeout is the effective timeout used only to render an accurate "Command timed out" message; the actual deadline is enforced by ctx. The returned output combines stdout+stderr, truncated at MaxOutputBytes on a valid UTF-8 boundary. Exported so internal/tools/rununsafeshell and internal/tools/skill can reuse it.
func Timeout ¶
Timeout returns the effective per-command timeout: seconds converted to a time.Duration capped at maxTimeout (30m) when positive, or CommandTimeout as the default when seconds is zero or negative. This is the single source of the "override or default" decision, shared by run_shell and run_unsafe_shell.
func ToolDef ¶
func ToolDef() tooldef.Definition
ToolDef returns the jungi tool definition for the sandboxed shell.
Types ¶
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool implements tool.Tool for the run_shell tool. It binds the sandbox the command runs inside; the per-invocation command and restart flag come from the request (pre-parsed by the client into Command/Restart).
func New ¶
New returns a run_shell Tool that runs commands inside sb.
func (*Tool) Definition ¶
func (*Tool) Definition() tooldef.Definition
Definition delegates to the package-level ToolDef so the advertised definition stays identical whether or not a Tool has been constructed.
func (*Tool) Execute ¶
Execute runs the command (or restarts the session) and labels the event: the restart variant is surfaced via Variant; otherwise the command is the Subject. Display equals the model output.
Source Files
¶
- proc_unix.go
- runshell.go