/** * Tool Approval Module - Shared HITL approval flow for built-in tools. * * Purpose: * - Provide a reusable wrapper around HITL option prompts for tool-level approvals. * * Key Features: * - Standardized approval result contract (`approved`, `reason`, `optionId`, `source`) * - Configurable options/default and multiple approved option IDs * - Deterministic deny/timeout handling for sensitive tool operations * - Optional durable synthetic approval prompt/resolution message persistence * * Implementation Notes: * - Delegates prompt transport/runtime behavior to `requestWorldOption` * - Returns normalized results to reduce duplicated approval mapping logic in tools * - When message context is available, persists canonical approval prompt/resolution artifacts * * Recent Changes: * - 2026-03-12: Added optional durable approval prompt/resolution persistence with separate requestId vs owning toolCallId support. * - 2026-02-28: Initial shared approval helper extracted for `load_skill`, `create_agent`, and `web_fetch`. */ import { type HitlOption } from './hitl.js'; import { type AgentMessage, type World } from './types.js'; export type ToolApprovalReason = 'approved' | 'user_denied' | 'timeout'; export type ToolApprovalResult = { approved: boolean; reason: ToolApprovalReason; optionId: string; source: 'user' | 'timeout'; }; export type ToolApprovalRequest = { world: World; chatId: string | null; requestId?: string; toolCallId?: string; title: string; message: string; options: HitlOption[]; defaultOptionId: string; approvedOptionIds: string[]; metadata?: Record; agentName?: string | null; messages?: AgentMessage[]; }; export declare function requestToolApproval(request: ToolApprovalRequest): Promise;