Documentation
¶
Index ¶
Constants ¶
const ( // DefaultTimeout is the default timeout for tool execution. DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BridgedToolInfo ¶ added in v1.214.0
type BridgedToolInfo interface {
// ServerName returns the server that provides this tool.
ServerName() string
// OriginalName returns the tool's original name (before sanitization).
OriginalName() string
}
BridgedToolInfo is an optional interface for tools that originate from external servers (e.g., MCP). Tools implementing this interface provide human-readable names for display.
type Category ¶
type Category string
Category represents a tool category.
const ( // CategoryAtmos represents Atmos-specific tools. CategoryAtmos Category = "atmos" // CategoryFile represents file operation tools. CategoryFile Category = "file" // CategorySystem represents system operation tools. CategorySystem Category = "system" // CategoryMCP represents MCP-provided tools. CategoryMCP Category = "mcp" )
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes tools with permission checking.
func NewExecutor ¶
func NewExecutor(registry *Registry, permChecker *permission.Checker, timeout time.Duration) *Executor
NewExecutor creates a new tool executor.
func (*Executor) DisplayName ¶ added in v1.214.0
DisplayName returns a human-readable name for a tool. For bridged tools (e.g., MCP), returns "server → clean_tool_name". For other tools, returns the tool name as-is.
func (*Executor) Execute ¶
func (e *Executor) Execute(ctx context.Context, toolName string, params map[string]interface{}) (*Result, error)
Execute runs a tool with the given parameters.
func (*Executor) ExecuteBatch ¶
ExecuteBatch runs multiple tools in sequence.
type ParamType ¶
type ParamType string
ParamType represents the type of a parameter.
const ( // ParamTypeString is a string parameter. ParamTypeString ParamType = "string" // ParamTypeInt is an integer parameter. // Note: JSON Schema uses "integer", not "int". ParamTypeInt ParamType = "integer" // ParamTypeBool is a boolean parameter. // Note: JSON Schema uses "boolean", not "bool". ParamTypeBool ParamType = "boolean" // ParamTypeArray is an array parameter. ParamTypeArray ParamType = "array" // ParamTypeObject is an object parameter. ParamTypeObject ParamType = "object" )
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
Description string `json:"description"`
Type ParamType `json:"type"`
Required bool `json:"required"`
Default interface{} `json:"default,omitempty"`
}
Parameter defines a tool parameter.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages available tools.
func (*Registry) ListByCategory ¶
ListByCategory returns tools in a specific category.
func (*Registry) Unregister ¶
Unregister removes a tool from the registry.
type Result ¶
type Result struct {
Success bool `json:"success"`
Output string `json:"output"`
Error error `json:"error,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
Result contains the result of tool execution.
type Tool ¶
type Tool interface {
// Name returns the unique tool name.
Name() string
// Description returns a description of what the tool does.
Description() string
// Parameters returns the list of parameters this tool accepts.
Parameters() []Parameter
// Execute runs the tool with the given parameters.
Execute(ctx context.Context, params map[string]interface{}) (*Result, error)
// RequiresPermission returns true if this tool needs user permission.
RequiresPermission() bool
// IsRestricted returns true if this tool is always restricted (requires confirmation).
IsRestricted() bool
}
Tool represents an executable operation that AI can perform.