@caplets/core 0.18.0 → 0.18.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.
@@ -1,4 +1,4 @@
1
- import { Ct as resolveProjectConfigPath, Mt as __exportAll, Ot as CapletsError, St as resolveProjectCapletsRoot, bt as resolveCapletsRoot, gt as loadConfigWithSources, vt as DEFAULT_AUTH_DIR, xt as resolveConfigPath, yt as DEFAULT_COMPLETION_CACHE_DIR } from "./options-DM1cMRcp.js";
1
+ import { Ct as resolveProjectConfigPath, Mt as __exportAll, Ot as CapletsError, St as resolveProjectCapletsRoot, bt as resolveCapletsRoot, gt as loadConfigWithSources, vt as DEFAULT_AUTH_DIR, xt as resolveConfigPath, yt as DEFAULT_COMPLETION_CACHE_DIR } from "./options-BqibJVxq.js";
2
2
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { createHash } from "node:crypto";
@@ -1,2 +1,2 @@
1
- import { a as generatedToolInputJsonSchemaForCaplet, c as mcpOperations, i as generatedToolInputJsonSchema, l as operations, n as completionRefSchema, o as generatedToolInputSchema, r as generatedToolInputDescriptions, s as generatedToolInputSchemaForCaplet, t as completionArgumentSchema } from "./generated-tool-input-schema-B6rce396.js";
1
+ import { a as generatedToolInputJsonSchemaForCaplet, c as mcpOperations, i as generatedToolInputJsonSchema, l as operations, n as completionRefSchema, o as generatedToolInputSchema, r as generatedToolInputDescriptions, s as generatedToolInputSchemaForCaplet, t as completionArgumentSchema } from "./generated-tool-input-schema-BYoyY-l-.js";
2
2
  export { completionArgumentSchema, completionRefSchema, generatedToolInputDescriptions, generatedToolInputJsonSchema, generatedToolInputJsonSchemaForCaplet, generatedToolInputSchema, generatedToolInputSchemaForCaplet, mcpOperations, operations };
package/dist/index.js CHANGED
@@ -1,17 +1,16 @@
1
- import { $ as assertCompleteRequestPrompt, A as CreateMessageResultSchema, At as toSafeError, B as JSONRPCMessageSchema, C as AjvJsonSchemaValidator, D as CallToolRequestSchema, Dt as CAPLETS_ERROR_CODES, E as toJsonSchemaCompat, Et as SERVER_ID_PATTERN, F as EmptyResultSchema, G as ListRootsResultSchema, H as ListPromptsRequestSchema, I as ErrorCode, J as McpError, K as ListToolsRequestSchema, L as GetPromptRequestSchema, M as CreateTaskResultSchema, Nt as __require, O as CallToolResultSchema, Ot as CapletsError, P as ElicitResultSchema, Pt as __toESM, R as InitializeRequestSchema, S as assertToolsCallTaskCapability, St as resolveProjectCapletsRoot, T as mergeCapabilities, Tt as validateCapletFile, U as ListResourceTemplatesRequestSchema, V as LATEST_PROTOCOL_VERSION, W as ListResourcesRequestSchema, X as SUPPORTED_PROTOCOL_VERSIONS, Y as ReadResourceRequestSchema, Z as SetLevelRequestSchema, _t as parseConfig, a as resolveCapletsServer, at as getLiteralValue, bt as resolveCapletsRoot, c as ServerRegistry, ct as getSchemaDescription, d as runOAuthFlow, dt as normalizeObjectSchema, et as assertCompleteRequestResourceTemplate, f as startGenericOAuthFlow, ft as objectFromShape, g as readTokenBundle, gt as loadConfigWithSources, h as isTokenBundleExpired, ht as loadConfig, i as resolveCapletsMode, it as isJSONRPCResultResponse, j as CreateMessageResultWithToolsSchema, jt as __commonJSMin, k as CompleteRequestSchema, kt as redactSecrets, l as capabilityDescription, lt as isSchemaOptional, m as deleteTokenBundle, mt as safeParseAsync, nt as isJSONRPCErrorResponse, o as CapletsEngine, ot as getObjectShape, p as startOAuthFlow, pt as safeParse, q as LoggingLevelSchema, r as parseServerBaseUrl, rt as isJSONRPCRequest, s as handleServerTool, st as getParseErrorMessage, t as controlUrlForBase, tt as isInitializeRequest, u as runGenericOAuthFlow, ut as isZ4Schema, v as ReadBuffer, w as Protocol, wt as discoverCapletFiles, x as assertClientRequestTaskCapability, xt as resolveConfigPath, y as serializeMessage, z as InitializedNotificationSchema } from "./options-DM1cMRcp.js";
2
- import { A as url, C as object, D as string, b as literal, d as ZodOptional, o as generatedToolInputSchema, s as generatedToolInputSchemaForCaplet } from "./generated-tool-input-schema-B6rce396.js";
3
- import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-CxGG6ae3.js";
1
+ import { $ as assertCompleteRequestPrompt, A as CreateMessageResultSchema, At as toSafeError, B as JSONRPCMessageSchema, C as AjvJsonSchemaValidator, D as CallToolRequestSchema, Dt as CAPLETS_ERROR_CODES, E as toJsonSchemaCompat, Et as SERVER_ID_PATTERN, F as EmptyResultSchema, G as ListRootsResultSchema, H as ListPromptsRequestSchema, I as ErrorCode, J as McpError, K as ListToolsRequestSchema, L as GetPromptRequestSchema, M as CreateTaskResultSchema, Nt as __require, O as CallToolResultSchema, Ot as CapletsError, P as ElicitResultSchema, Pt as __toESM, R as InitializeRequestSchema, S as assertToolsCallTaskCapability, St as resolveProjectCapletsRoot, T as mergeCapabilities, Tt as validateCapletFile, U as ListResourceTemplatesRequestSchema, V as LATEST_PROTOCOL_VERSION, W as ListResourcesRequestSchema, X as SUPPORTED_PROTOCOL_VERSIONS, Y as ReadResourceRequestSchema, Z as SetLevelRequestSchema, _t as parseConfig, a as resolveCapletsServer, at as getLiteralValue, bt as resolveCapletsRoot, c as ServerRegistry, ct as getSchemaDescription, d as runOAuthFlow, dt as normalizeObjectSchema, et as assertCompleteRequestResourceTemplate, f as startGenericOAuthFlow, ft as objectFromShape, g as readTokenBundle, gt as loadConfigWithSources, h as isTokenBundleExpired, ht as loadConfig, i as resolveCapletsMode, it as isJSONRPCResultResponse, j as CreateMessageResultWithToolsSchema, jt as __commonJSMin, k as CompleteRequestSchema, kt as redactSecrets, l as capabilityDescription, lt as isSchemaOptional, m as deleteTokenBundle, mt as safeParseAsync, nt as isJSONRPCErrorResponse, o as CapletsEngine, ot as getObjectShape, p as startOAuthFlow, pt as safeParse, q as LoggingLevelSchema, r as parseServerBaseUrl, rt as isJSONRPCRequest, s as handleServerTool, st as getParseErrorMessage, t as controlUrlForBase, tt as isInitializeRequest, u as runGenericOAuthFlow, ut as isZ4Schema, v as ReadBuffer, w as Protocol, wt as discoverCapletFiles, x as assertClientRequestTaskCapability, xt as resolveConfigPath, y as serializeMessage, z as InitializedNotificationSchema } from "./options-BqibJVxq.js";
2
+ import { A as url, C as object, D as string, b as literal, d as ZodOptional, o as generatedToolInputSchema, s as generatedToolInputSchemaForCaplet } from "./generated-tool-input-schema-BYoyY-l-.js";
3
+ import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-dbB1hc97.js";
4
4
  import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
5
5
  import { basename, dirname, join, parse, relative, resolve } from "node:path";
6
6
  import { execFileSync } from "node:child_process";
7
7
  import process$1, { stdin, stdout } from "node:process";
8
8
  import { tmpdir } from "node:os";
9
+ import { Readable } from "node:stream";
10
+ import { STATUS_CODES, createServer } from "node:http";
9
11
  import { randomUUID, timingSafeEqual } from "node:crypto";
10
12
  import { createInterface } from "node:readline/promises";
11
- import { createServer } from "http";
12
- import { Http2ServerRequest, constants as constants$1 } from "http2";
13
- import { Readable } from "stream";
14
- import crypto$1 from "crypto";
13
+ import { Http2ServerRequest, constants as constants$1 } from "node:http2";
15
14
  //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
16
15
  /**
17
16
  * Experimental server task features for MCP SDK.
@@ -1321,7 +1320,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
1321
1320
  } };
1322
1321
  //#endregion
1323
1322
  //#region package.json
1324
- var version = "0.18.0";
1323
+ var version = "0.18.1";
1325
1324
  //#endregion
1326
1325
  //#region src/serve/session.ts
1327
1326
  var CapletsMcpSession = class {
@@ -5370,7 +5369,7 @@ function redactRemoteMessage(message) {
5370
5369
  return String(redactSecrets(message)).replace(/\b(authorization\s*:\s*(?:basic|bearer)\s+)[^\s,;]+/giu, "$1[REDACTED]").replace(/\b((?:access_)?token=)[^\s,;]+/giu, "$1[REDACTED]").replace(/\b((?:token|secret|authorization|auth|api[-_]?key|password|credential|clientsecret|client_secret|code|refresh(?:_token)?)\s*[=:]\s*)[^\s,;]+/giu, "$1[REDACTED]");
5371
5370
  }
5372
5371
  //#endregion
5373
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/compose.js
5372
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/compose.js
5374
5373
  var compose = (middleware, onError, onNotFound) => {
5375
5374
  return (context, next) => {
5376
5375
  let index = -1;
@@ -5401,7 +5400,7 @@ var compose = (middleware, onError, onNotFound) => {
5401
5400
  };
5402
5401
  };
5403
5402
  //#endregion
5404
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/http-exception.js
5403
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/http-exception.js
5405
5404
  var HTTPException = class extends Error {
5406
5405
  res;
5407
5406
  status;
@@ -5429,10 +5428,10 @@ var HTTPException = class extends Error {
5429
5428
  }
5430
5429
  };
5431
5430
  //#endregion
5432
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/request/constants.js
5431
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/request/constants.js
5433
5432
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
5434
5433
  //#endregion
5435
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/utils/body.js
5434
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/utils/body.js
5436
5435
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
5437
5436
  const { all = false, dot = false } = options;
5438
5437
  const contentType = (request instanceof HonoRequest ? request.raw.headers : request.headers).get("Content-Type");
@@ -5480,7 +5479,7 @@ var handleParsingNestedValues = (form, key, value) => {
5480
5479
  });
5481
5480
  };
5482
5481
  //#endregion
5483
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/utils/url.js
5482
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/utils/url.js
5484
5483
  var splitPath = (path) => {
5485
5484
  const paths = path.split("/");
5486
5485
  if (paths[0] === "") paths.shift();
@@ -5644,7 +5643,7 @@ var getQueryParams = (url, key) => {
5644
5643
  };
5645
5644
  var decodeURIComponent_ = decodeURIComponent;
5646
5645
  //#endregion
5647
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/request.js
5646
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/request.js
5648
5647
  var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
5649
5648
  var HonoRequest = class {
5650
5649
  /**
@@ -5916,7 +5915,7 @@ var HonoRequest = class {
5916
5915
  }
5917
5916
  };
5918
5917
  //#endregion
5919
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/utils/html.js
5918
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/utils/html.js
5920
5919
  var HtmlEscapedCallbackPhase = {
5921
5920
  Stringify: 1,
5922
5921
  BeforeStream: 2,
@@ -5946,7 +5945,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
5946
5945
  else return resStr;
5947
5946
  };
5948
5947
  //#endregion
5949
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/context.js
5948
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/context.js
5950
5949
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
5951
5950
  var setDefaultContentType = (contentType, headers) => {
5952
5951
  return {
@@ -6307,7 +6306,7 @@ var Context = class {
6307
6306
  };
6308
6307
  };
6309
6308
  //#endregion
6310
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router.js
6309
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router.js
6311
6310
  var METHODS = [
6312
6311
  "get",
6313
6312
  "post",
@@ -6319,10 +6318,10 @@ var METHODS = [
6319
6318
  var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
6320
6319
  var UnsupportedPathError = class extends Error {};
6321
6320
  //#endregion
6322
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/utils/constants.js
6321
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/utils/constants.js
6323
6322
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
6324
6323
  //#endregion
6325
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/hono-base.js
6324
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/hono-base.js
6326
6325
  var notFoundHandler = (c) => {
6327
6326
  return c.text("404 Not Found", 404);
6328
6327
  };
@@ -6423,7 +6422,7 @@ var Hono$1 = class _Hono {
6423
6422
  handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
6424
6423
  handler[COMPOSED_HANDLER] = r.handler;
6425
6424
  }
6426
- subApp.#addRoute(r.method, r.path, handler);
6425
+ subApp.#addRoute(r.method, r.path, handler, r.basePath);
6427
6426
  });
6428
6427
  return this;
6429
6428
  }
@@ -6540,7 +6539,7 @@ var Hono$1 = class _Hono {
6540
6539
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
6541
6540
  return (request) => {
6542
6541
  const url = new URL(request.url);
6543
- url.pathname = url.pathname.slice(pathPrefixLength) || "/";
6542
+ url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
6544
6543
  return new Request(url, request);
6545
6544
  };
6546
6545
  })();
@@ -6552,11 +6551,11 @@ var Hono$1 = class _Hono {
6552
6551
  this.#addRoute("ALL", mergePath(path, "*"), handler);
6553
6552
  return this;
6554
6553
  }
6555
- #addRoute(method, path, handler) {
6554
+ #addRoute(method, path, handler, baseRoutePath) {
6556
6555
  method = method.toUpperCase();
6557
6556
  path = mergePath(this._basePath, path);
6558
6557
  const r = {
6559
- basePath: this._basePath,
6558
+ basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
6560
6559
  path,
6561
6560
  method,
6562
6561
  handler
@@ -6656,7 +6655,7 @@ var Hono$1 = class _Hono {
6656
6655
  };
6657
6656
  };
6658
6657
  //#endregion
6659
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router/reg-exp-router/matcher.js
6658
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router/reg-exp-router/matcher.js
6660
6659
  var emptyParam = [];
6661
6660
  function match(method, path) {
6662
6661
  const matchers = this.buildAllMatchers();
@@ -6673,7 +6672,7 @@ function match(method, path) {
6673
6672
  return match2(method, path);
6674
6673
  }
6675
6674
  //#endregion
6676
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router/reg-exp-router/node.js
6675
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router/reg-exp-router/node.js
6677
6676
  var LABEL_REG_EXP_STR = "[^/]+";
6678
6677
  var ONLY_WILDCARD_REG_EXP_STR = ".*";
6679
6678
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
@@ -6752,7 +6751,7 @@ var Node$1 = class _Node {
6752
6751
  }
6753
6752
  };
6754
6753
  //#endregion
6755
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router/reg-exp-router/trie.js
6754
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router/reg-exp-router/trie.js
6756
6755
  var Trie = class {
6757
6756
  #context = { varIndex: 0 };
6758
6757
  #root = new Node$1();
@@ -6810,7 +6809,7 @@ var Trie = class {
6810
6809
  }
6811
6810
  };
6812
6811
  //#endregion
6813
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router/reg-exp-router/router.js
6812
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router/reg-exp-router/router.js
6814
6813
  var nullMatcher = [
6815
6814
  /^$/,
6816
6815
  [],
@@ -6941,7 +6940,7 @@ var RegExpRouter = class {
6941
6940
  }
6942
6941
  };
6943
6942
  //#endregion
6944
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router/smart-router/router.js
6943
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router/smart-router/router.js
6945
6944
  var SmartRouter = class {
6946
6945
  name = "SmartRouter";
6947
6946
  #routers = [];
@@ -6988,7 +6987,7 @@ var SmartRouter = class {
6988
6987
  }
6989
6988
  };
6990
6989
  //#endregion
6991
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router/trie-router/node.js
6990
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router/trie-router/node.js
6992
6991
  var emptyParams = /* @__PURE__ */ Object.create(null);
6993
6992
  var hasChildren = (children) => {
6994
6993
  for (const _ in children) return true;
@@ -7141,7 +7140,7 @@ var Node = class _Node {
7141
7140
  }
7142
7141
  };
7143
7142
  //#endregion
7144
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/router/trie-router/router.js
7143
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/router/trie-router/router.js
7145
7144
  var TrieRouter = class {
7146
7145
  name = "TrieRouter";
7147
7146
  #node;
@@ -7161,7 +7160,7 @@ var TrieRouter = class {
7161
7160
  }
7162
7161
  };
