Documentation
¶
Index ¶
- Constants
- func CreateScriptToolSet(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error)
- func CreateToolSet(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error)
- func RunAskpassClient(ctx context.Context, prompt string, out io.Writer) error
- type RunShellArgs
- type RunShellBackgroundArgs
- type ScriptToolSet
- type StopBackgroundJobArgs
- type ToolSet
- type ViewBackgroundJobArgs
Constants ¶
const ( ToolNameShell = "shell" ToolNameRunShellBackground = "run_background_job" ToolNameListBackgroundJobs = "list_background_jobs" ToolNameViewBackgroundJob = "view_background_job" ToolNameStopBackgroundJob = "stop_background_job" )
const AskpassCommandName = "__askpass"
AskpassCommandName is the hidden CLI subcommand sudo runs (via the generated SUDO_ASKPASS wrapper) to fetch a password. It is exported so the command registration in cmd/root stays in sync with the wrapper script built here.
Variables ¶
This section is empty.
Functions ¶
func CreateScriptToolSet ¶ added in v1.60.0
func CreateScriptToolSet(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error)
CreateScriptToolSet is used by the tools registry.
func CreateToolSet ¶ added in v1.60.0
func CreateToolSet(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error)
CreateToolSet is used by the tools registry.
func RunAskpassClient ¶ added in v1.83.0
RunAskpassClient is the body of the hidden `__askpass` subcommand. sudo runs it (through the generated wrapper script) to obtain a password: it dials the agent's private socket, forwards the prompt, and prints the returned password to out. It returns an error (a non-zero exit, which tells sudo to abort) when the socket is unavailable or the user declines.
Types ¶
type RunShellArgs ¶
type RunShellArgs struct {
Cmd string `json:"cmd" jsonschema:"Shell command"`
Cwd string `json:"cwd,omitempty" jsonschema:"Working directory (default \".\")"`
Timeout int `json:"timeout,omitempty" jsonschema:"Timeout in seconds (default 30)"`
}
func (*RunShellArgs) UnmarshalJSON ¶
func (a *RunShellArgs) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both the canonical "cmd" key and the common alias "command" for the shell command parameter.
The advertised schema still declares "cmd" as the canonical name, but many models (particularly ones biased by Anthropic's built-in bash tool and other ecosystems that use "command") occasionally emit "command" instead. Accepting both prevents a wasted turn on an empty-command error while keeping the canonical contract unchanged. When "cmd" is present with a non-blank value it wins; a blank (empty or whitespace-only) "cmd" falls back to "command" so a valid alias is not silently shadowed.
type RunShellBackgroundArgs ¶
type RunShellBackgroundArgs struct {
Cmd string `json:"cmd" jsonschema:"Shell command to run in background"`
Cwd string `json:"cwd,omitempty" jsonschema:"Working directory (default \".\")"`
}
func (*RunShellBackgroundArgs) UnmarshalJSON ¶
func (a *RunShellBackgroundArgs) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both "cmd" (canonical) and "command" (common alias), mirroring RunShellArgs.UnmarshalJSON. See its comment for rationale.
type ScriptToolSet ¶ added in v1.60.0
type ScriptToolSet struct {
// contains filtered or unexported fields
}
func NewScript ¶ added in v1.60.0
func NewScript(shellTools map[string]latest.ScriptShellToolConfig, env []string) (*ScriptToolSet, error)
func (*ScriptToolSet) Instructions ¶ added in v1.60.0
func (t *ScriptToolSet) Instructions() string
type StopBackgroundJobArgs ¶
type StopBackgroundJobArgs struct {
JobID string `json:"job_id" jsonschema:"Background job ID"`
}
type ToolSet ¶ added in v1.60.0
type ToolSet struct {
// contains filtered or unexported fields
}
ToolSet provides shell command execution capabilities.
func New ¶ added in v1.60.0
func New(env []string, runConfig *config.RuntimeConfig) *ToolSet
New creates a new shell toolset.
func (*ToolSet) Instructions ¶ added in v1.60.0
func (*ToolSet) SetElicitationHandler ¶ added in v1.83.0
func (t *ToolSet) SetElicitationHandler(handler tools.ElicitationHandler)
SetElicitationHandler wires the runtime's elicitation handler into the shell toolset. It is used by the sudo askpass flow to prompt the user for their password. The handler is re-applied at the start of every turn, so this must stay idempotent.
type ViewBackgroundJobArgs ¶
type ViewBackgroundJobArgs struct {
JobID string `json:"job_id" jsonschema:"Background job ID"`
}