action

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: AGPL-3.0 Imports: 12 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 BuildProjectContext added in v1.17.0

func BuildProjectContext(workDir string) string

BuildProjectContext generates a snapshot of the project structure and key files for inclusion in the system prompt. This gives providers immediate context without needing a tool round to explore.

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 FileDeleteTool added in v1.18.0

func FileDeleteTool() provider.ToolDefinition

FileDeleteTool returns a ToolDefinition for deleting files or empty directories.

func FileEditTool added in v1.18.0

func FileEditTool() provider.ToolDefinition

FileEditTool returns a ToolDefinition for targeted search-and-replace editing.

func FileInfoTool added in v1.18.0

func FileInfoTool() provider.ToolDefinition

FileInfoTool returns a ToolDefinition for getting file metadata.

func FileReadTool

func FileReadTool() provider.ToolDefinition

FileReadTool returns a ToolDefinition for reading files.

func FileRenameTool added in v1.18.0

func FileRenameTool() provider.ToolDefinition

FileRenameTool returns a ToolDefinition for renaming or moving files.

func FileWriteTool

func FileWriteTool() provider.ToolDefinition

FileWriteTool returns a ToolDefinition for writing files.

func FindFilesTool added in v1.18.0

func FindFilesTool() provider.ToolDefinition

FindFilesTool returns a ToolDefinition for glob-based file search.

func GrepSearchTool added in v1.16.0

func GrepSearchTool() provider.ToolDefinition

GrepSearchTool returns a ToolDefinition for searching file contents.

func ListDirectoryTool added in v1.16.0

func ListDirectoryTool() provider.ToolDefinition

ListDirectoryTool returns a ToolDefinition for listing directory contents.

func ReadOnlyTools added in v1.13.0

func ReadOnlyTools() []provider.ToolDefinition

ReadOnlyTools returns tool definitions that are safe for concurrent fan-out execution — read-only operations with no side effects.

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.

func ToolUsageHints added in v1.17.0

func ToolUsageHints() string

ToolUsageHints returns guidance text for providers on how to use the available read-only tools effectively during fan-out.

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 context is cancelled.

func (*ToolLoop) RunWithMessages added in v1.13.0

func (l *ToolLoop) RunWithMessages(
	ctx context.Context,
	messages []provider.Message,
	toolCalls []provider.ToolCall,
	opts provider.QueryOpts,
	out chan<- provider.StreamChunk,
) ([]provider.Message, error)

RunWithMessages is like Run but also returns the messages appended during the tool loop (tool results + follow-up assistant messages). These can be used to preserve structured tool call history in the conversation state.

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