@a2a-js/sdk 0.2.5 → 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.
- package/README.md +14 -1
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/server/index.cjs +102 -121
- package/dist/server/index.d.cts +14 -22
- package/dist/server/index.d.ts +14 -22
- package/dist/server/index.js +102 -110
- package/dist/types-DNKcmF0f.d.cts +2562 -0
- package/dist/types-DNKcmF0f.d.ts +2562 -0
- package/package.json +16 -6
- package/dist/types-CcBgkR2G.d.cts +0 -2048
- package/dist/types-CcBgkR2G.d.ts +0 -2048
package/README.md
CHANGED
|
@@ -21,12 +21,25 @@ You can install the A2A SDK using either `npm`.
|
|
|
21
21
|
npm install @a2a-js/sdk
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
### For Server Usage
|
|
25
|
+
|
|
26
|
+
If you plan to use the A2A server functionality (A2AExpressApp), you'll also need to install Express as it's a peer dependency:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install express
|
|
30
|
+
```
|
|
31
|
+
|
|
24
32
|
You can also find JavaScript samples [here](https://github.com/google-a2a/a2a-samples/tree/main/samples/js).
|
|
25
33
|
|
|
26
34
|
## A2A Server
|
|
27
35
|
|
|
28
36
|
This directory contains a TypeScript server implementation for the Agent-to-Agent (A2A) communication protocol, built using Express.js.
|
|
29
37
|
|
|
38
|
+
**Note:** Express is a peer dependency for server functionality. Make sure to install it separately:
|
|
39
|
+
```bash
|
|
40
|
+
npm install express
|
|
41
|
+
```
|
|
42
|
+
|
|
30
43
|
### 1. Define Agent Card
|
|
31
44
|
|
|
32
45
|
```typescript
|
|
@@ -81,12 +94,12 @@ const movieAgentCard: AgentCard = {
|
|
|
81
94
|
import {
|
|
82
95
|
InMemoryTaskStore,
|
|
83
96
|
TaskStore,
|
|
84
|
-
A2AExpressApp,
|
|
85
97
|
AgentExecutor,
|
|
86
98
|
RequestContext,
|
|
87
99
|
ExecutionEventBus,
|
|
88
100
|
DefaultRequestHandler,
|
|
89
101
|
} from "@a2a-js/sdk/server";
|
|
102
|
+
import { A2AExpressApp } from "@a2a-js/sdk/server/express";
|
|
90
103
|
|
|
91
104
|
// 1. Define your agent's logic as a AgentExecutor
|
|
92
105
|
class MyAgentExecutor implements AgentExecutor {
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ac as AgentCard, w as MessageSendParams, S as SendMessageResponse, B as Message, aw as Task, aO as TaskStatusUpdateEvent, aQ as TaskArtifactUpdateEvent, Z as TaskPushNotificationConfig, b as SetTaskPushNotificationConfigResponse, X as TaskIdParams, c as GetTaskPushNotificationConfigResponse, V as TaskQueryParams, G as GetTaskResponse, C as CancelTaskResponse, i as JSONRPCResponse, J as JSONRPCErrorResponse } from '../types-DNKcmF0f.cjs';
|
|
2
2
|
|
|
3
3
|
type A2AStreamEventData = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
4
4
|
/**
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ac as AgentCard, w as MessageSendParams, S as SendMessageResponse, B as Message, aw as Task, aO as TaskStatusUpdateEvent, aQ as TaskArtifactUpdateEvent, Z as TaskPushNotificationConfig, b as SetTaskPushNotificationConfigResponse, X as TaskIdParams, c as GetTaskPushNotificationConfigResponse, V as TaskQueryParams, G as GetTaskResponse, C as CancelTaskResponse, i as JSONRPCResponse, J as JSONRPCErrorResponse } from '../types-DNKcmF0f.js';
|
|
2
2
|
|
|
3
3
|
type A2AStreamEventData = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
4
4
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as SendMessageResponse,
|
|
2
|
-
export {
|
|
1
|
+
import { S as SendMessageResponse, a as SendStreamingMessageResponse, G as GetTaskResponse, C as CancelTaskResponse, b as SetTaskPushNotificationConfigResponse, c as GetTaskPushNotificationConfigResponse, L as ListTaskPushNotificationConfigSuccessResponse, D as DeleteTaskPushNotificationConfigSuccessResponse, d as GetAuthenticatedExtendedCardSuccessResponse, J as JSONRPCErrorResponse } from './types-DNKcmF0f.cjs';
|
|
2
|
+
export { A as A2AError, e as A2ARequest, a9 as APIKeySecurityScheme, aa as AgentCapabilities, ae as AgentCapabilities1, ac as AgentCard, aD as AgentCard1, ap as AgentCardSignature, ab as AgentExtension, ad as AgentInterface, af as AgentProvider, ar as AgentProvider1, aq as AgentSkill, as as Artifact, aR as Artifact1, u as AuthenticatedExtendedCardNotConfiguredError, aj as AuthorizationCodeOAuthFlow, at as AuthorizationCodeOAuthFlow1, W as CancelTaskRequest, av as CancelTaskSuccessResponse, ak as ClientCredentialsOAuthFlow, aA as ClientCredentialsOAuthFlow1, s as ContentTypeNotSupportedError, N as DataPart, a7 as DeleteTaskPushNotificationConfigParams, aB as DeleteTaskPushNotificationConfigParams1, a6 as DeleteTaskPushNotificationConfigRequest, g as DeleteTaskPushNotificationConfigResponse, aC as FileBase, F as FilePart, H as FileWithBytes, K as FileWithUri, a8 as GetAuthenticatedExtendedCardRequest, h as GetAuthenticatedExtendedCardResponse, a1 as GetTaskPushNotificationConfigParams, $ as GetTaskPushNotificationConfigRequest, aE as GetTaskPushNotificationConfigSuccessResponse, R as GetTaskRequest, aG as GetTaskSuccessResponse, ag as HTTPAuthSecurityScheme, al as ImplicitOAuthFlow, aI as ImplicitOAuthFlow1, o as InternalError, t as InvalidAgentResponseError, n as InvalidParamsError, I as InvalidRequestError, l as JSONParseError, au as JSONRPCError, aJ as JSONRPCMessage, aK as JSONRPCRequest, i as JSONRPCResponse, aV as JSONRPCSuccessResponse, a5 as ListTaskPushNotificationConfigParams, aW as ListTaskPushNotificationConfigParams1, a4 as ListTaskPushNotificationConfigRequest, j as ListTaskPushNotificationConfigResponse, B as Message, ax as Message1, az as Message2, x as MessageSendConfiguration, aX as MessageSendConfiguration1, w as MessageSendParams, Q as MessageSendParams1, aY as MessageSendParams2, m as MethodNotFoundError, ao as MutualTLSSecurityScheme, M as MySchema, ah as OAuth2SecurityScheme, ai as OAuthFlows, aZ as OAuthFlows1, an as OpenIdConnectSecurityScheme, P as Part, a_ as PartBase, am as PasswordOAuthFlow, a$ as PasswordOAuthFlow1, z as PushNotificationAuthenticationInfo, b0 as PushNotificationAuthenticationInfo1, y as PushNotificationConfig, _ as PushNotificationConfig1, b1 as PushNotificationConfig2, r as PushNotificationNotSupportedError, f as SecurityScheme, b2 as SecuritySchemeBase, v as SendMessageRequest, aL as SendMessageSuccessResponse, O as SendStreamingMessageRequest, aN as SendStreamingMessageSuccessResponse, Y as SetTaskPushNotificationConfigRequest, aS as SetTaskPushNotificationConfigSuccessResponse, aw as Task, aH as Task1, aM as Task2, aQ as TaskArtifactUpdateEvent, X as TaskIdParams, a0 as TaskIdParams1, a3 as TaskIdParams2, q as TaskNotCancelableError, p as TaskNotFoundError, Z as TaskPushNotificationConfig, aF as TaskPushNotificationConfig1, aT as TaskPushNotificationConfig2, aU as TaskPushNotificationConfig3, V as TaskQueryParams, b3 as TaskQueryParams1, a2 as TaskResubscriptionRequest, T as TaskState, ay as TaskStatus, aP as TaskStatus1, b4 as TaskStatus2, aO as TaskStatusUpdateEvent, E as TextPart, k as TransportProtocol, U as UnsupportedOperationError } from './types-DNKcmF0f.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents any valid JSON-RPC response defined in the A2A protocol.
|
|
6
6
|
*/
|
|
7
|
-
type A2AResponse = SendMessageResponse | SendStreamingMessageResponse | GetTaskResponse | CancelTaskResponse | SetTaskPushNotificationConfigResponse | GetTaskPushNotificationConfigResponse | JSONRPCErrorResponse;
|
|
7
|
+
type A2AResponse = SendMessageResponse | SendStreamingMessageResponse | GetTaskResponse | CancelTaskResponse | SetTaskPushNotificationConfigResponse | GetTaskPushNotificationConfigResponse | ListTaskPushNotificationConfigSuccessResponse | DeleteTaskPushNotificationConfigSuccessResponse | GetAuthenticatedExtendedCardSuccessResponse | JSONRPCErrorResponse;
|
|
8
8
|
|
|
9
|
-
export { type A2AResponse, CancelTaskResponse, GetTaskPushNotificationConfigResponse, GetTaskResponse, JSONRPCErrorResponse, SendMessageResponse, SendStreamingMessageResponse, SetTaskPushNotificationConfigResponse };
|
|
9
|
+
export { type A2AResponse, CancelTaskResponse, DeleteTaskPushNotificationConfigSuccessResponse, GetAuthenticatedExtendedCardSuccessResponse, GetTaskPushNotificationConfigResponse, GetTaskResponse, JSONRPCErrorResponse, ListTaskPushNotificationConfigSuccessResponse, SendMessageResponse, SendStreamingMessageResponse, SetTaskPushNotificationConfigResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as SendMessageResponse,
|
|
2
|
-
export {
|
|
1
|
+
import { S as SendMessageResponse, a as SendStreamingMessageResponse, G as GetTaskResponse, C as CancelTaskResponse, b as SetTaskPushNotificationConfigResponse, c as GetTaskPushNotificationConfigResponse, L as ListTaskPushNotificationConfigSuccessResponse, D as DeleteTaskPushNotificationConfigSuccessResponse, d as GetAuthenticatedExtendedCardSuccessResponse, J as JSONRPCErrorResponse } from './types-DNKcmF0f.js';
|
|
2
|
+
export { A as A2AError, e as A2ARequest, a9 as APIKeySecurityScheme, aa as AgentCapabilities, ae as AgentCapabilities1, ac as AgentCard, aD as AgentCard1, ap as AgentCardSignature, ab as AgentExtension, ad as AgentInterface, af as AgentProvider, ar as AgentProvider1, aq as AgentSkill, as as Artifact, aR as Artifact1, u as AuthenticatedExtendedCardNotConfiguredError, aj as AuthorizationCodeOAuthFlow, at as AuthorizationCodeOAuthFlow1, W as CancelTaskRequest, av as CancelTaskSuccessResponse, ak as ClientCredentialsOAuthFlow, aA as ClientCredentialsOAuthFlow1, s as ContentTypeNotSupportedError, N as DataPart, a7 as DeleteTaskPushNotificationConfigParams, aB as DeleteTaskPushNotificationConfigParams1, a6 as DeleteTaskPushNotificationConfigRequest, g as DeleteTaskPushNotificationConfigResponse, aC as FileBase, F as FilePart, H as FileWithBytes, K as FileWithUri, a8 as GetAuthenticatedExtendedCardRequest, h as GetAuthenticatedExtendedCardResponse, a1 as GetTaskPushNotificationConfigParams, $ as GetTaskPushNotificationConfigRequest, aE as GetTaskPushNotificationConfigSuccessResponse, R as GetTaskRequest, aG as GetTaskSuccessResponse, ag as HTTPAuthSecurityScheme, al as ImplicitOAuthFlow, aI as ImplicitOAuthFlow1, o as InternalError, t as InvalidAgentResponseError, n as InvalidParamsError, I as InvalidRequestError, l as JSONParseError, au as JSONRPCError, aJ as JSONRPCMessage, aK as JSONRPCRequest, i as JSONRPCResponse, aV as JSONRPCSuccessResponse, a5 as ListTaskPushNotificationConfigParams, aW as ListTaskPushNotificationConfigParams1, a4 as ListTaskPushNotificationConfigRequest, j as ListTaskPushNotificationConfigResponse, B as Message, ax as Message1, az as Message2, x as MessageSendConfiguration, aX as MessageSendConfiguration1, w as MessageSendParams, Q as MessageSendParams1, aY as MessageSendParams2, m as MethodNotFoundError, ao as MutualTLSSecurityScheme, M as MySchema, ah as OAuth2SecurityScheme, ai as OAuthFlows, aZ as OAuthFlows1, an as OpenIdConnectSecurityScheme, P as Part, a_ as PartBase, am as PasswordOAuthFlow, a$ as PasswordOAuthFlow1, z as PushNotificationAuthenticationInfo, b0 as PushNotificationAuthenticationInfo1, y as PushNotificationConfig, _ as PushNotificationConfig1, b1 as PushNotificationConfig2, r as PushNotificationNotSupportedError, f as SecurityScheme, b2 as SecuritySchemeBase, v as SendMessageRequest, aL as SendMessageSuccessResponse, O as SendStreamingMessageRequest, aN as SendStreamingMessageSuccessResponse, Y as SetTaskPushNotificationConfigRequest, aS as SetTaskPushNotificationConfigSuccessResponse, aw as Task, aH as Task1, aM as Task2, aQ as TaskArtifactUpdateEvent, X as TaskIdParams, a0 as TaskIdParams1, a3 as TaskIdParams2, q as TaskNotCancelableError, p as TaskNotFoundError, Z as TaskPushNotificationConfig, aF as TaskPushNotificationConfig1, aT as TaskPushNotificationConfig2, aU as TaskPushNotificationConfig3, V as TaskQueryParams, b3 as TaskQueryParams1, a2 as TaskResubscriptionRequest, T as TaskState, ay as TaskStatus, aP as TaskStatus1, b4 as TaskStatus2, aO as TaskStatusUpdateEvent, E as TextPart, k as TransportProtocol, U as UnsupportedOperationError } from './types-DNKcmF0f.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents any valid JSON-RPC response defined in the A2A protocol.
|
|
6
6
|
*/
|
|
7
|
-
type A2AResponse = SendMessageResponse | SendStreamingMessageResponse | GetTaskResponse | CancelTaskResponse | SetTaskPushNotificationConfigResponse | GetTaskPushNotificationConfigResponse | JSONRPCErrorResponse;
|
|
7
|
+
type A2AResponse = SendMessageResponse | SendStreamingMessageResponse | GetTaskResponse | CancelTaskResponse | SetTaskPushNotificationConfigResponse | GetTaskPushNotificationConfigResponse | ListTaskPushNotificationConfigSuccessResponse | DeleteTaskPushNotificationConfigSuccessResponse | GetAuthenticatedExtendedCardSuccessResponse | JSONRPCErrorResponse;
|
|
8
8
|
|
|
9
|
-
export { type A2AResponse, CancelTaskResponse, GetTaskPushNotificationConfigResponse, GetTaskResponse, JSONRPCErrorResponse, SendMessageResponse, SendStreamingMessageResponse, SetTaskPushNotificationConfigResponse };
|
|
9
|
+
export { type A2AResponse, CancelTaskResponse, DeleteTaskPushNotificationConfigSuccessResponse, GetAuthenticatedExtendedCardSuccessResponse, GetTaskPushNotificationConfigResponse, GetTaskResponse, JSONRPCErrorResponse, ListTaskPushNotificationConfigSuccessResponse, SendMessageResponse, SendStreamingMessageResponse, SetTaskPushNotificationConfigResponse };
|
package/dist/server/index.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,21 +14,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/server/index.ts
|
|
30
20
|
var server_exports = {};
|
|
31
21
|
__export(server_exports, {
|
|
32
22
|
A2AError: () => A2AError,
|
|
33
|
-
A2AExpressApp: () => A2AExpressApp,
|
|
34
23
|
DefaultExecutionEventBus: () => DefaultExecutionEventBus,
|
|
35
24
|
DefaultExecutionEventBusManager: () => DefaultExecutionEventBusManager,
|
|
36
25
|
DefaultRequestHandler: () => DefaultRequestHandler,
|
|
@@ -241,6 +230,12 @@ var A2AError = class _A2AError extends Error {
|
|
|
241
230
|
`Unsupported operation: ${operation}`
|
|
242
231
|
);
|
|
243
232
|
}
|
|
233
|
+
static authenticatedExtendedCardNotConfigured() {
|
|
234
|
+
return new _A2AError(
|
|
235
|
+
-32007,
|
|
236
|
+
`Extended card not configured.`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
244
239
|
};
|
|
245
240
|
|
|
246
241
|
// src/server/result_manager.ts
|
|
@@ -375,20 +370,28 @@ var ResultManager = class {
|
|
|
375
370
|
var terminalStates = ["completed", "failed", "canceled", "rejected"];
|
|
376
371
|
var DefaultRequestHandler = class {
|
|
377
372
|
agentCard;
|
|
373
|
+
extendedAgentCard;
|
|
378
374
|
taskStore;
|
|
379
375
|
agentExecutor;
|
|
380
376
|
eventBusManager;
|
|
381
377
|
// Store for push notification configurations (could be part of TaskStore or separate)
|
|
382
378
|
pushNotificationConfigs = /* @__PURE__ */ new Map();
|
|
383
|
-
constructor(agentCard, taskStore, agentExecutor, eventBusManager = new DefaultExecutionEventBusManager()) {
|
|
379
|
+
constructor(agentCard, taskStore, agentExecutor, eventBusManager = new DefaultExecutionEventBusManager(), extendedAgentCard) {
|
|
384
380
|
this.agentCard = agentCard;
|
|
385
381
|
this.taskStore = taskStore;
|
|
386
382
|
this.agentExecutor = agentExecutor;
|
|
387
383
|
this.eventBusManager = eventBusManager;
|
|
384
|
+
this.extendedAgentCard = extendedAgentCard;
|
|
388
385
|
}
|
|
389
386
|
async getAgentCard() {
|
|
390
387
|
return this.agentCard;
|
|
391
388
|
}
|
|
389
|
+
async getAuthenticatedExtendedAgentCard() {
|
|
390
|
+
if (!this.extendedAgentCard) {
|
|
391
|
+
throw A2AError.authenticatedExtendedCardNotConfigured();
|
|
392
|
+
}
|
|
393
|
+
return this.extendedAgentCard;
|
|
394
|
+
}
|
|
392
395
|
async _createRequestContext(incomingMessage, taskId, isStream) {
|
|
393
396
|
let task;
|
|
394
397
|
let referenceTasks;
|
|
@@ -611,27 +614,78 @@ var DefaultRequestHandler = class {
|
|
|
611
614
|
if (!this.agentCard.capabilities.pushNotifications) {
|
|
612
615
|
throw A2AError.pushNotificationNotSupported();
|
|
613
616
|
}
|
|
614
|
-
const
|
|
615
|
-
if (!
|
|
617
|
+
const task = await this.taskStore.load(params.taskId);
|
|
618
|
+
if (!task) {
|
|
616
619
|
throw A2AError.taskNotFound(params.taskId);
|
|
617
620
|
}
|
|
618
|
-
|
|
621
|
+
const { taskId, pushNotificationConfig } = params;
|
|
622
|
+
if (!pushNotificationConfig.id) {
|
|
623
|
+
pushNotificationConfig.id = taskId;
|
|
624
|
+
}
|
|
625
|
+
const configs = this.pushNotificationConfigs.get(taskId) || [];
|
|
626
|
+
const updatedConfigs = configs.filter((c) => c.id !== pushNotificationConfig.id);
|
|
627
|
+
updatedConfigs.push(pushNotificationConfig);
|
|
628
|
+
this.pushNotificationConfigs.set(taskId, updatedConfigs);
|
|
619
629
|
return params;
|
|
620
630
|
}
|
|
621
631
|
async getTaskPushNotificationConfig(params) {
|
|
622
632
|
if (!this.agentCard.capabilities.pushNotifications) {
|
|
623
633
|
throw A2AError.pushNotificationNotSupported();
|
|
624
634
|
}
|
|
625
|
-
const
|
|
626
|
-
if (!
|
|
635
|
+
const task = await this.taskStore.load(params.id);
|
|
636
|
+
if (!task) {
|
|
627
637
|
throw A2AError.taskNotFound(params.id);
|
|
628
638
|
}
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
639
|
+
const configs = this.pushNotificationConfigs.get(params.id) || [];
|
|
640
|
+
if (configs.length === 0) {
|
|
631
641
|
throw A2AError.internalError(`Push notification config not found for task ${params.id}.`);
|
|
632
642
|
}
|
|
643
|
+
let configId;
|
|
644
|
+
if ("pushNotificationConfigId" in params && params.pushNotificationConfigId) {
|
|
645
|
+
configId = params.pushNotificationConfigId;
|
|
646
|
+
} else {
|
|
647
|
+
configId = params.id;
|
|
648
|
+
}
|
|
649
|
+
const config = configs.find((c) => c.id === configId);
|
|
650
|
+
if (!config) {
|
|
651
|
+
throw A2AError.internalError(`Push notification config with id '${configId}' not found for task ${params.id}.`);
|
|
652
|
+
}
|
|
633
653
|
return { taskId: params.id, pushNotificationConfig: config };
|
|
634
654
|
}
|
|
655
|
+
async listTaskPushNotificationConfigs(params) {
|
|
656
|
+
if (!this.agentCard.capabilities.pushNotifications) {
|
|
657
|
+
throw A2AError.pushNotificationNotSupported();
|
|
658
|
+
}
|
|
659
|
+
const task = await this.taskStore.load(params.id);
|
|
660
|
+
if (!task) {
|
|
661
|
+
throw A2AError.taskNotFound(params.id);
|
|
662
|
+
}
|
|
663
|
+
const configs = this.pushNotificationConfigs.get(params.id) || [];
|
|
664
|
+
return configs.map((config) => ({
|
|
665
|
+
taskId: params.id,
|
|
666
|
+
pushNotificationConfig: config
|
|
667
|
+
}));
|
|
668
|
+
}
|
|
669
|
+
async deleteTaskPushNotificationConfig(params) {
|
|
670
|
+
if (!this.agentCard.capabilities.pushNotifications) {
|
|
671
|
+
throw A2AError.pushNotificationNotSupported();
|
|
672
|
+
}
|
|
673
|
+
const task = await this.taskStore.load(params.id);
|
|
674
|
+
if (!task) {
|
|
675
|
+
throw A2AError.taskNotFound(params.id);
|
|
676
|
+
}
|
|
677
|
+
const { id: taskId, pushNotificationConfigId } = params;
|
|
678
|
+
const configs = this.pushNotificationConfigs.get(taskId);
|
|
679
|
+
if (!configs) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const updatedConfigs = configs.filter((c) => c.id !== pushNotificationConfigId);
|
|
683
|
+
if (updatedConfigs.length === 0) {
|
|
684
|
+
this.pushNotificationConfigs.delete(taskId);
|
|
685
|
+
} else if (updatedConfigs.length < configs.length) {
|
|
686
|
+
this.pushNotificationConfigs.set(taskId, updatedConfigs);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
635
689
|
async *resubscribe(params) {
|
|
636
690
|
if (!this.agentCard.capabilities.streaming) {
|
|
637
691
|
throw A2AError.unsupportedOperation("Streaming (and thus resubscription) is not supported.");
|
|
@@ -713,9 +767,21 @@ var JsonRpcTransportHandler = class {
|
|
|
713
767
|
error: a2aError.toJSONRPCError()
|
|
714
768
|
};
|
|
715
769
|
}
|
|
716
|
-
const { method,
|
|
770
|
+
const { method, id: requestId = null } = rpcRequest;
|
|
717
771
|
try {
|
|
772
|
+
if (method === "agent/getAuthenticatedExtendedCard") {
|
|
773
|
+
const result = await this.requestHandler.getAuthenticatedExtendedAgentCard();
|
|
774
|
+
return {
|
|
775
|
+
jsonrpc: "2.0",
|
|
776
|
+
id: requestId,
|
|
777
|
+
result
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
if (!rpcRequest.params) {
|
|
781
|
+
throw A2AError.invalidParams(`'params' is required for '${method}'`);
|
|
782
|
+
}
|
|
718
783
|
if (method === "message/stream" || method === "tasks/resubscribe") {
|
|
784
|
+
const params = rpcRequest.params;
|
|
719
785
|
const agentCard = await this.requestHandler.getAgentCard();
|
|
720
786
|
if (!agentCard.capabilities.streaming) {
|
|
721
787
|
throw A2AError.unsupportedOperation(`Method ${method} requires streaming capability.`);
|
|
@@ -740,22 +806,33 @@ var JsonRpcTransportHandler = class {
|
|
|
740
806
|
let result;
|
|
741
807
|
switch (method) {
|
|
742
808
|
case "message/send":
|
|
743
|
-
result = await this.requestHandler.sendMessage(params);
|
|
809
|
+
result = await this.requestHandler.sendMessage(rpcRequest.params);
|
|
744
810
|
break;
|
|
745
811
|
case "tasks/get":
|
|
746
|
-
result = await this.requestHandler.getTask(params);
|
|
812
|
+
result = await this.requestHandler.getTask(rpcRequest.params);
|
|
747
813
|
break;
|
|
748
814
|
case "tasks/cancel":
|
|
749
|
-
result = await this.requestHandler.cancelTask(params);
|
|
815
|
+
result = await this.requestHandler.cancelTask(rpcRequest.params);
|
|
750
816
|
break;
|
|
751
817
|
case "tasks/pushNotificationConfig/set":
|
|
752
818
|
result = await this.requestHandler.setTaskPushNotificationConfig(
|
|
753
|
-
params
|
|
819
|
+
rpcRequest.params
|
|
754
820
|
);
|
|
755
821
|
break;
|
|
756
822
|
case "tasks/pushNotificationConfig/get":
|
|
757
823
|
result = await this.requestHandler.getTaskPushNotificationConfig(
|
|
758
|
-
params
|
|
824
|
+
rpcRequest.params
|
|
825
|
+
);
|
|
826
|
+
break;
|
|
827
|
+
case "tasks/pushNotificationConfig/delete":
|
|
828
|
+
await this.requestHandler.deleteTaskPushNotificationConfig(
|
|
829
|
+
rpcRequest.params
|
|
830
|
+
);
|
|
831
|
+
result = null;
|
|
832
|
+
break;
|
|
833
|
+
case "tasks/pushNotificationConfig/list":
|
|
834
|
+
result = await this.requestHandler.listTaskPushNotificationConfigs(
|
|
835
|
+
rpcRequest.params
|
|
759
836
|
);
|
|
760
837
|
break;
|
|
761
838
|
default:
|
|
@@ -777,105 +854,9 @@ var JsonRpcTransportHandler = class {
|
|
|
777
854
|
}
|
|
778
855
|
}
|
|
779
856
|
};
|
|
780
|
-
|
|
781
|
-
// src/server/a2a_express_app.ts
|
|
782
|
-
var import_express = __toESM(require("express"), 1);
|
|
783
|
-
var A2AExpressApp = class {
|
|
784
|
-
requestHandler;
|
|
785
|
-
// Kept for getAgentCard
|
|
786
|
-
jsonRpcTransportHandler;
|
|
787
|
-
constructor(requestHandler) {
|
|
788
|
-
this.requestHandler = requestHandler;
|
|
789
|
-
this.jsonRpcTransportHandler = new JsonRpcTransportHandler(requestHandler);
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Adds A2A routes to an existing Express app.
|
|
793
|
-
* @param app Optional existing Express app.
|
|
794
|
-
* @param baseUrl The base URL for A2A endpoints (e.g., "/a2a/api").
|
|
795
|
-
* @param middlewares Optional array of Express middlewares to apply to the A2A routes.
|
|
796
|
-
* @returns The Express app with A2A routes.
|
|
797
|
-
*/
|
|
798
|
-
setupRoutes(app, baseUrl = "", middlewares) {
|
|
799
|
-
const router = import_express.default.Router();
|
|
800
|
-
router.use(import_express.default.json(), ...middlewares ?? []);
|
|
801
|
-
router.get("/.well-known/agent.json", async (req, res) => {
|
|
802
|
-
try {
|
|
803
|
-
const agentCard = await this.requestHandler.getAgentCard();
|
|
804
|
-
res.json(agentCard);
|
|
805
|
-
} catch (error) {
|
|
806
|
-
console.error("Error fetching agent card:", error);
|
|
807
|
-
res.status(500).json({ error: "Failed to retrieve agent card" });
|
|
808
|
-
}
|
|
809
|
-
});
|
|
810
|
-
router.post("/", async (req, res) => {
|
|
811
|
-
try {
|
|
812
|
-
const rpcResponseOrStream = await this.jsonRpcTransportHandler.handle(req.body);
|
|
813
|
-
if (typeof rpcResponseOrStream?.[Symbol.asyncIterator] === "function") {
|
|
814
|
-
const stream = rpcResponseOrStream;
|
|
815
|
-
res.setHeader("Content-Type", "text/event-stream");
|
|
816
|
-
res.setHeader("Cache-Control", "no-cache");
|
|
817
|
-
res.setHeader("Connection", "keep-alive");
|
|
818
|
-
res.flushHeaders();
|
|
819
|
-
try {
|
|
820
|
-
for await (const event of stream) {
|
|
821
|
-
res.write(`id: ${(/* @__PURE__ */ new Date()).getTime()}
|
|
822
|
-
`);
|
|
823
|
-
res.write(`data: ${JSON.stringify(event)}
|
|
824
|
-
|
|
825
|
-
`);
|
|
826
|
-
}
|
|
827
|
-
} catch (streamError) {
|
|
828
|
-
console.error(`Error during SSE streaming (request ${req.body?.id}):`, streamError);
|
|
829
|
-
const a2aError = streamError instanceof A2AError ? streamError : A2AError.internalError(streamError.message || "Streaming error.");
|
|
830
|
-
const errorResponse = {
|
|
831
|
-
jsonrpc: "2.0",
|
|
832
|
-
id: req.body?.id || null,
|
|
833
|
-
// Use original request ID if available
|
|
834
|
-
error: a2aError.toJSONRPCError()
|
|
835
|
-
};
|
|
836
|
-
if (!res.headersSent) {
|
|
837
|
-
res.status(500).json(errorResponse);
|
|
838
|
-
} else {
|
|
839
|
-
res.write(`id: ${(/* @__PURE__ */ new Date()).getTime()}
|
|
840
|
-
`);
|
|
841
|
-
res.write(`event: error
|
|
842
|
-
`);
|
|
843
|
-
res.write(`data: ${JSON.stringify(errorResponse)}
|
|
844
|
-
|
|
845
|
-
`);
|
|
846
|
-
}
|
|
847
|
-
} finally {
|
|
848
|
-
if (!res.writableEnded) {
|
|
849
|
-
res.end();
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
} else {
|
|
853
|
-
const rpcResponse = rpcResponseOrStream;
|
|
854
|
-
res.status(200).json(rpcResponse);
|
|
855
|
-
}
|
|
856
|
-
} catch (error) {
|
|
857
|
-
console.error("Unhandled error in A2AExpressApp POST handler:", error);
|
|
858
|
-
const a2aError = error instanceof A2AError ? error : A2AError.internalError("General processing error.");
|
|
859
|
-
const errorResponse = {
|
|
860
|
-
jsonrpc: "2.0",
|
|
861
|
-
id: req.body?.id || null,
|
|
862
|
-
error: a2aError.toJSONRPCError()
|
|
863
|
-
};
|
|
864
|
-
if (!res.headersSent) {
|
|
865
|
-
res.status(500).json(errorResponse);
|
|
866
|
-
} else if (!res.writableEnded) {
|
|
867
|
-
res.end();
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
});
|
|
871
|
-
app.use(baseUrl, router);
|
|
872
|
-
return app;
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
857
|
// Annotate the CommonJS export names for ESM import in node:
|
|
876
858
|
0 && (module.exports = {
|
|
877
859
|
A2AError,
|
|
878
|
-
A2AExpressApp,
|
|
879
860
|
DefaultExecutionEventBus,
|
|
880
861
|
DefaultExecutionEventBusManager,
|
|
881
862
|
DefaultRequestHandler,
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import {
|
|
3
|
-
import { A2AResponse } from '../index.cjs';
|
|
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.cjs';
|
|
5
3
|
|
|
6
4
|
type AgentExecutionEvent = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
7
5
|
interface ExecutionEventBus {
|
|
@@ -97,12 +95,15 @@ declare class ExecutionEventQueue {
|
|
|
97
95
|
|
|
98
96
|
interface A2ARequestHandler {
|
|
99
97
|
getAgentCard(): Promise<AgentCard>;
|
|
98
|
+
getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
|
|
100
99
|
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
101
100
|
sendMessageStream(params: MessageSendParams): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
102
101
|
getTask(params: TaskQueryParams): Promise<Task>;
|
|
103
102
|
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
104
103
|
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
105
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
104
|
+
getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
|
|
105
|
+
listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
|
|
106
|
+
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
|
|
106
107
|
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -133,12 +134,14 @@ declare class InMemoryTaskStore implements TaskStore {
|
|
|
133
134
|
|
|
134
135
|
declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
135
136
|
private readonly agentCard;
|
|
137
|
+
private readonly extendedAgentCard?;
|
|
136
138
|
private readonly taskStore;
|
|
137
139
|
private readonly agentExecutor;
|
|
138
140
|
private readonly eventBusManager;
|
|
139
141
|
private readonly pushNotificationConfigs;
|
|
140
|
-
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager);
|
|
142
|
+
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, extendedAgentCard?: AgentCard);
|
|
141
143
|
getAgentCard(): Promise<AgentCard>;
|
|
144
|
+
getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
|
|
142
145
|
private _createRequestContext;
|
|
143
146
|
private _processEvents;
|
|
144
147
|
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
@@ -146,7 +149,9 @@ declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
|
146
149
|
getTask(params: TaskQueryParams): Promise<Task>;
|
|
147
150
|
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
148
151
|
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
149
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
152
|
+
getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
|
|
153
|
+
listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
|
|
154
|
+
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
|
|
150
155
|
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
151
156
|
}
|
|
152
157
|
|
|
@@ -188,21 +193,7 @@ declare class JsonRpcTransportHandler {
|
|
|
188
193
|
* For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
|
|
189
194
|
* For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
|
|
190
195
|
*/
|
|
191
|
-
handle(requestBody: any): Promise<
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
declare class A2AExpressApp {
|
|
195
|
-
private requestHandler;
|
|
196
|
-
private jsonRpcTransportHandler;
|
|
197
|
-
constructor(requestHandler: A2ARequestHandler);
|
|
198
|
-
/**
|
|
199
|
-
* Adds A2A routes to an existing Express app.
|
|
200
|
-
* @param app Optional existing Express app.
|
|
201
|
-
* @param baseUrl The base URL for A2A endpoints (e.g., "/a2a/api").
|
|
202
|
-
* @param middlewares Optional array of Express middlewares to apply to the A2A routes.
|
|
203
|
-
* @returns The Express app with A2A routes.
|
|
204
|
-
*/
|
|
205
|
-
setupRoutes(app: Express, baseUrl?: string, middlewares?: Array<RequestHandler | ErrorRequestHandler>): Express;
|
|
196
|
+
handle(requestBody: any): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
|
|
206
197
|
}
|
|
207
198
|
|
|
208
199
|
/**
|
|
@@ -226,6 +217,7 @@ declare class A2AError extends Error {
|
|
|
226
217
|
static taskNotCancelable(taskId: string): A2AError;
|
|
227
218
|
static pushNotificationNotSupported(): A2AError;
|
|
228
219
|
static unsupportedOperation(operation: string): A2AError;
|
|
220
|
+
static authenticatedExtendedCardNotConfigured(): A2AError;
|
|
229
221
|
}
|
|
230
222
|
|
|
231
|
-
export { A2AError,
|
|
223
|
+
export { A2AError, type A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, InMemoryTaskStore, JsonRpcTransportHandler, RequestContext, ResultManager, type TaskStore };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import {
|
|
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 {
|
|
@@ -97,12 +95,15 @@ declare class ExecutionEventQueue {
|
|
|
97
95
|
|
|
98
96
|
interface A2ARequestHandler {
|
|
99
97
|
getAgentCard(): Promise<AgentCard>;
|
|
98
|
+
getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
|
|
100
99
|
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
101
100
|
sendMessageStream(params: MessageSendParams): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
102
101
|
getTask(params: TaskQueryParams): Promise<Task>;
|
|
103
102
|
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
104
103
|
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
105
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
104
|
+
getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
|
|
105
|
+
listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
|
|
106
|
+
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
|
|
106
107
|
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -133,12 +134,14 @@ declare class InMemoryTaskStore implements TaskStore {
|
|
|
133
134
|
|
|
134
135
|
declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
135
136
|
private readonly agentCard;
|
|
137
|
+
private readonly extendedAgentCard?;
|
|
136
138
|
private readonly taskStore;
|
|
137
139
|
private readonly agentExecutor;
|
|
138
140
|
private readonly eventBusManager;
|
|
139
141
|
private readonly pushNotificationConfigs;
|
|
140
|
-
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager);
|
|
142
|
+
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, extendedAgentCard?: AgentCard);
|
|
141
143
|
getAgentCard(): Promise<AgentCard>;
|
|
144
|
+
getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
|
|
142
145
|
private _createRequestContext;
|
|
143
146
|
private _processEvents;
|
|
144
147
|
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
@@ -146,7 +149,9 @@ declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
|
146
149
|
getTask(params: TaskQueryParams): Promise<Task>;
|
|
147
150
|
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
148
151
|
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
149
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
152
|
+
getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
|
|
153
|
+
listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
|
|
154
|
+
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
|
|
150
155
|
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
151
156
|
}
|
|
152
157
|
|
|
@@ -188,21 +193,7 @@ declare class JsonRpcTransportHandler {
|
|
|
188
193
|
* For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
|
|
189
194
|
* For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
|
|
190
195
|
*/
|
|
191
|
-
handle(requestBody: any): Promise<
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
declare class A2AExpressApp {
|
|
195
|
-
private requestHandler;
|
|
196
|
-
private jsonRpcTransportHandler;
|
|
197
|
-
constructor(requestHandler: A2ARequestHandler);
|
|
198
|
-
/**
|
|
199
|
-
* Adds A2A routes to an existing Express app.
|
|
200
|
-
* @param app Optional existing Express app.
|
|
201
|
-
* @param baseUrl The base URL for A2A endpoints (e.g., "/a2a/api").
|
|
202
|
-
* @param middlewares Optional array of Express middlewares to apply to the A2A routes.
|
|
203
|
-
* @returns The Express app with A2A routes.
|
|
204
|
-
*/
|
|
205
|
-
setupRoutes(app: Express, baseUrl?: string, middlewares?: Array<RequestHandler | ErrorRequestHandler>): Express;
|
|
196
|
+
handle(requestBody: any): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
|
|
206
197
|
}
|
|
207
198
|
|
|
208
199
|
/**
|
|
@@ -226,6 +217,7 @@ declare class A2AError extends Error {
|
|
|
226
217
|
static taskNotCancelable(taskId: string): A2AError;
|
|
227
218
|
static pushNotificationNotSupported(): A2AError;
|
|
228
219
|
static unsupportedOperation(operation: string): A2AError;
|
|
220
|
+
static authenticatedExtendedCardNotConfigured(): A2AError;
|
|
229
221
|
}
|
|
230
222
|
|
|
231
|
-
export { A2AError,
|
|
223
|
+
export { A2AError, type A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, InMemoryTaskStore, JsonRpcTransportHandler, RequestContext, ResultManager, type TaskStore };
|