@dexto/server 1.6.20 → 1.6.22
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/dist/a2a/jsonrpc/methods.cjs +1 -1
- package/dist/a2a/jsonrpc/methods.d.ts +14 -4
- package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
- package/dist/a2a/jsonrpc/methods.js +1 -1
- package/dist/approval/wire-approval-events.cjs +44 -0
- package/dist/approval/wire-approval-events.d.ts +4 -0
- package/dist/approval/wire-approval-events.d.ts.map +1 -0
- package/dist/approval/wire-approval-events.js +20 -0
- package/dist/events/session-sse-subscriber.cjs +167 -0
- package/dist/events/session-sse-subscriber.d.ts +13 -0
- package/dist/events/session-sse-subscriber.d.ts.map +1 -0
- package/dist/events/session-sse-subscriber.js +143 -0
- package/dist/hono/__tests__/test-fixtures.cjs +8 -0
- package/dist/hono/__tests__/test-fixtures.d.ts +1 -0
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +8 -0
- package/dist/hono/index.cjs +40 -8
- package/dist/hono/index.d.ts +45 -4531
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +43 -9
- package/dist/hono/node/index.cjs +51 -6
- package/dist/hono/node/index.d.ts.map +1 -1
- package/dist/hono/node/index.js +51 -6
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +158 -32
- package/dist/hono/routes/a2a-tasks.d.ts +1 -502
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +162 -32
- package/dist/hono/routes/a2a.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +410 -329
- package/dist/hono/routes/agents.d.ts +16043 -68
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +102 -88
- package/dist/hono/routes/approvals.d.ts +2089 -142
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -89
- package/dist/hono/routes/dexto-auth.cjs +40 -33
- package/dist/hono/routes/dexto-auth.d.ts +401 -2
- package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
- package/dist/hono/routes/dexto-auth.js +40 -33
- package/dist/hono/routes/discovery.cjs +16 -14
- package/dist/hono/routes/discovery.d.ts +586 -1
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +16 -14
- package/dist/hono/routes/greeting.cjs +26 -22
- package/dist/hono/routes/greeting.d.ts +787 -3
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +26 -22
- package/dist/hono/routes/health.d.ts +1 -1
- package/dist/hono/routes/key.cjs +60 -52
- package/dist/hono/routes/key.d.ts +1597 -1
- package/dist/hono/routes/key.d.ts.map +1 -1
- package/dist/hono/routes/key.js +60 -52
- package/dist/hono/routes/llm.cjs +382 -349
- package/dist/hono/routes/llm.d.ts +12148 -98
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +386 -349
- package/dist/hono/routes/mcp.cjs +257 -226
- package/dist/hono/routes/mcp.d.ts +6605 -309
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +263 -225
- package/dist/hono/routes/memory.cjs +102 -89
- package/dist/hono/routes/memory.d.ts +5368 -4
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +108 -90
- package/dist/hono/routes/messages.cjs +189 -191
- package/dist/hono/routes/messages.d.ts +3900 -12
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +192 -191
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2875 -2
- package/dist/hono/routes/models.d.ts.map +1 -1
- package/dist/hono/routes/models.js +108 -64
- package/dist/hono/routes/openrouter.cjs +79 -65
- package/dist/hono/routes/openrouter.d.ts +854 -1
- package/dist/hono/routes/openrouter.d.ts.map +1 -1
- package/dist/hono/routes/openrouter.js +79 -65
- package/dist/hono/routes/prompts.cjs +136 -109
- package/dist/hono/routes/prompts.d.ts +2818 -10
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +138 -109
- package/dist/hono/routes/queue.cjs +133 -120
- package/dist/hono/routes/queue.d.ts +5240 -11
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +136 -120
- package/dist/hono/routes/resources.cjs +65 -46
- package/dist/hono/routes/resources.d.ts +1983 -5
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +72 -47
- package/dist/hono/routes/schedules.cjs +233 -226
- package/dist/hono/routes/schedules.d.ts +4198 -22
- package/dist/hono/routes/schedules.d.ts.map +1 -1
- package/dist/hono/routes/schedules.js +233 -226
- package/dist/hono/routes/search.cjs +34 -30
- package/dist/hono/routes/search.d.ts +3094 -17
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +491 -393
- package/dist/hono/routes/sessions.d.ts +18263 -65
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +497 -395
- package/dist/hono/routes/static.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.cjs +57 -61
- package/dist/hono/routes/system-prompt.d.ts +1228 -2
- package/dist/hono/routes/system-prompt.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.js +58 -62
- package/dist/hono/routes/tools.cjs +29 -34
- package/dist/hono/routes/tools.d.ts +1755 -6
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +115 -123
- package/dist/hono/routes/webhooks.d.ts +2501 -11
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +120 -124
- package/dist/hono/routes/workspaces.cjs +84 -79
- package/dist/hono/routes/workspaces.d.ts +2093 -2
- package/dist/hono/routes/workspaces.d.ts.map +1 -1
- package/dist/hono/routes/workspaces.js +89 -80
- package/dist/hono/schemas/responses.cjs +463 -260
- package/dist/hono/schemas/responses.d.ts +1893 -209
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +203 -14
- package/dist/hono/start-server.cjs +9 -0
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +9 -0
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +7 -7
|
@@ -34,7 +34,7 @@ class A2AMethodHandlers {
|
|
|
34
34
|
* Creates a task if taskId not provided in message, or adds to existing task.
|
|
35
35
|
*
|
|
36
36
|
* @param params Message send parameters
|
|
37
|
-
* @returns Task
|
|
37
|
+
* @returns Task containing the agent response
|
|
38
38
|
*/
|
|
39
39
|
async messageSend(params) {
|
|
40
40
|
if (!params?.message) {
|
|
@@ -12,7 +12,16 @@
|
|
|
12
12
|
* - tasks/cancel - Cancel an in-progress task
|
|
13
13
|
*/
|
|
14
14
|
import type { DextoAgent } from '@dexto/core';
|
|
15
|
-
import type { Task,
|
|
15
|
+
import type { Task, MessageSendParams, TaskQueryParams, ListTasksParams, ListTasksResult, TaskIdParams } from '../types.js';
|
|
16
|
+
type MethodMap = {
|
|
17
|
+
'message/send': (params: MessageSendParams) => Promise<Task>;
|
|
18
|
+
'message/stream': (params: MessageSendParams) => Promise<{
|
|
19
|
+
taskId: string;
|
|
20
|
+
}>;
|
|
21
|
+
'tasks/get': (params: TaskQueryParams) => Promise<Task>;
|
|
22
|
+
'tasks/list': (params?: ListTasksParams) => Promise<ListTasksResult>;
|
|
23
|
+
'tasks/cancel': (params: TaskIdParams) => Promise<Task>;
|
|
24
|
+
};
|
|
16
25
|
/**
|
|
17
26
|
* A2A Method Handlers
|
|
18
27
|
*
|
|
@@ -40,9 +49,9 @@ export declare class A2AMethodHandlers {
|
|
|
40
49
|
* Creates a task if taskId not provided in message, or adds to existing task.
|
|
41
50
|
*
|
|
42
51
|
* @param params Message send parameters
|
|
43
|
-
* @returns Task
|
|
52
|
+
* @returns Task containing the agent response
|
|
44
53
|
*/
|
|
45
|
-
messageSend(params: MessageSendParams): Promise<Task
|
|
54
|
+
messageSend(params: MessageSendParams): Promise<Task>;
|
|
46
55
|
/**
|
|
47
56
|
* tasks/get - Retrieve a task by ID
|
|
48
57
|
*
|
|
@@ -105,6 +114,7 @@ export declare class A2AMethodHandlers {
|
|
|
105
114
|
*
|
|
106
115
|
* @returns Map of method names to handlers
|
|
107
116
|
*/
|
|
108
|
-
getMethods():
|
|
117
|
+
getMethods(): MethodMap;
|
|
109
118
|
}
|
|
119
|
+
export {};
|
|
110
120
|
//# sourceMappingURL=methods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../../src/a2a/jsonrpc/methods.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EACR,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../../src/a2a/jsonrpc/methods.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EACR,IAAI,EACJ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,EACf,MAAM,aAAa,CAAC;AAIrB,KAAK,SAAS,GAAG;IACb,cAAc,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,gBAAgB,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,WAAW,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IACrE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,iBAAiB;IACd,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,UAAU;IAErC;;;;;;;;OAQG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3D;;;;;;OAMG;IACG,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBtD;;;;;;;;OAQG;IACG,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IA0CnE;;;;;;OAMG;IACG,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBtD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAmB3E;;;;;;OAMG;IACH,UAAU,IAAI,SAAS;CAS1B"}
|
|
@@ -11,7 +11,7 @@ class A2AMethodHandlers {
|
|
|
11
11
|
* Creates a task if taskId not provided in message, or adds to existing task.
|
|
12
12
|
*
|
|
13
13
|
* @param params Message send parameters
|
|
14
|
-
* @returns Task
|
|
14
|
+
* @returns Task containing the agent response
|
|
15
15
|
*/
|
|
16
16
|
async messageSend(params) {
|
|
17
17
|
if (!params?.message) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var wire_approval_events_exports = {};
|
|
20
|
+
__export(wire_approval_events_exports, {
|
|
21
|
+
wireApprovalCoordinatorToAgent: () => wireApprovalCoordinatorToAgent
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(wire_approval_events_exports);
|
|
24
|
+
function wireApprovalCoordinatorToAgent(agent, approvalCoordinator) {
|
|
25
|
+
const controller = new AbortController();
|
|
26
|
+
const { signal } = controller;
|
|
27
|
+
approvalCoordinator.onRequest(
|
|
28
|
+
(request) => {
|
|
29
|
+
agent.emit("approval:request", request);
|
|
30
|
+
},
|
|
31
|
+
{ signal }
|
|
32
|
+
);
|
|
33
|
+
approvalCoordinator.onResponse(
|
|
34
|
+
(response) => {
|
|
35
|
+
agent.emit("approval:response", response);
|
|
36
|
+
},
|
|
37
|
+
{ signal }
|
|
38
|
+
);
|
|
39
|
+
return controller;
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
wireApprovalCoordinatorToAgent
|
|
44
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DextoAgent } from '@dexto/core';
|
|
2
|
+
import type { ApprovalCoordinator } from './approval-coordinator.js';
|
|
3
|
+
export declare function wireApprovalCoordinatorToAgent(agent: DextoAgent, approvalCoordinator: ApprovalCoordinator): AbortController;
|
|
4
|
+
//# sourceMappingURL=wire-approval-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-approval-events.d.ts","sourceRoot":"","sources":["../../src/approval/wire-approval-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,wBAAgB,8BAA8B,CAC1C,KAAK,EAAE,UAAU,EACjB,mBAAmB,EAAE,mBAAmB,GACzC,eAAe,CAmBjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function wireApprovalCoordinatorToAgent(agent, approvalCoordinator) {
|
|
2
|
+
const controller = new AbortController();
|
|
3
|
+
const { signal } = controller;
|
|
4
|
+
approvalCoordinator.onRequest(
|
|
5
|
+
(request) => {
|
|
6
|
+
agent.emit("approval:request", request);
|
|
7
|
+
},
|
|
8
|
+
{ signal }
|
|
9
|
+
);
|
|
10
|
+
approvalCoordinator.onResponse(
|
|
11
|
+
(response) => {
|
|
12
|
+
agent.emit("approval:response", response);
|
|
13
|
+
},
|
|
14
|
+
{ signal }
|
|
15
|
+
);
|
|
16
|
+
return controller;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
wireApprovalCoordinatorToAgent
|
|
20
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var session_sse_subscriber_exports = {};
|
|
20
|
+
__export(session_sse_subscriber_exports, {
|
|
21
|
+
SessionSseEventSubscriber: () => SessionSseEventSubscriber
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(session_sse_subscriber_exports);
|
|
24
|
+
var import_events = require("events");
|
|
25
|
+
var import_node_util = require("node:util");
|
|
26
|
+
var import_web = require("node:stream/web");
|
|
27
|
+
var import_core = require("@dexto/core");
|
|
28
|
+
function serializeEventPayload(eventName, payload) {
|
|
29
|
+
if (eventName === "llm:error") {
|
|
30
|
+
const errorPayload = payload;
|
|
31
|
+
return {
|
|
32
|
+
...errorPayload,
|
|
33
|
+
error: errorPayload.error instanceof Error ? {
|
|
34
|
+
message: errorPayload.error.message,
|
|
35
|
+
name: errorPayload.error.name,
|
|
36
|
+
stack: errorPayload.error.stack
|
|
37
|
+
} : errorPayload.error
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return payload;
|
|
41
|
+
}
|
|
42
|
+
class SessionSseEventSubscriber {
|
|
43
|
+
connections = /* @__PURE__ */ new Map();
|
|
44
|
+
globalAbortController;
|
|
45
|
+
subscribe(eventBus) {
|
|
46
|
+
this.globalAbortController?.abort();
|
|
47
|
+
this.globalAbortController = new AbortController();
|
|
48
|
+
const { signal } = this.globalAbortController;
|
|
49
|
+
(0, import_events.setMaxListeners)(32, signal);
|
|
50
|
+
const subscribeSessionEvent = (eventName) => {
|
|
51
|
+
eventBus.on(
|
|
52
|
+
eventName,
|
|
53
|
+
((payload) => {
|
|
54
|
+
if (!payload || typeof payload !== "object" || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.broadcastToSession(
|
|
58
|
+
payload.sessionId,
|
|
59
|
+
String(eventName),
|
|
60
|
+
serializeEventPayload(eventName, payload)
|
|
61
|
+
);
|
|
62
|
+
}),
|
|
63
|
+
{ signal }
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
subscribeSessionEvent("llm:thinking");
|
|
67
|
+
subscribeSessionEvent("llm:chunk");
|
|
68
|
+
subscribeSessionEvent("llm:response");
|
|
69
|
+
subscribeSessionEvent("llm:tool-call");
|
|
70
|
+
subscribeSessionEvent("llm:tool-call-partial");
|
|
71
|
+
subscribeSessionEvent("llm:tool-result");
|
|
72
|
+
subscribeSessionEvent("llm:error");
|
|
73
|
+
subscribeSessionEvent("llm:unsupported-input");
|
|
74
|
+
subscribeSessionEvent("tool:running");
|
|
75
|
+
subscribeSessionEvent("context:compacting");
|
|
76
|
+
subscribeSessionEvent("context:compacted");
|
|
77
|
+
subscribeSessionEvent("context:pruned");
|
|
78
|
+
subscribeSessionEvent("message:queued");
|
|
79
|
+
subscribeSessionEvent("message:dequeued");
|
|
80
|
+
subscribeSessionEvent("session:title-updated");
|
|
81
|
+
subscribeSessionEvent("approval:request");
|
|
82
|
+
subscribeSessionEvent("approval:response");
|
|
83
|
+
subscribeSessionEvent("service:event");
|
|
84
|
+
subscribeSessionEvent("run:complete");
|
|
85
|
+
import_core.logger.debug("SessionSseEventSubscriber subscribed to agent events");
|
|
86
|
+
}
|
|
87
|
+
createStream(sessionId) {
|
|
88
|
+
const connectionId = `${sessionId}-${Date.now()}`;
|
|
89
|
+
return new import_web.ReadableStream({
|
|
90
|
+
start: (controller) => {
|
|
91
|
+
const connection = {
|
|
92
|
+
sessionId,
|
|
93
|
+
controller,
|
|
94
|
+
abortController: new AbortController(),
|
|
95
|
+
connectedAt: Date.now()
|
|
96
|
+
};
|
|
97
|
+
this.connections.set(connectionId, connection);
|
|
98
|
+
import_core.logger.debug(`Session SSE connection opened for session ${sessionId}`);
|
|
99
|
+
const keepaliveInterval = setInterval(() => {
|
|
100
|
+
try {
|
|
101
|
+
this.sendSSEComment(controller, "keepalive");
|
|
102
|
+
} catch {
|
|
103
|
+
clearInterval(keepaliveInterval);
|
|
104
|
+
}
|
|
105
|
+
}, 3e4);
|
|
106
|
+
connection.abortController.signal.addEventListener("abort", () => {
|
|
107
|
+
clearInterval(keepaliveInterval);
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
cancel: () => {
|
|
111
|
+
const connection = this.connections.get(connectionId);
|
|
112
|
+
if (connection) {
|
|
113
|
+
connection.abortController.abort();
|
|
114
|
+
this.connections.delete(connectionId);
|
|
115
|
+
import_core.logger.debug(`Session SSE connection closed for session ${sessionId}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
broadcastToSession(sessionId, eventName, data) {
|
|
121
|
+
for (const [connectionId, connection] of this.connections.entries()) {
|
|
122
|
+
if (connection.sessionId !== sessionId) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
this.sendSSEEvent(connection.controller, eventName, data);
|
|
127
|
+
if (eventName === "run:complete" || eventName === "llm:error" && data.recoverable === false) {
|
|
128
|
+
connection.abortController.abort();
|
|
129
|
+
connection.controller.close();
|
|
130
|
+
this.connections.delete(connectionId);
|
|
131
|
+
}
|
|
132
|
+
} catch (error) {
|
|
133
|
+
import_core.logger.debug(
|
|
134
|
+
`Failed to send session SSE event ${eventName} for ${sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
135
|
+
);
|
|
136
|
+
connection.abortController.abort();
|
|
137
|
+
this.connections.delete(connectionId);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
sendSSEEvent(controller, eventName, data) {
|
|
142
|
+
const encoder = new import_node_util.TextEncoder();
|
|
143
|
+
const payload = `event: ${eventName}
|
|
144
|
+
data: ${JSON.stringify(data)}
|
|
145
|
+
|
|
146
|
+
`;
|
|
147
|
+
controller.enqueue(encoder.encode(payload));
|
|
148
|
+
}
|
|
149
|
+
sendSSEComment(controller, comment) {
|
|
150
|
+
const encoder = new import_node_util.TextEncoder();
|
|
151
|
+
controller.enqueue(encoder.encode(`: ${comment}
|
|
152
|
+
|
|
153
|
+
`));
|
|
154
|
+
}
|
|
155
|
+
cleanup() {
|
|
156
|
+
this.globalAbortController?.abort();
|
|
157
|
+
this.globalAbortController = void 0;
|
|
158
|
+
for (const [connectionId, connection] of this.connections.entries()) {
|
|
159
|
+
connection.abortController.abort();
|
|
160
|
+
this.connections.delete(connectionId);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
+
0 && (module.exports = {
|
|
166
|
+
SessionSseEventSubscriber
|
|
167
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReadableStream } from 'node:stream/web';
|
|
2
|
+
import type { AgentEventBus } from '@dexto/core';
|
|
3
|
+
export declare class SessionSseEventSubscriber {
|
|
4
|
+
private connections;
|
|
5
|
+
private globalAbortController;
|
|
6
|
+
subscribe(eventBus: AgentEventBus): void;
|
|
7
|
+
createStream(sessionId: string): ReadableStream<Uint8Array>;
|
|
8
|
+
private broadcastToSession;
|
|
9
|
+
private sendSSEEvent;
|
|
10
|
+
private sendSSEComment;
|
|
11
|
+
cleanup(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=session-sse-subscriber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-sse-subscriber.d.ts","sourceRoot":"","sources":["../../src/events/session-sse-subscriber.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAwC,MAAM,iBAAiB,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAC;AAgChE,qBAAa,yBAAyB;IAClC,OAAO,CAAC,WAAW,CAA2C;IAC9D,OAAO,CAAC,qBAAqB,CAA8B;IAE3D,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAuDxC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC;IAsC3D,OAAO,CAAC,kBAAkB;IAgC1B,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,cAAc;IAKtB,OAAO,IAAI,IAAI;CASlB"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { setMaxListeners } from "events";
|
|
2
|
+
import { TextEncoder } from "node:util";
|
|
3
|
+
import { ReadableStream } from "node:stream/web";
|
|
4
|
+
import { logger } from "@dexto/core";
|
|
5
|
+
function serializeEventPayload(eventName, payload) {
|
|
6
|
+
if (eventName === "llm:error") {
|
|
7
|
+
const errorPayload = payload;
|
|
8
|
+
return {
|
|
9
|
+
...errorPayload,
|
|
10
|
+
error: errorPayload.error instanceof Error ? {
|
|
11
|
+
message: errorPayload.error.message,
|
|
12
|
+
name: errorPayload.error.name,
|
|
13
|
+
stack: errorPayload.error.stack
|
|
14
|
+
} : errorPayload.error
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return payload;
|
|
18
|
+
}
|
|
19
|
+
class SessionSseEventSubscriber {
|
|
20
|
+
connections = /* @__PURE__ */ new Map();
|
|
21
|
+
globalAbortController;
|
|
22
|
+
subscribe(eventBus) {
|
|
23
|
+
this.globalAbortController?.abort();
|
|
24
|
+
this.globalAbortController = new AbortController();
|
|
25
|
+
const { signal } = this.globalAbortController;
|
|
26
|
+
setMaxListeners(32, signal);
|
|
27
|
+
const subscribeSessionEvent = (eventName) => {
|
|
28
|
+
eventBus.on(
|
|
29
|
+
eventName,
|
|
30
|
+
((payload) => {
|
|
31
|
+
if (!payload || typeof payload !== "object" || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this.broadcastToSession(
|
|
35
|
+
payload.sessionId,
|
|
36
|
+
String(eventName),
|
|
37
|
+
serializeEventPayload(eventName, payload)
|
|
38
|
+
);
|
|
39
|
+
}),
|
|
40
|
+
{ signal }
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
subscribeSessionEvent("llm:thinking");
|
|
44
|
+
subscribeSessionEvent("llm:chunk");
|
|
45
|
+
subscribeSessionEvent("llm:response");
|
|
46
|
+
subscribeSessionEvent("llm:tool-call");
|
|
47
|
+
subscribeSessionEvent("llm:tool-call-partial");
|
|
48
|
+
subscribeSessionEvent("llm:tool-result");
|
|
49
|
+
subscribeSessionEvent("llm:error");
|
|
50
|
+
subscribeSessionEvent("llm:unsupported-input");
|
|
51
|
+
subscribeSessionEvent("tool:running");
|
|
52
|
+
subscribeSessionEvent("context:compacting");
|
|
53
|
+
subscribeSessionEvent("context:compacted");
|
|
54
|
+
subscribeSessionEvent("context:pruned");
|
|
55
|
+
subscribeSessionEvent("message:queued");
|
|
56
|
+
subscribeSessionEvent("message:dequeued");
|
|
57
|
+
subscribeSessionEvent("session:title-updated");
|
|
58
|
+
subscribeSessionEvent("approval:request");
|
|
59
|
+
subscribeSessionEvent("approval:response");
|
|
60
|
+
subscribeSessionEvent("service:event");
|
|
61
|
+
subscribeSessionEvent("run:complete");
|
|
62
|
+
logger.debug("SessionSseEventSubscriber subscribed to agent events");
|
|
63
|
+
}
|
|
64
|
+
createStream(sessionId) {
|
|
65
|
+
const connectionId = `${sessionId}-${Date.now()}`;
|
|
66
|
+
return new ReadableStream({
|
|
67
|
+
start: (controller) => {
|
|
68
|
+
const connection = {
|
|
69
|
+
sessionId,
|
|
70
|
+
controller,
|
|
71
|
+
abortController: new AbortController(),
|
|
72
|
+
connectedAt: Date.now()
|
|
73
|
+
};
|
|
74
|
+
this.connections.set(connectionId, connection);
|
|
75
|
+
logger.debug(`Session SSE connection opened for session ${sessionId}`);
|
|
76
|
+
const keepaliveInterval = setInterval(() => {
|
|
77
|
+
try {
|
|
78
|
+
this.sendSSEComment(controller, "keepalive");
|
|
79
|
+
} catch {
|
|
80
|
+
clearInterval(keepaliveInterval);
|
|
81
|
+
}
|
|
82
|
+
}, 3e4);
|
|
83
|
+
connection.abortController.signal.addEventListener("abort", () => {
|
|
84
|
+
clearInterval(keepaliveInterval);
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
cancel: () => {
|
|
88
|
+
const connection = this.connections.get(connectionId);
|
|
89
|
+
if (connection) {
|
|
90
|
+
connection.abortController.abort();
|
|
91
|
+
this.connections.delete(connectionId);
|
|
92
|
+
logger.debug(`Session SSE connection closed for session ${sessionId}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
broadcastToSession(sessionId, eventName, data) {
|
|
98
|
+
for (const [connectionId, connection] of this.connections.entries()) {
|
|
99
|
+
if (connection.sessionId !== sessionId) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
this.sendSSEEvent(connection.controller, eventName, data);
|
|
104
|
+
if (eventName === "run:complete" || eventName === "llm:error" && data.recoverable === false) {
|
|
105
|
+
connection.abortController.abort();
|
|
106
|
+
connection.controller.close();
|
|
107
|
+
this.connections.delete(connectionId);
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
logger.debug(
|
|
111
|
+
`Failed to send session SSE event ${eventName} for ${sessionId}: ${error instanceof Error ? error.message : String(error)}`
|
|
112
|
+
);
|
|
113
|
+
connection.abortController.abort();
|
|
114
|
+
this.connections.delete(connectionId);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
sendSSEEvent(controller, eventName, data) {
|
|
119
|
+
const encoder = new TextEncoder();
|
|
120
|
+
const payload = `event: ${eventName}
|
|
121
|
+
data: ${JSON.stringify(data)}
|
|
122
|
+
|
|
123
|
+
`;
|
|
124
|
+
controller.enqueue(encoder.encode(payload));
|
|
125
|
+
}
|
|
126
|
+
sendSSEComment(controller, comment) {
|
|
127
|
+
const encoder = new TextEncoder();
|
|
128
|
+
controller.enqueue(encoder.encode(`: ${comment}
|
|
129
|
+
|
|
130
|
+
`));
|
|
131
|
+
}
|
|
132
|
+
cleanup() {
|
|
133
|
+
this.globalAbortController?.abort();
|
|
134
|
+
this.globalAbortController = void 0;
|
|
135
|
+
for (const [connectionId, connection] of this.connections.entries()) {
|
|
136
|
+
connection.abortController.abort();
|
|
137
|
+
this.connections.delete(connectionId);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
SessionSseEventSubscriber
|
|
143
|
+
};
|
|
@@ -107,10 +107,14 @@ async function startTestServer(agent, port, agentsContext) {
|
|
|
107
107
|
await import_node_fs.promises.writeFile(agentConfigPath, (0, import_yaml.stringify)(createTestAgentConfig()), "utf-8");
|
|
108
108
|
const { WebhookEventSubscriber } = await import("../../events/webhook-subscriber.js");
|
|
109
109
|
const { A2ASseEventSubscriber } = await import("../../events/a2a-sse-subscriber.js");
|
|
110
|
+
const { SessionSseEventSubscriber } = await import("../../events/session-sse-subscriber.js");
|
|
110
111
|
const { ApprovalCoordinator } = await import("../../approval/approval-coordinator.js");
|
|
112
|
+
const { wireApprovalCoordinatorToAgent } = await import("../../approval/wire-approval-events.js");
|
|
111
113
|
const webhookSubscriber = new WebhookEventSubscriber();
|
|
112
114
|
const sseSubscriber = new A2ASseEventSubscriber();
|
|
115
|
+
const sessionSseSubscriber = new SessionSseEventSubscriber();
|
|
113
116
|
const approvalCoordinator = new ApprovalCoordinator();
|
|
117
|
+
const approvalEventBridge = wireApprovalCoordinatorToAgent(agent, approvalCoordinator);
|
|
114
118
|
agent.registerSubscriber(webhookSubscriber);
|
|
115
119
|
agent.registerSubscriber(sseSubscriber);
|
|
116
120
|
const app = (0, import__.createDextoApp)({
|
|
@@ -120,6 +124,7 @@ async function startTestServer(agent, port, agentsContext) {
|
|
|
120
124
|
approvalCoordinator,
|
|
121
125
|
webhookSubscriber,
|
|
122
126
|
sseSubscriber,
|
|
127
|
+
sessionSseSubscriber,
|
|
123
128
|
...agentsContext ? { agentsContext } : {}
|
|
124
129
|
// Include agentsContext only if provided
|
|
125
130
|
});
|
|
@@ -144,12 +149,15 @@ async function startTestServer(agent, port, agentsContext) {
|
|
|
144
149
|
app,
|
|
145
150
|
bridge,
|
|
146
151
|
agent,
|
|
152
|
+
approvalCoordinator,
|
|
147
153
|
agentCard: updatedAgentCard,
|
|
148
154
|
baseUrl,
|
|
149
155
|
port: serverPort,
|
|
150
156
|
cleanup: async () => {
|
|
151
157
|
webhookSubscriber.cleanup();
|
|
152
158
|
sseSubscriber.cleanup();
|
|
159
|
+
sessionSseSubscriber.cleanup();
|
|
160
|
+
approvalEventBridge.abort();
|
|
153
161
|
approvalCoordinator.removeAllListeners();
|
|
154
162
|
await new Promise((resolve, reject) => {
|
|
155
163
|
bridge.server.close((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-fixtures.d.ts","sourceRoot":"","sources":["../../../src/hono/__tests__/test-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,WAAW,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAKtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CA+BnD;AAED,UAAU,sBAAsB;IAC5B,gBAAgB,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG,SAAS,CAAC;CAC9E;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACjC,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,sBAAsB,GACjC,OAAO,CAAC,UAAU,CAAC,CAarB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACjC,KAAK,EAAE,UAAU,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,qBAAqB,CAAC,eAAe,CAAC,GACvD,OAAO,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"test-fixtures.d.ts","sourceRoot":"","sources":["../../../src/hono/__tests__/test-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,WAAW,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAKtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CA+BnD;AAED,UAAU,sBAAsB;IAC5B,gBAAgB,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG,SAAS,CAAC;CAC9E;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACjC,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,sBAAsB,GACjC,OAAO,CAAC,UAAU,CAAC,CAarB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,mBAAmB,EAAE,OAAO,wCAAwC,EAAE,mBAAmB,CAAC;IAC1F,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACjC,KAAK,EAAE,UAAU,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,qBAAqB,CAAC,eAAe,CAAC,GACvD,OAAO,CAAC,UAAU,CAAC,CAyGrB;AAmCD;;GAEG;AACH,wBAAsB,WAAW,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,OAAO,CAAC;IACP,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC,CAmCD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,GACpD,IAAI,CAgBN;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;oBACH,OAAO,KAAG,OAAO;oBACjB,OAAO,KAAG,OAAO;qBAChB,OAAO,KAAG,OAAO;mBACnB,OAAO,KAAG,OAAO;oBAChB,OAAO,KAAG,OAAO;4BAET,OAAO,KAAG,OAAO;4BACjB,OAAO,KAAG,OAAO;2BAClB,OAAO,KAAG,OAAO;4BAChB,OAAO,KAAG,OAAO;CAG5C,CAAC"}
|
|
@@ -73,10 +73,14 @@ async function startTestServer(agent, port, agentsContext) {
|
|
|
73
73
|
await fs.writeFile(agentConfigPath, yamlStringify(createTestAgentConfig()), "utf-8");
|
|
74
74
|
const { WebhookEventSubscriber } = await import("../../events/webhook-subscriber.js");
|
|
75
75
|
const { A2ASseEventSubscriber } = await import("../../events/a2a-sse-subscriber.js");
|
|
76
|
+
const { SessionSseEventSubscriber } = await import("../../events/session-sse-subscriber.js");
|
|
76
77
|
const { ApprovalCoordinator } = await import("../../approval/approval-coordinator.js");
|
|
78
|
+
const { wireApprovalCoordinatorToAgent } = await import("../../approval/wire-approval-events.js");
|
|
77
79
|
const webhookSubscriber = new WebhookEventSubscriber();
|
|
78
80
|
const sseSubscriber = new A2ASseEventSubscriber();
|
|
81
|
+
const sessionSseSubscriber = new SessionSseEventSubscriber();
|
|
79
82
|
const approvalCoordinator = new ApprovalCoordinator();
|
|
83
|
+
const approvalEventBridge = wireApprovalCoordinatorToAgent(agent, approvalCoordinator);
|
|
80
84
|
agent.registerSubscriber(webhookSubscriber);
|
|
81
85
|
agent.registerSubscriber(sseSubscriber);
|
|
82
86
|
const app = createDextoApp({
|
|
@@ -86,6 +90,7 @@ async function startTestServer(agent, port, agentsContext) {
|
|
|
86
90
|
approvalCoordinator,
|
|
87
91
|
webhookSubscriber,
|
|
88
92
|
sseSubscriber,
|
|
93
|
+
sessionSseSubscriber,
|
|
89
94
|
...agentsContext ? { agentsContext } : {}
|
|
90
95
|
// Include agentsContext only if provided
|
|
91
96
|
});
|
|
@@ -110,12 +115,15 @@ async function startTestServer(agent, port, agentsContext) {
|
|
|
110
115
|
app,
|
|
111
116
|
bridge,
|
|
112
117
|
agent,
|
|
118
|
+
approvalCoordinator,
|
|
113
119
|
agentCard: updatedAgentCard,
|
|
114
120
|
baseUrl,
|
|
115
121
|
port: serverPort,
|
|
116
122
|
cleanup: async () => {
|
|
117
123
|
webhookSubscriber.cleanup();
|
|
118
124
|
sseSubscriber.cleanup();
|
|
125
|
+
sessionSseSubscriber.cleanup();
|
|
126
|
+
approvalEventBridge.abort();
|
|
119
127
|
approvalCoordinator.removeAllListeners();
|
|
120
128
|
await new Promise((resolve, reject) => {
|
|
121
129
|
bridge.server.close((err) => {
|
package/dist/hono/index.cjs
CHANGED
|
@@ -114,6 +114,7 @@ function createDextoApp(options) {
|
|
|
114
114
|
approvalCoordinator,
|
|
115
115
|
webhookSubscriber,
|
|
116
116
|
sseSubscriber,
|
|
117
|
+
sessionSseSubscriber,
|
|
117
118
|
agentsContext,
|
|
118
119
|
webRoot,
|
|
119
120
|
webUIConfig,
|
|
@@ -137,14 +138,45 @@ function createDextoApp(options) {
|
|
|
137
138
|
app.use(middlewarePattern, import_redaction.redactionMiddleware);
|
|
138
139
|
const routePrefix = normalizedPrefix;
|
|
139
140
|
const resolvedGetAgentConfigPath = getAgentConfigPath ?? ((_ctx) => void 0);
|
|
140
|
-
const fullApp = app
|
|
141
|
-
|
|
142
|
-
(0,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
)
|
|
147
|
-
|
|
141
|
+
const fullApp = app;
|
|
142
|
+
const mountedRouters = [
|
|
143
|
+
["/health", (0, import_health.createHealthRouter)(getAgent)],
|
|
144
|
+
["/", (0, import_a2a.createA2aRouter)(getAgentCard)],
|
|
145
|
+
["/", (0, import_a2a_jsonrpc.createA2AJsonRpcRouter)(getAgent, sseSubscriber)],
|
|
146
|
+
["/", (0, import_a2a_tasks.createA2ATasksRouter)(getAgent, sseSubscriber)],
|
|
147
|
+
[routePrefix, (0, import_greeting.createGreetingRouter)(getAgent)],
|
|
148
|
+
[routePrefix, (0, import_messages.createMessagesRouter)(getAgent, approvalCoordinator)],
|
|
149
|
+
[routePrefix, (0, import_llm.createLlmRouter)(getAgent)],
|
|
150
|
+
[routePrefix, (0, import_sessions.createSessionsRouter)(getAgent, sessionSseSubscriber)],
|
|
151
|
+
[routePrefix, (0, import_search.createSearchRouter)(getAgent)],
|
|
152
|
+
[routePrefix, (0, import_mcp.createMcpRouter)(getAgent, resolvedGetAgentConfigPath)],
|
|
153
|
+
[routePrefix, (0, import_webhooks.createWebhooksRouter)(getAgent, webhookSubscriber)],
|
|
154
|
+
[routePrefix, (0, import_prompts.createPromptsRouter)(getAgent)],
|
|
155
|
+
[routePrefix, (0, import_resources.createResourcesRouter)(getAgent)],
|
|
156
|
+
[routePrefix, (0, import_memory.createMemoryRouter)(getAgent)],
|
|
157
|
+
[routePrefix, (0, import_workspaces.createWorkspacesRouter)(getAgent)],
|
|
158
|
+
[routePrefix, (0, import_schedules.createSchedulesRouter)(getAgent)],
|
|
159
|
+
[routePrefix, (0, import_approvals.createApprovalsRouter)(getAgent, approvalCoordinator)],
|
|
160
|
+
[
|
|
161
|
+
routePrefix,
|
|
162
|
+
(0, import_agents.createAgentsRouter)(
|
|
163
|
+
getAgent,
|
|
164
|
+
agentsContext || dummyAgentsContext,
|
|
165
|
+
resolvedGetAgentConfigPath
|
|
166
|
+
)
|
|
167
|
+
],
|
|
168
|
+
[routePrefix, (0, import_queue.createQueueRouter)(getAgent)],
|
|
169
|
+
[routePrefix, (0, import_openrouter.createOpenRouterRouter)()],
|
|
170
|
+
[routePrefix, (0, import_key.createKeyRouter)()],
|
|
171
|
+
[routePrefix, (0, import_tools.createToolsRouter)(getAgent)],
|
|
172
|
+
[routePrefix, (0, import_discovery.createDiscoveryRouter)(resolvedGetAgentConfigPath)],
|
|
173
|
+
[routePrefix, (0, import_models.createModelsRouter)()],
|
|
174
|
+
[routePrefix, (0, import_system_prompt.createSystemPromptRouter)(getAgent)],
|
|
175
|
+
[routePrefix, (0, import_dexto_auth.createDextoAuthRouter)(getAgent)]
|
|
176
|
+
];
|
|
177
|
+
for (const [path, router] of mountedRouters) {
|
|
178
|
+
fullApp.route(path, router);
|
|
179
|
+
}
|
|
148
180
|
fullApp.doc("/openapi.json", {
|
|
149
181
|
openapi: "3.0.0",
|
|
150
182
|
info: {
|