@dexto/server 1.6.21 → 1.6.24
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/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/a2a-sse-subscriber.cjs +3 -0
- package/dist/events/a2a-sse-subscriber.d.ts.map +1 -1
- package/dist/events/a2a-sse-subscriber.js +3 -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/events/usage-event-subscriber.cjs +2 -2
- package/dist/events/usage-event-subscriber.d.ts.map +1 -1
- package/dist/events/usage-event-subscriber.js +2 -2
- 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 +2 -1
- package/dist/hono/index.d.ts +2 -0
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +2 -1
- 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/llm.cjs +1 -1
- package/dist/hono/routes/llm.d.ts +175 -175
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +1 -1
- package/dist/hono/routes/messages.cjs +43 -53
- package/dist/hono/routes/messages.d.ts +1 -2
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +43 -53
- package/dist/hono/routes/models.d.ts +5 -5
- package/dist/hono/routes/prompts.d.ts +50 -50
- package/dist/hono/routes/queue.d.ts +106 -12
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/resources.d.ts +5 -5
- package/dist/hono/routes/search.d.ts +297 -43
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/sessions.cjs +93 -2
- package/dist/hono/routes/sessions.d.ts +1736 -93
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +95 -3
- package/dist/hono/routes/tools.d.ts +5 -5
- package/dist/hono/schemas/responses.cjs +59 -3
- package/dist/hono/schemas/responses.d.ts +658 -97
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +59 -4
- 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/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
|
@@ -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
|
+
};
|
|
@@ -109,6 +109,9 @@ class A2ASseEventSubscriber {
|
|
|
109
109
|
...payload.estimatedCost !== void 0 && {
|
|
110
110
|
estimatedCost: payload.estimatedCost
|
|
111
111
|
},
|
|
112
|
+
...payload.costBreakdown && {
|
|
113
|
+
costBreakdown: payload.costBreakdown
|
|
114
|
+
},
|
|
112
115
|
...payload.pricingStatus && { pricingStatus: payload.pricingStatus }
|
|
113
116
|
});
|
|
114
117
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a-sse-subscriber.d.ts","sourceRoot":"","sources":["../../src/events/a2a-sse-subscriber.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAiB5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,WAAW,CAAyC;IAC5D,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,qBAAqB,CAAC,CAAkB;IAEhD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"a2a-sse-subscriber.d.ts","sourceRoot":"","sources":["../../src/events/a2a-sse-subscriber.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAiB5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,WAAW,CAAyC;IAC5D,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,qBAAqB,CAAC,CAAkB;IAEhD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IA4HxC;;;;;;;OAOG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC;IAiDxD;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IA0BvB;;;;;;;;OAQG;IACH,OAAO,CAAC,YAAY;IASpB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACH,OAAO,IAAI,IAAI;IAgBf;;OAEG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;OAEG;IACH,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CASjD"}
|
|
@@ -86,6 +86,9 @@ class A2ASseEventSubscriber {
|
|
|
86
86
|
...payload.estimatedCost !== void 0 && {
|
|
87
87
|
estimatedCost: payload.estimatedCost
|
|
88
88
|
},
|
|
89
|
+
...payload.costBreakdown && {
|
|
90
|
+
costBreakdown: payload.costBreakdown
|
|
91
|
+
},
|
|
89
92
|
...payload.pricingStatus && { pricingStatus: payload.pricingStatus }
|
|
90
93
|
});
|
|
91
94
|
},
|
|
@@ -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
|
+
};
|
|
@@ -128,13 +128,13 @@ class UsageEventSubscriber {
|
|
|
128
128
|
if (!(0, import_core.hasMeaningfulTokenUsage)(payload.tokenUsage)) {
|
|
129
129
|
return null;
|
|
130
130
|
}
|
|
131
|
-
const resolvedCostBreakdown = payload.provider && payload.model ? (() => {
|
|
131
|
+
const resolvedCostBreakdown = payload.costBreakdown ?? (payload.provider && payload.model ? (() => {
|
|
132
132
|
const pricing = (0, import_core.getModelPricing)(payload.provider, payload.model);
|
|
133
133
|
if (!pricing) {
|
|
134
134
|
return void 0;
|
|
135
135
|
}
|
|
136
136
|
return (0, import_core.calculateCostBreakdown)(payload.tokenUsage, pricing);
|
|
137
|
-
})() : void 0;
|
|
137
|
+
})() : void 0);
|
|
138
138
|
const resolvedEstimatedCost = payload.estimatedCost ?? resolvedCostBreakdown?.totalUsd;
|
|
139
139
|
return {
|
|
140
140
|
eventId: createUsageEventId(payload.usageScopeId, payload.messageId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-event-subscriber.d.ts","sourceRoot":"","sources":["../../src/events/usage-event-subscriber.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,EAMb,KAAK,QAAQ,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAGR,yBAAyB,EAC5B,MAAM,wBAAwB,CAAC;AAqBhC,UAAU,0BAA2B,SAAQ,yBAAyB;IAClE,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAcD,qBAAa,oBAAqB,YAAW,eAAe;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsC;IACtE,OAAO,CAAC,eAAe,CAAC,CAAkB;IAC1C,OAAO,CAAC,+BAA+B,CAAC,CAAkB;IAC1D,OAAO,CAAC,aAAa,CAAC,CAAiC;IACvD,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,0BAA0B,CAAS;IAC3C,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,0BAA0B;IA0B9C,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IA2BxC,OAAO,IAAI,IAAI;IAmBF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,OAAO,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"usage-event-subscriber.d.ts","sourceRoot":"","sources":["../../src/events/usage-event-subscriber.ts"],"names":[],"mappings":"AACA,OAA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
111
111
|
return null;
|
|
112
112
|
}
|
|
113
|
-
const resolvedCostBreakdown = payload.provider && payload.model ? (() => {
|
|
113
|
+
const resolvedCostBreakdown = payload.costBreakdown ?? (payload.provider && payload.model ? (() => {
|
|
114
114
|
const pricing = getModelPricing(payload.provider, payload.model);
|
|
115
115
|
if (!pricing) {
|
|
116
116
|
return void 0;
|
|
117
117
|
}
|
|
118
118
|
return calculateCostBreakdown(payload.tokenUsage, pricing);
|
|
119
|
-
})() : void 0;
|
|
119
|
+
})() : void 0);
|
|
120
120
|
const resolvedEstimatedCost = payload.estimatedCost ?? resolvedCostBreakdown?.totalUsd;
|
|
121
121
|
return {
|
|
122
122
|
eventId: createUsageEventId(payload.usageScopeId, payload.messageId),
|
|
@@ -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,s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gB,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,
|
|
@@ -146,7 +147,7 @@ function createDextoApp(options) {
|
|
|
146
147
|
[routePrefix, (0, import_greeting.createGreetingRouter)(getAgent)],
|
|
147
148
|
[routePrefix, (0, import_messages.createMessagesRouter)(getAgent, approvalCoordinator)],
|
|
148
149
|
[routePrefix, (0, import_llm.createLlmRouter)(getAgent)],
|
|
149
|
-
[routePrefix, (0, import_sessions.createSessionsRouter)(getAgent)],
|
|
150
|
+
[routePrefix, (0, import_sessions.createSessionsRouter)(getAgent, sessionSseSubscriber)],
|
|
150
151
|
[routePrefix, (0, import_search.createSearchRouter)(getAgent)],
|
|
151
152
|
[routePrefix, (0, import_mcp.createMcpRouter)(getAgent, resolvedGetAgentConfigPath)],
|
|
152
153
|
[routePrefix, (0, import_webhooks.createWebhooksRouter)(getAgent, webhookSubscriber)],
|
package/dist/hono/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { type SystemPromptRouterSchema } from './routes/system-prompt.js';
|
|
|
29
29
|
import { type WebUIRuntimeConfig } from './routes/static.js';
|
|
30
30
|
import { WebhookEventSubscriber } from '../events/webhook-subscriber.js';
|
|
31
31
|
import { A2ASseEventSubscriber } from '../events/a2a-sse-subscriber.js';
|
|
32
|
+
import { SessionSseEventSubscriber } from '../events/session-sse-subscriber.js';
|
|
32
33
|
import { ApprovalCoordinator } from '../approval/approval-coordinator.js';
|
|
33
34
|
import type { DextoApp, GetAgentConfigPathFn, GetAgentFn } from './types.js';
|
|
34
35
|
export type CreateDextoAppOptions = {
|
|
@@ -48,6 +49,7 @@ export type CreateDextoAppOptions = {
|
|
|
48
49
|
approvalCoordinator: ApprovalCoordinator;
|
|
49
50
|
webhookSubscriber: WebhookEventSubscriber;
|
|
50
51
|
sseSubscriber: A2ASseEventSubscriber;
|
|
52
|
+
sessionSseSubscriber: SessionSseEventSubscriber;
|
|
51
53
|
agentsContext?: AgentsRouterContext;
|
|
52
54
|
/** Absolute path to WebUI build output. If provided, static files will be served. */
|
|
53
55
|
webRoot?: string;
|
package/dist/hono/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAwB,KAAK,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tB,eAAe,GACf,iBAAiB,GACjB,qBAAqB,GACrB,kBAAkB,GAClB,wBAAwB,GACxB,qBAAqB,CAAC;AAE5B,KAAK,sBAAsB,GACrB,wBAAwB,GACxB,uBAAuB,GACvB,sBAAsB,GACtB,kBAAkB,CAAC;AAEzB,KAAK,gBAAgB,GAAG,eAAe,CAAC,sBAAsB,EAAE,OAAO,kBAAkB,CAAC,CAAC;AAM3F,KAAK,eAAe,GAAG,YAAY,GAAG,eAAe,GAAG,aAAa,CAAC;AACtE,KAAK,SAAS,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAEpD,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,QAAQ,CAoOvE;AAED,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;AAGrD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/hono/index.js
CHANGED
|
@@ -95,6 +95,7 @@ function createDextoApp(options) {
|
|
|
95
95
|
approvalCoordinator,
|
|
96
96
|
webhookSubscriber,
|
|
97
97
|
sseSubscriber,
|
|
98
|
+
sessionSseSubscriber,
|
|
98
99
|
agentsContext,
|
|
99
100
|
webRoot,
|
|
100
101
|
webUIConfig,
|
|
@@ -127,7 +128,7 @@ function createDextoApp(options) {
|
|
|
127
128
|
[routePrefix, createGreetingRouter(getAgent)],
|
|
128
129
|
[routePrefix, createMessagesRouter(getAgent, approvalCoordinator)],
|
|
129
130
|
[routePrefix, createLlmRouter(getAgent)],
|
|
130
|
-
[routePrefix, createSessionsRouter(getAgent)],
|
|
131
|
+
[routePrefix, createSessionsRouter(getAgent, sessionSseSubscriber)],
|
|
131
132
|
[routePrefix, createSearchRouter(getAgent)],
|
|
132
133
|
[routePrefix, createMcpRouter(getAgent, resolvedGetAgentConfigPath)],
|
|
133
134
|
[routePrefix, createWebhooksRouter(getAgent, webhookSubscriber)],
|