Documentation
¶
Index ¶
- func AllTools() []provider.ToolDefinition
- func DetectVerifyCommand(workDir string) string
- func FileReadTool() provider.ToolDefinition
- func FileWriteTool() provider.ToolDefinition
- func RunVerification(ctx context.Context, command string, workDir string, timeout time.Duration) (output string, success bool, err error)
- func ShellExecTool() provider.ToolDefinition
- type ConfirmFunc
- type Executor
- type ExternalToolHandler
- type ToolLoop
- type ToolResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllTools ¶
func AllTools() []provider.ToolDefinition
AllTools returns all available tool definitions.
func DetectVerifyCommand ¶ added in v0.2.0
DetectVerifyCommand auto-detects the appropriate test/verify command for the project in the given working directory.
func FileReadTool ¶
func FileReadTool() provider.ToolDefinition
FileReadTool returns a ToolDefinition for reading files.
func FileWriteTool ¶
func FileWriteTool() provider.ToolDefinition
FileWriteTool returns a ToolDefinition for writing files.
func RunVerification ¶ added in v0.2.0
func RunVerification(ctx context.Context, command string, workDir string, timeout time.Duration) (output string, success bool, err error)
RunVerification executes a verification command and returns the output and whether it succeeded.
func ShellExecTool ¶
func ShellExecTool() provider.ToolDefinition
ShellExecTool returns a ToolDefinition for executing shell commands.
Types ¶
type ConfirmFunc ¶
ConfirmFunc is a callback that asks the user to confirm an action. It receives the tool name (e.g. "file_write", "shell_exec") and a human-readable description, and returns true if the user approves.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor dispatches tool calls to the appropriate handler.
func NewExecutor ¶
func NewExecutor(confirm ConfirmFunc, cmdTimeout time.Duration) *Executor
NewExecutor creates an Executor with the given confirmation callback and command timeout for shell operations.
func (*Executor) Execute ¶
func (e *Executor) Execute(call provider.ToolCall) ToolResult
Execute parses a ToolCall and routes it to the correct handler.
func (*Executor) SetExternalHandler ¶ added in v1.9.0
func (e *Executor) SetExternalHandler(handler ExternalToolHandler)
SetExternalHandler registers a handler for tool calls not recognized by the built-in executor (e.g. MCP-discovered tools).
type ExternalToolHandler ¶ added in v1.9.0
ExternalToolHandler is a callback for handling tool calls that the built-in executor doesn't recognize (e.g. MCP tools). It receives the tool call and returns the output string or an error.
type ToolLoop ¶
type ToolLoop struct {
// contains filtered or unexported fields
}
ToolLoop manages the iterative cycle of executing tool calls and sending results back to the model until the model produces a final text response.
func NewToolLoop ¶
NewToolLoop creates a ToolLoop with the given executor and primary provider.
func (*ToolLoop) Run ¶
func (l *ToolLoop) Run( ctx context.Context, messages []provider.Message, toolCalls []provider.ToolCall, opts provider.QueryOpts, out chan<- provider.StreamChunk, ) error
Run executes tool calls, appends results as native tool messages, and re-queries the model. It streams chunks to the output channel as they arrive from the provider. It repeats until the model stops issuing tool calls or the context is cancelled.
type ToolResult ¶
ToolResult holds the outcome of executing a single tool call.