@mailmodo/a2a 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,367 @@
1
+ import {
2
+ A2AClient,
3
+ JsonRpcTransport,
4
+ JsonRpcTransportFactory,
5
+ PushNotificationNotSupportedError,
6
+ createAuthenticatingFetchWithRetry
7
+ } from "../chunk-UBRSFN2J.mjs";
8
+ import {
9
+ AGENT_CARD_PATH
10
+ } from "../chunk-PHP7LM4Y.mjs";
11
+
12
+ // src/client/card-resolver.ts
13
+ var DefaultAgentCardResolver = class {
14
+ constructor(options) {
15
+ this.options = options;
16
+ }
17
+ /**
18
+ * Fetches the agent card based on provided base URL and path.
19
+ * Path is selected in the following order:
20
+ * 1) path parameter
21
+ * 2) path from options
22
+ * 3) .well-known/agent-card.json
23
+ */
24
+ async resolve(baseUrl, path) {
25
+ const agentCardUrl = new URL(path ?? this.options?.path ?? AGENT_CARD_PATH, baseUrl);
26
+ const response = await this.fetchImpl(agentCardUrl);
27
+ if (!response.ok) {
28
+ throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status}`);
29
+ }
30
+ return await response.json();
31
+ }
32
+ fetchImpl(...args) {
33
+ if (this.options?.fetchImpl) {
34
+ return this.options.fetchImpl(...args);
35
+ }
36
+ return fetch(...args);
37
+ }
38
+ };
39
+ var AgentCardResolver = {
40
+ Default: new DefaultAgentCardResolver()
41
+ };
42
+
43
+ // src/client/multitransport-client.ts
44
+ var Client = class {
45
+ constructor(transport, agentCard, config) {
46
+ this.transport = transport;
47
+ this.agentCard = agentCard;
48
+ this.config = config;
49
+ }
50
+ /**
51
+ * Sends a message to an agent to initiate a new interaction or to continue an existing one.
52
+ * Uses blocking mode by default.
53
+ */
54
+ sendMessage(params, options) {
55
+ params = this.applyClientConfig({
56
+ params,
57
+ blocking: !(this.config?.polling ?? false)
58
+ });
59
+ return this.executeWithInterceptors(
60
+ { method: "sendMessage", value: params },
61
+ options,
62
+ this.transport.sendMessage.bind(this.transport)
63
+ );
64
+ }
65
+ /**
66
+ * Sends a message to an agent to initiate/continue a task AND subscribes the client to real-time updates for that task.
67
+ * Performs fallback to non-streaming if not supported by the agent.
68
+ */
69
+ async *sendMessageStream(params, options) {
70
+ const method = "sendMessageStream";
71
+ params = this.applyClientConfig({ params, blocking: true });
72
+ const beforeArgs = {
73
+ input: { method, value: params },
74
+ options
75
+ };
76
+ const beforeResult = await this.interceptBefore(beforeArgs);
77
+ if (beforeResult) {
78
+ const earlyReturn = beforeResult.earlyReturn.value;
79
+ const afterArgs = {
80
+ result: { method, value: earlyReturn },
81
+ options: beforeArgs.options
82
+ };
83
+ await this.interceptAfter(afterArgs, beforeResult.executed);
84
+ yield afterArgs.result.value;
85
+ return;
86
+ }
87
+ if (!this.agentCard.capabilities.streaming) {
88
+ const result = await this.transport.sendMessage(beforeArgs.input.value, beforeArgs.options);
89
+ const afterArgs = {
90
+ result: { method, value: result },
91
+ options: beforeArgs.options
92
+ };
93
+ await this.interceptAfter(afterArgs);
94
+ yield afterArgs.result.value;
95
+ return;
96
+ }
97
+ for await (const event of this.transport.sendMessageStream(
98
+ beforeArgs.input.value,
99
+ beforeArgs.options
100
+ )) {
101
+ const afterArgs = {
102
+ result: { method, value: event },
103
+ options: beforeArgs.options
104
+ };
105
+ await this.interceptAfter(afterArgs);
106
+ yield afterArgs.result.value;
107
+ if (afterArgs.earlyReturn) {
108
+ return;
109
+ }
110
+ }
111
+ }
112
+ /**
113
+ * Sets or updates the push notification configuration for a specified task.
114
+ * Requires the server to have AgentCard.capabilities.pushNotifications: true.
115
+ */
116
+ setTaskPushNotificationConfig(params, options) {
117
+ if (!this.agentCard.capabilities.pushNotifications) {
118
+ throw new PushNotificationNotSupportedError();
119
+ }
120
+ return this.executeWithInterceptors(
121
+ { method: "setTaskPushNotificationConfig", value: params },
122
+ options,
123
+ this.transport.setTaskPushNotificationConfig.bind(this.transport)
124
+ );
125
+ }
126
+ /**
127
+ * Retrieves the current push notification configuration for a specified task.
128
+ * Requires the server to have AgentCard.capabilities.pushNotifications: true.
129
+ */
130
+ getTaskPushNotificationConfig(params, options) {
131
+ if (!this.agentCard.capabilities.pushNotifications) {
132
+ throw new PushNotificationNotSupportedError();
133
+ }
134
+ return this.executeWithInterceptors(
135
+ { method: "getTaskPushNotificationConfig", value: params },
136
+ options,
137
+ this.transport.getTaskPushNotificationConfig.bind(this.transport)
138
+ );
139
+ }
140
+ /**
141
+ * Retrieves the associated push notification configurations for a specified task.
142
+ * Requires the server to have AgentCard.capabilities.pushNotifications: true.
143
+ */
144
+ listTaskPushNotificationConfig(params, options) {
145
+ if (!this.agentCard.capabilities.pushNotifications) {
146
+ throw new PushNotificationNotSupportedError();
147
+ }
148
+ return this.executeWithInterceptors(
149
+ { method: "listTaskPushNotificationConfig", value: params },
150
+ options,
151
+ this.transport.listTaskPushNotificationConfig.bind(this.transport)
152
+ );
153
+ }
154
+ /**
155
+ * Deletes an associated push notification configuration for a task.
156
+ */
157
+ deleteTaskPushNotificationConfig(params, options) {
158
+ return this.executeWithInterceptors(
159
+ { method: "deleteTaskPushNotificationConfig", value: params },
160
+ options,
161
+ this.transport.deleteTaskPushNotificationConfig.bind(this.transport)
162
+ );
163
+ }
164
+ /**
165
+ * Retrieves the current state (including status, artifacts, and optionally history) of a previously initiated task.
166
+ */
167
+ getTask(params, options) {
168
+ return this.executeWithInterceptors(
169
+ { method: "getTask", value: params },
170
+ options,
171
+ this.transport.getTask.bind(this.transport)
172
+ );
173
+ }
174
+ /**
175
+ * Requests the cancellation of an ongoing task. The server will attempt to cancel the task,
176
+ * but success is not guaranteed (e.g., the task might have already completed or failed, or cancellation might not be supported at its current stage).
177
+ */
178
+ cancelTask(params, options) {
179
+ return this.executeWithInterceptors(
180
+ { method: "cancelTask", value: params },
181
+ options,
182
+ this.transport.cancelTask.bind(this.transport)
183
+ );
184
+ }
185
+ /**
186
+ * Allows a client to reconnect to an updates stream for an ongoing task after a previous connection was interrupted.
187
+ */
188
+ async *resubscribeTask(params, options) {
189
+ const method = "resubscribeTask";
190
+ const beforeArgs = { input: { method, value: params }, options };
191
+ const beforeResult = await this.interceptBefore(beforeArgs);
192
+ if (beforeResult) {
193
+ const earlyReturn = beforeResult.earlyReturn.value;
194
+ const afterArgs = {
195
+ result: { method, value: earlyReturn },
196
+ options: beforeArgs.options
197
+ };
198
+ await this.interceptAfter(afterArgs, beforeResult.executed);
199
+ yield afterArgs.result.value;
200
+ return;
201
+ }
202
+ for await (const event of this.transport.resubscribeTask(
203
+ beforeArgs.input.value,
204
+ beforeArgs.options
205
+ )) {
206
+ const afterArgs = {
207
+ result: { method, value: event },
208
+ options: beforeArgs.options
209
+ };
210
+ await this.interceptAfter(afterArgs);
211
+ yield afterArgs.result.value;
212
+ if (afterArgs.earlyReturn) {
213
+ return;
214
+ }
215
+ }
216
+ }
217
+ applyClientConfig({
218
+ params,
219
+ blocking
220
+ }) {
221
+ const result = { ...params, configuration: params.configuration ?? {} };
222
+ if (!result.configuration.acceptedOutputModes && this.config?.acceptedOutputModes) {
223
+ result.configuration.acceptedOutputModes = this.config.acceptedOutputModes;
224
+ }
225
+ if (!result.configuration.pushNotificationConfig && this.config?.pushNotificationConfig) {
226
+ result.configuration.pushNotificationConfig = this.config.pushNotificationConfig;
227
+ }
228
+ result.configuration.blocking ??= blocking;
229
+ return result;
230
+ }
231
+ async executeWithInterceptors(input, options, transportCall) {
232
+ const beforeArgs = {
233
+ input,
234
+ options
235
+ };
236
+ const beforeResult = await this.interceptBefore(beforeArgs);
237
+ if (beforeResult) {
238
+ const afterArgs2 = {
239
+ result: {
240
+ method: input.method,
241
+ value: beforeResult.earlyReturn.value
242
+ },
243
+ options: beforeArgs.options
244
+ };
245
+ await this.interceptAfter(afterArgs2, beforeResult.executed);
246
+ return afterArgs2.result.value;
247
+ }
248
+ const result = await transportCall(beforeArgs.input.value, beforeArgs.options);
249
+ const afterArgs = {
250
+ result: { method: input.method, value: result },
251
+ options: beforeArgs.options
252
+ };
253
+ await this.interceptAfter(afterArgs);
254
+ return afterArgs.result.value;
255
+ }
256
+ async interceptBefore(args) {
257
+ if (!this.config?.interceptors || this.config.interceptors.length === 0) {
258
+ return;
259
+ }
260
+ const executed = [];
261
+ for (const interceptor of this.config.interceptors) {
262
+ await interceptor.before(args);
263
+ executed.push(interceptor);
264
+ if (args.earlyReturn) {
265
+ return {
266
+ earlyReturn: args.earlyReturn,
267
+ executed
268
+ };
269
+ }
270
+ }
271
+ }
272
+ async interceptAfter(args, interceptors) {
273
+ if (!this.config?.interceptors || this.config.interceptors.length === 0) {
274
+ return;
275
+ }
276
+ for (const interceptor of interceptors ?? this.config.interceptors) {
277
+ await interceptor.after(args);
278
+ if (args.earlyReturn) {
279
+ return;
280
+ }
281
+ }
282
+ }
283
+ };
284
+
285
+ // src/client/factory.ts
286
+ var ClientFactoryOptions = {
287
+ Default: {
288
+ transports: [new JsonRpcTransportFactory()]
289
+ }
290
+ };
291
+ var ClientFactory = class {
292
+ constructor(options = ClientFactoryOptions.Default) {
293
+ this.options = options;
294
+ if (!options.transports || options.transports.length === 0) {
295
+ throw new Error("No transports provided");
296
+ }
297
+ for (const transport of options.transports) {
298
+ if (this.transportsByName.has(transport.protocolName)) {
299
+ throw new Error(`Duplicate transport name: ${transport.protocolName}`);
300
+ }
301
+ this.transportsByName.set(transport.protocolName, transport);
302
+ }
303
+ for (const transport of options.preferredTransports ?? []) {
304
+ const factory = this.options.transports.find((t) => t.protocolName === transport);
305
+ if (!factory) {
306
+ throw new Error(
307
+ `Unknown preferred transport: ${transport}, available transports: ${[...this.transportsByName.keys()].join()}`
308
+ );
309
+ }
310
+ }
311
+ this.agentCardResolver = options.cardResolver ?? AgentCardResolver.Default;
312
+ }
313
+ transportsByName = /* @__PURE__ */ new Map();
314
+ agentCardResolver;
315
+ /**
316
+ * Creates a new client from the provided agent card.
317
+ */
318
+ async createFromAgentCard(agentCard) {
319
+ const agentCardPreferred = agentCard.preferredTransport ?? JsonRpcTransportFactory.name;
320
+ const additionalInterfaces = agentCard.additionalInterfaces ?? [];
321
+ const urlsPerAgentTransports = new Map([
322
+ [agentCardPreferred, agentCard.url],
323
+ ...additionalInterfaces.map((i) => [i.transport, i.url])
324
+ ]);
325
+ const transportsByPreference = [
326
+ ...this.options.preferredTransports ?? [],
327
+ agentCardPreferred,
328
+ ...additionalInterfaces.map((i) => i.transport)
329
+ ];
330
+ for (const transport of transportsByPreference) {
331
+ if (!urlsPerAgentTransports.has(transport)) {
332
+ continue;
333
+ }
334
+ const factory = this.transportsByName.get(transport);
335
+ if (!factory) {
336
+ continue;
337
+ }
338
+ return new Client(
339
+ await factory.create(urlsPerAgentTransports.get(transport), agentCard),
340
+ agentCard,
341
+ this.options.clientConfig
342
+ );
343
+ }
344
+ throw new Error(
345
+ "No compatible transport found, available transports: " + [...this.transportsByName.keys()].join()
346
+ );
347
+ }
348
+ /**
349
+ * Downloads agent card using AgentCardResolver from options
350
+ * and creates a new client from the downloaded card.
351
+ */
352
+ async createFromAgentCardUrl(baseUrl, path) {
353
+ const agentCard = await this.agentCardResolver.resolve(baseUrl, path);
354
+ return await this.createFromAgentCard(agentCard);
355
+ }
356
+ };
357
+ export {
358
+ A2AClient,
359
+ AgentCardResolver,
360
+ Client,
361
+ ClientFactory,
362
+ ClientFactoryOptions,
363
+ DefaultAgentCardResolver,
364
+ JsonRpcTransport,
365
+ JsonRpcTransportFactory,
366
+ createAuthenticatingFetchWithRetry
367
+ };
@@ -0,0 +1,233 @@
1
+ import { a as Message, T as Task, b as TaskStatusUpdateEvent, c as TaskArtifactUpdateEvent, V as PushNotificationConfig, A as AgentCard, M as MessageSendParams, i as TaskQueryParams, f as TaskIdParams, d as TaskPushNotificationConfig, a8 as GetTaskPushNotificationConfigParams, L as ListTaskPushNotificationConfigParams, D as DeleteTaskPushNotificationConfigParams, J as JSONRPCResponse, ax as JSONRPCError } from './types-Due_Cv6t.mjs';
2
+ import { S as ServerCallContext, A as A2ARequestHandler } from './a2a_request_handler-DPkhsCMt.mjs';
3
+ import { EventEmitter } from 'events';
4
+
5
+ type AgentExecutionEvent = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
6
+ interface ExecutionEventBus {
7
+ publish(event: AgentExecutionEvent): void;
8
+ on(eventName: 'event' | 'finished', listener: (event: AgentExecutionEvent) => void): this;
9
+ off(eventName: 'event' | 'finished', listener: (event: AgentExecutionEvent) => void): this;
10
+ once(eventName: 'event' | 'finished', listener: (event: AgentExecutionEvent) => void): this;
11
+ removeAllListeners(eventName?: 'event' | 'finished'): this;
12
+ finished(): void;
13
+ }
14
+ declare class DefaultExecutionEventBus extends EventEmitter implements ExecutionEventBus {
15
+ constructor();
16
+ publish(event: AgentExecutionEvent): void;
17
+ finished(): void;
18
+ }
19
+
20
+ declare class RequestContext {
21
+ readonly userMessage: Message;
22
+ readonly taskId: string;
23
+ readonly contextId: string;
24
+ readonly task?: Task;
25
+ readonly referenceTasks?: Task[];
26
+ readonly context?: ServerCallContext;
27
+ constructor(userMessage: Message, taskId: string, contextId: string, task?: Task, referenceTasks?: Task[], context?: ServerCallContext);
28
+ }
29
+
30
+ interface AgentExecutor {
31
+ /**
32
+ * Executes the agent logic based on the request context and publishes events.
33
+ * @param requestContext The context of the current request.
34
+ * @param eventBus The bus to publish execution events to.
35
+ */
36
+ execute: (requestContext: RequestContext, eventBus: ExecutionEventBus) => Promise<void>;
37
+ /**
38
+ * Method to explicitly cancel a running task.
39
+ * The implementation should handle the logic of stopping the execution
40
+ * and publishing the final 'canceled' status event on the provided event bus.
41
+ * @param taskId The ID of the task to cancel.
42
+ * @param eventBus The event bus associated with the task's execution.
43
+ */
44
+ cancelTask: (taskId: string, eventBus: ExecutionEventBus) => Promise<void>;
45
+ }
46
+
47
+ interface ExecutionEventBusManager {
48
+ createOrGetByTaskId(taskId: string): ExecutionEventBus;
49
+ getByTaskId(taskId: string): ExecutionEventBus | undefined;
50
+ cleanupByTaskId(taskId: string): void;
51
+ }
52
+ declare class DefaultExecutionEventBusManager implements ExecutionEventBusManager {
53
+ private taskIdToBus;
54
+ /**
55
+ * Creates or retrieves an existing ExecutionEventBus based on the taskId.
56
+ * @param taskId The ID of the task.
57
+ * @returns An instance of IExecutionEventBus.
58
+ */
59
+ createOrGetByTaskId(taskId: string): ExecutionEventBus;
60
+ /**
61
+ * Retrieves an existing ExecutionEventBus based on the taskId.
62
+ * @param taskId The ID of the task.
63
+ * @returns An instance of IExecutionEventBus or undefined if not found.
64
+ */
65
+ getByTaskId(taskId: string): ExecutionEventBus | undefined;
66
+ /**
67
+ * Removes the event bus for a given taskId.
68
+ * This should be called when an execution flow is complete to free resources.
69
+ * @param taskId The ID of the task.
70
+ */
71
+ cleanupByTaskId(taskId: string): void;
72
+ }
73
+
74
+ /**
75
+ * An async queue that subscribes to an ExecutionEventBus for events
76
+ * and provides an async generator to consume them.
77
+ */
78
+ declare class ExecutionEventQueue {
79
+ private eventBus;
80
+ private eventQueue;
81
+ private resolvePromise?;
82
+ private stopped;
83
+ private boundHandleEvent;
84
+ constructor(eventBus: ExecutionEventBus);
85
+ private handleEvent;
86
+ private handleFinished;
87
+ /**
88
+ * Provides an async generator that yields events from the event bus.
89
+ * Stops when a Message event is received or a TaskStatusUpdateEvent with final=true is received.
90
+ */
91
+ events(): AsyncGenerator<AgentExecutionEvent, void, undefined>;
92
+ /**
93
+ * Stops the event queue from processing further events.
94
+ */
95
+ stop(): void;
96
+ }
97
+
98
+ /**
99
+ * Simplified interface for task storage providers.
100
+ * Stores and retrieves the task.
101
+ */
102
+ interface TaskStore {
103
+ /**
104
+ * Saves a task.
105
+ * Overwrites existing data if the task ID exists.
106
+ * @param data An object containing the task.
107
+ * @returns A promise resolving when the save operation is complete.
108
+ */
109
+ save(task: Task): Promise<void>;
110
+ /**
111
+ * Loads a task by task ID.
112
+ * @param taskId The ID of the task to load.
113
+ * @returns A promise resolving to an object containing the Task, or undefined if not found.
114
+ */
115
+ load(taskId: string): Promise<Task | undefined>;
116
+ }
117
+ declare class InMemoryTaskStore implements TaskStore {
118
+ private store;
119
+ load(taskId: string): Promise<Task | undefined>;
120
+ save(task: Task): Promise<void>;
121
+ }
122
+
123
+ interface PushNotificationStore {
124
+ save(taskId: string, pushNotificationConfig: PushNotificationConfig): Promise<void>;
125
+ load(taskId: string): Promise<PushNotificationConfig[]>;
126
+ delete(taskId: string, configId?: string): Promise<void>;
127
+ }
128
+ declare class InMemoryPushNotificationStore implements PushNotificationStore {
129
+ private store;
130
+ save(taskId: string, pushNotificationConfig: PushNotificationConfig): Promise<void>;
131
+ load(taskId: string): Promise<PushNotificationConfig[]>;
132
+ delete(taskId: string, configId?: string): Promise<void>;
133
+ }
134
+
135
+ interface PushNotificationSender {
136
+ send(task: Task): Promise<void>;
137
+ }
138
+
139
+ declare class DefaultRequestHandler implements A2ARequestHandler {
140
+ private readonly agentCard;
141
+ private readonly taskStore;
142
+ private readonly agentExecutor;
143
+ private readonly eventBusManager;
144
+ private readonly pushNotificationStore?;
145
+ private readonly pushNotificationSender?;
146
+ private readonly extendedAgentCardProvider?;
147
+ constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, pushNotificationStore?: PushNotificationStore, pushNotificationSender?: PushNotificationSender, extendedAgentCardProvider?: AgentCard | ExtendedAgentCardProvider);
148
+ getAgentCard(): Promise<AgentCard>;
149
+ getAuthenticatedExtendedAgentCard(context?: ServerCallContext): Promise<AgentCard>;
150
+ private _createRequestContext;
151
+ private _processEvents;
152
+ sendMessage(params: MessageSendParams, context?: ServerCallContext): Promise<Message | Task>;
153
+ sendMessageStream(params: MessageSendParams, context?: ServerCallContext): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
154
+ getTask(params: TaskQueryParams, _context?: ServerCallContext): Promise<Task>;
155
+ cancelTask(params: TaskIdParams, _context?: ServerCallContext): Promise<Task>;
156
+ setTaskPushNotificationConfig(params: TaskPushNotificationConfig, _context?: ServerCallContext): Promise<TaskPushNotificationConfig>;
157
+ getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams, _context?: ServerCallContext): Promise<TaskPushNotificationConfig>;
158
+ listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams, _context?: ServerCallContext): Promise<TaskPushNotificationConfig[]>;
159
+ deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams, _context?: ServerCallContext): Promise<void>;
160
+ resubscribe(params: TaskIdParams, _context?: ServerCallContext): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
161
+ private _sendPushNotificationIfNeeded;
162
+ private _handleProcessingError;
163
+ }
164
+ type ExtendedAgentCardProvider = (context?: ServerCallContext) => Promise<AgentCard>;
165
+
166
+ declare class ResultManager {
167
+ private taskStore;
168
+ private currentTask?;
169
+ private latestUserMessage?;
170
+ private finalMessageResult?;
171
+ constructor(taskStore: TaskStore);
172
+ setContext(latestUserMessage: Message): void;
173
+ /**
174
+ * Processes an agent execution event and updates the task store.
175
+ * @param event The agent execution event.
176
+ */
177
+ processEvent(event: AgentExecutionEvent): Promise<void>;
178
+ private saveCurrentTask;
179
+ /**
180
+ * Gets the final result, which could be a Message or a Task.
181
+ * This should be called after the event stream has been fully processed.
182
+ * @returns The final Message or the current Task.
183
+ */
184
+ getFinalResult(): Message | Task | undefined;
185
+ /**
186
+ * Gets the task currently being managed by this ResultManager instance.
187
+ * This task could be one that was started with or one created during agent execution.
188
+ * @returns The current Task or undefined if no task is active.
189
+ */
190
+ getCurrentTask(): Task | undefined;
191
+ }
192
+
193
+ /**
194
+ * Handles JSON-RPC transport layer, routing requests to A2ARequestHandler.
195
+ */
196
+ declare class JsonRpcTransportHandler {
197
+ private requestHandler;
198
+ constructor(requestHandler: A2ARequestHandler);
199
+ /**
200
+ * Handles an incoming JSON-RPC request.
201
+ * For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
202
+ * For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
203
+ */
204
+ handle(requestBody: any, context?: ServerCallContext): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
205
+ private isRequestValid;
206
+ private paramsAreValid;
207
+ }
208
+
209
+ /**
210
+ * Custom error class for A2A server operations, incorporating JSON-RPC error codes.
211
+ */
212
+ declare class A2AError extends Error {
213
+ code: number;
214
+ data?: Record<string, unknown>;
215
+ taskId?: string;
216
+ constructor(code: number, message: string, data?: Record<string, unknown>, taskId?: string);
217
+ /**
218
+ * Formats the error into a standard JSON-RPC error object structure.
219
+ */
220
+ toJSONRPCError(): JSONRPCError;
221
+ static parseError(message: string, data?: Record<string, unknown>): A2AError;
222
+ static invalidRequest(message: string, data?: Record<string, unknown>): A2AError;
223
+ static methodNotFound(method: string): A2AError;
224
+ static invalidParams(message: string, data?: Record<string, unknown>): A2AError;
225
+ static internalError(message: string, data?: Record<string, unknown>): A2AError;
226
+ static taskNotFound(taskId: string): A2AError;
227
+ static taskNotCancelable(taskId: string): A2AError;
228
+ static pushNotificationNotSupported(): A2AError;
229
+ static unsupportedOperation(operation: string): A2AError;
230
+ static authenticatedExtendedCardNotConfigured(): A2AError;
231
+ }
232
+
233
+ export { type AgentExecutor as A, DefaultExecutionEventBus as D, type ExecutionEventBus as E, InMemoryTaskStore as I, JsonRpcTransportHandler as J, type PushNotificationSender as P, RequestContext as R, type TaskStore as T, type PushNotificationStore as a, type AgentExecutionEvent as b, type ExecutionEventBusManager as c, DefaultExecutionEventBusManager as d, ExecutionEventQueue as e, DefaultRequestHandler as f, type ExtendedAgentCardProvider as g, ResultManager as h, A2AError as i, InMemoryPushNotificationStore as j };