@a2a-js/sdk 0.2.4 → 0.3.0

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.
@@ -1,7 +1,5 @@
1
1
  import { EventEmitter } from 'events';
2
- import { a as Message, T as Task, b as TaskStatusUpdateEvent, c as TaskArtifactUpdateEvent, A as AgentCard, M as MessageSendParams, g as TaskQueryParams, f as TaskIdParams, d as TaskPushNotificationConfig, j as JSONRPCError } from '../types-CcBgkR2G.js';
3
- import { A2AResponse } from '../index.js';
4
- import { Express, RequestHandler, ErrorRequestHandler } from 'express';
2
+ import { B as Message, aw as Task, aO as TaskStatusUpdateEvent, aQ as TaskArtifactUpdateEvent, ac as AgentCard, w as MessageSendParams, V as TaskQueryParams, X as TaskIdParams, Z as TaskPushNotificationConfig, a1 as GetTaskPushNotificationConfigParams, a5 as ListTaskPushNotificationConfigParams, a7 as DeleteTaskPushNotificationConfigParams, i as JSONRPCResponse, au as JSONRPCError } from '../types-DNKcmF0f.js';
5
3
 
6
4
  type AgentExecutionEvent = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
7
5
  interface ExecutionEventBus {
@@ -71,14 +69,41 @@ declare class DefaultExecutionEventBusManager implements ExecutionEventBusManage
71
69
  cleanupByTaskId(taskId: string): void;
72
70
  }
73
71
 
72
+ /**
73
+ * An async queue that subscribes to an ExecutionEventBus for events
74
+ * and provides an async generator to consume them.
75
+ */
76
+ declare class ExecutionEventQueue {
77
+ private eventBus;
78
+ private eventQueue;
79
+ private resolvePromise?;
80
+ private stopped;
81
+ private boundHandleEvent;
82
+ constructor(eventBus: ExecutionEventBus);
83
+ private handleEvent;
84
+ private handleFinished;
85
+ /**
86
+ * Provides an async generator that yields events from the event bus.
87
+ * Stops when a Message event is received or a TaskStatusUpdateEvent with final=true is received.
88
+ */
89
+ events(): AsyncGenerator<AgentExecutionEvent, void, undefined>;
90
+ /**
91
+ * Stops the event queue from processing further events.
92
+ */
93
+ stop(): void;
94
+ }
95
+
74
96
  interface A2ARequestHandler {
75
97
  getAgentCard(): Promise<AgentCard>;
98
+ getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
76
99
  sendMessage(params: MessageSendParams): Promise<Message | Task>;
77
100
  sendMessageStream(params: MessageSendParams): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
78
101
  getTask(params: TaskQueryParams): Promise<Task>;
79
102
  cancelTask(params: TaskIdParams): Promise<Task>;
80
103
  setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
81
- getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
104
+ getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
105
+ listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
106
+ deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
82
107
  resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
83
108
  }
84
109
 
@@ -109,12 +134,14 @@ declare class InMemoryTaskStore implements TaskStore {
109
134
 
110
135
  declare class DefaultRequestHandler implements A2ARequestHandler {
111
136
  private readonly agentCard;
137
+ private readonly extendedAgentCard?;
112
138
  private readonly taskStore;
113
139
  private readonly agentExecutor;
114
140
  private readonly eventBusManager;
115
141
  private readonly pushNotificationConfigs;
116
- constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager);
142
+ constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, extendedAgentCard?: AgentCard);
117
143
  getAgentCard(): Promise<AgentCard>;
144
+ getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
118
145
  private _createRequestContext;
119
146
  private _processEvents;
120
147
  sendMessage(params: MessageSendParams): Promise<Message | Task>;
@@ -122,7 +149,9 @@ declare class DefaultRequestHandler implements A2ARequestHandler {
122
149
  getTask(params: TaskQueryParams): Promise<Task>;
123
150
  cancelTask(params: TaskIdParams): Promise<Task>;
124
151
  setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
125
- getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
152
+ getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
153
+ listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
154
+ deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
126
155
  resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
127
156
  }
