@cerefox/memory 0.11.0 → 1.0.0-beta.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.
Files changed (42) hide show
  1. package/AGENT_GUIDE.md +1 -1
  2. package/AGENT_QUICK_REFERENCE.md +1 -1
  3. package/dist/bin/cerefox.js +1089 -846
  4. package/dist/frontend/assets/index-CCkg5PXt.js +125 -0
  5. package/dist/frontend/assets/index-CCkg5PXt.js.map +1 -0
  6. package/dist/frontend/index.html +1 -1
  7. package/dist/server-assets/_shared/ef-auth/index.ts +134 -0
  8. package/dist/server-assets/_shared/ef-meta/index.ts +1 -1
  9. package/dist/server-assets/_shared/embeddings/index.ts +42 -2
  10. package/dist/server-assets/_shared/ingest/chunker.ts +210 -0
  11. package/dist/server-assets/_shared/ingest/index.ts +32 -0
  12. package/dist/server-assets/_shared/ingest/pipeline-helpers.ts +135 -0
  13. package/dist/server-assets/_shared/mcp-auth/index.ts +352 -0
  14. package/dist/server-assets/_shared/mcp-tools/_chunker.ts +16 -170
  15. package/dist/server-assets/_shared/mcp-tools/get-help-content.ts +2 -2
  16. package/dist/server-assets/_shared/mcp-tools/ingest.ts +17 -5
  17. package/dist/server-assets/db/migrations/0012_content_format.sql +20 -0
  18. package/dist/server-assets/db/rpcs.sql +88 -13
  19. package/dist/server-assets/db/schema.sql +7 -1
  20. package/dist/server-assets/supabase/functions/cerefox-get-audit-log/index.ts +8 -0
  21. package/dist/server-assets/supabase/functions/cerefox-get-document/index.ts +8 -0
  22. package/dist/server-assets/supabase/functions/cerefox-ingest/index.ts +29 -173
  23. package/dist/server-assets/supabase/functions/cerefox-list-projects/index.ts +8 -0
  24. package/dist/server-assets/supabase/functions/cerefox-list-versions/index.ts +8 -0
  25. package/dist/server-assets/supabase/functions/cerefox-mcp/index.ts +54 -0
  26. package/dist/server-assets/supabase/functions/cerefox-mcp/oauth.ts +121 -0
  27. package/dist/server-assets/supabase/functions/cerefox-metadata/index.ts +8 -0
  28. package/dist/server-assets/supabase/functions/cerefox-metadata-search/index.ts +8 -0
  29. package/dist/server-assets/supabase/functions/cerefox-search/index.ts +11 -1
  30. package/docs/guides/access-paths.md +81 -30
  31. package/docs/guides/cli.md +32 -3
  32. package/docs/guides/configuration.md +4 -1
  33. package/docs/guides/connect-agents.md +102 -54
  34. package/docs/guides/content-format.md +55 -0
  35. package/docs/guides/migration-1.0.md +87 -0
  36. package/docs/guides/ops-scripts.md +1 -1
  37. package/docs/guides/quickstart.md +20 -0
  38. package/docs/guides/setup-supabase.md +154 -13
  39. package/docs/guides/upgrading.md +4 -3
  40. package/package.json +1 -1
  41. package/dist/frontend/assets/index-ojNhWSxm.js +0 -125
  42. package/dist/frontend/assets/index-ojNhWSxm.js.map +0 -1
@@ -7184,7 +7184,7 @@ var exports_meta = {};
7184
7184
  __export(exports_meta, {
7185
7185
  PKG_VERSION: () => PKG_VERSION
7186
7186
  });
7187
- var PKG_VERSION = "0.11.0";
7187
+ var PKG_VERSION = "1.0.0-beta.1";
7188
7188
  var init_meta = () => {};
7189
7189
 
7190
7190
  // ../../node_modules/.bun/tslib@2.8.1/node_modules/tslib/tslib.js
@@ -7792,7 +7792,7 @@ var require_tslib = __commonJS((exports, module) => {
7792
7792
  });
7793
7793
  });
7794
7794
 
