/** * P2P Transport * * Peer-to-peer messaging for distributed agent communication. * Builds on existing edgework gateway connector. */ interface P2PMessage { id: string; from: string; to: string; type: 'request' | 'response' | 'broadcast' | 'heartbeat'; payload: unknown; timestamp: number; ttl?: number; } interface P2PPeer { id: string; endpoint: string; lastSeen: number; capabilities: string[]; latencyMs?: number; } interface P2PConfig { /** This peer's ID */ peerId?: string; /** Discovery method */ discovery?: 'gateway' | 'mdns' | 'manual'; /** Gateway URL for peer discovery */ gatewayUrl?: string; /** Heartbeat interval in ms */ heartbeatIntervalMs?: number; /** Peer timeout in ms */ peerTimeoutMs?: number; } /** * P2P mesh network for agent communication. */ declare class P2PMesh { private peerId; private peers; private messageHandlers; private config; constructor(config?: P2PConfig); /** * Get this peer's ID. */ getId(): string; /** * Add a known peer. */ addPeer(peer: P2PPeer): void; /** * Remove a peer. */ removePeer(peerId: string): void; /** * Get all known peers. */ getPeers(): P2PPeer[]; /** * Send a message to a specific peer. */ send(to: string, payload: unknown): Promise; /** * Broadcast a message to all known peers. */ broadcast(payload: unknown): Promise; /** * Register a message handler. */ onMessage(type: string, handler: (message: P2PMessage) => void | Promise): void; /** * Handle an incoming message. */ handleMessage(message: P2PMessage): Promise; /** * Discover peers via gateway. */ discover(): Promise; } /** * A2A Protocol * * Agent-to-Agent protocol for cross-framework interoperability. * Google ADK A2A pattern — allows agents from different frameworks to communicate. */ interface A2AAgentCard { /** Agent name */ name: string; /** Agent description */ description: string; /** Supported capabilities */ capabilities: string[]; /** Agent endpoint URL */ endpoint: string; /** Protocol version */ version: string; /** Supported input/output formats */ formats: string[]; } interface A2AMessage { /** Message ID */ id: string; /** Sender agent card */ from: A2AAgentCard; /** Task to perform */ task: string; /** Input data */ input: unknown; /** Expected output format */ outputFormat?: string; /** Timeout in ms */ timeoutMs?: number; /** Metadata */ metadata?: Record; } interface A2AResponse { /** Original message ID */ messageId: string; /** Response status */ status: 'success' | 'error' | 'partial'; /** Output data */ output: unknown; /** Error message if status is error */ error?: string; /** Processing time in ms */ processingMs: number; /** Metadata */ metadata?: Record; } /** * A2A Client — sends tasks to remote agents. */ declare class A2AClient { private agentCard; constructor(agentCard: A2AAgentCard); /** * Discover remote agents at an endpoint. */ discover(endpointUrl: string): Promise; /** * Send a task to a remote agent. */ sendTask(target: A2AAgentCard, task: string, input: unknown, options?: { timeoutMs?: number; outputFormat?: string; }): Promise; } /** * A2A Server — receives tasks from remote agents. */ declare class A2AServer { private agentCard; private handler; constructor(agentCard: A2AAgentCard, handler: A2AServer['handler']); /** * Get the agent card for discovery. */ getAgentCard(): A2AAgentCard; /** * Handle an incoming A2A task. */ handleTask(message: A2AMessage): Promise; } export { type A2AAgentCard, A2AClient, type A2AMessage, type A2AResponse, A2AServer, type P2PConfig, P2PMesh, type P2PMessage, type P2PPeer };