128
157
 
@@ -164,21 +193,7 @@ declare class JsonRpcTransportHandler {
164
193
  * For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
165
194
  * For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
166
195
  */
167
- handle(requestBody: any): Promise<A2AResponse | AsyncGenerator<A2AResponse, void, undefined>>;
168
- }
169
-
170
- declare class A2AExpressApp {
171
- private requestHandler;
172
- private jsonRpcTransportHandler;
173
- constructor(requestHandler: A2ARequestHandler);
174
- /**
175
- * Adds A2A routes to an existing Express app.
176
- * @param app Optional existing Express app.
177
- * @param baseUrl The base URL for A2A endpoints (e.g., "/a2a/api").
178
- * @param middlewares Optional array of Express middlewares to apply to the A2A routes.
179
- * @returns The Express app with A2A routes.
180
- */
181
- setupRoutes(app: Express, baseUrl?: string, middlewares?: Array<RequestHandler | ErrorRequestHandler>): Express;
196
+ handle(requestBody: any): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
182
197
  }
183
198
 
184
199
  /**
@@ -202,6 +217,7 @@ declare class A2AError extends Error {
202
217
  static taskNotCancelable(taskId: string): A2AError;
203
218
  static pushNotificationNotSupported(): A2AError;
204
219
  static unsupportedOperation(operation: string): A2AError;
220
+ static authenticatedExtendedCardNotConfigured(): A2AError;
205
221
  }
206
222
 
207
- export { A2AError, A2AExpressApp, type A2ARequestHandler, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, InMemoryTaskStore, JsonRpcTransportHandler, RequestContext, ResultManager, type TaskStore };
223
+ export { A2AError, type A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, InMemoryTaskStore, JsonRpcTransportHandler, RequestContext, ResultManager, type TaskStore };
@@ -64,6 +64,63 @@ var DefaultExecutionEventBusManager = class {
64
64
  }
65
65
  };
66
66
 
67
+ // src/server/events/execution_event_queue.ts
68
+ var ExecutionEventQueue = class {
69
+ eventBus;
70
+ eventQueue = [];
71
+ resolvePromise;
72
+ stopped = false;
73
+ boundHandleEvent;
74
+ constructor(eventBus) {
75
+ this.eventBus = eventBus;
76
+ this.eventBus.on("event", this.handleEvent);
77
+ this.eventBus.on("finished", this.handleFinished);
78
+ }
79
+ handleEvent = (event) => {
80
+ if (this.stopped) return;
81
+ this.eventQueue.push(event);
82
+ if (this.resolvePromise) {
83
+ this.resolvePromise();
84
+ this.resolvePromise = void 0;
85
+ }
86
+ };
87
+ handleFinished = () => {
88
+ this.stop();
89
+ };
90
+ /**
91
+ * Provides an async generator that yields events from the event bus.
92
+ * Stops when a Message event is received or a TaskStatusUpdateEvent with final=true is received.
93
+ */
94
+ async *events() {
95
+ while (!this.stopped || this.eventQueue.length > 0) {
96
+ if (this.eventQueue.length > 0) {
97
+ const event = this.eventQueue.shift();
98
+ yield event;
99
+ if (event.kind === "message" || event.kind === "status-update" && event.final) {
100
+ this.handleFinished();
101
+ break;
102
+ }
103
+ } else if (!this.stopped) {
104
+ await new Promise((resolve) => {
105
+ this.resolvePromise = resolve;
106
+ });
107
+ }
108
+ }
109
+ }
110
+ /**
111
+ * Stops the event queue from processing further events.
112
+ */
113
+ stop() {
114
+ this.stopped = true;
115
+ if (this.resolvePromise) {
116
+ this.resolvePromise();
117
+ this.resolvePromise = void 0;
118
+ }
119
+ this.eventBus.off("event", this.handleEvent);
120
+ this.eventBus.off("finished", this.handleFinished);
121
+ }
122
+ };
123
+
67
124
  // src/server/request_handler/default_request_handler.ts
