/** * A2AAdapter — Agent-to-Agent (A2A) protocol adapter. * * Implements the Google A2A (Agent-to-Agent) open protocol that lets * independently hosted agents discover each other through a standard * Agent Card (/.well-known/agent.json) and exchange tasks via a * JSON-RPC envelope posted to the agent's task endpoint. * * References: * https://google.github.io/A2A/ * https://github.com/google/A2A * * Usage: * * const adapter = new A2AAdapter(); * await adapter.initialize({}); * * // Register a remote agent by its Agent Card URL * await adapter.registerRemoteAgent('remote-analyst', 'https://agent.example.com'); * * // Or register a local agent that serves an A2A-compliant card * adapter.registerLocalA2AAgent('local-writer', { * name: 'Writing Agent', * description: 'Draft documents given a topic', * version: '1.0', * capabilities: { streaming: false }, * taskEndpoint: 'https://writer.internal/tasks', * }); * * await registry.addAdapter(adapter); * * // In the orchestrator: * delegateTask({ targetAgent: 'a2a:remote-analyst', ... }) * * @module A2AAdapter * @version 1.0.0 */ import { BaseAdapter } from './base-adapter'; import type { AdapterConfig, AdapterCapabilities, AgentPayload, AgentContext, AgentResult } from '../types/agent-adapter'; /** Agent Card served at /.well-known/agent.json (A2A spec §3.1) */ export interface A2AAgentCard { /** Human-readable agent name */ name: string; /** Purpose / capabilities in plain English */ description?: string; /** SemVer */ version?: string; /** Protocol capabilities declared by the agent */ capabilities?: { streaming?: boolean; pushNotifications?: boolean; stateTransitionHistory?: boolean; }; /** URL that accepts A2A task envelopes (defaults to /tasks) */ taskEndpoint?: string; /** Agent homepage or further docs */ url?: string; } /** JSON-RPC 2.0 task request envelope sent to the task endpoint (A2A spec §4) */ export interface A2ATask { jsonrpc: '2.0'; id: string; method: 'tasks/send'; params: { id: string; message: { role: 'user'; parts: Array<{ type: 'text'; text: string; }>; }; metadata?: Record; }; } /** State of a running A2A task */ export type A2ATaskState = 'submitted' | 'working' | 'input-required' | 'completed' | 'canceled' | 'failed' | 'unknown'; /** Artifact produced by the agent (A2A spec §4.3) */ export interface A2AArtifact { name?: string; description?: string; parts: Array<{ type: string; text?: string; data?: unknown; }>; } /** JSON-RPC 2.0 task response (A2A spec §4) */ export interface A2ATaskResponse { jsonrpc: '2.0'; id: string; result?: { id: string; status: { state: A2ATaskState; message?: string; }; artifacts?: A2AArtifact[]; metadata?: Record; }; error?: { code: number; message: string; data?: unknown; }; } /** Adapter configuration specific to A2A */ export interface A2AAdapterConfig extends AdapterConfig { /** Default bearer token applied to all agents unless overridden at agent level */ defaultBearerToken?: string; /** Default timeout for all agents in ms (default: 30 000) */ defaultTimeoutMs?: number; /** Custom fetch implementation (for testing / node compat) */ fetchImpl?: typeof fetch; } export declare class A2AAdapter extends BaseAdapter { readonly name = "a2a"; readonly version = "1.0.0"; private a2aAgents; private defaultBearerToken?; private defaultTimeoutMs; private fetchImpl; get capabilities(): AdapterCapabilities; initialize(config: A2AAdapterConfig): Promise; /** * Fetch the Agent Card from `/.well-known/agent.json` and register * the remote agent for use in the orchestrator. * * @param agentId - Local identifier (used in `delegate_task` calls) * @param baseUrl - Root URL of the remote A2A-compliant agent server * @param options - Optional bearer token / timeout override */ registerRemoteAgent(agentId: string, baseUrl: string, options?: { bearerToken?: string; timeoutMs?: number; }): Promise; /** * Register a local A2A agent whose card you already have (no network fetch). * Useful when the card is embedded in config or returned from another service. */ registerLocalA2AAgent(agentId: string, card: A2AAgentCard & { taskEndpoint: string; }, options?: { bearerToken?: string; timeoutMs?: number; }): void; executeAgent(agentId: string, payload: AgentPayload, context: AgentContext): Promise; private fetchAgentCard; private sendTask; private extractOutput; } //# sourceMappingURL=a2a-adapter.d.ts.map