tools

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrToolAlreadyRegistered

func ErrToolAlreadyRegistered(name string) error

func ErrToolNotFound

func ErrToolNotFound(name string) error

func NewBashTool

func NewBashTool(workspace string) types.Tool

NewBashTool returns a tool to execute shell commands. Delegates to agent/tools/builtin/runtime.CommandTool but returns name "bash"

func NewEditFileTool

func NewEditFileTool(workspace string) types.Tool

NewEditFileTool returns a tool to edit file contents. Delegates to agent/tools/builtin/fs.EditTool

func NewGlobTool

func NewGlobTool(workspace string) types.Tool

NewGlobTool returns a tool to find files matching a pattern. Delegates to agent/tools/builtin/search.GlobTool

func NewGrepTool

func NewGrepTool(workspace string) types.Tool

NewGrepTool returns a tool to search for text in files. Delegates to agent/tools/builtin/search.GrepTool

func NewJobKillTool

func NewJobKillTool() types.Tool

NewJobKillTool returns a tool to kill background jobs. Delegates to agent/tools/builtin/runtime.JobKillTool

func NewJobOutputTool

func NewJobOutputTool() types.Tool

NewJobOutputTool returns a tool to get background job output. Delegates to agent/tools/builtin/runtime.JobOutputTool

func NewMCPClientTool

func NewMCPClientTool() types.Tool

NewMCPClientTool returns a tool to interact with MCP servers. Delegates to agent/tools/builtin/mcp.MCPClientTool

func NewMCPTools

func NewMCPTools(ctx context.Context, url, transport string, headers map[string]string) (*mcp.Client, []types.Tool, error)

NewMCPTools creates an MCP client and returns the tools provided by the server. The caller is responsible for closing the client when it's no longer needed.

func NewQuestionTool

func NewQuestionTool() types.Tool

NewQuestionTool returns a tool to ask the user questions. Delegates to agent/tools/builtin/runtime.QuestionTool

func NewReadFileTool

func NewReadFileTool(workspace string) types.Tool

NewReadFileTool returns a tool to read file contents. Delegates to agent/tools/builtin/fs.ReadTool

func NewSkillTool

func NewSkillTool(list []*skills.Skill) types.Tool

func NewTodoTool

func NewTodoTool() types.Tool

NewTodoTool returns a tool to manage tasks. Delegates to agent/tools/builtin/task.TodoTool

func NewWebFetchTool

func NewWebFetchTool() types.Tool

NewWebFetchTool returns a tool to fetch web pages. Delegates to agent/tools/builtin/web.WebFetchTool

func NewWebSearchTool

func NewWebSearchTool() types.Tool

NewWebSearchTool returns a tool to search the web. Delegates to agent/tools/builtin/web.WebSearchTool

func NewWriteFileTool

func NewWriteFileTool(workspace string) types.Tool

NewWriteFileTool returns a tool to write file contents. Delegates to agent/tools/builtin/fs.WriteTool

func WrapLoopDetection

func WrapLoopDetection(inner types.Tool, sessionID string, detector agentutils.LoopDetector, sender ToolEventSender) types.Tool

func WrapNonFatalTool

func WrapNonFatalTool(inner types.Tool) types.Tool

func WrapToolResultLimiter

func WrapToolResultLimiter(inner types.Tool, maxBytes, maxStringBytes int) types.Tool

Types

type ListDirectoryTool

type ListDirectoryTool struct {
	// contains filtered or unexported fields
}

func NewListDirectoryTool

func NewListDirectoryTool(workspace string) *ListDirectoryTool

func (*ListDirectoryTool) Description

func (t *ListDirectoryTool) Description() string

func (*ListDirectoryTool) Execute

func (t *ListDirectoryTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)

func (*ListDirectoryTool) Metadata

func (t *ListDirectoryTool) Metadata() types.ToolMetadata

func (*ListDirectoryTool) Name

func (t *ListDirectoryTool) Name() string

func (*ListDirectoryTool) Schema

func (t *ListDirectoryTool) Schema() map[string]interface{}

type LoopDetectedError

type LoopDetectedError struct {
	ToolName   string
	Suggestion string
}

func (*LoopDetectedError) Error

func (e *LoopDetectedError) Error() string

type MCPClient

type MCPClient struct {
	// contains filtered or unexported fields
}

func (*MCPClient) ExecuteTool