68
125
  import { v4 as uuidv4 } from "uuid";
69
126
 
@@ -140,62 +197,11 @@ var A2AError = class _A2AError extends Error {
140
197
  `Unsupported operation: ${operation}`
141
198
  );
142
199
  }
143
- };
144
-
145
- // src/server/events/execution_event_queue.ts
146
- var ExecutionEventQueue = class {
147
- eventBus;
148
- eventQueue = [];
149
- resolvePromise;
150
- stopped = false;
151
- boundHandleEvent;
152
- constructor(eventBus) {
153
- this.eventBus = eventBus;
154
- this.eventBus.on("event", this.handleEvent);
155
- this.eventBus.on("finished", this.handleFinished);
156
- }
157
- handleEvent = (event) => {
158
- if (this.stopped) return;
159
- this.eventQueue.push(event);
160
- if (this.resolvePromise) {
161
- this.resolvePromise();
162
- this.resolvePromise = void 0;
163
- }
164
- };
165
- handleFinished = () => {
166
- this.stop();
167
- };
168
- /**
169
- * Provides an async generator that yields events from the event bus.
170
- * Stops when a Message event is received or a TaskStatusUpdateEvent with final=true is received.
171
- */
172
- async *events() {
173
- while (!this.stopped || this.eventQueue.length > 0) {
174
- if (this.eventQueue.length > 0) {
175
- const event = this.eventQueue.shift();
176
- yield event;
177
- if (event.kind === "message" || event.kind === "status-update" && event.final) {
178
- this.handleFinished();
179
- break;
180
- }
181
- } else if (!this.stopped) {
182
- await new Promise((resolve) => {
183
- this.resolvePromise = resolve;
184
- });
185
- }
186
- }
187
- }
188
- /**
189
- * Stops the event queue from processing further events.
190
- */
191
- stop() {
192
- this.stopped = true;
193
- if (this.resolvePromise) {
194
- this.resolvePromise();
195
- this.resolvePromise = void 0;
196
- }
197
- this.eventBus.off("event", this.handleEvent);
198
- this.eventBus.off("finished", this.handleFinished);
200
+ static authenticatedExtendedCardNotConfigured() {
201
+ return new _A2AError(
202
+ -32007,
203
+ `Extended card not configured.`
204
+ );
199
205
  }
200
206
  };
201
207
 
@@ -331,20 +337,28 @@ var ResultManager = class {
331
337
  var terminalStates = ["completed", "failed", "canceled", "rejected"];
332
338
  var DefaultRequestHandler = class {
333
339
  agentCard;
340
+ extendedAgentCard;
334
341
  taskStore;
335
342
  agentExecutor;
336
343
  eventBusManager;
337
344
  // Store for push notification configurations (could be part of TaskStore or separate)
338
345
  pushNotificationConfigs = /* @__PURE__ */ new Map();
339
- constructor(agentCard, taskStore, agentExecutor, eventBusManager = new DefaultExecutionEventBusManager()) {
346
+ constructor(agentCard, taskStore, agentExecutor, eventBusManager = new DefaultExecutionEventBusManager(), extendedAgentCard) {
340
347
  this.agentCard = agentCard;
341
348
  this.taskStore = taskStore;
342
349
  this.agentExecutor = agentExecutor;
343
350
  this.eventBusManager = eventBusManager;
351
+ this.extendedAgentCard = extendedAgentCard;
344
352
  }
345
353
  async getAgentCard() {
346
354
  return this.agentCard;
347
355
  }
356
+ async getAuthenticatedExtendedAgentCard() {
357
+ if (!this.extendedAgentCard) {
358
+ throw A2AError.authenticatedExtendedCardNotConfigured();
359
+ }
360
+ return this.extendedAgentCard;
361
+ }
348
362
  async _createRequestContext(incomingMessage, taskId, isStream) {
349
363
  let task;
350
364
  let referenceTasks;
@@ -368,11 +382,11 @@ var DefaultRequestHandler = class {
368
382
  }
369
383
  }
370
384
  }
371
- const messageForContext = { ...incomingMessage };
372
- if (!messageForContext.contextId) {
373
- messageForContext.contextId = task?.contextId || uuidv4();
374
- }
375
- const contextId = incomingMessage.contextId || uuidv4();
385
+ const contextId = incomingMessage.contextId || task?.contextId || uuidv4();
386
+ const messageForContext = {
387
+ ...incomingMessage,
388
+ contextId
389
+ };
376
390
  return new RequestContext(
377
391
  messageForContext,
378
392
  taskId,
@@ -567,27 +581,78 @@ var DefaultRequestHandler = class {
567
581
  if (!this.agentCard.capabilities.pushNotifications) {
568
582
  throw A2AError.pushNotificationNotSupported();
569
583
  }
570
- const taskAndHistory = await this.taskStore.load(params.taskId);
571
- if (!taskAndHistory) {
584
+ const task = await this.taskStore.load(params.taskId);
585
+ if (!task) {
572
586
  throw A2AError.taskNotFound(params.taskId);
573
587
  }
574
- this.pushNotificationConfigs.set(params.taskId, params.pushNotificationConfig);
588
+ const { taskId, pushNotificationConfig } = params;
589
+ if (!pushNotificationConfig.id) {
590
+ pushNotificationConfig.id = taskId;
591
+ }
592
+ const configs = this.pushNotificationConfigs.get(taskId) || [];
593
+ const updatedConfigs = configs.filter((c) => c.id !== pushNotificationConfig.id);
594
+ updatedConfigs.push(pushNotificationConfig);
595
+ this.pushNotificationConfigs.set(taskId, updatedConfigs);
575
596
  return params;
576
597
  }
577
598
  async getTaskPushNotificationConfig(params) {
578
599
  if (!this.agentCard.capabilities.pushNotifications) {
579
600
  throw A2AError.pushNotificationNotSupported();
580
601
  }
581
- const taskAndHistory = await this.taskStore.load(params.id);
582
- if (!taskAndHistory) {
602
+ const task = await this.taskStore.load(params.id);
603
+ if (!task) {
583
604
  throw A2AError.taskNotFound(params.id);
584
605
  }
585
- const config = this.pushNotificationConfigs.get(params.id);
586
- if (!config) {
606
+ const configs = this.pushNotificationConfigs.get(params.id) || [];
607
+ if (configs.length === 0) {
587
608
  throw A2AError.internalError(`Push notification config not found for task ${params.id}.`);
588
609
  }
610
+ let configId;
611
+ if ("pushNotificationConfigId" in params && params.pushNotificationConfigId) {
612
+ configId = params.pushNotificationConfigId;
613
+ } else {
614
+ configId = params.id;
615
+ }
616
+ const config = configs.find((c) => c.id === configId);
617
+ if (!config) {
618
+ throw A2AError.internalError(`Push notification config with id '${configId}' not found for task ${params.id}.`);
619
+ }
589
620
  return { taskId: params.id, pushNotificationConfig: config };
590
621
  }
622
+ async listTaskPushNotificationConfigs(params) {
623
+ if (!this.agentCard.capabilities.pushNotifications) {
624
+ throw A2AError.pushNotificationNotSupported();
625
+ }
626
+ const task = await this.taskStore.load(params.id);
627
+ if (!task) {
628
+ throw A2AError.taskNotFound(params.id);
629
+ }
630
+ const configs = this.pushNotificationConfigs.get(params.id) || [];
631
+ return configs.map((config) => ({
632
+ taskId: params.id,
633
+ pushNotificationConfig: config
634
+ }));
635
+ }
636
+ async deleteTaskPushNotificationConfig(params) {
637
+ if (!this.agentCard.capabilities.pushNotifications) {
638
+ throw A2AError.pushNotificationNotSupported();
639
+ }
640
+ const task = await this.taskStore.load(params.id);
641
+ if (!task) {
642
+ throw A2AError.taskNotFound(params.id);
643
+ }
644
+ const { id: taskId, pushNotificationConfigId } = params;
645
+ const configs = this.pushNotificationConfigs.get(taskId);
646
+ if (!configs) {
647
+ return;
648
+ }
649
+ const updatedConfigs = configs.filter((c) => c.id !== pushNotificationConfigId);
650
+ if (updatedConfigs.length === 0) {
651
+ this.pushNotificationConfigs.delete(taskId);
652
+ } else if (updatedConfigs.length < configs.length) {
653
+ this.pushNotificationConfigs.set(taskId, updatedConfigs);
654
+ }
655
+ }
591
656
  async *resubscribe(params) {
592
657
  if (!this.agentCard.capabilities.streaming) {
593
658
  throw A2AError.unsupportedOperation("Streaming (and thus resubscription) is not supported.");
@@ -669,9 +734,21 @@ var JsonRpcTransportHandler = class {
669
734
  error: a2aError.toJSONRPCError()
670
735
  };
671
736
  }
672
- const { method, params = {}, id: requestId = null } = rpcRequest;
737
+ const { method, id: requestId = null } = rpcRequest;
673
738
  try {
739
+ if (method === "agent/getAuthenticatedExtendedCard") {
740
+ const result = await this.requestHandler.getAuthenticatedExtendedAgentCard();
741
+ return {
742
+ jsonrpc: "2.0",
743
+ id: requestId,
744
+ result
745
+ };
746
+ }
747
+ if (!rpcRequest.params) {
748
+ throw A2AError.invalidParams(`'params' is required for '${method}'`);
749
+ }
674
750
  if (method === "message/stream" || method === "tasks/resubscribe") {
751
+ const params = rpcRequest.params;
675
752
  const agentCard = await this.requestHandler.getAgentCard();
676
753
  if (!agentCard.capabilities.streaming) {
677
754
  throw A2AError.unsupportedOperation(`Method ${method} requires streaming capability.`);
@@ -696,22 +773,33 @@ var JsonRpcTransportHandler = class {
696
773
  let result;
697
774
  switch (method) {
698
775
  case "message/send":
699
- result = await this.requestHandler.sendMessage(params);
776
+ result = await this.requestHandler.sendMessage(rpcRequest.params);
700
777
  break;
701
778
  case "tasks/get":
702
- result = await this.requestHandler.getTask(params);
779
+ result = await this.requestHandler.getTask(rpcRequest.params);
703
780
  break;
704
781
  case "tasks/cancel":
705
- result = await this.requestHandler.cancelTask(params);
782
+ result = await this.requestHandler.cancelTask(rpcRequest.params);
706
783
  break;
707
784
  case "tasks/pushNotificationConfig/set":
708
785
  result = await this.requestHandler.setTaskPushNotificationConfig(
709
- params
786
+ rpcRequest.params
710
787
  );
711
788
  break;
712
789
  case "tasks/pushNotificationConfig/get":
713
790
  result = await this.requestHandler.getTaskPushNotificationConfig(
714
- params
791
+ rpcRequest.params
792
+ );
793
+ break;
794
+ case "tasks/pushNotificationConfig/delete":
795
+ await this.requestHandler.deleteTaskPushNotificationConfig(
796
+ rpcRequest.params
797
+ );
798
+ result = null;
799
+ break;
800
+ case "tasks/pushNotificationConfig/list":
801
+ result = await this.requestHandler.listTaskPushNotificationConfigs(
802
+ rpcRequest.params
715
803
  );
716
804
  break;
717
805
  default:
@@ -733,107 +821,12 @@ var JsonRpcTransportHandler = class {
733
821
  }
734
822
  }
735
823
  };
736
-
737
- // src/server/a2a_express_app.ts
738
- import express from "express";
739
- var A2AExpressApp = class {
740
- requestHandler;
741
- // Kept for getAgentCard
742
- jsonRpcTransportHandler;
743
- constructor(requestHandler) {
744
- this.requestHandler = requestHandler;
745
- this.jsonRpcTransportHandler = new JsonRpcTransportHandler(requestHandler);
746
- }
747
- /**
748
- * Adds A2A routes to an existing Express app.
749
- * @param app Optional existing Express app.
750
- * @param baseUrl The base URL for A2A endpoints (e.g., "/a2a/api").
751
- * @param middlewares Optional array of Express middlewares to apply to the A2A routes.
752
- * @returns The Express app with A2A routes.
753
- */
754
- setupRoutes(app, baseUrl = "", middlewares) {
755
- const router = express.Router();
756
- router.use(express.json(), ...middlewares ?? []);
757
- router.get("/.well-known/agent.json", async (req, res) => {
758
- try {
759
- const agentCard = await this.requestHandler.getAgentCard();
760
- res.json(agentCard);
761
- } catch (error) {
762
- console.error("Error fetching agent card:", error);
763
- res.status(500).json({ error: "Failed to retrieve agent card" });
764
- }
765
- });
766
- router.post("/", async (req, res) => {
767
- try {
768
- const rpcResponseOrStream = await this.jsonRpcTransportHandler.handle(req.body);
769
- if (typeof rpcResponseOrStream?.[Symbol.asyncIterator] === "function") {
770
- const stream = rpcResponseOrStream;
771
- res.setHeader("Content-Type", "text/event-stream");
772
- res.setHeader("Cache-Control", "no-cache");
773
- res.setHeader("Connection", "keep-alive");
774
- res.flushHeaders();
775
- try {
776
- for await (const event of stream) {
777
- res.write(`id: ${(/* @__PURE__ */ new Date()).getTime()}
778
- `);
779
- res.write(`data: ${JSON.stringify(event)}
780
-
781
- `);
782
- }
783
- } catch (streamError) {
784
- console.error(`Error during SSE streaming (request ${req.body?.id}):`, streamError);
785
- const a2aError = streamError instanceof A2AError ? streamError : A2AError.internalError(streamError.message || "Streaming error.");
786
- const errorResponse = {
787
- jsonrpc: "2.0",
788
- id: req.body?.id || null,
789
- // Use original request ID if available
790
- error: a2aError.toJSONRPCError()
791
- };
792
- if (!res.headersSent) {
793
- res.status(500).json(errorResponse);
794
- } else {
795
- res.write(`id: ${(/* @__PURE__ */ new Date()).getTime()}
796
- `);
797
- res.write(`event: error
798
- `);
799
- res.write(`data: ${JSON.stringify(errorResponse)}
800
-
801
- `);
802
- }
803
- } finally {
804
- if (!res.writableEnded) {
805
- res.end();
806
- }
807
- }
808
- } else {
809
- const rpcResponse = rpcResponseOrStream;
810
- res.status(200).json(rpcResponse);
811
- }
812
- } catch (error) {
813
- console.error("Unhandled error in A2AExpressApp POST handler:", error);
814
- const a2aError = error instanceof A2AError ? error : A2AError.internalError("General processing error.");
815
- const errorResponse = {
816
- jsonrpc: "2.0",
817
- id: req.body?.id || null,
818
- error: a2aError.toJSONRPCError()
819
- };
820
- if (!res.headersSent) {
821
- res.status(500).json(errorResponse);
822
- } else if (!res.writableEnded) {
823
- res.end();
824
- }
825
- }
826
- });
827
- app.use(baseUrl, router);
828
- return app;
829
- }
830
- };
831
824
  export {
832
825
  A2AError,
833
- A2AExpressApp,
834
826
  DefaultExecutionEventBus,
835
827
  DefaultExecutionEventBusManager,
836
828
  DefaultRequestHandler,
829
+ ExecutionEventQueue,
837
830
  InMemoryTaskStore,
838
831
  JsonRpcTransportHandler,
839
832
  RequestContext,