/** * Approval Checker - Tool Approval Validation Functions * * Purpose: Validate tool execution approvals * Features: * - Check for session-wide approvals * - Check for one-time approvals (not consumed) * - Match by tool name, directory, and parameters * - Enhanced protocol support with __type='tool_result' * * These functions are pure logic with no side effects */ import { AgentMessage, World } from '../types.js'; /** * Check if tool needs approval and if it can execute * Returns approval status and optional approval request data */ export declare function checkToolApproval(world: World, toolName: string, toolArgs: any, message: string, messages: AgentMessage[], context: { workingDirectory?: string; [key: string]: any; }): Promise<{ needsApproval: boolean; canExecute: boolean; approvalRequest?: any; }>; /** * Find one-time approval that hasn't been consumed yet * * One-time approval is valid if: * - scope: 'once' * - Matches tool name, directory, and parameters * - NOT followed by a tool execution result (not consumed) * * Once found and used, it should be "consumed" by checking for subsequent tool results */ export declare function findOnceApproval(messages: AgentMessage[], toolName: string, toolArgs?: any, workingDirectory?: string): { decision: 'approve'; scope: 'once'; toolName: string; } | undefined; /** * Find session-wide approval for a tool in message history * Supports enhanced string protocol (JSON) * * Session approval matches on: * - Tool name (required) * - Working directory (if provided) * - Parameters (exact match) * * Enhanced protocol format: * { * role: 'tool', * tool_call_id: 'approval_...', * content: '{"__type":"tool_result","content":"{\"decision\":\"approve\",\"scope\":\"session\",\"toolName\":\"...\",\"toolArgs\":{...},\"workingDirectory\":\"...\"}"}' * } */ export declare function findSessionApproval(messages: AgentMessage[], toolName: string, toolArgs?: any, workingDirectory?: string): { decision: 'approve'; scope: 'session'; toolName: string; } | undefined;