7795
- // ../../node_modules/.bun/@supabase+functions-js@2.108.1/node_modules/@supabase/functions-js/dist/main/helper.js
7795
+ // ../../node_modules/.bun/@supabase+functions-js@2.110.2/node_modules/@supabase/functions-js/dist/main/helper.js
7796
7796
  var require_helper = __commonJS((exports) => {
7797
7797
  Object.defineProperty(exports, "__esModule", { value: true });
7798
7798
  exports.resolveFetch = undefined;
@@ -7805,7 +7805,7 @@ var require_helper = __commonJS((exports) => {
7805
7805
  exports.resolveFetch = resolveFetch;
7806
7806
  });
7807
7807
 
7808
- // ../../node_modules/.bun/@supabase+functions-js@2.108.1/node_modules/@supabase/functions-js/dist/main/types.js
7808
+ // ../../node_modules/.bun/@supabase+functions-js@2.110.2/node_modules/@supabase/functions-js/dist/main/types.js
7809
7809
  var require_types = __commonJS((exports) => {
7810
7810
  Object.defineProperty(exports, "__esModule", { value: true });
7811
7811
  exports.FunctionRegion = exports.FunctionsHttpError = exports.FunctionsRelayError = exports.FunctionsFetchError = exports.FunctionsError = undefined;
@@ -7866,7 +7866,7 @@ var require_types = __commonJS((exports) => {
7866
7866
  })(FunctionRegion || (exports.FunctionRegion = FunctionRegion = {}));
7867
7867
  });
7868
7868
 
7869
- // ../../node_modules/.bun/@supabase+functions-js@2.108.1/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js
7869
+ // ../../node_modules/.bun/@supabase+functions-js@2.110.2/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js
7870
7870
  var require_FunctionsClient = __commonJS((exports) => {
7871
7871
  Object.defineProperty(exports, "__esModule", { value: true });
7872
7872
  exports.FunctionsClient = undefined;
@@ -7902,7 +7902,8 @@ var require_FunctionsClient = __commonJS((exports) => {
7902
7902
  url.searchParams.set("forceFunctionRegion", region);
7903
7903
  }
7904
7904
  let body;
7905
- if (functionArgs && (headers && !Object.prototype.hasOwnProperty.call(headers, "Content-Type") || !headers)) {
7905
+ const hasContentTypeHeader = !!headers && Object.keys(headers).some((key) => key.toLowerCase() === "content-type");
7906
+ if (functionArgs && !hasContentTypeHeader) {
7906
7907
  if (typeof Blob !== "undefined" && functionArgs instanceof Blob || functionArgs instanceof ArrayBuffer) {
7907
7908
  _headers["Content-Type"] = "application/octet-stream";
7908
7909
  body = functionArgs;
@@ -7979,7 +7980,7 @@ var require_FunctionsClient = __commonJS((exports) => {
7979
7980
  exports.FunctionsClient = FunctionsClient;
7980
7981
  });
7981
7982
 
7982
- // ../../node_modules/.bun/@supabase+functions-js@2.108.1/node_modules/@supabase/functions-js/dist/main/index.js
7983
+ // ../../node_modules/.bun/@supabase+functions-js@2.110.2/node_modules/@supabase/functions-js/dist/main/index.js
7983
7984
  var require_main = __commonJS((exports) => {
7984
7985
  Object.defineProperty(exports, "__esModule", { value: true });
7985
7986
  exports.FunctionRegion = exports.FunctionsRelayError = exports.FunctionsHttpError = exports.FunctionsFetchError = exports.FunctionsError = exports.FunctionsClient = undefined;
@@ -8005,7 +8006,7 @@ var require_main = __commonJS((exports) => {
8005
8006
  } });
8006
8007
  });
8007
8008
 
8008
- // ../../node_modules/.bun/@supabase+postgrest-js@2.108.1/node_modules/@supabase/postgrest-js/dist/index.mjs
8009
+ // ../../node_modules/.bun/@supabase+postgrest-js@2.110.2/node_modules/@supabase/postgrest-js/dist/index.mjs
8009
8010
  function sleep(ms, signal) {
8010
8011
  return new Promise((resolve) => {
8011
8012
  if (signal === null || signal === undefined ? undefined : signal.aborted) {
@@ -8816,7 +8817,7 @@ var init_dist = __esm(() => {
8816
8817
  };
8817
8818
  });
8818
8819
 
8819
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js
8820
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js
8820
8821
  var require_websocket_factory = __commonJS((exports) => {
8821
8822
  Object.defineProperty(exports, "__esModule", { value: true });
8822
8823
  exports.WebSocketFactory = undefined;
@@ -8854,24 +8855,10 @@ var require_websocket_factory = __commonJS((exports) => {
8854
8855
  if (_process) {
8855
8856
  const processVersions = _process["versions"];
8856
8857
  if (processVersions && processVersions["node"]) {
8857
- const versionString = processVersions["node"];
8858
- const nodeVersion = parseInt(versionString.replace(/^v/, "").split(".")[0]);
8859
- if (nodeVersion >= 22) {
8860
- if (typeof globalThis.WebSocket !== "undefined") {
8861
- return { type: "native", wsConstructor: globalThis.WebSocket };
8862
- }
8863
- return {
8864
- type: "unsupported",
8865
- error: `Node.js ${nodeVersion} detected but native WebSocket not found.`,
8866
- workaround: "Provide a WebSocket implementation via the transport option."
8867
- };
8868
- }
8869
8858
  return {
8870
8859
  type: "unsupported",
8871
- error: `Node.js ${nodeVersion} detected without native WebSocket support.`,
8872
- workaround: `For Node.js < 22, install "ws" package and provide it via the transport option:
8873
- ` + `import ws from "ws"
8874
- ` + "new RealtimeClient(url, { transport: ws })"
8860
+ error: "Node.js detected but native WebSocket not found.",
8861
+ workaround: "Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."
8875
8862
  };
8876
8863
  }
8877
8864
  }
@@ -8897,7 +8884,7 @@ Suggested solution: ${env.workaround}`;
8897
8884
  static isWebSocketSupported() {
8898
8885
  try {
8899
8886
  const env = this.detectEnvironment();
8900
- return env.type === "native" || env.type === "ws";
8887
+ return env.type === "native";
8901
8888
  } catch (_a) {
8902
8889
  return false;
8903
8890
  }
@@ -8907,14 +8894,14 @@ Suggested solution: ${env.workaround}`;
8907
8894
  exports.default = WebSocketFactory;
8908
8895
  });
8909
8896
 
8910
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/lib/version.js
8897
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/lib/version.js
8911
8898
  var require_version = __commonJS((exports) => {
8912
8899
  Object.defineProperty(exports, "__esModule", { value: true });
8913
8900
  exports.version = undefined;
8914
- exports.version = "2.108.1";
8901
+ exports.version = "2.110.2";
8915
8902
  });
8916
8903
 
8917
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/lib/constants.js
8904
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/lib/constants.js
8918
8905
  var require_constants = __commonJS((exports) => {
8919
8906
  Object.defineProperty(exports, "__esModule", { value: true });
8920
8907
  exports.CONNECTION_STATE = exports.TRANSPORTS = exports.CHANNEL_EVENTS = exports.CHANNEL_STATES = exports.SOCKET_STATES = exports.MAX_PUSH_BUFFER_SIZE = exports.WS_CLOSE_NORMAL = exports.DEFAULT_TIMEOUT = exports.VERSION = exports.DEFAULT_VSN = exports.VSN_2_0_0 = exports.VSN_1_0_0 = exports.DEFAULT_VERSION = undefined;
@@ -8959,7 +8946,7 @@ var require_constants = __commonJS((exports) => {
8959
8946
  };
8960
8947
  });
8961
8948
 
8962
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js
8949
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js
8963
8950
  var require_serializer = __commonJS((exports) => {
8964
8951
  Object.defineProperty(exports, "__esModule", { value: true });
8965
8952
 
@@ -9104,7 +9091,7 @@ var require_serializer = __commonJS((exports) => {
9104
9091
  exports.default = Serializer;
9105
9092
  });
9106
9093
 
9107
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js
9094
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js
9108
9095
  var require_transformers = __commonJS((exports) => {
9109
9096
  Object.defineProperty(exports, "__esModule", { value: true });
9110
9097
  exports.httpEndpointURL = exports.toTimestampString = exports.toArray = exports.toJson = exports.toNumber = exports.toBoolean = exports.convertCell = exports.convertColumn = exports.convertChangeData = exports.PostgresTypes = undefined;
@@ -9273,7 +9260,7 @@ var require_transformers = __commonJS((exports) => {
9273
9260
  exports.httpEndpointURL = httpEndpointURL;
9274
9261
  });
9275
9262
 
9276
- // ../../node_modules/.bun/@supabase+phoenix@0.4.2/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js
9263
+ // ../../node_modules/.bun/@supabase+phoenix@0.4.4/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js
9277
9264
  var require_phoenix_cjs = __commonJS((exports, module) => {
9278
9265
  var __defProp2 = Object.defineProperty;
9279
9266
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -10651,7 +10638,7 @@ var require_phoenix_cjs = __commonJS((exports, module) => {
10651
10638
  };
10652
10639
  });
10653
10640
 
10654
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js
10641
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js
10655
10642
  var require_presenceAdapter = __commonJS((exports) => {
10656
10643
  Object.defineProperty(exports, "__esModule", { value: true });
10657
10644
  var phoenix_1 = require_phoenix_cjs();
@@ -10724,7 +10711,7 @@ var require_presenceAdapter = __commonJS((exports) => {
10724
10711
  }
10725
10712
  });
10726
10713
 
10727
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js
10714
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js
10728
10715
  var require_RealtimePresence = __commonJS((exports) => {
10729
10716
  Object.defineProperty(exports, "__esModule", { value: true });
10730
10717
  exports.REALTIME_PRESENCE_LISTEN_EVENTS = undefined;
@@ -10749,7 +10736,7 @@ var require_RealtimePresence = __commonJS((exports) => {
10749
10736
  exports.default = RealtimePresence;
10750
10737
  });
10751
10738
 
10752
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js
10739
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js
10753
10740
  var require_normalizeChannelError = __commonJS((exports) => {
10754
10741
  Object.defineProperty(exports, "__esModule", { value: true });
10755
10742
  exports.normalizeChannelError = normalizeChannelError;
@@ -10772,7 +10759,7 @@ var require_normalizeChannelError = __commonJS((exports) => {
10772
10759
  }
10773
10760
  });
10774
10761
 
10775
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js
10762
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js
10776
10763
  var require_channelAdapter = __commonJS((exports) => {
10777
10764
  Object.defineProperty(exports, "__esModule", { value: true });
10778
10765
  var constants_1 = require_constants();
@@ -10874,10 +10861,100 @@ var require_channelAdapter = __commonJS((exports) => {
10874
10861
  }
10875
10862
  });
10876
10863
 
10877
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js
10864
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/RealtimePostgresFilterBuilder.js
10865
+ var require_RealtimePostgresFilterBuilder = __commonJS((exports) => {
10866
+ Object.defineProperty(exports, "__esModule", { value: true });
10867
+ exports.postgresChangesFilter = exports.RealtimePostgresFilterBuilder = undefined;
10868
+ var PostgrestReservedCharsRegexp2 = /[,()"\\]/;
10869
+ var needsQuoting = (value) => PostgrestReservedCharsRegexp2.test(value) || value !== value.trim();
10870
+ var quote = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
10871
+ var serializeScalar = (value) => {
10872
+ const serialized = value === null ? "null" : String(value);
10873
+ return needsQuoting(serialized) ? quote(serialized) : serialized;
10874
+ };
10875
+ var serializeIsValue = (value) => value === null ? "null" : String(value);
10876
+ var serialize = (operator, value) => {
10877
+ if (operator === "in") {
10878
+ const values = Array.isArray(value) ? value : [value];
10879
+ if (values.length === 0) {
10880
+ throw new Error("Realtime `in` filter requires at least one value.");
10881
+ }
10882
+ const items = Array.from(new Set(values)).map((v) => serializeScalar(v)).join(",");
10883
+ return `in.(${items})`;
10884
+ }
10885
+ if (operator === "is") {
10886
+ return `is.${serializeIsValue(value)}`;
10887
+ }
10888
+ return `${operator}.${serializeScalar(value)}`;
10889
+ };
10890
+
10891
+ class RealtimePostgresFilterBuilder {
10892
+ constructor() {
10893
+ this.filters = [];
10894
+ }
10895
+ add(column, operator, value, negate = false) {
10896
+ const prefix = negate ? "not." : "";
10897
+ this.filters.push(`${column}=${prefix}${serialize(operator, value)}`);
10898
+ return this;
10899
+ }
10900
+ eq(column, value) {
10901
+ return this.add(column, "eq", value);
10902
+ }
10903
+ neq(column, value) {
10904
+ return this.add(column, "neq", value);
10905
+ }
10906
+ gt(column, value) {
10907
+ return this.add(column, "gt", value);
10908
+ }
10909
+ gte(column, value) {
10910
+ return this.add(column, "gte", value);
10911
+ }
10912
+ lt(column, value) {
10913
+ return this.add(column, "lt", value);
10914
+ }
10915
+ lte(column, value) {
10916
+ return this.add(column, "lte", value);
10917
+ }
10918
+ in(column, values) {
10919
+ return this.add(column, "in", values);
10920
+ }
10921
+ like(column, pattern) {
10922
+ return this.add(column, "like", pattern);
10923
+ }
10924
+ ilike(column, pattern) {
10925
+ return this.add(column, "ilike", pattern);
10926
+ }
10927
+ match(column, pattern) {
10928
+ return this.add(column, "match", pattern);
10929
+ }
10930
+ imatch(column, pattern) {
10931
+ return this.add(column, "imatch", pattern);
10932
+ }
10933
+ is(column, value) {
10934
+ return this.add(column, "is", value);
10935
+ }
10936
+ isDistinct(column, value) {
10937
+ return this.add(column, "isdistinct", value);
10938
+ }
10939
+ not(column, operator, value) {
10940
+ return this.add(column, operator, value, true);
10941
+ }
10942
+ build() {
10943
+ return this.filters.join(",");
10944
+ }
10945
+ toString() {
10946
+ return this.build();
10947
+ }
10948
+ }
10949
+ exports.RealtimePostgresFilterBuilder = RealtimePostgresFilterBuilder;
10950
+ var postgresChangesFilter = () => new RealtimePostgresFilterBuilder;
10951
+ exports.postgresChangesFilter = postgresChangesFilter;
10952
+ });
10953
+
10954
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js
10878
10955
  var require_RealtimeChannel = __commonJS((exports) => {
10879
10956
  Object.defineProperty(exports, "__esModule", { value: true });
10880
- exports.REALTIME_CHANNEL_STATES = exports.REALTIME_SUBSCRIBE_STATES = exports.REALTIME_LISTEN_TYPES = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = undefined;
10957
+ exports.REALTIME_CHANNEL_STATES = exports.REALTIME_SUBSCRIBE_STATES = exports.REALTIME_LISTEN_TYPES = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports.postgresChangesFilter = exports.RealtimePostgresFilterBuilder = undefined;
10881
10958
  var tslib_1 = require_tslib();
10882
10959
  var constants_1 = require_constants();
10883
10960
  var RealtimePresence_1 = tslib_1.__importDefault(require_RealtimePresence());
@@ -10885,6 +10962,14 @@ var require_RealtimeChannel = __commonJS((exports) => {
10885
10962
  var transformers_1 = require_transformers();
10886
10963
  var normalizeChannelError_1 = require_normalizeChannelError();
10887
10964
  var channelAdapter_1 = tslib_1.__importDefault(require_channelAdapter());
10965
+ var RealtimePostgresFilterBuilder_1 = require_RealtimePostgresFilterBuilder();
10966
+ var RealtimePostgresFilterBuilder_2 = require_RealtimePostgresFilterBuilder();
10967
+ Object.defineProperty(exports, "RealtimePostgresFilterBuilder", { enumerable: true, get: function() {
10968
+ return RealtimePostgresFilterBuilder_2.RealtimePostgresFilterBuilder;
10969
+ } });
10970
+ Object.defineProperty(exports, "postgresChangesFilter", { enumerable: true, get: function() {
10971
+ return RealtimePostgresFilterBuilder_2.postgresChangesFilter;
10972
+ } });
10888
10973
  var REALTIME_POSTGRES_CHANGES_LISTEN_EVENT;
10889
10974
  (function(REALTIME_POSTGRES_CHANGES_LISTEN_EVENT2) {
10890
10975
  REALTIME_POSTGRES_CHANGES_LISTEN_EVENT2["ALL"] = "*";
@@ -11070,6 +11155,9 @@ var require_RealtimeChannel = __commonJS((exports) => {
11070
11155
  if (response.status === 202) {
11071
11156
  return { success: true };
11072
11157
  }
11158
+ if (response.status === 404) {
11159
+ return Promise.reject(new Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. " + "Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. " + "See https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/migrations/httpsend-server-version.md"));
11160
+ }
11073
11161
  let errorMessage = response.statusText;
11074
11162
  try {
11075
11163
  const errorBody = await response.json();
@@ -11147,6 +11235,10 @@ var require_RealtimeChannel = __commonJS((exports) => {
11147
11235
  }
11148
11236
  _on(type, filter, callback) {
11149
11237
  const typeLower = type.toLocaleLowerCase();
11238
+ const filterValue = filter === null || filter === undefined ? undefined : filter.filter;
11239
+ if (filterValue instanceof RealtimePostgresFilterBuilder_1.RealtimePostgresFilterBuilder || typeof filterValue === "object" && filterValue !== null && typeof filterValue.build === "function") {
11240
+ filter = Object.assign(Object.assign({}, filter), { filter: filterValue.build() });
11241
+ }
11150
11242
  const ref = this.channelAdapter.on(type, callback);
11151
11243
  const binding = {
11152
11244
  type: typeLower,
@@ -11249,7 +11341,7 @@ var require_RealtimeChannel = __commonJS((exports) => {
11249
11341
  exports.default = RealtimeChannel;
11250
11342
  });
11251
11343
 
11252
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js
11344
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js
11253
11345
  var require_socketAdapter = __commonJS((exports) => {
11254
11346
  Object.defineProperty(exports, "__esModule", { value: true });
11255
11347
  var phoenix_1 = require_phoenix_cjs();
@@ -11362,7 +11454,7 @@ var require_socketAdapter = __commonJS((exports) => {
11362
11454
  exports.default = SocketAdapter;
11363
11455
  });
11364
11456
 
11365
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js
11457
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js
11366
11458
  var require_RealtimeClient = __commonJS((exports) => {
11367
11459
  Object.defineProperty(exports, "__esModule", { value: true });
11368
11460
  var tslib_1 = require_tslib();
@@ -11511,22 +11603,6 @@ var require_RealtimeClient = __commonJS((exports) => {
11511
11603
  this.socketAdapter.connect();
11512
11604
  } catch (error) {
11513
11605
  const errorMessage = error.message;
11514
- if (errorMessage.includes("Node.js")) {
11515
- throw new Error(`${errorMessage}
11516
-
11517
- ` + `To use Realtime in Node.js, you need to provide a WebSocket implementation:
11518
-
11519
- ` + `Option 1: Use Node.js 22+ which has native WebSocket support
11520
- ` + `Option 2: Install and provide the "ws" package:
11521
-
11522
- ` + ` npm install ws
11523
-
11524
- ` + ` import ws from "ws"
11525
- ` + ` const client = new RealtimeClient(url, {
11526
- ` + ` ...options,
11527
- ` + ` transport: ws
11528
- ` + " })");
11529
- }
11530
11606
  throw new Error(`WebSocket not available: ${errorMessage}`);
11531
11607
  }
11532
11608
  this._handleNodeJsRaceCondition();
@@ -11721,6 +11797,8 @@ var require_RealtimeClient = __commonJS((exports) => {
11721
11797
  }
11722
11798
  _wrapHeartbeatCallback(heartbeatCallback) {
11723
11799
  return (status, latency) => {
11800
+ if (status === "disconnected")
11801
+ return;
11724
11802
  if (status == "sent")
11725
11803
  this._setAuthSafely();
11726
11804
  if (heartbeatCallback)
@@ -11829,15 +11907,21 @@ var require_RealtimeClient = __commonJS((exports) => {
11829
11907
  exports.default = RealtimeClient;
11830
11908
  });
11831
11909
 
11832
- // ../../node_modules/.bun/@supabase+realtime-js@2.108.1/node_modules/@supabase/realtime-js/dist/main/index.js
11910
+ // ../../node_modules/.bun/@supabase+realtime-js@2.110.2/node_modules/@supabase/realtime-js/dist/main/index.js
11833
11911
  var require_main2 = __commonJS((exports) => {
11834
11912
  Object.defineProperty(exports, "__esModule", { value: true });
11835
- exports.WebSocketFactory = exports.REALTIME_CHANNEL_STATES = exports.REALTIME_SUBSCRIBE_STATES = exports.REALTIME_PRESENCE_LISTEN_EVENTS = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports.REALTIME_LISTEN_TYPES = exports.RealtimeClient = exports.RealtimeChannel = exports.RealtimePresence = undefined;
11913
+ exports.WebSocketFactory = exports.REALTIME_CHANNEL_STATES = exports.REALTIME_SUBSCRIBE_STATES = exports.REALTIME_PRESENCE_LISTEN_EVENTS = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports.REALTIME_LISTEN_TYPES = exports.postgresChangesFilter = exports.RealtimePostgresFilterBuilder = exports.RealtimeClient = exports.RealtimeChannel = exports.RealtimePresence = undefined;
11836
11914
  var tslib_1 = require_tslib();
11837
11915
  var RealtimeClient_1 = tslib_1.__importDefault(require_RealtimeClient());
11838
11916
  exports.RealtimeClient = RealtimeClient_1.default;
11839
11917
  var RealtimeChannel_1 = tslib_1.__importStar(require_RealtimeChannel());
11840
11918
  exports.RealtimeChannel = RealtimeChannel_1.default;
11919
+ Object.defineProperty(exports, "RealtimePostgresFilterBuilder", { enumerable: true, get: function() {
11920
+ return RealtimeChannel_1.RealtimePostgresFilterBuilder;
11921
+ } });
11922
+ Object.defineProperty(exports, "postgresChangesFilter", { enumerable: true, get: function() {
11923
+ return RealtimeChannel_1.postgresChangesFilter;
11924
+ } });
11841
11925
  Object.defineProperty(exports, "REALTIME_LISTEN_TYPES", { enumerable: true, get: function() {
11842
11926
  return RealtimeChannel_1.REALTIME_LISTEN_TYPES;
11843
11927
  } });
@@ -12159,7 +12243,7 @@ var init_dist2 = __esm(() => {
12159
12243
  };
12160
12244
  });
12161
12245
 
12162
- // ../../node_modules/.bun/@supabase+storage-js@2.108.1/node_modules/@supabase/storage-js/dist/index.mjs
12246
+ // ../../node_modules/.bun/@supabase+storage-js@2.110.2/node_modules/@supabase/storage-js/dist/index.mjs
12163
12247
  function _typeof2(o) {
12164
12248
  "@babel/helpers - typeof";
12165
12249
  return _typeof2 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o$1) {
@@ -12467,7 +12551,7 @@ var StorageError, StorageApiError, StorageUnknownError, resolveFetch = (customFe
12467
12551
  throw error;
12468
12552
  }
12469
12553
  }
12470
- }, DEFAULT_SEARCH_OPTIONS, DEFAULT_FILE_OPTIONS, StorageFileApi, version = "2.108.1", DEFAULT_HEADERS, StorageBucketApi, StorageAnalyticsClient, VectorIndexApi, VectorDataApi, VectorBucketApi, StorageVectorsClient, VectorBucketScope, VectorIndexScope, StorageClient;
12554
+ }, DEFAULT_SEARCH_OPTIONS, DEFAULT_FILE_OPTIONS, StorageFileApi, version = "2.110.2", DEFAULT_HEADERS, StorageBucketApi, StorageAnalyticsClient, VectorIndexApi, VectorDataApi, VectorBucketApi, StorageVectorsClient, VectorBucketScope, VectorIndexScope, StorageClient;
12471
12555
  var init_dist3 = __esm(() => {
12472
12556
  init_dist2();
12473
12557
  StorageError = class extends Error {
@@ -12754,18 +12838,33 @@ var init_dist3 = __esm(() => {
12754
12838
  return await remove(_this12.fetch, `${_this12.url}/object/${_this12.bucketId}`, { prefixes: paths }, { headers: _this12.headers });
12755
12839
  });
12756
12840
  }
12757
- async list(path, options, parameters) {
12841
+ async purgeCache(path, options, parameters) {
12758
12842
  var _this13 = this;
12759
12843
  return _this13.handleOperation(async () => {
12760
- const body = _objectSpread22(_objectSpread22(_objectSpread22({}, DEFAULT_SEARCH_OPTIONS), options), {}, { prefix: path || "" });
12761
- return await post(_this13.fetch, `${_this13.url}/object/list/${_this13.bucketId}`, body, { headers: _this13.headers }, parameters);
12844
+ const _path = _this13._getFinalPath(path);
12845
+ const query = new URLSearchParams;
12846
+ if (options === null || options === undefined ? undefined : options.transformations)
12847
+ query.set("transformations", "true");
12848
+ const queryString = query.toString();
12849
+ return await remove(_this13.fetch, `${_this13.url}/cdn/${_path}${queryString ? `?${queryString}` : ""}`, {}, { headers: _this13.headers }, parameters);
12762
12850
  });
12763
12851
  }
12764
- async listV2(options, parameters) {
12852
+ async list(path, options, parameters) {
12765
12853
  var _this14 = this;
12766
12854
  return _this14.handleOperation(async () => {
12855
+ const sortBy = (options === null || options === undefined ? undefined : options.sortBy) ? _objectSpread22(_objectSpread22({}, DEFAULT_SEARCH_OPTIONS.sortBy), options.sortBy) : DEFAULT_SEARCH_OPTIONS.sortBy;
12856
+ const body = _objectSpread22(_objectSpread22(_objectSpread22({}, DEFAULT_SEARCH_OPTIONS), options), {}, {
12857
+ sortBy,
12858
+ prefix: path || ""
12859
+ });
12860
+ return await post(_this14.fetch, `${_this14.url}/object/list/${_this14.bucketId}`, body, { headers: _this14.headers }, parameters);
12861
+ });
12862
+ }
12863
+ async listV2(options, parameters) {
12864
+ var _this15 = this;
12865
+ return _this15.handleOperation(async () => {
12767
12866
  const body = _objectSpread22({}, options);
12768
- return await post(_this14.fetch, `${_this14.url}/object/list-v2/${_this14.bucketId}`, body, { headers: _this14.headers }, parameters);
12867
+ return await post(_this15.fetch, `${_this15.url}/object/list-v2/${_this15.bucketId}`, body, { headers: _this15.headers }, parameters);
12769
12868
  });
12770
12869
  }
12771
12870
  encodeMetadata(metadata) {
@@ -12858,6 +12957,16 @@ var init_dist3 = __esm(() => {
12858
12957
  return await remove(_this6.fetch, `${_this6.url}/bucket/${id}`, {}, { headers: _this6.headers });
12859
12958
  });
12860
12959
  }
12960
+ async purgeBucketCache(id, options, parameters) {
12961
+ var _this7 = this;
12962
+ return _this7.handleOperation(async () => {
12963
+ const query = new URLSearchParams;
12964
+ if (options === null || options === undefined ? undefined : options.transformations)
12965
+ query.set("transformations", "true");
12966
+ const queryString = query.toString();
12967
+ return await remove(_this7.fetch, `${_this7.url}/cdn/${id}${queryString ? `?${queryString}` : ""}`, {}, { headers: _this7.headers }, parameters);
12968
+ });
12969
+ }
12861
12970
  listBucketOptionsToQueryString(options) {
12862
12971
  const params = {};
12863
12972
  if (options) {
@@ -13175,21 +13284,22 @@ var init_dist3 = __esm(() => {
13175
13284
  };
13176
13285
  });
13177
13286
 
13178
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/version.js
13287
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/version.js
13179
13288
  var require_version2 = __commonJS((exports) => {
13180
13289
  Object.defineProperty(exports, "__esModule", { value: true });
13181
13290
  exports.version = undefined;
13182
- exports.version = "2.108.1";
13291
+ exports.version = "2.110.2";
13183
13292
  });
13184
13293
 
13185
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/constants.js
13294
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/constants.js
13186
13295
  var require_constants2 = __commonJS((exports) => {
13187
13296
  Object.defineProperty(exports, "__esModule", { value: true });
13188
- exports.JWKS_TTL = exports.BASE64URL_REGEX = exports.API_VERSIONS = exports.API_VERSION_HEADER_NAME = exports.NETWORK_FAILURE = exports.DEFAULT_HEADERS = exports.AUDIENCE = exports.STORAGE_KEY = exports.GOTRUE_URL = exports.EXPIRY_MARGIN_MS = exports.AUTO_REFRESH_TICK_THRESHOLD = exports.AUTO_REFRESH_TICK_DURATION_MS = undefined;
13297
+ exports.JWKS_TTL = exports.BASE64URL_REGEX = exports.API_VERSIONS = exports.API_VERSION_HEADER_NAME = exports.NETWORK_FAILURE = exports.DEFAULT_HEADERS = exports.AUDIENCE = exports.STORAGE_KEY = exports.GOTRUE_URL = exports.REFRESH_FAILURE_COOLDOWN_MS = exports.EXPIRY_MARGIN_MS = exports.AUTO_REFRESH_TICK_THRESHOLD = exports.AUTO_REFRESH_TICK_DURATION_MS = undefined;
13189
13298
  var version_1 = require_version2();
13190
13299
  exports.AUTO_REFRESH_TICK_DURATION_MS = 30 * 1000;
13191
13300
  exports.AUTO_REFRESH_TICK_THRESHOLD = 3;
13192
13301
  exports.EXPIRY_MARGIN_MS = exports.AUTO_REFRESH_TICK_THRESHOLD * exports.AUTO_REFRESH_TICK_DURATION_MS;
13302
+ exports.REFRESH_FAILURE_COOLDOWN_MS = 2 * exports.AUTO_REFRESH_TICK_DURATION_MS;
13193
13303
  exports.GOTRUE_URL = "http://localhost:9999";
13194
13304
  exports.STORAGE_KEY = "supabase.auth.token";
13195
13305
  exports.AUDIENCE = "";
@@ -13209,7 +13319,7 @@ var require_constants2 = __commonJS((exports) => {
13209
13319
  exports.JWKS_TTL = 10 * 60 * 1000;
13210
13320
  });
13211
13321
 
13212
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/errors.js
13322
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/errors.js
13213
13323
  var require_errors = __commonJS((exports) => {
13214
13324
  Object.defineProperty(exports, "__esModule", { value: true });
13215
13325
  exports.AuthInvalidJwtError = exports.AuthWeakPasswordError = exports.AuthRefreshDiscardedError = exports.AuthRetryableFetchError = exports.AuthPKCECodeVerifierMissingError = exports.AuthPKCEGrantCodeExchangeError = exports.AuthImplicitGrantRedirectError = exports.AuthInvalidCredentialsError = exports.AuthInvalidTokenResponseError = exports.AuthSessionMissingError = exports.CustomAuthError = exports.AuthUnknownError = exports.AuthApiError = exports.AuthError = undefined;
@@ -13378,7 +13488,7 @@ var require_errors = __commonJS((exports) => {
13378
13488
  exports.AuthInvalidJwtError = AuthInvalidJwtError;
13379
13489
  });
13380
13490
 
13381
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/base64url.js
13491
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/base64url.js
13382
13492
  var require_base64url = __commonJS((exports) => {
13383
13493
  Object.defineProperty(exports, "__esModule", { value: true });
13384
13494
  exports.byteToBase64URL = byteToBase64URL;
@@ -13566,7 +13676,7 @@ var require_base64url = __commonJS((exports) => {
13566
13676
  }
13567
13677
  });
13568
13678
 
13569
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/helpers.js
13679
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/helpers.js
13570
13680
  var require_helpers = __commonJS((exports) => {
13571
13681
  Object.defineProperty(exports, "__esModule", { value: true });
13572
13682
  exports.Deferred = exports.removeItemAsync = exports.getItemAsync = exports.setItemAsync = exports.looksLikeFetchResponse = exports.resolveFetch = exports.supportsLocalStorage = exports.isBrowser = undefined;
@@ -13881,7 +13991,7 @@ var require_helpers = __commonJS((exports) => {
13881
13991
  }
13882
13992
  });
13883
13993
 
13884
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/fetch.js
13994
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/fetch.js
13885
13995
  var require_fetch = __commonJS((exports) => {
13886
13996
  Object.defineProperty(exports, "__esModule", { value: true });
13887
13997
  exports.handleError = handleError2;
@@ -13910,7 +14020,24 @@ var require_fetch = __commonJS((exports) => {
13910
14020
  }
13911
14021
  return JSON.stringify(err);
13912
14022
  };
13913
- var NETWORK_ERROR_CODES = [502, 503, 504, 520, 521, 522, 523, 524, 530];
14023
+ var NETWORK_ERROR_CODES = [
14024
+ 500,
14025
+ 501,
14026
+ 502,
14027
+ 503,
14028
+ 504,
14029
+ 520,
14030
+ 521,
14031
+ 522,
14032
+ 523,
14033
+ 524,
14034
+ 525,
14035
+ 526,
14036
+ 527,
14037
+ 528,
14038
+ 529,
14039
+ 530
14040
+ ];
13914
14041
  async function handleError2(error) {
13915
14042
  var _a;
13916
14043
  if (!(0, helpers_1.looksLikeFetchResponse)(error)) {
@@ -14046,14 +14173,14 @@ var require_fetch = __commonJS((exports) => {
14046
14173
  }
14047
14174
  });
14048
14175
 
14049
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/types.js
14176
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/types.js
14050
14177
  var require_types2 = __commonJS((exports) => {
14051
14178
  Object.defineProperty(exports, "__esModule", { value: true });
14052
14179
  exports.SIGN_OUT_SCOPES = undefined;
14053
14180
  exports.SIGN_OUT_SCOPES = ["global", "local", "others"];
14054
14181
  });
14055
14182
 
14056
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js
14183
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js
14057
14184
  var require_GoTrueAdminApi = __commonJS((exports) => {
14058
14185
  Object.defineProperty(exports, "__esModule", { value: true });
14059
14186
  var tslib_1 = require_tslib();
@@ -14500,7 +14627,7 @@ var require_GoTrueAdminApi = __commonJS((exports) => {
14500
14627
  exports.default = GoTrueAdminApi;
14501
14628
  });
14502
14629
 
14503
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js
14630
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js
14504
14631
  var require_local_storage = __commonJS((exports) => {
14505
14632
  Object.defineProperty(exports, "__esModule", { value: true });
14506
14633
  exports.memoryLocalStorageAdapter = memoryLocalStorageAdapter;
@@ -14519,7 +14646,7 @@ var require_local_storage = __commonJS((exports) => {
14519
14646
  }
14520
14647
  });
14521
14648
 
14522
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/locks.js
14649
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/locks.js
14523
14650
  var require_locks = __commonJS((exports) => {
14524
14651
  Object.defineProperty(exports, "__esModule", { value: true });
14525
14652
  exports.ProcessLockAcquireTimeoutError = exports.NavigatorLockAcquireTimeoutError = exports.LockAcquireTimeoutError = exports.internals = undefined;
@@ -14693,7 +14820,7 @@ var require_locks = __commonJS((exports) => {
14693
14820
  }
14694
14821
  });
14695
14822
 
14696
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js
14823
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js
14697
14824
  var require_polyfills = __commonJS((exports) => {
14698
14825
  Object.defineProperty(exports, "__esModule", { value: true });
14699
14826
  exports.polyfillGlobalThis = polyfillGlobalThis;
@@ -14717,7 +14844,7 @@ var require_polyfills = __commonJS((exports) => {
14717
14844
  }
14718
14845
  });
14719
14846
 
14720
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js
14847
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js
14721
14848
  var require_ethereum = __commonJS((exports) => {
14722
14849
  Object.defineProperty(exports, "__esModule", { value: true });
14723
14850
  exports.getAddress = getAddress;
@@ -14794,7 +14921,7 @@ ${suffix}`;
14794
14921
  }
14795
14922
  });
14796
14923
 
14797
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js
14924
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js
14798
14925
  var require_webauthn_errors = __commonJS((exports) => {
14799
14926
  Object.defineProperty(exports, "__esModule", { value: true });
14800
14927
  exports.WebAuthnUnknownError = exports.WebAuthnError = undefined;
@@ -14981,7 +15108,7 @@ var require_webauthn_errors = __commonJS((exports) => {
14981
15108
  }
14982
15109
  });
14983
15110
 
14984
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js
15111
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js
14985
15112
  var require_webauthn = __commonJS((exports) => {
14986
15113
  Object.defineProperty(exports, "__esModule", { value: true });
14987
15114
  exports.WebAuthnApi = exports.DEFAULT_REQUEST_OPTIONS = exports.DEFAULT_CREATION_OPTIONS = exports.webAuthnAbortService = exports.WebAuthnAbortService = exports.identifyAuthenticationError = exports.identifyRegistrationError = exports.isWebAuthnError = exports.WebAuthnError = undefined;
@@ -15435,7 +15562,7 @@ var require_webauthn = __commonJS((exports) => {
15435
15562
  exports.WebAuthnApi = WebAuthnApi;
15436
15563
  });
15437
15564
 
15438
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js
15565
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js
15439
15566
  var require_GoTrueClient = __commonJS((exports) => {
15440
15567
  Object.defineProperty(exports, "__esModule", { value: true });
15441
15568
  var tslib_1 = require_tslib();
@@ -15493,8 +15620,10 @@ var require_GoTrueClient = __commonJS((exports) => {
15493
15620
  this.autoRefreshTickTimeout = null;
15494
15621
  this.visibilityChangedCallback = null;
15495
15622
  this.refreshingDeferred = null;
15623
+ this.lastRefreshFailure = null;
15496
15624
  this._sessionRemovalEpoch = 0;
15497
15625
  this.initializePromise = null;
15626
+ this._pendingInitNotifications = null;
15498
15627
  this.detectSessionInUrl = true;
15499
15628
  this.hasCustomAuthorizationHeader = false;
15500
15629
  this.suppressGetSessionWarning = false;
@@ -15594,6 +15723,9 @@ var require_GoTrueClient = __commonJS((exports) => {
15594
15723
  }
15595
15724
  (_c = this.broadcastChannel) === null || _c === undefined || _c.addEventListener("message", async (event) => {
15596
15725
  this._debug("received broadcast notification from other tab or client", event);
15726
+ if (event.data.event === "TOKEN_REFRESHED" || event.data.event === "SIGNED_IN") {
15727
+ this.lastRefreshFailure = null;
15728
+ }
15597
15729
  try {
15598
15730
  await this._notifyAllSubscribers(event.data.event, event.data.session, false);
15599
15731
  } catch (error) {
@@ -15626,9 +15758,11 @@ var require_GoTrueClient = __commonJS((exports) => {
15626
15758
  return this;
15627
15759
  }
15628
15760
  async initialize() {
15761
+ var _a;
15629
15762
  if (this.initializePromise) {
15630
15763
  return await this.initializePromise;
15631
15764
  }
15765
+ this._pendingInitNotifications = [];
15632
15766
  this.initializePromise = (async () => {
15633
15767
  if (this.lock != null) {
15634
15768
  return await this._acquireLock(this.lockAcquireTimeout, async () => {
@@ -15637,7 +15771,13 @@ var require_GoTrueClient = __commonJS((exports) => {
15637
15771
  }
15638
15772
  return await this._initialize();
15639
15773
  })();
15640
- return await this.initializePromise;
15774
+ const result = await this.initializePromise;
15775
+ const queue = (_a = this._pendingInitNotifications) !== null && _a !== undefined ? _a : [];
15776
+ this._pendingInitNotifications = null;
15777
+ for (const n of queue) {
15778
+ await this._notifyAllSubscribers(n.event, n.session, n.broadcast);
15779
+ }
15780
+ return result;
15641
15781
  }
15642
15782
  async _initialize() {
15643
15783
  var _a;
@@ -16420,6 +16560,13 @@ var require_GoTrueClient = __commonJS((exports) => {
16420
16560
  }
16421
16561
  const { data: session, error } = await this._callRefreshToken(currentSession.refresh_token);
16422
16562
  if (error) {
16563
+ const accessTokenStillValid = !!(currentSession.expires_at && currentSession.expires_at * 1000 > Date.now());
16564
+ if (accessTokenStillValid) {
16565
+ const stillStored = await (0, helpers_1.getItemAsync)(this.storage, this.storageKey);
16566
+ if (stillStored && stillStored.refresh_token === currentSession.refresh_token) {
16567
+ return this._returnResult({ data: { session: currentSession }, error: null });
16568
+ }
16569
+ }
16423
16570
  return this._returnResult({ data: { session: null }, error });
16424
16571
  }
16425
16572
  return this._returnResult({ data: { session }, error: null });
@@ -16727,6 +16874,10 @@ var require_GoTrueClient = __commonJS((exports) => {
16727
16874
  async _signOut({ scope } = { scope: "global" }) {
16728
16875
  return await this._useSession(async (result) => {
16729
16876
  var _a;
16877
+ const removeCurrentSession = async () => {
16878
+ await this._removeSession();
16879
+ await (0, helpers_1.removeItemAsync)(this.storage, `${this.storageKey}-code-verifier`);
16880
+ };
16730
16881
  const { data, error: sessionError } = result;
16731
16882
  if (sessionError && !(0, errors_1.isAuthSessionMissingError)(sessionError)) {
16732
16883
  return this._returnResult({ error: sessionError });
@@ -16736,13 +16887,15 @@ var require_GoTrueClient = __commonJS((exports) => {
16736
16887
  const { error } = await this.admin.signOut(accessToken, scope);
16737
16888
  if (error) {
16738
16889
  if (!((0, errors_1.isAuthApiError)(error) && (error.status === 404 || error.status === 401 || error.status === 403) || (0, errors_1.isAuthSessionMissingError)(error))) {
16890
+ if (scope !== "others") {
16891
+ await removeCurrentSession();
16892
+ }
16739
16893
  return this._returnResult({ error });
16740
16894
  }
16741
16895
  }
16742
16896
  }
16743
16897
  if (scope !== "others") {
16744
- await this._removeSession();
16745
- await (0, helpers_1.removeItemAsync)(this.storage, `${this.storageKey}-code-verifier`);
16898
+ await removeCurrentSession();
16746
16899
  }
16747
16900
  return this._returnResult({ error: null });
16748
16901
  });
@@ -17023,10 +17176,6 @@ var require_GoTrueClient = __commonJS((exports) => {
17023
17176
  this._debug(debugName, "refresh discarded by commit guard", error);
17024
17177
  } else {
17025
17178
  this._debug(debugName, "refresh failed", error);
17026
- if (!(0, errors_1.isAuthRetryableFetchError)(error)) {
17027
- this._debug(debugName, "refresh failed with a non-retryable error, removing the session", error);
17028
- await this._removeSession();
17029
- }
17030
17179
  }
17031
17180
  }
17032
17181
  }
@@ -17063,6 +17212,10 @@ var require_GoTrueClient = __commonJS((exports) => {
17063
17212
  if (this.refreshingDeferred) {
17064
17213
  return this.refreshingDeferred.promise;
17065
17214
  }
17215
+ if (this.lastRefreshFailure && this.lastRefreshFailure.refreshToken === refreshToken && Date.now() < this.lastRefreshFailure.expiresAt) {
17216
+ this._debug("#_callRefreshToken()", "returning cached failure (cooldown active)");
17217
+ return this.lastRefreshFailure.result;
17218
+ }
17066
17219
  const debugName = `#_callRefreshToken()`;
17067
17220
  this._debug(debugName, "begin");
17068
17221
  try {
@@ -17104,6 +17257,7 @@ var require_GoTrueClient = __commonJS((exports) => {
17104
17257
  }
17105
17258
  await this._notifyAllSubscribers("TOKEN_REFRESHED", data.session);
17106
17259
  const result = { data: data.session, error: null };
17260
+ this.lastRefreshFailure = null;
17107
17261
  this.refreshingDeferred.resolve(result);
17108
17262
  return result;
17109
17263
  } catch (error) {
@@ -17111,8 +17265,19 @@ var require_GoTrueClient = __commonJS((exports) => {
17111
17265
  if ((0, errors_1.isAuthError)(error)) {
17112
17266
  const result = { data: null, error };
17113
17267
  if (!(0, errors_1.isAuthRetryableFetchError)(error)) {
17114
- await this._removeSession();
17268
+ const storedNow = await (0, helpers_1.getItemAsync)(this.storage, this.storageKey);
17269
+ const accessTokenStillValid = !!((storedNow === null || storedNow === undefined ? undefined : storedNow.expires_at) && storedNow.expires_at * 1000 > Date.now());
17270
+ if (accessTokenStillValid) {
17271
+ this._debug(debugName, "proactive refresh failed, access token still valid — preserving session");
17272
+ } else {
17273
+ await this._removeSession();
17274
+ }
17115
17275
  }
17276
+ this.lastRefreshFailure = {
17277
+ refreshToken,
17278
+ result,
17279
+ expiresAt: Date.now() + constants_1.REFRESH_FAILURE_COOLDOWN_MS
17280
+ };
17116
17281
  (_a = this.refreshingDeferred) === null || _a === undefined || _a.resolve(result);
17117
17282
  return result;
17118
17283
  }
@@ -17124,6 +17289,10 @@ var require_GoTrueClient = __commonJS((exports) => {
17124
17289
  }
17125
17290
  }
17126
17291
  async _notifyAllSubscribers(event, session, broadcast = true) {
17292
+ if (this._pendingInitNotifications !== null && broadcast) {
17293
+ this._pendingInitNotifications.push({ event, session, broadcast });
17294
+ return;
17295
+ }
17127
17296
  const debugName = `#_notifyAllSubscribers(${event})`;
17128
17297
  this._debug(debugName, "begin", session, `broadcast = ${broadcast}`);
17129
17298
  try {
@@ -17173,6 +17342,7 @@ var require_GoTrueClient = __commonJS((exports) => {
17173
17342
  async _removeSession() {
17174
17343
  this._sessionRemovalEpoch += 1;
17175
17344
  this._debug("#_removeSession()");
17345
+ this.lastRefreshFailure = null;
17176
17346
  this.suppressGetSessionWarning = false;
17177
17347
  await (0, helpers_1.removeItemAsync)(this.storage, this.storageKey);
17178
17348
  await (0, helpers_1.removeItemAsync)(this.storage, this.storageKey + "-code-verifier");
@@ -18088,7 +18258,7 @@ var require_GoTrueClient = __commonJS((exports) => {
18088
18258
  exports.default = GoTrueClient;
18089
18259
  });
18090
18260
 
18091
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js
18261
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js
18092
18262
  var require_AuthAdminApi = __commonJS((exports) => {
18093
18263
  Object.defineProperty(exports, "__esModule", { value: true });
18094
18264
  var tslib_1 = require_tslib();
@@ -18097,7 +18267,7 @@ var require_AuthAdminApi = __commonJS((exports) => {
18097
18267
  exports.default = AuthAdminApi;
18098
18268
  });
18099
18269
 
18100
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/AuthClient.js
18270
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/AuthClient.js
18101
18271
  var require_AuthClient = __commonJS((exports) => {
18102
18272
  Object.defineProperty(exports, "__esModule", { value: true });
18103
18273
  var tslib_1 = require_tslib();
@@ -18106,7 +18276,7 @@ var require_AuthClient = __commonJS((exports) => {
18106
18276
  exports.default = AuthClient;
18107
18277
  });
18108
18278
 
18109
- // ../../node_modules/.bun/@supabase+auth-js@2.108.1/node_modules/@supabase/auth-js/dist/main/index.js
18279
+ // ../../node_modules/.bun/@supabase+auth-js@2.110.2/node_modules/@supabase/auth-js/dist/main/index.js
18110
18280
  var require_main3 = __commonJS((exports) => {
18111
18281
  Object.defineProperty(exports, "__esModule", { value: true });
18112
18282
  exports.processLock = exports.lockInternals = exports.NavigatorLockAcquireTimeoutError = exports.navigatorLock = exports.AuthClient = exports.AuthAdminApi = exports.GoTrueClient = exports.GoTrueAdminApi = undefined;
@@ -18136,7 +18306,7 @@ var require_main3 = __commonJS((exports) => {
18136
18306
  } });
18137
18307
  });
18138
18308
 
18139
- // ../../node_modules/.bun/@supabase+supabase-js@2.108.1/node_modules/@supabase/supabase-js/dist/index.mjs
18309
+ // ../../node_modules/.bun/@supabase+supabase-js@2.110.2/node_modules/@supabase/supabase-js/dist/index.mjs
18140
18310
  var exports_dist = {};
18141
18311
  __export(exports_dist, {
18142
18312
  createClient: () => createClient,
@@ -18395,9 +18565,9 @@ function shouldShowDeprecationWarning() {
18395
18565
  const versionMatch = processVersion.match(/^v(\d+)\./);
18396
18566
  if (!versionMatch)
18397
18567
  return false;
18398
- return parseInt(versionMatch[1], 10) <= 18;
18568
+ return parseInt(versionMatch[1], 10) <= 20;
18399
18569
  }
18400
- var import_functions_js, import_realtime_js, import_auth_js, version2 = "2.108.1", JS_ENV = "", JS_RUNTIME_VERSION, _Deno$version, _process$version, _runtimeMeta, DEFAULT_HEADERS2, DEFAULT_GLOBAL_OPTIONS, DEFAULT_DB_OPTIONS, DEFAULT_AUTH_OPTIONS, DEFAULT_REALTIME_OPTIONS, DEFAULT_TRACE_PROPAGATION_OPTIONS, otelModulePromise = null, OTEL_PKG = "@opentelemetry/api", resolveFetch2 = (customFetch) => {
18570
+ var import_functions_js, import_realtime_js, import_auth_js, version2 = "2.110.2", JS_ENV = "", JS_RUNTIME_VERSION, _Deno$version, _process$version, _runtimeMeta, DEFAULT_HEADERS2, DEFAULT_GLOBAL_OPTIONS, DEFAULT_DB_OPTIONS, DEFAULT_AUTH_OPTIONS, DEFAULT_REALTIME_OPTIONS, DEFAULT_TRACE_PROPAGATION_OPTIONS, otelModulePromise = null, OTEL_PKG = "@opentelemetry/api", resolveFetch2 = (customFetch) => {
18401
18571
  if (customFetch)
18402
18572
  return (...args) => customFetch(...args);
18403
18573
  return (...args) => fetch(...args);
@@ -18611,7 +18781,7 @@ var init_dist4 = __esm(() => {
18611
18781
  }
18612
18782
  };
18613
18783
  if (shouldShowDeprecationWarning())
18614
- console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");
18784
+ console.warn("⚠️ Node.js 20 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 22 or later. For more information, visit: https://github.com/orgs/supabase/discussions/45715");
18615
18785
  });
18616
18786
 
18617
18787
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
@@ -22742,6 +22912,7 @@ function loadSettings(opts = {}) {
22742
22912
  supabaseUrl: env2.CEREFOX_SUPABASE_URL ?? "",
22743
22913
  supabaseKey: env2.CEREFOX_SUPABASE_KEY ?? "",
22744
22914
  supabaseAnonKey: env2.CEREFOX_SUPABASE_ANON_KEY ?? "",
22915
+ accessToken: env2.CEREFOX_ACCESS_TOKEN ?? "",
22745
22916
  databaseUrl: env2.CEREFOX_DATABASE_URL ?? "",
22746
22917
  openaiApiKey: env2.CEREFOX_OPENAI_API_KEY ?? env2.OPENAI_API_KEY ?? "",
22747
22918
  fireworksApiKey: env2.CEREFOX_FIREWORKS_API_KEY ?? ""
@@ -25022,6 +25193,126 @@ var init_bundled_docs = __esm(() => {
25022
25193
  PACKAGE_ROOT = findPackageRoot();
25023
25194
  });
25024
25195
 
25196
+ // ../../_shared/ingest/chunker.ts
25197
+ function cpLen(s) {
25198
+ let n = 0;
25199
+ for (const _ of s)
25200
+ n++;
25201
+ return n;
25202
+ }
25203
+ function rstripHash(s) {
25204
+ let i = s.length;
25205
+ while (i > 0 && s[i - 1] === "#")
25206
+ i--;
25207
+ return s.slice(0, i);
25208
+ }
25209
+ function findHeadings(doc) {
25210
+ const out = [];
25211
+ const re = /^(#{1,3})[ \t]+(.+)$/gm;
25212
+ let m;
25213
+ while ((m = re.exec(doc)) !== null) {
25214
+ out.push({ offset: m.index, level: m[1].length, text: rstripHash(m[2]).trim() });
25215
+ }
25216
+ return out;
25217
+ }
25218
+ function activeHeadings(headings, offset) {
25219
+ const stack = [];
25220
+ for (const h of headings) {
25221
+ if (h.offset > offset)
25222
+ break;
25223
+ while (stack.length && stack[stack.length - 1].level >= h.level)
25224
+ stack.pop();
25225
+ stack.push(h);
25226
+ }
25227
+ return stack;
25228
+ }
25229
+ function hardSplitCp(s, maxCp) {
25230
+ const out = [];
25231
+ let buf = "";
25232
+ let n = 0;
25233
+ for (const ch of s) {
25234
+ if (n >= maxCp) {
25235
+ out.push(buf);
25236
+ buf = "";
25237
+ n = 0;
25238
+ }
25239
+ buf += ch;
25240
+ n++;
25241
+ }
25242
+ if (buf)
25243
+ out.push(buf);
25244
+ return out;
25245
+ }
25246
+ function chunkMarkdown(text, maxChunkChars = 4000, _minChunkChars = 100) {
25247
+ const doc = text.trim();
25248
+ if (!doc)
25249
+ return [];
25250
+ if (cpLen(doc) <= maxChunkChars) {
25251
+ return [
25252
+ { chunk_index: 0, heading_path: [], heading_level: 0, title: "", content: doc, char_count: cpLen(doc) }
25253
+ ];
25254
+ }
25255
+ const headings = findHeadings(doc);
25256
+ const parts = doc.split(/(\n{2,})/);
25257
+ const atoms = [];
25258
+ for (let i = 0;i < parts.length; i += 2) {
25259
+ const unit = (parts[i] ?? "") + (parts[i + 1] ?? "");
25260
+ if (unit === "")
25261
+ continue;
25262
+ if (cpLen(unit) > maxChunkChars)
25263
+ atoms.push(...hardSplitCp(unit, maxChunkChars));
25264
+ else
25265
+ atoms.push(unit);
25266
+ }
25267
+ const chunks = [];
25268
+ let buf = "";
25269
+ let bufCp = 0;
25270
+ let bufStart = 0;
25271
+ let offset = 0;
25272
+ const flush = () => {
25273
+ if (buf === "")
25274
+ return;
25275
+ const stack = activeHeadings(headings, bufStart);
25276
+ chunks.push({
25277
+ chunk_index: chunks.length,
25278
+ heading_path: stack.map((h) => h.text),
25279
+ heading_level: stack.length ? stack[stack.length - 1].level : 0,
25280
+ title: stack.length ? stack[stack.length - 1].text : "",
25281
+ content: buf,
25282
+ char_count: bufCp
25283
+ });
25284
+ buf = "";
25285
+ bufCp = 0;
25286
+ };
25287
+ for (const atom of atoms) {
25288
+ const cp = cpLen(atom);
25289
+ if (buf === "") {
25290
+ bufStart = offset;
25291
+ buf = atom;
25292
+ bufCp = cp;
25293
+ } else if (bufCp + cp <= maxChunkChars) {
25294
+ buf += atom;
25295
+ bufCp += cp;
25296
+ } else {
25297
+ flush();
25298
+ bufStart = offset;
25299
+ buf = atom;
25300
+ bufCp = cp;
25301
+ }
25302
+ offset += atom.length;
25303
+ }
25304
+ flush();
25305
+ return chunks;
25306
+ }
25307
+ function embeddingInputFor(docTitle, chunk) {
25308
+ const breadcrumb = chunk.heading_path.join(" > ");
25309
+ const head2 = breadcrumb ? `# ${docTitle}
25310
+ ${breadcrumb}` : `# ${docTitle}`;
25311
+ return `${head2}
25312
+ ${chunk.content}`;
25313
+ }
25314
+ var CONTENT_FORMAT_BLIND_STITCH = 2;
25315
+
25025
25316
  // ../../_shared/embeddings/index.ts
25026
25317
  function openaiEmbeddingConfig() {
25027
25318
  const env4 = globalThis.process?.env ?? {};
@@ -25033,9 +25324,26 @@ function openaiEmbeddingConfig() {
25033
25324
  dimensions: Number.isNaN(dims) || dims <= 0 ? EMBEDDING_DIMENSIONS : dims
25034
25325
  };
25035
25326
  }
25327
+ function embeddingMaxInputChars() {
25328
+ const env4 = globalThis.process?.env ?? {};
25329
+ const raw = Number.parseInt(env4.CEREFOX_EMBED_MAX_INPUT_CHARS ?? "", 10);
25330
+ return Number.isNaN(raw) || raw <= 0 ? DEFAULT_EMBED_MAX_INPUT_CHARS : raw;
25331
+ }
25332
+ function capEmbeddingInput(text) {
25333
+ const max = embeddingMaxInputChars();
25334
+ if (text.length <= max)
25335
+ return text;
25336
+ let cut = text.slice(0, max);
25337
+ const last = cut.charCodeAt(cut.length - 1);
25338
+ if (last >= 55296 && last <= 56319)
25339
+ cut = cut.slice(0, -1);
25340
+ console.warn(`[embeddings] truncated an embedding input: ${text.length} → ${cut.length} chars ` + `(cap CEREFOX_EMBED_MAX_INPUT_CHARS=${max}). The full content is stored and reconstructed ` + `untouched; only this chunk's embedding uses the prefix (degraded search for this chunk).`);
25341
+ return cut;
25342
+ }
25036
25343
  async function getEmbedding(text, apiKey) {
25037
25344
  let lastError = null;
25038
25345
  const cfg = openaiEmbeddingConfig();
25346
+ const input = capEmbeddingInput(text);
25039
25347
  for (let attempt = 0;attempt < EMBEDDING_MAX_RETRIES; attempt++) {
25040
25348
  try {
25041
25349
  const response = await fetch(cfg.url, {
@@ -25046,7 +25354,7 @@ async function getEmbedding(text, apiKey) {
25046
25354
  },
25047
25355
  body: JSON.stringify({
25048
25356
  model: cfg.model,
25049
- input: text,
25357
+ input,
25050
25358
  dimensions: cfg.dimensions
25051
25359
  })
25052
25360
  });
@@ -25079,6 +25387,7 @@ async function getEmbedding(text, apiKey) {
25079
25387
  async function embedBatchSingleCall(texts, apiKey) {
25080
25388
  let lastError = null;
25081
25389
  const cfg = openaiEmbeddingConfig();
25390
+ const inputs = texts.map(capEmbeddingInput);
25082
25391
  for (let attempt = 0;attempt < EMBEDDING_MAX_RETRIES; attempt++) {
25083
25392
  try {
25084
25393
  const response = await fetch(cfg.url, {
@@ -25089,7 +25398,7 @@ async function embedBatchSingleCall(texts, apiKey) {
25089
25398
  },
25090
25399
  body: JSON.stringify({
25091
25400
  model: cfg.model,
25092
- input: texts,
25401
+ input: inputs,
25093
25402
  dimensions: cfg.dimensions
25094
25403
  })
25095
25404
  });
@@ -25135,7 +25444,7 @@ async function embedBatch(texts, apiKey, batchSize = EMBEDDING_BATCH_SIZE) {
25135
25444
  }
25136
25445
  return out;
25137
25446
  }
25138
- var OPENAI_EMBEDDING_URL = "https://api.openai.com/v1/embeddings", OPENAI_MODEL = "text-embedding-3-small", EMBEDDING_DIMENSIONS = 768, EMBEDDING_MAX_RETRIES = 3, EMBEDDING_INITIAL_BACKOFF_MS = 500, EMBEDDING_BATCH_SIZE = 96;
25447
+ var OPENAI_EMBEDDING_URL = "https://api.openai.com/v1/embeddings", OPENAI_MODEL = "text-embedding-3-small", EMBEDDING_DIMENSIONS = 768, DEFAULT_EMBED_MAX_INPUT_CHARS = 20000, EMBEDDING_MAX_RETRIES = 3, EMBEDDING_INITIAL_BACKOFF_MS = 500, EMBEDDING_BATCH_SIZE = 96;
25139
25448
 
25140
25449
  // ../../node_modules/.bun/underscore@1.13.8/node_modules/underscore/underscore-node-f.cjs
25141
25450
  var require_underscore_node_f = __commonJS((exports) => {
@@ -54039,10 +54348,10 @@ var init_get_document = __esm(() => {
54039
54348
  });
54040
54349
 
54041
54350
  // ../../_shared/mcp-tools/get-help-content.ts
54042
- var HELP_FULL = '# Cerefox Knowledge Base -- Agent Quick Reference\n\nCerefox is a persistent, shared knowledge base. You have **10 MCP tools** (9 of them have CLI equivalents — `cerefox_get_help` is MCP-only). For the full guide, search Cerefox for "How AI Agents Use Cerefox" or call `cerefox_get_help` to retrieve this content over MCP.\n\n## Tools\n\n| Tool | Purpose | Key params |\n|------|---------|------------|\n| `cerefox_search` | Find documents (hybrid FTS + semantic) | `query` (required), `project_name`, `metadata_filter`, `requestor` |\n| `cerefox_ingest` | Save or update a document | `title`, `content` (required), `document_id` (update by ID), `expected_content_hash` (**required on content updates** — see rule 9), `last_write_wins`, `update_if_exists`, `project_name` (single, non-destructive add on update), `project_names` (list, destructive replace on update), `metadata`, `author` |\n| `cerefox_get_document` | Get full document by ID (header includes `content_hash` — the update token) | `document_id` (required) |\n| `cerefox_list_versions` | Version history of a document | `document_id` (required) |\n| `cerefox_metadata_search` | Find or list docs by metadata, project, or time (no text query) | `metadata_filter`, `project_name` (list a project\'s docs), `updated_since`, `include_content` — **at least one** of metadata_filter/project_name/updated_since/created_since |\n| `cerefox_list_metadata_keys` | Discover available metadata keys | (none required) |\n| `cerefox_list_projects` | List all projects | (none required) |\n| `cerefox_set_document_projects` | Set doc\'s project memberships to exactly the given list (destructive replace; metadata-only, no content change) | `document_id`, `project_names` (required) |\n| `cerefox_get_audit_log` | Query write operation history | `document_id`, `author`, `operation`, `since` |\n| `cerefox_get_help` | Retrieve Cerefox conventions (this reference) over MCP. **Call this whenever uncertain.** | `topic` (optional, case-insensitive H2 substring match) |\n\n## Essential Rules\n\n1. **Search before ingesting** -- check if the document exists first.\n2. **Prefer ID-based updates** -- pass `document_id` from search results for deterministic updates. Falls back to title-matching with `update_if_exists: true`.\n3. **Set `author`/`requestor`** to your name on every call (e.g., "Claude Code", "archiver"). On MCP, pass as parameters. On CLI, pass `--author`/`--author-type`/`--requestor` flags, or rely on `CEREFOX_AUTHOR_NAME`/`CEREFOX_AUTHOR_TYPE`/`CEREFOX_REQUESTOR_NAME` env vars set in the user\'s `.env`.\n4. **Use `document_id` from search results** `[id: uuid]` for get_document and list_versions.\n5. **Add metadata** -- at minimum `type` ("decision-log", "research", "design-doc") and `status` ("active", "draft").\n6. **Write structured Markdown** with H1/H2/H3 headings for good chunking and search.\n7. **Deletes are soft (recoverable); purge is web-UI-only.** If you decide to delete, surface it to the user (`I soft-deleted X — recoverable from the Cerefox web UI trash`). You cannot un-do your own delete from agent code by design.\n8. **Cross-doc links inside content**: **always use `[Text](document-uuid)`.** UUIDs are the only fully reliable link form — stable across title changes, never ambiguous, no encoding gotchas. Every `cerefox_search` result shows `[id: <uuid>]` after the title; grab it and use it. Title-based linking (`[Text](<Title With Spaces>)`) is fragile (breaks on colons, parens, ampersands, brackets — silently navigates to wrong page) — **don\'t write title-based links**; do an extra search to get the UUID instead. Repo-path forms (`[Text](docs/path.md)`) exist for repo-ingested files; don\'t construct manually. See `AGENT_GUIDE.md → Writing linkable content` for the full rule.\n9. **Concurrency: content updates require `expected_content_hash`.** Pass the `content_hash` you read (shown by `cerefox_get_document`, `cerefox_search`, and `cerefox_metadata_search`) when updating a document. If it\'s stale you get a **conflict** — re-read the document, merge your changes into the latest content, retry with the new hash. **Never resolve a conflict by overwriting blindly** — the current content includes another writer\'s work. `last_write_wins: true` skips the check; use it ONLY when an external source of truth makes conflicts meaningless (file re-sync), never to silence a conflict.\n10. **Project memberships — non-destructive by default**: on `cerefox_ingest` updates, **`project_name` (singular) is a non-destructive add** (ensures membership, preserves others). Use **`project_names` (list)** when you want to set the doc\'s full project set in one call (destructive replace). For metadata-only project changes without writing content, use **`cerefox_set_document_projects(document_id, project_names)`** — that tool is the destructive-replace contract made explicit. Never call `cerefox_set_document_projects` with a single name when you mean "add" — that would REMOVE the doc from all other projects. When in doubt, use `cerefox_ingest` with singular `project_name`.\n\n## Update Workflow (ID-based -- preferred)\n\n```\nsearch("topic") -> find doc [id: abc123] -> get_document(abc123) -> note its content_hash -> modify ->\ningest(title="Same Title", content="...", document_id="abc123",\n expected_content_hash="<the hash you read>", author="my-agent")\n```\n\nOn a **conflict** error: get_document again (fresh content + fresh hash) -> merge your changes -> retry with the new hash.\n\n## Update Workflow (title-based -- fallback)\n\n```\nsearch("topic") -> find doc (note its hash) -> modify ->\ningest(title="Same Title", content="...", update_if_exists=true,\n expected_content_hash="<the hash you read>", author="my-agent")\n```\n\n## Catch-Up Workflow\n\n```\nmetadata_search(metadata_filter={"type": "decision-log"}, updated_since="2026-03-28T00:00:00Z")\n```\n\n## CLI fallback (when MCP is unavailable)\n\nIf `cerefox_search` is not in your tool list, your user has likely installed the Cerefox CLI. The canonical invocation is plain **`cerefox <subcommand>`** (the TypeScript CLI, installed via `npm install -g @cerefox/memory`). It uses a resource-verb shape (`cerefox document get`, `cerefox project list`, …). The legacy Python `uv run cerefox` is now a frozen husk as of v0.9 — only `uv run cerefox mcp` still works.\n\nSame operations, same conventions. Full reference: [`docs/guides/cli.md`](docs/guides/cli.md). CLI flag names match MCP parameter names exactly (e.g. `metadata_filter` ↔ `--metadata-filter`); common flags also have single-letter short forms (`-f`, `-p`, `-c`, `-m`, `-u`, `-a`, `-r`). Use the canonical long name (what `--help` shows) or its short form — there are no long-form aliases like `--filter` or `--count`.\n\n| MCP tool | CLI |\n|---|---|\n| `cerefox_search` | `cerefox search "<q>" --requestor "<your-name>"` |\n| `cerefox_ingest` (paste) | `printf \'...\' \\| cerefox document ingest --paste --title "<t>" --author "<your-name>" --author-type agent` |\n| `cerefox_ingest` (update by ID) | `printf \'...\' \\| cerefox document ingest --paste --title "<t>" --document-id "<uuid>" --expected-content-hash "<hash>" --author "<your-name>" --author-type agent` |\n| `cerefox_get_document` | `cerefox document get <id> --version-id <vid> --requestor "<your-name>"` |\n| `cerefox_list_versions` | `cerefox document version list <id> --requestor "<your-name>"` |\n| `cerefox_list_projects` | `cerefox project list --requestor "<your-name>"` |\n| `cerefox_list_metadata_keys` | `cerefox metadata keys` |\n| `cerefox_metadata_search` | `cerefox metadata search --metadata-filter \'<json>\' --requestor "<your-name>"` (list a project: `cerefox document list --project <name>`) |\n| `cerefox_set_document_projects` | `cerefox document set-projects <id> <name...> --author "<your-name>" --author-type agent` (or `--clear` to remove all) |\n| `cerefox_get_audit_log` | `cerefox audit list --requestor "<your-name>"` (add `--json` for scripted access) |\n| `cerefox_get_help` | `cerefox guides show agent-quick-reference` (or `cerefox guides list` for the full bundled-docs index) |\n\n**Set identity on every call**, exactly as you would on MCP:\n- Writes (`document ingest`, `document ingest-dir`): `--author "<your-name>" --author-type agent`\n- Reads: `--requestor "<your-name>"`\n\nOr have your user set `CEREFOX_AUTHOR_NAME` / `CEREFOX_AUTHOR_TYPE` / `CEREFOX_REQUESTOR_NAME` in their `.env` to apply defaults once.\n', HELP_SECTIONS, HELP_SECTION_HEADINGS;
54351
+ var HELP_FULL = '# Cerefox Knowledge Base -- Agent Quick Reference\n\nCerefox is a persistent, shared knowledge base. You have **10 MCP tools** (9 of them have CLI equivalents — `cerefox_get_help` is MCP-only). For the full guide, search Cerefox for "How AI Agents Use Cerefox" or call `cerefox_get_help` to retrieve this content over MCP.\n\n## Tools\n\n| Tool | Purpose | Key params |\n|------|---------|------------|\n| `cerefox_search` | Find documents (hybrid FTS + semantic) | `query` (required), `project_name`, `metadata_filter`, `requestor` |\n| `cerefox_ingest` | Save or update a document | `title`, `content` (required), `document_id` (update by ID), `expected_content_hash` (**required on content updates** — see rule 9), `last_write_wins`, `update_if_exists`, `project_name` (single, non-destructive add on update), `project_names` (list, destructive replace on update), `metadata` (omit on update to keep existing tags; `{}` clears), `author` |\n| `cerefox_get_document` | Get full document by ID (header includes `content_hash` — the update token) | `document_id` (required) |\n| `cerefox_list_versions` | Version history of a document | `document_id` (required) |\n| `cerefox_metadata_search` | Find or list docs by metadata, project, or time (no text query) | `metadata_filter`, `project_name` (list a project\'s docs), `updated_since`, `include_content` — **at least one** of metadata_filter/project_name/updated_since/created_since |\n| `cerefox_list_metadata_keys` | Discover available metadata keys | (none required) |\n| `cerefox_list_projects` | List all projects | (none required) |\n| `cerefox_set_document_projects` | Set doc\'s project memberships to exactly the given list (destructive replace; metadata-only, no content change) | `document_id`, `project_names` (required) |\n| `cerefox_get_audit_log` | Query write operation history | `document_id`, `author`, `operation`, `since` |\n| `cerefox_get_help` | Retrieve Cerefox conventions (this reference) over MCP. **Call this whenever uncertain.** | `topic` (optional, case-insensitive H2 substring match) |\n\n## Essential Rules\n\n1. **Search before ingesting** -- check if the document exists first.\n2. **Prefer ID-based updates** -- pass `document_id` from search results for deterministic updates. Falls back to title-matching with `update_if_exists: true`.\n3. **Set `author`/`requestor`** to your name on every call (e.g., "Claude Code", "archiver"). On MCP, pass as parameters. On CLI, pass `--author`/`--author-type`/`--requestor` flags, or rely on `CEREFOX_AUTHOR_NAME`/`CEREFOX_AUTHOR_TYPE`/`CEREFOX_REQUESTOR_NAME` env vars set in the user\'s `.env`.\n4. **Use `document_id` from search results** `[id: uuid]` for get_document and list_versions.\n5. **Add metadata** -- at minimum `type` ("decision-log", "research", "design-doc") and `status` ("active", "draft").\n6. **Write structured Markdown** with H1/H2/H3 headings for good chunking and search.\n7. **Deletes are soft (recoverable); purge is web-UI-only.** If you decide to delete, surface it to the user (`I soft-deleted X — recoverable from the Cerefox web UI trash`). You cannot un-do your own delete from agent code by design.\n8. **Cross-doc links inside content**: **always use `[Text](document-uuid)`.** UUIDs are the only fully reliable link form — stable across title changes, never ambiguous, no encoding gotchas. Every `cerefox_search` result shows `[id: <uuid>]` after the title; grab it and use it. Title-based linking (`[Text](<Title With Spaces>)`) is fragile (breaks on colons, parens, ampersands, brackets — silently navigates to wrong page) — **don\'t write title-based links**; do an extra search to get the UUID instead. Repo-path forms (`[Text](docs/path.md)`) exist for repo-ingested files; don\'t construct manually. See `AGENT_GUIDE.md → Writing linkable content` for the full rule.\n9. **Concurrency: content updates require `expected_content_hash`.** Pass the `content_hash` you read (shown by `cerefox_get_document`, `cerefox_search`, and `cerefox_metadata_search`) when updating a document. If it\'s stale you get a **conflict** — re-read the document, merge your changes into the latest content, retry with the new hash. **Never resolve a conflict by overwriting blindly** — the current content includes another writer\'s work. `last_write_wins: true` skips the check; use it ONLY when an external source of truth makes conflicts meaningless (file re-sync), never to silence a conflict.\n10. **Project memberships — non-destructive by default**: on `cerefox_ingest` updates, **`project_name` (singular) is a non-destructive add** (ensures membership, preserves others). Use **`project_names` (list)** when you want to set the doc\'s full project set in one call (destructive replace). For metadata-only project changes without writing content, use **`cerefox_set_document_projects(document_id, project_names)`** — that tool is the destructive-replace contract made explicit. Never call `cerefox_set_document_projects` with a single name when you mean "add" — that would REMOVE the doc from all other projects. When in doubt, use `cerefox_ingest` with singular `project_name`.\n\n## Update Workflow (ID-based -- preferred)\n\n```\nsearch("topic") -> find doc [id: abc123] -> get_document(abc123) -> note its content_hash -> modify ->\ningest(title="Same Title", content="...", document_id="abc123",\n expected_content_hash="<the hash you read>", author="my-agent")\n```\n\nOn a **conflict** error: get_document again (fresh content + fresh hash) -> merge your changes -> retry with the new hash.\n\n## Update Workflow (title-based -- fallback)\n\n```\nsearch("topic") -> find doc (note its hash) -> modify ->\ningest(title="Same Title", content="...", update_if_exists=true,\n expected_content_hash="<the hash you read>", author="my-agent")\n```\n\n## Catch-Up Workflow\n\n```\nmetadata_search(metadata_filter={"type": "decision-log"}, updated_since="2026-03-28T00:00:00Z")\n```\n\n## CLI fallback (when MCP is unavailable)\n\nIf `cerefox_search` is not in your tool list, your user has likely installed the Cerefox CLI. The canonical invocation is plain **`cerefox <subcommand>`** (the TypeScript CLI, installed via `npm install -g @cerefox/memory`). It uses a resource-verb shape (`cerefox document get`, `cerefox project list`, …). The legacy Python `uv run cerefox` is now a frozen husk as of v0.9 — only `uv run cerefox mcp` still works.\n\nSame operations, same conventions. Full reference: [`docs/guides/cli.md`](docs/guides/cli.md). CLI flag names match MCP parameter names exactly (e.g. `metadata_filter` ↔ `--metadata-filter`); common flags also have single-letter short forms (`-f`, `-p`, `-c`, `-m`, `-u`, `-a`, `-r`). Use the canonical long name (what `--help` shows) or its short form — there are no long-form aliases like `--filter` or `--count`.\n\n| MCP tool | CLI |\n|---|---|\n| `cerefox_search` | `cerefox search "<q>" --requestor "<your-name>"` |\n| `cerefox_ingest` (paste) | `printf \'...\' \\| cerefox document ingest --paste --title "<t>" --author "<your-name>" --author-type agent` |\n| `cerefox_ingest` (update by ID) | `printf \'...\' \\| cerefox document ingest --paste --title "<t>" --document-id "<uuid>" --expected-content-hash "<hash>" --author "<your-name>" --author-type agent` |\n| `cerefox_get_document` | `cerefox document get <id> --version-id <vid> --requestor "<your-name>"` |\n| `cerefox_list_versions` | `cerefox document version list <id> --requestor "<your-name>"` |\n| `cerefox_list_projects` | `cerefox project list --requestor "<your-name>"` |\n| `cerefox_list_metadata_keys` | `cerefox metadata keys` |\n| `cerefox_metadata_search` | `cerefox metadata search --metadata-filter \'<json>\' --requestor "<your-name>"` (list a project: `cerefox document list --project <name>`) |\n| `cerefox_set_document_projects` | `cerefox document set-projects <id> <name...> --author "<your-name>" --author-type agent` (or `--clear` to remove all) |\n| `cerefox_get_audit_log` | `cerefox audit list --requestor "<your-name>"` (add `--json` for scripted access) |\n| `cerefox_get_help` | `cerefox guides show agent-quick-reference` (or `cerefox guides list` for the full bundled-docs index) |\n\n**Set identity on every call**, exactly as you would on MCP:\n- Writes (`document ingest`, `document ingest-dir`): `--author "<your-name>" --author-type agent`\n- Reads: `--requestor "<your-name>"`\n\nOr have your user set `CEREFOX_AUTHOR_NAME` / `CEREFOX_AUTHOR_TYPE` / `CEREFOX_REQUESTOR_NAME` in their `.env` to apply defaults once.\n', HELP_SECTIONS, HELP_SECTION_HEADINGS;
54043
54352
  var init_get_help_content = __esm(() => {
54044
54353
  HELP_SECTIONS = {
54045
- Tools: "## Tools\n\n| Tool | Purpose | Key params |\n|------|---------|------------|\n| `cerefox_search` | Find documents (hybrid FTS + semantic) | `query` (required), `project_name`, `metadata_filter`, `requestor` |\n| `cerefox_ingest` | Save or update a document | `title`, `content` (required), `document_id` (update by ID), `expected_content_hash` (**required on content updates** — see rule 9), `last_write_wins`, `update_if_exists`, `project_name` (single, non-destructive add on update), `project_names` (list, destructive replace on update), `metadata`, `author` |\n| `cerefox_get_document` | Get full document by ID (header includes `content_hash` — the update token) | `document_id` (required) |\n| `cerefox_list_versions` | Version history of a document | `document_id` (required) |\n| `cerefox_metadata_search` | Find or list docs by metadata, project, or time (no text query) | `metadata_filter`, `project_name` (list a project's docs), `updated_since`, `include_content` — **at least one** of metadata_filter/project_name/updated_since/created_since |\n| `cerefox_list_metadata_keys` | Discover available metadata keys | (none required) |\n| `cerefox_list_projects` | List all projects | (none required) |\n| `cerefox_set_document_projects` | Set doc's project memberships to exactly the given list (destructive replace; metadata-only, no content change) | `document_id`, `project_names` (required) |\n| `cerefox_get_audit_log` | Query write operation history | `document_id`, `author`, `operation`, `since` |\n| `cerefox_get_help` | Retrieve Cerefox conventions (this reference) over MCP. **Call this whenever uncertain.** | `topic` (optional, case-insensitive H2 substring match) |",
54354
+ Tools: "## Tools\n\n| Tool | Purpose | Key params |\n|------|---------|------------|\n| `cerefox_search` | Find documents (hybrid FTS + semantic) | `query` (required), `project_name`, `metadata_filter`, `requestor` |\n| `cerefox_ingest` | Save or update a document | `title`, `content` (required), `document_id` (update by ID), `expected_content_hash` (**required on content updates** — see rule 9), `last_write_wins`, `update_if_exists`, `project_name` (single, non-destructive add on update), `project_names` (list, destructive replace on update), `metadata` (omit on update to keep existing tags; `{}` clears), `author` |\n| `cerefox_get_document` | Get full document by ID (header includes `content_hash` — the update token) | `document_id` (required) |\n| `cerefox_list_versions` | Version history of a document | `document_id` (required) |\n| `cerefox_metadata_search` | Find or list docs by metadata, project, or time (no text query) | `metadata_filter`, `project_name` (list a project's docs), `updated_since`, `include_content` — **at least one** of metadata_filter/project_name/updated_since/created_since |\n| `cerefox_list_metadata_keys` | Discover available metadata keys | (none required) |\n| `cerefox_list_projects` | List all projects | (none required) |\n| `cerefox_set_document_projects` | Set doc's project memberships to exactly the given list (destructive replace; metadata-only, no content change) | `document_id`, `project_names` (required) |\n| `cerefox_get_audit_log` | Query write operation history | `document_id`, `author`, `operation`, `since` |\n| `cerefox_get_help` | Retrieve Cerefox conventions (this reference) over MCP. **Call this whenever uncertain.** | `topic` (optional, case-insensitive H2 substring match) |",
54046
54355
  "Essential Rules": '## Essential Rules\n\n1. **Search before ingesting** -- check if the document exists first.\n2. **Prefer ID-based updates** -- pass `document_id` from search results for deterministic updates. Falls back to title-matching with `update_if_exists: true`.\n3. **Set `author`/`requestor`** to your name on every call (e.g., "Claude Code", "archiver"). On MCP, pass as parameters. On CLI, pass `--author`/`--author-type`/`--requestor` flags, or rely on `CEREFOX_AUTHOR_NAME`/`CEREFOX_AUTHOR_TYPE`/`CEREFOX_REQUESTOR_NAME` env vars set in the user\'s `.env`.\n4. **Use `document_id` from search results** `[id: uuid]` for get_document and list_versions.\n5. **Add metadata** -- at minimum `type` ("decision-log", "research", "design-doc") and `status` ("active", "draft").\n6. **Write structured Markdown** with H1/H2/H3 headings for good chunking and search.\n7. **Deletes are soft (recoverable); purge is web-UI-only.** If you decide to delete, surface it to the user (`I soft-deleted X — recoverable from the Cerefox web UI trash`). You cannot un-do your own delete from agent code by design.\n8. **Cross-doc links inside content**: **always use `[Text](document-uuid)`.** UUIDs are the only fully reliable link form — stable across title changes, never ambiguous, no encoding gotchas. Every `cerefox_search` result shows `[id: <uuid>]` after the title; grab it and use it. Title-based linking (`[Text](<Title With Spaces>)`) is fragile (breaks on colons, parens, ampersands, brackets — silently navigates to wrong page) — **don\'t write title-based links**; do an extra search to get the UUID instead. Repo-path forms (`[Text](docs/path.md)`) exist for repo-ingested files; don\'t construct manually. See `AGENT_GUIDE.md → Writing linkable content` for the full rule.\n9. **Concurrency: content updates require `expected_content_hash`.** Pass the `content_hash` you read (shown by `cerefox_get_document`, `cerefox_search`, and `cerefox_metadata_search`) when updating a document. If it\'s stale you get a **conflict** — re-read the document, merge your changes into the latest content, retry with the new hash. **Never resolve a conflict by overwriting blindly** — the current content includes another writer\'s work. `last_write_wins: true` skips the check; use it ONLY when an external source of truth makes conflicts meaningless (file re-sync), never to silence a conflict.\n10. **Project memberships — non-destructive by default**: on `cerefox_ingest` updates, **`project_name` (singular) is a non-destructive add** (ensures membership, preserves others). Use **`project_names` (list)** when you want to set the doc\'s full project set in one call (destructive replace). For metadata-only project changes without writing content, use **`cerefox_set_document_projects(document_id, project_names)`** — that tool is the destructive-replace contract made explicit. Never call `cerefox_set_document_projects` with a single name when you mean "add" — that would REMOVE the doc from all other projects. When in doubt, use `cerefox_ingest` with singular `project_name`.',
54047
54356
  "Update Workflow (ID-based -- preferred)": `## Update Workflow (ID-based -- preferred)
54048
54357
 
@@ -54122,144 +54431,6 @@ var init_get_help = __esm(() => {
54122
54431
  });
54123
54432
 
54124
54433
  // ../../_shared/mcp-tools/_chunker.ts
54125
- function parseSections2(text) {
54126
- const lines = text.split(`
54127
- `);
54128
- const sections = [];
54129
- let currentHeadings = [];
54130
- let currentLevel = 0;
54131
- let bodyLines = [];
54132
- function collectSection() {
54133
- const body = bodyLines.join(`
54134
- `).trim();
54135
- bodyLines = [];
54136
- let content;
54137
- if (currentLevel > 0) {
54138
- const headerLine = "#".repeat(currentLevel) + " " + (currentHeadings[currentHeadings.length - 1] ?? "");
54139
- content = body ? headerLine + `
54140
-
54141
- ` + body : headerLine;
54142
- } else {
54143
- content = body;
54144
- }
54145
- if (!content.trim())
54146
- return;
54147
- sections.push({
54148
- level: currentLevel,
54149
- headings: [...currentHeadings],
54150
- heading: currentHeadings[currentHeadings.length - 1] ?? "",
54151
- content,
54152
- body
54153
- });
54154
- }
54155
- for (const line of lines) {
54156
- const h1 = line.match(/^# (.+)/);
54157
- const h2 = line.match(/^## (.+)/);
54158
- const h3 = line.match(/^### (.+)/);
54159
- if (h1) {
54160
- collectSection();
54161
- currentHeadings = [h1[1].trim()];
54162
- currentLevel = 1;
54163
- } else if (h2) {
54164
- collectSection();
54165
- currentHeadings = [currentHeadings[0] ?? "", h2[1].trim()].filter(Boolean);
54166
- currentLevel = 2;
54167
- } else if (h3) {
54168
- collectSection();
54169
- currentHeadings = [
54170
- currentHeadings[0] ?? "",
54171
- currentHeadings[1] ?? "",
54172
- h3[1].trim()
54173
- ].filter(Boolean);
54174
- currentLevel = 3;
54175
- } else {
54176
- bodyLines.push(line);
54177
- }
54178
- }
54179
- collectSection();
54180
- return sections;
54181
- }
54182
- function makeChunk(headings, level, content) {
54183
- const title = headings[headings.length - 1] ?? "";
54184
- return {
54185
- heading_path: [...headings],
54186
- heading_level: level,
54187
- title,
54188
- content,
54189
- char_count: content.length
54190
- };
54191
- }
54192
- function chunkMarkdown2(text) {
54193
- const trimmed = text.trim();
54194
- if (!trimmed)
54195
- return [];
54196
- if (trimmed.length <= MAX_CHUNK_CHARS) {
54197
- return [makeChunk([], 0, trimmed)];
54198
- }
54199
- const sections = parseSections2(trimmed);
54200
- const chunks = [];
54201
- let bufParts = [];
54202
- let bufHeadings = [];
54203
- let bufLevel = 0;
54204
- let bufChars = 0;
54205
- function flushBuf() {
54206
- if (bufParts.length === 0)
54207
- return;
54208
- chunks.push(makeChunk(bufHeadings, bufLevel, bufParts.join(`
54209
-
54210
- `)));
54211
- bufParts = [];
54212
- bufHeadings = [];
54213
- bufLevel = 0;
54214
- bufChars = 0;
54215
- }
54216
- for (const section of sections) {
54217
- const { level, headings, heading, content, body } = section;
54218
- if (content.length > MAX_CHUNK_CHARS) {
54219
- flushBuf();
54220
- const headerPrefix = level > 0 ? "#".repeat(level) + " " + heading + `
54221
-
54222
- ` : "";
54223
- const bodyToSplit = body || content;
54224
- const paragraphs = bodyToSplit.split(/\n\n+/);
54225
- let sub = "";
54226
- let isFirst = true;
54227
- for (const para of paragraphs) {
54228
- const prefix = isFirst ? headerPrefix : "";
54229
- if (sub.length + prefix.length + para.length + 2 > MAX_CHUNK_CHARS && sub.length > 0) {
54230
- chunks.push(makeChunk(headings, level, sub.trim()));
54231
- sub = para;
54232
- isFirst = false;
54233
- } else {
54234
- sub = sub ? sub + `
54235
-
54236
- ` + para : prefix + para;
54237
- isFirst = false;
54238
- }
54239
- }
54240
- if (sub.trim())
54241
- chunks.push(makeChunk(headings, level, sub.trim()));
54242
- continue;
54243
- }
54244
- const addition = content.length + (bufParts.length > 0 ? 2 : 0);
54245
- if (bufChars + addition <= MAX_CHUNK_CHARS) {
54246
- if (bufParts.length === 0) {
54247
- bufHeadings = headings;
54248
- bufLevel = level;
54249
- }
54250
- bufParts.push(content);
54251
- bufChars += addition;
54252
- } else {
54253
- flushBuf();
54254
- bufParts = [content];
54255
- bufHeadings = headings;
54256
- bufLevel = level;
54257
- bufChars = content.length;
54258
- }
54259
- }
54260
- flushBuf();
54261
- return chunks;
54262
- }
54263
54434
  function normalizeContent(text) {
54264
54435
  return text.trim().replace(/\r\n/g, `
54265
54436
  `).replace(/\r/g, `
@@ -54272,7 +54443,7 @@ async function sha256hex(text) {
54272
54443
  const hash = await crypto.subtle.digest("SHA-256", bytes);
54273
54444
  return Array.from(new Uint8Array(hash)).map((b2) => b2.toString(16).padStart(2, "0")).join("");
54274
54445
  }
54275
- var MAX_CHUNK_CHARS = 4000;
54446
+ var init__chunker = () => {};
54276
54447
 
54277
54448
  // ../../_shared/mcp-tools/ingest.ts
54278
54449
  function conflictError(documentId, expectedHash, currentHash) {
@@ -54297,7 +54468,7 @@ async function handler4(supabase, args, ctx) {
54297
54468
  const project_name = args.project_name;
54298
54469
  const project_names_raw = args.project_names;
54299
54470
  const source = args.source ?? "agent";
54300
- const metadata = args.metadata ?? {};
54471
+ const metadata = args.metadata ?? null;
54301
54472
  const update_if_exists = args.update_if_exists ?? false;
54302
54473
  const author = args.author ?? "mcp-agent";
54303
54474
  const author_type = "agent";
@@ -54328,11 +54499,10 @@ async function handler4(supabase, args, ctx) {
54328
54499
  if (!last_write_wins && expected_content_hash && expected_content_hash !== existingDoc.content_hash) {
54329
54500
  throw conflictError(existingDoc.id, expected_content_hash, existingDoc.content_hash);
54330
54501
  }
54331
- const chunks2 = chunkMarkdown2(content);
54502
+ const chunks2 = chunkMarkdown(content);
54332
54503
  if (chunks2.length === 0)
54333
54504
  throw new Error("Content produced no chunks");
54334
- const texts2 = chunks2.map((c2) => `# ${title}
54335
- ${c2.content}`);
54505
+ const texts2 = chunks2.map((c2) => embeddingInputFor(title, c2));
54336
54506
  const embeddings2 = await embedBatch(texts2, ctx.openaiApiKey);
54337
54507
  const totalChars2 = chunks2.reduce((s, c2) => s + c2.char_count, 0);
54338
54508
  const chunkData2 = chunks2.map((chunk, i) => ({
@@ -54357,7 +54527,8 @@ ${c2.content}`);
54357
54527
  p_author_type: author_type,
54358
54528
  p_source_label: source,
54359
54529
  p_expected_content_hash: expected_content_hash,
54360
- p_last_write_wins: last_write_wins
54530
+ p_last_write_wins: last_write_wins,
54531
+ p_content_format: CONTENT_FORMAT_BLIND_STITCH
54361
54532
  });
54362
54533
  if (ingestErr2)
54363
54534
  throw mapIngestRpcError(ingestErr2.message, existingDoc.id);
@@ -54386,11 +54557,10 @@ ${c2.content}`);
54386
54557
  if (!last_write_wins && expected_content_hash && expected_content_hash !== existingDoc.content_hash) {
54387
54558
  throw conflictError(existingDoc.id, expected_content_hash, existingDoc.content_hash);
54388
54559
  }
54389
- const chunks2 = chunkMarkdown2(content);
54560
+ const chunks2 = chunkMarkdown(content);
54390
54561
  if (chunks2.length === 0)
54391
54562
  throw new Error("Content produced no chunks");
54392
- const texts2 = chunks2.map((c2) => `# ${title}
54393
- ${c2.content}`);
54563
+ const texts2 = chunks2.map((c2) => embeddingInputFor(title, c2));
54394
54564
  const embeddings2 = await embedBatch(texts2, ctx.openaiApiKey);
54395
54565
  const totalChars2 = chunks2.reduce((s, c2) => s + c2.char_count, 0);
54396
54566
  const chunkData2 = chunks2.map((chunk, i) => ({
@@ -54415,7 +54585,8 @@ ${c2.content}`);
54415
54585
  p_author_type: author_type,
54416
54586
  p_source_label: source,
54417
54587
  p_expected_content_hash: expected_content_hash,
54418
- p_last_write_wins: last_write_wins
54588
+ p_last_write_wins: last_write_wins,
54589
+ p_content_format: CONTENT_FORMAT_BLIND_STITCH
54419
54590
  });
54420
54591
  if (ingestErr2)
54421
54592
  throw mapIngestRpcError(ingestErr2.message, existingDoc.id);
@@ -54438,11 +54609,10 @@ ${c2.content}`);
54438
54609
  if (hashMatch?.length) {
54439
54610
  return `Document already up-to-date: "${hashMatch[0].title}" (id: ${hashMatch[0].id}). Content hash unchanged.`;
54440
54611
  }
54441
- const chunks = chunkMarkdown2(content);
54612
+ const chunks = chunkMarkdown(content);
54442
54613
  if (chunks.length === 0)
54443
54614
  throw new Error("Content produced no chunks");
54444
- const texts = chunks.map((c2) => `# ${title}
54445
- ${c2.content}`);
54615
+ const texts = chunks.map((c2) => embeddingInputFor(title, c2));
54446
54616
  const embeddings = await embedBatch(texts, ctx.openaiApiKey);
54447
54617
  const totalChars = chunks.reduce((s, c2) => s + c2.char_count, 0);
54448
54618
  const chunkData = chunks.map((chunk, i) => ({
@@ -54464,7 +54634,8 @@ ${c2.content}`);
54464
54634
  p_review_status: reviewStatus,
54465
54635
  p_chunks: chunkData,
54466
54636
  p_author: author,
54467
- p_author_type: author_type
54637
+ p_author_type: author_type,
54638
+ p_content_format: CONTENT_FORMAT_BLIND_STITCH
54468
54639
  });
54469
54640
  if (ingestErr || !ingestResult?.length) {
54470
54641
  throw new Error(`Ingest RPC failed: ${ingestErr?.message ?? "no data returned"}`);
@@ -54487,6 +54658,7 @@ ${c2.content}`);
54487
54658
  }
54488
54659
  var ingestTool;
54489
54660
  var init_ingest = __esm(() => {
54661
+ init__chunker();
54490
54662
  init__projects();
54491
54663
  init_types3();
54492
54664
  ingestTool = {
@@ -63936,7 +64108,7 @@ var require_data = __commonJS((exports, module) => {
63936
64108
  };
63937
64109
  });
63938
64110
 
63939
- // ../../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js
64111
+ // ../../node_modules/.bun/fast-uri@3.1.3/node_modules/fast-uri/lib/utils.js
63940
64112
  var require_utils2 = __commonJS((exports, module) => {
63941
64113
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
63942
64114
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
@@ -64247,7 +64419,7 @@ var require_utils2 = __commonJS((exports, module) => {
64247
64419
  };
64248
64420
  });
64249
64421
 
64250
- // ../../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js
64422
+ // ../../node_modules/.bun/fast-uri@3.1.3/node_modules/fast-uri/lib/schemes.js
64251
64423
  var require_schemes = __commonJS((exports, module) => {
64252
64424
  var { isUUID } = require_utils2();
64253
64425
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
@@ -64421,7 +64593,7 @@ var require_schemes = __commonJS((exports, module) => {
64421
64593
  };
64422
64594
  });
64423
64595
 
64424
- // ../../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/index.js
64596
+ // ../../node_modules/.bun/fast-uri@3.1.3/node_modules/fast-uri/index.js
64425
64597
  var require_fast_uri = __commonJS((exports, module) => {
64426
64598
  var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
64427
64599
  var { SCHEMES, getSchemeHandler } = require_schemes();
@@ -64633,7 +64805,7 @@ var require_fast_uri = __commonJS((exports, module) => {
64633
64805
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
64634
64806
  if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
64635
64807
  try {
64636
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
64808
+ parsed.host = new URL("http://" + parsed.host).hostname;
64637
64809
  } catch (e) {
64638
64810
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
64639
64811
  }
@@ -68607,190 +68779,7 @@ import { homedir as homedir4, platform } from "node:os";
68607
68779
  import { dirname, join as join4 } from "node:path";
68608
68780
  import { spawnSync } from "node:child_process";
68609
68781
 
68610
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
68611
- /*!
68612
- * Copyright (c) Squirrel Chat et al., All rights reserved.
68613
- * SPDX-License-Identifier: BSD-3-Clause
68614
- *
68615
- * Redistribution and use in source and binary forms, with or without
68616
- * modification, are permitted provided that the following conditions are met:
68617
- *
68618
- * 1. Redistributions of source code must retain the above copyright notice, this
68619
- * list of conditions and the following disclaimer.
68620
- * 2. Redistributions in binary form must reproduce the above copyright notice,
68621
- * this list of conditions and the following disclaimer in the
68622
- * documentation and/or other materials provided with the distribution.
68623
- * 3. Neither the name of the copyright holder nor the names of its contributors
68624
- * may be used to endorse or promote products derived from this software without
68625
- * specific prior written permission.
68626
- *
68627
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
68628
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
68629
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
68630
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
68631
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68632
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
68633
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
68634
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
68635
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
68636
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68637
- */
68638
- function getLineColFromPtr(string, ptr) {
68639
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
68640
- return [lines.length, lines.pop().length + 1];
68641
- }
68642
- function makeCodeBlock(string, line, column) {
68643
- let lines = string.split(/\r\n|\n|\r/g);
68644
- let codeblock = "";
68645
- let numberLen = (Math.log10(line + 1) | 0) + 1;
68646
- for (let i = line - 1;i <= line + 1; i++) {
68647
- let l2 = lines[i - 1];
68648
- if (!l2)
68649
- continue;
68650
- codeblock += i.toString().padEnd(numberLen, " ");
68651
- codeblock += ": ";
68652
- codeblock += l2;
68653
- codeblock += `
68654
- `;
68655
- if (i === line) {
68656
- codeblock += " ".repeat(numberLen + column + 2);
68657
- codeblock += `^
68658
- `;
68659
- }
68660
- }
68661
- return codeblock;
68662
- }
68663
-
68664
- class TomlError extends Error {
68665
- line;
68666
- column;
68667
- codeblock;
68668
- constructor(message, options) {
68669
- const [line, column] = getLineColFromPtr(options.toml, options.ptr);
68670
- const codeblock = makeCodeBlock(options.toml, line, column);
68671
- super(`Invalid TOML document: ${message}
68672
-
68673
- ${codeblock}`, options);
68674
- this.line = line;
68675
- this.column = column;
68676
- this.codeblock = codeblock;
68677
- }
68678
- }
68679
-
68680
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/util.js
68681
- /*!
68682
- * Copyright (c) Squirrel Chat et al., All rights reserved.
68683
- * SPDX-License-Identifier: BSD-3-Clause
68684
- *
68685
- * Redistribution and use in source and binary forms, with or without
68686
- * modification, are permitted provided that the following conditions are met:
68687
- *
68688
- * 1. Redistributions of source code must retain the above copyright notice, this
68689
- * list of conditions and the following disclaimer.
68690
- * 2. Redistributions in binary form must reproduce the above copyright notice,
68691
- * this list of conditions and the following disclaimer in the
68692
- * documentation and/or other materials provided with the distribution.
68693
- * 3. Neither the name of the copyright holder nor the names of its contributors
68694
- * may be used to endorse or promote products derived from this software without
68695
- * specific prior written permission.
68696
- *
68697
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
68698
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
68699
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
68700
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
68701
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68702
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
68703
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
68704
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
68705
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
68706
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68707
- */
68708
- function isEscaped(str, ptr) {
68709
- let i = 0;
68710
- while (str[ptr - ++i] === "\\")
68711
- ;
68712
- return --i && i % 2;
68713
- }
68714
- function indexOfNewline(str, start = 0, end = str.length) {
68715
- let idx = str.indexOf(`
68716
- `, start);
68717
- if (str[idx - 1] === "\r")
68718
- idx--;
68719
- return idx <= end ? idx : -1;
68720
- }
68721
- function skipComment(str, ptr) {
68722
- for (let i = ptr;i < str.length; i++) {
68723
- let c2 = str[i];
68724
- if (c2 === `
68725
- `)
68726
- return i;
68727
- if (c2 === "\r" && str[i + 1] === `
68728
- `)
68729
- return i + 1;
68730
- if (c2 < " " && c2 !== "\t" || c2 === "") {
68731
- throw new TomlError("control characters are not allowed in comments", {
68732
- toml: str,
68733
- ptr
68734
- });
68735
- }
68736
- }
68737
- return str.length;
68738
- }
68739
- function skipVoid(str, ptr, banNewLines, banComments) {
68740
- let c2;
68741
- while (true) {
68742
- while ((c2 = str[ptr]) === " " || c2 === "\t" || !banNewLines && (c2 === `
68743
- ` || c2 === "\r" && str[ptr + 1] === `
68744
- `))
68745
- ptr++;
68746
- if (banComments || c2 !== "#")
68747
- break;
68748
- ptr = skipComment(str, ptr);
68749
- }
68750
- return ptr;
68751
- }
68752
- function skipUntil(str, ptr, sep, end, banNewLines = false) {
68753
- if (!end) {
68754
- ptr = indexOfNewline(str, ptr);
68755
- return ptr < 0 ? str.length : ptr;
68756
- }
68757
- for (let i = ptr;i < str.length; i++) {
68758
- let c2 = str[i];
68759
- if (c2 === "#") {
68760
- i = indexOfNewline(str, i);
68761
- } else if (c2 === sep) {
68762
- return i + 1;
68763
- } else if (c2 === end || banNewLines && (c2 === `
68764
- ` || c2 === "\r" && str[i + 1] === `
68765
- `)) {
68766
- return i;
68767
- }
68768
- }
68769
- throw new TomlError("cannot find end of structure", {
68770
- toml: str,
68771
- ptr
68772
- });
68773
- }
68774
- function getStringEnd(str, seek) {
68775
- let first = str[seek];
68776
- let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
68777
- seek += target.length - 1;
68778
- do
68779
- seek = str.indexOf(target, ++seek);
68780
- while (seek > -1 && first !== "'" && isEscaped(str, seek));
68781
- if (seek > -1) {
68782
- seek += target.length;
68783
- if (target.length > 1) {
68784
- if (str[seek] === first)
68785
- seek++;
68786
- if (str[seek] === first)
68787
- seek++;
68788
- }
68789
- }
68790
- return seek;
68791
- }
68792
-
68793
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/date.js
68782
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/date.js
68794
68783
  /*!
68795
68784
  * Copyright (c) Squirrel Chat et al., All rights reserved.
68796
68785
  * SPDX-License-Identifier: BSD-3-Clause
@@ -68910,7 +68899,77 @@ class TomlDate extends Date {
68910
68899
  }
68911
68900
  }
68912
68901
 
68913
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/primitive.js
68902
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/error.js
68903
+ /*!
68904
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
68905
+ * SPDX-License-Identifier: BSD-3-Clause
68906
+ *
68907
+ * Redistribution and use in source and binary forms, with or without
68908
+ * modification, are permitted provided that the following conditions are met:
68909
+ *
68910
+ * 1. Redistributions of source code must retain the above copyright notice, this
68911
+ * list of conditions and the following disclaimer.
68912
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
68913
+ * this list of conditions and the following disclaimer in the
68914
+ * documentation and/or other materials provided with the distribution.
68915
+ * 3. Neither the name of the copyright holder nor the names of its contributors
68916
+ * may be used to endorse or promote products derived from this software without
68917
+ * specific prior written permission.
68918
+ *
68919
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
68920
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
68921
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
68922
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
68923
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68924
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
68925
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
68926
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
68927
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
68928
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68929
+ */
68930
+ function getLineColFromPtr(string, ptr) {
68931
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
68932
+ return [lines.length, lines.pop().length + 1];
68933
+ }
68934
+ function makeCodeBlock(string, line, column) {
68935
+ let lines = string.split(/\r\n|\n|\r/g);
68936
+ let codeblock = "";
68937
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
68938
+ for (let i = line - 1;i <= line + 1; i++) {
68939
+ let l2 = lines[i - 1];
68940
+ if (!l2)
68941
+ continue;
68942
+ codeblock += i.toString().padEnd(numberLen, " ");
68943
+ codeblock += ": ";
68944
+ codeblock += l2;
68945
+ codeblock += `
68946
+ `;
68947
+ if (i === line) {
68948
+ codeblock += " ".repeat(numberLen + column + 2);
68949
+ codeblock += `^
68950
+ `;
68951
+ }
68952
+ }
68953
+ return codeblock;
68954
+ }
68955
+
68956
+ class TomlError extends Error {
68957
+ line;
68958
+ column;
68959
+ codeblock;
68960
+ constructor(message, options) {
68961
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
68962
+ const codeblock = makeCodeBlock(options.toml, line, column);
68963
+ super(`Invalid TOML document: ${message}
68964
+
68965
+ ${codeblock}`, options);
68966
+ this.line = line;
68967
+ this.column = column;
68968
+ this.codeblock = codeblock;
68969
+ }
68970
+ }
68971
+
68972
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/primitive.js
68914
68973
  /*!
68915
68974
  * Copyright (c) Squirrel Chat et al., All rights reserved.
68916
68975
  * SPDX-License-Identifier: BSD-3-Clause
@@ -68941,95 +69000,103 @@ class TomlDate extends Date {
68941
69000
  var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
68942
69001
  var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
68943
69002
  var LEADING_ZERO = /^[+-]?0[0-9_]/;
68944
- var ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
68945
- var ESC_MAP = {
68946
- b: "\b",
68947
- t: "\t",
68948
- n: `
68949
- `,
68950
- f: "\f",
68951
- r: "\r",
68952
- e: "\x1B",
68953
- '"': '"',
68954
- "\\": "\\"
68955
- };
68956
- function parseString(str, ptr = 0, endPtr = str.length) {
68957
- let isLiteral = str[ptr] === "'";
68958
- let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
69003
+ function parseString(str, ptr) {
69004
+ let c2 = str[ptr++];
69005
+ let first = c2;
69006
+ let isLiteral = c2 === "'";
69007
+ let isMultiline = c2 === str[ptr] && c2 === str[ptr + 1];
68959
69008
  if (isMultiline) {
68960
- endPtr -= 2;
68961
- if (str[ptr += 2] === "\r")
68962
- ptr++;
68963
- if (str[ptr] === `
69009
+ if (str[ptr += 2] === `
68964
69010
  `)
68965
69011
  ptr++;
69012
+ else if (str[ptr] === "\r" && str[ptr + 1] === `
69013
+ `)
69014
+ ptr += 2;
68966
69015
  }
68967
- let tmp = 0;
68968
- let isEscape;
68969
69016
  let parsed = "";
68970
69017
  let sliceStart = ptr;
68971
- while (ptr < endPtr - 1) {
68972
- let c2 = str[ptr++];
68973
- if (c2 === `
68974
- ` || c2 === "\r" && str[ptr] === `
68975
- `) {
68976
- if (!isMultiline) {
68977
- throw new TomlError("newlines are not allowed in strings", {
68978
- toml: str,
68979
- ptr: ptr - 1
68980
- });
68981
- }
69018
+ let state = 0;
69019
+ for (let i = ptr;i < str.length; i++) {
69020
+ c2 = str[i];
69021
+ if (isMultiline && (c2 === `
69022
+ ` || c2 === "\r" && str[i + 1] === `
69023
+ `)) {
69024
+ state = state && 3;
68982
69025
  } else if (c2 < " " && c2 !== "\t" || c2 === "") {
68983
69026
  throw new TomlError("control characters are not allowed in strings", {
68984
69027
  toml: str,
68985
- ptr: ptr - 1
69028
+ ptr: i
68986
69029
  });
68987
- }
68988
- if (isEscape) {
68989
- isEscape = false;
69030
+ } else if ((!state || state === 3) && c2 === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
69031
+ if (isMultiline) {
69032
+ if (str[i + 3] === first)
69033
+ i++;
69034
+ if (str[i + 3] === first)
69035
+ i++;
69036
+ }
69037
+ return [
69038
+ state ? parsed : parsed + str.slice(sliceStart, i),
69039
+ i + (isMultiline ? 3 : 1)
69040
+ ];
69041
+ } else if (!state) {
69042
+ if (!isLiteral && c2 === "\\") {
69043
+ parsed += str.slice(sliceStart, sliceStart = i);
69044
+ state = 1;
69045
+ }
69046
+ } else if (state === 1) {
68990
69047
  if (c2 === "x" || c2 === "u" || c2 === "U") {
68991
- let code = str.slice(ptr, ptr += c2 === "x" ? 2 : c2 === "u" ? 4 : 8);
68992
- if (!ESCAPE_REGEX.test(code)) {
68993
- throw new TomlError("invalid unicode escape", {
68994
- toml: str,
68995
- ptr: tmp
68996
- });
68997
- }
68998
- try {
68999
- parsed += String.fromCodePoint(parseInt(code, 16));
69000
- } catch {
69001
- throw new TomlError("invalid unicode escape", {
69002
- toml: str,
69003
- ptr: tmp
69004
- });
69005
- }
69006
- } else if (isMultiline && (c2 === `
69007
- ` || c2 === " " || c2 === "\t" || c2 === "\r")) {
69008
- ptr = skipVoid(str, ptr - 1, true);
69009
- if (str[ptr] !== `
69010
- ` && str[ptr] !== "\r") {
69011
- throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
69012
- toml: str,
69013
- ptr: tmp
69014
- });
69015
- }
69016
- ptr = skipVoid(str, ptr);
69017
- } else if (c2 in ESC_MAP) {
69018
- parsed += ESC_MAP[c2];
69048
+ let value = 0;
69049
+ let len = c2 === "x" ? 2 : c2 === "u" ? 4 : 8;
69050
+ for (let j = 0;j < len; j++, i++) {
69051
+ let hex = str.charCodeAt(i + 1);
69052
+ let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
69053
+ if (digit < 0)
69054
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
69055
+ value = value << 4 | digit;
69056
+ }
69057
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
69058
+ throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
69059
+ }
69060
+ parsed += String.fromCodePoint(value);
69061
+ sliceStart = i + 1;
69062
+ state = 0;
69063
+ } else if (c2 === " " || c2 === "\t") {
69064
+ state = 2;
69019
69065
  } else {
69020
- throw new TomlError("unrecognized escape sequence", {
69066
+ if (c2 === "b")
69067
+ parsed += "\b";
69068
+ else if (c2 === "t")
69069
+ parsed += "\t";
69070
+ else if (c2 === "n")
69071
+ parsed += `
69072
+ `;
69073
+ else if (c2 === "f")
69074
+ parsed += "\f";
69075
+ else if (c2 === "r")
69076
+ parsed += "\r";
69077
+ else if (c2 === "e")
69078
+ parsed += "\x1B";
69079
+ else if (c2 === '"')
69080
+ parsed += '"';
69081
+ else if (c2 === "\\")
69082
+ parsed += "\\";
69083
+ else
69084
+ throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
69085
+ sliceStart = i + 1;
69086
+ state = 0;
69087
+ }
69088
+ } else if (c2 !== " " && c2 !== "\t") {
69089
+ if (state === 2) {
69090
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
69021
69091
  toml: str,
69022
- ptr: tmp
69092
+ ptr: sliceStart
69023
69093
  });
69024
69094
  }
69025
- sliceStart = ptr;
69026
- } else if (!isLiteral && c2 === "\\") {
69027
- tmp = ptr - 1;
69028
- isEscape = true;
69029
- parsed += str.slice(sliceStart, tmp);
69095
+ state = !isLiteral && c2 === "\\" ? 1 : 0;
69096
+ sliceStart = i;
69030
69097
  }
69031
69098
  }
69032
- return parsed + str.slice(sliceStart, endPtr - 1);
69099
+ throw new TomlError("unfinished string", { toml: str, ptr });
69033
69100
  }
69034
69101
  function parseValue(value, toml, ptr, integersAsBigInt) {
69035
69102
  if (value === "true")
@@ -69082,7 +69149,96 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
69082
69149
  return date;
69083
69150
  }
69084
69151
 
69085
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/extract.js
69152
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/util.js
69153
+ /*!
69154
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
69155
+ * SPDX-License-Identifier: BSD-3-Clause
69156
+ *
69157
+ * Redistribution and use in source and binary forms, with or without
69158
+ * modification, are permitted provided that the following conditions are met:
69159
+ *
69160
+ * 1. Redistributions of source code must retain the above copyright notice, this
69161
+ * list of conditions and the following disclaimer.
69162
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
69163
+ * this list of conditions and the following disclaimer in the
69164
+ * documentation and/or other materials provided with the distribution.
69165
+ * 3. Neither the name of the copyright holder nor the names of its contributors
69166
+ * may be used to endorse or promote products derived from this software without
69167
+ * specific prior written permission.
69168
+ *
69169
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
69170
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
69171
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
69172
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
69173
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69174
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
69175
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
69176
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
69177
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
69178
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69179
+ */
69180
+ function indexOfNewline(str, start = 0, end = str.length) {
69181
+ let idx = str.indexOf(`
69182
+ `, start);
69183
+ if (str[idx - 1] === "\r")
69184
+ idx--;
69185
+ return idx <= end ? idx : -1;
69186
+ }
69187
+ function skipComment(str, ptr) {
69188
+ for (let i = ptr;i < str.length; i++) {
69189
+ let c2 = str[i];
69190
+ if (c2 === `
69191
+ `)
69192
+ return i;
69193
+ if (c2 === "\r" && str[i + 1] === `
69194
+ `)
69195
+ return i + 1;
69196
+ if (c2 < " " && c2 !== "\t" || c2 === "") {
69197
+ throw new TomlError("control characters are not allowed in comments", {
69198
+ toml: str,
69199
+ ptr
69200
+ });
69201
+ }
69202
+ }
69203
+ return str.length;
69204
+ }
69205
+ function skipVoid(str, ptr, banNewLines, banComments) {
69206
+ let c2;
69207
+ while (true) {
69208
+ while ((c2 = str[ptr]) === " " || c2 === "\t" || !banNewLines && (c2 === `
69209
+ ` || c2 === "\r" && str[ptr + 1] === `
69210
+ `))
69211
+ ptr++;
69212
+ if (banComments || c2 !== "#")
69213
+ break;
69214
+ ptr = skipComment(str, ptr);
69215
+ }
69216
+ return ptr;
69217
+ }
69218
+ function skipUntil(str, ptr, sep, end, banNewLines = false) {
69219
+ if (!end) {
69220
+ ptr = indexOfNewline(str, ptr);
69221
+ return ptr < 0 ? str.length : ptr;
69222
+ }
69223
+ for (let i = ptr;i < str.length; i++) {
69224
+ let c2 = str[i];
69225
+ if (c2 === "#") {
69226
+ i = indexOfNewline(str, i);
69227
+ } else if (c2 === sep) {
69228
+ return i + 1;
69229
+ } else if (c2 === end || banNewLines && (c2 === `
69230
+ ` || c2 === "\r" && str[i + 1] === `
69231
+ `)) {
69232
+ return i;
69233
+ }
69234
+ }
69235
+ throw new TomlError("cannot find end of structure", {
69236
+ toml: str,
69237
+ ptr
69238
+ });
69239
+ }
69240
+
69241
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/extract.js
69086
69242
  /*!
69087
69243
  * Copyright (c) Squirrel Chat et al., All rights reserved.
69088
69244
  * SPDX-License-Identifier: BSD-3-Clause
@@ -69142,25 +69298,24 @@ function extractValue(str, ptr, end, depth, integersAsBigInt) {
69142
69298
  }
69143
69299
  return [value, endPtr2];
69144
69300
  }
69145
- let endPtr;
69146
69301
  if (c2 === '"' || c2 === "'") {
69147
- endPtr = getStringEnd(str, ptr);
69148
- let parsed = parseString(str, ptr, endPtr);
69302
+ let [parsed, endPtr2] = parseString(str, ptr);
69149
69303
  if (end) {
69150
- endPtr = skipVoid(str, endPtr);
69151
- if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== `
69152
- ` && str[endPtr] !== "\r") {
69304
+ endPtr2 = skipVoid(str, endPtr2);
69305
+ if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== `
69306
+ ` && str[endPtr2] !== "\r") {
69153
69307
  throw new TomlError("unexpected character encountered", {
69154
69308
  toml: str,
69155
- ptr: endPtr
69309
+ ptr: endPtr2
69156
69310
  });
69157
69311
  }
69158
- endPtr += +(str[endPtr] === ",");
69312
+ if (str[endPtr2] === ",")
69313
+ endPtr2++;
69159
69314
  }
69160
- return [parsed, endPtr];
69315
+ return [parsed, endPtr2];
69161
69316
  }
69162
- endPtr = skipUntil(str, ptr, ",", end);
69163
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
69317
+ let endPtr = skipUntil(str, ptr, ",", end);
69318
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
69164
69319
  if (!slice[0]) {
69165
69320
  throw new TomlError("incomplete key-value declaration: no value specified", {
69166
69321
  toml: str,
@@ -69169,7 +69324,8 @@ function extractValue(str, ptr, end, depth, integersAsBigInt) {
69169
69324
  }
69170
69325
  if (end && slice[1] > -1) {
69171
69326
  endPtr = skipVoid(str, ptr + slice[1]);
69172
- endPtr += +(str[endPtr] === ",");
69327
+ if (str[endPtr] === ",")
69328
+ endPtr++;
69173
69329
  }
69174
69330
  return [
69175
69331
  parseValue(slice[0], str, ptr, integersAsBigInt),
@@ -69177,7 +69333,7 @@ function extractValue(str, ptr, end, depth, integersAsBigInt) {
69177
69333
  ];
69178
69334
  }
69179
69335
 
69180
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/struct.js
69336
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/struct.js
69181
69337
  /*!
69182
69338
  * Copyright (c) Squirrel Chat et al., All rights reserved.
69183
69339
  * SPDX-License-Identifier: BSD-3-Clause
@@ -69226,13 +69382,7 @@ function parseKey(str, ptr, end = "=") {
69226
69382
  ptr
69227
69383
  });
69228
69384
  }
69229
- let eos = getStringEnd(str, ptr);
69230
- if (eos < 0) {
69231
- throw new TomlError("unfinished string encountered", {
69232
- toml: str,
69233
- ptr
69234
- });
69235
- }
69385
+ let [part, eos] = parseString(str, ptr);
69236
69386
  dot = str.indexOf(".", eos);
69237
69387
  let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
69238
69388
  let newLine = indexOfNewline(strEnd);
@@ -69257,7 +69407,7 @@ function parseKey(str, ptr, end = "=") {
69257
69407
  });
69258
69408
  }
69259
69409
  }
69260
- parsed.push(parseString(str, ptr, eos));
69410
+ parsed.push(part);
69261
69411
  } else {
69262
69412
  dot = str.indexOf(".", ptr);
69263
69413
  let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
@@ -69354,7 +69504,7 @@ function parseArray(str, ptr, depth, integersAsBigInt) {
69354
69504
  return [res, ptr];
69355
69505
  }
69356
69506
 
69357
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/parse.js
69507
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/parse.js
69358
69508
  /*!
69359
69509
  * Copyright (c) Squirrel Chat et al., All rights reserved.
69360
69510
  * SPDX-License-Identifier: BSD-3-Clause
@@ -69495,7 +69645,7 @@ function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
69495
69645
  return res;
69496
69646
  }
69497
69647
 
69498
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/stringify.js
69648
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/stringify.js
69499
69649
  /*!
69500
69650
  * Copyright (c) Squirrel Chat et al., All rights reserved.
69501
69651
  * SPDX-License-Identifier: BSD-3-Clause
@@ -69555,7 +69705,7 @@ function stringifyValue(val, type, depth, numberAsFloat) {
69555
69705
  return "inf";
69556
69706
  if (val === -Infinity)
69557
69707
  return "-inf";
69558
- if (numberAsFloat && Number.isInteger(val))
69708
+ if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
69559
69709
  return val.toFixed(1);
69560
69710
  return val.toString();
69561
69711
  }
@@ -69669,7 +69819,7 @@ function stringify(obj2, { maxDepth = 1000, numbersAsFloat = false } = {}) {
69669
69819
  return str;
69670
69820
  }
69671
69821
 
69672
- // ../../node_modules/.bun/smol-toml@1.6.1/node_modules/smol-toml/dist/index.js
69822
+ // ../../node_modules/.bun/smol-toml@1.7.0/node_modules/smol-toml/dist/index.js
69673
69823
  /*!
69674
69824
  * Copyright (c) Squirrel Chat et al., All rights reserved.
69675
69825
  * SPDX-License-Identifier: BSD-3-Clause
@@ -70247,6 +70397,17 @@ function parseProjectRef(supabaseUrl) {
70247
70397
  return null;
70248
70398
  }
70249
70399
  }
70400
+ var PRIMITIVE_EFS = [
70401
+ "cerefox-search",
70402
+ "cerefox-ingest",
70403
+ "cerefox-metadata",
70404
+ "cerefox-get-document",
70405
+ "cerefox-list-versions",
70406
+ "cerefox-get-audit-log",
70407
+ "cerefox-metadata-search",
70408
+ "cerefox-list-projects"
70409
+ ];
70410
+ var NO_VERIFY_JWT_EFS = new Set(["cerefox-mcp", ...PRIMITIVE_EFS]);
70250
70411
  function listEdgeFunctions(functionsDir) {
70251
70412
  if (!existsSync7(functionsDir))
70252
70413
  return [];
@@ -70411,6 +70572,10 @@ Proceed with deployment to Supabase?`, true);
70411
70572
  const args = ["--yes", "supabase", "functions", "deploy", ef, "--use-api"];
70412
70573
  if (projectRef)
70413
70574
  args.push("--project-ref", projectRef);
70575
+ if (NO_VERIFY_JWT_EFS.has(ef)) {
70576
+ args.push("--no-verify-jwt");
70577
+ info(` (${ef}: --no-verify-jwt — in-function auth)`);
70578
+ }
70414
70579
  const r = spawnSync2("npx", args, {
70415
70580
  encoding: "utf8",
70416
70581
  stdio: "inherit",
@@ -70429,6 +70594,24 @@ Proceed with deployment to Supabase?`, true);
70429
70594
  process.exit(1);
70430
70595
  }
70431
70596
  println(c.green(` ✓ Deployed ${efOk} Edge Function(s).`));
70597
+ if (efNames.includes("cerefox-mcp")) {
70598
+ const ref = projectRef ?? "<ref>";
70599
+ println(c.yellow(`
70600
+ ⚠ cerefox-mcp authenticates in-function (OAuth for cloud/mobile Claude).
70601
+ ` + ` Pin the owner — this is the authorization boundary (else any user who
70602
+ ` + ` self-registers on your project could get an accepted token):
70603
+ ` + ` supabase secrets set CEREFOX_OAUTH_OWNER_ID=<owner user uuid> --project-ref ${ref}
70604
+ ` + " Setup: docs/guides/setup-supabase.md Step 7 (incl. the client_secret_post gotcha)."));
70605
+ }
70606
+ if (efNames.some((ef) => PRIMITIVE_EFS.includes(ef))) {
70607
+ const ref = projectRef ?? "<ref>";
70608
+ println(c.yellow(`
70609
+ ⚠ The primitive Edge Functions now require the Cerefox access token.
70610
+ ` + ` If CEREFOX_ACCESS_TOKENS is unset they reject ALL callers (fail closed) —
70611
+ ` + " GPT Actions, remote HTTP, and `cerefox doctor`. Generate it now:\n" + ` cerefox token generate
70612
+ ` + ` (or manually: supabase secrets set CEREFOX_ACCESS_TOKENS=<token> --project-ref ${ref})
70613
+ ` + " Migration + client cutover: docs/specs/ef-auth-migration-design.md §6."));
70614
+ }
70432
70615
  }
70433
70616
  println(c.green(`
70434
70617
  ✓ Server deploy complete.`));
@@ -70705,7 +70888,7 @@ function registerVersionArchive(parent) {
70705
70888
  parent.command("unarchive").description("Unarchive a document version (allow version cleanup again).").argument("<version-id>", "UUID of the version (from `cerefox version list`).").option("-a, --author <name>", "Caller identity (audit log).").option("--author-type <type>", "'user' or 'agent' (default: user).", "user").action((versionId, options) => setArchived(versionId, false, options));
70706
70889
  }
70707
70890
 
70708
- // ../../node_modules/.bun/ora@9.4.0/node_modules/ora/index.js
70891
+ // ../../node_modules/.bun/ora@9.4.1/node_modules/ora/index.js
70709
70892
  import process8 from "node:process";
70710
70893
  import { stripVTControlCharacters } from "node:util";
70711
70894
 
@@ -73431,10 +73614,11 @@ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
73431
73614
  return 1;
73432
73615
  }
73433
73616
 
73434
- // ../../node_modules/.bun/string-width@8.2.1/node_modules/string-width/index.js
73617
+ // ../../node_modules/.bun/string-width@8.2.2/node_modules/string-width/index.js
73435
73618
  var segmenter = new Intl.Segmenter;
73436
- var zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})+$/v;
73437
- var leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
73619
+ var zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v;
73620
+ var leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v;
73621
+ var spacingMarkRegex = /\p{Spacing_Mark}/v;
73438
73622
  var rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
73439
73623
  var unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
73440
73624
  var extendedPictographicRegex = /\p{Extended_Pictographic}/gu;
@@ -73501,7 +73685,7 @@ function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
73501
73685
  }
73502
73686
  return width;
73503
73687
  }
73504
- function trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions) {
73688
+ function trailingWidth(visibleSegment, eastAsianWidthOptions) {
73505
73689
  let extra = 0;
73506
73690
  let first = true;
73507
73691
  for (const character of visibleSegment) {
@@ -73509,7 +73693,7 @@ function trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions) {
73509
73693
  first = false;
73510
73694
  continue;
73511
73695
  }
73512
- if (character >= "＀" && character <= "￯") {
73696
+ if (spacingMarkRegex.test(character) || character >= "＀" && character <= "￯") {
73513
73697
  extra += eastAsianWidth(character.codePointAt(0), eastAsianWidthOptions);
73514
73698
  }
73515
73699
  }
@@ -73551,7 +73735,7 @@ function stringWidth(input, options = {}) {
73551
73735
  }
73552
73736
  const codePoint = visibleSegment.codePointAt(0);
73553
73737
  width += eastAsianWidth(codePoint, eastAsianWidthOptions);
73554
- width += trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions);
73738
+ width += trailingWidth(visibleSegment, eastAsianWidthOptions);
73555
73739
  }
73556
73740
  return width;
73557
73741
  }
@@ -73628,7 +73812,7 @@ class StdinDiscarder {
73628
73812
  var stdinDiscarder = new StdinDiscarder;
73629
73813
  var stdin_discarder_default = Object.freeze(stdinDiscarder);
73630
73814
 
73631
- // ../../node_modules/.bun/ora@9.4.0/node_modules/ora/index.js
73815
+ // ../../node_modules/.bun/ora@9.4.1/node_modules/ora/index.js
73632
73816
  var RENDER_DEFERRAL_TIMEOUT = 200;
73633
73817
  var SYNCHRONIZED_OUTPUT_ENABLE = "\x1B[?2026h";
73634
73818
  var SYNCHRONIZED_OUTPUT_DISABLE = "\x1B[?2026l";
@@ -74003,7 +74187,7 @@ class Ora {
74003
74187
  return this;
74004
74188
  }
74005
74189
  start(text) {
74006
- if (text) {
74190
+ if (text !== undefined) {
74007
74191
  this.text = text;
74008
74192
  }
74009
74193
  if (this.isSilent) {
@@ -74097,7 +74281,7 @@ import { homedir as homedir5 } from "node:os";
74097
74281
  import { join as join8 } from "node:path";
74098
74282
 
74099
74283
  // ../../_shared/ef-meta/index.ts
74100
- var EF_VERSION = "0.11.0";
74284
+ var EF_VERSION = "1.0.0-beta.1";
74101
74285
 
74102
74286
  // src/cli/util/checks.ts
74103
74287
  init_config();
@@ -74148,7 +74332,7 @@ async function checkServerCompatibility(opts) {
74148
74332
  };
74149
74333
  if (!opts.bearer) {
74150
74334
  result.efProbeSkipped = true;
74151
- result.efSkipReason = "No anon JWT (CEREFOX_SUPABASE_ANON_KEY) configured; Edge Function version check skipped.";
74335
+ result.efSkipReason = "No CEREFOX_ACCESS_TOKEN configured; Edge Function version check skipped.";
74152
74336
  return result;
74153
74337
  }
74154
74338
  let agg = null;
@@ -74446,6 +74630,54 @@ async function checkSchemaVersion() {
74446
74630
  };
74447
74631
  }
74448
74632
  }
74633
+ var CONTENT_FORMAT_CHECK_NAME = "content format";
74634
+ async function checkContentFormat() {
74635
+ const settings = loadSettings();
74636
+ if (!settings.supabaseUrl || !settings.supabaseKey) {
74637
+ return { name: CONTENT_FORMAT_CHECK_NAME, status: "skipped", detail: "Supabase config missing; skipped." };
74638
+ }
74639
+ try {
74640
+ const url = `${settings.supabaseUrl.replace(/\/$/, "")}/rest/v1/rpc/cerefox_content_format_stats`;
74641
+ const resp = await fetch(url, {
74642
+ method: "POST",
74643
+ headers: {
74644
+ "Content-Type": "application/json",
74645
+ apikey: settings.supabaseKey,
74646
+ Authorization: `Bearer ${settings.supabaseKey}`
74647
+ },
74648
+ body: "{}"
74649
+ });
74650
+ if (!resp.ok) {
74651
+ return {
74652
+ name: CONTENT_FORMAT_CHECK_NAME,
74653
+ status: "skipped",
74654
+ detail: `format stats unavailable (${resp.status}); deploy schema 0.8.0 to enable.`
74655
+ };
74656
+ }
74657
+ const rows = await resp.json();
74658
+ const legacy = rows[0]?.legacy_docs ?? 0;
74659
+ const total = rows[0]?.total_docs ?? 0;
74660
+ if (legacy === 0) {
74661
+ return {
74662
+ name: CONTENT_FORMAT_CHECK_NAME,
74663
+ status: "ok",
74664
+ detail: total === 0 ? "no documents yet" : `all ${total} document(s) use the current format`
74665
+ };
74666
+ }
74667
+ return {
74668
+ name: CONTENT_FORMAT_CHECK_NAME,
74669
+ status: "skipped",
74670
+ detail: `${legacy} of ${total} document(s) use the legacy reconstruction format (format 1).`,
74671
+ hint: "They auto-convert on next edit; run `cerefox server reindex` to convert all now. What this means: `cerefox guides show content-format`."
74672
+ };
74673
+ } catch (err) {
74674
+ return {
74675
+ name: CONTENT_FORMAT_CHECK_NAME,
74676
+ status: "skipped",
74677
+ detail: `content-format check skipped: ${err instanceof Error ? err.message : String(err)}`
74678
+ };
74679
+ }
74680
+ }
74449
74681
  function hasCerefoxInJsonFile(path) {
74450
74682
  if (!existsSync9(path))
74451
74683
  return false;
@@ -74555,19 +74787,19 @@ async function checkEdgeFunctionsCompat() {
74555
74787
  detail: "Supabase URL not set; EF version check skipped."
74556
74788
  };
74557
74789
  }
74558
- if (!settings.supabaseAnonKey) {
74790
+ if (!settings.accessToken) {
74559
74791
  return {
74560
74792
  name: "edge functions",
74561
74793
  status: "skipped",
74562
- detail: "No CEREFOX_SUPABASE_ANON_KEY set; EF version check skipped.",
74563
- hint: "Set the legacy anon JWT (eyJ…) to enable client↔server version checks."
74794
+ detail: "No CEREFOX_ACCESS_TOKEN set; EF version check skipped.",
74795
+ hint: "Run `cerefox token generate` to enable client↔server version checks."
74564
74796
  };
74565
74797
  }
74566
74798
  let compat;
74567
74799
  try {
74568
74800
  compat = await checkServerCompatibility({
74569
74801
  aggregatorUrl: aggregatorUrlFor(settings.supabaseUrl),
74570
- bearer: settings.supabaseAnonKey,
74802
+ bearer: settings.accessToken,
74571
74803
  bundledEf: EF_VERSION
74572
74804
  });
74573
74805
  } catch (err) {
@@ -74634,6 +74866,7 @@ async function runAllChecks(opts = {}) {
74634
74866
  { name: "supabase", phase: "Probing Supabase Data API", run: () => checkSupabase() },
74635
74867
  { name: "openai", phase: "Probing OpenAI embeddings", run: () => checkOpenAI() },
74636
74868
  { name: "schema + RPCs", phase: "Reading schema + RPC version", run: () => checkSchemaVersion() },
74869
+ { name: "content format", phase: "Checking chunk reconstruction format", run: () => checkContentFormat() },
74637
74870
  { name: "edge functions", phase: "Probing Edge Function versions", run: () => checkEdgeFunctionsCompat() },
74638
74871
  { name: "postgres", phase: "Probing Postgres DDL endpoint", run: () => checkPostgres() },
74639
74872
  { name: "mcp clients", phase: "Scanning MCP client configs", run: () => checkMcpConfigs() }
@@ -74816,205 +75049,6 @@ import { basename as basename2, extname as extname3 } from "node:path";
74816
75049
  // src/ingestion/pipeline.ts
74817
75050
  import { readFileSync as readFileSync8 } from "node:fs";
74818
75051
  import { basename, extname as extname2, resolve as resolve3 } from "node:path";
74819
-
74820
- // ../../_shared/ingest/chunker.ts
74821
- function cpLen(s) {
74822
- let n = 0;
74823
- for (const _ of s)
74824
- n++;
74825
- return n;
74826
- }
74827
- function cpSlice(s, start, end) {
74828
- const arr = [...s];
74829
- return arr.slice(start, end).join("");
74830
- }
74831
- function rstripHash(s) {
74832
- let i = s.length;
74833
- while (i > 0 && s[i - 1] === "#")
74834
- i--;
74835
- return s.slice(0, i);
74836
- }
74837
- var HEADING_RE = /^(#{1,3})\s+(.+)$/gm;
74838
- var PARAGRAPH_SEP = /\n{2,}/;
74839
- function parseSections(text) {
74840
- const segments = [];
74841
- HEADING_RE.lastIndex = 0;
74842
- const parts = text.split(HEADING_RE);
74843
- const preamble = parts[0]?.trim() ?? "";
74844
- if (preamble) {
74845
- segments.push([0, "", preamble]);
74846
- }
74847
- for (let i = 1;i + 2 < parts.length + 1; i += 3) {
74848
- if (i + 2 > parts.length)
74849
- break;
74850
- const hashes = parts[i] ?? "";
74851
- const headingText = rstripHash(parts[i + 1] ?? "").trim();
74852
- const body = (parts[i + 2] ?? "").trim();
74853
- segments.push([hashes.length, headingText, body]);
74854
- }
74855
- return segments;
74856
- }
74857
- function appendChunk(chunks, content, path, level, heading, opts = {}) {
74858
- const forceNew = opts.forceNew ?? true;
74859
- const minChunkChars = opts.minChunkChars ?? 0;
74860
- if (!forceNew && cpLen(content) < minChunkChars && chunks.length > 0) {
74861
- const prev = chunks[chunks.length - 1];
74862
- prev.content = `${prev.content}
74863
-
74864
- ${content}`;
74865
- prev.char_count = cpLen(prev.content);
74866
- return;
74867
- }
74868
- const title = level > 0 ? heading : path[path.length - 1] ?? "";
74869
- chunks.push({
74870
- chunk_index: chunks.length,
74871
- heading_path: [...path],
74872
- heading_level: level,
74873
- title,
74874
- content,
74875
- char_count: cpLen(content)
74876
- });
74877
- }
74878
- function splitParagraphs(text, maxChars) {
74879
- const paragraphs = text.split(PARAGRAPH_SEP).filter((p) => p.trim() !== "");
74880
- if (paragraphs.length === 0)
74881
- return [];
74882
- const result = [];
74883
- let currentParts = [];
74884
- let currentLen = 0;
74885
- for (const para of paragraphs) {
74886
- const paraLen = cpLen(para);
74887
- const addition = paraLen + (currentParts.length > 0 ? 2 : 0);
74888
- if (currentLen + addition <= maxChars) {
74889
- currentParts.push(para);
74890
- currentLen += addition;
74891
- } else if (currentParts.length > 0) {
74892
- result.push(currentParts.join(`
74893
-
74894
- `));
74895
- currentParts = [para];
74896
- currentLen = paraLen;
74897
- } else {
74898
- const step = Math.floor(maxChars / 2);
74899
- for (let start = 0;start < paraLen; start += step) {
74900
- result.push(cpSlice(para, start, start + maxChars));
74901
- }
74902
- currentParts = [];
74903
- currentLen = 0;
74904
- }
74905
- }
74906
- if (currentParts.length > 0) {
74907
- result.push(currentParts.join(`
74908
-
74909
- `));
74910
- }
74911
- return result;
74912
- }
74913
- function chunkMarkdown(text, maxChunkChars = 4000, minChunkChars = 100) {
74914
- const stripped = text.trim();
74915
- if (!stripped)
74916
- return [];
74917
- if (cpLen(stripped) <= maxChunkChars) {
74918
- return [
74919
- {
74920
- chunk_index: 0,
74921
- heading_path: [],
74922
- heading_level: 0,
74923
- title: "",
74924
- content: stripped,
74925
- char_count: cpLen(stripped)
74926
- }
74927
- ];
74928
- }
74929
- const sections = parseSections(stripped);
74930
- const chunks = [];
74931
- let headingStack = [];
74932
- let bufParts = [];
74933
- let bufPath = [];
74934
- let bufLevel = 0;
74935
- let bufHeading = "";
74936
- let bufChars = 0;
74937
- const flushBuf = () => {
74938
- if (bufParts.length === 0)
74939
- return;
74940
- const content = bufParts.join(`
74941
-
74942
- `);
74943
- appendChunk(chunks, content, bufPath, bufLevel, bufHeading, {
74944
- forceNew: true
74945
- });
74946
- bufParts = [];
74947
- bufPath = [];
74948
- bufLevel = 0;
74949
- bufHeading = "";
74950
- bufChars = 0;
74951
- };
74952
- for (const [level, heading, body] of sections) {
74953
- let path;
74954
- if (level > 0) {
74955
- headingStack = headingStack.slice(0, level - 1);
74956
- headingStack.push(heading);
74957
- path = [...headingStack];
74958
- } else {
74959
- path = [];
74960
- }
74961
- let content;
74962
- if (level > 0) {
74963
- const headerLine = "#".repeat(level) + " " + heading;
74964
- content = body ? `${headerLine}
74965
-
74966
- ${body}` : headerLine;
74967
- } else {
74968
- content = body;
74969
- }
74970
- if (content.trim() === "")
74971
- continue;
74972
- const contentLen = cpLen(content);
74973
- if (contentLen > maxChunkChars) {
74974
- flushBuf();
74975
- const headerPrefix = level > 0 ? `${"#".repeat(level)} ${heading}
74976
-
74977
- ` : "";
74978
- const pieces = splitParagraphs(body, maxChunkChars);
74979
- for (let i = 0;i < pieces.length; i++) {
74980
- const rawPiece = pieces[i];
74981
- const piece = (i === 0 ? headerPrefix + rawPiece : rawPiece).trim();
74982
- if (!piece)
74983
- continue;
74984
- appendChunk(chunks, piece, path, level, heading, {
74985
- forceNew: i === 0,
74986
- minChunkChars
74987
- });
74988
- }
74989
- if (pieces.length === 0) {
74990
- appendChunk(chunks, content, path, level, heading, { forceNew: true });
74991
- }
74992
- continue;
74993
- }
74994
- const addition = contentLen + (bufParts.length > 0 ? 2 : 0);
74995
- if (bufChars + addition <= maxChunkChars) {
74996
- if (bufParts.length === 0) {
74997
- bufPath = path;
74998
- bufLevel = level;
74999
- bufHeading = heading;
75000
- }
75001
- bufParts.push(content);
75002
- bufChars += addition;
75003
- } else {
75004
- flushBuf();
75005
- bufParts = [content];
75006
- bufPath = path;
75007
- bufLevel = level;
75008
- bufHeading = heading;
75009
- bufChars = contentLen;
75010
- }
75011
- }
75012
- flushBuf();
75013
- for (let i = 0;i < chunks.length; i++) {
75014
- chunks[i].chunk_index = i;
75015
- }
75016
- return chunks;
75017
- }
75018
75052
  // ../../_shared/ingest/pipeline-helpers.ts
75019
75053
  import { createHash } from "node:crypto";
75020
75054
  function normalizeForHash(text) {
@@ -75151,6 +75185,8 @@ class IngestionDbBridge {
75151
75185
  params.p_retention_hours = args.retentionHours;
75152
75186
  if (args.cleanupEnabled !== undefined)
75153
75187
  params.p_cleanup_enabled = args.cleanupEnabled;
75188
+ if (args.contentFormat !== undefined)
75189
+ params.p_content_format = args.contentFormat;
75154
75190
  if (args.documentId !== null) {
75155
75191
  params.p_expected_content_hash = args.expectedContentHash ?? null;
75156
75192
  params.p_last_write_wins = args.lastWriteWins ?? false;
@@ -75393,8 +75429,7 @@ class IngestionPipeline {
75393
75429
  const sourcePath = sourcePathOpt ?? deriveSourcePath(title);
75394
75430
  let chunkRows = [];
75395
75431
  if (chunks.length > 0) {
75396
- const texts = chunks.map((c2) => `# ${title}
75397
- ${c2.content}`);
75432
+ const texts = chunks.map((c2) => embeddingInputFor(title, c2));
75398
75433
  const embeddings = await embedBatch(texts, this.apiKey);
75399
75434
  chunkRows = chunks.map((c2, i) => ({
75400
75435
  chunk_index: c2.chunk_index,
@@ -75417,6 +75452,7 @@ ${c2.content}`);
75417
75452
  metadata: validatedMeta,
75418
75453
  reviewStatus,
75419
75454
  chunks: chunkRows,
75455
+ contentFormat: CONTENT_FORMAT_BLIND_STITCH,
75420
75456
  author,
75421
75457
  authorType
75422
75458
  });
@@ -75481,8 +75517,7 @@ ${c2.content}`);
75481
75517
  }
75482
75518
  await this.db.updateDocumentRow(documentId, updates);
75483
75519
  if (titleChanged) {
75484
- const texts = actualChunks.map((c2) => `# ${title}
75485
- ${c2.content}`);
75520
+ const texts = actualChunks.map((c2) => embeddingInputFor(title, c2));
75486
75521
  try {
75487
75522
  const embeddings = await embedBatch(texts, this.apiKey);
75488
75523
  for (let i = 0;i < actualChunks.length; i++) {
@@ -75530,8 +75565,7 @@ ${c2.content}`);
75530
75565
  const totalChars = chunks.reduce((acc, c2) => acc + c2.char_count, 0);
75531
75566
  let chunkRows = [];
75532
75567
  if (chunks.length > 0) {
75533
- const texts = chunks.map((c2) => `# ${title}
75534
- ${c2.content}`);
75568
+ const texts = chunks.map((c2) => embeddingInputFor(title, c2));
75535
75569
  const embeddings = await embedBatch(texts, this.apiKey);
75536
75570
  chunkRows = chunks.map((c2, i) => ({
75537
75571
  chunk_index: c2.chunk_index,
@@ -75555,6 +75589,7 @@ ${c2.content}`);
75555
75589
  metadata: metaToWrite,
75556
75590
  reviewStatus,
75557
75591
  chunks: chunkRows,
75592
+ contentFormat: CONTENT_FORMAT_BLIND_STITCH,
75558
75593
  author,
75559
75594
  authorType,
75560
75595
  sourceLabel: source,
@@ -75635,7 +75670,7 @@ async function action18(path, options) {
75635
75670
  if (author === "unknown") {
75636
75671
  warn("No --author / CEREFOX_AUTHOR_NAME set — audit log will record this write as 'unknown'.");
75637
75672
  }
75638
- const metadata = parseJsonObjectArg(options.metadata, "--metadata") ?? {};
75673
+ const metadata = parseJsonObjectArg(options.metadata, "--metadata");
75639
75674
  let projectNames;
75640
75675
  if (options.projectNames) {
75641
75676
  projectNames = options.projectNames.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
@@ -75662,7 +75697,7 @@ async function action18(path, options) {
75662
75697
  source: options.source ?? "cli",
75663
75698
  projectName: options.projectName ?? null,
75664
75699
  projectNames: projectNames ?? null,
75665
- metadata,
75700
+ metadata: metadata ?? null,
75666
75701
  updateExisting: Boolean(options.updateIfExists),
75667
75702
  documentId: options.documentId ?? null,
75668
75703
  author,
@@ -75675,7 +75710,7 @@ async function action18(path, options) {
75675
75710
  source: options.source ?? "cli",
75676
75711
  projectName: options.projectName ?? null,
75677
75712
  projectNames: projectNames ?? null,
75678
- metadata,
75713
+ metadata: metadata ?? null,
75679
75714
  updateExisting: Boolean(options.updateIfExists),
75680
75715
  documentId: options.documentId ?? null,
75681
75716
  author,
@@ -75748,7 +75783,7 @@ async function action19(dir, options) {
75748
75783
  if (author === "unknown") {
75749
75784
  warn("No --author / CEREFOX_AUTHOR_NAME set — audit log will record these writes as 'unknown'.");
75750
75785
  }
75751
- const metadata = parseJsonObjectArg(options.metadata, "--metadata") ?? {};
75786
+ const metadata = parseJsonObjectArg(options.metadata, "--metadata");
75752
75787
  const settings = loadSettings();
75753
75788
  if (!settings.supabaseUrl || !settings.supabaseKey) {
75754
75789
  throw userError("Supabase credentials not configured — run `cerefox init` first.");
@@ -75779,7 +75814,7 @@ async function action19(dir, options) {
75779
75814
  title: basename3(file, extname4(file)),
75780
75815
  source: options.source ?? "cli",
75781
75816
  projectName: options.projectName ?? null,
75782
- metadata,
75817
+ metadata: metadata ?? null,
75783
75818
  updateExisting: Boolean(options.updateIfExists),
75784
75819
  author,
75785
75820
  authorType,
@@ -75975,6 +76010,7 @@ function buildEnvFile(answers) {
75975
76010
  if (answers.CEREFOX_AUTHOR_TYPE) {
75976
76011
  lines.push(`CEREFOX_AUTHOR_TYPE=${answers.CEREFOX_AUTHOR_TYPE}`);
75977
76012
  }
76013
+ lines.push("", "# ── Optional: connect cloud/mobile Claude over OAuth (setup-supabase.md Step 7) ──", "# These are only needed for the optional claude.ai / Claude-mobile OAuth feature.", "# The Cerefox access token gates the Edge Functions (GPT Actions, remote MCP,", "# and doctor's version check). It is written here automatically by", "# `cerefox token generate` — you don't set it by hand:", "# CEREFOX_ACCESS_TOKEN=cfx_pat_...", "# The PUBLISHABLE key is public-safe (no KB access) — used by the consent-page", "# Cloudflare Worker deploy (cloudflare/cerefox-consent/deploy.sh reads this):", "# CEREFOX_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...");
75978
76014
  return lines.join(`
75979
76015
  `) + `
75980
76016
  `;
@@ -76447,9 +76483,9 @@ function registerMcp(program2) {
76447
76483
  init_cli_core();
76448
76484
  init_client();
76449
76485
  async function action26(options) {
76450
- const metadataFilter = parseJsonObjectArg(options.metadataFilter, "--metadata-filter");
76451
- if (!metadataFilter || Object.keys(metadataFilter).length === 0) {
76452
- throw userError("--metadata-filter is required and must be a non-empty JSON object.", `Example: --metadata-filter '{"type":"decision-log"}'.`);
76486
+ const metadataFilter = parseJsonObjectArg(options.metadataFilter, "--metadata-filter") ?? {};
76487
+ if (Object.keys(metadataFilter).length === 0 && !options.projectName && !options.updatedSince && !options.createdSince) {
76488
+ throw userError("Provide at least one of: --metadata-filter, --project-name, --updated-since, or --created-since.", `Examples: --metadata-filter '{"type":"decision-log"}' · --project-name "research" (lists that project's docs).`);
76453
76489
  }
76454
76490
  const limit = parsePositiveInt(options.limit, "--limit", 10);
76455
76491
  const maxBytes = parseNonNegativeInt(options.maxBytes, "--max-bytes", 200000);
@@ -76509,7 +76545,7 @@ async function action26(options) {
76509
76545
  }
76510
76546
  }
76511
76547
  function registerMetadataSearch(program2) {
76512
- program2.command("metadata-search").description("Find documents by metadata criteria (no text query).").requiredOption("-f, --metadata-filter <json>", "JSON object; only docs whose metadata contains ALL pairs are returned.").option("-p, --project-name <name>", "Filter to a specific project.").option("--updated-since <iso>", "Only docs updated on/after this ISO timestamp.").option("--created-since <iso>", "Only docs created on/after this ISO timestamp.").option("--include-content", "Include full document text in results.").option("-l, --limit <n>", "Maximum docs to return.", "10").option("--max-bytes <n>", "Response size budget in bytes (with --include-content).", "200000").option("-r, --requestor <name>", "Agent / user name (usage log).").option("--json", "Emit machine-readable JSON.").action(action26);
76548
+ program2.command("metadata-search").description("Find or list documents by metadata, project, or time criteria (no text query).").option("-f, --metadata-filter <json>", "JSON object; only docs whose metadata contains ALL pairs are returned. Optional — omit to list by --project-name / time range alone (at least one criterion is required).").option("-p, --project-name <name>", "Filter to a specific project.").option("--updated-since <iso>", "Only docs updated on/after this ISO timestamp.").option("--created-since <iso>", "Only docs created on/after this ISO timestamp.").option("--include-content", "Include full document text in results.").option("-l, --limit <n>", "Maximum docs to return.", "10").option("--max-bytes <n>", "Response size budget in bytes (with --include-content).", "200000").option("-r, --requestor <name>", "Agent / user name (usage log).").option("--json", "Emit machine-readable JSON.").action(action26);
76513
76549
  }
76514
76550
 
76515
76551
  // src/cli/commands/reindex.ts
@@ -77003,21 +77039,205 @@ function registerStatus(program2) {
77003
77039
  program2.command("status").description("Quick sanity check (fast subset of `cerefox doctor`).").option("--json", "Emit machine-readable JSON.").action(action31);
77004
77040
  }
77005
77041
 
77042
+ // src/cli/commands/token.ts
77043
+ init_cli_core();
77044
+ init_config();
77045
+ import { randomBytes } from "node:crypto";
77046
+ import { spawnSync as spawnSync7 } from "node:child_process";
77047
+
77048
+ // src/cli/util/env-file.ts
77049
+ import { copyFileSync as copyFileSync3, existsSync as existsSync12, readFileSync as readFileSync13, writeFileSync as writeFileSync5 } from "node:fs";
77050
+ import { dirname as dirname5 } from "node:path";
77051
+ import { spawnSync as spawnSync6 } from "node:child_process";
77052
+ function escapeRegExp(s) {
77053
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
77054
+ }
77055
+ function upsertEnvVar(path, key, value, opts = {}) {
77056
+ const line = `${key}=${value}`;
77057
+ const header = opts.comment ? `# ${opts.comment}
77058
+ ` : "";
77059
+ if (!existsSync12(path)) {
77060
+ writeFileSync5(path, `${header}${line}
77061
+ `, { mode: 384 });
77062
+ return { path, action: "created" };
77063
+ }
77064
+ const original = readFileSync13(path, "utf8");
77065
+ let backupPath;
77066
+ if (!opts.noBackup) {
77067
+ backupPath = `${path}.pre-cerefox.bak`;
77068
+ copyFileSync3(path, backupPath);
77069
+ }
77070
+ const re = new RegExp(`^(\\s*)${escapeRegExp(key)}=.*$`, "m");
77071
+ let next;
77072
+ let action32;
77073
+ if (re.test(original)) {
77074
+ next = original.replace(re, `$1${line}`);
77075
+ action32 = "updated";
77076
+ } else {
77077
+ const base = original.endsWith(`
77078
+ `) ? original : `${original}
77079
+ `;
77080
+ next = `${base}
77081
+ ${header}${line}
77082
+ `;
77083
+ action32 = "added";
77084
+ }
77085
+ writeFileSync5(path, next);
77086
+ return { path, action: action32, backupPath };
77087
+ }
77088
+ function readEnvVar(path, key) {
77089
+ if (!existsSync12(path))
77090
+ return null;
77091
+ const m = readFileSync13(path, "utf8").match(new RegExp(`^\\s*${escapeRegExp(key)}=(.*)$`, "m"));
77092
+ return m ? m[1].trim() : null;
77093
+ }
77094
+ function envGitignoreWarning(path) {
77095
+ try {
77096
+ const dir = dirname5(path);
77097
+ const inTree = spawnSync6("git", ["-C", dir, "rev-parse", "--is-inside-work-tree"], {
77098
+ encoding: "utf8"
77099
+ });
77100
+ if (inTree.status !== 0 || inTree.stdout.trim() !== "true")
77101
+ return null;
77102
+ const ignored = spawnSync6("git", ["-C", dir, "check-ignore", "-q", path]);
77103
+ if (ignored.status === 0)
77104
+ return null;
77105
+ return `${path} is inside a git repo and is NOT gitignored — add it to .gitignore ` + `before committing (it now holds a secret access token).`;
77106
+ } catch {
77107
+ return null;
77108
+ }
77109
+ }
77110
+
77111
+ // src/cli/commands/token.ts
77112
+ var SECRET_NAME = "CEREFOX_ACCESS_TOKENS";
77113
+ var LOCAL_NAME = "CEREFOX_ACCESS_TOKEN";
77114
+ var PREFIX = "cfx_pat_";
77115
+ function mintToken() {
77116
+ return PREFIX + randomBytes(32).toString("base64url");
77117
+ }
77118
+ function mask(token) {
77119
+ return token.length <= 16 ? "…" : `${token.slice(0, PREFIX.length + 4)}…${token.slice(-4)}`;
77120
+ }
77121
+ function parseProjectRef2(supabaseUrl) {
77122
+ if (!supabaseUrl)
77123
+ return null;
77124
+ try {
77125
+ const label = new URL(supabaseUrl).hostname.split(".")[0];
77126
+ return /^[a-z0-9]{20}$/.test(label) ? label : null;
77127
+ } catch {
77128
+ return null;
77129
+ }
77130
+ }
77131
+ function setSecret(setValue, projectRef, dryRun) {
77132
+ const args = ["--yes", "supabase", "secrets", "set", `${SECRET_NAME}=${setValue}`];
77133
+ if (projectRef)
77134
+ args.push("--project-ref", projectRef);
77135
+ if (dryRun) {
77136
+ const shown = setValue.split(",").map(mask).join(",");
77137
+ println(c.dim(` (dry-run) npx supabase secrets set ${SECRET_NAME}=${shown}` + (projectRef ? ` --project-ref ${projectRef}` : "")));
77138
+ return;
77139
+ }
77140
+ const r = spawnSync7("npx", args, { encoding: "utf8", stdio: "inherit" });
77141
+ if (r.status !== 0) {
77142
+ throw userError(`Failed to set the ${SECRET_NAME} Function secret.`, "Install the Supabase CLI and link the project (or pass --project-ref <ref>).");
77143
+ }
77144
+ println(c.green(` ✓ Set ${SECRET_NAME} on Supabase.`));
77145
+ }
77146
+ function writeLocalEnv(token, opts) {
77147
+ if (!opts.env)
77148
+ return;
77149
+ if (opts.dryRun) {
77150
+ println(c.dim(` (dry-run) would upsert ${LOCAL_NAME} in ${resolveEnvFile()}`));
77151
+ return;
77152
+ }
77153
+ const envPath = resolveEnvFile();
77154
+ const r = upsertEnvVar(envPath, LOCAL_NAME, token, {
77155
+ noBackup: !opts.backup,
77156
+ comment: "── Cerefox access token — Edge Function credential (managed by `cerefox token`) ──"
77157
+ });
77158
+ println(c.green(` ✓ ${r.action === "created" ? "Wrote" : "Updated"} ${LOCAL_NAME} in ${r.path}`));
77159
+ if (r.backupPath)
77160
+ println(c.dim(` backup: ${r.backupPath}`));
77161
+ const warn2 = envGitignoreWarning(envPath);
77162
+ if (warn2)
77163
+ eprintln(c.yellow(` ⚠ ${warn2}`));
77164
+ }
77165
+ function printTokenOnce(token) {
77166
+ println("");
77167
+ println(c.bold(" Your Cerefox access token (shown once — store it securely):"));
77168
+ println(` ${c.green(token)}`);
77169
+ println("");
77170
+ println(c.dim(" Paste it into any token-bearing client:"));
77171
+ println(c.dim(" • Custom GPT → Configure → Actions → Authentication → API Key (Bearer)"));
77172
+ println(c.dim(" • Remote HTTP MCP → the Authorization: Bearer header"));
77173
+ println(c.dim(" If the GPT Actions schema changed this release, re-paste it too"));
77174
+ println(c.dim(" (see docs/guides/connect-agents.md). Lose the token → `cerefox token rotate`."));
77175
+ }
77176
+ function generateAction(opts) {
77177
+ const projectRef = opts.projectRef ?? parseProjectRef2(loadSettings().supabaseUrl);
77178
+ const token = mintToken();
77179
+ println(c.bold("Generating a Cerefox access token…"));
77180
+ setSecret(token, projectRef, opts.dryRun);
77181
+ writeLocalEnv(token, opts);
77182
+ if (!opts.dryRun)
77183
+ printTokenOnce(token);
77184
+ }
77185
+ function rotateAction(opts) {
77186
+ const projectRef = opts.projectRef ?? parseProjectRef2(loadSettings().supabaseUrl);
77187
+ const envPath = resolveEnvFile();
77188
+ const current = readEnvVar(envPath, LOCAL_NAME);
77189
+ if (opts.finalize) {
77190
+ if (!current) {
77191
+ throw userError(`No ${LOCAL_NAME} in ${envPath} to finalize to.`, "Run `cerefox token generate` or `cerefox token rotate` first.");
77192
+ }
77193
+ println(c.bold("Finalizing rotation (dropping the previous token)…"));
77194
+ setSecret(current, projectRef, opts.dryRun);
77195
+ if (!opts.dryRun)
77196
+ println(c.green(" ✓ Only the current token is accepted now."));
77197
+ return;
77198
+ }
77199
+ const token = mintToken();
77200
+ const setValue = current ? `${token},${current}` : token;
77201
+ println(c.bold("Rotating the Cerefox access token…"));
77202
+ setSecret(setValue, projectRef, opts.dryRun);
77203
+ writeLocalEnv(token, opts);
77204
+ if (!opts.dryRun) {
77205
+ printTokenOnce(token);
77206
+ println("");
77207
+ println(c.yellow(` Both the new and previous tokens are accepted right now. Update every
77208
+ ` + " client to the new token, then run `cerefox token rotate --finalize`\n" + " to stop accepting the old one."));
77209
+ }
77210
+ }
77211
+ function listAction2() {
77212
+ const envPath = resolveEnvFile();
77213
+ const local = readEnvVar(envPath, LOCAL_NAME);
77214
+ println(c.bold("Cerefox access token"));
77215
+ println(local ? ` local (${LOCAL_NAME} in ${envPath}): ${c.green(mask(local))}` : c.dim(` no ${LOCAL_NAME} in ${envPath} — run \`cerefox token generate\``));
77216
+ println(c.dim(` The server-side accepted set (${SECRET_NAME}) is write-only; list names/digests
77217
+ ` + " with: npx supabase secrets list"));
77218
+ }
77219
+ function registerToken(program2) {
77220
+ const token = program2.command("token").description("Manage the Cerefox Edge Function access token(s).");
77221
+ token.command("generate").description("Mint a token, set the Supabase secret, and write it to .env.").option("--project-ref <ref>", "Supabase project ref (default: derived from CEREFOX_SUPABASE_URL).").option("--no-env", "Do not write CEREFOX_ACCESS_TOKEN to .env.").option("--no-backup", "Skip the .pre-cerefox.bak backup of an existing .env.").option("--dry-run", "Print the plan without minting or writing anything.").action(generateAction);
77222
+ token.command("rotate").description("Mint a new token accepted alongside the old (zero-downtime); --finalize drops the old.").option("--finalize", "Stop accepting the previous token (run after clients migrate).").option("--project-ref <ref>", "Supabase project ref (default: derived from CEREFOX_SUPABASE_URL).").option("--no-env", "Do not write CEREFOX_ACCESS_TOKEN to .env.").option("--no-backup", "Skip the .pre-cerefox.bak backup of an existing .env.").option("--dry-run", "Print the plan without minting or writing anything.").action(rotateAction);
77223
+ token.command("list").description("Show the local token (masked) and where the server-side set lives.").action(listAction2);
77224
+ }
77225
+
77006
77226
  // src/cli/program.ts
77007
77227
  init_sync_self_docs();
77008
77228
 
77009
77229
  // src/cli/commands/web.ts
77010
77230
  init_cli_core();
77011
77231
 
77012
- // ../../node_modules/.bun/@hono+node-server@2.0.4+8bc17dcb8a4189a6/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
77232
+ // ../../node_modules/.bun/@hono+node-server@2.0.8+68404363cdc13251/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
77013
77233
  var X_ALREADY_SENT = "x-hono-already-sent";
77014
77234
 
77015
- // ../../node_modules/.bun/@hono+node-server@2.0.4+8bc17dcb8a4189a6/node_modules/@hono/node-server/dist/index.mjs
77235
+ // ../../node_modules/.bun/@hono+node-server@2.0.8+68404363cdc13251/node_modules/@hono/node-server/dist/index.mjs
77016
77236
  import { STATUS_CODES, createServer } from "node:http";
77017
77237
  import { Http2ServerRequest, constants } from "node:http2";
77018
77238
  import { Readable } from "node:stream";
77019
77239
 
77020
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/helper/websocket/index.js
77240
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/helper/websocket/index.js
77021
77241
  var WSContext = class {
77022
77242
  #init;
77023
77243
  constructor(init) {
@@ -77065,7 +77285,7 @@ var defineWebSocketHelper = (handler11) => {
77065
77285
  };
77066
77286
  };
77067
77287
 
77068
- // ../../node_modules/.bun/@hono+node-server@2.0.4+8bc17dcb8a4189a6/node_modules/@hono/node-server/dist/index.mjs
77288
+ // ../../node_modules/.bun/@hono+node-server@2.0.8+68404363cdc13251/node_modules/@hono/node-server/dist/index.mjs
77069
77289
  var RequestError = class extends Error {
77070
77290
  constructor(message, options) {
77071
77291
  super(message, options);
@@ -77506,7 +77726,8 @@ var Response$1 = class Response$12 {
77506
77726
  const liveHeaders = cache && cache[2] instanceof Headers ? cache[2] : undefined;
77507
77727
  delete this[cacheKey];
77508
77728
  return this[responseCache] ||= new GlobalResponse(this.#body, liveHeaders ? {
77509
- ...this.#init,
77729
+ status: this.#init?.status,
77730
+ statusText: this.#init?.statusText,
77510
77731
  headers: liveHeaders
77511
77732
  } : this.#init);
77512
77733
  }
@@ -78199,7 +78420,7 @@ var serve = (options, listeningListener) => {
78199
78420
  return server;
78200
78421
  };
78201
78422
 
78202
- // ../../node_modules/.bun/@hono+node-server@2.0.4+8bc17dcb8a4189a6/node_modules/@hono/node-server/dist/utils/stream.mjs
78423
+ // ../../node_modules/.bun/@hono+node-server@2.0.8+68404363cdc13251/node_modules/@hono/node-server/dist/utils/stream.mjs
78203
78424
  import { Readable as Readable2 } from "node:stream";
78204
78425
  import { versions as versions2 } from "node:process";
78205
78426
  var pr54206Applied = () => {
@@ -78265,7 +78486,7 @@ var createStreamBody = (stream, useNativeReadableToWeb = useReadableToWeb) => {
78265
78486
  });
78266
78487
  };
78267
78488
 
78268
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/utils/mime.js
78489
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/utils/mime.js
78269
78490
  var getMimeType = (filename, mimes = baseMimes) => {
78270
78491
  const regexp = /\.([a-zA-Z0-9]+?)$/;
78271
78492
  const match = filename.match(regexp);
@@ -78334,8 +78555,8 @@ var _baseMimes = {
78334
78555
  };
78335
78556
  var baseMimes = _baseMimes;
78336
78557
 
78337
- // ../../node_modules/.bun/@hono+node-server@2.0.4+8bc17dcb8a4189a6/node_modules/@hono/node-server/dist/serve-static.mjs
78338
- import { createReadStream, existsSync as existsSync12, statSync as statSync5 } from "node:fs";
78558
+ // ../../node_modules/.bun/@hono+node-server@2.0.8+68404363cdc13251/node_modules/@hono/node-server/dist/serve-static.mjs
78559
+ import { createReadStream, existsSync as existsSync13, statSync as statSync5 } from "node:fs";
78339
78560
  import { join as join12 } from "node:path";
78340
78561
  var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
78341
78562
  var ENCODINGS = {
@@ -78368,7 +78589,7 @@ var tryDecodeURI = (str) => tryDecode(str, decodeURI);
78368
78589
  var serveStatic = (options = { root: "" }) => {
78369
78590
  const root = options.root || "";
78370
78591
  const optionPath = options.path;
78371
- if (root !== "" && !existsSync12(root))
78592
+ if (root !== "" && !existsSync13(root))
78372
78593
  console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
78373
78594
  return async (c2, next) => {
78374
78595
  if (c2.finalized)
@@ -78379,7 +78600,7 @@ var serveStatic = (options = { root: "" }) => {
78379
78600
  else
78380
78601
  try {
78381
78602
  filename = tryDecodeURI(c2.req.path);
78382
- if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename))
78603
+ if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename))
78383
78604
  throw new Error;
78384
78605
  } catch {
78385
78606
  await options.onNotFound?.(c2.req.path, c2);
@@ -78398,7 +78619,7 @@ var serveStatic = (options = { root: "" }) => {
78398
78619
  }
78399
78620
  const mimeType = getMimeType(path);
78400
78621
  c2.header("Content-Type", mimeType || "application/octet-stream");
78401
- if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
78622
+ if (options.precompressed && (!mimeType || mimeType === "application/octet-stream" || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
78402
78623
  const acceptEncodingSet = new Set(c2.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim()));
78403
78624
  for (const encoding of ENCODINGS_ORDERED_KEYS) {
78404
78625
  if (!acceptEncodingSet.has(encoding))
@@ -78446,11 +78667,11 @@ var serveStatic = (options = { root: "" }) => {
78446
78667
  };
78447
78668
 
78448
78669
  // src/web/server.ts
78449
- import { existsSync as existsSync16 } from "node:fs";
78450
- import { readFileSync as readFileSync15 } from "node:fs";
78670
+ import { existsSync as existsSync17 } from "node:fs";
78671
+ import { readFileSync as readFileSync16 } from "node:fs";
78451
78672
  import { join as join16 } from "node:path";
78452
78673
 
78453
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/compose.js
78674
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/compose.js
78454
78675
  var compose = (middleware, onError, onNotFound) => {
78455
78676
  return (context, next) => {
78456
78677
  let index = -1;
@@ -78494,21 +78715,39 @@ var compose = (middleware, onError, onNotFound) => {
78494
78715
  };
78495
78716
  };
78496
78717
 
78497
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/request/constants.js
78718
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/request/constants.js
78498
78719
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
78499
78720
 
78500
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/utils/body.js
78721
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/utils/buffer.js
78722
+ var bufferToFormData = (arrayBuffer, contentType2) => {
78723
+ const response = new Response(arrayBuffer, {
78724
+ headers: {
78725
+ "Content-Type": contentType2.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase())
78726
+ }
78727
+ });
78728
+ return response.formData();
78729
+ };
78730
+
78731
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/utils/body.js
78732
+ var isRawRequest = (request) => ("headers" in request);
78501
78733
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
78502
78734
  const { all = false, dot = false } = options;
78503
- const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
78735
+ const headers = isRawRequest(request) ? request.headers : request.raw.headers;
78504
78736
  const contentType2 = headers.get("Content-Type");
78505
- if (contentType2?.startsWith("multipart/form-data") || contentType2?.startsWith("application/x-www-form-urlencoded")) {
78737
+ const mediaType = contentType2?.split(";")[0].trim().toLowerCase();
78738
+ if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") {
78506
78739
  return parseFormData(request, { all, dot });
78507
78740
  }
78508
78741
  return {};
78509
78742
  };
78510
78743
  async function parseFormData(request, options) {
78511
- const formData = await request.formData();
78744
+ const headers = isRawRequest(request) ? request.headers : request.raw.headers;
78745
+ const arrayBuffer = await request.arrayBuffer();
78746
+ const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || "");
78747
+ if (!isRawRequest(request)) {
78748
+ request.bodyCache.formData = formDataPromise;
78749
+ }
78750
+ const formData = await formDataPromise;
78512
78751
  if (formData) {
78513
78752
  return convertFormDataToBodyData(formData, options);
78514
78753
  }
@@ -78568,7 +78807,7 @@ var handleParsingNestedValues = (form, key, value) => {
78568
78807
  });
78569
78808
  };
78570
78809
 
78571
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/utils/url.js
78810
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/utils/url.js
78572
78811
  var splitPath = (path) => {
78573
78812
  const paths = path.split("/");
78574
78813
  if (paths[0] === "") {
@@ -78768,7 +79007,7 @@ var getQueryParams = (url, key) => {
78768
79007
  };
78769
79008
  var decodeURIComponent_ = decodeURIComponent;
78770
79009
 
78771
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/request.js
79010
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/request.js
78772
79011
  var tryDecodeURIComponent = (str) => tryDecode2(str, decodeURIComponent_);
78773
79012
  var HonoRequest = class {
78774
79013
  raw;
@@ -78882,7 +79121,7 @@ var HonoRequest = class {
78882
79121
  }
78883
79122
  };
78884
79123
 
78885
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/utils/html.js
79124
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/utils/html.js
78886
79125
  var HtmlEscapedCallbackPhase = {
78887
79126
  Stringify: 1,
78888
79127
  BeforeStream: 2,
@@ -78920,7 +79159,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer2) =>
78920
79159
  }
78921
79160
  };
78922
79161
 
78923
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/context.js
79162
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/context.js
78924
79163
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
78925
79164
  var setDefaultContentType = (contentType2, headers) => {
78926
79165
  return {
@@ -79087,7 +79326,7 @@ var Context = class {
79087
79326
  };
79088
79327
  };
79089
79328
 
79090
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router.js
79329
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router.js
79091
79330
  var METHOD_NAME_ALL = "ALL";
79092
79331
  var METHOD_NAME_ALL_LOWERCASE = "all";
79093
79332
  var METHODS = ["get", "post", "put", "delete", "options", "patch"];
@@ -79095,10 +79334,10 @@ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is
79095
79334
  var UnsupportedPathError = class extends Error {
79096
79335
  };
79097
79336
 
79098
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/utils/constants.js
79337
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/utils/constants.js
79099
79338
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
79100
79339
 
79101
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/hono-base.js
79340
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/hono-base.js
79102
79341
  var notFoundHandler = (c2) => {
79103
79342
  return c2.text("404 Not Found", 404);
79104
79343
  };
@@ -79322,7 +79561,7 @@ var Hono = class _Hono {
79322
79561
  };
79323
79562
  };
79324
79563
 
79325
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/matcher.js
79564
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/reg-exp-router/matcher.js
79326
79565
  var emptyParam = [];
79327
79566
  function match(method, path) {
79328
79567
  const matchers = this.buildAllMatchers();
@@ -79343,7 +79582,7 @@ function match(method, path) {
79343
79582
  return match2(method, path);
79344
79583
  }
79345
79584
 
79346
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/node.js
79585
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/reg-exp-router/node.js
79347
79586
  var LABEL_REG_EXP_STR = "[^/]+";
79348
79587
  var ONLY_WILDCARD_REG_EXP_STR = ".*";
79349
79588
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
@@ -79447,7 +79686,7 @@ var Node = class _Node {
79447
79686
  }
79448
79687
  };
79449
79688
 
79450
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/trie.js
79689
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/reg-exp-router/trie.js
79451
79690
  var Trie = class {
79452
79691
  #context = { varIndex: 0 };
79453
79692
  #root = new Node;
@@ -79503,7 +79742,7 @@ var Trie = class {
79503
79742
  }
79504
79743
  };
79505
79744
 
79506
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/router.js
79745
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/reg-exp-router/router.js
79507
79746
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
79508
79747
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
79509
79748
  function buildWildcardRegExp(path) {
@@ -79668,7 +79907,7 @@ var RegExpRouter = class {
79668
79907
  }
79669
79908
  };
79670
79909
 
79671
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/prepared-router.js
79910
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/reg-exp-router/prepared-router.js
79672
79911
  var PreparedRegExpRouter = class {
79673
79912
  name = "PreparedRegExpRouter";
79674
79913
  #matchers;
@@ -79740,7 +79979,7 @@ var PreparedRegExpRouter = class {
79740
79979
  match = match;
79741
79980
  };
79742
79981
 
79743
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/smart-router/router.js
79982
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/smart-router/router.js
79744
79983
  var SmartRouter = class {
79745
79984
  name = "SmartRouter";
79746
79985
  #routers = [];
@@ -79795,7 +80034,7 @@ var SmartRouter = class {
79795
80034
  }
79796
80035
  };
79797
80036
 
79798
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/trie-router/node.js
80037
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/trie-router/node.js
79799
80038
  var emptyParams = /* @__PURE__ */ Object.create(null);
79800
80039
  var hasChildren = (children) => {
79801
80040
  for (const _ in children) {
@@ -79929,6 +80168,9 @@ var Node2 = class _Node2 {
79929
80168
  if (m) {
79930
80169
  params[name] = m[0];
79931
80170
  this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
80171
+ if (m[0].length === restPathString.length && child.#children["*"]) {
80172
+ this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
80173
+ }
79932
80174
  if (hasChildren(child.#children)) {
79933
80175
  child.#params = params;
79934
80176
  const componentCount = m[0].match(/\//)?.length ?? 0;
@@ -79964,7 +80206,7 @@ var Node2 = class _Node2 {
79964
80206
  }
79965
80207
  };
79966
80208
 
79967
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/router/trie-router/router.js
80209
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/router/trie-router/router.js
79968
80210
  var TrieRouter = class {
79969
80211
  name = "TrieRouter";
79970
80212
  #node;
@@ -79986,7 +80228,7 @@ var TrieRouter = class {
79986
80228
  }
79987
80229
  };
79988
80230
 
79989
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/hono.js
80231
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/hono.js
79990
80232
  var Hono2 = class extends Hono {
79991
80233
  constructor(options = {}) {
79992
80234
  super(options);
@@ -79996,7 +80238,7 @@ var Hono2 = class extends Hono {
79996
80238
  }
79997
80239
  };
79998
80240
 
79999
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/utils/color.js
80241
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/utils/color.js
80000
80242
  function getColorEnabled() {
80001
80243
  const { process: process10, Deno: Deno2 } = globalThis;
80002
80244
  const isNoColor = typeof Deno2?.noColor === "boolean" ? Deno2.noColor : process10 !== undefined ? "NO_COLOR" in process10?.env : false;
@@ -80015,7 +80257,7 @@ async function getColorEnabledAsync() {
80015
80257
  return !isNoColor;
80016
80258
  }
80017
80259
 
80018
- // ../../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/middleware/logger/index.js
80260
+ // ../../node_modules/.bun/hono@4.12.29/node_modules/hono/dist/middleware/logger/index.js
80019
80261
  var humanize = (times) => {
80020
80262
  const [delimiter, separator] = [",", "."];
80021
80263
  const orderTimes = times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter));
@@ -81376,12 +81618,12 @@ import { execFileSync } from "node:child_process";
81376
81618
 
81377
81619
  // src/web/docs.ts
81378
81620
  import {
81379
- existsSync as existsSync13,
81380
- readFileSync as readFileSync13,
81621
+ existsSync as existsSync14,
81622
+ readFileSync as readFileSync14,
81381
81623
  readdirSync as readdirSync6,
81382
81624
  statSync as statSync6
81383
81625
  } from "node:fs";
81384
- import { basename as basename5, dirname as dirname5, join as join13, resolve as resolve5 } from "node:path";
81626
+ import { basename as basename5, dirname as dirname6, join as join13, resolve as resolve5 } from "node:path";
81385
81627
  import { fileURLToPath as fileURLToPath3 } from "node:url";
81386
81628
  var TOP_LEVEL_DOCS = [
81387
81629
  { filename: "README.md", path: "README.md", category: "readme" },
@@ -81397,7 +81639,7 @@ var TOP_LEVEL_DOCS = [
81397
81639
  }
81398
81640
  ];
81399
81641
  function moduleDir2() {
81400
- return dirname5(fileURLToPath3(import.meta.url));
81642
+ return dirname6(fileURLToPath3(import.meta.url));
81401
81643
  }
81402
81644
  function resolveDocsRoots() {
81403
81645
  const here = moduleDir2();
@@ -81409,7 +81651,7 @@ function resolveDocsRoots() {
81409
81651
  let pkgTopLevel = null;
81410
81652
  for (const pkg of pkgRootCandidates) {
81411
81653
  const guides = join13(pkg, "docs", "guides");
81412
- if (existsSync13(guides) && statSync6(guides).isDirectory()) {
81654
+ if (existsSync14(guides) && statSync6(guides).isDirectory()) {
81413
81655
  pkgGuides = guides;
81414
81656
  pkgTopLevel = pkg;
81415
81657
  break;
@@ -81421,13 +81663,13 @@ function resolveDocsRoots() {
81421
81663
  return {
81422
81664
  pkgGuides,
81423
81665
  pkgTopLevel,
81424
- repoGuides: existsSync13(repoGuides) ? repoGuides : null,
81425
- repoTopLevel: existsSync13(join13(repoTopLevel, "README.md")) ? repoTopLevel : null
81666
+ repoGuides: existsSync14(repoGuides) ? repoGuides : null,
81667
+ repoTopLevel: existsSync14(join13(repoTopLevel, "README.md")) ? repoTopLevel : null
81426
81668
  };
81427
81669
  }
81428
81670
  function readH1(filePath) {
81429
81671
  try {
81430
- const content = readFileSync13(filePath, "utf8");
81672
+ const content = readFileSync14(filePath, "utf8");
81431
81673
  const match2 = content.match(/^#\s+(.+?)\s*$/m);
81432
81674
  return match2 ? match2[1] : null;
81433
81675
  } catch {
@@ -81448,7 +81690,7 @@ function listBundledDocs2() {
81448
81690
  if (topRoot) {
81449
81691
  for (const t of TOP_LEVEL_DOCS) {
81450
81692
  const abs = join13(topRoot, t.filename);
81451
- if (existsSync13(abs)) {
81693
+ if (existsSync14(abs)) {
81452
81694
  entries.push(entryForFile(abs, t.path, t.category));
81453
81695
  }
81454
81696
  }
@@ -81475,9 +81717,9 @@ function readDoc(docPath) {
81475
81717
  if (!candidate.startsWith(rootResolved + "/") && candidate !== rootResolved) {
81476
81718
  return null;
81477
81719
  }
81478
- if (existsSync13(candidate) && statSync6(candidate).isFile()) {
81720
+ if (existsSync14(candidate) && statSync6(candidate).isFile()) {
81479
81721
  try {
81480
- return readFileSync13(candidate, "utf8");
81722
+ return readFileSync14(candidate, "utf8");
81481
81723
  } catch {
81482
81724
  return null;
81483
81725
  }
@@ -81522,17 +81764,17 @@ function registerMetaRoutes(app, ctx) {
81522
81764
  app.get("/api/v1/schema-version", async (c2) => {
81523
81765
  let bundled = null;
81524
81766
  try {
81525
- const { readFileSync: readFileSync14, existsSync: existsSync14 } = await import("node:fs");
81767
+ const { readFileSync: readFileSync15, existsSync: existsSync15 } = await import("node:fs");
81526
81768
  const { fileURLToPath: fileURLToPath4 } = await import("node:url");
81527
- const { dirname: dirname6, join: join14 } = await import("node:path");
81528
- const here = dirname6(fileURLToPath4(import.meta.url));
81769
+ const { dirname: dirname7, join: join14 } = await import("node:path");
81770
+ const here = dirname7(fileURLToPath4(import.meta.url));
81529
81771
  const candidates = [
81530
81772
  join14(here, "..", "..", "..", "db", "schema.sql"),
81531
81773
  join14(here, "..", "..", "..", "..", "..", "src", "cerefox", "db", "schema.sql")
81532
81774
  ];
81533
81775
  for (const path of candidates) {
81534
- if (existsSync14(path)) {
81535
- const sql = readFileSync14(path, "utf8");
81776
+ if (existsSync15(path)) {
81777
+ const sql = readFileSync15(path, "utf8");
81536
81778
  const match2 = sql.match(SCHEMA_VERSION_RE2);
81537
81779
  bundled = match2 ? match2[1] : null;
81538
81780
  break;
@@ -81628,7 +81870,7 @@ function registerPostgrestProxy(app) {
81628
81870
 
81629
81871
  // src/web/routes/preferences.ts
81630
81872
  init_config();
81631
- import { existsSync as existsSync14, mkdirSync as mkdirSync4, readFileSync as readFileSync14, writeFileSync as writeFileSync5 } from "node:fs";
81873
+ import { existsSync as existsSync15, mkdirSync as mkdirSync4, readFileSync as readFileSync15, writeFileSync as writeFileSync6 } from "node:fs";
81632
81874
  import { join as join14 } from "node:path";
81633
81875
  function isTheme(v) {
81634
81876
  return v === "auto" || v === "light" || v === "dark";
@@ -81638,7 +81880,7 @@ function prefsFile() {
81638
81880
  }
81639
81881
  function readPrefs() {
81640
81882
  try {
81641
- const raw2 = JSON.parse(readFileSync14(prefsFile(), "utf8"));
81883
+ const raw2 = JSON.parse(readFileSync15(prefsFile(), "utf8"));
81642
81884
  if (isTheme(raw2.theme))
81643
81885
  return { theme: raw2.theme };
81644
81886
  } catch {}
@@ -81654,9 +81896,9 @@ function registerPreferencesRoutes(app) {
81654
81896
  const next = { ...readPrefs(), theme: body.theme };
81655
81897
  try {
81656
81898
  const dir = userStateDir();
81657
- if (!existsSync14(dir))
81899
+ if (!existsSync15(dir))
81658
81900
  mkdirSync4(dir, { recursive: true });
81659
- writeFileSync5(prefsFile(), `${JSON.stringify(next, null, 2)}
81901
+ writeFileSync6(prefsFile(), `${JSON.stringify(next, null, 2)}
81660
81902
  `);
81661
81903
  } catch (err) {
81662
81904
  return c2.json({ detail: err instanceof Error ? err.message : String(err) }, 500);
@@ -81726,14 +81968,14 @@ function registerProjectsRoutes(app, ctx) {
81726
81968
  }
81727
81969
 
81728
81970
  // src/web/static.ts
81729
- import { existsSync as existsSync15, statSync as statSync7 } from "node:fs";
81730
- import { dirname as dirname6, join as join15 } from "node:path";
81971
+ import { existsSync as existsSync16, statSync as statSync7 } from "node:fs";
81972
+ import { dirname as dirname7, join as join15 } from "node:path";
81731
81973
  import { fileURLToPath as fileURLToPath4 } from "node:url";
81732
81974
  function moduleDir3() {
81733
- return dirname6(fileURLToPath4(import.meta.url));
81975
+ return dirname7(fileURLToPath4(import.meta.url));
81734
81976
  }
81735
81977
  function isUsableSpaDir(dir) {
81736
- return existsSync15(dir) && statSync7(dir).isDirectory() && existsSync15(join15(dir, "index.html"));
81978
+ return existsSync16(dir) && statSync7(dir).isDirectory() && existsSync16(join15(dir, "index.html"));
81737
81979
  }
81738
81980
  function resolveSpaDist() {
81739
81981
  const here = moduleDir3();
@@ -81755,7 +81997,7 @@ function resolveStaticDir() {
81755
81997
  join15(here, "..", "..", "..", "..", "web", "static")
81756
81998
  ];
81757
81999
  for (const c2 of candidates) {
81758
- if (existsSync15(c2) && statSync7(c2).isDirectory())
82000
+ if (existsSync16(c2) && statSync7(c2).isDirectory())
81759
82001
  return c2;
81760
82002
  }
81761
82003
  return null;
@@ -81842,8 +82084,8 @@ function buildApp(ctx = buildWebContext()) {
81842
82084
  rewriteRequestPath: (path) => path.replace(/^\/app/, "") || "/"
81843
82085
  }));
81844
82086
  const indexPath = join16(spaDist, "index.html");
81845
- if (existsSync16(indexPath)) {
81846
- const indexHtml = readFileSync15(indexPath, "utf8");
82087
+ if (existsSync17(indexPath)) {
82088
+ const indexHtml = readFileSync16(indexPath, "utf8");
81847
82089
  app.get("/app/*", (c2) => c2.html(indexHtml));
81848
82090
  }
81849
82091
  }
@@ -81855,13 +82097,13 @@ class CompatibilityError extends Error {
81855
82097
  }
81856
82098
  async function assertServerCompatible() {
81857
82099
  const settings = loadSettings();
81858
- if (!settings.supabaseUrl || !settings.supabaseAnonKey)
82100
+ if (!settings.supabaseUrl || !settings.accessToken)
81859
82101
  return;
81860
82102
  let compat2;
81861
82103
  try {
81862
82104
  compat2 = await checkServerCompatibility({
81863
82105
  aggregatorUrl: aggregatorUrlFor(settings.supabaseUrl),
81864
- bearer: settings.supabaseAnonKey,
82106
+ bearer: settings.accessToken,
81865
82107
  bundledEf: EF_VERSION
81866
82108
  });
81867
82109
  } catch {
@@ -81901,12 +82143,12 @@ async function buildWebServer(options = {}) {
81901
82143
  // src/web/daemon.ts
81902
82144
  import { spawn } from "node:child_process";
81903
82145
  import {
81904
- existsSync as existsSync17,
82146
+ existsSync as existsSync18,
81905
82147
  mkdirSync as mkdirSync5,
81906
82148
  openSync,
81907
- readFileSync as readFileSync16,
82149
+ readFileSync as readFileSync17,
81908
82150
  rmSync,
81909
- writeFileSync as writeFileSync6
82151
+ writeFileSync as writeFileSync7
81910
82152
  } from "node:fs";
81911
82153
  import { homedir as homedir8 } from "node:os";
81912
82154
  import { join as join17 } from "node:path";
@@ -81915,14 +82157,14 @@ var PID_FILE = join17(STATE_DIR, "web.pid");
81915
82157
  var LOG_FILE = join17(STATE_DIR, "web.log");
81916
82158
  var daemonPaths = { stateDir: STATE_DIR, pidFile: PID_FILE, logFile: LOG_FILE };
81917
82159
  function ensureStateDir() {
81918
- if (!existsSync17(STATE_DIR))
82160
+ if (!existsSync18(STATE_DIR))
81919
82161
  mkdirSync5(STATE_DIR, { recursive: true });
81920
82162
  }
81921
82163
  function readPidFile() {
81922
- if (!existsSync17(PID_FILE))
82164
+ if (!existsSync18(PID_FILE))
81923
82165
  return null;
81924
82166
  try {
81925
- const parsed = JSON.parse(readFileSync16(PID_FILE, "utf8"));
82167
+ const parsed = JSON.parse(readFileSync17(PID_FILE, "utf8"));
81926
82168
  if (typeof parsed.pid !== "number")
81927
82169
  return null;
81928
82170
  return {
@@ -81937,7 +82179,7 @@ function readPidFile() {
81937
82179
  }
81938
82180
  function writePidFile(info3) {
81939
82181
  ensureStateDir();
81940
- writeFileSync6(PID_FILE, JSON.stringify(info3, null, 2) + `
82182
+ writeFileSync7(PID_FILE, JSON.stringify(info3, null, 2) + `
81941
82183
  `, "utf8");
81942
82184
  }
81943
82185
  function removePidFile() {
@@ -82235,6 +82477,7 @@ Learn more:
82235
82477
  registerMcp(program2);
82236
82478
  registerWeb(program2);
82237
82479
  registerCompletion(program2);
82480
+ registerToken(program2);
82238
82481
  const document2 = program2.command("document").description("Documents: get, list, edit, delete, restore, ingest, ingest-dir, version.");
82239
82482
  moveInto(document2, registerGetDoc, "get");
82240
82483
  moveInto(document2, registerListDocs, "list");
@@ -82285,7 +82528,7 @@ Learn more:
82285
82528
 
82286
82529
  // src/bin/cerefox.ts
82287
82530
  async function bareEntryPoint() {
82288
- const { existsSync: existsSync18 } = await import("node:fs");
82531
+ const { existsSync: existsSync19 } = await import("node:fs");
82289
82532
  const { resolveEnvFile: resolveEnvFile2 } = await Promise.resolve().then(() => (init_config(), exports_config));
82290
82533
  const { c: c2, println: println2 } = await Promise.resolve().then(() => (init_cli_core(), exports_cli_core));
82291
82534
  const { PKG_VERSION: PKG_VERSION2 } = await Promise.resolve().then(() => (init_meta(), exports_meta));
@@ -82294,7 +82537,7 @@ async function bareEntryPoint() {
82294
82537
  println2("");
82295
82538
  let configExists = false;
82296
82539
  try {
82297
- configExists = existsSync18(resolveEnvFile2());
82540
+ configExists = existsSync19(resolveEnvFile2());
82298
82541
  } catch {}
82299
82542
  if (!configExists) {
82300
82543
  println2(c2.yellow("⚠ No config detected."));