import type { XMTPClient } from '../messaging/xmtp.js'; /** Structured XMTP message sent from agent to guardian requesting co-signature */ export interface GuardianApprovalRequest { type: 'azeth:guardian_request'; version: '1.0'; requestId: string; chainId: number; account: `0x${string}`; userOpHash: `0x${string}`; operation: { type: 'transfer' | 'whitelist_add' | 'agreement' | 'payment' | 'other'; description: string; to?: string; amount?: string; usdValue?: string; }; reason: string; limits: { maxTxAmountUSD: string; dailySpendLimitUSD: string; guardianMaxTxAmountUSD: string; guardianDailySpendLimitUSD: string; dailySpentUSD: string; }; expiresAt: string; } /** Structured XMTP message sent from guardian back to agent with decision */ export interface GuardianApprovalResponse { type: 'azeth:guardian_response'; version: '1.0'; requestId: string; decision: 'approved' | 'rejected'; signature?: `0x${string}`; reason?: string; } /** In-memory record of a pending guardian approval request */ export interface PendingApproval { requestId: string; userOpHash: `0x${string}`; ownerSignature: `0x${string}`; guardianAddress: `0x${string}`; operation: GuardianApprovalRequest['operation']; reason: string; status: 'pending' | 'approved' | 'rejected' | 'expired'; guardianSignature?: `0x${string}`; rejectionReason?: string; createdAt: number; expiresAt: number; } /** Result of a guardian approval request */ export type GuardianApprovalResult = { status: 'approved'; signature: `0x${string}`; combinedSignature: `0x${string}`; } | { status: 'rejected'; reason?: string; } | { status: 'timeout'; requestId: string; } | { status: 'error'; message: string; }; /** Retrieve a pending approval by request ID. Auto-expires if past deadline. */ export declare function getPendingApproval(requestId: string): PendingApproval | undefined; /** Get all non-expired pending approvals. */ export declare function getAllPendingApprovals(): PendingApproval[]; /** Remove all expired approvals from the store. */ export declare function clearExpiredApprovals(): void; /** * Send a guardian approval request via XMTP and poll for the response. * * The agent sends a structured JSON message to the guardian's address, * then polls XMTP for a response until timeout. On approval, the guardian's * signature is combined with the owner's signature (owner 65 bytes + guardian 65 bytes). * * @param xmtpClient - Initialized XMTPClient instance * @param guardianAddress - Ethereum address of the guardian * @param userOpHash - The UserOperation hash that needs co-signing * @param ownerSignature - The owner's EIP-191 signature of the userOpHash * @param chainId - The chain ID for the operation * @param account - The smart account address * @param operation - Human-readable operation details * @param reason - Why guardian approval is needed (e.g., EXCEEDS_TX_LIMIT) * @param limits - Current guardrail limits for context * @param options - Polling options (timeoutMs, pollIntervalMs) * @returns The approval result with combined signature, rejection reason, or timeout */ export declare function requestGuardianApproval(xmtpClient: XMTPClient, guardianAddress: `0x${string}`, userOpHash: `0x${string}`, ownerSignature: `0x${string}`, chainId: number, account: `0x${string}`, operation: GuardianApprovalRequest['operation'], reason: string, limits: GuardianApprovalRequest['limits'], options?: { timeoutMs?: number; pollIntervalMs?: number; }): Promise; /** * Check XMTP messages from the guardian for a response to a specific request. * * Reads recent messages from the guardian's conversation and looks for a * matching `azeth:guardian_response` message. * * @param xmtpClient - Initialized XMTPClient instance * @param guardianAddress - Guardian's Ethereum address * @param requestId - The approval request ID to match * @param afterTimestamp - Only consider messages after this timestamp (ms) * @returns The parsed response, or null if no matching response found */ export declare function checkForGuardianResponse(xmtpClient: XMTPClient, guardianAddress: `0x${string}`, requestId: string, afterTimestamp?: number): Promise; /** Try to parse a message string as a GuardianApprovalResponse. Returns null if not a valid response. */ export declare function tryParseGuardianResponse(content: string): GuardianApprovalResponse | null; /** Try to parse a message string as a GuardianApprovalRequest. Returns null if not a valid request. */ export declare function tryParseGuardianRequest(content: string): GuardianApprovalRequest | null; //# sourceMappingURL=guardian-approval.d.ts.map