tools

package
v0.0.0-...-9b994e1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

package tools provides the tools used by LLMs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecTool

type ExecTool struct {
}

ExecTool is a manager of command execution tools.

func NewExecTool

func NewExecTool() *ExecTool

NewExecTool creates a new command execution tool.

func (*ExecTool) Close

func (et *ExecTool) Close() error

Close implements Manager interface.

func (*ExecTool) ToolDefs

func (et *ExecTool) ToolDefs(ctx context.Context) ([]ToolDefinition, error)

ToolDefs implements Manager interface.

type FileTools

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

FileTools provides the tools/functions related to files (read/write/update/search). It is guarded under a certain directory (typically the current directory of the command started).

func NewFiles

func NewFiles(rootPath string) *FileTools

NewFiles creates a new FileTools in the directory.

func (*FileTools) Close

func (ft *FileTools) Close() error

Close closes the handle to the root.

func (*FileTools) ToolDefs

func (ft *FileTools) ToolDefs(ctx context.Context) ([]ToolDefinition, error)

ToolDefs implements Manager interface.

type MCPTool

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

MCPTool is a tool provided by MCP.

func NewCommandMCP

func NewCommandMCP(name string, command []string) *MCPTool

NewCommandMCP creates a new MCPTool using the command-line.

func NewHTTPMCP

func NewHTTPMCP(name, endpoint string, headers map[string]string) *MCPTool

NewHTTPMCP creates a new MCPTool with the given HTTP endpoint.

func NewMCP

func NewMCP(cfg config.MCPConfig) *MCPTool

NewMCP creates a new MCPTool based on the config.

func (*MCPTool) Close

func (mt *MCPTool) Close() error

func (*MCPTool) ToolDefs

func (mt *MCPTool) ToolDefs(ctx context.Context) ([]ToolDefinition, error)

ToolDefs creates the list of ToolDefinitions for the MCPTool.

type Manager

type Manager interface {
	// ToolDefs returns the list of tools it can support.
	ToolDefs(ctx context.Context) ([]ToolDefinition, error)
	// Close closes the session.
	Close() error
}

Manager manages the multiple tools.

func NewManagers

func NewManagers(cwd string, c *config.Config) []Manager

NewManagers creates the list of the managers from the config.

type ToolDefinition

type ToolDefinition interface {
	// The name of the tool.
	Name() string
	// The description of the tool.
	Description() string
	// Schema of the request object.
	RequestSchema() *jsonschema.Schema
	// Schema of the response object.
	ResponseSchema() *jsonschema.Schema
	// contains filtered or unexported methods
}

ToolDefinition is a definition of a tool.

type ToolError

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

ToolError is a type of error that should be reported to agent.

func (*ToolError) Error

func (e *ToolError) Error() string

Error implements error type.

func (*ToolError) Unwrap

func (e *ToolError) Unwrap() error

Unwrap implements unwrapping.

type ToolRunner

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

ToolRunner keeps the list of the tools and accepts the tool requests and conducts their invocations.

func NewToolRunner

func NewToolRunner(defs []ToolDefinition) (*ToolRunner, error)

NewToolRunner creates a new ToolRunner instance.

func (*ToolRunner) Run

func (r *ToolRunner) Run(ctx context.Context, name string, in map[string]any) (any, []*parts.Part, error)

Run runs a new tool with the given name and the input data.

Jump to

Keyboard shortcuts

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