Documentation
¶
Index ¶
- func BuildApprovalSummary(toolName string, params map[string]interface{}) string
- func Chain(tool *agent.Tool, middlewares ...Middleware) *agent.Tool
- func ChainAll(tools []*agent.Tool, middlewares ...Middleware) []*agent.Tool
- func NeedsApproval(t *agent.Tool, ic config.InterceptorConfig) bool
- func Truncate(s string, maxLen int) string
- type Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildApprovalSummary ¶
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.
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 ¶
func WithApproval(ic config.InterceptorConfig, ap approval.Provider, gs *approval.GrantStore, limiter wallet.SpendingLimiter) Middleware
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.