action

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

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

func DetectVerifyCommand(workDir string) string

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

type ConfirmFunc func(toolName, description string) bool

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

type ExternalToolHandler func(call provider.ToolCall) (string, error)

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

func NewToolLoop(executor *Executor, primary provider.Provider) *ToolLoop

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 iteration limit is reached.

type ToolResult

type ToolResult struct {
	ToolCallID string
	Output     string
	Error      error
}

ToolResult holds the outcome of executing a single tool call.

Jump to

Keyboard shortcuts

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