tools

package
v2.0.0-...-f08db84 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const AutoExecKey contextKey = "auto_exec"
View Source
const ConfirmedKey contextKey = "confirmed"

ConfirmedKey marks that any required user confirmation for the current tool call has already been obtained (e.g. by PreConfirm), so the tool handler should not prompt again.

Variables

View Source
var AllBuiltinTools = []string{
	"web_search_exa",
	"web_search_firecrawl",
	"read_directory",
	"read_file",
	"execute_command",
	"web_fetch",
	"write_file",
	"edit_file",
	"grep",
	"glob",
}
View Source
var DefaultRegistry = NewRegistry()

Functions

func IsBuiltinTool

func IsBuiltinTool(name string) bool

func ParseToolList

func ParseToolList(input string) ([]string, bool)

func PreConfirm

func PreConfirm(ctx context.Context, name string, argsJSON string) (bool, string, error)

PreConfirm performs any interactive confirmation required for a tool call before execution begins. Callers should invoke this on an undeadlined context (i.e. before starting a per-execution timeout) so that the time spent waiting on user input does not count against the tool's execution budget. It returns (proceed, message, err): if proceed is false, message contains the cancellation message that should be returned as the tool's result without running the handler at all.

Types

type FunctionSpec

type FunctionSpec struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Parameters  map[string]any `json:"parameters"`
}

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, name string, argsJSON string) (string, error)

func (*Registry) GetOpenAITools

func (r *Registry) GetOpenAITools() []any

func (*Registry) Has

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

func (*Registry) ListSpecs

func (r *Registry) ListSpecs() []ToolSpec

func (*Registry) Register

func (r *Registry) Register(spec ToolSpec, handler ToolHandler)

func (*Registry) RegisterBuiltinTools

func (r *Registry) RegisterBuiltinTools(selectedTools ...string)

type ToolHandler

type ToolHandler func(ctx context.Context, args map[string]any) (string, error)

type ToolSpec

type ToolSpec struct {
	Type     string       `json:"type"` // "function"
	Function FunctionSpec `json:"function"`
}

Jump to

Keyboard shortcuts

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