func (c *MCPClient) ExecuteTool(ctx context.Context, name string, input map[string]interface{}) (interface{}, error)

func (*MCPClient) GetConfig

func (c *MCPClient) GetConfig() *ServerConfig

func (*MCPClient) ListTools

func (c *MCPClient) ListTools() []ToolInfo

type MCPManager

type MCPManager struct {
	// contains filtered or unexported fields
}

func NewMCPManager

func NewMCPManager() *MCPManager

func (*MCPManager) AddServer

func (m *MCPManager) AddServer(ctx context.Context, name string, config *ServerConfig) error

func (*MCPManager) Close

func (m *MCPManager) Close()

func (*MCPManager) GetServer

func (m *MCPManager) GetServer(name string) (*MCPClient, bool)

func (*MCPManager) ListServers

func (m *MCPManager) ListServers() []string

func (*MCPManager) ListTools

func (m *MCPManager) ListTools() map[string][]ToolInfo

func (*MCPManager) RemoveServer

func (m *MCPManager) RemoveServer(name string) error

type MCPServerNotification

type MCPServerNotification struct {
	Type      string
	SessionID string
	Tool      string
	CallID    string
	State     string
	Output    interface{}
	Error     string
}

type MCPStreamHandler

type MCPStreamHandler struct {
	// contains filtered or unexported fields
}

func NewMCPStreamHandler

func NewMCPStreamHandler(manager *MCPManager, sessionID string) *MCPStreamHandler

func (*MCPStreamHandler) Execute

func (h *MCPStreamHandler) Execute(ctx context.Context, serverName, toolName string, input map[string]interface{}) (interface{}, error)

func (*MCPStreamHandler) SetOnError

func (h *MCPStreamHandler) SetOnError(fn func(err error))

func (*MCPStreamHandler) SetOnToolCall

func (h *MCPStreamHandler) SetOnToolCall(fn func(notification MCPServerNotification))

type Registry

type Registry = agenttools.Registry

func NewRegistry

func NewRegistry() *Registry

type ServerConfig

type ServerConfig struct {
	Name      string
	URL       string
	Transport string
	Headers   map[string]string
	Type      string // "local" or "remote"
	Command   []string
	Env       map[string]string
}

func ConvertToMCPServerConfig

func ConvertToMCPServerConfig(config map[string]interface{}) (*ServerConfig, error)

type SkillTool

type SkillTool struct {
	// contains filtered or unexported fields
}

func (*SkillTool) Description

func (t *SkillTool) Description() string

func (*SkillTool) Execute

func (t *SkillTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)

func (*SkillTool) Metadata

func (t *SkillTool) Metadata() types.ToolMetadata

func (*SkillTool) Name

func (t *SkillTool) Name() string

func (*SkillTool) Schema

func (t *SkillTool) Schema() map[string]interface{}

type ToolCallbackAdapter

type ToolCallbackAdapter struct {
	SessionID string
	Sender    ToolEventSender
}

ToolCallbackAdapter sends real-time tool events to a ToolEventSender

func (*ToolCallbackAdapter) OnToolCall

func (a *ToolCallbackAdapter) OnToolCall(toolName string, toolCallID string, input map[string]interface{})

func (*ToolCallbackAdapter) OnToolError

func (a *ToolCallbackAdapter) OnToolError(toolName string, toolCallID string, err error)

func (*ToolCallbackAdapter) OnToolInputEnd

func (a *ToolCallbackAdapter) OnToolInputEnd(toolName string, toolCallID string, input map[string]interface{})

func (*ToolCallbackAdapter) OnToolInputStart

func (a *ToolCallbackAdapter) OnToolInputStart(toolName string, toolCallID string, input map[string]interface{})

func (*ToolCallbackAdapter) OnToolResult

func (a *ToolCallbackAdapter) OnToolResult(toolName string, toolCallID string, output interface{})

type ToolError

type ToolError string

func (ToolError) Error

func (e ToolError) Error() string

type ToolEventSender

type ToolEventSender interface {
	SendToolCall(sessionID, toolCallID, toolName string, input map[string]interface{})
	SendToolResult(sessionID, toolCallID, toolName string, result string)
	SendToolError(sessionID, toolCallID, toolName string, err string)
}

ToolEventSender is an interface to send tool events

type ToolInfo

type ToolInfo struct {
	Name        string
	Description string
	InputSchema json.RawMessage
}

Jump to

Keyboard shortcuts

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