7163
7162
  //#endregion
7164
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/hono.js
7163
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/hono.js
7165
7164
  var Hono = class extends Hono$1 {
7166
7165
  /**
7167
7166
  * Creates an instance of the Hono class.
@@ -7202,7 +7201,7 @@ object({
7202
7201
  client_secret: string().optional()
7203
7202
  });
7204
7203
  //#endregion
7205
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/utils/stream.js
7204
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/utils/stream.js
7206
7205
  var StreamingApi = class {
7207
7206
  writer;
7208
7207
  encoder;
@@ -7275,7 +7274,7 @@ var StreamingApi = class {
7275
7274
  }
7276
7275
  };
7277
7276
  //#endregion
7278
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/helper/streaming/sse.js
7277
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/helper/streaming/sse.js
7279
7278
  var SSEStreamingApi = class extends StreamingApi {
7280
7279
  constructor(writable, readable) {
7281
7280
  super(writable, readable);
@@ -7299,7 +7298,7 @@ var SSEStreamingApi = class extends StreamingApi {
7299
7298
  }
7300
7299
  };
7301
7300
  //#endregion
7302
- //#region ../../node_modules/.pnpm/@hono+mcp@0.3.0_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__hono-rate-limiter@0.5.3_hono@4.12.19__hono@4.12.19_zod@4.4.3/node_modules/@hono/mcp/dist/index.js
7301
+ //#region ../../node_modules/.pnpm/@hono+mcp@0.3.0_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__hono-rate-limiter@0.5.3_hono@4.12.21__hono@4.12.21_zod@4.4.3/node_modules/@hono/mcp/dist/index.js
7303
7302
  let isOldBunVersion = () => {
7304
7303
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
7305
7304
  if (version === void 0) return false;
@@ -7740,36 +7739,56 @@ var StreamableHTTPTransport = class {
7740
7739
  }
7741
7740
  };
7742
7741
  //#endregion
7743
- //#region ../../node_modules/.pnpm/@hono+node-server@1.19.14_hono@4.12.19/node_modules/@hono/node-server/dist/index.mjs
7742
+ //#region ../../node_modules/.pnpm/@hono+node-server@2.0.3_hono@4.12.21/node_modules/@hono/node-server/dist/index.mjs
7744
7743
  var RequestError = class extends Error {
7745
7744
  constructor(message, options) {
7746
7745
  super(message, options);
7747
7746
  this.name = "RequestError";
7748
7747
  }
7749
7748
  };
7750
- var toRequestError = (e) => {
7749
+ const reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
7750
+ const reDotSegment = /\/\.\.?(?:[/?#]|$)/;
7751
+ const reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
7752
+ const buildUrl = (scheme, host, incomingUrl) => {
7753
+ const url = `${scheme}://${host}${incomingUrl}`;
7754
+ if (!reValidHost.test(host)) {
7755
+ const urlObj = new URL(url);
7756
+ if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase()) throw new RequestError("Invalid host header");
7757
+ return urlObj.href;
7758
+ } else if (incomingUrl.length === 0) return url + "/";
7759
+ else {
7760
+ if (incomingUrl.charCodeAt(0) !== 47) throw new RequestError("Invalid URL");
7761
+ if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) return new URL(url).href;
7762
+ return url;
7763
+ }
7764
+ };
7765
+ const toRequestError = (e) => {
7751
7766
  if (e instanceof RequestError) return e;
7752
7767
  return new RequestError(e.message, { cause: e });
7753
7768
  };
7754
- var GlobalRequest = global.Request;
7769
+ const GlobalRequest = global.Request;
7755
7770
  var Request$1 = class extends GlobalRequest {
7756
7771
  constructor(input, options) {
7757
- if (typeof input === "object" && getRequestCache in input) input = input[getRequestCache]();
7758
- if (typeof options?.body?.getReader !== "undefined") options.duplex ??= "half";
7772
+ if (typeof input === "object" && getRequestCache in input) {
7773
+ const hasReplacementBody = options !== void 0 && "body" in options && options.body != null;
7774
+ if (input[bodyConsumedDirectlyKey] && !hasReplacementBody) throw new TypeError("Cannot construct a Request with a Request object that has already been used.");
7775
+ input = input[getRequestCache]();
7776
+ }
7777
+ if (typeof (options?.body)?.getReader !== "undefined") options.duplex ??= "half";
7759
7778
  super(input, options);
7760
7779
  }
7761
7780
  };
7762
- var newHeadersFromIncoming = (incoming) => {
7781
+ const newHeadersFromIncoming = (incoming) => {
7763
7782
  const headerRecord = [];
7764
7783
  const rawHeaders = incoming.rawHeaders;
7765
- for (let i = 0; i < rawHeaders.length; i += 2) {
7766
- const { [i]: key, [i + 1]: value } = rawHeaders;
7767
- if (key.charCodeAt(0) !== 58) headerRecord.push([key, value]);
7784
+ for (let i = 0, len = rawHeaders.length; i < len; i += 2) {
7785
+ const key = rawHeaders[i];
7786
+ if (key.charCodeAt(0) !== 58) headerRecord.push([key, rawHeaders[i + 1]]);
7768
7787
  }
7769
7788
  return new Headers(headerRecord);
7770
7789
  };
7771
- var wrapBodyStream = Symbol("wrapBodyStream");
7772
- var newRequestFromIncoming = (method, url, headers, incoming, abortController) => {
7790
+ const wrapBodyStream = Symbol("wrapBodyStream");
7791
+ const newRequestFromIncoming = (method, url, headers, incoming, abortController) => {
7773
7792
  const init = {
7774
7793
  method,
7775
7794
  headers,
@@ -7802,15 +7821,162 @@ var newRequestFromIncoming = (method, url, headers, incoming, abortController) =
7802
7821
  } else init.body = Readable.toWeb(incoming);
7803
7822
  return new Request$1(url, init);
7804
7823
  };
7805
- var getRequestCache = Symbol("getRequestCache");
7806
- var requestCache = Symbol("requestCache");
7807
- var incomingKey = Symbol("incomingKey");
7808
- var urlKey = Symbol("urlKey");
7809
- var headersKey = Symbol("headersKey");
7810
- var abortControllerKey = Symbol("abortControllerKey");
7811
- var requestPrototype = {
7824
+ const getRequestCache = Symbol("getRequestCache");
7825
+ const requestCache = Symbol("requestCache");
7826
+ const incomingKey = Symbol("incomingKey");
7827
+ const urlKey = Symbol("urlKey");
7828
+ const methodKey = Symbol("methodKey");
7829
+ const headersKey = Symbol("headersKey");
7830
+ const abortControllerKey = Symbol("abortControllerKey");
7831
+ const getAbortController = Symbol("getAbortController");
7832
+ const abortRequest = Symbol("abortRequest");
7833
+ const bodyBufferKey = Symbol("bodyBuffer");
7834
+ const bodyReadPromiseKey = Symbol("bodyReadPromise");
7835
+ const bodyConsumedDirectlyKey = Symbol("bodyConsumedDirectly");
7836
+ const bodyLockReaderKey = Symbol("bodyLockReader");
7837
+ const abortReasonKey = Symbol("abortReason");
7838
+ const newBodyUnusableError = () => {
7839
+ return /* @__PURE__ */ new TypeError("Body is unusable");
7840
+ };
7841
+ const rejectBodyUnusable = () => {
7842
+ return Promise.reject(newBodyUnusableError());
7843
+ };
7844
+ const textDecoder = new TextDecoder();
7845
+ const consumeBodyDirectOnce = (request) => {
7846
+ if (request[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
7847
+ request[bodyConsumedDirectlyKey] = true;
7848
+ };
7849
+ const toArrayBuffer = (buf) => {
7850
+ return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
7851
+ };
7852
+ const contentType = (request) => {
7853
+ return (request[headersKey] ||= newHeadersFromIncoming(request[incomingKey])).get("content-type") || "";
7854
+ };
7855
+ const methodTokenRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
7856
+ const normalizeIncomingMethod = (method) => {
7857
+ if (typeof method !== "string" || method.length === 0) return "GET";
7858
+ switch (method) {
7859
+ case "DELETE":
7860
+ case "GET":
7861
+ case "HEAD":
7862
+ case "OPTIONS":
7863
+ case "POST":
7864
+ case "PUT": return method;
7865
+ }
7866
+ const upper = method.toUpperCase();
7867
+ switch (upper) {
7868
+ case "DELETE":
7869
+ case "GET":
7870
+ case "HEAD":
7871
+ case "OPTIONS":
7872
+ case "POST":
7873
+ case "PUT": return upper;
7874
+ default: return method;
7875
+ }
7876
+ };
7877
+ const validateDirectReadMethod = (method) => {
7878
+ if (!methodTokenRegExp.test(method)) return /* @__PURE__ */ new TypeError(`'${method}' is not a valid HTTP method.`);
7879
+ const normalized = method.toUpperCase();
7880
+ if (normalized === "CONNECT" || normalized === "TRACK" || normalized === "TRACE" && method !== "TRACE") return /* @__PURE__ */ new TypeError(`'${method}' HTTP method is unsupported.`);
7881
+ };
7882
+ const readBodyWithFastPath = (request, method, fromBuffer) => {
7883
+ if (request[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
7884
+ const methodName = request.method;
7885
+ if (methodName === "GET" || methodName === "HEAD") return request[getRequestCache]()[method]();
7886
+ const methodValidationError = validateDirectReadMethod(methodName);
7887
+ if (methodValidationError) return Promise.reject(methodValidationError);
7888
+ if (request[requestCache]) {
7889
+ if (methodName !== "TRACE") return request[requestCache][method]();
7890
+ }
7891
+ const alreadyUsedError = consumeBodyDirectOnce(request);
7892
+ if (alreadyUsedError) return alreadyUsedError;
7893
+ const raw = readRawBodyIfAvailable(request);
7894
+ if (raw) {
7895
+ const result = Promise.resolve(fromBuffer(raw, request));
7896
+ request[bodyBufferKey] = void 0;
7897
+ return result;
7898
+ }
7899
+ return readBodyDirect(request).then((buf) => {
7900
+ const result = fromBuffer(buf, request);
7901
+ request[bodyBufferKey] = void 0;
7902
+ return result;
7903
+ });
7904
+ };
7905
+ const readRawBodyIfAvailable = (request) => {
7906
+ const incoming = request[incomingKey];
7907
+ if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) return incoming.rawBody;
7908
+ };
7909
+ const readBodyDirect = (request) => {
7910
+ if (request[bodyBufferKey]) return Promise.resolve(request[bodyBufferKey]);
7911
+ if (request[bodyReadPromiseKey]) return request[bodyReadPromiseKey];
7912
+ const incoming = request[incomingKey];
7913
+ if (Readable.isDisturbed(incoming)) return rejectBodyUnusable();
7914
+ const promise = new Promise((resolve, reject) => {
7915
+ const chunks = [];
7916
+ let settled = false;
7917
+ const finish = (callback) => {
7918
+ if (settled) return;
7919
+ settled = true;
7920
+ cleanup();
7921
+ callback();
7922
+ };
7923
+ const onData = (chunk) => {
7924
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
7925
+ };
7926
+ const onEnd = () => {
7927
+ finish(() => {
7928
+ const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
7929
+ request[bodyBufferKey] = buffer;
7930
+ resolve(buffer);
7931
+ });
7932
+ };
7933
+ const onError = (error) => {
7934
+ finish(() => {
7935
+ reject(error);
7936
+ });
7937
+ };
7938
+ const onClose = () => {
7939
+ if (incoming.readableEnded) {
7940
+ onEnd();
7941
+ return;
7942
+ }
7943
+ finish(() => {
7944
+ if (incoming.errored) {
7945
+ reject(incoming.errored);
7946
+ return;
7947
+ }
7948
+ const reason = request[abortReasonKey];
7949
+ if (reason !== void 0) {
7950
+ reject(reason instanceof Error ? reason : new Error(String(reason)));
7951
+ return;
7952
+ }
7953
+ reject(/* @__PURE__ */ new Error("Client connection prematurely closed."));
7954
+ });
7955
+ };
7956
+ const cleanup = () => {
7957
+ incoming.off("data", onData);
7958
+ incoming.off("end", onEnd);
7959
+ incoming.off("error", onError);
7960
+ incoming.off("close", onClose);
7961
+ request[bodyReadPromiseKey] = void 0;
7962
+ };
7963
+ incoming.on("data", onData);
7964
+ incoming.on("end", onEnd);
7965
+ incoming.on("error", onError);
7966
+ incoming.on("close", onClose);
7967
+ queueMicrotask(() => {
7968
+ if (settled) return;
7969
+ if (incoming.readableEnded) onEnd();
7970
+ else if (incoming.errored) onError(incoming.errored);
7971
+ else if (incoming.destroyed) onClose();
7972
+ });
7973
+ });
7974
+ request[bodyReadPromiseKey] = promise;
7975
+ return promise;
7976
+ };
7977
+ const requestPrototype = {
7812
7978
  get method() {
7813
- return this[incomingKey].method || "GET";
7979
+ return this[methodKey];
7814
7980
  },
7815
7981
  get url() {
7816
7982
  return this[urlKey];
@@ -7818,18 +7984,57 @@ var requestPrototype = {
7818
7984
  get headers() {
7819
7985
  return this[headersKey] ||= newHeadersFromIncoming(this[incomingKey]);
7820
7986
  },
7821
- [Symbol("getAbortController")]() {
7822
- this[getRequestCache]();
7987
+ [abortRequest](reason) {
7988
+ if (this[abortReasonKey] === void 0) this[abortReasonKey] = reason;
7989
+ const abortController = this[abortControllerKey];
7990
+ if (abortController && !abortController.signal.aborted) abortController.abort(reason);
7991
+ },
7992
+ [getAbortController]() {
7993
+ this[abortControllerKey] ||= new AbortController();
7994
+ if (this[abortReasonKey] !== void 0 && !this[abortControllerKey].signal.aborted) this[abortControllerKey].abort(this[abortReasonKey]);
7823
7995
  return this[abortControllerKey];
7824
7996
  },
7825
7997
  [getRequestCache]() {
7826
- this[abortControllerKey] ||= new AbortController();
7827
- return this[requestCache] ||= newRequestFromIncoming(this.method, this[urlKey], this.headers, this[incomingKey], this[abortControllerKey]);
7998
+ const abortController = this[getAbortController]();
7999
+ if (this[requestCache]) return this[requestCache];
8000
+ const method = this.method;
8001
+ if (this[bodyConsumedDirectlyKey] && !(method === "GET" || method === "HEAD")) {
8002
+ this[bodyBufferKey] = void 0;
8003
+ const init = {
8004
+ method: method === "TRACE" ? "GET" : method,
8005
+ headers: this.headers,
8006
+ signal: abortController.signal
8007
+ };
8008
+ if (method !== "TRACE") {
8009
+ init.body = new ReadableStream({ start(c) {
8010
+ c.close();
8011
+ } });
8012
+ init.duplex = "half";
8013
+ }
8014
+ const req = new Request$1(this[urlKey], init);
8015
+ if (method === "TRACE") Object.defineProperty(req, "method", { get() {
8016
+ return "TRACE";
8017
+ } });
8018
+ return this[requestCache] = req;
8019
+ }
8020
+ return this[requestCache] = newRequestFromIncoming(this.method, this[urlKey], this.headers, this[incomingKey], abortController);
8021
+ },
8022
+ get body() {
8023
+ if (!this[bodyConsumedDirectlyKey]) return this[getRequestCache]().body;
8024
+ const request = this[getRequestCache]();
8025
+ if (!this[bodyLockReaderKey] && request.body) this[bodyLockReaderKey] = request.body.getReader();
8026
+ return request.body;
8027
+ },
8028
+ get bodyUsed() {
8029
+ if (this[bodyConsumedDirectlyKey]) return true;
8030
+ if (this[requestCache]) return this[requestCache].bodyUsed;
8031
+ return false;
7828
8032
  }
7829
8033
  };
8034
+ Object.defineProperty(requestPrototype, "signal", { get() {
8035
+ return this[getAbortController]().signal;
8036
+ } });
7830
8037
  [
7831
- "body",
7832
- "bodyUsed",
7833
8038
  "cache",
7834
8039
  "credentials",
7835
8040
  "destination",
@@ -7838,25 +8043,37 @@ var requestPrototype = {
7838
8043
  "redirect",
7839
8044
  "referrer",
7840
8045
  "referrerPolicy",
7841
- "signal",
7842
8046
  "keepalive"
7843
8047
  ].forEach((k) => {
7844
8048
  Object.defineProperty(requestPrototype, k, { get() {
7845
8049
  return this[getRequestCache]()[k];
7846
8050
  } });
7847
8051
  });
7848
- [
7849
- "arrayBuffer",
7850
- "blob",
7851
- "clone",
7852
- "formData",
7853
- "json",
7854
- "text"
7855
- ].forEach((k) => {
8052
+ ["clone", "formData"].forEach((k) => {
7856
8053
  Object.defineProperty(requestPrototype, k, { value: function() {
8054
+ if (this[bodyConsumedDirectlyKey]) {
8055
+ if (k === "clone") throw newBodyUnusableError();
8056
+ return rejectBodyUnusable();
8057
+ }
7857
8058
  return this[getRequestCache]()[k]();
7858
8059
  } });
7859
8060
  });
8061
+ Object.defineProperty(requestPrototype, "text", { value: function() {
8062
+ return readBodyWithFastPath(this, "text", (buf) => textDecoder.decode(buf));
8063
+ } });
8064
+ Object.defineProperty(requestPrototype, "arrayBuffer", { value: function() {
8065
+ return readBodyWithFastPath(this, "arrayBuffer", (buf) => toArrayBuffer(buf));
8066
+ } });
8067
+ Object.defineProperty(requestPrototype, "blob", { value: function() {
8068
+ return readBodyWithFastPath(this, "blob", (buf, request) => {
8069
+ const type = contentType(request);
8070
+ return new Response(buf, type ? { headers: { "content-type": type } } : void 0).blob();
8071
+ });
8072
+ } });
8073
+ Object.defineProperty(requestPrototype, "json", { value: function() {
8074
+ if (this[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
8075
+ return this.text().then(JSON.parse);
8076
+ } });
7860
8077
  Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
7861
8078
  return `Request (lightweight) ${inspectFn({
7862
8079
  method: this.method,
@@ -7869,9 +8086,10 @@ Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom")
7869
8086
  })}`;
7870
8087
  } });
7871
8088
  Object.setPrototypeOf(requestPrototype, Request$1.prototype);
7872
- var newRequest = (incoming, defaultHostname) => {
8089
+ const newRequest = (incoming, defaultHostname) => {
7873
8090
  const req = Object.create(requestPrototype);
7874
8091
  req[incomingKey] = incoming;
8092
+ req[methodKey] = normalizeIncomingMethod(incoming.method);
7875
8093
  const incomingUrl = incoming.url || "";
7876
8094
  if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
7877
8095
  if (incoming instanceof Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
@@ -7889,26 +8107,35 @@ var newRequest = (incoming, defaultHostname) => {
7889
8107
  scheme = incoming.scheme;
7890
8108
  if (!(scheme === "http" || scheme === "https")) throw new RequestError("Unsupported scheme");
7891
8109
  } else scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
7892
- const url = new URL(`${scheme}://${host}${incomingUrl}`);
7893
- if (url.hostname.length !== host.length && url.hostname !== host.replace(/:\d+$/, "")) throw new RequestError("Invalid host header");
7894
- req[urlKey] = url.href;
8110
+ try {
8111
+ req[urlKey] = buildUrl(scheme, host, incomingUrl);
8112
+ } catch (e) {
8113
+ if (e instanceof RequestError) throw e;
8114
+ else throw new RequestError("Invalid URL", { cause: e });
8115
+ }
7895
8116
  return req;
7896
8117
  };
7897
- var responseCache = Symbol("responseCache");
7898
- var getResponseCache = Symbol("getResponseCache");
7899
- var cacheKey = Symbol("cache");
7900
- var GlobalResponse = global.Response;
7901
- var Response2 = class _Response {
8118
+ const defaultContentType = "text/plain; charset=UTF-8";
8119
+ const responseCache = Symbol("responseCache");
8120
+ const getResponseCache = Symbol("getResponseCache");
8121
+ const cacheKey = Symbol("cache");
8122
+ const GlobalResponse = global.Response;
8123
+ var Response$1 = class Response$1 {
7902
8124
  #body;
7903
8125
  #init;
7904
8126
  [getResponseCache]() {
8127
+ const cache = this[cacheKey];
8128
+ const liveHeaders = cache && cache[2] instanceof Headers ? cache[2] : void 0;
7905
8129
  delete this[cacheKey];
7906
- return this[responseCache] ||= new GlobalResponse(this.#body, this.#init);
8130
+ return this[responseCache] ||= new GlobalResponse(this.#body, liveHeaders ? {
8131
+ ...this.#init,
8132
+ headers: liveHeaders
8133
+ } : this.#init);
7907
8134
  }
7908
8135
  constructor(body, init) {
7909
8136
  let headers;
7910
8137
  this.#body = body;
7911
- if (init instanceof _Response) {
8138
+ if (init instanceof Response$1) {
7912
8139
  const cachedGlobalResponse = init[responseCache];
7913
8140
  if (cachedGlobalResponse) {
7914
8141
  this.#init = cachedGlobalResponse;
@@ -7916,19 +8143,19 @@ var Response2 = class _Response {
7916
8143
  return;
7917
8144
  } else {
7918
8145
  this.#init = init.#init;
7919
- headers = new Headers(init.#init.headers);
8146
+ headers = new Headers(init.headers);
7920
8147
  }
7921
8148
  } else this.#init = init;
7922
- if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
8149
+ if (body == null || typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
7923
8150
  init?.status || 200,
7924
- body,
8151
+ body ?? null,
7925
8152
  headers || init?.headers
7926
8153
  ];
7927
8154
  }
7928
8155
  get headers() {
7929
8156
  const cache = this[cacheKey];
7930
8157
  if (cache) {
7931
- if (!(cache[2] instanceof Headers)) cache[2] = new Headers(cache[2] || { "content-type": "text/plain; charset=UTF-8" });
8158
+ if (!(cache[2] instanceof Headers)) cache[2] = new Headers(cache[2] || (cache[1] === null ? void 0 : { "content-type": defaultContentType }));
7932
8159
  return cache[2];
7933
8160
  }
7934
8161
  return this[getResponseCache]().headers;
@@ -7950,7 +8177,7 @@ var Response2 = class _Response {
7950
8177
  "type",
7951
8178
  "url"
7952
8179
  ].forEach((k) => {
7953
- Object.defineProperty(Response2.prototype, k, { get() {
8180
+ Object.defineProperty(Response$1.prototype, k, { get() {
7954
8181
  return this[getResponseCache]()[k];
7955
8182
  } });
7956
8183
  });
@@ -7962,11 +8189,11 @@ var Response2 = class _Response {
7962
8189
  "json",
7963
8190
  "text"
7964
8191
  ].forEach((k) => {
7965
- Object.defineProperty(Response2.prototype, k, { value: function() {
8192
+ Object.defineProperty(Response$1.prototype, k, { value: function() {
7966
8193
  return this[getResponseCache]()[k]();
7967
8194
  } });
7968
8195
  });
7969
- Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
8196
+ Object.defineProperty(Response$1.prototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
7970
8197
  return `Response (lightweight) ${inspectFn({
7971
8198
  status: this.status,
7972
8199
  headers: this.headers,
@@ -7977,8 +8204,51 @@ Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custo
7977
8204
  depth: depth == null ? null : depth - 1
7978
8205
  })}`;
7979
8206
  } });
7980
- Object.setPrototypeOf(Response2, GlobalResponse);
7981
- Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
8207
+ Object.setPrototypeOf(Response$1, GlobalResponse);
8208
+ Object.setPrototypeOf(Response$1.prototype, GlobalResponse.prototype);
8209
+ const validRedirectUrl = /^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/;
8210
+ const parseRedirectUrl = (url) => {
8211
+ if (url instanceof URL) return url.href;
8212
+ if (validRedirectUrl.test(url)) return url;
8213
+ return new URL(url).href;
8214
+ };
8215
+ const validRedirectStatuses = new Set([
8216
+ 301,
8217
+ 302,
8218
+ 303,
8219
+ 307,
8220
+ 308
8221
+ ]);
8222
+ Object.defineProperty(Response$1, "redirect", {
8223
+ value: function redirect(url, status = 302) {
8224
+ if (!validRedirectStatuses.has(status)) throw new RangeError("Invalid status code");
8225
+ return new Response$1(null, {
8226
+ status,
8227
+ headers: { location: parseRedirectUrl(url) }
8228
+ });
8229
+ },
8230
+ writable: true,
8231
+ configurable: true
8232
+ });
8233
+ Object.defineProperty(Response$1, "json", {
8234
+ value: function json(data, init) {
8235
+ const body = JSON.stringify(data);
8236
+ if (body === void 0) throw new TypeError("The data is not JSON serializable");
8237
+ const initHeaders = init?.headers;
8238
+ let headers;
8239
+ if (initHeaders) {
8240
+ headers = new Headers(initHeaders);
8241
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
8242
+ } else headers = { "content-type": "application/json" };
8243
+ return new Response$1(body, {
8244
+ status: init?.status ?? 200,
8245
+ statusText: init?.statusText,
8246
+ headers
8247
+ });
8248
+ },
8249
+ writable: true,
8250
+ configurable: true
8251
+ });
7982
8252
  async function readWithoutBlocking(readPromise) {
7983
8253
  return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
7984
8254
  }
@@ -8014,23 +8284,23 @@ function writeFromReadableStream(stream, writable) {
8014
8284
  else if (writable.destroyed) return;
8015
8285
  return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
8016
8286
  }
8017
- var buildOutgoingHttpHeaders = (headers) => {
8287
+ const buildOutgoingHttpHeaders = (headers, defaultContentType) => {
8018
8288
  const res = {};
8019
8289
  if (!(headers instanceof Headers)) headers = new Headers(headers ?? void 0);
8020
- const cookies = [];
8021
- for (const [k, v] of headers) if (k === "set-cookie") cookies.push(v);
8022
- else res[k] = v;
8023
- if (cookies.length > 0) res["set-cookie"] = cookies;
8024
- res["content-type"] ??= "text/plain; charset=UTF-8";
8290
+ if (headers.has("set-cookie")) {
8291
+ const cookies = [];
8292
+ for (const [k, v] of headers) if (k === "set-cookie") cookies.push(v);
8293
+ else res[k] = v;
8294
+ if (cookies.length > 0) res["set-cookie"] = cookies;
8295
+ } else for (const [k, v] of headers) res[k] = v;
8296
+ if (defaultContentType) res["content-type"] ??= defaultContentType;
8025
8297
  return res;
8026
8298
  };
8027
- var X_ALREADY_SENT = "x-hono-already-sent";
8028
- if (typeof global.crypto === "undefined") global.crypto = crypto$1;
8029
- var outgoingEnded = Symbol("outgoingEnded");
8030
- var incomingDraining = Symbol("incomingDraining");
8031
- var DRAIN_TIMEOUT_MS = 500;
8032
- var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
8033
- var drainIncoming = (incoming) => {
8299
+ const outgoingEnded = Symbol("outgoingEnded");
8300
+ const incomingDraining = Symbol("incomingDraining");
8301
+ const DRAIN_TIMEOUT_MS = 500;
8302
+ const MAX_DRAIN_BYTES = 64 * 1024 * 1024;
8303
+ const drainIncoming = (incoming) => {
8034
8304
  const incomingWithDrainState = incoming;
8035
8305
  if (incoming.destroyed || incomingWithDrainState[incomingDraining]) return;
8036
8306
  incomingWithDrainState[incomingDraining] = true;
@@ -8063,9 +8333,23 @@ var drainIncoming = (incoming) => {
8063
8333
  incoming.on("error", cleanup);
8064
8334
  incoming.resume();
8065
8335
  };
8066
- var handleRequestError = () => new Response(null, { status: 400 });
8067
- var handleFetchError = (e) => new Response(null, { status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500 });
8068
- var handleResponseError = (e, outgoing) => {
8336
+ const makeCloseHandler = (req, incoming, outgoing, needsBodyCleanup) => () => {
8337
+ if (incoming.errored) req[abortRequest](incoming.errored.toString());
8338
+ else if (!outgoing.writableFinished) req[abortRequest]("Client connection prematurely closed.");
8339
+ if (needsBodyCleanup && !incoming.readableEnded) setTimeout(() => {
8340
+ if (!incoming.readableEnded) setTimeout(() => {
8341
+ drainIncoming(incoming);
8342
+ });
8343
+ });
8344
+ };
8345
+ const isImmediateCacheableResponse = (res) => {
8346
+ if (!(cacheKey in res)) return false;
8347
+ const body = res[cacheKey][1];
8348
+ return body === null || typeof body === "string" || body instanceof Uint8Array;
8349
+ };
8350
+ const handleRequestError = () => new Response(null, { status: 400 });
8351
+ const handleFetchError = (e) => new Response(null, { status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500 });
8352
+ const handleResponseError = (e, outgoing) => {
8069
8353
  const err = e instanceof Error ? e : new Error("unknown error", { cause: e });
8070
8354
  if (err.code === "ERR_STREAM_PREMATURE_CLOSE") console.info("The user aborted a request.");
8071
8355
  else {
@@ -8075,20 +8359,49 @@ var handleResponseError = (e, outgoing) => {
8075
8359
  outgoing.destroy(err);
8076
8360
  }
8077
8361
  };
8078
- var flushHeaders = (outgoing) => {
8362
+ const flushHeaders = (outgoing) => {
8079
8363
  if ("flushHeaders" in outgoing && outgoing.writable) outgoing.flushHeaders();
8080
8364
  };
8081
- var responseViaCache = async (res, outgoing) => {
8365
+ const responseViaCache = async (res, outgoing) => {
8082
8366
  let [status, body, header] = res[cacheKey];
8367
+ if (!header) {
8368
+ if (body === null) {
8369
+ outgoing.writeHead(status);
8370
+ outgoing.end();
8371
+ } else if (typeof body === "string") {
8372
+ outgoing.writeHead(status, {
8373
+ "Content-Type": defaultContentType,
8374
+ "Content-Length": Buffer.byteLength(body)
8375
+ });
8376
+ outgoing.end(body);
8377
+ } else if (body instanceof Uint8Array) {
8378
+ outgoing.writeHead(status, {
8379
+ "Content-Type": defaultContentType,
8380
+ "Content-Length": body.byteLength
8381
+ });
8382
+ outgoing.end(body);
8383
+ } else if (body instanceof Blob) {
8384
+ outgoing.writeHead(status, {
8385
+ "Content-Type": defaultContentType,
8386
+ "Content-Length": body.size
8387
+ });
8388
+ outgoing.end(new Uint8Array(await body.arrayBuffer()));
8389
+ } else {
8390
+ outgoing.writeHead(status, { "Content-Type": defaultContentType });
8391
+ flushHeaders(outgoing);
8392
+ await writeFromReadableStream(body, outgoing)?.catch((e) => handleResponseError(e, outgoing));
8393
+ }
8394
+ outgoing[outgoingEnded]?.();
8395
+ return;
8396
+ }
8083
8397
  let hasContentLength = false;
8084
- if (!header) header = { "content-type": "text/plain; charset=UTF-8" };
8085
- else if (header instanceof Headers) {
8398
+ if (header instanceof Headers) {
8086
8399
  hasContentLength = header.has("content-length");
8087
- header = buildOutgoingHttpHeaders(header);
8400
+ header = buildOutgoingHttpHeaders(header, body === null ? void 0 : defaultContentType);
8088
8401
  } else if (Array.isArray(header)) {
8089
8402
  const headerObj = new Headers(header);
8090
8403
  hasContentLength = headerObj.has("content-length");
8091
- header = buildOutgoingHttpHeaders(headerObj);
8404
+ header = buildOutgoingHttpHeaders(headerObj, body === null ? void 0 : defaultContentType);
8092
8405
  } else for (const key in header) if (key.length === 14 && key.toLowerCase() === "content-length") {
8093
8406
  hasContentLength = true;
8094
8407
  break;
@@ -8099,7 +8412,8 @@ var responseViaCache = async (res, outgoing) => {
8099
8412
  else if (body instanceof Blob) header["Content-Length"] = body.size;
8100
8413
  }
8101
8414
  outgoing.writeHead(status, header);
8102
- if (typeof body === "string" || body instanceof Uint8Array) outgoing.end(body);
8415
+ if (body == null) outgoing.end();
8416
+ else if (typeof body === "string" || body instanceof Uint8Array) outgoing.end(body);
8103
8417
  else if (body instanceof Blob) outgoing.end(new Uint8Array(await body.arrayBuffer()));
8104
8418
  else {
8105
8419
  flushHeaders(outgoing);
@@ -8107,8 +8421,8 @@ var responseViaCache = async (res, outgoing) => {
8107
8421
  }
8108
8422
  outgoing[outgoingEnded]?.();
8109
8423
  };
8110
- var isPromise = (res) => typeof res.then === "function";
8111
- var responseViaResponseObject = async (res, outgoing, options = {}) => {
8424
+ const isPromise = (res) => typeof res.then === "function";
8425
+ const responseViaResponseObject = async (res, outgoing, options = {}) => {
8112
8426
  if (isPromise(res)) if (options.errorHandler) try {
8113
8427
  res = await res;
8114
8428
  } catch (err) {
@@ -8118,7 +8432,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
8118
8432
  }
8119
8433
  else res = await res.catch(handleFetchError);
8120
8434
  if (cacheKey in res) return responseViaCache(res, outgoing);
8121
- const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
8435
+ const resHeaderRecord = buildOutgoingHttpHeaders(res.headers, res.body === null ? void 0 : defaultContentType);
8122
8436
  if (res.body) {
8123
8437
  const reader = res.body.getReader();
8124
8438
  const values = [];
@@ -8158,57 +8472,55 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
8158
8472
  if (values.length === 0) flushHeaders(outgoing);
8159
8473
  await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
8160
8474
  }
8161
- } else if (resHeaderRecord[X_ALREADY_SENT]) {} else {
8475
+ } else if (resHeaderRecord["x-hono-already-sent"]) {} else {
8162
8476
  outgoing.writeHead(res.status, resHeaderRecord);
8163
8477
  outgoing.end();
8164
8478
  }
8165
8479
  outgoing[outgoingEnded]?.();
8166
8480
  };
8167
- var getRequestListener = (fetchCallback, options = {}) => {
8481
+ const getRequestListener = (fetchCallback, options = {}) => {
8168
8482
  const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
8169
8483
  if (options.overrideGlobalObjects !== false && global.Request !== Request$1) {
8170
8484
  Object.defineProperty(global, "Request", { value: Request$1 });
8171
- Object.defineProperty(global, "Response", { value: Response2 });
8485
+ Object.defineProperty(global, "Response", { value: Response$1 });
8172
8486
  }
8173
8487
  return async (incoming, outgoing) => {
8174
8488
  let res, req;
8489
+ let needsBodyCleanup = false;
8490
+ let closeHandlerAttached = false;
8491
+ const ensureCloseHandler = () => {
8492
+ if (!req || closeHandlerAttached) return;
8493
+ closeHandlerAttached = true;
8494
+ outgoing.on("close", makeCloseHandler(req, incoming, outgoing, needsBodyCleanup));
8495
+ };
8175
8496
  try {
8176
8497
  req = newRequest(incoming, options.hostname);
8177
- let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
8178
- if (!incomingEnded) {
8498
+ needsBodyCleanup = autoCleanupIncoming && !(incoming.method === "GET" || incoming.method === "HEAD");
8499
+ if (needsBodyCleanup) {
8179
8500
  incoming[wrapBodyStream] = true;
8180
- incoming.on("end", () => {
8181
- incomingEnded = true;
8182
- });
8183
8501
  if (incoming instanceof Http2ServerRequest) outgoing[outgoingEnded] = () => {
8184
- if (!incomingEnded) setTimeout(() => {
8185
- if (!incomingEnded) setTimeout(() => {
8186
- drainIncoming(incoming);
8502
+ if (!incoming.readableEnded) setTimeout(() => {
8503
+ if (!incoming.readableEnded) setTimeout(() => {
8504
+ incoming.destroy();
8505
+ outgoing.destroy();
8187
8506
  });
8188
8507
  });
8189
8508
  };
8190
- outgoing.on("finish", () => {
8191
- if (!incomingEnded) drainIncoming(incoming);
8192
- });
8193
8509
  }
8194
- outgoing.on("close", () => {
8195
- if (req[abortControllerKey]) {
8196
- if (incoming.errored) req[abortControllerKey].abort(incoming.errored.toString());
8197
- else if (!outgoing.writableFinished) req[abortControllerKey].abort("Client connection prematurely closed.");
8198
- }
8199
- if (!incomingEnded) setTimeout(() => {
8200
- if (!incomingEnded) setTimeout(() => {
8201
- drainIncoming(incoming);
8202
- });
8203
- });
8204
- });
8205
8510
  res = fetchCallback(req, {
8206
8511
  incoming,
8207
8512
  outgoing
8208
8513
  });
8209
- if (cacheKey in res) return responseViaCache(res, outgoing);
8514
+ if (!isPromise(res) && isImmediateCacheableResponse(res)) {
8515
+ if (needsBodyCleanup && !incoming.readableEnded) outgoing.once("finish", () => {
8516
+ if (!incoming.readableEnded) drainIncoming(incoming);
8517
+ });
8518
+ return responseViaCache(res, outgoing);
8519
+ }
8520
+ ensureCloseHandler();
8210
8521
  } catch (e) {
8211
8522
  if (!res) if (options.errorHandler) {
8523
+ ensureCloseHandler();
8212
8524
  res = await options.errorHandler(req ? e : toRequestError(e));
8213
8525
  if (!res) return;
8214
8526
  } else if (!req) res = handleRequestError();
@@ -8222,16 +8534,126 @@ var getRequestListener = (fetchCallback, options = {}) => {
8222
8534
  }
8223
8535
  };
8224
8536
  };
8225
- var createAdaptorServer = (options) => {
8537
+ globalThis.CloseEvent;
8538
+ const CONNECTION_SYMBOL_KEY = Symbol("CONNECTION_SYMBOL_KEY");
8539
+ const WAIT_FOR_WEBSOCKET_SYMBOL = Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");
8540
+ const responseHeadersToSkip = new Set([
8541
+ "connection",
8542
+ "content-length",
8543
+ "keep-alive",
8544
+ "proxy-authenticate",
8545
+ "proxy-authorization",
8546
+ "te",
8547
+ "trailer",
8548
+ "transfer-encoding",
8549
+ "upgrade",
8550
+ "sec-websocket-accept",
8551
+ "sec-websocket-extensions",
8552
+ "sec-websocket-protocol"
8553
+ ]);
8554
+ const appendResponseHeaders = (headers, responseHeaders) => {
8555
+ if (!responseHeaders) return;
8556
+ responseHeaders.forEach((value, key) => {
8557
+ if (responseHeadersToSkip.has(key.toLowerCase())) return;
8558
+ headers.push(`${key}: ${value}`);
8559
+ });
8560
+ };
8561
+ const rejectUpgradeRequest = (socket, status, responseHeaders) => {
8562
+ const responseLines = ["Connection: close", "Content-Length: 0"];
8563
+ appendResponseHeaders(responseLines, responseHeaders);
8564
+ socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r\n${responseLines.join("\r\n")}\r\n\r
8565
+ `);
8566
+ };
8567
+ const createUpgradeRequest = (request) => {
8568
+ const protocol = request.socket.encrypted ? "https" : "http";
8569
+ const url = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
8570
+ const headers = new Headers();
8571
+ for (const key in request.headers) {
8572
+ const value = request.headers[key];
8573
+ if (!value) continue;
8574
+ headers.append(key, Array.isArray(value) ? value[0] : value);
8575
+ }
8576
+ return new Request(url, { headers });
8577
+ };
8578
+ const setupWebSocket = (options) => {
8579
+ const { server, fetchCallback, wss } = options;
8580
+ const waiterMap = /* @__PURE__ */ new Map();
8581
+ wss.on("connection", (ws, request) => {
8582
+ const waiter = waiterMap.get(request);
8583
+ if (waiter) {
8584
+ waiter.resolve(ws);
8585
+ waiterMap.delete(request);
8586
+ }
8587
+ });
8588
+ const waitForWebSocket = (request, connectionSymbol) => {
8589
+ return new Promise((resolve) => {
8590
+ waiterMap.set(request, {
8591
+ resolve,
8592
+ connectionSymbol
8593
+ });
8594
+ });
8595
+ };
8596
+ server.on("upgrade", async (request, socket, head) => {
8597
+ if (request.headers.upgrade?.toLowerCase() !== "websocket") return;
8598
+ const env = {
8599
+ incoming: request,
8600
+ outgoing: void 0,
8601
+ wss,
8602
+ [WAIT_FOR_WEBSOCKET_SYMBOL]: waitForWebSocket
8603
+ };
8604
+ let status = 400;
8605
+ let responseHeaders;
8606
+ try {
8607
+ const response = await fetchCallback(createUpgradeRequest(request), env);
8608
+ if (response instanceof Response) {
8609
+ status = response.status;
8610
+ responseHeaders = response.headers;
8611
+ }
8612
+ } catch {
8613
+ if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
8614
+ return;
8615
+ }
8616
+ const waiter = waiterMap.get(request);
8617
+ if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY]) {
8618
+ waiterMap.delete(request);
8619
+ if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, status, responseHeaders);
8620
+ return;
8621
+ }
8622
+ const addResponseHeaders = (headers) => {
8623
+ appendResponseHeaders(headers, responseHeaders);
8624
+ };
8625
+ wss.on("headers", addResponseHeaders);
8626
+ try {
8627
+ wss.handleUpgrade(request, socket, head, (ws) => {
8628
+ wss.emit("connection", ws, request);
8629
+ });
8630
+ } finally {
8631
+ wss.off("headers", addResponseHeaders);
8632
+ }
8633
+ });
8634
+ server.on("close", () => {
8635
+ wss.close();
8636
+ });
8637
+ };
8638
+ const createAdaptorServer = (options) => {
8226
8639
  const fetchCallback = options.fetch;
8227
8640
  const requestListener = getRequestListener(fetchCallback, {
8228
8641
  hostname: options.hostname,
8229
8642
  overrideGlobalObjects: options.overrideGlobalObjects,
8230
8643
  autoCleanupIncoming: options.autoCleanupIncoming
8231
8644
  });
8232
- return (options.createServer || createServer)(options.serverOptions || {}, requestListener);
8645
+ const server = (options.createServer || createServer)(options.serverOptions || {}, requestListener);
8646
+ if (options.websocket && options.websocket.server) {
8647
+ if (options.websocket.server.options.noServer !== true) throw new Error("WebSocket server must be created with { noServer: true } option");
8648
+ setupWebSocket({
8649
+ server,
8650
+ fetchCallback,
8651
+ wss: options.websocket.server
8652
+ });
8653
+ }
8654
+ return server;
8233
8655
  };
8234
- var serve = (options, listeningListener) => {
8656
+ const serve = (options, listeningListener) => {
8235
8657
  const server = createAdaptorServer(options);
8236
8658
  server.listen(options?.port ?? 3e3, options.hostname, () => {
8237
8659
  const serverInfo = server.address();
@@ -8240,7 +8662,7 @@ var serve = (options, listeningListener) => {
8240
8662
  return server;
8241
8663
  };
8242
8664
  //#endregion
8243
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/utils/color.js
8665
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/utils/color.js
8244
8666
  function getColorEnabled() {
8245
8667
  const { process, Deno } = globalThis;
8246
8668
  return !(typeof Deno?.noColor === "boolean" ? Deno.noColor : process !== void 0 ? "NO_COLOR" in process?.env : false);
@@ -8257,7 +8679,7 @@ async function getColorEnabledAsync() {
8257
8679
  })() : !getColorEnabled());
8258
8680
  }
8259
8681
  //#endregion
8260
- //#region ../../node_modules/.pnpm/hono@4.12.19/node_modules/hono/dist/middleware/logger/index.js
8682
+ //#region ../../node_modules/.pnpm/hono@4.12.21/node_modules/hono/dist/middleware/logger/index.js
8261
8683
  var humanize = (times) => {
8262
8684
  const [delimiter, separator] = [",", "."];
8263
8685
  return times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter)).join(separator);
package/dist/native.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Ot as CapletsError, Q as ToolListChangedNotificationSchema, _ as StreamableHTTPClientTransport, a as resolveCapletsServer, b as Client, i as resolveCapletsMode, l as capabilityDescription, n as mcpUrlForBase, o as CapletsEngine } from "./options-DM1cMRcp.js";
2
- import { a as generatedToolInputJsonSchemaForCaplet, i as generatedToolInputJsonSchema, l as operations, o as generatedToolInputSchema } from "./generated-tool-input-schema-B6rce396.js";
1
+ import { Ot as CapletsError, Q as ToolListChangedNotificationSchema, _ as StreamableHTTPClientTransport, a as resolveCapletsServer, b as Client, i as resolveCapletsMode, l as capabilityDescription, n as mcpUrlForBase, o as CapletsEngine } from "./options-BqibJVxq.js";
2
+ import { a as generatedToolInputJsonSchemaForCaplet, i as generatedToolInputJsonSchema, l as operations, o as generatedToolInputSchema } from "./generated-tool-input-schema-BYoyY-l-.js";
3
3
  //#region src/native/options.ts
4
4
  const DEFAULT_POLL_INTERVAL_MS = 3e4;
5
5
  function resolveNativeCapletsServiceOptions(input = {}, env = process.env) {
@@ -1,4 +1,4 @@
1
- import { A as url, B as clone, C as object$1, D as string, E as record, F as $ZodType, H as normalizeParams, I as parse$2, L as parseAsync, M as toJSONSchema, N as _coercedNumber, O as union, P as $ZodObject, R as safeParse$1, S as number$1, T as preprocess, U as $constructor, V as defineLazy, W as NEVER, _ as custom, b as literal, c as mcpOperations, f as _enum, g as boolean, h as array, i as generatedToolInputJsonSchema, j as datetime, k as unknown, l as operations, m as any, p as _null, s as generatedToolInputSchemaForCaplet, u as ZodNumber$1, v as discriminatedUnion, w as optional, x as looseObject, y as intersection, z as safeParseAsync$1 } from "./generated-tool-input-schema-B6rce396.js";
1
+ import { A as url, B as clone, C as object$1, D as string, E as record, F as $ZodType, H as normalizeParams, I as parse$2, L as parseAsync, M as toJSONSchema, N as _coercedNumber, O as union, P as $ZodObject, R as safeParse$1, S as number$1, T as preprocess, U as $constructor, V as defineLazy, W as NEVER, _ as custom, b as literal, c as mcpOperations, f as _enum, g as boolean, h as array, i as generatedToolInputJsonSchema, j as datetime, k as unknown, l as operations, m as any, p as _null, s as generatedToolInputSchemaForCaplet, u as ZodNumber$1, v as discriminatedUnion, w as optional, x as looseObject, y as intersection, z as safeParseAsync$1 } from "./generated-tool-input-schema-BYoyY-l-.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { accessSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
4
4
  import minpath, { basename, delimiter, dirname, extname, isAbsolute, join, parse, posix, relative, resolve, win32 } from "node:path";
@@ -53853,7 +53853,7 @@ var CapletsEngine = class {
53853
53853
  }
53854
53854
  }
53855
53855
  async completeCliWords(words) {
53856
- const { completeCliWords } = await import("./completion-CxGG6ae3.js").then((n) => n.r);
53856
+ const { completeCliWords } = await import("./completion-dbB1hc97.js").then((n) => n.r);
53857
53857
  return await completeCliWords(words, {
53858
53858
  config: this.registry.config,
53859
53859
  managers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caplets/core",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Core runtime library for Caplets progressive disclosure gateways.",
5
5
  "keywords": [
6
6
  "caplets",
@@ -46,21 +46,21 @@
46
46
  "dependencies": {
47
47
  "@apidevtools/swagger-parser": "^12.1.0",
48
48
  "@hono/mcp": "^0.3.0",
49
- "@hono/node-server": "^1.19.14",
49
+ "@hono/node-server": "^2.0.3",
50
50
  "@modelcontextprotocol/sdk": "^1.29.0",
51
51
  "commander": "^14.0.3",
52
52
  "graphql": "^16.14.0",
53
- "hono": "^4.12.19",
53
+ "hono": "^4.12.21",
54
54
  "vfile": "^6.0.3",
55
55
  "vfile-matter": "^5.0.1",
56
56
  "zod": "^4.4.3"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/node": "^25.9.0",
60
- "@typescript/native-preview": "7.0.0-dev.20260518.1",
61
- "rolldown": "^1.0.1",
59
+ "@types/node": "^25.9.1",
60
+ "@typescript/native-preview": "7.0.0-dev.20260519.1",
61
+ "rolldown": "^1.0.2",
62
62
  "typescript": "^6.0.3",
63
- "vitest": "^4.1.6"
63
+ "vitest": "^4.1.7"
64
64
  },
65
65
  "engines": {
66
66
  "node": ">=22"