tools

package
v0.0.0-...-23898a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ErrComputerUseUnavailable = intl.ErrComputerUseUnavailable

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.

View Source
var ErrNoAsker = intl.ErrNoAsker

ErrNoAsker is returned by ExecuteAskUser when no Asker is wired.

Functions

func AgentTool

func AgentTool() api.Tool

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

func AllowedToolsForSubagent(subagentType string) map[string]bool

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

func AskUserQuestionTool() api.Tool

AskUserQuestionTool returns the schema for the ask_user tool.

func BashTool

func BashTool() api.Tool

BashTool returns the tool definition for executing shell commands.

func ComputerUseTool

func ComputerUseTool() api.Tool

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

func ConfigTool() api.Tool

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 CronCreateTool() api.Tool

func CronDeleteTool

func CronDeleteTool() api.Tool

func CronGetTool

func CronGetTool() api.Tool

func CronListTool

func CronListTool() api.Tool

func EnterPlanModeTool

func EnterPlanModeTool() api.Tool

func ExecuteAgent

func ExecuteAgent(ctx context.Context, input map[string]any) (string, error)

func ExecuteAskUser

func ExecuteAskUser(ctx context.Context, asker Asker, input map[string]any) (string, error)

ExecuteAskUser runs the ask_user tool with the supplied Asker.

func ExecuteBash

func ExecuteBash(ctx context.Context, input map[string]any, workspace string) (string, error)

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 ExecuteCronCreate(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)

func ExecuteCronDelete

func ExecuteCronDelete(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)

func ExecuteCronGet

func ExecuteCronGet(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)

func ExecuteCronList

func ExecuteCronList(ctx context.Context, input map[string]any, reg *team.CronRegistry) (string, error)

func ExecuteEnterPlanMode

func ExecuteEnterPlanMode(ctx context.Context, input map[string]any, state *PlanModeState) (string, error)

func ExecuteExitPlanMode

func ExecuteExitPlanMode(ctx context.Context, input map[string]any, state *PlanModeState) (string, error)

func ExecuteFileEdit

func ExecuteFileEdit(ctx context.Context, input map[string]any) (string, error)

ExecuteFileEdit applies the requested edit at input["path"].

func ExecuteGlob

func ExecuteGlob(ctx context.Context, input map[string]any) (string, error)

ExecuteGlob expands input["pattern"] into matching paths.

func ExecuteGrep

func ExecuteGrep(ctx context.Context, input map[string]any) (string, error)

ExecuteGrep runs a ripgrep-style search using the input arguments.

func ExecuteLSP

func ExecuteLSP(ctx context.Context, input map[string]any, registry *lsp.Registry) (string, error)

func ExecuteListMcpResources

func ExecuteListMcpResources(ctx context.Context, input map[string]any, provider mcp.Provider) (string, error)

func ExecuteMcpAuth

func ExecuteMcpAuth(ctx context.Context, input map[string]any, provider mcp.Provider) (string, error)

func ExecuteNotebookEdit

func ExecuteNotebookEdit(ctx context.Context, input map[string]any) (string, error)

func ExecuteREPL

func ExecuteREPL(ctx context.Context, input map[string]any) (string, error)

func ExecuteReadFile

func ExecuteReadFile(ctx context.Context, input map[string]any) (string, error)

ExecuteReadFile reads the file at input["path"] and returns its contents.

func ExecuteReadMcpResource

func ExecuteReadMcpResource(ctx context.Context, input map[string]any, provider mcp.Provider) (string, error)

func ExecuteRemoteTrigger

func ExecuteRemoteTrigger(ctx context.Context, input map[string]any) (string, error)

func ExecuteRunTaskPacket

func ExecuteRunTaskPacket(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)

func ExecuteSendUserMessage

func ExecuteSendUserMessage(ctx context.Context, input map[string]any) (string, error)

func ExecuteSkill

func ExecuteSkill(ctx context.Context, input map[string]any, workDir string) (string, error)

ExecuteSkill loads a skill from <workDir>/.claude/skills. Pass an empty workDir to use the process CWD.

func ExecuteSleep

func ExecuteSleep(ctx context.Context, input map[string]any) (string, error)

func ExecuteStructuredOutput

func ExecuteStructuredOutput(ctx context.Context, input map[string]any) (string, error)

func ExecuteTaskCreate

func ExecuteTaskCreate(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)

func ExecuteTaskGet

func ExecuteTaskGet(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)

func ExecuteTaskList

func ExecuteTaskList(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)

func ExecuteTaskOutput

func ExecuteTaskOutput(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)

func ExecuteTaskStop

func ExecuteTaskStop(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)

func ExecuteTaskUpdate

func ExecuteTaskUpdate(ctx context.Context, input map[string]any, reg *task.Registry) (string, error)

func ExecuteTeamCreate

func ExecuteTeamCreate(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)

func ExecuteTeamDelete

func ExecuteTeamDelete(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)

func ExecuteTeamGet

func ExecuteTeamGet(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)

func ExecuteTeamList

func ExecuteTeamList(ctx context.Context, input map[string]any, reg *team.TeamRegistry) (string, error)

func ExecuteTodoWrite

func ExecuteTodoWrite(ctx context.Context, input map[string]any) (string, error)

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

func ExecuteWebFetch(ctx context.Context, input map[string]any) (string, error)

ExecuteWebFetch performs an HTTP GET for input["url"] and returns the body.

func ExecuteWebSearch

func ExecuteWebSearch(ctx context.Context, input map[string]any) (string, error)

ExecuteWebSearch reads BRAVE_API_KEY (or compatible) from env; absence surfaces as a tool error to the model.

func ExecuteWorkerAwaitReady

func ExecuteWorkerAwaitReady(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerCreate

func ExecuteWorkerCreate(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerGet

func ExecuteWorkerGet(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerObserve

func ExecuteWorkerObserve(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerObserveCompletion

func ExecuteWorkerObserveCompletion(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerResolveTrust

func ExecuteWorkerResolveTrust(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerRestart

func ExecuteWorkerRestart(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerSendPrompt

func ExecuteWorkerSendPrompt(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWorkerTerminate

func ExecuteWorkerTerminate(ctx context.Context, input map[string]any, reg *worker.WorkerRegistry) (string, error)

func ExecuteWriteFile

func ExecuteWriteFile(ctx context.Context, input map[string]any) (string, error)

ExecuteWriteFile writes input["content"] to input["path"], creating parent directories as needed.

func ExitPlanModeTool

func ExitPlanModeTool() api.Tool

func FileEditTool

func FileEditTool() api.Tool

FileEditTool returns the tool definition for in-place file editing (string replacement with optional replace_all semantics).

func GlobTool

func GlobTool() api.Tool

GlobTool returns the tool definition for filesystem glob matching.

func GrepTool

func GrepTool() api.Tool

GrepTool returns the tool definition for content search.

func ListMcpResourcesTool

func ListMcpResourcesTool() api.Tool

func LspTool

func LspTool() api.Tool

func McpAuthTool

func McpAuthTool() api.Tool

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 NotebookEditTool() api.Tool

func REPLTool

func REPLTool() api.Tool

func ReadFileTool

func ReadFileTool() api.Tool

ReadFileTool returns the tool definition for reading files.

func ReadImageTool

func ReadImageTool() api.Tool

ReadImageTool returns the tool definition for loading an image into the conversation as a vision content block.

func ReadMcpResourceTool

func ReadMcpResourceTool() api.Tool

func RemoteTriggerTool

func RemoteTriggerTool() api.Tool

func RunTaskPacketTool

func RunTaskPacketTool() api.Tool

func ScreenshotTool

func ScreenshotTool() api.Tool

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 SendUserMessageTool() api.Tool

func SkillTool

func SkillTool() api.Tool

func SleepTool

func SleepTool() api.Tool

func StructuredOutputTool

func StructuredOutputTool() api.Tool

func TaskCreateTool

func TaskCreateTool() api.Tool

func TaskGetTool

func TaskGetTool() api.Tool

func TaskListTool

func TaskListTool() api.Tool

func TaskOutputTool

func TaskOutputTool() api.Tool

func TaskStopTool

func TaskStopTool() api.Tool

func TaskUpdateTool

func TaskUpdateTool() api.Tool

func TeamCreateTool

func TeamCreateTool() api.Tool

func TeamDeleteTool

func TeamDeleteTool() api.Tool

func TeamGetTool

func TeamGetTool() api.Tool

func TeamListTool

func TeamListTool() api.Tool

func TodoWriteTool

func TodoWriteTool() api.Tool

func ToolSearchTool

func ToolSearchTool() api.Tool

func WebFetchTool

func WebFetchTool() api.Tool

WebFetchTool returns the tool definition for fetching URLs.

func WebSearchTool

func WebSearchTool() api.Tool

func WorkerAwaitReadyTool

func WorkerAwaitReadyTool() api.Tool

func WorkerCreateTool

func WorkerCreateTool() api.Tool

func WorkerGetTool

func WorkerGetTool() api.Tool

func WorkerObserveCompletionTool

func WorkerObserveCompletionTool() api.Tool

func WorkerObserveTool

func WorkerObserveTool() api.Tool

func WorkerResolveTrustTool

func WorkerResolveTrustTool() api.Tool

func WorkerRestartTool

func WorkerRestartTool() api.Tool

func WorkerSendPromptTool

func WorkerSendPromptTool() api.Tool

func WorkerTerminateTool

func WorkerTerminateTool() api.Tool

func WriteFileTool

func WriteFileTool() api.Tool

WriteFileTool returns the tool definition for writing files.

Types

type AgentSpec

type AgentSpec = intl.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.

func ValidateAgentInput

func ValidateAgentInput(input map[string]any) (*AgentSpec, error)

ValidateAgentInput parses and validates the raw input map for the agent tool. Returns the spec on success or a descriptive error.

type Answer

type Answer = intl.Answer

Answer is what the Asker returns.

type Asker

type Asker = intl.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

func ExecuteComputerUse(ctx context.Context, input map[string]any) (ComputerUseResult, error)

ExecuteComputerUse dispatches the action verb in input["action"] to the matching backend handler. See ComputerUseTool for the schema.

type Option

type Option = intl.Option

Option is a single selectable answer.

type PlanModeState

type PlanModeState struct {
	Active *bool
	Dir    string
}

PlanModeState is the mutable flag + on-disk state directory shared by enter_plan_mode and exit_plan_mode so they can coordinate.

type Question

type Question = intl.Question

Question is the structured payload passed to an Asker.

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

func ExecuteReadImage(ctx context.Context, input map[string]any) (ReadImageResult, error)

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

func ExecuteScreenshot(ctx context.Context, input map[string]any) (ReadImageResult, error)

ExecuteScreenshot captures the host display and returns it as a base64-encoded image content block. Equivalent to ExecuteComputerUse with action="screenshot".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL