import type { ToolCallInfo } from '../types'; export type ApprovalStatus = 'pending' | 'approved' | 'rejected'; /** * Approval request for a tool execution. * * When a tool has `needsApproval: true` in AI SDK v6, the agent * will pause and wait for approval before executing the tool. */ export interface ApprovalRequest { /** Unique request ID */ id: string; /** Agent session ID */ sessionId: string; /** Agent ID */ agentId: string; /** Tenant ID for scoping */ tenantId?: string; /** Tool name requiring approval */ toolName: string; /** Tool call ID from AI SDK */ toolCallId: string; /** Tool arguments */ toolArgs: unknown; /** Human-readable reason for approval */ reason: string; /** When the approval was requested */ requestedAt: Date; /** Current status */ status: ApprovalStatus; /** Additional context payload */ payload?: Record; /** Who resolved the approval */ reviewer?: string; /** When the approval was resolved */ resolvedAt?: Date; /** Reviewer notes */ notes?: string; } /** * Storage interface for approval requests. */ export interface ApprovalStore { create(request: ApprovalRequest): Promise; get(id: string): Promise; getByToolCallId(toolCallId: string): Promise; update(id: string, updates: Partial>): Promise; list(options?: { status?: ApprovalStatus; agentId?: string; tenantId?: string; }): Promise; } export interface InMemoryApprovalStoreOptions { maxItems?: number; } /** * In-memory approval store for development and testing. */ export declare class InMemoryApprovalStore implements ApprovalStore { private readonly items; private readonly maxItems; constructor(options?: InMemoryApprovalStoreOptions); create(request: ApprovalRequest): Promise; get(id: string): Promise; getByToolCallId(toolCallId: string): Promise; update(id: string, updates: Partial>): Promise; list(options?: { status?: ApprovalStatus; agentId?: string; tenantId?: string; }): Promise; clear(): void; private evictIfNeeded; } /** * Approval workflow for managing tool execution approvals. * * Integrates with AI SDK v6's `needsApproval` feature on tools. * * @example * ```typescript * const workflow = new ApprovalWorkflow(); * * // When a tool needs approval * const request = await workflow.requestApproval({ * sessionId: 'sess_123', * agentId: 'support.bot.v1', * toolName: 'delete_account', * toolCallId: 'call_abc', * toolArgs: { userId: 'user_123' }, * reason: 'Account deletion requires human approval', * }); * * // When approval is granted * await workflow.approve(request.id, 'admin@example.com', 'Verified identity'); * * // Or rejected * await workflow.reject(request.id, 'admin@example.com', 'Suspicious activity'); * ``` */ export declare class ApprovalWorkflow { private readonly store; constructor(store?: ApprovalStore); /** * Request approval for a tool execution. */ requestApproval(params: { sessionId: string; agentId: string; tenantId?: string; toolName: string; toolCallId: string; toolArgs: unknown; reason: string; payload?: Record; }): Promise; /** * Request approval from an AI SDK tool call. */ requestApprovalFromToolCall(toolCall: ToolCallInfo, context: { sessionId: string; agentId: string; tenantId?: string; reason?: string; /** Locale for i18n (BCP 47). Falls back to 'en'. */ locale?: string; }): Promise; /** * Approve a pending request. */ approve(id: string, reviewer: string, notes?: string): Promise; /** * Reject a pending request. */ reject(id: string, reviewer: string, notes?: string): Promise; /** * Get approval status for a tool call. */ getStatus(toolCallId: string): Promise; /** * Check if a tool call is approved. */ isApproved(toolCallId: string): Promise; /** * List pending approvals. */ listPending(options?: { agentId?: string; tenantId?: string; }): Promise; /** * Get approval request by ID. */ get(id: string): Promise; } /** * Create an approval workflow instance. */ export declare function createApprovalWorkflow(store?: ApprovalStore | InMemoryApprovalStoreOptions): ApprovalWorkflow;