tool

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultToolTimeout      = 2 * time.Minute
	DefaultToolMaxResult    = 100_000
	DefaultRetryMaxAttempts = 2
	DefaultRetryInitial     = 200 * time.Millisecond
	DefaultRetryMax         = 2 * time.Second
	DefaultRetryMultiplier  = 2
	DefaultRetryJitter      = 0.2
)
View Source
const ProgressIndeterminate = "indeterminate"

ProgressIndeterminate is the mode value for indeterminate progress bars.

View Source
const ToolCallIDParam = "__buckley_tool_call_id"

ToolCallIDParam allows callers to attach a stable tool call ID for telemetry.

Variables

View Source
var DefaultLongRunningTools = map[string]string{
	"run_shell":          "Shell command",
	"search_text":        "Searching",
	"search_replace":     "Replacing",
	"find_files":         "Scanning files",
	"git_diff":           "Diff",
	"git_log":            "Git log",
	"analyze_complexity": "Analyzing complexity",
	"find_duplicates":    "Finding duplicates",
	"generate_test":      "Generating tests",
}

DefaultLongRunningTools lists tools that should trigger progress indicators.

Functions

func ApplyRegistryConfig

func ApplyRegistryConfig(registry *Registry, cfg RegistryConfig)

ApplyRegistryConfig applies registry defaults and middleware settings.

func DefaultRetryable

func DefaultRetryable(err error) bool

DefaultRetryable determines whether an error should be retried.

func FormatActivityLog

func FormatActivityLog(group *ActivityGroup) string

FormatActivityLog formats an activity group for display

func FromJSON

func FromJSON(jsonStr string) (*builtin.Result, error)

FromJSON parses a result from JSON

func GovernedToolNames added in v1.1.0

func GovernedToolNames(registry *Registry, evaluator types.RuleEvaluator, role, taskType string, baseAllowed []string, budgetUtil float64) []string

GovernedToolNames returns the tool list after skill and arbiter filtering.

func IsToolAllowed

func IsToolAllowed(name string, allowed []string) bool

IsToolAllowed returns true if the tool name is allowed by the filter. An empty allowed list means all tools are allowed.

func RequiredTierForTool added in v1.1.0

func RequiredTierForTool(t Tool) types.PermissionTier

RequiredTierForTool infers the permission tier for a tool from its metadata.

func SetResultEncoding

func SetResultEncoding(useToon bool)

SetResultEncoding toggles whether tool outputs use TOON or JSON encoding.

func ToJSON

func ToJSON(r *builtin.Result) (string, error)

ToJSON converts a result to JSON

func ToOpenAIFunction

func ToOpenAIFunction(t Tool) map[string]any

ToOpenAIFunction converts a tool to OpenAI function calling format

Types

type ActivityGroup

type ActivityGroup struct {
	Category  Category   // Category of tools in this group
	StartTime time.Time  // When first tool was called
	EndTime   time.Time  // When last tool was completed
	ToolCalls []ToolCall // Individual tool calls in this group
	Summary   string     // Human-readable summary
}

ActivityGroup represents a group of related tool calls

type ActivityGroupingConfig

type ActivityGroupingConfig struct {
	WindowSeconds int // Time window for grouping (default: 30)
	Enabled       bool
}

ActivityGroupingConfig holds configuration for activity grouping

func DefaultActivityGroupingConfig

func DefaultActivityGroupingConfig() ActivityGroupingConfig

DefaultActivityGroupingConfig returns sensible defaults

type ActivityTracker

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

ActivityTracker tracks tool calls and groups them for display

func NewActivityTracker

func NewActivityTracker(config ActivityGroupingConfig) *ActivityTracker

NewActivityTracker creates a new activity tracker

func (*ActivityTracker) GetGroups

func (t *ActivityTracker) GetGroups() []ActivityGroup

GetGroups returns all activity groups

func (*ActivityTracker) GetLatestGroup

func (t *ActivityTracker) GetLatestGroup() *ActivityGroup

GetLatestGroup returns the most recent activity group

func (*ActivityTracker) RecordCall

func (t *ActivityTracker) RecordCall(tool Tool, params map[string]any, result *builtin.Result, startTime, endTime time.Time)

RecordCall records a tool call for potential grouping

type Category

type Category string

Category represents the functional category of a tool

