Help us shape the future of Go! Take the 2026 Go Developer Survey

tools

package
v1.233.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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

func (e *Executor) DisplayName(toolName string) string

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

func (e *Executor) ExecuteBatch(ctx context.Context, calls []ToolCall) ([]*Result, error)

ExecuteBatch runs multiple tools in sequence.

func (*Executor) ListTools

func (e *Executor) ListTools() []Tool

ListTools returns all available tools from the registry.

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 NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new tool registry.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered tools.

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, error)

Get retrieves a tool by name.

func (*Registry) List

func (r *Registry) List() []Tool

List returns all registered tools.

func (*Registry) ListByCategory

func (r *Registry) ListByCategory(category Category) []Tool

ListByCategory returns tools in a specific category.

func (*Registry) Register

func (r *Registry) Register(tool Tool) error

Register adds a tool to the registry.

func (*Registry) Unregister

func (r *Registry) Unregister(name string) error

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.

type ToolCall

type ToolCall struct {
	Tool   string                 `json:"tool"`
	Params map[string]interface{} `json:"params"`
}

ToolCall represents a tool execution request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL