toolchain

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildApprovalSummary

func BuildApprovalSummary(toolName string, params map[string]interface{}) string

BuildApprovalSummary returns a human-readable description of what a tool invocation will do, suitable for display in approval messages.

func Chain

func Chain(tool *agent.Tool, middlewares ...Middleware) *agent.Tool

Chain applies middlewares to a single tool, returning a new tool with wrapped handler. Middlewares are applied in order: first middleware is outermost (executed first).

func ChainAll

func ChainAll(tools []*agent.Tool, middlewares ...Middleware) []*agent.Tool

ChainAll applies the same middleware stack to all tools.

func NeedsApproval

func NeedsApproval(t *agent.Tool, ic config.InterceptorConfig) bool

NeedsApproval determines whether a tool requires approval based on the configured policy, explicit exemptions, and sensitive tool lists.

func Truncate

func Truncate(s string, maxLen int) string

Truncate shortens s to maxLen characters, appending "..." if truncated.

Types

type Middleware

type Middleware func(tool *agent.Tool, next agent.ToolHandler) agent.ToolHandler

Middleware wraps a tool handler. It receives the tool (for metadata access) and the next handler.

func WithApproval

WithApproval returns a middleware that gates tool execution behind an approval flow. Uses fail-closed: denies execution unless explicitly approved. The Provider routes requests to the appropriate channel (Gateway, Telegram, Discord, Slack, TTY). The GrantStore tracks "always allow" grants to auto-approve repeat invocations within a session. When limiter is non-nil, payment tools with an amount below the auto-approve threshold are executed without explicit user confirmation.

func WithBrowserRecovery

func WithBrowserRecovery(sm *browser.SessionManager) Middleware

WithBrowserRecovery returns a middleware that provides panic recovery and auto-reconnect for browser tools. It only applies to tools whose name starts with "browser_"; other tools pass through unchanged.

func WithLearning

func WithLearning(observer learning.ToolResultObserver) Middleware

WithLearning returns a middleware that observes tool results for learning. After each handler execution the observer is called with session key, tool name, parameters, result, and any error.

Jump to

Keyboard shortcuts

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