/** * Google Agent Payments Protocol (AP2) Adapter * * Maps Bolyra's ZKP identity to AP2's mandate-based authorization model. * In AP2, agents carry cryptographically signed "mandates" from users — * Bolyra replaces plain-text mandates with ZKP proofs, so the merchant * verifies the agent's authority without seeing the user's instructions. * * AP2 Flow (standard): * 1. User creates an Intent Mandate (instruction to the agent) * 2. Agent shops, builds a Cart Mandate (user approves specific purchase) * 3. Agent presents Payment Mandate to merchant for checkout * 4. Merchant verifies mandate chain cryptographically * * Bolyra-enhanced Flow: * 1. User creates a Bolyra handshake proof encoding their intent as a ZKP * 2. Agent wraps the proof as an AP2-compatible credential * 3. Agent-to-agent delegation uses Bolyra's delegation chain (not plain mandates) * 4. Merchant verifies the ZKP — learns capabilities, not the raw instructions * * Privacy gain: AP2 mandates are tamper-proof but readable by the merchant. * Bolyra mandates are tamper-proof AND zero-knowledge — the merchant verifies * authorization without learning the user's budget, preferences, or identity. * * @see https://cloud.google.com/blog/products/ai-machine-learning/announcing-agents-to-payments-ap2-protocol * @see https://github.com/google-agentic-commerce/AP2 */ import type { HumanIdentity, AgentCredential } from '@bolyra/sdk'; import type { AP2AgentCapability, AP2AgentCredential, AP2DelegationRecord, AgentPaymentVerification, PaymentVerificationConfig } from './types'; import type { SpendPolicy } from './types'; /** * Map AP2 agent capabilities to a Bolyra SpendPolicy. * Takes the most permissive capability as the policy ceiling. */ export declare function capabilitiesToSpendPolicy(capabilities: AP2AgentCapability[]): SpendPolicy; /** * Map a Bolyra permission bitmask back to AP2 capabilities. * Reverse of the encoding for display/interop purposes. */ export declare function bitmaskToCapabilities(bitmask: bigint, currency?: string): AP2AgentCapability[]; /** * Create an AP2-compatible agent credential backed by a Bolyra ZKP. * * This is the core AP2 adapter function. It: * 1. Runs a Bolyra mutual handshake (human authorizes agent) * 2. Encodes the AP2 capabilities as a Bolyra permission bitmask * 3. Wraps the ZKP proof as an AP2 mandate proof * 4. Returns a credential that AP2-compatible merchants can verify * * The merchant sees the capability list (what the agent can do) but NOT * the human's identity, the exact spend limit, or the full delegation chain. * * @param human - The human operator's Bolyra identity * @param agent - The agent's Bolyra credential * @param capabilities - AP2 capabilities the agent should have * @param config - Adapter configuration * @returns AP2-compatible agent credential with embedded ZKP proof */ export declare function createAP2AgentCredential(human: HumanIdentity, agent: AgentCredential, capabilities: AP2AgentCapability[], config?: PaymentVerificationConfig): Promise; /** * Verify an AP2 agent credential (merchant-side). * * The merchant calls this to verify that an AP2 agent credential is backed * by a valid Bolyra ZKP proof. Returns a payment verification result. * * @param credential - The AP2 agent credential to verify * @param config - Adapter configuration * @returns Payment verification result */ export declare function verifyAP2AgentCredential(credential: AP2AgentCredential, config?: PaymentVerificationConfig): Promise; /** * Delegate capabilities from one agent to another using Bolyra's delegation chain. * * In AP2, agents can delegate capabilities to sub-agents (e.g., a shopping agent * delegates payment to a checkout agent). Bolyra tracks this as a delegation chain * with ZKP proofs at each hop, preventing scope escalation. * * @param fromCredential - The delegating agent's AP2 credential * @param toAgent - The target agent's Bolyra credential * @param capabilities - Capabilities to delegate (must be subset of fromCredential's) * @param config - Adapter configuration * @returns AP2 delegation record with Bolyra chain tracking */ export declare function delegateAP2Capabilities(fromCredential: AP2AgentCredential, toAgent: AgentCredential, capabilities: AP2AgentCapability[], config?: PaymentVerificationConfig): Promise;