const (
	CategoryCodebase      Category = "codebase"      // grep, find_symbol, search
	CategoryGit           Category = "git"           // git_status, git_diff, git_log
	CategoryTesting       Category = "testing"       // run_tests, generate_test
	CategoryFilesystem    Category = "filesystem"    // read, write, edit, list
	CategoryRefactoring   Category = "refactoring"   // rename_symbol, extract_function
	CategoryDocumentation Category = "documentation" // generate_docstring, explain_code
	CategoryAnalysis      Category = "analysis"      // analyze_complexity, find_duplicates
	CategoryDelegation    Category = "delegation"    // buckley, subagent, codex
	CategoryBrowser       Category = "browser"       // headless_browse
	CategoryShell         Category = "shell"         // shell_command
	CategoryPlanning      Category = "planning"      // todo, checkpoint
)

type ContextTool

type ContextTool interface {
	ExecuteWithContext(ctx context.Context, params map[string]any) (*builtin.Result, error)
}

ContextTool is an optional interface for tools that accept contexts.

type Cost

type Cost string

Cost represents the resource cost of a tool operation

const (
	CostFree      Cost = "free"      // bash, read - no API calls
	CostCheap     Cost = "cheap"     // grep, glob - minimal processing
	CostExpensive Cost = "expensive" // search (embeddings), compaction - uses LLM
)

type Executable added in v1.1.0

type Executable interface {
	Name() string
	Kind() ExecutableKind
	RequiredTier() types.PermissionTier
	Execute(ctx context.Context, input map[string]any) (*ExecutionResult, error)
}

Executable is the unified interface for both tools and slash commands.

type ExecutableKind added in v1.1.0

type ExecutableKind int

ExecutableKind distinguishes tools from commands.

const (
	ToolKind ExecutableKind = iota
	CommandKind
)

type ExecutionContext

type ExecutionContext struct {
	Context   context.Context
	ToolName  string
	Tool      Tool
	SessionID string
	CallID    string
	Params    map[string]any
	StartTime time.Time
	Attempt   int
	Metadata  map[string]any
}

ExecutionContext carries request metadata through the middleware chain.

type ExecutionRegistry added in v1.1.0

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

ExecutionRegistry is the single dispatch surface with arbiter governance.

func NewExecutionRegistry added in v1.1.0

func NewExecutionRegistry(
	evaluator types.RuleEvaluator,
	escalator types.PermissionEscalator,
	sandbox types.SandboxResolver,
) *ExecutionRegistry

NewExecutionRegistry creates a governed execution registry.

func (*ExecutionRegistry) Execute added in v1.1.0

func (r *ExecutionRegistry) Execute(ctx context.Context, name string, input map[string]any, role string) (*ExecutionResult, error)

Execute dispatches a named executable with full governance.

func (*ExecutionRegistry) FilterTo added in v1.1.0

func (r *ExecutionRegistry) FilterTo(config PoolConfig) *ToolPool

FilterTo creates a ToolPool from the registry with the given config.

func (*ExecutionRegistry) Register added in v1.1.0

func (r *ExecutionRegistry) Register(exec Executable)

Register adds an executable to the registry.

type ExecutionResult added in v1.1.0

type ExecutionResult struct {
	Output  string
	IsError bool
}

ExecutionResult is the output of an executable.

type Executor

type Executor func(ctx *ExecutionContext) (*builtin.Result, error)

Executor is the function signature for tool execution.

type HookRegistry

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

HookRegistry stores pre/post hooks per tool name.

func (*HookRegistry) PostHooks

func (h *HookRegistry) PostHooks(toolName string) []PostHook

PostHooks returns hooks in order: "*" then tool-specific.

func (*HookRegistry) PreHooks

func (h *HookRegistry) PreHooks(toolName string) []PreHook

PreHooks returns hooks in order: "*" then tool-specific.

func (*HookRegistry) RegisterPostHook

func (h *HookRegistry) RegisterPostHook(toolName string, hook PostHook)

RegisterPostHook registers a post-hook for a tool name or "*".

func (*HookRegistry) RegisterPreHook

func (h *HookRegistry) RegisterPreHook(toolName string, hook PreHook)

RegisterPreHook registers a pre-hook for a tool name or "*".

func (*HookRegistry) UnregisterHook

