/** * A2A agent that wraps a remote A2A agent as an InvokableAgent. * * Implements the InvokableAgent interface so it can be used anywhere a local Agent * can be used. The remote agent is invoked via the A2A protocol. * The A2A protocol is experimental, so breaking changes in the underlying SDK * may require breaking changes in this module. */ import type { ClientFactory as ClientFactoryType } from '@a2a-js/sdk/client'; import type { InvokableAgent, InvokeArgs, InvokeOptions } from '../types/agent.js'; import { AgentResult } from '../types/agent.js'; import { type A2AStreamEvent } from './events.js'; /** * Configuration options for creating an A2AAgent. */ export interface A2AAgentConfig { /** Base URL of the remote A2A agent */ url: string; /** Path to the agent card endpoint (default: '/.well-known/agent-card.json') */ agentCardPath?: string; /** Optional unique identifier. Defaults to the URL. */ id?: string; /** Optional name. If not provided, populated from the agent card after connection. */ name?: string; /** Optional description. If not provided, populated from the agent card after connection. */ description?: string; /** Optional custom A2A ClientFactory for authenticating requests (e.g. SigV4, bearer token). */ clientFactory?: ClientFactoryType; } /** * Wraps a remote A2A agent as an InvokableAgent. * * Implements `InvokableAgent` so it can be used polymorphically with local `Agent` instances. * On invocation, the agent lazily connects to the remote endpoint via the A2A protocol * and returns the response as an `AgentResult`. * * @example * ```typescript * import { A2AAgent } from '@strands-agents/sdk/a2a' * * const remoteAgent = new A2AAgent({ url: 'http://localhost:9000' }) * const result = await remoteAgent.invoke('Hello, remote agent!') * console.log(result.toString()) * ``` */ export declare class A2AAgent implements InvokableAgent { private _config; private _client; private _agentCard; /** * The unique identifier of the agent instance. */ readonly id: string; /** * The name of the agent. * If not provided in config, populated from the agent card after connection. */ readonly name?: string; /** * Optional description of what the agent does. * If not provided in config, populated from the agent card after connection. */ readonly description?: string; /** * Creates a new A2AAgent. * * @param config - Configuration for connecting to the remote agent */ constructor(config: A2AAgentConfig); /** * Invokes the remote agent and returns the final result. * * Built on top of `stream()` — consumes the full event stream and returns the final result. * * @param args - Arguments for invoking the agent * @param options - Optional invocation options. See {@link stream} for behavior. * @returns Promise that resolves to the AgentResult */ invoke(args: InvokeArgs, options?: InvokeOptions): Promise; /** * Streams the remote agent execution, yielding A2A events as they arrive. * * Yields `A2AStreamUpdateEvent` for each raw A2A protocol event (Message, Task, * TaskStatusUpdateEvent, TaskArtifactUpdateEvent), followed by an `A2AResultEvent` * containing the final result built from the last complete event. * * @param args - Arguments for invoking the agent * @param options - Optional invocation options. If `invocationState` is * provided, it is returned on the resulting `AgentResult`. The remote * agent runs in another process and cannot read or mutate it. Other * fields on `options` are ignored. * @returns Async generator that yields AgentStreamEvent objects and returns AgentResult */ stream(args: InvokeArgs, options?: InvokeOptions): AsyncGenerator; /** * Returns the cached A2A SDK client, creating one lazily on first use. * Also fetches and caches the agent card for name/description. * * @returns The A2A SDK client */ private _getClient; /** * Extracts a text string from InvokeArgs for sending to the remote agent. * * @param args - The invocation arguments * @returns The extracted text string */ private _extractTextFromArgs; /** * Checks whether an A2A streaming event represents a complete response. * * @param event - The A2A streaming event * @returns True if the event is a terminal/complete event */ private _isCompleteEvent; /** * Builds an AgentResult from the final A2A streaming event. * * @param event - The final A2A event, or undefined if no events were received * @param invocationState - Caller-provided invocation state, threaded through to the result * @param accumulatedText - Optional accumulated text from streaming artifacts * @returns The constructed AgentResult */ private _buildResult; /** * Extracts text content from an A2A streaming event. * * @param event - The A2A streaming event * @returns Extracted text content */ private _extractTextFromEvent; /** * Joins text from A2A parts, filtering out non-text parts. * * @param parts - Array of A2A parts * @returns Joined text content */ private _textFromParts; } //# sourceMappingURL=a2a-agent.d.ts.map