tools

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEnvironmentTools

func NewEnvironmentTools(executeFn func(ctx context.Context, req ToolRequest, onProgress func(ToolProgress)) (*ToolResponse, error)) []agent.AgentTool

NewEnvironmentTools creates agent tools that delegate execution to the provided execute function. This is the unified factory for all environments: LocalEnvironment, NativeSandboxEnvironment, etc.

Usage:

// Local environment
env := local.NewLocalEnvironment(rootDir, logger)
tools := tools.NewEnvironmentTools(env.ExecuteTool)

// Native sandbox environment
env := native.NewNativeSandboxEnvironment(svc, logger)
tools := tools.NewEnvironmentTools(env.ExecuteTool)

func NewLocalTools

func NewLocalTools(rootDir string, _ LocalToolsOptions) []agent.AgentTool

NewLocalTools creates the standard set of agent tools backed by local filesystem execution. All Tier 1 tools run in-process.

Types

type LocalBackend

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

LocalBackend executes tools directly in-process under a workspace root.

func NewLocalBackend

func NewLocalBackend(rootDir string) *LocalBackend

NewLocalBackend creates a backend that runs all built-in tools in-process.

func (*LocalBackend) ExecuteTool

func (b *LocalBackend) ExecuteTool(ctx context.Context, req ToolRequest, _ func(ToolProgress)) (*ToolResponse, error)

type LocalToolsOptions

type LocalToolsOptions struct {
	// MaxReadFileSize overrides the default max file size for read_file.
	MaxReadFileSize int64
}

LocalToolsOptions configures the local tools factory.

type ResourceSpec

type ResourceSpec struct {
	CPUs  int `json:"cpus,omitempty"`
	MemMB int `json:"mem_mb,omitempty"`
}

ResourceSpec provides optional resource hints for Tier 2 execution.

type ToolProgress

type ToolProgress struct {
	Content string
	IsError bool
}

ToolProgress carries incremental output during long-running tool execution.

type ToolRequest

type ToolRequest struct {
	SessionID  string
	ToolName   string
	ToolCallID string
	Params     map[string]any
	Resources  *ResourceSpec
}

ToolRequest carries all parameters needed to dispatch a single tool call.

type ToolResponse

type ToolResponse struct {
	Content    []ai.ContentBlock
	SnapshotID string
	ExitCode   *int
}

ToolResponse is the result of a tool execution.

type ToolTier

type ToolTier int

ToolTier classifies tools by execution model.

const (
	Tier1 ToolTier = 1 // In-process Go function execution
	Tier2 ToolTier = 2 // Isolated process execution
)

func ClassifyTool

func ClassifyTool(name string) ToolTier

ClassifyTool returns the tier for a given tool name. This classifier is centralized and shared across all backends.

Directories

Path Synopsis
Package envtools bridges the circular-import gap between internal/agent, internal/tools, and internal/sandbox/environment.
Package envtools bridges the circular-import gap between internal/agent, internal/tools, and internal/sandbox/environment.

Jump to

Keyboard shortcuts

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