tool

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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) 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) 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