@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.
Files changed (57) hide show
  1. package/dist/approval/wire-approval-events.cjs +44 -0
  2. package/dist/approval/wire-approval-events.d.ts +4 -0
  3. package/dist/approval/wire-approval-events.d.ts.map +1 -0
  4. package/dist/approval/wire-approval-events.js +20 -0
  5. package/dist/events/a2a-sse-subscriber.cjs +3 -0
  6. package/dist/events/a2a-sse-subscriber.d.ts.map +1 -1
  7. package/dist/events/a2a-sse-subscriber.js +3 -0
  8. package/dist/events/session-sse-subscriber.cjs +167 -0
  9. package/dist/events/session-sse-subscriber.d.ts +13 -0
  10. package/dist/events/session-sse-subscriber.d.ts.map +1 -0
  11. package/dist/events/session-sse-subscriber.js +143 -0
  12. package/dist/events/usage-event-subscriber.cjs +2 -2
  13. package/dist/events/usage-event-subscriber.d.ts.map +1 -1
  14. package/dist/events/usage-event-subscriber.js +2 -2
  15. package/dist/hono/__tests__/test-fixtures.cjs +8 -0
  16. package/dist/hono/__tests__/test-fixtures.d.ts +1 -0
  17. package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
  18. package/dist/hono/__tests__/test-fixtures.js +8 -0
  19. package/dist/hono/index.cjs +2 -1
  20. package/dist/hono/index.d.ts +2 -0
  21. package/dist/hono/index.d.ts.map +1 -1
  22. package/dist/hono/index.js +2 -1
  23. package/dist/hono/node/index.cjs +51 -6
  24. package/dist/hono/node/index.d.ts.map +1 -1
  25. package/dist/hono/node/index.js +51 -6
  26. package/dist/hono/routes/llm.cjs +1 -1
  27. package/dist/hono/routes/llm.d.ts +175 -175
  28. package/dist/hono/routes/llm.d.ts.map +1 -1
  29. package/dist/hono/routes/llm.js +1 -1
  30. package/dist/hono/routes/messages.cjs +43 -53
  31. package/dist/hono/routes/messages.d.ts +1 -2
  32. package/dist/hono/routes/messages.d.ts.map +1 -1
  33. package/dist/hono/routes/messages.js +43 -53
  34. package/dist/hono/routes/models.d.ts +5 -5
  35. package/dist/hono/routes/prompts.d.ts +50 -50
  36. package/dist/hono/routes/queue.d.ts +106 -12
  37. package/dist/hono/routes/queue.d.ts.map +1 -1
  38. package/dist/hono/routes/resources.d.ts +5 -5
  39. package/dist/hono/routes/search.d.ts +297 -43
  40. package/dist/hono/routes/search.d.ts.map +1 -1
  41. package/dist/hono/routes/sessions.cjs +93 -2
  42. package/dist/hono/routes/sessions.d.ts +1736 -93
  43. package/dist/hono/routes/sessions.d.ts.map +1 -1
  44. package/dist/hono/routes/sessions.js +95 -3
  45. package/dist/hono/routes/tools.d.ts +5 -5
  46. package/dist/hono/schemas/responses.cjs +59 -3
  47. package/dist/hono/schemas/responses.d.ts +658 -97
  48. package/dist/hono/schemas/responses.d.ts.map +1 -1
  49. package/dist/hono/schemas/responses.js +59 -4
  50. package/dist/hono/start-server.cjs +9 -0
  51. package/dist/hono/start-server.d.ts.map +1 -1
  52. package/dist/hono/start-server.js +9 -0
  53. package/dist/index.cjs +5 -1
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +2 -0
  57. package/package.json +7 -7
@@ -28,6 +28,12 @@ function createNodeServer(app, options) {
28
28
  const { getAgent: _getAgent } = options;
29
29
  const webhookSubscriber = app.webhookSubscriber;
30
30
  const server = (0, import_node_http.createServer)(async (req, res) => {
31
+ const disconnectController = new AbortController();
32
+ const abortOnDisconnect = () => {
33
+ disconnectController.abort();
34
+ };
35
+ req.on("aborted", abortOnDisconnect);
36
+ res.on("close", abortOnDisconnect);
31
37
  try {
32
38
  if (options.mcpHandlers && req.url?.startsWith("/mcp")) {
33
39
  if (req.method === "GET") {
@@ -64,14 +70,17 @@ function createNodeServer(app, options) {
64
70
  return;
65
71
  }
66
72
  }
67
- const request = await toRequest(req);
73
+ const request = await toRequest(req, disconnectController.signal);
68
74
  const response = await app.fetch(request);
69
- await sendNodeResponse(res, response);
75
+ await sendNodeResponse(res, response, disconnectController.signal);
70
76
  } catch (error) {
71
77
  const message = error instanceof Error ? error.message : String(error);
72
78
  import_core.logger.error(`Unhandled error in Node bridge: ${message}`, { error });
73
79
  res.statusCode = 500;
74
80
  res.end("Internal Server Error");
81
+ } finally {
82
+ req.off("aborted", abortOnDisconnect);
83
+ res.off("close", abortOnDisconnect);
75
84
  }
76
85
  });
77
86
  server.on("close", () => {
@@ -91,7 +100,7 @@ function createNodeServer(app, options) {
91
100
  }
92
101
  return result;
93
102
  }
94
- async function toRequest(req) {
103
+ async function toRequest(req, signal) {
95
104
  const protocol = req.socket?.encrypted ? "https" : "http";
96
105
  const host = req.headers.host ?? "localhost";
97
106
  const url = new URL(req.url ?? "/", `${protocol}://${host}`);
@@ -110,10 +119,11 @@ async function toRequest(req) {
110
119
  method,
111
120
  headers,
112
121
  body: body ?? void 0,
122
+ signal,
113
123
  duplex: body ? "half" : void 0
114
124
  });
115
125
  }
116
- async function sendNodeResponse(res, response) {
126
+ async function sendNodeResponse(res, response, signal) {
117
127
  res.statusCode = response.status;
118
128
  response.headers.forEach((value, key) => {
119
129
  if (key.toLowerCase() === "content-length") {
@@ -128,8 +138,43 @@ async function sendNodeResponse(res, response) {
128
138
  const webStream = response.body;
129
139
  const readable = import_node_stream.Readable.fromWeb(webStream);
130
140
  await new Promise((resolve, reject) => {
131
- readable.on("error", reject);
132
- res.on("finish", resolve);
141
+ let settled = false;
142
+ const settle = (callback) => {
143
+ if (settled) {
144
+ return;
145
+ }
146
+ settled = true;
147
+ cleanup();
148
+ callback();
149
+ };
150
+ const cleanup = () => {
151
+ readable.off("error", handleError);
152
+ readable.off("close", handleReadableClose);
153
+ res.off("finish", handleFinish);
154
+ res.off("close", handleClose);
155
+ signal.removeEventListener("abort", handleAbort);
156
+ };
157
+ const handleError = (error) => {
158
+ settle(() => reject(error));
159
+ };
160
+ const handleReadableClose = () => {
161
+ settle(resolve);
162
+ };
163
+ const handleFinish = () => {
164
+ settle(resolve);
165
+ };
166
+ const handleAbort = () => {
167
+ readable.destroy();
168
+ };
169
+ const handleClose = () => {
170
+ readable.destroy();
171
+ settle(resolve);
172
+ };
173
+ readable.on("error", handleError);
174
+ readable.on("close", handleReadableClose);
175
+ res.on("finish", handleFinish);
176
+ res.on("close", handleClose);
177
+ signal.addEventListener("abort", handleAbort, { once: true });
133
178
  readable.pipe(res);
134
179
  });
135
180
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hono/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAKjF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,EAAE,MAAM,UAAU,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE;QACV,UAAU,EAAE,CACR,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,OAAO,KACZ,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC1B,SAAS,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAClF,GAAG,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACxC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;CAC9C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAyE5F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hono/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAKjF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,EAAE,MAAM,UAAU,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE;QACV,UAAU,EAAE,CACR,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,OAAO,KACZ,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC1B,SAAS,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAClF,GAAG,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACxC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;CAC9C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAoF5F"}
@@ -5,6 +5,12 @@ function createNodeServer(app, options) {
5
5
  const { getAgent: _getAgent } = options;
6
6
  const webhookSubscriber = app.webhookSubscriber;
7
7
  const server = createServer(async (req, res) => {
8
+ const disconnectController = new AbortController();
9
+ const abortOnDisconnect = () => {
10
+ disconnectController.abort();
11
+ };
12
+ req.on("aborted", abortOnDisconnect);
13
+ res.on("close", abortOnDisconnect);
8
14
  try {
9
15
  if (options.mcpHandlers && req.url?.startsWith("/mcp")) {
10
16
  if (req.method === "GET") {
@@ -41,14 +47,17 @@ function createNodeServer(app, options) {
41
47
  return;
42
48
  }
43
49
  }
44
- const request = await toRequest(req);
50
+ const request = await toRequest(req, disconnectController.signal);
45
51
  const response = await app.fetch(request);
46
- await sendNodeResponse(res, response);
52
+ await sendNodeResponse(res, response, disconnectController.signal);
47
53
  } catch (error) {
48
54
  const message = error instanceof Error ? error.message : String(error);
49
55
  logger.error(`Unhandled error in Node bridge: ${message}`, { error });
50
56
  res.statusCode = 500;
51
57
  res.end("Internal Server Error");
58
+ } finally {
59
+ req.off("aborted", abortOnDisconnect);
60
+ res.off("close", abortOnDisconnect);
52
61
  }
53
62
  });
54
63
  server.on("close", () => {
@@ -68,7 +77,7 @@ function createNodeServer(app, options) {
68
77
  }
69
78
  return result;
70
79
  }
71
- async function toRequest(req) {
80
+ async function toRequest(req, signal) {
72
81
  const protocol = req.socket?.encrypted ? "https" : "http";
73
82
  const host = req.headers.host ?? "localhost";
74
83
  const url = new URL(req.url ?? "/", `${protocol}://${host}`);
@@ -87,10 +96,11 @@ async function toRequest(req) {
87
96
  method,
88
97
  headers,
89
98
  body: body ?? void 0,
99
+ signal,
90
100
  duplex: body ? "half" : void 0
91
101
  });
92
102
  }
93
- async function sendNodeResponse(res, response) {
103
+ async function sendNodeResponse(res, response, signal) {
94
104
  res.statusCode = response.status;
95
105
  response.headers.forEach((value, key) => {
96
106
  if (key.toLowerCase() === "content-length") {
@@ -105,8 +115,43 @@ async function sendNodeResponse(res, response) {
105
115
  const webStream = response.body;
106
116
  const readable = Readable.fromWeb(webStream);
107
117
  await new Promise((resolve, reject) => {
108
- readable.on("error", reject);
109
- res.on("finish", resolve);
118
+ let settled = false;
119
+ const settle = (callback) => {
120
+ if (settled) {
121
+ return;
122
+ }
123
+ settled = true;
124
+ cleanup();
125
+ callback();
126
+ };
127
+ const cleanup = () => {
128
+ readable.off("error", handleError);
129
+ readable.off("close", handleReadableClose);
130
+ res.off("finish", handleFinish);
131
+ res.off("close", handleClose);
132
+ signal.removeEventListener("abort", handleAbort);
133
+ };
134
+ const handleError = (error) => {
135
+ settle(() => reject(error));
136
+ };
137
+ const handleReadableClose = () => {
138
+ settle(resolve);
139
+ };
140
+ const handleFinish = () => {
141
+ settle(resolve);
142
+ };
143
+ const handleAbort = () => {
144
+ readable.destroy();
145
+ };
146
+ const handleClose = () => {
147
+ readable.destroy();
148
+ settle(resolve);
149
+ };
150
+ readable.on("error", handleError);
151
+ readable.on("close", handleReadableClose);
152
+ res.on("finish", handleFinish);
153
+ res.on("close", handleClose);
154
+ signal.addEventListener("abort", handleAbort, { once: true });
110
155
  readable.pipe(res);
111
156
  });
112
157
  }
@@ -43,7 +43,7 @@ const CatalogQuerySchema = import_zod_openapi.z.object({
43
43
  hasKey: import_zod_openapi.z.union([import_zod_openapi.z.literal("true"), import_zod_openapi.z.literal("false"), import_zod_openapi.z.literal("1"), import_zod_openapi.z.literal("0")]).optional().transform(
44
44
  (raw) => raw === "true" || raw === "1" ? true : raw === "false" || raw === "0" ? false : void 0
45
45
  ).describe("Filter by API key presence (true or false)"),
46
- fileType: import_zod_openapi.z.enum(import_core2.SUPPORTED_FILE_TYPES).optional().describe("Filter by supported file type (audio, pdf, or image)"),
46
+ fileType: import_zod_openapi.z.enum(import_core2.SUPPORTED_FILE_TYPES).optional().describe("Filter by supported file type (audio, pdf, image, video, or document)"),
47
47
  defaultOnly: import_zod_openapi.z.union([import_zod_openapi.z.literal("true"), import_zod_openapi.z.literal("false"), import_zod_openapi.z.literal("1"), import_zod_openapi.z.literal("0")]).optional().transform(
48
48
  (raw) => raw === "true" || raw === "1" ? true : raw === "false" || raw === "0" ? false : void 0
49
49
  ).describe("Include only default models (true or false)"),