@a2a-js/sdk 0.2.5 → 0.3.1
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 +15 -1
- package/dist/a2a_request_handler-B5t-IxgA.d.ts +17 -0
- package/dist/a2a_request_handler-DUvKWfix.d.cts +17 -0
- package/dist/chunk-JA52GYRU.js +207 -0
- 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/express/index.cjs +338 -0
- package/dist/server/express/index.d.cts +19 -0
- package/dist/server/express/index.d.ts +19 -0
- package/dist/server/express/index.js +102 -0
- package/dist/server/index.cjs +102 -121
- package/dist/server/index.d.cts +11 -32
- package/dist/server/index.d.ts +11 -32
- package/dist/server/index.js +72 -278
- package/dist/types-DNKcmF0f.d.cts +2562 -0
- package/dist/types-DNKcmF0f.d.ts +2562 -0
- package/package.json +20 -7
- package/dist/types-CcBgkR2G.d.cts +0 -2048
- package/dist/types-CcBgkR2G.d.ts +0 -2048
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,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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';
|
|
3
|
+
import { A as A2ARequestHandler } from '../a2a_request_handler-DUvKWfix.cjs';
|
|
5
4
|
|
|
6
5
|
type AgentExecutionEvent = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
7
6
|
interface ExecutionEventBus {
|
|
@@ -95,17 +94,6 @@ declare class ExecutionEventQueue {
|
|
|
95
94
|
stop(): void;
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
interface A2ARequestHandler {
|
|
99
|
-
getAgentCard(): Promise<AgentCard>;
|
|
100
|
-
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
101
|
-
sendMessageStream(params: MessageSendParams): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
102
|
-
getTask(params: TaskQueryParams): Promise<Task>;
|
|
103
|
-
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
104
|
-
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
105
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
106
|
-
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
97
|
/**
|
|
110
98
|
* Simplified interface for task storage providers.
|
|
111
99
|
* Stores and retrieves the task.
|
|
@@ -133,12 +121,14 @@ declare class InMemoryTaskStore implements TaskStore {
|
|
|
133
121
|
|
|
134
122
|
declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
135
123
|
private readonly agentCard;
|
|
124
|
+
private readonly extendedAgentCard?;
|
|
136
125
|
private readonly taskStore;
|
|
137
126
|
private readonly agentExecutor;
|
|
138
127
|
private readonly eventBusManager;
|
|
139
128
|
private readonly pushNotificationConfigs;
|
|
140
|
-
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager);
|
|
129
|
+
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, extendedAgentCard?: AgentCard);
|
|
141
130
|
getAgentCard(): Promise<AgentCard>;
|
|
131
|
+
getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
|
|
142
132
|
private _createRequestContext;
|
|
143
133
|
private _processEvents;
|
|
144
134
|
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
@@ -146,7 +136,9 @@ declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
|
146
136
|
getTask(params: TaskQueryParams): Promise<Task>;
|
|
147
137
|
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
148
138
|
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
149
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
139
|
+
getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
|
|
140
|
+
listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
|
|
141
|
+
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
|
|
150
142
|
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
151
143
|
}
|
|
152
144
|
|
|
@@ -188,21 +180,7 @@ declare class JsonRpcTransportHandler {
|
|
|
188
180
|
* For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
|
|
189
181
|
* For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
|
|
190
182
|
*/
|
|
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;
|
|
183
|
+
handle(requestBody: any): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
|
|
206
184
|
}
|
|
207
185
|
|
|
208
186
|
/**
|
|
@@ -226,6 +204,7 @@ declare class A2AError extends Error {
|
|
|
226
204
|
static taskNotCancelable(taskId: string): A2AError;
|
|
227
205
|
static pushNotificationNotSupported(): A2AError;
|
|
228
206
|
static unsupportedOperation(operation: string): A2AError;
|
|
207
|
+
static authenticatedExtendedCardNotConfigured(): A2AError;
|
|
229
208
|
}
|
|
230
209
|
|
|
231
|
-
export { A2AError,
|
|
210
|
+
export { A2AError, 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,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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';
|
|
3
|
+
import { A as A2ARequestHandler } from '../a2a_request_handler-B5t-IxgA.js';
|
|
5
4
|
|
|
6
5
|
type AgentExecutionEvent = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
7
6
|
interface ExecutionEventBus {
|
|
@@ -95,17 +94,6 @@ declare class ExecutionEventQueue {
|
|
|
95
94
|
stop(): void;
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
interface A2ARequestHandler {
|
|
99
|
-
getAgentCard(): Promise<AgentCard>;
|
|
100
|
-
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
101
|
-
sendMessageStream(params: MessageSendParams): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
102
|
-
getTask(params: TaskQueryParams): Promise<Task>;
|
|
103
|
-
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
104
|
-
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
105
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
106
|
-
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
97
|
/**
|
|
110
98
|
* Simplified interface for task storage providers.
|
|
111
99
|
* Stores and retrieves the task.
|
|
@@ -133,12 +121,14 @@ declare class InMemoryTaskStore implements TaskStore {
|
|
|
133
121
|
|
|
134
122
|
declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
135
123
|
private readonly agentCard;
|
|
124
|
+
private readonly extendedAgentCard?;
|
|
136
125
|
private readonly taskStore;
|
|
137
126
|
private readonly agentExecutor;
|
|
138
127
|
private readonly eventBusManager;
|
|
139
128
|
private readonly pushNotificationConfigs;
|
|
140
|
-
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager);
|
|
129
|
+
constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, extendedAgentCard?: AgentCard);
|
|
141
130
|
getAgentCard(): Promise<AgentCard>;
|
|
131
|
+
getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
|
|
142
132
|
private _createRequestContext;
|
|
143
133
|
private _processEvents;
|
|
144
134
|
sendMessage(params: MessageSendParams): Promise<Message | Task>;
|
|
@@ -146,7 +136,9 @@ declare class DefaultRequestHandler implements A2ARequestHandler {
|
|
|
146
136
|
getTask(params: TaskQueryParams): Promise<Task>;
|
|
147
137
|
cancelTask(params: TaskIdParams): Promise<Task>;
|
|
148
138
|
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
|
|
149
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<TaskPushNotificationConfig>;
|
|
139
|
+
getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
|
|
140
|
+
listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
|
|
141
|
+
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
|
|
150
142
|
resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
|
|
151
143
|
}
|
|
152
144
|
|
|
@@ -188,21 +180,7 @@ declare class JsonRpcTransportHandler {
|
|
|
188
180
|
* For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
|
|
189
181
|
* For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
|
|
190
182
|
*/
|
|
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;
|
|
183
|
+
handle(requestBody: any): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
|
|
206
184
|
}
|
|
207
185
|
|
|
208
186
|
/**
|
|
@@ -226,6 +204,7 @@ declare class A2AError extends Error {
|
|
|
226
204
|
static taskNotCancelable(taskId: string): A2AError;
|
|
227
205
|
static pushNotificationNotSupported(): A2AError;
|
|
228
206
|
static unsupportedOperation(operation: string): A2AError;
|
|
207
|
+
static authenticatedExtendedCardNotConfigured(): A2AError;
|
|
229
208
|
}
|
|
230
209
|
|
|
231
|
-
export { A2AError,
|
|
210
|
+
export { A2AError, A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, InMemoryTaskStore, JsonRpcTransportHandler, RequestContext, ResultManager, type TaskStore };
|