func (h *HookRegistry) UnregisterHook(toolName string, hook any)

UnregisterHook removes a previously registered hook for a tool name or "*".

type HookResult

type HookResult struct {
	Abort          bool
	ModifiedParams map[string]any
	AbortReason    string
	AbortResult    *builtin.Result
}

HookResult describes how a pre-hook wants to adjust execution.

type Impact

type Impact string

Impact represents the impact level of a tool operation

const (
	ImpactReadOnly    Impact = "readonly"    // read, grep, glob - no modifications
	ImpactModifying   Impact = "modifying"   // edit, write - modifies files
	ImpactDestructive Impact = "destructive" // delete, git reset - destructive operations
)

type Intent

type Intent struct {
	Phase        string    // "planning", "execution", "review"
	Activity     string    // High-level activity description
	Tools        []string  // Tools that will be used
	ExpectedTime string    // Estimated time (e.g., "~30 seconds")
	Timestamp    time.Time // When intent was declared
}

Intent represents a statement of what the agent is about to do

type IntentBuilder

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

IntentBuilder helps construct intent statements

func NewIntentBuilder

func NewIntentBuilder(phase string) *IntentBuilder

NewIntentBuilder creates a new intent builder

func (*IntentBuilder) Activity

func (b *IntentBuilder) Activity(activity string) *IntentBuilder

Activity sets the high-level activity description

func (*IntentBuilder) AddParam

func (b *IntentBuilder) AddParam(key string, value any) *IntentBuilder

AddParam adds a parameter for template substitution

func (*IntentBuilder) AddTool

func (b *IntentBuilder) AddTool(toolName string) *IntentBuilder

AddTool adds a tool to the intent

func (*IntentBuilder) Build

func (b *IntentBuilder) Build() Intent

Build creates the intent statement

type IntentFormatter

type IntentFormatter struct{}

IntentFormatter formats intent statements for display

func NewIntentFormatter

func NewIntentFormatter() *IntentFormatter

NewIntentFormatter creates a new intent formatter

func (*IntentFormatter) Format

func (f *IntentFormatter) Format(intent Intent) string

Format formats an intent for display

func (*IntentFormatter) FormatCompact

func (f *IntentFormatter) FormatCompact(intent Intent) string

FormatCompact creates a compact single-line intent

func (*IntentFormatter) FormatWithDetails

func (f *IntentFormatter) FormatWithDetails(intent Intent) string

FormatWithDetails formats an intent with detailed information

type IntentHistory

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

IntentHistory tracks intent statements for a session

func NewIntentHistory

func NewIntentHistory() *IntentHistory

NewIntentHistory creates a new intent history

func (*IntentHistory) Add

func (h *IntentHistory) Add(intent Intent)

Add adds an intent to the history

func (*IntentHistory) Clear

func (h *IntentHistory) Clear()

Clear clears the intent history

func (*IntentHistory) Count

func (h *IntentHistory) Count() int

Count returns the number of intents

func (*IntentHistory) GetAll

func (h *IntentHistory) GetAll() []Intent

GetAll returns all intents

func (*IntentHistory) GetByPhase

func (h *IntentHistory) GetByPhase(phase string) []Intent

GetByPhase returns intents for a specific phase

func (*IntentHistory) GetLatest

func (h *IntentHistory) GetLatest() *Intent

GetLatest returns the most recent intent

func (*IntentHistory) GetRecent

func (h *IntentHistory) GetRecent(n int) []Intent

GetRecent returns the N most recent intents

type IntentLibrary

type IntentLibrary struct{}

IntentLibrary provides pre-built intent templates for common activities

func NewIntentLibrary

func NewIntentLibrary() *IntentLibrary

NewIntentLibrary creates a new intent library

func (*IntentLibrary) AnalyzingCodebase

func (l *IntentLibrary) AnalyzingCodebase(phase string, target string) Intent

AnalyzingCodebase creates an intent for codebase analysis

func (*IntentLibrary) FixingIssue

func (l *IntentLibrary) FixingIssue(issueID int, title string) Intent

FixingIssue creates an intent for fixing a review issue

func (*IntentLibrary) GeneratingArtifact

func (l *IntentLibrary) GeneratingArtifact(artifactType string) Intent

GeneratingArtifact creates an intent for artifact generation

