tool

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBinary added in v0.7.0

func IsBinary(data string) bool

IsBinary reports whether data appears to be binary (non-text) content. It samples up to the first 8KB and checks for a high ratio of non-UTF-8 bytes or null bytes, which are reliable indicators of binary data.

func TruncateHead

func TruncateHead(output string) truncationResult

TruncateHead keeps the first N lines / bytes (whichever limit is hit first). Suitable for file reads and search results where the beginning matters most.

func TruncateTail

func TruncateTail(output string) truncationResult

TruncateTail keeps the last N lines / bytes (whichever limit is hit first). Suitable for command output and logs where the end matters most.

Types

type BashTool

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

BashTool executes bash commands.

func (*BashTool) Definition

func (t *BashTool) Definition() toolspec.Definition

func (*BashTool) Execute

func (t *BashTool) Execute(ctx context.Context, args map[string]any) (string, error)

type DelegateConfig added in v0.6.2

type DelegateConfig struct {
	Engine      *engine.Engine
	Registry    *Registry
	Model       ai.Model
	APIKey      string
	System      string
	PluginHooks engine.PluginHookRunner // optional plugin lifecycle hooks
}

DelegateConfig holds the dependencies needed to spawn subagent loops.

type DelegateTool added in v0.6.2

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

DelegateTool spawns child agent loops for bounded subtasks.

func NewDelegateTool added in v0.6.2

func NewDelegateTool(cfg DelegateConfig) *DelegateTool

NewDelegateTool creates a delegate tool with the given configuration.

func (*DelegateTool) Definition added in v0.6.2

func (t *DelegateTool) Definition() toolspec.Definition

func (*DelegateTool) Execute added in v0.6.2

func (t *DelegateTool) Execute(ctx context.Context, args map[string]any) (string, error)

type EditTool

type EditTool struct{}

EditTool makes surgical edits to files by exact string replacement.

func (*EditTool) Definition

func (t *EditTool) Definition() toolspec.Definition

func (*EditTool) Execute

func (t *EditTool) Execute(_ context.Context, args map[string]any) (string, error)

type ReadTool

type ReadTool struct{}

ReadTool reads file contents.

func (*ReadTool) Definition

func (t *ReadTool) Definition() toolspec.Definition

func (*ReadTool) Execute

func (t *ReadTool) Execute(_ context.Context, args map[string]any) (string, error)

type Registry

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

Registry holds named tools and provides lookup + definitions.

func NewRegistry

func NewRegistry(workDir string) *Registry

NewRegistry creates a registry with the default built-in tools.

func (*Registry) BuiltinNames added in v0.7.0

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

BuiltinNames returns the names of all currently registered tools.

func (*Registry) Definitions

func (r *Registry) Definitions() []toolspec.Definition

Definitions returns all tool definitions for passing to the LLM.

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, name string, args map[string]any) (string, error)

Execute runs the named tool with given arguments.

func (*Registry) Has added in v0.6.2

func (r *Registry) Has(name string) bool

Has reports whether the registry contains a tool with the given name.

func (*Registry) Register

func (r *Registry) Register(t Tool)

Register adds a tool to the registry.

type Tool

type Tool interface {
	Definition() toolspec.Definition
	Execute(ctx context.Context, args map[string]any) (string, error)
}

Tool is a built-in tool that can be executed by the Go runner.

type WebFetchTool

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

WebFetchTool fetches a URL, extracts readable content, and returns it in the requested format.

func NewWebFetchTool

func NewWebFetchTool() *WebFetchTool

func (*WebFetchTool) Definition

func (t *WebFetchTool) Definition() toolspec.Definition

func (*WebFetchTool) Execute

func (t *WebFetchTool) Execute(ctx context.Context, args map[string]any) (string, error)

type WriteTool

type WriteTool struct{}

WriteTool creates new files or completely overwrites existing ones.

func (*WriteTool) Definition

func (t *WriteTool) Definition() toolspec.Definition

func (*WriteTool) Execute

func (t *WriteTool) Execute(_ context.Context, args map[string]any) (string, error)

Jump to

Keyboard shortcuts

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