/** * agent.json Bridge — APS ↔ agent.json Commerce Integration * * Maps agent.json capability manifests (FransDevelopment/agent-json spec v1.3) * to APS 4-gate commerce preflight and signed receipt generation. * * agent.json declares WHAT a service offers + economics. * APS enforces WHO can spend, HOW MUCH, and traces it back to the human principal. * * Composition: agent.json (capability discovery + pricing) + APS (identity + delegation + enforcement) * * @module interop/agent-json-bridge */ import type { CommerceDelegation, CommercePreflightResult } from '../types/commerce.js'; export interface AgentJsonManifest { version: string; origin: string; payout_address: string; display_name?: string; description?: string; identity?: AgentJsonIdentity; intents?: AgentJsonIntent[]; bounty?: AgentJsonBounty; incentive?: AgentJsonIncentive; payments?: Record; x402?: Record; extensions?: Record; } export interface AgentJsonIdentity { did?: string; public_key?: string; } export interface AgentJsonIntent { name: string; description: string; endpoint?: string; method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; parameters?: Record; returns?: AgentJsonReturns; price?: AgentJsonPrice; bounty?: AgentJsonBounty; incentive?: AgentJsonIncentive; payments?: Record; x402?: Record; extensions?: Record; } export interface AgentJsonParameter { type: 'string' | 'integer' | 'number' | 'boolean' | 'array' | 'object'; required?: boolean; description?: string; enum?: unknown[]; default?: unknown; } export interface AgentJsonReturns { type: 'object' | 'array' | 'string'; description?: string; properties?: Record; } export interface AgentJsonPrice { amount: number; currency: string; model?: 'per_call' | 'per_unit' | 'flat'; unit_param?: string; free_tier?: number; network?: string | string[]; } export interface AgentJsonBounty { type: 'cpa'; rate: number; currency: string; splits?: { orchestrator?: number; platform?: number; referrer?: number; }; } export interface AgentJsonIncentive { type: 'cpa'; rate: number; currency: string; } export interface AgentJsonCommerceReceipt { receiptId: string; version: string; timestamp: string; agentId: string; delegationId: string; delegationChain: string[]; beneficiary: string; service: { origin: string; displayName?: string; did?: string; publicKey?: string; }; intent: { name: string; description: string; endpoint?: string; }; spend: { amount: number; currency: string; pricingModel: string; }; bountyEarned?: { amount: number; currency: string; }; signature: string; } /** * Parse and validate an agent.json manifest. * Accepts either a JSON string or an already-parsed object. * Validates required fields per spec: version, origin, payout_address. */ export declare function parseAgentJson(input: string | object): AgentJsonManifest; /** * Resolve the effective price for an intent. * Returns amount in the smallest currency unit (cents for USD/USDC) * or the raw amount if no conversion needed. */ export declare function resolveIntentPrice(manifest: AgentJsonManifest, intentName: string): { amount: number; currency: string; model: string; } | null; /** * Resolve effective bounty for an intent. * Intent-level bounty overrides manifest-level bounty (spec §4.4). */ export declare function resolveIntentBounty(manifest: AgentJsonManifest, intentName: string): AgentJsonBounty | null; /** * Run APS 4-gate commerce preflight against an agent.json intent. * * Gates: * 1. Scope check — is the intent's scope covered by delegation? * 2. Spend limit — is the price within remaining budget? * 3. Merchant whitelist — is the service origin in allowed merchants? * 4. Human approval threshold — does price exceed approval threshold? * * Maps agent.json's `price` field to APS's `CommerceDelegation` constraints. */ export declare function commercePreflightFromManifest(opts: { manifest: AgentJsonManifest; intentName: string; delegation: CommerceDelegation; }): CommercePreflightResult; /** * Generate a signed commerce receipt linking an agent.json intent * to an APS delegation chain. * * Call this AFTER successful preflight + execution. * The receipt proves: who authorized (delegation chain), what was called * (intent from manifest), how much was spent (price from manifest), * who benefits (principal from delegation), and which service provided it * (identity from manifest). */ export declare function generateCommerceReceiptFromManifest(opts: { manifest: AgentJsonManifest; intentName: string; delegation: CommerceDelegation; beneficiary: string; privateKey: string; }): AgentJsonCommerceReceipt; //# sourceMappingURL=agent-json-bridge.d.ts.map