Documentation
¶
Index ¶
- func SetDelegateFn(fn func(ctx context.Context, role, request string) (string, error))
- func SetSandboxProvider(sp sandbox.Provider)
- func WithChromePath(path string) func(*browserTool)
- func WithHeadless(headless bool) func(*browserTool)
- func WithRootDir(dir string) fileToolOption
- func WithTabTimeout(d time.Duration) func(*browserTool)
- type AskHumanOption
- type Base
- type SearchResult
- type Tool
- func AskAgentTool() Tool
- func AskHumanTool() Tool
- func BrowserTool(headless bool, opts ...func(*browserTool)) Tool
- func CalculatorTool() Tool
- func CodeInterpreterTool() Tool
- func DelegateToAgentTool() Tool
- func DelegateWorkTool() Tool
- func DirTool(opts ...fileToolOption) Tool
- func EditFileTool(opts ...fileToolOption) Tool
- func New(name, description string, params map[string]any, ...) Tool
- func NewAskHumanTool(opts ...AskHumanOption) Tool
- func NewWebSearchTool(opts ...WebSearchOption) Tool
- func ReadFileTool(opts ...fileToolOption) Tool
- func ShellTool() Tool
- func WebSearchTool(apiKey string) Tool
- func WriteFileTool(opts ...fileToolOption) Tool
- type WebSearchOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDelegateFn ¶ added in v0.2.0
SetDelegateFn sets the delegate function used by DelegateToAgentTool.
func SetSandboxProvider ¶ added in v0.3.0
SetSandboxProvider sets the sandbox provider used by CodeInterpreterTool.
func WithChromePath ¶ added in v0.4.0
func WithChromePath(path string) func(*browserTool)
WithChromePath sets a custom Chrome/Chromium binary path.
func WithHeadless ¶ added in v0.4.0
func WithHeadless(headless bool) func(*browserTool)
WithHeadless overrides the headless mode after construction. Pass false to show the browser window (useful for debugging).
func WithRootDir ¶ added in v0.6.0
func WithRootDir(dir string) fileToolOption
WithRootDir sets the allowed root directory for file operations. Paths that escape this directory are rejected with ErrPathTraversal. Default is os.TempDir() when not set.
func WithTabTimeout ¶ added in v0.4.0
WithTabTimeout sets the per-action timeout (default 30s).
Types ¶
type AskHumanOption ¶ added in v0.6.0
type AskHumanOption func(*askHumanTool)
AskHumanOption configures an AskHumanTool.
func WithAskTimeout ¶ added in v0.6.0
func WithAskTimeout(d time.Duration) AskHumanOption
WithAskTimeout sets the maximum duration to wait for human input. A zero value means no timeout.
func WithEnabled ¶ added in v0.6.0
func WithEnabled(enabled bool) AskHumanOption
WithEnabled configures whether the tool prompts for human input. When false, Execute returns "[ask_human disabled]" without reading stdin.
func WithPrompt ¶ added in v0.6.0
func WithPrompt(prompt string) AskHumanOption
WithPrompt sets the prompt prefix displayed before the question.
func WithStdout ¶ added in v0.6.0
func WithStdout(w io.Writer) AskHumanOption
WithStdout sets the writer used for prompt output. Defaults to os.Stderr.
type Base ¶
type Base struct {
ToolName string
Desc string
Params map[string]any
ExecuteFn func(ctx context.Context, args map[string]any) (string, error)
}
Base provides a default implementation of the Tool interface.
func (*Base) Description ¶
Description returns the tool's description.
func (*Base) Parameters ¶
Parameters returns the tool's JSON schema parameters.
type SearchResult ¶ added in v0.6.0
SearchResult represents a single web search result.
func (SearchResult) Format ¶ added in v0.6.0
func (sr SearchResult) Format() string
Format returns a formatted string representation in the spec-defined format.
type Tool ¶
type Tool interface {
Name() string
Description() string
Parameters() map[string]any
Execute(ctx context.Context, args map[string]any) (string, error)
}
Tool is the interface that all tools must implement.
func AskAgentTool ¶ added in v0.2.0
func AskAgentTool() Tool
AskAgentTool creates a tool that asks another agent a question via A2A.
func AskHumanTool ¶
func AskHumanTool() Tool
AskHumanTool creates a tool that asks a human for input or approval.
func BrowserTool ¶ added in v0.4.0
BrowserTool creates a new browser automation tool. headless=false enables visible Chrome mode for debugging. Options: WithChromePath, WithTabTimeout, WithHeadless. Actions: navigate(url), click(selector), type(selector,text), extract_text(selector), extract_html(selector), screenshot(), scroll(direction=down|up).
func CalculatorTool ¶
func CalculatorTool() Tool
CalculatorTool creates a tool that evaluates mathematical expressions.
func CodeInterpreterTool ¶ added in v0.3.0
func CodeInterpreterTool() Tool
CodeInterpreterTool creates a tool that executes code using the configured sandbox.
func DelegateToAgentTool ¶ added in v0.2.0
func DelegateToAgentTool() Tool
DelegateToAgentTool creates a tool that delegates a task to another agent via A2A.
func DelegateWorkTool ¶
func DelegateWorkTool() Tool
DelegateWorkTool creates a tool that delegates a task to another agent.
func DirTool ¶ added in v0.6.0
func DirTool(opts ...fileToolOption) Tool
DirTool creates a tool that lists files and directories. Supports single-level and recursive listing.
func EditFileTool ¶ added in v0.6.0
func EditFileTool(opts ...fileToolOption) Tool
EditFileTool creates a tool that performs search-and-replace in a file. Uses bufio.Scanner for line-by-line processing — memory is proportional to the longest line, not the total file size. Writes to a temp file in the same directory, then atomically renames on success.
func New ¶
func New(name, description string, params map[string]any, fn func(ctx context.Context, args map[string]any) (string, error)) Tool
New creates a new Tool with the given name, description, parameters, and execute function.
func NewAskHumanTool ¶ added in v0.6.0
func NewAskHumanTool(opts ...AskHumanOption) Tool
NewAskHumanTool creates a new AskHumanTool with the given options.
func NewWebSearchTool ¶ added in v0.6.0
func NewWebSearchTool(opts ...WebSearchOption) Tool
NewWebSearchTool creates a web search tool with the given options.
func ReadFileTool ¶
func ReadFileTool(opts ...fileToolOption) Tool
ReadFileTool creates a tool that reads the contents of a file. The tool streams content up to maxBytes (default 10 MB) to avoid loading large files entirely into memory. If the file exceeds maxBytes, the result includes a truncation warning.
func ShellTool ¶
func ShellTool() Tool
ShellTool creates a tool that executes shell commands on the local system.
func WebSearchTool ¶
WebSearchTool creates a web search tool. Deprecated: use NewWebSearchTool.
func WriteFileTool ¶
func WriteFileTool(opts ...fileToolOption) Tool
WriteFileTool creates a tool that writes content to a file. Parent directories are created automatically if they do not exist.
type WebSearchOption ¶ added in v0.6.0
type WebSearchOption func(*webSearchTool)
WebSearchOption configures a webSearchTool.
func WithNumResults ¶ added in v0.6.0
func WithNumResults(n int) WebSearchOption
WithNumResults sets the maximum number of search results to return (default 5).
func WithTimeout ¶ added in v0.6.0
func WithTimeout(d time.Duration) WebSearchOption
WithTimeout sets the HTTP timeout for search requests (default 10s).