tools

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MPL-2.0 Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tools provides implementations for executing tools as part of MindTrial's function calling capabilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrToolNotAvailable is returned when a requested tool is not available.
	ErrToolNotAvailable = errors.New("tool not available")
	// ErrToolExecutionFailed is returned when a tool executes but fails with an error.
	ErrToolExecutionFailed = errors.New("tool execution failed")
	// ErrInvalidToolArguments is returned when tool arguments are invalid or don't match the expected schema.
	ErrInvalidToolArguments = errors.New("invalid tool arguments")
	// ErrToolInternal is returned for low-level internal errors during tool execution.
	ErrToolInternal = errors.New("tool internal error")
	// ErrUnsupportedToolType is returned when an unsupported tool type is encountered.
	ErrUnsupportedToolType = errors.New("unsupported tool type")
	// ErrToolMaxCallsExceeded is returned when a tool has exceeded its maximum call limit.
	ErrToolMaxCallsExceeded = errors.New("tool max calls exceeded")
	// ErrToolTimeout is returned when a tool execution times out.
	ErrToolTimeout = errors.New("tool execution timeout")
)

Functions

This section is empty.

Types

type DockerTool

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

func NewDockerTool

func NewDockerTool(cfg *config.ToolConfig, maxCalls *int, timeout *time.Duration, maxMemoryMB *int, cpuPercent *int) *DockerTool

NewDockerTool creates a new Docker tool.

type DockerToolExecutor

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

DockerToolExecutor executes tools within Docker containers.

func NewDockerToolExecutor

func NewDockerToolExecutor(ctx context.Context) (*DockerToolExecutor, error)

NewDockerToolExecutor creates a new Docker tool executor.

func (*DockerToolExecutor) Close

func (d *DockerToolExecutor) Close() error

Close closes the Docker client connection and cleans up shared directories.

func (*DockerToolExecutor) ExecuteTool

func (d *DockerToolExecutor) ExecuteTool(ctx context.Context, logger logging.Logger, toolName string, args json.RawMessage, data map[string][]byte) (json.RawMessage, error)

ExecuteTool executes a tool by name with the given arguments and auxiliary data files.

func (*DockerToolExecutor) GetUsageStats

func (d *DockerToolExecutor) GetUsageStats() map[string]ToolUsage

GetUsageStats returns usage statistics for all tools.

func (*DockerToolExecutor) RegisterTool

func (d *DockerToolExecutor) RegisterTool(tool *DockerTool)

RegisterTool registers a tool with the executor.

func (*DockerToolExecutor) ValidateTool added in v0.12.1

func (d *DockerToolExecutor) ValidateTool(ctx context.Context, cfg config.ToolConfig) error

ValidateTool ensures the Docker image referenced by the tool configuration is available locally.

type TextOrData added in v0.12.0

type TextOrData interface {
	~string | ~[]byte
}

TextOrData is a constraint for types that can be written to files.

type ToolUsage

type ToolUsage struct {
	CallCount   int64
	TotalTimeNs int64
}

ToolUsage tracks usage statistics for a tool.

Jump to

Keyboard shortcuts

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