/** * Society Protocol — A2A (Agent-to-Agent) Bridge * * Implements Google's Agent-to-Agent protocol bridge, * enabling interoperability between A2A-compliant agents * and Society Protocol's P2P network. * * A2A spec: Agent Card, Tasks, Streaming, Push Notifications * * - Inbound: A2A task requests → Society CoC chains * - Outbound: Society chains → A2A task responses */ import { EventEmitter } from 'events'; import type { Storage } from '../storage.js'; import type { RoomManager } from '../rooms.js'; import type { CocEngine } from '../coc.js'; import type { KnowledgePool } from '../knowledge.js'; import type { Identity } from '../identity.js'; export interface A2AAgentCard { name: string; description: string; url: string; version: string; capabilities: A2ACapabilities; skills: A2ASkill[]; defaultInputModes: string[]; defaultOutputModes: string[]; } export interface A2ACapabilities { streaming: boolean; pushNotifications: boolean; stateTransitionHistory: boolean; } export interface A2ASkill { id: string; name: string; description: string; tags: string[]; examples?: string[]; } export type A2ATaskState = 'submitted' | 'working' | 'input-required' | 'completed' | 'canceled' | 'failed' | 'unknown'; export interface A2AMessage { role: 'user' | 'agent'; parts: A2APart[]; } export interface A2ATextPart { type: 'text'; text: string; } export interface A2AFilePart { type: 'file'; file: { name: string; mimeType: string; bytes?: string; uri?: string; }; } export interface A2ADataPart { type: 'data'; data: Record; } export type A2APart = A2ATextPart | A2AFilePart | A2ADataPart; export interface A2ATask { id: string; sessionId: string; status: { state: A2ATaskState; message?: A2AMessage; }; history?: A2AMessage[]; artifacts?: A2AArtifact[]; metadata?: Record; } export interface A2AArtifact { name: string; description?: string; parts: A2APart[]; index?: number; } export interface A2ATaskSendParams { id: string; sessionId?: string; message: A2AMessage; acceptedOutputModes?: string[]; metadata?: Record; } export interface A2ABridgeConfig { identity: Identity; storage: Storage; rooms: RoomManager; coc: CocEngine; knowledge: KnowledgePool; /** Default room for incoming A2A tasks */ defaultRoom: string; /** Skills exposed to A2A agents */ exposedSkills?: A2ASkill[]; /** Base URL for this agent's A2A endpoint */ baseUrl?: string; } export declare class A2ABridge extends EventEmitter { private identity; private storage; private rooms; private coc; private knowledge; private defaultRoom; private exposedSkills; private baseUrl; private taskMappings; constructor(config: A2ABridgeConfig); getAgentCard(): A2AAgentCard; private getDefaultSkills; handleTaskSend(params: A2ATaskSendParams): Promise; getTask(taskId: string): A2ATask | undefined; cancelTask(taskId: string): Promise; handleJsonRpc(request: { jsonrpc: string; id: string | number; method: string; params?: Record; }): Promise<{ jsonrpc: string; id: string | number; result?: unknown; error?: { code: number; message: string; }; }>; /** * Convert a completed Society chain into an A2A task response. */ chainToA2ATask(chainId: string): A2ATask | undefined; /** * Create A2A message from Society step output. */ stepToA2AMessage(stepOutput: { memo: string; artifacts?: Array<{ artifact_type: string; content?: string; }>; }): A2AMessage; private syncTaskState; private getStatusMessage; private createErrorTask; private setupCocListeners; getStats(): { activeTasks: number; completedTasks: number; failedTasks: number; }; destroy(): void; } //# sourceMappingURL=a2a-bridge.d.ts.map