Documentation
¶
Overview ¶
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Package builtin provides built-in tools for the tool execution framework.
Index ¶
- func DefaultAllowedCommands() []string
- func DefaultDeniedCommands() []string
- func ExpandAllowedPaths(workingDir string) []string
- func NewRegistryWithCoreTools() (*tools.Registry, error)
- func RegisterCoreTools(registry *tools.Registry, workingDir string, allowedPaths []string) error
- func RegisterCoreToolsWithDefaults(registry *tools.Registry) error
- type BashTool
- func (t *BashTool) Category() tools.Category
- func (t *BashTool) Description() string
- func (t *BashTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
- func (t *BashTool) Name() string
- func (t *BashTool) RequiresConfirmation() bool
- func (t *BashTool) Schema() tools.ToolSchema
- type ExecCommandTool
- func (t *ExecCommandTool) Category() tools.Category
- func (t *ExecCommandTool) Description() string
- func (t *ExecCommandTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
- func (t *ExecCommandTool) Name() string
- func (t *ExecCommandTool) RequiresConfirmation() bool
- func (t *ExecCommandTool) Schema() tools.ToolSchema
- type GrepTool
- func (t *GrepTool) Category() tools.Category
- func (t *GrepTool) Description() string
- func (t *GrepTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
- func (t *GrepTool) Name() string
- func (t *GrepTool) RequiresConfirmation() bool
- func (t *GrepTool) Schema() tools.ToolSchema
- type HTTPRequestTool
- func (t *HTTPRequestTool) Category() tools.Category
- func (t *HTTPRequestTool) Description() string
- func (t *HTTPRequestTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
- func (t *HTTPRequestTool) Name() string
- func (t *HTTPRequestTool) RequiresConfirmation() bool
- func (t *HTTPRequestTool) Schema() tools.ToolSchema
- type ReadFileTool
- func (t *ReadFileTool) Category() tools.Category
- func (t *ReadFileTool) Description() string
- func (t *ReadFileTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
- func (t *ReadFileTool) Name() string
- func (t *ReadFileTool) RequiresConfirmation() bool
- func (t *ReadFileTool) Schema() tools.ToolSchema
- type Sandbox
- type SearchReplaceTool
- func (t *SearchReplaceTool) Category() tools.Category
- func (t *SearchReplaceTool) Description() string
- func (t *SearchReplaceTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
- func (t *SearchReplaceTool) Name() string
- func (t *SearchReplaceTool) RequiresConfirmation() bool
- func (t *SearchReplaceTool) Schema() tools.ToolSchema
- type WriteFileTool
- func (t *WriteFileTool) Category() tools.Category
- func (t *WriteFileTool) Description() string
- func (t *WriteFileTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
- func (t *WriteFileTool) Name() string
- func (t *WriteFileTool) RequiresConfirmation() bool
- func (t *WriteFileTool) Schema() tools.ToolSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAllowedCommands ¶
func DefaultAllowedCommands() []string
DefaultAllowedCommands returns a whitelist of safe commands for execution.
func DefaultDeniedCommands ¶
func DefaultDeniedCommands() []string
DefaultDeniedCommands returns a blacklist of dangerous commands.
func ExpandAllowedPaths ¶
ExpandAllowedPaths expands the allowed paths to include commonly needed directories relative to the working directory.
func NewRegistryWithCoreTools ¶
NewRegistryWithCoreTools creates a new registry and registers all core tools with default settings. This is the simplest way to get a fully configured registry for immediate use.
Example:
registry, err := builtin.NewRegistryWithCoreTools()
if err != nil {
log.Fatal(err)
}
// Execute a tool
result, err := registry.Execute(ctx, "bash", map[string]interface{}{
"command": "ls -la",
}, nil)
func RegisterCoreTools ¶
RegisterCoreTools registers all core built-in tools with the provided registry. This includes bash execution, file operations, grep, and search/replace functionality.
Parameters:
- registry: The tool registry to register tools with
- workingDir: The working directory for tool execution (used for sandboxing)
- allowedPaths: Paths that tools are allowed to access (for security sandboxing)
Returns an error if any tool registration fails.
func RegisterCoreToolsWithDefaults ¶
RegisterCoreToolsWithDefaults registers all core tools with default configuration. It uses the current working directory and allows access to it recursively.
This is a convenience function for quick setup. For production use, prefer RegisterCoreTools with explicit configuration.
Types ¶
type BashTool ¶
type BashTool struct {
// contains filtered or unexported fields
}
BashTool implements a tool for executing shell commands with security sandboxing. It provides timeout support, output capture, and command validation.
func NewBashTool ¶
NewBashTool creates a new BashTool instance with the specified sandbox.
func (*BashTool) Description ¶
Description returns a human-readable description of what the tool does.
func (*BashTool) Execute ¶
func (t *BashTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
Execute runs the tool with the provided input and returns the result.
func (*BashTool) RequiresConfirmation ¶
RequiresConfirmation returns true if this tool requires user confirmation before execution.
func (*BashTool) Schema ¶
func (t *BashTool) Schema() tools.ToolSchema
Schema returns the JSON schema for the tool's input parameters.
type ExecCommandTool ¶
type ExecCommandTool struct {
// contains filtered or unexported fields
}
ExecCommandTool implements a tool for executing shell commands with security restrictions.
func NewExecCommandTool ¶
func NewExecCommandTool(allowedCommands []string, workingDir string) *ExecCommandTool
NewExecCommandTool creates a new ExecCommandTool instance. If allowedCommands is empty, all commands are allowed (use with caution). workingDir sets the working directory for command execution.
func (*ExecCommandTool) Category ¶
func (t *ExecCommandTool) Category() tools.Category
Category returns the category this tool belongs to.
func (*ExecCommandTool) Description ¶
func (t *ExecCommandTool) Description() string
Description returns a human-readable description of what the tool does.
func (*ExecCommandTool) Execute ¶
func (t *ExecCommandTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
Execute runs the tool with the provided input and returns the result.
func (*ExecCommandTool) Name ¶
func (t *ExecCommandTool) Name() string
Name returns the unique name of the tool.
func (*ExecCommandTool) RequiresConfirmation ¶
func (t *ExecCommandTool) RequiresConfirmation() bool
RequiresConfirmation returns true if this tool requires user confirmation before execution.
func (*ExecCommandTool) Schema ¶
func (t *ExecCommandTool) Schema() tools.ToolSchema
Schema returns the JSON schema for the tool's input parameters.
type GrepTool ¶
type GrepTool struct {
// contains filtered or unexported fields
}
GrepTool implements a tool for searching across files with regex support.
func NewGrepTool ¶
NewGrepTool creates a new GrepTool instance with the specified sandbox.
func (*GrepTool) Description ¶
Description returns a human-readable description of what the tool does.
func (*GrepTool) Execute ¶
func (t *GrepTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
Execute runs the tool with the provided input and returns the result.
func (*GrepTool) RequiresConfirmation ¶
RequiresConfirmation returns true if this tool requires user confirmation before execution.
func (*GrepTool) Schema ¶
func (t *GrepTool) Schema() tools.ToolSchema
Schema returns the JSON schema for the tool's input parameters.
type HTTPRequestTool ¶
type HTTPRequestTool struct {
// contains filtered or unexported fields
}
HTTPRequestTool implements a tool for making HTTP requests with security restrictions.
func NewHTTPRequestTool ¶
func NewHTTPRequestTool(allowedHosts []string) *HTTPRequestTool
NewHTTPRequestTool creates a new HTTPRequestTool instance. If allowedHosts is empty, all hosts are allowed (use with caution). A default HTTP client with 30-second timeout is used.
func (*HTTPRequestTool) Category ¶
func (t *HTTPRequestTool) Category() tools.Category
Category returns the category this tool belongs to.
func (*HTTPRequestTool) Description ¶
func (t *HTTPRequestTool) Description() string
Description returns a human-readable description of what the tool does.
func (*HTTPRequestTool) Execute ¶
func (t *HTTPRequestTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
Execute runs the tool with the provided input and returns the result.
func (*HTTPRequestTool) Name ¶
func (t *HTTPRequestTool) Name() string
Name returns the unique name of the tool.
func (*HTTPRequestTool) RequiresConfirmation ¶
func (t *HTTPRequestTool) RequiresConfirmation() bool
RequiresConfirmation returns true if this tool requires user confirmation before execution.
func (*HTTPRequestTool) Schema ¶
func (t *HTTPRequestTool) Schema() tools.ToolSchema
Schema returns the JSON schema for the tool's input parameters.
type ReadFileTool ¶
type ReadFileTool struct {
// contains filtered or unexported fields
}
ReadFileTool implements a tool for reading file contents with path sandboxing.
func NewReadFileTool ¶
func NewReadFileTool(allowedPaths []string) *ReadFileTool
NewReadFileTool creates a new ReadFileTool instance.
func (*ReadFileTool) Category ¶
func (t *ReadFileTool) Category() tools.Category
Category returns the category this tool belongs to.
func (*ReadFileTool) Description ¶
func (t *ReadFileTool) Description() string
Description returns a human-readable description of what the tool does.
func (*ReadFileTool) Execute ¶
func (t *ReadFileTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
Execute runs the tool with the provided input and returns the result.
func (*ReadFileTool) Name ¶
func (t *ReadFileTool) Name() string
Name returns the unique name of the tool.
func (*ReadFileTool) RequiresConfirmation ¶
func (t *ReadFileTool) RequiresConfirmation() bool
RequiresConfirmation returns true if this tool requires user confirmation before execution.
func (*ReadFileTool) Schema ¶
func (t *ReadFileTool) Schema() tools.ToolSchema
Schema returns the JSON schema for the tool's input parameters.
type Sandbox ¶
type Sandbox struct {
// AllowedPaths defines paths that tools are allowed to access
AllowedPaths []string
// AllowedCommands defines whitelisted commands for bash execution
AllowedCommands []string
// DeniedCommands defines explicitly blacklisted commands
DeniedCommands []string
// WorkingDirectory is the base directory for relative path operations
WorkingDirectory string
// MaxFileSize is the maximum file size that can be read/written (in bytes)
MaxFileSize int64
// MaxOutputSize is the maximum output size for command execution (in bytes)
MaxOutputSize int64
// AuditLog enables logging of all sandbox operations
AuditLog bool
}
Sandbox provides security sandboxing for tool operations. It enforces path restrictions, command whitelisting, and resource limits.
func DefaultSandbox ¶
DefaultSandbox returns a Sandbox with sensible default security settings.
func GetDefaultSandbox ¶
GetDefaultSandbox returns a sandbox instance with default security settings for the given working directory and allowed paths.
func (*Sandbox) ResolveWorkingDirectory ¶
ResolveWorkingDirectory resolves a working directory path with sandbox validation.
func (*Sandbox) ValidateCommand ¶
ValidateCommand checks if a command is allowed by the sandbox. It checks against both whitelist and blacklist.
func (*Sandbox) ValidateFileSize ¶
ValidateFileSize checks if a file size is within the allowed limit.
func (*Sandbox) ValidateOutputSize ¶
ValidateOutputSize checks if output size is within the allowed limit.
func (*Sandbox) ValidatePath ¶
ValidatePath checks if a path is allowed by the sandbox. It resolves the path to an absolute path and checks against allowed paths.
type SearchReplaceTool ¶
type SearchReplaceTool struct {
// contains filtered or unexported fields
}
SearchReplaceTool implements find and replace functionality with regex support.
func NewSearchReplaceTool ¶
func NewSearchReplaceTool(sandbox *Sandbox) *SearchReplaceTool
NewSearchReplaceTool creates a new SearchReplaceTool instance with the specified sandbox.
func (*SearchReplaceTool) Category ¶
func (t *SearchReplaceTool) Category() tools.Category
Category returns the category this tool belongs to.
func (*SearchReplaceTool) Description ¶
func (t *SearchReplaceTool) Description() string
Description returns a human-readable description of what the tool does.
func (*SearchReplaceTool) Execute ¶
func (t *SearchReplaceTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
Execute runs the tool with the provided input and returns the result.
func (*SearchReplaceTool) Name ¶
func (t *SearchReplaceTool) Name() string
Name returns the unique name of the tool.
func (*SearchReplaceTool) RequiresConfirmation ¶
func (t *SearchReplaceTool) RequiresConfirmation() bool
RequiresConfirmation returns true if this tool requires user confirmation before execution.
func (*SearchReplaceTool) Schema ¶
func (t *SearchReplaceTool) Schema() tools.ToolSchema
Schema returns the JSON schema for the tool's input parameters.
type WriteFileTool ¶
type WriteFileTool struct {
// contains filtered or unexported fields
}
WriteFileTool implements a tool for writing file contents with path sandboxing.
func NewWriteFileTool ¶
func NewWriteFileTool(allowedPaths []string) *WriteFileTool
NewWriteFileTool creates a new WriteFileTool instance.
func (*WriteFileTool) Category ¶
func (t *WriteFileTool) Category() tools.Category
Category returns the category this tool belongs to.
func (*WriteFileTool) Description ¶
func (t *WriteFileTool) Description() string
Description returns a human-readable description of what the tool does.
func (*WriteFileTool) Execute ¶
func (t *WriteFileTool) Execute(ctx context.Context, input map[string]interface{}) (*tools.Result, error)
Execute runs the tool with the provided input and returns the result.
func (*WriteFileTool) Name ¶
func (t *WriteFileTool) Name() string
Name returns the unique name of the tool.
func (*WriteFileTool) RequiresConfirmation ¶
func (t *WriteFileTool) RequiresConfirmation() bool
RequiresConfirmation returns true if this tool requires user confirmation before execution.
func (*WriteFileTool) Schema ¶
func (t *WriteFileTool) Schema() tools.ToolSchema
Schema returns the JSON schema for the tool's input parameters.