Documentation
¶
Index ¶
- Constants
- Variables
- func Execute(ctx context.Context, name string, params map[string]any, cwd string) ui.ToolResult
- func ExecuteAndFormat(ctx context.Context, name string, params map[string]any, cwd string) (string, error)
- func GetToolSchemas() []provider.Tool
- func Register(tool Tool)
- type BashTool
- func (t *BashTool) Description() string
- func (t *BashTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *BashTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *BashTool) Icon() string
- func (t *BashTool) Name() string
- func (t *BashTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
- func (t *BashTool) RequiresPermission() bool
- type EditTool
- func (t *EditTool) Description() string
- func (t *EditTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *EditTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *EditTool) Icon() string
- func (t *EditTool) Name() string
- func (t *EditTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
- func (t *EditTool) RequiresPermission() bool
- type GlobTool
- type GrepTool
- type PermissionAwareTool
- type ReadTool
- type Registry
- type Tool
- type ToolError
- type ToolInput
- type ToolSchema
- type WebFetchTool
- type WebSearchTool
- type WriteTool
- func (t *WriteTool) Description() string
- func (t *WriteTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *WriteTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *WriteTool) Icon() string
- func (t *WriteTool) Name() string
- func (t *WriteTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
- func (t *WriteTool) RequiresPermission() bool
Constants ¶
const (
IconBash = "$"
)
const (
IconEdit = "✏️"
)
const (
IconWrite = "📝"
)
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global default tool registry
Functions ¶
func ExecuteAndFormat ¶
func ExecuteAndFormat(ctx context.Context, name string, params map[string]any, cwd string) (string, error)
ExecuteAndFormat executes a tool and returns the result as a string for the LLM
func GetToolSchemas ¶
GetToolSchemas returns provider.Tool definitions for all registered tools
Types ¶
type BashTool ¶
type BashTool struct{}
BashTool executes shell commands
func (*BashTool) Description ¶
func (*BashTool) ExecuteApproved ¶
func (t *BashTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
ExecuteApproved executes the command after user approval
func (*BashTool) PreparePermission ¶
func (t *BashTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
PreparePermission prepares a permission request with command preview
func (*BashTool) RequiresPermission ¶
RequiresPermission returns true - Bash always requires permission
type EditTool ¶
type EditTool struct{}
EditTool performs string replacement edits on files
func (*EditTool) Description ¶
func (*EditTool) ExecuteApproved ¶
func (t *EditTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
ExecuteApproved performs the file edit after user approval
func (*EditTool) PreparePermission ¶
func (t *EditTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
PreparePermission prepares a permission request with diff information
func (*EditTool) RequiresPermission ¶
RequiresPermission returns true - Edit always requires permission
type GlobTool ¶
type GlobTool struct{}
GlobTool finds files matching a pattern
func (*GlobTool) Description ¶
type GrepTool ¶
type GrepTool struct{}
GrepTool searches for patterns in files
func (*GrepTool) Description ¶
type PermissionAwareTool ¶
type PermissionAwareTool interface {
Tool
// RequiresPermission returns true if the tool needs user approval
RequiresPermission() bool
// PreparePermission prepares a permission request (e.g., computes diff)
PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
// ExecuteApproved executes the tool after user approval
ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
}
PermissionAwareTool is a tool that requires user permission before execution
type ReadTool ¶
type ReadTool struct{}
ReadTool reads file contents
func (*ReadTool) Description ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages tool registration and execution
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx context.Context, name string, params map[string]any, cwd string) ui.ToolResult
Execute runs a tool by name with the given parameters
type Tool ¶
type Tool interface {
// Name returns the tool name
Name() string
// Description returns a brief description of the tool
Description() string
// Icon returns the tool icon emoji
Icon() string
// Execute runs the tool with the given parameters
Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
}
Tool represents a read-only tool that can be executed
type ToolError ¶
type ToolError struct {
Message string
}
ToolError represents a tool-specific error
type ToolInput ¶
type ToolInput struct {
Name string // Tool name
Args string // Raw argument string
Params map[string]any // Parsed parameters
}
ToolInput represents parsed tool input
type ToolSchema ¶
ToolSchema defines the JSON schema for a tool
type WebFetchTool ¶
type WebFetchTool struct{}
WebFetchTool fetches content from URLs
func (*WebFetchTool) Description ¶
func (t *WebFetchTool) Description() string
func (*WebFetchTool) Execute ¶
func (t *WebFetchTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
func (*WebFetchTool) Icon ¶
func (t *WebFetchTool) Icon() string
func (*WebFetchTool) Name ¶
func (t *WebFetchTool) Name() string
type WebSearchTool ¶
type WebSearchTool struct{}
WebSearchTool searches the web for information
func (*WebSearchTool) Description ¶
func (t *WebSearchTool) Description() string
func (*WebSearchTool) Execute ¶
func (t *WebSearchTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
func (*WebSearchTool) Icon ¶
func (t *WebSearchTool) Icon() string
func (*WebSearchTool) Name ¶
func (t *WebSearchTool) Name() string
type WriteTool ¶
type WriteTool struct{}
WriteTool writes content to files
func (*WriteTool) Description ¶
func (*WriteTool) Execute ¶
Execute implements the Tool interface (for permission-unaware execution)
func (*WriteTool) ExecuteApproved ¶
func (t *WriteTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
ExecuteApproved performs the file write after user approval
func (*WriteTool) PreparePermission ¶
func (t *WriteTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
PreparePermission prepares a permission request with diff information
func (*WriteTool) RequiresPermission ¶
RequiresPermission returns true - Write always requires permission