func (*IntentLibrary) ImplementingTask

func (l *IntentLibrary) ImplementingTask(taskID int, description string) Intent

ImplementingTask creates an intent for implementing a task

func (*IntentLibrary) RefactoringCode

func (l *IntentLibrary) RefactoringCode(description string) Intent

RefactoringCode creates an intent for refactoring

func (*IntentLibrary) RunningTests

func (l *IntentLibrary) RunningTests(testPath string) Intent

RunningTests creates an intent for running tests

func (*IntentLibrary) SearchingForPattern

func (l *IntentLibrary) SearchingForPattern(pattern string, scope string) Intent

SearchingForPattern creates an intent for pattern searching

func (*IntentLibrary) ValidatingImplementation

func (l *IntentLibrary) ValidatingImplementation(aspect string) Intent

ValidatingImplementation creates an intent for review validation

type Middleware

type Middleware func(next Executor) Executor

Middleware wraps an Executor with additional behavior.

func Chain

func Chain(middlewares ...Middleware) Middleware

Chain composes middlewares in order (first middleware is outermost).

func DefaultMiddlewareStack

func DefaultMiddlewareStack(cfg MiddlewareConfig) []Middleware

DefaultMiddlewareStack returns the default middleware chain.

func DockerSandboxMiddleware

func DockerSandboxMiddleware(sandbox SandboxExecutor, kindLookup func(string) string) Middleware

DockerSandboxMiddleware intercepts shell-executing tools and routes them through the provided SandboxExecutor. Read-only tools pass through untouched.

func FileChangeTracking

func FileChangeTracking(watcher *filewatch.FileWatcher) Middleware

FileChangeTracking emits file change notifications for write/edit tools.

func Hooks

func Hooks(registry *HookRegistry) Middleware

Hooks runs registered pre/post hooks around tool execution.

func PanicRecovery

func PanicRecovery() Middleware

PanicRecovery converts panics into tool errors and records stack traces in metadata.

func Progress

func Progress(manager ProgressTracker, longRunning map[string]string) Middleware

Progress reports tool execution progress to the manager.

func ResultSizeLimit

func ResultSizeLimit(maxBytes int, suffix string) Middleware

ResultSizeLimit truncates oversized tool results.

func Retry

func Retry(cfg RetryConfig) Middleware

Retry retries tool execution with exponential backoff.

func Timeout

func Timeout(defaultTimeout time.Duration, perTool map[string]time.Duration) Middleware

Timeout applies a per-tool or default timeout by updating the context.

func ToastNotifications

func ToastNotifications(manager ToastNotifier) Middleware

ToastNotifications emits toast messages for tool failures.

func Validation

func Validation(cfg ValidationConfig, onError func(tool, param, msg string)) Middleware

Validation applies configured validation rules before executing tools.

type MiddlewareConfig

type MiddlewareConfig struct {
	ToastManager    ToastNotifier
	ProgressManager ProgressTracker
	FileWatcher     *filewatch.FileWatcher

	DefaultTimeout   time.Duration
	PerToolTimeouts  map[string]time.Duration
	RetryConfig      RetryConfig
	MaxResultBytes   int
	LongRunningTools map[string]string

	ValidationConfig  ValidationConfig
	OnValidationError func(tool, param, msg string)
}

MiddlewareConfig configures the default middleware stack.

type PermissionDeniedError added in v1.1.0

type PermissionDeniedError struct {
	Tool   string
	Reason string
}

PermissionDeniedError indicates a tool call was denied.

func (*PermissionDeniedError) Error added in v1.1.0

func (e *PermissionDeniedError) Error() string

type PoolConfig added in v1.1.0

type PoolConfig struct {
	Mode         PoolMode
	IncludeMCP   bool
	ExcludeTools []string
}

PoolConfig describes a filtered tool set.

type PoolMode added in v1.1.0

type PoolMode int

PoolMode controls tool filtering.

const (
	PoolFull     PoolMode = iota // all tools
	PoolStandard                 // no danger tools
	PoolSimple                   // read + edit + bash only
	PoolReadOnly                 // read + search only
)

type PostHook

type PostHook func(ctx *ExecutionContext, result *builtin.Result, err error) (*builtin.Result, error)

PostHook runs after a tool executes.

type PreHook

