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) ActiveProject() string
- func (t *Tools) BuiltinServerConnected(name string) bool
- func (t *Tools) ConnectBuiltinServer(ctx context.Context, name string) (int, error)
- func (t *Tools) ConnectMCP(ctx context.Context) error
- func (t *Tools) ConnectMCPServer(ctx context.Context, config mcp.ServerConfig) (int, error)
- func (t *Tools) ContainerAvailable() bool
- func (t *Tools) DisconnectMCP() error
- func (t *Tools) DisconnectMCPServer(name string) 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) GetSettings() map[string]string
- func (t *Tools) HasBuiltinServer(name string) bool
- func (t *Tools) LoadDirectory(path string) error
- func (t *Tools) LoadFile(path string) error
- func (t *Tools) MCPServerConnected(name string) bool
- 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) Sandbox() string
- func (t *Tools) Schema() []llm.ToolSchema
- func (t *Tools) SetActiveProject(name string)
- func (t *Tools) SetProject(name string)
- func (t *Tools) SetSettings(m map[string]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 {
// OnFileWrite is called after a successful write_file or append_file operation.
// Parameters: ctx, relative path, operation ("write"/"append"), description.
OnFileWrite func(ctx context.Context, path, operation, description string)
// contains filtered or unexported fields
}
Tools is a collection of callable tools.
func (*Tools) ActiveProject ¶ added in v0.2.0
ActiveProject returns the current active project name, or "" if none.
func (*Tools) BuiltinServerConnected ¶ added in v0.2.0
BuiltinServerConnected reports whether a built-in server's tools are already registered.
func (*Tools) ConnectBuiltinServer ¶ added in v0.2.0
ConnectBuiltinServer registers all tools from a built-in Go MCP server implementation. Tools are registered with the standard "servername__toolname" prefix. Returns the number of tools registered.
func (*Tools) ConnectMCP ¶
ConnectMCP connects all MCP servers and discovers their tools.
func (*Tools) ConnectMCPServer ¶ added in v0.2.0
ConnectMCPServer connects a single MCP server by config at runtime, discovers its tools, and registers them. Returns the number of tools found.
func (*Tools) ContainerAvailable ¶
ContainerAvailable returns whether container execution is available.
func (*Tools) DisconnectMCP ¶
DisconnectMCP disconnects all MCP servers.
func (*Tools) DisconnectMCPServer ¶ added in v0.2.1
DisconnectMCPServer disconnects a single MCP server by name, removes it from the client list, and unregisters all its tools.
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) GetSettings ¶ added in v0.2.0
GetSettings returns a copy of the current settings map.
func (*Tools) HasBuiltinServer ¶ added in v0.2.0
HasBuiltinServer reports whether a Go-native implementation exists for the named MCP server.
func (*Tools) LoadDirectory ¶
LoadDirectory loads tool definitions from YAML files.
func (*Tools) MCPServerConnected ¶ added in v0.2.0
MCPServerConnected reports whether a server with the given name is already connected.
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) Sandbox ¶ added in v0.2.0
Sandbox returns the base sandbox path (without project subdirectory).
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) SetActiveProject ¶ added in v0.2.0
SetActiveProject sets the active project name for workspace subdirectories. All file and exec operations will target sandbox/<project>/ when set. Pass an empty string to clear the active project.
func (*Tools) SetProject ¶
SetProject sets the active project for container routing.
func (*Tools) SetSettings ¶ added in v0.2.0
SetSettings replaces the tool settings map used for dynamic tool interpolation.
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.