import { Message } from '@a2a-js/sdk'; import { ConnectorTool } from '../../types/connector.js'; import { StreamEvent } from '../../types/stream.js'; import '../../types/memory.js'; declare class A2AModule { /** Communication attempts per send: the first call plus one retry. */ private static readonly MAX_SEND_ATTEMPTS; /** Map of A2A server URLs to their corresponding tool instances */ private a2aConnectors; /** Map of session IDs to their A2A session state */ private a2aTasks; private agentId; /** * Registers a new A2A peer server URL for connection. * * @param conns - Set of name, url pair */ addA2AConnector(conns: { [name: string]: string; }): Promise; getA2AConnectors(): Array<{ name: string; url: string; }>; hasConnector(connectorName: string): boolean; private getOrCreateClient; /** * Retrieves tools from all registered A2A peer servers. * * Attempts to connect to each registered server, fetch their agent cards, * and create tool instances. Disables tools for unreachable servers. * * @returns Promise resolving to array of available A2A tools */ getTools(prompt: string): Promise; /** * Constructs a message payload for A2A communication. * * Includes session context (task ID and context ID) if available * for maintaining conversation continuity. * * @param query - The message content to send * @param threadId - The session identifier * @returns Formatted Message object for A2A protocol */ getMessagePayload(query: string, threadId: string, metadata?: Record): Message; private sendMessageToConnector; /** * Sends a message through the connector, retrying once on communication * failure (network error, stream timeout, connection reset). A failed * attempt may have left a broken task mapping for the thread, so it is * dropped to let the retry start a fresh task. * * Retries ONLY when the failed attempt delivered no events: once the * consumer has seen output, the remote agent is already executing, and * re-sending would both run the task twice and replay the delivered * events. Throws the last error when no (further) attempt is allowed. */ private sendWithRetry; sendTask(params: { connectorName: string; message: string; threadId: string; metadata?: Record; }): AsyncGenerator; /** * Executes an A2A tool by sending a message to the remote agent. * * Handles streaming responses, maintains session state, and extracts * text content from various event types in the response stream. * * @param tool - The A2ATool instance to use * @param query - The message to send to the agent * @param threadId - The session identifier for context tracking * @yields StreamEvent objects for intermediate events * @returns Final text response from the agent */ useTool(tool: ConnectorTool, query: string, threadId: string): AsyncGenerator; } export { A2AModule };