type PreHook func(ctx *ExecutionContext) HookResult

PreHook runs before a tool executes.

type ProgressTracker

type ProgressTracker interface {
	Start(id, label string, mode string, total int)
	Done(id string)
}

ProgressTracker reports start/done events for long-running tools.

type Registry

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

Registry manages all available tools

func NewEmptyRegistry

func NewEmptyRegistry() *Registry

NewEmptyRegistry creates a new empty tool registry without any built-in tools

func NewRegistry

func NewRegistry(opts ...RegistryOption) *Registry

NewRegistry creates a new tool registry with built-in tools

func (*Registry) Close

func (r *Registry) Close() error

Close releases resources held by the registry, including sandbox containers.

func (*Registry) ConfigureContainers

func (r *Registry) ConfigureContainers(cfg *config.Config, repoRoot string)

ConfigureContainers wires container support for shell execution when enabled.

func (*Registry) ConfigureDockerSandbox

func (r *Registry) ConfigureDockerSandbox(cfg *config.Config, workDir string)

ConfigureDockerSandbox sets up Docker-based OS-level sandboxing when enabled.

func (*Registry) ConfigureTodoPlanning

func (r *Registry) ConfigureTodoPlanning(llmClient builtin.PlanningClient, planningModel string)

ConfigureTodoPlanning enables planning capabilities on the TodoTool

func (*Registry) ContainerInfo

func (r *Registry) ContainerInfo() (enabled bool, composePath string, workDir string)

ContainerInfo exposes whether container execution is enabled and the compose details.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered tools

func (*Registry) DisableContainers

func (r *Registry) DisableContainers()

DisableContainers disables container execution

func (*Registry) EnableCodeIndex

func (r *Registry) EnableCodeIndex(store *storage.Store)

EnableCodeIndex registers context lookup tools backed by storage.

func (*Registry) EnableContainers

func (r *Registry) EnableContainers(composePath, workDir string)

EnableContainers configures the registry to run tools inside containers.

func (*Registry) EnableMissionControl

func (r *Registry) EnableMissionControl(store *mission.Store, agentID string, requireApproval bool, timeout time.Duration)

EnableMissionControl configures mission-control-backed approvals for mutating tools. When requireApproval is true, write_file/apply_patch will block until approved.

func (*Registry) EnableSemanticSearch

func (r *Registry) EnableSemanticSearch(searcher *embeddings.Searcher)

EnableSemanticSearch registers semantic search tools

func (*Registry) EnableTelemetry

func (r *Registry) EnableTelemetry(hub *telemetry.Hub, sessionID string)

EnableTelemetry wires telemetry events for selected built-in tools.

func (*Registry) Execute

func (r *Registry) Execute(name string, params map[string]any) (*builtin.Result, error)

Execute executes a tool by name using a background context.

func (*Registry) ExecuteWithContext

func (r *Registry) ExecuteWithContext(ctx context.Context, name string, params map[string]any) (*builtin.Result, error)

ExecuteWithContext executes a tool by name using the provided context.

func (*Registry) Filter

func (r *Registry) Filter(keep func(Tool) bool)

Filter removes tools that do not match the predicate.

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

Get returns a tool by name

func (*Registry) GetTodoTool

func (r *Registry) GetTodoTool() *builtin.TodoTool

GetTodoTool returns the registered TodoTool, or nil if not registered

func (*Registry) Hooks

func (r *Registry) Hooks() *HookRegistry

Hooks returns the registry hook manager.

func (*Registry) List

func (r *Registry) List() []Tool

List returns all registered tools

func (*Registry) LoadDefaultPlugins

func (r *Registry) LoadDefaultPlugins() error

LoadDefaultPlugins loads plugins from standard locations

func (*Registry) LoadExternal

func (r *Registry) LoadExternal(pluginDir string) error

LoadExternal loads external plugin tools from a directory

func (*Registry) LoadExternalFromMultipleDirs

func (r *Registry) LoadExternalFromMultipleDirs(dirs []string) error

LoadExternalFromMultipleDirs loads external plugins from multiple directories

func (*Registry) Register

func (r *Registry) Register(t Tool)

Register registers a tool

func (*Registry) Remove

func (r *Registry) Remove(name string)

Remove unregisters a tool by name.

func (*Registry) RequiredTier added in v1.1.0

