Documentation
¶
Index ¶
- func NewTools(cfg *config.Config, builtins []string) map[string]agentdomain.Tool
- type Tool
- func (t *Tool) Definition() sdk.ChatCompletionTool
- func (t *Tool) Execute(ctx context.Context, args map[string]any) (*agentdomain.ToolExecutionResult, error)
- func (t *Tool) FormatPreview(result *agentdomain.ToolExecutionResult) string
- func (t *Tool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string
- func (t *Tool) IsEnabled() bool
- func (t *Tool) Manifest() agentdomain.ToolManifest
- func (t *Tool) ShouldAlwaysExpand() bool
- func (t *Tool) ShouldCollapseArg(key string) bool
- func (t *Tool) Validate(args map[string]any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTools ¶
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) 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 ¶
ShouldAlwaysExpand leaves the result collapsed by default.
func (*Tool) ShouldCollapseArg ¶
ShouldCollapseArg keeps every argument visible.