/** * Network Intelligence — shared pricing signals across agents. * * This module enables optional network effects: agents using x402-cfo * can share anonymized pricing data, improving anomaly detection for * all participants. Local-first: works entirely offline. * * The value scales with adoption. How it works: * 1. Each x402-cfo instance anonymously records pricing signals: * - host, asset, network, amount (no wallet addresses, no agent IDs) * 2. Signals are batched and sent to a central intelligence endpoint * (when available) at configurable intervals * 3. The network returns aggregate pricing intelligence: * - "Typical price for api.data.com is $0.25 (p50) to $0.45 (p95)" * - "This endpoint's pricing is anomalous across the network" * 4. Local anomaly detection is enhanced with network-wide context * * Privacy guarantees: * - Opt-in only (disabled by default) * - No wallet addresses, agent IDs, or deployer identity sent * - Only: host, asset, network, amount, timestamp (rounded to hour) * - Signals are hashed before sending to prevent correlation * - Local-first: works entirely offline, network is bonus intelligence * * Architecture: * - Client-side ready NOW (this module) * - Server endpoint: future (when user base justifies infrastructure) * - Until server exists, all intelligence is local-only */ /** An anonymized pricing signal. */ export interface PricingSignal { /** Hashed host identifier (SHA-256 of hostname) */ hostHash: string; /** Payment asset (e.g., 'USDC') */ asset: string; /** Network (e.g., 'base') */ network: string; /** Amount paid */ amount: number; /** Timestamp rounded to nearest hour for privacy */ hourBucket: number; } /** Network-wide pricing intelligence for a host. */ export interface NetworkIntelligence { /** Number of agents reporting on this host */ reporters: number; /** Network-wide pricing stats */ pricing: { p50: number; p75: number; p95: number; mean: number; }; /** Whether an observed price is anomalous ACROSS the network */ isNetworkAnomaly: boolean; /** Freshness of the intelligence */ lastUpdated: number; } export interface NetworkClientConfig { /** Enable network intelligence. Default: false (opt-in only) */ enabled?: boolean; /** Intelligence endpoint URL. Default: null (local-only mode) */ endpoint?: string | null; /** Batch interval for sending signals (ms). Default: 300000 (5 min) */ batchIntervalMs?: number; /** Max signals to buffer before force-flush. Default: 100 */ maxBufferSize?: number; } /** * Network Intelligence Client. * * Collects anonymized pricing signals and (when connected to a server) * provides network-wide anomaly context. * * Until a server exists, this operates in local-only mode — collecting * signals for future use and providing the architecture for network * intelligence when the user base justifies infrastructure. */ export declare class NetworkIntelligence { private enabled; private endpoint; private batchIntervalMs; private maxBufferSize; private signalBuffer; private localCache; private batchTimer; constructor(config?: NetworkClientConfig); /** * Record a pricing signal from a payment. * Only records if intelligence is enabled (opt-in). */ record(host: string, asset: string, network: string, amount: number): void; /** * Query network intelligence for a host. * * In local-only mode, returns intelligence based on local observations. * When connected to server, would return network-wide intelligence. */ query(host: string, observedAmount?: number): NetworkIntelligenceResult | null; /** * Get all locally tracked hosts with their signal counts. */ trackedHosts(): { hostHash: string; signalCount: number; }[]; /** * Flush buffered signals to the network endpoint. * No-op if no endpoint configured (local-only mode). */ flush(): Promise; /** * Stop the batch timer and flush remaining signals. */ stop(): Promise; /** * Hash a hostname for privacy. * Uses a simple deterministic hash (not cryptographic — we're anonymizing, not securing). */ private hashHost; private percentile; } /** Type alias for query results (avoids conflict with class name). */ export type NetworkIntelligenceResult = { reporters: number; pricing: { p50: number; p75: number; p95: number; mean: number; }; isNetworkAnomaly: boolean; lastUpdated: number; }; //# sourceMappingURL=network.d.ts.map