Documentation
¶
Overview ¶
Package tools exposes a stable public-API surface over the built-in tool implementations that ship with claw-code-go. Internal tool packages live under internal/ and cannot be imported from outside the module — this wrapper makes them callable by external consumers (e.g. iterion) without leaking internal types beyond what is strictly necessary.
Each tool comes as a pair: a `XxxTool() api.Tool` returning the schema and description the model needs to call the tool, and an `ExecuteXxx` function that runs the tool with the parsed input arguments. Consumers register these against their own LLM client / workflow engine.
The bash tool is special: the underlying executor needs a permission mode and a workspace root for command validation. The public wrapper pins permissions.ModeAllow (no policy gating) and forwards the workspace argument; consumers that want a stricter policy should reach for the internal API directly via the same module.
Index ¶
- Variables
- func AgentTool() api.Tool
- func AllowedToolsForSubagent(subagentType string) map[string]bool
- func AskUserQuestionTool() api.Tool
- func BashTool() api.Tool
- func ComputerUseTool() api.Tool
- func ConfigTool() api.Tool
- func CronCreateTool() api.Tool
- func CronDeleteTool() api.Tool
- func CronGetTool() api.Tool
- func CronListTool() api.Tool
- func EnterPlanModeTool() api.Tool
- func ExecuteAgent(ctx context.Context, input map[string]any) (string, error)
- func ExecuteAskUser(ctx context.Context, asker Asker, input map[string]any) (string, error)
- func ExecuteBash(ctx context.Context, input map[string]any, workspace string) (string, error)
- func ExecuteBashWithEnv(ctx context.Context, input map[string]any, workspace string, extraEnv []string) (string, error)
- func ExecuteConfig(ctx context.Context, input map[string]any, configMap map[string]any) (string, error)
- func ExecuteCronCreate(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)
- func ExecuteCronDelete(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)
- func ExecuteCronGet(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)
- func ExecuteCronList(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)
- func ExecuteEnterPlanMode(ctx context.Context, input map[string]any, state *PlanModeState) (string, error)
- func ExecuteExitPlanMode(ctx context.Context, input map[string]any, state *PlanModeState) (string, error)
- func ExecuteFileEdit(ctx context.Context, input map[string]any) (string, error)
- func ExecuteGlob(ctx context.Context, input map[string]any) (string, error)
- func ExecuteGrep(ctx context.Context, input map[string]any) (string, error)
- func ExecuteLSP(ctx context.Context, input map[string]any, registry *lsp.Registry) (string, error)
- func ExecuteListMcpResources(ctx context.Context, input map[string]any, provider mcp.Provider) (string, error)
- func ExecuteMcpAuth(ctx context.Context, input map[string]any, provider mcp.Provider) (string, error)
- func ExecuteNotebookEdit(ctx context.Context, input map[string]any) (string, error)
- func ExecuteREPL(ctx context.Context, input map[string]any) (string, error)
- func ExecuteReadFile(ctx context.Context, input map[string]any) (string, error)
- func ExecuteReadMcpResource(ctx context.Context, input map[string]any, provider mcp.Provider) (string, error)
- func ExecuteRemoteTrigger(ctx context.Context, input map[string]any) (string, error)
- func ExecuteRunTaskPacket(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)
- func ExecuteSendUserMessage(ctx context.Context, input map[string]any) (string, error)
- func ExecuteSkill(ctx context.Context, input map[string]any, workDir string) (string, error)
- func ExecuteSleep(ctx context.Context, input map[string]any) (string, error)
- func ExecuteStructuredOutput(ctx context.Context, input map[string]any) (string, error)
- func ExecuteTaskCreate(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)
- func ExecuteTaskGet(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)
- func ExecuteTaskList(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)
- func ExecuteTaskOutput(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)
- func ExecuteTaskStop(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)
- func ExecuteTaskUpdate(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)
- func ExecuteTeamCreate(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)
- func ExecuteTeamDelete(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)
- func ExecuteTeamGet(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)
- func ExecuteTeamList(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)
- func ExecuteTodoWrite(ctx context.Context, input map[string]any) (string, error)
- func ExecuteToolSearch(ctx context.Context, input map[string]any, allTools []api.Tool) (string, error)
- func ExecuteWebFetch(ctx context.Context, input map[string]any) (string, error)
- func ExecuteWebSearch(ctx context.Context, input map[string]any) (string, error)
- func ExecuteWorkerAwaitReady(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerCreate(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerGet(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerObserve(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerObserveCompletion(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerResolveTrust(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerRestart(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerSendPrompt(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWorkerTerminate(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)
- func ExecuteWriteFile(ctx context.Context, input map[string]any) (string, error)
- func ExitPlanModeTool() api.Tool
- func FileEditTool() api.Tool
- func GlobTool() api.Tool
- func GrepTool() api.Tool
- func ListMcpResourcesTool() api.Tool
- func LspTool() api.Tool
- func McpAuthTool() api.Tool
- func NewProgrammaticAsker(h func(ctx context.Context, q Question) (Answer, error)) *intl.ProgrammaticAsker
- func NewStdinAsker() *intl.StdinAsker
- func NotebookEditTool() api.Tool
- func REPLTool() api.Tool
- func ReadFileTool() api.Tool
- func ReadImageTool() api.Tool
- func ReadMcpResourceTool() api.Tool
- func RemoteTriggerTool() api.Tool
- func RunTaskPacketTool() api.Tool
- func ScreenshotTool() api.Tool
- func SendUserMessageTool() api.Tool
- func SkillTool() api.Tool
- func SleepTool() api.Tool
- func StructuredOutputTool() api.Tool
- func TaskCreateTool() api.Tool
- func TaskGetTool() api.Tool
- func TaskListTool() api.Tool
- func TaskOutputTool() api.Tool
- func TaskStopTool() api.Tool
- func TaskUpdateTool() api.Tool
- func TeamCreateTool() api.Tool
- func TeamDeleteTool() api.Tool
- func TeamGetTool() api.Tool
- func TeamListTool() api.Tool
- func TodoWriteTool() api.Tool
- func ToolSearchTool() api.Tool
- func WebFetchTool() api.Tool
- func WebSearchTool() api.Tool
- func WorkerAwaitReadyTool() api.Tool
- func WorkerCreateTool() api.Tool
- func WorkerGetTool() api.Tool
- func WorkerObserveCompletionTool() api.Tool
- func WorkerObserveTool() api.Tool
- func WorkerResolveTrustTool() api.Tool
- func WorkerRestartTool() api.Tool
- func WorkerSendPromptTool() api.Tool
- func WorkerTerminateTool() api.Tool
- func WriteFileTool() api.Tool
- type AgentSpec
- type Answer
- type Asker
- type ComputerUseResult
- type Option
- type PlanModeState
- type Question
- type ReadImageResult
Constants ¶
This section is empty.
Variables ¶
ErrComputerUseUnavailable is returned (wrapped) when the host environment cannot support computer-use actions: no display server, missing required binaries (xdotool, ImageMagick `import`), or unsupported OS. Use errors.Is to detect.
var ErrNoAsker = intl.ErrNoAsker
ErrNoAsker is returned by ExecuteAskUser when no Asker is wired.
Functions ¶
func AgentTool ¶
AgentTool returns the subagent-spawn tool. The internal executor only validates and returns metadata; orchestration is the host's job (iterion's claw backend already routes tool_use back).
func AllowedToolsForSubagent ¶
AllowedToolsForSubagent returns the set of tool names a subagent of the given type is permitted to call. Returns nil for the "general-purpose" / unrecognised types — a nil map signals "no restriction" to callers.
func AskUserQuestionTool ¶
AskUserQuestionTool returns the schema for the ask_user tool.
func ComputerUseTool ¶
ComputerUseTool returns the tool definition for the computer_use tool. Action verbs mirror Anthropic's computer_use_20241022 spec: screenshot, left_click, right_click, middle_click, double_click, type, key, mouse_move, cursor_position, left_click_drag.
func ConfigTool ¶
ConfigTool returns the `config` tool that reads from a host-supplied configuration map. Hosts wire it via ExecuteConfig with a populated map; without a map the tool returns "no configuration available".
func CronCreateTool ¶
func CronDeleteTool ¶
func CronGetTool ¶
func CronListTool ¶
func EnterPlanModeTool ¶
func ExecuteAskUser ¶
ExecuteAskUser runs the ask_user tool with the supplied Asker.
func ExecuteBash ¶
ExecuteBash runs the bash command at input["command"]. Workspace is the directory used for command validation; pass an empty string to skip workspace-based validation entirely. Permission mode is fixed to ModeAllow — the wrapper assumes the caller has already gated invocations upstream (e.g. via an iterion workflow's allowed-tools list).
The spawned bash inherits the calling process's environment. When the caller manages a project-local toolchain (devbox, nix, asdf) whose bin path is absent from the parent shell's PATH, use ExecuteBashWithEnv to surface it explicitly.
func ExecuteBashWithEnv ¶
func ExecuteBashWithEnv(ctx context.Context, input map[string]any, workspace string, extraEnv []string) (string, error)
ExecuteBashWithEnv runs the bash command with extra environment entries (KEY=value format) appended to the inherited environment. Permission mode is fixed to ModeAllow as in ExecuteBash. Pass nil extraEnv for plain inheritance (equivalent to ExecuteBash).
Typical use: an iterion CLI launched outside its devbox shell can pass the devbox bin directory via extraEnv so the LLM-driven fixer can run `go test` / `gofmt` against the project toolchain even when the operator forgot to prefix the run with `devbox run --`.
func ExecuteConfig ¶
func ExecuteConfig(ctx context.Context, input map[string]any, configMap map[string]any) (string, error)
ExecuteConfig reads a value out of `configMap` for the requested key.
func ExecuteCronCreate ¶
func ExecuteCronDelete ¶
func ExecuteCronGet ¶
func ExecuteCronList ¶
func ExecuteEnterPlanMode ¶
func ExecuteExitPlanMode ¶
func ExecuteFileEdit ¶
ExecuteFileEdit applies the requested edit at input["path"].
func ExecuteGlob ¶
ExecuteGlob expands input["pattern"] into matching paths.
func ExecuteGrep ¶
ExecuteGrep runs a ripgrep-style search using the input arguments.
func ExecuteLSP ¶
func ExecuteListMcpResources ¶
func ExecuteMcpAuth ¶
func ExecuteNotebookEdit ¶
func ExecuteReadFile ¶
ExecuteReadFile reads the file at input["path"] and returns its contents.
func ExecuteReadMcpResource ¶
func ExecuteRemoteTrigger ¶
func ExecuteRunTaskPacket ¶
func ExecuteSendUserMessage ¶
func ExecuteSkill ¶
ExecuteSkill loads a skill from <workDir>/.claude/skills. Pass an empty workDir to use the process CWD.
func ExecuteStructuredOutput ¶
func ExecuteTaskCreate ¶
func ExecuteTaskGet ¶
func ExecuteTaskList ¶
func ExecuteTaskOutput ¶
func ExecuteTaskStop ¶
func ExecuteTaskUpdate ¶
func ExecuteTeamCreate ¶
func ExecuteTeamDelete ¶
func ExecuteTeamGet ¶
func ExecuteTeamList ¶
func ExecuteTodoWrite ¶
func ExecuteToolSearch ¶
func ExecuteToolSearch(ctx context.Context, input map[string]any, allTools []api.Tool) (string, error)
ExecuteToolSearch ranks `allTools` against input["query"]. Hosts pass the full set of tools registered for the current agent so the search has the right haystack.
func ExecuteWebFetch ¶
ExecuteWebFetch performs an HTTP GET for input["url"] and returns the body.
func ExecuteWebSearch ¶
ExecuteWebSearch reads BRAVE_API_KEY (or compatible) from env; absence surfaces as a tool error to the model.
func ExecuteWorkerAwaitReady ¶
func ExecuteWorkerCreate ¶
func ExecuteWorkerGet ¶
func ExecuteWorkerObserve ¶
func ExecuteWorkerRestart ¶
func ExecuteWorkerSendPrompt ¶
func ExecuteWorkerTerminate ¶
func ExecuteWriteFile ¶
ExecuteWriteFile writes input["content"] to input["path"], creating parent directories as needed.
func ExitPlanModeTool ¶
func FileEditTool ¶
FileEditTool returns the tool definition for in-place file editing (string replacement with optional replace_all semantics).
func ListMcpResourcesTool ¶
func McpAuthTool ¶
func NewProgrammaticAsker ¶
func NewProgrammaticAsker(h func(ctx context.Context, q Question) (Answer, error)) *intl.ProgrammaticAsker
NewProgrammaticAsker wraps a handler closure as an Asker.
func NewStdinAsker ¶
func NewStdinAsker() *intl.StdinAsker
NewStdinAsker returns an Asker bound to os.Stdin / os.Stdout.
func NotebookEditTool ¶
func ReadFileTool ¶
ReadFileTool returns the tool definition for reading files.
func ReadImageTool ¶
ReadImageTool returns the tool definition for loading an image into the conversation as a vision content block.
func ReadMcpResourceTool ¶
func RemoteTriggerTool ¶
func RunTaskPacketTool ¶
func ScreenshotTool ¶
ScreenshotTool returns the tool definition for capturing a screenshot. Backed by ImageMagick `import` on Linux/X11; returns ErrComputerUseUnavailable when prerequisites are missing.
func SendUserMessageTool ¶
func StructuredOutputTool ¶
func TaskCreateTool ¶
func TaskGetTool ¶
func TaskListTool ¶
func TaskOutputTool ¶
func TaskStopTool ¶
func TaskUpdateTool ¶
func TeamCreateTool ¶
func TeamDeleteTool ¶
func TeamGetTool ¶
func TeamListTool ¶
func TodoWriteTool ¶
func ToolSearchTool ¶
func WebFetchTool ¶
WebFetchTool returns the tool definition for fetching URLs.
func WebSearchTool ¶
func WorkerAwaitReadyTool ¶
func WorkerCreateTool ¶
func WorkerGetTool ¶
func WorkerObserveTool ¶
func WorkerResolveTrustTool ¶
func WorkerRestartTool ¶
func WorkerSendPromptTool ¶
func WorkerTerminateTool ¶
func WriteFileTool ¶
WriteFileTool returns the tool definition for writing files.
Types ¶
type AgentSpec ¶
AgentSpec is the validated form of agent tool input. Hosts that override the default (metadata-only) agent executor with a real subagent runner use ValidateAgentInput to parse the raw input map before spawning the child loop.
type Asker ¶
Asker is the interface SDK consumers implement to deliver a question to a human (or a simulated batch source) and return the answer.
type ComputerUseResult ¶
type ComputerUseResult = intl.ComputerUseResult
ComputerUseResult is the typed payload of ExecuteComputerUse. For screenshot actions, Blocks holds a single image ContentBlock and Description is "screenshot". For input actions (click / type / key / mouse_move / cursor_position / left_click_drag), Blocks is empty and Description holds a short success summary.
func ExecuteComputerUse ¶
ExecuteComputerUse dispatches the action verb in input["action"] to the matching backend handler. See ComputerUseTool for the schema.
type PlanModeState ¶
PlanModeState is the mutable flag + on-disk state directory shared by enter_plan_mode and exit_plan_mode so they can coordinate.
type ReadImageResult ¶
type ReadImageResult = intl.ReadImageResult
ReadImageResult is the typed payload of ExecuteReadImage. Blocks contains a single vision ContentBlock that callers can splice into a tool_result content list bound for the next user-turn message.
func ExecuteReadImage ¶
ExecuteReadImage loads an image from input["path"] (local file) or input["url"] (HTTPS only) and returns it as a base64 vision block. Maximum size is 5 MB.
func ExecuteScreenshot ¶
ExecuteScreenshot captures the host display and returns it as a base64-encoded image content block. Equivalent to ExecuteComputerUse with action="screenshot".