custom

package
v0.216.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTools

func NewTools(cfg *config.Config, builtins []string) map[string]agentdomain.Tool

NewTools loads the user's custom tools from tools.custom_dir (default ~/.infer/tools), then the project's from .agents/tools and .infer/tools. A project tool replaces a user tool of the same name, and .infer/tools wins. A project dir that is the user dir under any alias is skipped, so the user's own tools keep their approval.

Types

type Tool

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

Tool runs a custom tool's command: the call's arguments go to stdin as one JSON object and stdout is the result.

func (*Tool) Definition

func (t *Tool) Definition() sdk.ChatCompletionTool

Definition returns the manifest's description and JSON Schema.

func (*Tool) Execute

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

Execute runs the command and reports a failed call in the result, not as an error, so the model reads why it failed.

func (*Tool) FormatPreview

func (t *Tool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns the first lines of the output, or the error.

func (*Tool) FormatResult

func (t *Tool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats the result for the UI, the model or a preview.

func (*Tool) IsEnabled

func (t *Tool) IsEnabled() bool

IsEnabled is always true: a disabled manifest never loads.

func (*Tool) Manifest

func (t *Tool) Manifest() agentdomain.ToolManifest

Manifest returns the manifest as declared, so the registry answers the tool's modes and approval like a built-in's.

func (*Tool) ShouldAlwaysExpand

func (t *Tool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand leaves the result collapsed by default.

func (*Tool) ShouldCollapseArg

func (t *Tool) ShouldCollapseArg(key string) bool

ShouldCollapseArg keeps every argument visible.

func (*Tool) Validate

func (t *Tool) Validate(args map[string]any) error

Validate checks the arguments against the manifest's parameters.

Jump to

Keyboard shortcuts

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