func (r *Registry) RequiredTier(name string) types.PermissionTier

RequiredTier returns the inferred tier for a registered tool.

func (*Registry) SetCompactionManager

func (r *Registry) SetCompactionManager(compactor builtin.Compactor)

SetCompactionManager registers the compact_context tool.

func (*Registry) SetContainerContext

func (r *Registry) SetContainerContext(composePath, workDir string)

SetContainerContext tracks compose/workdir metadata without forcing container execution.

func (*Registry) SetEnv

func (r *Registry) SetEnv(env map[string]string)

SetEnv configures environment variable overrides for tools that support it.

func (*Registry) SetMaxExecTimeSeconds

func (r *Registry) SetMaxExecTimeSeconds(seconds int32)

SetMaxExecTimeSeconds configures a global max execution time for tools that support it.

func (*Registry) SetMaxFileSizeBytes

func (r *Registry) SetMaxFileSizeBytes(max int64)

SetMaxFileSizeBytes configures file size limits for tools that support it.

func (*Registry) SetMaxOutputBytes

func (r *Registry) SetMaxOutputBytes(max int)

SetMaxOutputBytes configures a global max output size for tools that support it.

func (*Registry) SetSandboxConfig

func (r *Registry) SetSandboxConfig(cfg any)

SetSandboxConfig configures command sandboxing for tools that support it. The cfg value is passed through to each tool that implements a SetSandboxConfig method, allowing the tool package to remain decoupled from the concrete sandbox.Config type.

func (*Registry) SetTodoStore

func (r *Registry) SetTodoStore(store builtin.TodoStore)

SetTodoStore initializes the TODO tool with a storage backend

func (*Registry) SetToolKind

func (r *Registry) SetToolKind(toolName, kind string)

SetToolKind associates an ACP tool_call kind with a tool name. Valid kinds are defined in pkg/acp/types.go (read, edit, delete, execute, etc.).

func (*Registry) SetWorkDir

func (r *Registry) SetWorkDir(workDir string)

SetWorkDir configures a base working directory for tools that support it. Tools may use this to resolve relative paths and run shell/git commands in the correct repository root (critical for hosted/multi-project deployments).

func (*Registry) ToOpenAIFunctions

func (r *Registry) ToOpenAIFunctions() []map[string]any

ToOpenAIFunctions converts all tools to OpenAI function calling format

func (*Registry) ToOpenAIFunctionsFiltered

func (r *Registry) ToOpenAIFunctionsFiltered(allowed []string) []map[string]any

ToOpenAIFunctionsFiltered converts only allowed tools to OpenAI function format. If allowed is empty, all tools are returned.

func (*Registry) ToOpenAIFunctionsGoverned added in v1.1.0

func (r *Registry) ToOpenAIFunctionsGoverned(evaluator types.RuleEvaluator, role, taskType string, baseAllowed []string, budgetUtil float64) []map[string]any

ToOpenAIFunctionsGoverned applies skill and arbiter filtering before exposing tools.

func (*Registry) ToolKind

func (r *Registry) ToolKind(toolName string) string

ToolKind returns the ACP tool_call kind for a tool, or empty string if not set.

func (*Registry) UpdateMissionAgent

func (r *Registry) UpdateMissionAgent(agentID string)

UpdateMissionAgent updates the agent identifier recorded alongside pending changes.

func (*Registry) UpdateMissionSession

func (r *Registry) UpdateMissionSession(sessionID string)

UpdateMissionSession updates the active session used when recording pending changes.

func (*Registry) UpdateTelemetrySession

func (r *Registry) UpdateTelemetrySession(sessionID string)

UpdateTelemetrySession updates the active session used for telemetry fan-out.

func (*Registry) Use

func (r *Registry) Use(mw Middleware)

Use registers a middleware on the registry.

type RegistryConfig

type RegistryConfig struct {
	TelemetryHub       *telemetry.Hub
	TelemetrySessionID string
	HookRegistry       *HookRegistry

	MissionStore           *mission.Store
	MissionSessionID       string
	MissionAgentID         string
	MissionTimeout         time.Duration
	RequireMissionApproval bool

	MaxOutputBytes int
	Middleware     MiddlewareConfig
}

RegistryConfig configures registry defaults and middleware options.

func DefaultRegistryConfig

