Documentation
¶
Index ¶
- Variables
- func RegisterEmailTool(t *Tools)
- type DynamicParamDef
- type DynamicToolDef
- type DynamicToolImpl
- type MCPServerOption
- type MCPServerStatus
- type ParamDef
- type SkillsRef
- type ToolDef
- type ToolError
- type ToolFunc
- type ToolMiddleware
- type Tools
- func (t *Tools) ConnectMCP(ctx context.Context) error
- func (t *Tools) ContainerAvailable() bool
- func (t *Tools) DisconnectMCP() error
- func (t *Tools) Execute(ctx context.Context, name string, params map[string]any) (string, error)
- func (t *Tools) Filter(names ...string) *Tools
- func (t *Tools) FilterMCP(patterns ...string) *Tools
- func (t *Tools) LoadDirectory(path string) error
- func (t *Tools) LoadFile(path string) error
- func (t *Tools) MCPServerStatuses() []MCPServerStatus
- func (t *Tools) ReadMCPResource(ctx context.Context, serverName, uri string) (string, error)
- func (t *Tools) Register(name string, fn any) error
- func (t *Tools) RegisterBuiltins()
- func (t *Tools) RegisterDynamicTool(def DynamicToolDef) error
- func (t *Tools) Schema() []llm.ToolSchema
- func (t *Tools) SetProject(name string)
- func (t *Tools) Use(mw ToolMiddleware)
- func (t *Tools) WithSkillsRef(sp SkillsRef) *Tools
- type ToolsOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrToolNotFound is returned when a tool is not registered ErrToolNotFound = errors.New("tool not found") // ErrToolAlreadyRegistered is returned when trying to register a duplicate tool name. ErrToolAlreadyRegistered = errors.New("tool already registered") )
Standard errors
Functions ¶
func RegisterEmailTool ¶
func RegisterEmailTool(t *Tools)
RegisterEmailTool registers the send_email built-in tool. SMTP configuration is read from environment variables at call time:
- SMTP_HOST (required)
- SMTP_PORT (default 587)
- SMTP_USER (required)
- SMTP_PASS (required)
- SMTP_FROM (defaults to SMTP_USER)
Types ¶
type DynamicParamDef ¶
type DynamicParamDef struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Description string `yaml:"description"`
Required bool `yaml:"required"`
Default any `yaml:"default"`
Enum []string `yaml:"enum"`
}
DynamicParamDef is a YAML parameter definition.
type DynamicToolDef ¶
type DynamicToolDef struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Params []DynamicParamDef `yaml:"params"`
Implementation DynamicToolImpl `yaml:"implementation"`
}
DynamicToolDef is a YAML tool definition.
type DynamicToolImpl ¶
type DynamicToolImpl struct {
Type string `yaml:"type"` // http, exec, file_read, file_write, builtin
Method string `yaml:"method"`
URL string `yaml:"url"`
Headers map[string]string `yaml:"headers"`
Query map[string]string `yaml:"query"`
Body any `yaml:"body"`
Command string `yaml:"command"`
Path string `yaml:"path"`
Timeout string `yaml:"timeout"`
}
DynamicToolImpl is a YAML implementation definition.
type MCPServerOption ¶
type MCPServerOption func(*mcpServerOptions)
MCPServerOption configures MCP server behavior.
func WithMCPAutoConnect ¶
func WithMCPAutoConnect(enabled bool) MCPServerOption
WithMCPAutoConnect enables automatic connection on first tool call.
func WithMCPTimeout ¶
func WithMCPTimeout(d time.Duration) MCPServerOption
WithMCPTimeout sets the timeout for MCP operations.
type MCPServerStatus ¶
type MCPServerStatus struct {
Name string `json:"name"`
Connected bool `json:"connected"`
Transport string `json:"transport,omitempty"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
Tools []string `json:"tools"`
}
MCPServerStatus describes the status of a connected MCP server.
type ParamDef ¶
type ParamDef struct {
Type string `json:"type" yaml:"type"`
Description string `json:"description" yaml:"description"`
Required bool `json:"required" yaml:"required"`
Default any `json:"default,omitempty" yaml:"default,omitempty"`
Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"`
}
ParamDef defines a tool parameter.
type SkillsRef ¶
type SkillsRef interface {
GetMatchedSkills() []skills.SkillMatch
}
SkillsRef is a narrow interface for skill-based tool augmentation. *vega.SkillsPrompt satisfies this interface.
type ToolMiddleware ¶
ToolMiddleware wraps tool execution.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
Tools is a collection of callable tools.
func (*Tools) ConnectMCP ¶
ConnectMCP connects all MCP servers and discovers their tools.
func (*Tools) ContainerAvailable ¶
ContainerAvailable returns whether container execution is available.
func (*Tools) DisconnectMCP ¶
DisconnectMCP disconnects all MCP servers.
func (*Tools) FilterMCP ¶
FilterMCP returns a new Tools with only tools from specified MCP servers. Supports patterns like "server__*" to include all tools from a server.
func (*Tools) LoadDirectory ¶
LoadDirectory loads tool definitions from YAML files.
func (*Tools) MCPServerStatuses ¶
func (t *Tools) MCPServerStatuses() []MCPServerStatus
MCPServerStatuses returns the status of all configured MCP servers.
func (*Tools) ReadMCPResource ¶
ReadMCPResource reads a resource from a specific MCP server by name.
func (*Tools) Register ¶
Register adds a tool to the collection. The function can be: - func(params) string - func(params) (string, error) - func(ctx, params) (string, error) - ToolDef with explicit schema
func (*Tools) RegisterBuiltins ¶
func (t *Tools) RegisterBuiltins()
RegisterBuiltins adds the built-in tools.
func (*Tools) RegisterDynamicTool ¶
func (t *Tools) RegisterDynamicTool(def DynamicToolDef) error
RegisterDynamicTool registers a tool from a DynamicToolDef.
func (*Tools) Schema ¶
func (t *Tools) Schema() []llm.ToolSchema
Schema returns the schemas for all tools. If a skillsRef is set, tools declared by matched skills are also included.
func (*Tools) SetProject ¶
SetProject sets the active project for container routing.
func (*Tools) WithSkillsRef ¶
WithSkillsRef returns a shallow copy with a skills prompt reference set. When Schema() is called, tools declared by matched skills are included.
type ToolsOption ¶
type ToolsOption func(*Tools)
ToolsOption configures Tools.
func WithContainer ¶
func WithContainer(cm *container.Manager) ToolsOption
WithContainer enables container-based tool execution.
func WithContainerRouting ¶
func WithContainerRouting(toolNames ...string) ToolsOption
WithContainerRouting specifies which tools should be routed to containers.
func WithMCPServer ¶
func WithMCPServer(config mcp.ServerConfig) ToolsOption
WithMCPServer adds an MCP server to the tools collection. Tools from the server will be prefixed with "server_name__tool_name".
func WithSandbox ¶
func WithSandbox(path string) ToolsOption
WithSandbox restricts file operations to a directory.