Documentation
¶
Index ¶
- Constants
- func ActiveModel(ctx context.Context) string
- func ActiveTools(ctx context.Context) []string
- func CreateTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func CreateToolsFromConfig(cfg *config.Config) (map[string]tool.InvokableTool, error)
- func NewA2ATool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewAskUserTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewBingSearchTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewBrowserUseTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewCommandLineTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewDuckDuckGoTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewFileSystemTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewGoogleSearchTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewHTTPRequestTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewJavaScriptTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewSequentialThinkingTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewSubagentTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewTodoListTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func NewWikipediaTool(name string, cfg config.Tool) (tool.InvokableTool, error)
- func SetRemoteAgentRunner(r RemoteAgentRunner)
- func SetSubagentRunner(r SubagentRunner)
- func SubagentDepth(ctx context.Context) int
- func WithActiveModel(ctx context.Context, model string) context.Context
- func WithActiveTools(ctx context.Context, names []string) context.Context
- func WithApproval(inner tool.InvokableTool, policy approval.Policy) (tool.InvokableTool, error)
- func WithHost(ctx context.Context, h Host) context.Context
- func WithSubagentDepth(ctx context.Context, depth int) context.Context
- type AskUserTool
- type Host
- type RemoteAgentRunner
- type RemoteAgentSpec
- type SubagentRunner
- type SubagentSpec
- type TodoItem
- type TodoListTool
Constants ¶
const ( TodoPending = "pending" TodoInProgress = "in_progress" TodoCompleted = "completed" )
Todo statuses. The model is asked to pass the complete list on every call.
const ( A2AToolType = "a2a" AskUserToolType = "ask_user" BingSearchToolType = "bing_search" BrowserUseToolType = "browser_use" CommandLineToolType = "command_line" CustomExecToolType = "custom_exec" CustomHTTPToolType = "custom_http" DuckDuckGoToolType = "duckduckgo" FileSystemToolType = "file_system" GoogleSearchToolType = "google_search" HTTPRequestToolType = "http_request" JavaScriptToolType = "javascript" PluginToolType = "plugin" SequentialThinkingToolType = "sequential_thinking" SubagentToolType = "subagent" TodoListToolType = "todo_list" WikipediaToolType = "wikipedia" )
Tool type identifiers use lowercase snake_case. The default instance name is the type identifier; configured instances may use their own explicit names.
const ( A2AToolName = A2AToolType AskUserToolName = AskUserToolType BrowserUseToolName = BrowserUseToolType CommandLineToolName = CommandLineToolType FileSystemToolName = FileSystemToolType HTTPRequestToolName = HTTPRequestToolType JavaScriptToolName = JavaScriptToolType SubagentToolName = SubagentToolType TodoListToolName = TodoListToolType )
Variables ¶
This section is empty.
Functions ¶
func ActiveModel ¶
ActiveModel returns the model recorded by WithActiveModel, or "".
func ActiveTools ¶
ActiveTools returns the tool names recorded by WithActiveTools.
func CreateTool ¶
CreateTool creates a tool whose runtime name is exactly its configuration key.
func CreateToolsFromConfig ¶
CreateToolsFromConfig creates all tools from configuration.
func NewA2ATool ¶ added in v0.5.0
NewA2ATool creates a tool that calls configured remote A2A agents without streaming.
Config options:
- agents: allowlist of names from a2a_agents (default: all)
- timeout: overall per-call timeout in seconds (default 300)
- poll_interval_ms: task polling interval in milliseconds (default 1000)
func NewAskUserTool ¶
NewAskUserTool creates the ask_user tool.
func NewBingSearchTool ¶
NewBingSearchTool creates Bing search tool
func NewBrowserUseTool ¶
NewBrowserUseTool creates browser usage tool.
The upstream constructor launches Chrome immediately, which made every agent startup pop a browser window (browser_use is one of the built-in agent's default tools). The returned tool therefore starts the browser lazily, on the first actual tool call.
func NewCommandLineTool ¶
NewCommandLineTool creates the "command_line" shell tool.
Config options:
- work_dir: working directory for commands (optional)
- timeout: execution timeout in seconds (default 60)
func NewDuckDuckGoTool ¶
NewDuckDuckGoTool creates DuckDuckGo search tool
func NewFileSystemTool ¶
NewFileSystemTool creates the "file_system" tool.
Config options:
- root: directory the tool may access (default: current working directory)
- max_bytes: read budget per call in bytes (default 200 KiB)
- max_entries: list/grep result cap (default 500 for list, 200 for grep)
- timeout: per-call timeout in seconds (default 30)
func NewGoogleSearchTool ¶
NewGoogleSearchTool creates Google search tool
func NewHTTPRequestTool ¶
NewHTTPRequestTool creates HTTP request tool
func NewJavaScriptTool ¶
NewJavaScriptTool executes an async function body in a fresh moejs runtime. No filesystem, network, process or module loader APIs are installed.
func NewSequentialThinkingTool ¶
NewSequentialThinkingTool uses the configured name and description rather than exposing the upstream implementation's fixed tool name.
func NewSubagentTool ¶
NewSubagentTool creates the "subagent" tool.
Config options:
- agents: allowlist of configured agent names (default: all)
- tools: allowlist of tool names a temporary agent may request (default: all)
- allow_temp: allow ad-hoc agents built from a system prompt (default true)
- max_depth: maximum subagent nesting depth (default 1)
- timeout: per-child-run timeout in seconds (default 300)
func NewTodoListTool ¶
NewTodoListTool creates the todo tool.
func NewWikipediaTool ¶
NewWikipediaTool creates Wikipedia tool
func SetRemoteAgentRunner ¶ added in v0.5.0
func SetRemoteAgentRunner(r RemoteAgentRunner)
SetRemoteAgentRunner installs the remote A2A agent runner.
func SetSubagentRunner ¶
func SetSubagentRunner(r SubagentRunner)
SetSubagentRunner installs the child-agent runner.
func SubagentDepth ¶
SubagentDepth reports the nesting depth carried by ctx.
func WithActiveModel ¶
WithActiveModel records the model the current run is using, so nested agents (the subagent tool) run on the same model, including a runtime /model switch.
func WithActiveTools ¶
WithActiveTools records the tool names the current run has, so a subagent asked for nothing but a prompt inherits the same capabilities.
func WithApproval ¶
func WithApproval(inner tool.InvokableTool, policy approval.Policy) (tool.InvokableTool, error)
WithApproval wraps inner with the given approval policy. Tools that only talk to the user (ask_user, todo_list) are never gated.
Types ¶
type AskUserTool ¶
type AskUserTool struct {
// contains filtered or unexported fields
}
AskUserTool asks the user a question through the host and waits for an answer.
func (*AskUserTool) InvokableRun ¶
func (t *AskUserTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)
InvokableRun asks the question and returns the user's answer.
type Host ¶
type Host interface {
// AskUser asks the user a question and returns the answer ("" when the
// user cancels).
AskUser(ctx context.Context, question string, options []string) (string, error)
// UpdateTodos replaces the displayed task list.
UpdateTodos(ctx context.Context, items []TodoItem) error
// ApproveTool asks the user whether a dangerous tool call may run. It
// reports false when the user denies the request.
ApproveTool(ctx context.Context, req approval.Request) (bool, error)
}
Host is implemented by interactive front-ends (the TUI) that can talk to the user and display the task list. Tools receive it through the context.
func HostFromContext ¶
HostFromContext returns the host attached to a context, or nil.
type RemoteAgentRunner ¶ added in v0.5.0
type RemoteAgentRunner func(context.Context, RemoteAgentSpec) (string, error)
RemoteAgentRunner runs a remote A2A agent. The agent package installs the implementation so the tools package does not depend on the protocol server.
type RemoteAgentSpec ¶ added in v0.5.0
type RemoteAgentSpec struct {
Agent string
Prompt string
TaskID string
ContextID string
Timeout time.Duration
PollInterval time.Duration
}
RemoteAgentSpec describes one non-streaming A2A call.
type SubagentRunner ¶
type SubagentRunner func(ctx context.Context, spec SubagentSpec) (string, error)
SubagentRunner runs a child agent and returns its final answer. The agent package installs the real implementation; injecting it keeps the dependency direction one-way (agent imports tools).
type SubagentSpec ¶
SubagentSpec describes a child-agent run requested by the model. Agent names a configured agent; otherwise System describes a temporary one (it falls back to a default instruction when the call only carried a prompt).
type TodoListTool ¶
type TodoListTool struct {
// contains filtered or unexported fields
}
TodoListTool maintains the task list shown by the host.
func (*TodoListTool) InvokableRun ¶
func (t *TodoListTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)
InvokableRun replaces the host's task list and returns a summary.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package approval holds the types shared by the tool-approval wrapper and the tools that know which of their calls need a human decision.
|
Package approval holds the types shared by the tool-approval wrapper and the tools that know which of their calls need a human decision. |