Documentation
¶
Overview ¶
Package shell implements shell execution and tool-bash, matching shell/shell, bash-local, bash-sandbox, and tool-bash (M37). Requests resolve to explicit specs. Results keep exitCode, signal, timedOut, aborted, and timeoutMs independent. Foreground execution uses subprocess with a 64 KB inline limit and complete spill streams; background execution uses jobs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatOutput ¶
func FormatOutput(r *BashResult) string
FormatOutput formats model-facing text with spill-reading guidance when truncated.
Types ¶
type BashResult ¶
type BashResult struct {
// Output is inline output, potentially truncated to its tail.
Output string `json:"output"`
// Truncated indicates output truncation.
Truncated bool `json:"truncated"`
// SpillPath points to the complete stream when truncated.
SpillPath string `json:"spillPath,omitempty"`
// Result records execution facts.
Result RunResult `json:"result"`
}
BashResult is the model-facing tool-bash result.
type BashTool ¶
type BashTool struct {
// contains filtered or unexported fields
}
BashTool implements the tool using Shell.
func (*BashTool) Exec ¶
func (b *BashTool) Exec(req ExecRequest) (*BashResult, error)
Exec executes a command and returns a model-facing result.
type ExecRequest ¶
type ExecRequest struct {
// Command is the command text to execute.
Command string
// Cwd is the working directory; empty inherits it.
Cwd string
// TimeoutMs is the timeout in milliseconds; nonpositive disables it.
TimeoutMs int
// Env adds environment variables.
Env map[string]string
}
ExecRequest describes a shell execution request.
type ExecSpec ¶
type ExecSpec struct {
// Argv wraps the command in bash -c, cmd /c, or PowerShell.
Argv []string
// Cwd is the working directory.
Cwd string
// TimeoutMs is the timeout.
TimeoutMs int
// Env adds environment variables.
Env map[string]string
// SandboxMode is the effective read-only, workspace-write, or danger mode.
SandboxMode string
}
ExecSpec is the fully resolved execution specification.
type RunResult ¶
type RunResult struct {
// ExitCode may be -1 for signal termination or abnormal exit.
ExitCode int `json:"exitCode"`
Signal string `json:"signal,omitempty"`
// TimedOut indicates forced termination due to timeout.
TimedOut bool `json:"timedOut"`
// Aborted indicates termination due to cancellation.
Aborted bool `json:"aborted"`
// TimeoutMs is the configured timeout in milliseconds; zero means unset.
TimeoutMs int `json:"timeoutMs"`
}
RunResult records five independent execution outcome fields.
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell executes shell commands.
func New ¶
New creates a shell with read-only, workspace-write, or danger mode; empty defaults to workspace-write.
func (*Shell) Resolve ¶
func (s *Shell) Resolve(req ExecRequest) ExecSpec
Resolve converts a command into an execution specification.
func (*Shell) Run ¶
func (s *Shell) Run(req ExecRequest) (RunResult, BashResult, error)
Run waits for foreground execution and returns outcome and collected output.