func DefaultRegistryConfig() RegistryConfig

DefaultRegistryConfig returns baseline defaults for registry setup.

type RegistryOption

type RegistryOption func(*registryOptions)

RegistryOption configures optional settings for a Registry.

func WithBuiltinFilter

func WithBuiltinFilter(filter func(Tool) bool) RegistryOption

WithBuiltinFilter allows callers to filter built-in tools during registry construction.

func WithKind

func WithKind(toolName, kind string) RegistryOption

WithKind sets the ACP tool_call kind for a tool during registry construction.

type RetryConfig

type RetryConfig struct {
	MaxAttempts   int
	InitialDelay  time.Duration
	MaxDelay      time.Duration
	Multiplier    float64
	Jitter        float64
	RetryableFunc func(error) bool
}

RetryConfig configures retry behavior.

type RichTool

type RichTool interface {
	Tool
	Metadata() ToolMetadata
}

RichTool is an optional interface that tools can implement for enhanced UI Tools that don't implement this will use default metadata

type SandboxExecutor

type SandboxExecutor interface {
	Execute(ctx context.Context, req SandboxRequest) (*SandboxResult, error)
	Ready(ctx context.Context) error
	Close() error
}

SandboxExecutor defines the interface for OS-level sandbox execution. Implementations route shell commands to isolated environments (e.g. Docker containers).

type SandboxRequest

type SandboxRequest struct {
	Command  string
	WorkDir  string
	Env      map[string]string
	Timeout  time.Duration
	ToolName string
}

SandboxRequest describes a command to execute inside the sandbox.

type SandboxResult

type SandboxResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
	Duration time.Duration
	Killed   bool
}

SandboxResult holds the output of a sandboxed command execution.

type ToastNotifier

type ToastNotifier interface {
	Error(title, message string)
}

ToastNotifier sends user-visible toast notifications.

type Tool

type Tool interface {
	Name() string
	Description() string
	Parameters() builtin.ParameterSchema
	Execute(params map[string]any) (*builtin.Result, error)
}

Tool represents a tool that can be called by the LLM

type ToolCall

type ToolCall struct {
	Tool      Tool
	Params    map[string]any
	Result    *builtin.Result
	StartTime time.Time
	EndTime   time.Time
	Duration  time.Duration
	Metadata  ToolMetadata
}

ToolCall represents a single tool invocation with timing

type ToolMetadata

type ToolMetadata struct {
	Category     Category // Functional category
	Intent       string   // Template for intent display: "Searching for {pattern} in {path}"
	Summary      string   // Template for result summary: "Found {count} matches in {files} files"
	Impact       Impact   // Operation impact level
	Cost         Cost     // Resource cost
	ExampleUsage string   // Example of how to use this tool
}

ToolMetadata contains rich metadata for enhanced UI display

func DefaultMetadata

func DefaultMetadata() ToolMetadata

DefaultMetadata returns default metadata for tools without explicit metadata

func GetMetadata

func GetMetadata(t Tool) ToolMetadata

GetMetadata returns metadata for a tool, with fallback to defaults

type ToolPool added in v1.1.0

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

ToolPool is an immutable filtered set of executables.

func AssemblePool added in v1.1.0

func AssemblePool(registry *ExecutionRegistry, evaluator types.RuleEvaluator, role, taskType string) *ToolPool

AssemblePool builds a filtered tool set using arbiter governance.

func (*ToolPool) Has added in v1.1.0

func (p *ToolPool) Has(name string) bool

Has returns whether the pool contains the named executable.

func (*ToolPool) List added in v1.1.0

func (p *ToolPool) List() []string

List returns all executable names in the pool.

type ValidationConfig

type ValidationConfig struct {
	Rules []ValidationRule
}

ValidationConfig collects validation rules.

type ValidationRule

type ValidationRule struct {
	Tool     string
	Param    string
	Validate Validator
}

ValidationRule defines a validation rule for a tool parameter.

type Validator

type Validator func(value any) error

Validator checks a parameter value.

func ValidateNonEmpty

func ValidateNonEmpty() Validator

ValidateNonEmpty ensures a parameter is non-empty.

func ValidatePath

func ValidatePath(baseDir string) Validator

ValidatePath ensures a path is non-empty and within baseDir (when provided).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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