tools

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBashOutputBytes = 256 * 1024

MaxBashOutputBytes bounds command output in memory while leaving enough of both ends to diagnose failures. The agent applies its own final transcript cap, but the tool must not buffer an unbounded command before reaching it.

View Source
const MaxReadBytes = 256 * 1024

MaxReadBytes caps the total bytes ReadFile will return in a single call. Files larger than this must be paged via offset/limit.

Variables

This section is empty.

Functions

func ConversationGenerationFrom added in v0.6.2

func ConversationGenerationFrom(ctx context.Context) uint64

ConversationGenerationFrom returns the TUI conversation generation carried by ctx. Zero is the initial generation and the default outside the TUI.

func WithCallMetadata added in v0.4.0

func WithCallMetadata(ctx context.Context, metadata CallMetadata) context.Context

func WithConversationGeneration added in v0.6.2

func WithConversationGeneration(ctx context.Context, generation uint64) context.Context

WithConversationGeneration tags work started by one TUI conversation. Tools copy the value onto buffered UI events at production time, before those events can be delayed by an intermediate channel.

Types

type Bash

type Bash struct {
	Timeout time.Duration
	CWD     string
}

func (Bash) Name

func (Bash) Name() string

func (Bash) Run

func (b Bash) Run(ctx context.Context, input map[string]any) (string, error)

func (Bash) Spec

func (Bash) Spec() llm.ToolSpec

type CallMetadata added in v0.4.0

type CallMetadata struct {
	ToolUseID string
	GroupID   string
	GroupSize int
	GroupPos  int
}

CallMetadata identifies one model-requested tool execution. It is carried through context so tools that supervise nested work can attribute their events without exposing scheduler fields in model-facing schemas.

func CallMetadataFrom added in v0.4.0

func CallMetadataFrom(ctx context.Context) (CallMetadata, bool)

type EditFile

type EditFile struct{}

func (EditFile) Name

func (EditFile) Name() string

func (EditFile) Run

func (EditFile) Run(ctx context.Context, input map[string]any) (string, error)

func (EditFile) Spec

func (EditFile) Spec() llm.ToolSpec

type Glob added in v0.2.0

type Glob struct {
	Root string
}

func (Glob) Name added in v0.2.0

func (Glob) Name() string

func (Glob) ParallelSafe added in v0.4.0

func (Glob) ParallelSafe(map[string]any) bool

func (Glob) Run added in v0.2.0

func (g Glob) Run(ctx context.Context, input map[string]any) (string, error)

func (Glob) Spec added in v0.2.0

func (Glob) Spec() llm.ToolSpec

type Grep added in v0.2.0

type Grep struct {
	Root string
}

func (Grep) Name added in v0.2.0

func (Grep) Name() string

func (Grep) ParallelSafe added in v0.4.0

func (Grep) ParallelSafe(map[string]any) bool

func (Grep) Run added in v0.2.0

func (g Grep) Run(ctx context.Context, input map[string]any) (string, error)

func (Grep) Spec added in v0.2.0

func (Grep) Spec() llm.ToolSpec

type ParallelTool added in v0.4.0

type ParallelTool interface {
	ParallelSafe(input map[string]any) bool
}

ParallelTool is an optional capability for tools that are safe to execute alongside other parallel-safe calls from the same model response. Tools that do not implement it are always serial. The model never controls this decision.

type ReadFile

type ReadFile struct{}

func (ReadFile) Name

func (ReadFile) Name() string

func (ReadFile) ParallelSafe added in v0.4.0

func (ReadFile) ParallelSafe(map[string]any) bool

func (ReadFile) Run

func (ReadFile) Run(ctx context.Context, input map[string]any) (string, error)

func (ReadFile) Spec

func (ReadFile) Spec() llm.ToolSpec

type Registry

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

func NewRegistry

func NewRegistry(ts ...Tool) *Registry

func (*Registry) Filter

func (r *Registry) Filter(names []string) *Registry

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

func (*Registry) Names added in v0.2.0

func (r *Registry) Names() []string

func (*Registry) ParallelSafe added in v0.4.0

func (r *Registry) ParallelSafe(name string, input map[string]any) bool

ParallelSafe reports the tool's runtime-owned concurrency classification. Unknown and unclassified tools fail closed to serial execution.

func (*Registry) Specs

func (r *Registry) Specs() []llm.ToolSpec

type Tool

type Tool interface {
	Name() string
	Spec() llm.ToolSpec
	Run(ctx context.Context, input map[string]any) (string, error)
}

type WriteFile

type WriteFile struct{}

func (WriteFile) Name

func (WriteFile) Name() string

func (WriteFile) Run

func (WriteFile) Run(ctx context.Context, input map[string]any) (string, error)

func (WriteFile) Spec

func (WriteFile) Spec() llm.ToolSpec

Jump to

Keyboard shortcuts

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