zephex 2.0.11 → 2.0.14

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.
@@ -149,6 +149,25 @@ function filePolyfill(path) {
149
149
  text: async () => readFile(path, "utf8")
150
150
  };
151
151
  }
152
+
153
+ class GlobPolyfill {
154
+ pattern;
155
+ constructor(pattern) {
156
+ this.pattern = pattern;
157
+ }
158
+ async* scan(opts) {
159
+ const { glob } = await import("node:fs/promises");
160
+ const cwd = opts?.cwd ?? process.cwd();
161
+ for await (const entry of glob(this.pattern, { cwd })) {
162
+ if (opts?.absolute) {
163
+ const { resolve } = await import("node:path");
164
+ yield resolve(cwd, entry);
165
+ } else {
166
+ yield entry;
167
+ }
168
+ }
169
+ }
170
+ }
152
171
  function ensureBunPolyfill() {
153
172
  const g = globalThis;
154
173
  if (typeof g.Bun !== "undefined")
@@ -156,7 +175,8 @@ function ensureBunPolyfill() {
156
175
  g.Bun = {
157
176
  file: filePolyfill,
158
177
  spawn: spawnPolyfill,
159
- JSONL: { parse: jsonlParsePolyfill }
178
+ JSONL: { parse: jsonlParsePolyfill },
179
+ Glob: GlobPolyfill
160
180
  };
161
181
  }
162
182
  var init_bun_polyfill = __esm(() => {
@@ -14034,7 +14054,7 @@ var ZEPHEX_TOOLS, ThinkInputSchema, ThinkOutputSchema;
14034
14054
  var init_schemas3 = __esm(() => {
14035
14055
  init_zod();
14036
14056
  ZEPHEX_TOOLS = [
14037
- "inspect_url",
14057
+ "Zephex_dev_info",
14038
14058
  "audit_headers",
14039
14059
  "find_code",
14040
14060
  "read_code",
@@ -14719,7 +14739,7 @@ var require_tslib = __commonJS((exports, module) => {
14719
14739
  });
14720
14740
  });
14721
14741
 
14722
- // node_modules/.bun/@supabase+functions-js@2.100.1/node_modules/@supabase/functions-js/dist/main/helper.js
14742
+ // node_modules/.bun/@supabase+functions-js@2.105.1/node_modules/@supabase/functions-js/dist/main/helper.js
14723
14743
  var require_helper = __commonJS((exports) => {
14724
14744
  Object.defineProperty(exports, "__esModule", { value: true });
14725
14745
  exports.resolveFetch = undefined;
@@ -14732,7 +14752,7 @@ var require_helper = __commonJS((exports) => {
14732
14752
  exports.resolveFetch = resolveFetch;
14733
14753
  });
14734
14754
 
14735
- // node_modules/.bun/@supabase+functions-js@2.100.1/node_modules/@supabase/functions-js/dist/main/types.js
14755
+ // node_modules/.bun/@supabase+functions-js@2.105.1/node_modules/@supabase/functions-js/dist/main/types.js
14736
14756
  var require_types = __commonJS((exports) => {
14737
14757
  Object.defineProperty(exports, "__esModule", { value: true });
14738
14758
  exports.FunctionRegion = exports.FunctionsHttpError = exports.FunctionsRelayError = exports.FunctionsFetchError = exports.FunctionsError = undefined;
@@ -14743,6 +14763,13 @@ var require_types = __commonJS((exports) => {
14743
14763
  this.name = name;
14744
14764
  this.context = context;
14745
14765
  }
14766
+ toJSON() {
14767
+ return {
14768
+ name: this.name,
14769
+ message: this.message,
14770
+ context: this.context
14771
+ };
14772
+ }
14746
14773
  }
14747
14774
  exports.FunctionsError = FunctionsError;
14748
14775
 
@@ -14786,7 +14813,7 @@ var require_types = __commonJS((exports) => {
14786
14813
  })(FunctionRegion || (exports.FunctionRegion = FunctionRegion = {}));
14787
14814
  });
14788
14815
 
14789
- // node_modules/.bun/@supabase+functions-js@2.100.1/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js
14816
+ // node_modules/.bun/@supabase+functions-js@2.105.1/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js
14790
14817
  var require_FunctionsClient = __commonJS((exports) => {
14791
14818
  Object.defineProperty(exports, "__esModule", { value: true });
14792
14819
  exports.FunctionsClient = undefined;
@@ -14899,7 +14926,7 @@ var require_FunctionsClient = __commonJS((exports) => {
14899
14926
  exports.FunctionsClient = FunctionsClient;
14900
14927
  });
14901
14928
 
14902
- // node_modules/.bun/@supabase+functions-js@2.100.1/node_modules/@supabase/functions-js/dist/main/index.js
14929
+ // node_modules/.bun/@supabase+functions-js@2.105.1/node_modules/@supabase/functions-js/dist/main/index.js
14903
14930
  var require_main = __commonJS((exports) => {
14904
14931
  Object.defineProperty(exports, "__esModule", { value: true });
14905
14932
  exports.FunctionRegion = exports.FunctionsRelayError = exports.FunctionsHttpError = exports.FunctionsFetchError = exports.FunctionsError = exports.FunctionsClient = undefined;
@@ -14925,7 +14952,33 @@ var require_main = __commonJS((exports) => {
14925
14952
  } });
14926
14953
  });
14927
14954
 
14928
- // node_modules/.bun/@supabase+postgrest-js@2.100.1/node_modules/@supabase/postgrest-js/dist/index.mjs
14955
+ // node_modules/.bun/@supabase+postgrest-js@2.105.1/node_modules/@supabase/postgrest-js/dist/index.mjs
14956
+ function sleep(ms, signal) {
14957
+ return new Promise((resolve) => {
14958
+ if (signal === null || signal === undefined ? undefined : signal.aborted) {
14959
+ resolve();
14960
+ return;
14961
+ }
14962
+ const id = setTimeout(() => {
14963
+ signal === null || signal === undefined || signal.removeEventListener("abort", onAbort);
14964
+ resolve();
14965
+ }, ms);
14966
+ function onAbort() {
14967
+ clearTimeout(id);
14968
+ resolve();
14969
+ }
14970
+ signal === null || signal === undefined || signal.addEventListener("abort", onAbort);
14971
+ });
14972
+ }
14973
+ function shouldRetry(method, status, attemptCount, retryEnabled) {
14974
+ if (!retryEnabled || attemptCount >= DEFAULT_MAX_RETRIES)
14975
+ return false;
14976
+ if (!RETRYABLE_METHODS.includes(method))
14977
+ return false;
14978
+ if (!RETRYABLE_STATUS_CODES.includes(status))
14979
+ return false;
14980
+ return true;
14981
+ }
14929
14982
  function _typeof(o) {
14930
14983
  "@babel/helpers - typeof";
14931
14984
  return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o$1) {
@@ -14979,10 +15032,11 @@ function _objectSpread2(e) {
14979
15032
  }
14980
15033
  return e;
14981
15034
  }
14982
- var PostgrestError, PostgrestBuilder = class {
15035
+ var DEFAULT_MAX_RETRIES = 3, getRetryDelay = (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000), RETRYABLE_STATUS_CODES, RETRYABLE_METHODS, PostgrestError, PostgrestBuilder = class {
14983
15036
  constructor(builder) {
14984
- var _builder$shouldThrowO, _builder$isMaybeSingl, _builder$urlLengthLim;
15037
+ var _builder$shouldThrowO, _builder$isMaybeSingl, _builder$shouldStripN, _builder$urlLengthLim, _builder$retry;
14985
15038
  this.shouldThrowOnError = false;
15039
+ this.retryEnabled = true;
14986
15040
  this.method = builder.method;
14987
15041
  this.url = builder.url;
14988
15042
  this.headers = new Headers(builder.headers);
@@ -14991,7 +15045,9 @@ var PostgrestError, PostgrestBuilder = class {
14991
15045
  this.shouldThrowOnError = (_builder$shouldThrowO = builder.shouldThrowOnError) !== null && _builder$shouldThrowO !== undefined ? _builder$shouldThrowO : false;
14992
15046
  this.signal = builder.signal;
14993
15047
  this.isMaybeSingle = (_builder$isMaybeSingl = builder.isMaybeSingle) !== null && _builder$isMaybeSingl !== undefined ? _builder$isMaybeSingl : false;
15048
+ this.shouldStripNulls = (_builder$shouldStripN = builder.shouldStripNulls) !== null && _builder$shouldStripN !== undefined ? _builder$shouldStripN : false;
14994
15049
  this.urlLengthLimit = (_builder$urlLengthLim = builder.urlLengthLimit) !== null && _builder$urlLengthLim !== undefined ? _builder$urlLengthLim : 8000;
15050
+ this.retryEnabled = (_builder$retry = builder.retry) !== null && _builder$retry !== undefined ? _builder$retry : true;
14995
15051
  if (builder.fetch)
14996
15052
  this.fetch = builder.fetch;
14997
15053
  else
@@ -15001,11 +15057,21 @@ var PostgrestError, PostgrestBuilder = class {
15001
15057
  this.shouldThrowOnError = true;
15002
15058
  return this;
15003
15059
  }
15060
+ stripNulls() {
15061
+ if (this.headers.get("Accept") === "text/csv")
15062
+ throw new Error("stripNulls() cannot be used with csv()");
15063
+ this.shouldStripNulls = true;
15064
+ return this;
15065
+ }
15004
15066
  setHeader(name, value) {
15005
15067
  this.headers = new Headers(this.headers);
15006
15068
  this.headers.set(name, value);
15007
15069
  return this;
15008
15070
  }
15071
+ retry(enabled) {
15072
+ this.retryEnabled = enabled;
15073
+ return this;
15074
+ }
15009
15075
  then(onfulfilled, onrejected) {
15010
15076
  var _this = this;
15011
15077
  if (this.schema === undefined) {} else if (["GET", "HEAD"].includes(this.method))
@@ -15014,78 +15080,54 @@ var PostgrestError, PostgrestBuilder = class {
15014
15080
  this.headers.set("Content-Profile", this.schema);
15015
15081
  if (this.method !== "GET" && this.method !== "HEAD")
15016
15082
  this.headers.set("Content-Type", "application/json");
15083
+ if (this.shouldStripNulls) {
15084
+ const currentAccept = this.headers.get("Accept");
15085
+ if (currentAccept === "application/vnd.pgrst.object+json")
15086
+ this.headers.set("Accept", "application/vnd.pgrst.object+json;nulls=stripped");
15087
+ else if (!currentAccept || currentAccept === "application/json")
15088
+ this.headers.set("Accept", "application/vnd.pgrst.array+json;nulls=stripped");
15089
+ }
15017
15090
  const _fetch = this.fetch;
15018
- let res = _fetch(this.url.toString(), {
15019
- method: this.method,
15020
- headers: this.headers,
15021
- body: JSON.stringify(this.body),
15022
- signal: this.signal
15023
- }).then(async (res$1) => {
15024
- let error48 = null;
15025
- let data = null;
15026
- let count = null;
15027
- let status = res$1.status;
15028
- let statusText = res$1.statusText;
15029
- if (res$1.ok) {
15030
- var _this$headers$get2, _res$headers$get;
15031
- if (_this.method !== "HEAD") {
15032
- var _this$headers$get;
15033
- const body = await res$1.text();
15034
- if (body === "") {} else if (_this.headers.get("Accept") === "text/csv")
15035
- data = body;
15036
- else if (_this.headers.get("Accept") && ((_this$headers$get = _this.headers.get("Accept")) === null || _this$headers$get === undefined ? undefined : _this$headers$get.includes("application/vnd.pgrst.plan+text")))
15037
- data = body;
15038
- else
15039
- data = JSON.parse(body);
15040
- }
15041
- const countHeader = (_this$headers$get2 = _this.headers.get("Prefer")) === null || _this$headers$get2 === undefined ? undefined : _this$headers$get2.match(/count=(exact|planned|estimated)/);
15042
- const contentRange = (_res$headers$get = res$1.headers.get("content-range")) === null || _res$headers$get === undefined ? undefined : _res$headers$get.split("/");
15043
- if (countHeader && contentRange && contentRange.length > 1)
15044
- count = parseInt(contentRange[1]);
15045
- if (_this.isMaybeSingle && Array.isArray(data))
15046
- if (data.length > 1) {
15047
- error48 = {
15048
- code: "PGRST116",
15049
- details: `Results contain ${data.length} rows, application/vnd.pgrst.object+json requires 1 row`,
15050
- hint: null,
15051
- message: "JSON object requested, multiple (or no) rows returned"
15052
- };
15053
- data = null;
15054
- count = null;
15055
- status = 406;
15056
- statusText = "Not Acceptable";
15057
- } else if (data.length === 1)
15058
- data = data[0];
15059
- else
15060
- data = null;
15061
- } else {
15062
- const body = await res$1.text();
15091
+ const executeWithRetry = async () => {
15092
+ let attemptCount = 0;
15093
+ while (true) {
15094
+ const requestHeaders = new Headers(_this.headers);
15095
+ if (attemptCount > 0)
15096
+ requestHeaders.set("X-Retry-Count", String(attemptCount));
15097
+ let res$1;
15063
15098
  try {
15064
- error48 = JSON.parse(body);
15065
- if (Array.isArray(error48) && res$1.status === 404) {
15066
- data = [];
15067
- error48 = null;
15068
- status = 200;
15069
- statusText = "OK";
15070
- }
15071
- } catch (_unused) {
15072
- if (res$1.status === 404 && body === "") {
15073
- status = 204;
15074
- statusText = "No Content";
15075
- } else
15076
- error48 = { message: body };
15077
- }
15078
- if (error48 && _this.shouldThrowOnError)
15079
- throw new PostgrestError(error48);
15099
+ res$1 = await _fetch(_this.url.toString(), {
15100
+ method: _this.method,
15101
+ headers: requestHeaders,
15102
+ body: JSON.stringify(_this.body, (_, value) => typeof value === "bigint" ? value.toString() : value),
15103
+ signal: _this.signal
15104
+ });
15105
+ } catch (fetchError) {
15106
+ if ((fetchError === null || fetchError === undefined ? undefined : fetchError.name) === "AbortError" || (fetchError === null || fetchError === undefined ? undefined : fetchError.code) === "ABORT_ERR")
15107
+ throw fetchError;
15108
+ if (!RETRYABLE_METHODS.includes(_this.method))
15109
+ throw fetchError;
15110
+ if (_this.retryEnabled && attemptCount < DEFAULT_MAX_RETRIES) {
15111
+ const delay = getRetryDelay(attemptCount);
15112
+ attemptCount++;
15113
+ await sleep(delay, _this.signal);
15114
+ continue;
15115
+ }
15116
+ throw fetchError;
15117
+ }
15118
+ if (shouldRetry(_this.method, res$1.status, attemptCount, _this.retryEnabled)) {
15119
+ var _res$headers$get, _res$headers;
15120
+ const retryAfterHeader = (_res$headers$get = (_res$headers = res$1.headers) === null || _res$headers === undefined ? undefined : _res$headers.get("Retry-After")) !== null && _res$headers$get !== undefined ? _res$headers$get : null;
15121
+ const delay = retryAfterHeader !== null ? Math.max(0, parseInt(retryAfterHeader, 10) || 0) * 1000 : getRetryDelay(attemptCount);
15122
+ await res$1.text();
15123
+ attemptCount++;
15124
+ await sleep(delay, _this.signal);
15125
+ continue;
15126
+ }
15127
+ return await _this.processResponse(res$1);
15080
15128
  }
15081
- return {
15082
- error: error48,
15083
- data,
15084
- count,
15085
- status,
15086
- statusText
15087
- };
15088
- });
15129
+ };
15130
+ let res = executeWithRetry();
15089
15131
  if (!this.shouldThrowOnError)
15090
15132
  res = res.catch((fetchError) => {
15091
15133
  var _fetchError$name2;
@@ -15123,6 +15165,7 @@ ${cause.stack}`;
15123
15165
  hint += `. Your request URL is ${urlLength} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`;
15124
15166
  }
15125
15167
  return {
15168
+ success: false,
15126
15169
  error: {
15127
15170
  message: `${(_fetchError$name2 = fetchError === null || fetchError === undefined ? undefined : fetchError.name) !== null && _fetchError$name2 !== undefined ? _fetchError$name2 : "FetchError"}: ${fetchError === null || fetchError === undefined ? undefined : fetchError.message}`,
15128
15171
  details: errorDetails,
@@ -15137,6 +15180,74 @@ ${cause.stack}`;
15137
15180
  });
15138
15181
  return res.then(onfulfilled, onrejected);
15139
15182
  }
15183
+ async processResponse(res) {
15184
+ var _this2 = this;
15185
+ let error48 = null;
15186
+ let data = null;
15187
+ let count = null;
15188
+ let status = res.status;
15189
+ let statusText = res.statusText;
15190
+ if (res.ok) {
15191
+ var _this$headers$get2, _res$headers$get2;
15192
+ if (_this2.method !== "HEAD") {
15193
+ var _this$headers$get;
15194
+ const body = await res.text();
15195
+ if (body === "") {} else if (_this2.headers.get("Accept") === "text/csv")
15196
+ data = body;
15197
+ else if (_this2.headers.get("Accept") && ((_this$headers$get = _this2.headers.get("Accept")) === null || _this$headers$get === undefined ? undefined : _this$headers$get.includes("application/vnd.pgrst.plan+text")))
15198
+ data = body;
15199
+ else
15200
+ data = JSON.parse(body);
15201
+ }
15202
+ const countHeader = (_this$headers$get2 = _this2.headers.get("Prefer")) === null || _this$headers$get2 === undefined ? undefined : _this$headers$get2.match(/count=(exact|planned|estimated)/);
15203
+ const contentRange = (_res$headers$get2 = res.headers.get("content-range")) === null || _res$headers$get2 === undefined ? undefined : _res$headers$get2.split("/");
15204
+ if (countHeader && contentRange && contentRange.length > 1)
15205
+ count = parseInt(contentRange[1]);
15206
+ if (_this2.isMaybeSingle && Array.isArray(data))
15207
+ if (data.length > 1) {
15208
+ error48 = {
15209
+ code: "PGRST116",
15210
+ details: `Results contain ${data.length} rows, application/vnd.pgrst.object+json requires 1 row`,
15211
+ hint: null,
15212
+ message: "JSON object requested, multiple (or no) rows returned"
15213
+ };
15214
+ data = null;
15215
+ count = null;
15216
+ status = 406;
15217
+ statusText = "Not Acceptable";
15218
+ } else if (data.length === 1)
15219
+ data = data[0];
15220
+ else
15221
+ data = null;
15222
+ } else {
15223
+ const body = await res.text();
15224
+ try {
15225
+ error48 = JSON.parse(body);
15226
+ if (Array.isArray(error48) && res.status === 404) {
15227
+ data = [];
15228
+ error48 = null;
15229
+ status = 200;
15230
+ statusText = "OK";
15231
+ }
15232
+ } catch (_unused) {
15233
+ if (res.status === 404 && body === "") {
15234
+ status = 204;
15235
+ statusText = "No Content";
15236
+ } else
15237
+ error48 = { message: body };
15238
+ }
15239
+ if (error48 && _this2.shouldThrowOnError)
15240
+ throw new PostgrestError(error48);
15241
+ }
15242
+ return {
15243
+ success: error48 === null,
15244
+ error: error48,
15245
+ data,
15246
+ count,
15247
+ status,
15248
+ statusText
15249
+ };
15250
+ }
15140
15251
  returns() {
15141
15252
  return this;
15142
15253
  }
@@ -15144,12 +15255,13 @@ ${cause.stack}`;
15144
15255
  return this;
15145
15256
  }
15146
15257
  }, PostgrestTransformBuilder, PostgrestReservedCharsRegexp, PostgrestFilterBuilder, PostgrestQueryBuilder = class {
15147
- constructor(url2, { headers = {}, schema, fetch: fetch$1, urlLengthLimit = 8000 }) {
15258
+ constructor(url2, { headers = {}, schema, fetch: fetch$1, urlLengthLimit = 8000, retry }) {
15148
15259
  this.url = url2;
15149
15260
  this.headers = new Headers(headers);
15150
15261
  this.schema = schema;
15151
15262
  this.fetch = fetch$1;
15152
15263
  this.urlLengthLimit = urlLengthLimit;
15264
+ this.retry = retry;
15153
15265
  }
15154
15266
  cloneRequestState() {
15155
15267
  return {
@@ -15178,7 +15290,8 @@ ${cause.stack}`;
15178
15290
  headers,
15179
15291
  schema: this.schema,
15180
15292
  fetch: this.fetch,
15181
- urlLengthLimit: this.urlLengthLimit
15293
+ urlLengthLimit: this.urlLengthLimit,
15294
+ retry: this.retry
15182
15295
  });
15183
15296
  }
15184
15297
  insert(values, { count, defaultToNull = true } = {}) {
@@ -15203,7 +15316,8 @@ ${cause.stack}`;
15203
15316
  schema: this.schema,
15204
15317
  body: values,
15205
15318
  fetch: (_this$fetch = this.fetch) !== null && _this$fetch !== undefined ? _this$fetch : fetch,
15206
- urlLengthLimit: this.urlLengthLimit
15319
+ urlLengthLimit: this.urlLengthLimit,
15320
+ retry: this.retry
15207
15321
  });
15208
15322
  }
15209
15323
  upsert(values, { onConflict, ignoreDuplicates = false, count, defaultToNull = true } = {}) {
@@ -15231,7 +15345,8 @@ ${cause.stack}`;
15231
15345
  schema: this.schema,
15232
15346
  body: values,
15233
15347
  fetch: (_this$fetch2 = this.fetch) !== null && _this$fetch2 !== undefined ? _this$fetch2 : fetch,
15234
- urlLengthLimit: this.urlLengthLimit
15348
+ urlLengthLimit: this.urlLengthLimit,
15349
+ retry: this.retry
15235
15350
  });
15236
15351
  }
15237
15352
  update(values, { count } = {}) {
@@ -15247,7 +15362,8 @@ ${cause.stack}`;
15247
15362
  schema: this.schema,
15248
15363
  body: values,
15249
15364
  fetch: (_this$fetch3 = this.fetch) !== null && _this$fetch3 !== undefined ? _this$fetch3 : fetch,
15250
- urlLengthLimit: this.urlLengthLimit
15365
+ urlLengthLimit: this.urlLengthLimit,
15366
+ retry: this.retry
15251
15367
  });
15252
15368
  }
15253
15369
  delete({ count } = {}) {
@@ -15262,11 +15378,12 @@ ${cause.stack}`;
15262
15378
  headers,
15263
15379
  schema: this.schema,
15264
15380
  fetch: (_this$fetch4 = this.fetch) !== null && _this$fetch4 !== undefined ? _this$fetch4 : fetch,
15265
- urlLengthLimit: this.urlLengthLimit
15381
+ urlLengthLimit: this.urlLengthLimit,
15382
+ retry: this.retry
15266
15383
  });
15267
15384
  }
15268
15385
  }, PostgrestClient = class PostgrestClient2 {
15269
- constructor(url2, { headers = {}, schema, fetch: fetch$1, timeout, urlLengthLimit = 8000 } = {}) {
15386
+ constructor(url2, { headers = {}, schema, fetch: fetch$1, timeout, urlLengthLimit = 8000, retry } = {}) {
15270
15387
  this.url = url2;
15271
15388
  this.headers = new Headers(headers);
15272
15389
  this.schemaName = schema;
@@ -15296,6 +15413,7 @@ ${cause.stack}`;
15296
15413
  };
15297
15414
  else
15298
15415
  this.fetch = originalFetch;
15416
+ this.retry = retry;
15299
15417
  }
15300
15418
  from(relation) {
15301
15419
  if (!relation || typeof relation !== "string" || relation.trim() === "")
@@ -15304,7 +15422,8 @@ ${cause.stack}`;
15304
15422
  headers: new Headers(this.headers),
15305
15423
  schema: this.schemaName,
15306
15424
  fetch: this.fetch,
15307
- urlLengthLimit: this.urlLengthLimit
15425
+ urlLengthLimit: this.urlLengthLimit,
15426
+ retry: this.retry
15308
15427
  });
15309
15428
  }
15310
15429
  schema(schema) {
@@ -15312,7 +15431,8 @@ ${cause.stack}`;
15312
15431
  headers: this.headers,
15313
15432
  schema,
15314
15433
  fetch: this.fetch,
15315
- urlLengthLimit: this.urlLengthLimit
15434
+ urlLengthLimit: this.urlLengthLimit,
15435
+ retry: this.retry
15316
15436
  });
15317
15437
  }
15318
15438
  rpc(fn, args = {}, { head = false, get = false, count } = {}) {
@@ -15346,11 +15466,18 @@ ${cause.stack}`;
15346
15466
  schema: this.schemaName,
15347
15467
  body,
15348
15468
  fetch: (_this$fetch = this.fetch) !== null && _this$fetch !== undefined ? _this$fetch : fetch,
15349
- urlLengthLimit: this.urlLengthLimit
15469
+ urlLengthLimit: this.urlLengthLimit,
15470
+ retry: this.retry
15350
15471
  });
15351
15472
  }
15352
15473
  };
15353
15474
  var init_dist = __esm(() => {
15475
+ RETRYABLE_STATUS_CODES = [520, 503];
15476
+ RETRYABLE_METHODS = [
15477
+ "GET",
15478
+ "HEAD",
15479
+ "OPTIONS"
15480
+ ];
15354
15481
  PostgrestError = class extends Error {
15355
15482
  constructor(context) {
15356
15483
  super(context.message);
@@ -15359,6 +15486,15 @@ var init_dist = __esm(() => {
15359
15486
  this.hint = context.hint;
15360
15487
  this.code = context.code;
15361
15488
  }
15489
+ toJSON() {
15490
+ return {
15491
+ name: this.name,
15492
+ message: this.message,
15493
+ details: this.details,
15494
+ hint: this.hint,
15495
+ code: this.code
15496
+ };
15497
+ }
15362
15498
  };
15363
15499
  PostgrestTransformBuilder = class extends PostgrestBuilder {
15364
15500
  select(columns) {
@@ -15606,7 +15742,7 @@ var init_dist = __esm(() => {
15606
15742
  };
15607
15743
  });
15608
15744
 
15609
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js
15745
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js
15610
15746
  var require_websocket_factory = __commonJS((exports) => {
15611
15747
  Object.defineProperty(exports, "__esModule", { value: true });
15612
15748
  exports.WebSocketFactory = undefined;
@@ -15695,14 +15831,14 @@ Suggested solution: ${env.workaround}`;
15695
15831
  exports.default = WebSocketFactory;
15696
15832
  });
15697
15833
 
15698
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/lib/version.js
15834
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/lib/version.js
15699
15835
  var require_version = __commonJS((exports) => {
15700
15836
  Object.defineProperty(exports, "__esModule", { value: true });
15701
15837
  exports.version = undefined;
15702
- exports.version = "2.100.1";
15838
+ exports.version = "2.105.1";
15703
15839
  });
15704
15840
 
15705
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/lib/constants.js
15841
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/lib/constants.js
15706
15842
  var require_constants = __commonJS((exports) => {
15707
15843
  Object.defineProperty(exports, "__esModule", { value: true });
15708
15844
  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;
@@ -15747,7 +15883,7 @@ var require_constants = __commonJS((exports) => {
15747
15883
  };
15748
15884
  });
15749
15885
 
15750
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js
15886
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js
15751
15887
  var require_serializer = __commonJS((exports) => {
15752
15888
  Object.defineProperty(exports, "__esModule", { value: true });
15753
15889
 
@@ -15892,7 +16028,7 @@ var require_serializer = __commonJS((exports) => {
15892
16028
  exports.default = Serializer;
15893
16029
  });
15894
16030
 
15895
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js
16031
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js
15896
16032
  var require_transformers = __commonJS((exports) => {
15897
16033
  Object.defineProperty(exports, "__esModule", { value: true });
15898
16034
  exports.httpEndpointURL = exports.toTimestampString = exports.toArray = exports.toJson = exports.toNumber = exports.toBoolean = exports.convertCell = exports.convertColumn = exports.convertChangeData = exports.PostgresTypes = undefined;
@@ -16061,7 +16197,7 @@ var require_transformers = __commonJS((exports) => {
16061
16197
  exports.httpEndpointURL = httpEndpointURL;
16062
16198
  });
16063
16199
 
16064
- // node_modules/.bun/@supabase+phoenix@0.4.0/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js
16200
+ // node_modules/.bun/@supabase+phoenix@0.4.1/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js
16065
16201
  var require_phoenix_cjs = __commonJS((exports, module) => {
16066
16202
  var __defProp2 = Object.defineProperty;
16067
16203
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -17219,7 +17355,7 @@ var require_phoenix_cjs = __commonJS((exports, module) => {
17219
17355
  } catch (e) {
17220
17356
  this.log("error", "error in heartbeat callback", e);
17221
17357
  }
17222
- this.triggerChanError();
17358
+ this.triggerChanError(new Error("heartbeat timeout"));
17223
17359
  this.closeWasClean = false;
17224
17360
  this.teardown(() => this.reconnectTimer.scheduleTimeout(), WS_CLOSE_NORMAL, "heartbeat timeout");
17225
17361
  }
@@ -17278,7 +17414,7 @@ var require_phoenix_cjs = __commonJS((exports, module) => {
17278
17414
  this.conn.onclose = () => {};
17279
17415
  if (this.hasLogger())
17280
17416
  this.log("transport", "close", event);
17281
- this.triggerChanError();
17417
+ this.triggerChanError(event);
17282
17418
  this.clearHeartbeats();
17283
17419
  if (!this.closeWasClean) {
17284
17420
  this.reconnectTimer.scheduleTimeout();
@@ -17287,18 +17423,18 @@ var require_phoenix_cjs = __commonJS((exports, module) => {
17287
17423
  }
17288
17424
  onConnError(error48) {
17289
17425
  if (this.hasLogger())
17290
- this.log("transport", error48);
17426
+ this.log("transport", "error", error48);
17291
17427
  let transportBefore = this.transport;
17292
17428
  let establishedBefore = this.establishedConnections;
17293
17429
  this.triggerStateCallbacks("error", error48, transportBefore, establishedBefore);
17294
17430
  if (transportBefore === this.transport || establishedBefore > 0) {
17295
- this.triggerChanError();
17431
+ this.triggerChanError(error48);
17296
17432
  }
17297
17433
  }
17298
- triggerChanError() {
17434
+ triggerChanError(reason) {
17299
17435
  this.channels.forEach((channel) => {
17300
17436
  if (!(channel.isErrored() || channel.isLeaving() || channel.isClosed())) {
17301
- channel.trigger(CHANNEL_EVENTS.error);
17437
+ channel.trigger(CHANNEL_EVENTS.error, reason);
17302
17438
  }
17303
17439
  });
17304
17440
  }
@@ -17435,7 +17571,7 @@ var require_phoenix_cjs = __commonJS((exports, module) => {
17435
17571
  };
17436
17572
  });
17437
17573
 
17438
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js
17574
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js
17439
17575
  var require_presenceAdapter = __commonJS((exports) => {
17440
17576
  Object.defineProperty(exports, "__esModule", { value: true });
17441
17577
  var phoenix_1 = require_phoenix_cjs();
@@ -17508,7 +17644,7 @@ var require_presenceAdapter = __commonJS((exports) => {
17508
17644
  }
17509
17645
  });
17510
17646
 
17511
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js
17647
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js
17512
17648
  var require_RealtimePresence = __commonJS((exports) => {
17513
17649
  Object.defineProperty(exports, "__esModule", { value: true });
17514
17650
  exports.REALTIME_PRESENCE_LISTEN_EVENTS = undefined;
@@ -17533,7 +17669,30 @@ var require_RealtimePresence = __commonJS((exports) => {
17533
17669
  exports.default = RealtimePresence;
17534
17670
  });
17535
17671
 
17536
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js
17672
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js
17673
+ var require_normalizeChannelError = __commonJS((exports) => {
17674
+ Object.defineProperty(exports, "__esModule", { value: true });
17675
+ exports.normalizeChannelError = normalizeChannelError;
17676
+ function normalizeChannelError(reason) {
17677
+ if (reason instanceof Error) {
17678
+ return reason;
17679
+ }
17680
+ if (typeof reason === "string") {
17681
+ return new Error(reason);
17682
+ }
17683
+ if (reason && typeof reason === "object") {
17684
+ const obj = reason;
17685
+ if (typeof obj.code === "number") {
17686
+ const detail = typeof obj.reason === "string" && obj.reason ? ` (${obj.reason})` : "";
17687
+ return new Error(`socket closed: ${obj.code}${detail}`, { cause: reason });
17688
+ }
17689
+ return new Error("channel error: transport failure", { cause: reason });
17690
+ }
17691
+ return new Error("channel error: connection lost");
17692
+ }
17693
+ });
17694
+
17695
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js
17537
17696
  var require_channelAdapter = __commonJS((exports) => {
17538
17697
  Object.defineProperty(exports, "__esModule", { value: true });
17539
17698
  var constants_1 = require_constants();
@@ -17585,7 +17744,7 @@ var require_channelAdapter = __commonJS((exports) => {
17585
17744
  try {
17586
17745
  push = this.channel.push(event, payload, timeout);
17587
17746
  } catch (error48) {
17588
- throw `tried to push '${event}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`;
17747
+ throw new Error(`tried to push '${event}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`);
17589
17748
  }
17590
17749
  if (this.channel.pushBuffer.length > constants_1.MAX_PUSH_BUFFER_SIZE) {
17591
17750
  const removedPush = this.channel.pushBuffer.shift();
@@ -17635,7 +17794,7 @@ var require_channelAdapter = __commonJS((exports) => {
17635
17794
  }
17636
17795
  });
17637
17796
 
17638
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js
17797
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js
17639
17798
  var require_RealtimeChannel = __commonJS((exports) => {
17640
17799
  Object.defineProperty(exports, "__esModule", { value: true });
17641
17800
  exports.REALTIME_CHANNEL_STATES = exports.REALTIME_SUBSCRIBE_STATES = exports.REALTIME_LISTEN_TYPES = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = undefined;
@@ -17644,6 +17803,7 @@ var require_RealtimeChannel = __commonJS((exports) => {
17644
17803
  var RealtimePresence_1 = tslib_1.__importDefault(require_RealtimePresence());
17645
17804
  var Transformers = tslib_1.__importStar(require_transformers());
17646
17805
  var transformers_1 = require_transformers();
17806
+ var normalizeChannelError_1 = require_normalizeChannelError();
17647
17807
  var channelAdapter_1 = tslib_1.__importDefault(require_channelAdapter());
17648
17808
  var REALTIME_POSTGRES_CHANGES_LISTEN_EVENT;
17649
17809
  (function(REALTIME_POSTGRES_CHANGES_LISTEN_EVENT2) {
@@ -17708,7 +17868,7 @@ var require_RealtimeChannel = __commonJS((exports) => {
17708
17868
  this.broadcastEndpointURL = (0, transformers_1.httpEndpointURL)(this.socket.socketAdapter.endPointURL());
17709
17869
  this.private = this.params.config.private || false;
17710
17870
  if (!this.private && ((_b = (_a2 = this.params.config) === null || _a2 === undefined ? undefined : _a2.broadcast) === null || _b === undefined ? undefined : _b.replay)) {
17711
- throw `tried to use replay on public channel '${this.topic}'. It must be a private channel.`;
17871
+ throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`);
17712
17872
  }
17713
17873
  }
17714
17874
  subscribe(callback, timeout = this.timeout) {
@@ -17731,7 +17891,7 @@ var require_RealtimeChannel = __commonJS((exports) => {
17731
17891
  accessTokenPayload.access_token = this.socket.accessTokenValue;
17732
17892
  }
17733
17893
  this._onError((reason) => {
17734
- callback === null || callback === undefined || callback(REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR, reason);
17894
+ callback === null || callback === undefined || callback(REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR, (0, normalizeChannelError_1.normalizeChannelError)(reason));
17735
17895
  });
17736
17896
  this._onClose(() => callback === null || callback === undefined ? undefined : callback(REALTIME_SUBSCRIBE_STATES.CLOSED));
17737
17897
  this.updateJoinPayload(Object.assign({ config: config2 }, accessTokenPayload));
@@ -17747,7 +17907,8 @@ var require_RealtimeChannel = __commonJS((exports) => {
17747
17907
  this._updatePostgresBindings(postgres_changes2, callback);
17748
17908
  }).receive("error", (error48) => {
17749
17909
  this.state = constants_1.CHANNEL_STATES.errored;
17750
- callback === null || callback === undefined || callback(REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR, new Error(JSON.stringify(Object.values(error48).join(", ") || "error")));
17910
+ const message = Object.values(error48).join(", ") || "error";
17911
+ callback === null || callback === undefined || callback(REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR, new Error(message, { cause: error48 }));
17751
17912
  }).receive("timeout", () => {
17752
17913
  callback === null || callback === undefined || callback(REALTIME_SUBSCRIBE_STATES.TIMED_OUT);
17753
17914
  });
@@ -17794,16 +17955,18 @@ var require_RealtimeChannel = __commonJS((exports) => {
17794
17955
  }, opts);
17795
17956
  }
17796
17957
  on(type, filter, callback) {
17797
- if (this.channelAdapter.isJoined() && type === REALTIME_LISTEN_TYPES.PRESENCE) {
17798
- this.socket.log("channel", `cannot add presence callbacks for ${this.topic} after joining.`);
17799
- throw new Error("cannot add presence callbacks after joining a channel");
17958
+ const stateCheck = this.channelAdapter.isJoined() || this.channelAdapter.isJoining();
17959
+ const typeCheck = type === REALTIME_LISTEN_TYPES.PRESENCE || type === REALTIME_LISTEN_TYPES.POSTGRES_CHANGES;
17960
+ if (stateCheck && typeCheck) {
17961
+ this.socket.log("channel", `cannot add \`${type}\` callbacks for ${this.topic} after \`subscribe()\`.`);
17962
+ throw new Error(`cannot add \`${type}\` callbacks for ${this.topic} after \`subscribe()\`.`);
17800
17963
  }
17801
17964
  return this._on(type, filter, callback);
17802
17965
  }
17803
17966
  async httpSend(event, payload, opts = {}) {
17804
17967
  var _a2;
17805
17968
  if (payload === undefined || payload === null) {
17806
- return Promise.reject("Payload is required for httpSend()");
17969
+ return Promise.reject(new Error("Payload is required for httpSend()"));
17807
17970
  }
17808
17971
  const headers = {
17809
17972
  apikey: this.socket.apiKey ? this.socket.apiKey : "",
@@ -17977,6 +18140,16 @@ var require_RealtimeChannel = __commonJS((exports) => {
17977
18140
  return payload;
17978
18141
  });
17979
18142
  }
18143
+ copyBindings(other) {
18144
+ if (this.joinedOnce) {
18145
+ throw new Error("cannot copy bindings into joined channel");
18146
+ }
18147
+ for (const kind in other.bindings) {
18148
+ for (const binding of other.bindings[kind]) {
18149
+ this._on(binding.type, binding.filter, binding.callback);
18150
+ }
18151
+ }
18152
+ }
17980
18153
  static isFilterValueEqual(serverValue, clientValue) {
17981
18154
  const normalizedServer = serverValue !== null && serverValue !== undefined ? serverValue : undefined;
17982
18155
  const normalizedClient = clientValue !== null && clientValue !== undefined ? clientValue : undefined;
@@ -17999,7 +18172,7 @@ var require_RealtimeChannel = __commonJS((exports) => {
17999
18172
  exports.default = RealtimeChannel;
18000
18173
  });
18001
18174
 
18002
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js
18175
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js
18003
18176
  var require_socketAdapter = __commonJS((exports) => {
18004
18177
  Object.defineProperty(exports, "__esModule", { value: true });
18005
18178
  var phoenix_1 = require_phoenix_cjs();
@@ -18112,7 +18285,7 @@ var require_socketAdapter = __commonJS((exports) => {
18112
18285
  exports.default = SocketAdapter;
18113
18286
  });
18114
18287
 
18115
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js
18288
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js
18116
18289
  var require_RealtimeClient = __commonJS((exports) => {
18117
18290
  Object.defineProperty(exports, "__esModule", { value: true });
18118
18291
  var tslib_1 = require_tslib();
@@ -18200,6 +18373,8 @@ var require_RealtimeClient = __commonJS((exports) => {
18200
18373
  this._authPromise = null;
18201
18374
  this._workerHeartbeatTimer = undefined;
18202
18375
  this._pendingWorkerHeartbeatRef = null;
18376
+ this._pendingDisconnectTimer = null;
18377
+ this._disconnectOnEmptyChannelsAfterMs = 0;
18203
18378
  this._resolveFetch = (customFetch) => {
18204
18379
  if (customFetch) {
18205
18380
  return (...args) => customFetch(...args);
@@ -18251,6 +18426,7 @@ var require_RealtimeClient = __commonJS((exports) => {
18251
18426
  return this.socketAdapter.endPointURL();
18252
18427
  }
18253
18428
  async disconnect(code, reason) {
18429
+ this._cancelPendingDisconnect();
18254
18430
  if (this.isDisconnecting()) {
18255
18431
  return "ok";
18256
18432
  }
@@ -18267,9 +18443,6 @@ var require_RealtimeClient = __commonJS((exports) => {
18267
18443
  if (status === "ok") {
18268
18444
  channel.teardown();
18269
18445
  }
18270
- if (this.channels.length === 0) {
18271
- this.disconnect();
18272
- }
18273
18446
  return status;
18274
18447
  }
18275
18448
  async removeAllChannels() {
@@ -18279,7 +18452,7 @@ var require_RealtimeClient = __commonJS((exports) => {
18279
18452
  return result2;
18280
18453
  });
18281
18454
  const result = await Promise.all(promises);
18282
- this.disconnect();
18455
+ await this.disconnect();
18283
18456
  return result;
18284
18457
  }
18285
18458
  log(kind, msg, data) {
@@ -18302,6 +18475,7 @@ var require_RealtimeClient = __commonJS((exports) => {
18302
18475
  const exists = this.getChannels().find((c) => c.topic === realtimeTopic);
18303
18476
  if (!exists) {
18304
18477
  const chan = new RealtimeChannel_1.default(`realtime:${topic}`, params, this);
18478
+ this._cancelPendingDisconnect();
18305
18479
  this.channels.push(chan);
18306
18480
  return chan;
18307
18481
  } else {
@@ -18333,6 +18507,33 @@ var require_RealtimeClient = __commonJS((exports) => {
18333
18507
  }
18334
18508
  _remove(channel) {
18335
18509
  this.channels = this.channels.filter((c) => c.topic !== channel.topic);
18510
+ if (this.channels.length === 0) {
18511
+ this.log("transport", "no channels remaining, scheduling disconnect");
18512
+ this._schedulePendingDisconnect();
18513
+ }
18514
+ }
18515
+ _schedulePendingDisconnect() {
18516
+ this._cancelPendingDisconnect();
18517
+ if (this._disconnectOnEmptyChannelsAfterMs === 0) {
18518
+ this.log("transport", "disconnecting immediately - no channels");
18519
+ this.disconnect();
18520
+ return;
18521
+ }
18522
+ this._pendingDisconnectTimer = setTimeout(() => {
18523
+ this._pendingDisconnectTimer = null;
18524
+ if (this.channels.length === 0) {
18525
+ this.log("transport", "deferred disconnect fired - no channels, disconnecting");
18526
+ this.disconnect();
18527
+ }
18528
+ }, this._disconnectOnEmptyChannelsAfterMs);
18529
+ this.log("transport", `deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`);
18530
+ }
18531
+ _cancelPendingDisconnect() {
18532
+ if (this._pendingDisconnectTimer !== null) {
18533
+ this.log("transport", "pending disconnect cancelled - channel activity detected");
18534
+ clearTimeout(this._pendingDisconnectTimer);
18535
+ this._pendingDisconnectTimer = null;
18536
+ }
18336
18537
  }
18337
18538
  async _performAuth(token = null) {
18338
18539
  let tokenToSend;
@@ -18458,22 +18659,23 @@ var require_RealtimeClient = __commonJS((exports) => {
18458
18659
  return result_url;
18459
18660
  }
18460
18661
  _initializeOptions(options) {
18461
- var _a2, _b, _c, _d, _e, _f, _g, _h, _j;
18662
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
18462
18663
  this.worker = (_a2 = options === null || options === undefined ? undefined : options.worker) !== null && _a2 !== undefined ? _a2 : false;
18463
18664
  this.accessToken = (_b = options === null || options === undefined ? undefined : options.accessToken) !== null && _b !== undefined ? _b : null;
18464
18665
  const result = {};
18465
18666
  result.timeout = (_c = options === null || options === undefined ? undefined : options.timeout) !== null && _c !== undefined ? _c : constants_1.DEFAULT_TIMEOUT;
18466
18667
  result.heartbeatIntervalMs = (_d = options === null || options === undefined ? undefined : options.heartbeatIntervalMs) !== null && _d !== undefined ? _d : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL;
18467
- result.transport = (_e = options === null || options === undefined ? undefined : options.transport) !== null && _e !== undefined ? _e : websocket_factory_1.default.getWebSocketConstructor();
18668
+ this._disconnectOnEmptyChannelsAfterMs = (_e = options === null || options === undefined ? undefined : options.disconnectOnEmptyChannelsAfterMs) !== null && _e !== undefined ? _e : 2 * ((_f = options === null || options === undefined ? undefined : options.heartbeatIntervalMs) !== null && _f !== undefined ? _f : CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL);
18669
+ result.transport = (_g = options === null || options === undefined ? undefined : options.transport) !== null && _g !== undefined ? _g : websocket_factory_1.default.getWebSocketConstructor();
18468
18670
  result.params = options === null || options === undefined ? undefined : options.params;
18469
18671
  result.logger = options === null || options === undefined ? undefined : options.logger;
18470
18672
  result.heartbeatCallback = this._wrapHeartbeatCallback(options === null || options === undefined ? undefined : options.heartbeatCallback);
18471
- result.reconnectAfterMs = (_f = options === null || options === undefined ? undefined : options.reconnectAfterMs) !== null && _f !== undefined ? _f : (tries) => {
18673
+ result.reconnectAfterMs = (_h = options === null || options === undefined ? undefined : options.reconnectAfterMs) !== null && _h !== undefined ? _h : (tries) => {
18472
18674
  return RECONNECT_INTERVALS[tries - 1] || DEFAULT_RECONNECT_FALLBACK;
18473
18675
  };
18474
18676
  let defaultEncode;
18475
18677
  let defaultDecode;
18476
- const vsn = (_g = options === null || options === undefined ? undefined : options.vsn) !== null && _g !== undefined ? _g : constants_1.DEFAULT_VSN;
18678
+ const vsn = (_j = options === null || options === undefined ? undefined : options.vsn) !== null && _j !== undefined ? _j : constants_1.DEFAULT_VSN;
18477
18679
  switch (vsn) {
18478
18680
  case constants_1.VSN_1_0_0:
18479
18681
  defaultEncode = (payload, callback) => {
@@ -18491,8 +18693,8 @@ var require_RealtimeClient = __commonJS((exports) => {
18491
18693
  throw new Error(`Unsupported serializer version: ${result.vsn}`);
18492
18694
  }
18493
18695
  result.vsn = vsn;
18494
- result.encode = (_h = options === null || options === undefined ? undefined : options.encode) !== null && _h !== undefined ? _h : defaultEncode;
18495
- result.decode = (_j = options === null || options === undefined ? undefined : options.decode) !== null && _j !== undefined ? _j : defaultDecode;
18696
+ result.encode = (_k = options === null || options === undefined ? undefined : options.encode) !== null && _k !== undefined ? _k : defaultEncode;
18697
+ result.decode = (_l = options === null || options === undefined ? undefined : options.decode) !== null && _l !== undefined ? _l : defaultDecode;
18496
18698
  result.beforeReconnect = this._reconnectAuth.bind(this);
18497
18699
  if ((options === null || options === undefined ? undefined : options.logLevel) || (options === null || options === undefined ? undefined : options.log_level)) {
18498
18700
  this.logLevel = options.logLevel || options.log_level;
@@ -18517,7 +18719,7 @@ var require_RealtimeClient = __commonJS((exports) => {
18517
18719
  exports.default = RealtimeClient;
18518
18720
  });
18519
18721
 
18520
- // node_modules/.bun/@supabase+realtime-js@2.100.1/node_modules/@supabase/realtime-js/dist/main/index.js
18722
+ // node_modules/.bun/@supabase+realtime-js@2.105.1/node_modules/@supabase/realtime-js/dist/main/index.js
18521
18723
  var require_main2 = __commonJS((exports) => {
18522
18724
  Object.defineProperty(exports, "__esModule", { value: true });
18523
18725
  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;
@@ -18847,10 +19049,7 @@ var init_dist2 = __esm(() => {
18847
19049
  };
18848
19050
  });
18849
19051
 
18850
- // node_modules/.bun/@supabase+storage-js@2.100.1/node_modules/@supabase/storage-js/dist/index.mjs
18851
- function isStorageError(error48) {
18852
- return typeof error48 === "object" && error48 !== null && "__isStorageError" in error48;
18853
- }
19052
+ // node_modules/.bun/@supabase+storage-js@2.105.1/node_modules/@supabase/storage-js/dist/index.mjs
18854
19053
  function _typeof2(o) {
18855
19054
  "@babel/helpers - typeof";
18856
19055
  return _typeof2 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o$1) {
@@ -18904,6 +19103,24 @@ function _objectSpread22(e) {
18904
19103
  }
18905
19104
  return e;
18906
19105
  }
19106
+ function isStorageError(error48) {
19107
+ return typeof error48 === "object" && error48 !== null && "__isStorageError" in error48;
19108
+ }
19109
+ function setHeader(headers, name, value) {
19110
+ const result = _objectSpread22({}, headers);
19111
+ const nameLower = name.toLowerCase();
19112
+ for (const key of Object.keys(result))
19113
+ if (key.toLowerCase() === nameLower)
19114
+ delete result[key];
19115
+ result[nameLower] = value;
19116
+ return result;
19117
+ }
19118
+ function normalizeHeaders(headers) {
19119
+ const result = {};
19120
+ for (const [key, value] of Object.entries(headers))
19121
+ result[key.toLowerCase()] = value;
19122
+ return result;
19123
+ }
18907
19124
  async function _handleRequest(fetcher, method, url2, options, parameters, body, namespace) {
18908
19125
  return new Promise((resolve, reject) => {
18909
19126
  fetcher(url2, _getRequestParams(method, options, parameters, body)).then((result) => {
@@ -18997,7 +19214,13 @@ var StorageError, StorageApiError, StorageUnknownError, resolveFetch = (customFe
18997
19214
  if (method === "GET" || method === "HEAD" || !body)
18998
19215
  return _objectSpread22(_objectSpread22({}, params), parameters);
18999
19216
  if (isPlainObject2(body)) {
19000
- params.headers = _objectSpread22({ "Content-Type": "application/json" }, options === null || options === undefined ? undefined : options.headers);
19217
+ var _contentType;
19218
+ const headers = (options === null || options === undefined ? undefined : options.headers) || {};
19219
+ let contentType;
19220
+ for (const [key, value] of Object.entries(headers))
19221
+ if (key.toLowerCase() === "content-type")
19222
+ contentType = value;
19223
+ params.headers = setHeader(headers, "Content-Type", (_contentType = contentType) !== null && _contentType !== undefined ? _contentType : "application/json");
19001
19224
  params.body = JSON.stringify(body);
19002
19225
  } else
19003
19226
  params.body = body;
@@ -19008,7 +19231,7 @@ var StorageError, StorageApiError, StorageUnknownError, resolveFetch = (customFe
19008
19231
  constructor(url2, headers = {}, fetch$1, namespace = "storage") {
19009
19232
  this.shouldThrowOnError = false;
19010
19233
  this.url = url2;
19011
- this.headers = headers;
19234
+ this.headers = normalizeHeaders(headers);
19012
19235
  this.fetch = resolveFetch(fetch$1);
19013
19236
  this.namespace = namespace;
19014
19237
  }
@@ -19017,7 +19240,7 @@ var StorageError, StorageApiError, StorageUnknownError, resolveFetch = (customFe
19017
19240
  return this;
19018
19241
  }
19019
19242
  setHeader(name, value) {
19020
- this.headers = _objectSpread22(_objectSpread22({}, this.headers), {}, { [name]: value });
19243
+ this.headers = setHeader(this.headers, name, value);
19021
19244
  return this;
19022
19245
  }
19023
19246
  async handleOperation(operation) {
@@ -19106,7 +19329,7 @@ var StorageError, StorageApiError, StorageUnknownError, resolveFetch = (customFe
19106
19329
  throw error48;
19107
19330
  }
19108
19331
  }
19109
- }, DEFAULT_SEARCH_OPTIONS, DEFAULT_FILE_OPTIONS, StorageFileApi, version2 = "2.100.1", DEFAULT_HEADERS, StorageBucketApi, StorageAnalyticsClient, VectorIndexApi, VectorDataApi, VectorBucketApi, StorageVectorsClient, VectorBucketScope, VectorIndexScope, StorageClient;
19332
+ }, DEFAULT_SEARCH_OPTIONS, DEFAULT_FILE_OPTIONS, StorageFileApi, version2 = "2.105.1", DEFAULT_HEADERS, StorageBucketApi, StorageAnalyticsClient, VectorIndexApi, VectorDataApi, VectorBucketApi, StorageVectorsClient, VectorBucketScope, VectorIndexScope, StorageClient;
19110
19333
  var init_dist3 = __esm(() => {
19111
19334
  init_dist2();
19112
19335
  StorageError = class extends Error {
@@ -19118,6 +19341,14 @@ var init_dist3 = __esm(() => {
19118
19341
  this.status = status;
19119
19342
  this.statusCode = statusCode;
19120
19343
  }
19344
+ toJSON() {
19345
+ return {
19346
+ name: this.name,
19347
+ message: this.message,
19348
+ status: this.status,
19349
+ statusCode: this.statusCode
19350
+ };
19351
+ }
19121
19352
  };
19122
19353
  StorageApiError = class extends StorageError {
19123
19354
  constructor(message, status, statusCode, namespace = "storage") {
@@ -19127,12 +19358,7 @@ var init_dist3 = __esm(() => {
19127
19358
  this.statusCode = statusCode;
19128
19359
  }
19129
19360
  toJSON() {
19130
- return {
19131
- name: this.name,
19132
- message: this.message,
19133
- status: this.status,
19134
- statusCode: this.statusCode
19135
- };
19361
+ return _objectSpread22({}, super.toJSON());
19136
19362
  }
19137
19363
  };
19138
19364
  StorageUnknownError = class extends StorageError {
@@ -19193,7 +19419,8 @@ var init_dist3 = __esm(() => {
19193
19419
  options.duplex = "half";
19194
19420
  }
19195
19421
  if (fileOptions === null || fileOptions === undefined ? undefined : fileOptions.headers)
19196
- headers = _objectSpread22(_objectSpread22({}, headers), fileOptions.headers);
19422
+ for (const [key, value] of Object.entries(fileOptions.headers))
19423
+ headers = setHeader(headers, key, value);
19197
19424
  const cleanPath = _this._removeEmptyFolders(path);
19198
19425
  const _path = _this._getFinalPath(cleanPath);
19199
19426
  const data = await (method == "PUT" ? put : post)(_this.fetch, `${_this.url}/object/${_path}`, body, _objectSpread22({ headers }, (options === null || options === undefined ? undefined : options.duplex) ? { duplex: options.duplex } : {}));
@@ -19216,22 +19443,35 @@ var init_dist3 = __esm(() => {
19216
19443
  return _this3.handleOperation(async () => {
19217
19444
  let body;
19218
19445
  const options = _objectSpread22(_objectSpread22({}, DEFAULT_FILE_OPTIONS), fileOptions);
19219
- const headers = _objectSpread22(_objectSpread22({}, _this3.headers), { "x-upsert": String(options.upsert) });
19446
+ let headers = _objectSpread22(_objectSpread22({}, _this3.headers), { "x-upsert": String(options.upsert) });
19447
+ const metadata = options.metadata;
19220
19448
  if (typeof Blob !== "undefined" && fileBody instanceof Blob) {
19221
19449
  body = new FormData;
19222
19450
  body.append("cacheControl", options.cacheControl);
19451
+ if (metadata)
19452
+ body.append("metadata", _this3.encodeMetadata(metadata));
19223
19453
  body.append("", fileBody);
19224
19454
  } else if (typeof FormData !== "undefined" && fileBody instanceof FormData) {
19225
19455
  body = fileBody;
19226
- body.append("cacheControl", options.cacheControl);
19456
+ if (!body.has("cacheControl"))
19457
+ body.append("cacheControl", options.cacheControl);
19458
+ if (metadata && !body.has("metadata"))
19459
+ body.append("metadata", _this3.encodeMetadata(metadata));
19227
19460
  } else {
19228
19461
  body = fileBody;
19229
19462
  headers["cache-control"] = `max-age=${options.cacheControl}`;
19230
19463
  headers["content-type"] = options.contentType;
19464
+ if (metadata)
19465
+ headers["x-metadata"] = _this3.toBase64(_this3.encodeMetadata(metadata));
19466
+ if ((typeof ReadableStream !== "undefined" && body instanceof ReadableStream || body && typeof body === "object" && ("pipe" in body) && typeof body.pipe === "function") && !options.duplex)
19467
+ options.duplex = "half";
19231
19468
  }
19469
+ if (fileOptions === null || fileOptions === undefined ? undefined : fileOptions.headers)
19470
+ for (const [key, value] of Object.entries(fileOptions.headers))
19471
+ headers = setHeader(headers, key, value);
19232
19472
  return {
19233
19473
  path: cleanPath,
19234
- fullPath: (await put(_this3.fetch, url2.toString(), body, { headers })).Key
19474
+ fullPath: (await put(_this3.fetch, url2.toString(), body, _objectSpread22({ headers }, (options === null || options === undefined ? undefined : options.duplex) ? { duplex: options.duplex } : {}))).Key
19235
19475
  };
19236
19476
  });
19237
19477
  }
@@ -19285,9 +19525,13 @@ var init_dist3 = __esm(() => {
19285
19525
  let _path = _this8._getFinalPath(path);
19286
19526
  const hasTransform = typeof (options === null || options === undefined ? undefined : options.transform) === "object" && options.transform !== null && Object.keys(options.transform).length > 0;
19287
19527
  let data = await post(_this8.fetch, `${_this8.url}/object/sign/${_path}`, _objectSpread22({ expiresIn }, hasTransform ? { transform: options.transform } : {}), { headers: _this8.headers });
19288
- const downloadQueryParam = (options === null || options === undefined ? undefined : options.download) ? `&download=${options.download === true ? "" : options.download}` : "";
19289
- const returnedPath = hasTransform && data.signedURL.includes("/object/sign/") ? data.signedURL.replace("/object/sign/", "/render/image/sign/") : data.signedURL;
19290
- return { signedUrl: encodeURI(`${_this8.url}${returnedPath}${downloadQueryParam}`) };
19528
+ const query = new URLSearchParams;
19529
+ if (options === null || options === undefined ? undefined : options.download)
19530
+ query.set("download", options.download === true ? "" : options.download);
19531
+ if ((options === null || options === undefined ? undefined : options.cacheNonce) != null)
19532
+ query.set("cacheNonce", String(options.cacheNonce));
19533
+ const queryString = query.toString();
19534
+ return { signedUrl: encodeURI(`${_this8.url}${data.signedURL}${queryString ? `&${queryString}` : ""}`) };
19291
19535
  });
19292
19536
  }
19293
19537
  async createSignedUrls(paths, expiresIn, options) {
@@ -19297,16 +19541,25 @@ var init_dist3 = __esm(() => {
19297
19541
  expiresIn,
19298
19542
  paths
19299
19543
  }, { headers: _this9.headers });
19300
- const downloadQueryParam = (options === null || options === undefined ? undefined : options.download) ? `&download=${options.download === true ? "" : options.download}` : "";
19301
- return data.map((datum) => _objectSpread22(_objectSpread22({}, datum), {}, { signedUrl: datum.signedURL ? encodeURI(`${_this9.url}${datum.signedURL}${downloadQueryParam}`) : null }));
19544
+ const query = new URLSearchParams;
19545
+ if (options === null || options === undefined ? undefined : options.download)
19546
+ query.set("download", options.download === true ? "" : options.download);
19547
+ if ((options === null || options === undefined ? undefined : options.cacheNonce) != null)
19548
+ query.set("cacheNonce", String(options.cacheNonce));
19549
+ const queryString = query.toString();
19550
+ return data.map((datum) => _objectSpread22(_objectSpread22({}, datum), {}, { signedUrl: datum.signedURL ? encodeURI(`${_this9.url}${datum.signedURL}${queryString ? `&${queryString}` : ""}`) : null }));
19302
19551
  });
19303
19552
  }
19304
19553
  download(path, options, parameters) {
19305
- const renderPath = typeof (options === null || options === undefined ? undefined : options.transform) !== "undefined" ? "render/image/authenticated" : "object";
19306
- const transformationQuery = this.transformOptsToQueryString((options === null || options === undefined ? undefined : options.transform) || {});
19307
- const queryString = transformationQuery ? `?${transformationQuery}` : "";
19554
+ const renderPath = typeof (options === null || options === undefined ? undefined : options.transform) === "object" && options.transform !== null && Object.keys(options.transform).length > 0 ? "render/image/authenticated" : "object";
19555
+ const query = new URLSearchParams;
19556
+ if (options === null || options === undefined ? undefined : options.transform)
19557
+ this.applyTransformOptsToQuery(query, options.transform);
19558
+ if ((options === null || options === undefined ? undefined : options.cacheNonce) != null)
19559
+ query.set("cacheNonce", String(options.cacheNonce));
19560
+ const queryString = query.toString();
19308
19561
  const _path = this._getFinalPath(path);
19309
- const downloadFn = () => get(this.fetch, `${this.url}/${renderPath}/${_path}${queryString}`, {
19562
+ const downloadFn = () => get(this.fetch, `${this.url}/${renderPath}/${_path}${queryString ? `?${queryString}` : ""}`, {
19310
19563
  headers: this.headers,
19311
19564
  noResolveJson: true
19312
19565
  }, parameters);
@@ -19345,18 +19598,16 @@ var init_dist3 = __esm(() => {
19345
19598
  }
19346
19599
  getPublicUrl(path, options) {
19347
19600
  const _path = this._getFinalPath(path);
19348
- const _queryString = [];
19349
- const downloadQueryParam = (options === null || options === undefined ? undefined : options.download) ? `download=${options.download === true ? "" : options.download}` : "";
19350
- if (downloadQueryParam !== "")
19351
- _queryString.push(downloadQueryParam);
19352
- const renderPath = typeof (options === null || options === undefined ? undefined : options.transform) !== "undefined" ? "render/image" : "object";
19353
- const transformationQuery = this.transformOptsToQueryString((options === null || options === undefined ? undefined : options.transform) || {});
19354
- if (transformationQuery !== "")
19355
- _queryString.push(transformationQuery);
19356
- let queryString = _queryString.join("&");
19357
- if (queryString !== "")
19358
- queryString = `?${queryString}`;
19359
- return { data: { publicUrl: encodeURI(`${this.url}/${renderPath}/public/${_path}${queryString}`) } };
19601
+ const query = new URLSearchParams;
19602
+ if (options === null || options === undefined ? undefined : options.download)
19603
+ query.set("download", options.download === true ? "" : options.download);
19604
+ if (options === null || options === undefined ? undefined : options.transform)
19605
+ this.applyTransformOptsToQuery(query, options.transform);
19606
+ if ((options === null || options === undefined ? undefined : options.cacheNonce) != null)
19607
+ query.set("cacheNonce", String(options.cacheNonce));
19608
+ const queryString = query.toString();
19609
+ const renderPath = typeof (options === null || options === undefined ? undefined : options.transform) === "object" && options.transform !== null && Object.keys(options.transform).length > 0 ? "render/image" : "object";
19610
+ return { data: { publicUrl: encodeURI(`${this.url}/${renderPath}/public/${_path}`) + (queryString ? `?${queryString}` : "") } };
19360
19611
  }
19361
19612
  async remove(paths) {
19362
19613
  var _this12 = this;
@@ -19392,19 +19643,18 @@ var init_dist3 = __esm(() => {
19392
19643
  _removeEmptyFolders(path) {
19393
19644
  return path.replace(/^\/|\/$/g, "").replace(/\/+/g, "/");
19394
19645
  }
19395
- transformOptsToQueryString(transform2) {
19396
- const params = [];
19646
+ applyTransformOptsToQuery(query, transform2) {
19397
19647
  if (transform2.width)
19398
- params.push(`width=${transform2.width}`);
19648
+ query.set("width", transform2.width.toString());
19399
19649
  if (transform2.height)
19400
- params.push(`height=${transform2.height}`);
19650
+ query.set("height", transform2.height.toString());
19401
19651
  if (transform2.resize)
19402
- params.push(`resize=${transform2.resize}`);
19652
+ query.set("resize", transform2.resize);
19403
19653
  if (transform2.format)
19404
- params.push(`format=${transform2.format}`);
19654
+ query.set("format", transform2.format);
19405
19655
  if (transform2.quality)
19406
- params.push(`quality=${transform2.quality}`);
19407
- return params.join("&");
19656
+ query.set("quality", transform2.quality.toString());
19657
+ return query;
19408
19658
  }
19409
19659
  };
19410
19660
  DEFAULT_HEADERS = { "X-Client-Info": `storage-js/${version2}` };
@@ -19786,14 +20036,14 @@ var init_dist3 = __esm(() => {
19786
20036
  };
19787
20037
  });
19788
20038
 
19789
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/version.js
20039
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/version.js
19790
20040
  var require_version2 = __commonJS((exports) => {
19791
20041
  Object.defineProperty(exports, "__esModule", { value: true });
19792
20042
  exports.version = undefined;
19793
- exports.version = "2.100.1";
20043
+ exports.version = "2.105.1";
19794
20044
  });
19795
20045
 
19796
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/constants.js
20046
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/constants.js
19797
20047
  var require_constants2 = __commonJS((exports) => {
19798
20048
  Object.defineProperty(exports, "__esModule", { value: true });
19799
20049
  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;
@@ -19820,7 +20070,7 @@ var require_constants2 = __commonJS((exports) => {
19820
20070
  exports.JWKS_TTL = 10 * 60 * 1000;
19821
20071
  });
19822
20072
 
19823
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/errors.js
20073
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/errors.js
19824
20074
  var require_errors = __commonJS((exports) => {
19825
20075
  Object.defineProperty(exports, "__esModule", { value: true });
19826
20076
  exports.AuthInvalidJwtError = exports.AuthWeakPasswordError = exports.AuthRetryableFetchError = exports.AuthPKCECodeVerifierMissingError = exports.AuthPKCEGrantCodeExchangeError = exports.AuthImplicitGrantRedirectError = exports.AuthInvalidCredentialsError = exports.AuthInvalidTokenResponseError = exports.AuthSessionMissingError = exports.CustomAuthError = exports.AuthUnknownError = exports.AuthApiError = exports.AuthError = undefined;
@@ -19840,6 +20090,14 @@ var require_errors = __commonJS((exports) => {
19840
20090
  this.status = status;
19841
20091
  this.code = code;
19842
20092
  }
20093
+ toJSON() {
20094
+ return {
20095
+ name: this.name,
20096
+ message: this.message,
20097
+ status: this.status,
20098
+ code: this.code
20099
+ };
20100
+ }
19843
20101
  }
19844
20102
  exports.AuthError = AuthError;
19845
20103
  function isAuthError(error48) {
@@ -19908,12 +20166,7 @@ var require_errors = __commonJS((exports) => {
19908
20166
  this.details = details;
19909
20167
  }
19910
20168
  toJSON() {
19911
- return {
19912
- name: this.name,
19913
- message: this.message,
19914
- status: this.status,
19915
- details: this.details
19916
- };
20169
+ return Object.assign(Object.assign({}, super.toJSON()), { details: this.details });
19917
20170
  }
19918
20171
  }
19919
20172
  exports.AuthImplicitGrantRedirectError = AuthImplicitGrantRedirectError;
@@ -19928,12 +20181,7 @@ var require_errors = __commonJS((exports) => {
19928
20181
  this.details = details;
19929
20182
  }
19930
20183
  toJSON() {
19931
- return {
19932
- name: this.name,
19933
- message: this.message,
19934
- status: this.status,
19935
- details: this.details
19936
- };
20184
+ return Object.assign(Object.assign({}, super.toJSON()), { details: this.details });
19937
20185
  }
19938
20186
  }
19939
20187
  exports.AuthPKCEGrantCodeExchangeError = AuthPKCEGrantCodeExchangeError;
@@ -19963,6 +20211,9 @@ var require_errors = __commonJS((exports) => {
19963
20211
  super(message, "AuthWeakPasswordError", status, "weak_password");
19964
20212
  this.reasons = reasons;
19965
20213
  }
20214
+ toJSON() {
20215
+ return Object.assign(Object.assign({}, super.toJSON()), { reasons: this.reasons });
20216
+ }
19966
20217
  }
19967
20218
  exports.AuthWeakPasswordError = AuthWeakPasswordError;
19968
20219
  function isAuthWeakPasswordError(error48) {
@@ -19977,7 +20228,7 @@ var require_errors = __commonJS((exports) => {
19977
20228
  exports.AuthInvalidJwtError = AuthInvalidJwtError;
19978
20229
  });
19979
20230
 
19980
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/base64url.js
20231
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/base64url.js
19981
20232
  var require_base64url = __commonJS((exports) => {
19982
20233
  Object.defineProperty(exports, "__esModule", { value: true });
19983
20234
  exports.byteToBase64URL = byteToBase64URL;
@@ -20165,7 +20416,7 @@ var require_base64url = __commonJS((exports) => {
20165
20416
  }
20166
20417
  });
20167
20418
 
20168
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/helpers.js
20419
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/helpers.js
20169
20420
  var require_helpers = __commonJS((exports) => {
20170
20421
  Object.defineProperty(exports, "__esModule", { value: true });
20171
20422
  exports.Deferred = exports.removeItemAsync = exports.getItemAsync = exports.setItemAsync = exports.looksLikeFetchResponse = exports.resolveFetch = exports.supportsLocalStorage = exports.isBrowser = undefined;
@@ -20173,7 +20424,7 @@ var require_helpers = __commonJS((exports) => {
20173
20424
  exports.generateCallbackId = generateCallbackId;
20174
20425
  exports.parseParametersFromURL = parseParametersFromURL;
20175
20426
  exports.decodeJWT = decodeJWT;
20176
- exports.sleep = sleep;
20427
+ exports.sleep = sleep2;
20177
20428
  exports.retryable = retryable;
20178
20429
  exports.generatePKCEVerifier = generatePKCEVerifier;
20179
20430
  exports.generatePKCEChallenge = generatePKCEChallenge;
@@ -20182,6 +20433,7 @@ var require_helpers = __commonJS((exports) => {
20182
20433
  exports.validateExp = validateExp;
20183
20434
  exports.getAlgorithm = getAlgorithm;
20184
20435
  exports.validateUUID = validateUUID;
20436
+ exports.assertPasskeyExperimentalEnabled = assertPasskeyExperimentalEnabled;
20185
20437
  exports.userNotAvailableProxy = userNotAvailableProxy;
20186
20438
  exports.insecureUserWarningProxy = insecureUserWarningProxy;
20187
20439
  exports.deepClone = deepClone;
@@ -20307,7 +20559,7 @@ var require_helpers = __commonJS((exports) => {
20307
20559
  };
20308
20560
  return data;
20309
20561
  }
20310
- async function sleep(time3) {
20562
+ async function sleep2(time3) {
20311
20563
  return await new Promise((accept) => {
20312
20564
  setTimeout(() => accept(null), time3);
20313
20565
  });
@@ -20371,7 +20623,7 @@ var require_helpers = __commonJS((exports) => {
20371
20623
  const codeVerifier = generatePKCEVerifier();
20372
20624
  let storedCodeVerifier = codeVerifier;
20373
20625
  if (isPasswordRecovery) {
20374
- storedCodeVerifier += "/PASSWORD_RECOVERY";
20626
+ storedCodeVerifier += "/recovery";
20375
20627
  }
20376
20628
  await (0, exports.setItemAsync)(storage, `${storageKey}-code-verifier`, storedCodeVerifier);
20377
20629
  const codeChallenge = await generatePKCEChallenge(codeVerifier);
@@ -20426,6 +20678,11 @@ var require_helpers = __commonJS((exports) => {
20426
20678
  throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not");
20427
20679
  }
20428
20680
  }
20681
+ function assertPasskeyExperimentalEnabled(experimental) {
20682
+ if (!experimental.passkey) {
20683
+ throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).");
20684
+ }
20685
+ }
20429
20686
  function userNotAvailableProxy() {
20430
20687
  const proxyTarget = {};
20431
20688
  return new Proxy(proxyTarget, {
@@ -20474,7 +20731,7 @@ var require_helpers = __commonJS((exports) => {
20474
20731
  }
20475
20732
  });
20476
20733
 
20477
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/fetch.js
20734
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/fetch.js
20478
20735
  var require_fetch = __commonJS((exports) => {
20479
20736
  Object.defineProperty(exports, "__esModule", { value: true });
20480
20737
  exports.handleError = handleError2;
@@ -20490,7 +20747,7 @@ var require_fetch = __commonJS((exports) => {
20490
20747
  var helpers_1 = require_helpers();
20491
20748
  var errors_1 = require_errors();
20492
20749
  var _getErrorMessage2 = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
20493
- var NETWORK_ERROR_CODES = [502, 503, 504];
20750
+ var NETWORK_ERROR_CODES = [502, 503, 504, 520, 521, 522, 523, 524, 530];
20494
20751
  async function handleError2(error48) {
20495
20752
  var _a2;
20496
20753
  if (!(0, helpers_1.looksLikeFetchResponse)(error48)) {
@@ -20626,14 +20883,14 @@ var require_fetch = __commonJS((exports) => {
20626
20883
  }
20627
20884
  });
20628
20885
 
20629
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/types.js
20886
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/types.js
20630
20887
  var require_types2 = __commonJS((exports) => {
20631
20888
  Object.defineProperty(exports, "__esModule", { value: true });
20632
20889
  exports.SIGN_OUT_SCOPES = undefined;
20633
20890
  exports.SIGN_OUT_SCOPES = ["global", "local", "others"];
20634
20891
  });
20635
20892
 
20636
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js
20893
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js
20637
20894
  var require_GoTrueAdminApi = __commonJS((exports) => {
20638
20895
  Object.defineProperty(exports, "__esModule", { value: true });
20639
20896
  var tslib_1 = require_tslib();
@@ -20643,10 +20900,11 @@ var require_GoTrueAdminApi = __commonJS((exports) => {
20643
20900
  var errors_1 = require_errors();
20644
20901
 
20645
20902
  class GoTrueAdminApi {
20646
- constructor({ url: url2 = "", headers = {}, fetch: fetch2 }) {
20903
+ constructor({ url: url2 = "", headers = {}, fetch: fetch2, experimental }) {
20647
20904
  this.url = url2;
20648
20905
  this.headers = headers;
20649
20906
  this.fetch = (0, helpers_1.resolveFetch)(fetch2);
20907
+ this.experimental = experimental !== null && experimental !== undefined ? experimental : {};
20650
20908
  this.mfa = {
20651
20909
  listFactors: this._listFactors.bind(this),
20652
20910
  deleteFactor: this._deleteFactor.bind(this)
@@ -20666,6 +20924,10 @@ var require_GoTrueAdminApi = __commonJS((exports) => {
20666
20924
  updateProvider: this._updateCustomProvider.bind(this),
20667
20925
  deleteProvider: this._deleteCustomProvider.bind(this)
20668
20926
  };
20927
+ this.passkey = {
20928
+ listPasskeys: this._adminListPasskeys.bind(this),
20929
+ deletePasskey: this._adminDeletePasskey.bind(this)
20930
+ };
20669
20931
  }
20670
20932
  async signOut(jwt2, scope = types_1.SIGN_OUT_SCOPES[0]) {
20671
20933
  if (types_1.SIGN_OUT_SCOPES.indexOf(scope) < 0) {
@@ -21045,11 +21307,37 @@ var require_GoTrueAdminApi = __commonJS((exports) => {
21045
21307
  throw error48;
21046
21308
  }
21047
21309
  }
21310
+ async _adminListPasskeys(params) {
21311
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
21312
+ (0, helpers_1.validateUUID)(params.userId);
21313
+ try {
21314
+ return await (0, fetch_1._request)(this.fetch, "GET", `${this.url}/admin/users/${params.userId}/passkeys`, { headers: this.headers, xform: (data) => ({ data, error: null }) });
21315
+ } catch (error48) {
21316
+ if ((0, errors_1.isAuthError)(error48)) {
21317
+ return { data: null, error: error48 };
21318
+ }
21319
+ throw error48;
21320
+ }
21321
+ }
21322
+ async _adminDeletePasskey(params) {
21323
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
21324
+ (0, helpers_1.validateUUID)(params.userId);
21325
+ (0, helpers_1.validateUUID)(params.passkeyId);
21326
+ try {
21327
+ await (0, fetch_1._request)(this.fetch, "DELETE", `${this.url}/admin/users/${params.userId}/passkeys/${params.passkeyId}`, { headers: this.headers, noResolveJson: true });
21328
+ return { data: null, error: null };
21329
+ } catch (error48) {
21330
+ if ((0, errors_1.isAuthError)(error48)) {
21331
+ return { data: null, error: error48 };
21332
+ }
21333
+ throw error48;
21334
+ }
21335
+ }
21048
21336
  }
21049
21337
  exports.default = GoTrueAdminApi;
21050
21338
  });
21051
21339
 
21052
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js
21340
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js
21053
21341
  var require_local_storage = __commonJS((exports) => {
21054
21342
  Object.defineProperty(exports, "__esModule", { value: true });
21055
21343
  exports.memoryLocalStorageAdapter = memoryLocalStorageAdapter;
@@ -21068,7 +21356,7 @@ var require_local_storage = __commonJS((exports) => {
21068
21356
  }
21069
21357
  });
21070
21358
 
21071
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/locks.js
21359
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/locks.js
21072
21360
  var require_locks = __commonJS((exports) => {
21073
21361
  Object.defineProperty(exports, "__esModule", { value: true });
21074
21362
  exports.ProcessLockAcquireTimeoutError = exports.NavigatorLockAcquireTimeoutError = exports.LockAcquireTimeoutError = exports.internals = undefined;
@@ -21242,7 +21530,7 @@ var require_locks = __commonJS((exports) => {
21242
21530
  }
21243
21531
  });
21244
21532
 
21245
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js
21533
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js
21246
21534
  var require_polyfills = __commonJS((exports) => {
21247
21535
  Object.defineProperty(exports, "__esModule", { value: true });
21248
21536
  exports.polyfillGlobalThis = polyfillGlobalThis;
@@ -21266,7 +21554,7 @@ var require_polyfills = __commonJS((exports) => {
21266
21554
  }
21267
21555
  });
21268
21556
 
21269
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js
21557
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js
21270
21558
  var require_ethereum = __commonJS((exports) => {
21271
21559
  Object.defineProperty(exports, "__esModule", { value: true });
21272
21560
  exports.getAddress = getAddress;
@@ -21343,7 +21631,7 @@ ${suffix}`;
21343
21631
  }
21344
21632
  });
21345
21633
 
21346
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js
21634
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js
21347
21635
  var require_webauthn_errors = __commonJS((exports) => {
21348
21636
  Object.defineProperty(exports, "__esModule", { value: true });
21349
21637
  exports.WebAuthnUnknownError = exports.WebAuthnError = undefined;
@@ -21523,7 +21811,7 @@ var require_webauthn_errors = __commonJS((exports) => {
21523
21811
  }
21524
21812
  });
21525
21813
 
21526
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js
21814
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js
21527
21815
  var require_webauthn = __commonJS((exports) => {
21528
21816
  Object.defineProperty(exports, "__esModule", { value: true });
21529
21817
  exports.WebAuthnApi = exports.DEFAULT_REQUEST_OPTIONS = exports.DEFAULT_CREATION_OPTIONS = exports.webAuthnAbortService = exports.WebAuthnAbortService = exports.identifyAuthenticationError = exports.identifyRegistrationError = exports.isWebAuthnError = exports.WebAuthnError = undefined;
@@ -21532,6 +21820,7 @@ var require_webauthn = __commonJS((exports) => {
21532
21820
  exports.serializeCredentialCreationResponse = serializeCredentialCreationResponse;
21533
21821
  exports.serializeCredentialRequestResponse = serializeCredentialRequestResponse;
21534
21822
  exports.isValidDomain = isValidDomain;
21823
+ exports.browserSupportsWebAuthn = browserSupportsWebAuthn;
21535
21824
  exports.createCredential = createCredential;
21536
21825
  exports.getCredential = getCredential;
21537
21826
  exports.mergeCredentialCreationOptions = mergeCredentialCreationOptions;
@@ -21976,7 +22265,7 @@ var require_webauthn = __commonJS((exports) => {
21976
22265
  exports.WebAuthnApi = WebAuthnApi;
21977
22266
  });
21978
22267
 
21979
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js
22268
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js
21980
22269
  var require_GoTrueClient = __commonJS((exports) => {
21981
22270
  Object.defineProperty(exports, "__esModule", { value: true });
21982
22271
  var tslib_1 = require_tslib();
@@ -22005,7 +22294,8 @@ var require_GoTrueClient = __commonJS((exports) => {
22005
22294
  hasCustomAuthorizationHeader: false,
22006
22295
  throwOnError: false,
22007
22296
  lockAcquireTimeout: 5000,
22008
- skipAutoInitialize: false
22297
+ skipAutoInitialize: false,
22298
+ experimental: {}
22009
22299
  };
22010
22300
  async function lockNoOp(name, acquireTimeout, fn) {
22011
22301
  return await fn();
@@ -22028,7 +22318,7 @@ var require_GoTrueClient = __commonJS((exports) => {
22028
22318
  GLOBAL_JWKS[this.storageKey] = Object.assign(Object.assign({}, GLOBAL_JWKS[this.storageKey]), { cachedAt: value });
22029
22319
  }
22030
22320
  constructor(options) {
22031
- var _a2, _b, _c;
22321
+ var _a2, _b, _c, _d;
22032
22322
  this.userStorage = null;
22033
22323
  this.memoryStorage = null;
22034
22324
  this.stateChangeEmitters = new Map;
@@ -22061,10 +22351,12 @@ var require_GoTrueClient = __commonJS((exports) => {
22061
22351
  }
22062
22352
  this.persistSession = settings.persistSession;
22063
22353
  this.autoRefreshToken = settings.autoRefreshToken;
22354
+ this.experimental = (_b = settings.experimental) !== null && _b !== undefined ? _b : {};
22064
22355
  this.admin = new GoTrueAdminApi_1.default({
22065
22356
  url: settings.url,
22066
22357
  headers: settings.headers,
22067
- fetch: settings.fetch
22358
+ fetch: settings.fetch,
22359
+ experimental: this.experimental
22068
22360
  });
22069
22361
  this.url = settings.url;
22070
22362
  this.headers = settings.headers;
@@ -22077,7 +22369,7 @@ var require_GoTrueClient = __commonJS((exports) => {
22077
22369
  this.lockAcquireTimeout = settings.lockAcquireTimeout;
22078
22370
  if (settings.lock) {
22079
22371
  this.lock = settings.lock;
22080
- } else if (this.persistSession && (0, helpers_1.isBrowser)() && ((_b = globalThis === null || globalThis === undefined ? undefined : globalThis.navigator) === null || _b === undefined ? undefined : _b.locks)) {
22372
+ } else if (this.persistSession && (0, helpers_1.isBrowser)() && ((_c = globalThis === null || globalThis === undefined ? undefined : globalThis.navigator) === null || _c === undefined ? undefined : _c.locks)) {
22081
22373
  this.lock = locks_1.navigatorLock;
22082
22374
  } else {
22083
22375
  this.lock = lockNoOp;
@@ -22103,6 +22395,15 @@ var require_GoTrueClient = __commonJS((exports) => {
22103
22395
  listGrants: this._listOAuthGrants.bind(this),
22104
22396
  revokeGrant: this._revokeOAuthGrant.bind(this)
22105
22397
  };
22398
+ this.passkey = {
22399
+ startRegistration: this._startPasskeyRegistration.bind(this),
22400
+ verifyRegistration: this._verifyPasskeyRegistration.bind(this),
22401
+ startAuthentication: this._startPasskeyAuthentication.bind(this),
22402
+ verifyAuthentication: this._verifyPasskeyAuthentication.bind(this),
22403
+ list: this._listPasskeys.bind(this),
22404
+ update: this._updatePasskey.bind(this),
22405
+ delete: this._deletePasskey.bind(this)
22406
+ };
22106
22407
  if (this.persistSession) {
22107
22408
  if (settings.storage) {
22108
22409
  this.storage = settings.storage;
@@ -22127,7 +22428,7 @@ var require_GoTrueClient = __commonJS((exports) => {
22127
22428
  } catch (e) {
22128
22429
  console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available", e);
22129
22430
  }
22130
- (_c = this.broadcastChannel) === null || _c === undefined || _c.addEventListener("message", async (event) => {
22431
+ (_d = this.broadcastChannel) === null || _d === undefined || _d.addEventListener("message", async (event) => {
22131
22432
  this._debug("received broadcast notification from other tab or client", event);
22132
22433
  try {
22133
22434
  await this._notifyAllSubscribers(event.data.event, event.data.session, false);
@@ -22606,7 +22907,7 @@ var require_GoTrueClient = __commonJS((exports) => {
22606
22907
  }
22607
22908
  if (data.session) {
22608
22909
  await this._saveSession(data.session);
22609
- await this._notifyAllSubscribers("SIGNED_IN", data.session);
22910
+ await this._notifyAllSubscribers(redirectType === "recovery" ? "PASSWORD_RECOVERY" : "SIGNED_IN", data.session);
22610
22911
  }
22611
22912
  return this._returnResult({ data: Object.assign(Object.assign({}, data), { redirectType: redirectType !== null && redirectType !== undefined ? redirectType : null }), error: error48 });
22612
22913
  } catch (error48) {
@@ -23121,6 +23422,7 @@ var require_GoTrueClient = __commonJS((exports) => {
23121
23422
  }
23122
23423
  }
23123
23424
  async _getSessionFromURL(params, callbackUrlType) {
23425
+ var _a2;
23124
23426
  try {
23125
23427
  if (!(0, helpers_1.isBrowser)())
23126
23428
  throw new errors_1.AuthImplicitGrantRedirectError("No browser detected.");
@@ -23153,7 +23455,10 @@ var require_GoTrueClient = __commonJS((exports) => {
23153
23455
  const url2 = new URL(window.location.href);
23154
23456
  url2.searchParams.delete("code");
23155
23457
  window.history.replaceState(window.history.state, "", url2.toString());
23156
- return { data: { session: data2.session, redirectType: null }, error: null };
23458
+ return {
23459
+ data: { session: data2.session, redirectType: (_a2 = data2.redirectType) !== null && _a2 !== undefined ? _a2 : null },
23460
+ error: null
23461
+ };
23157
23462
  }
23158
23463
  const { provider_token, provider_refresh_token, access_token, refresh_token, expires_in, expires_at, token_type } = params;
23159
23464
  if (!access_token || !expires_in || !refresh_token || !token_type) {
@@ -23269,7 +23574,11 @@ var require_GoTrueClient = __commonJS((exports) => {
23269
23574
  } catch (err) {
23270
23575
  await ((_b = this.stateChangeEmitters.get(id)) === null || _b === undefined ? undefined : _b.callback("INITIAL_SESSION", null));
23271
23576
  this._debug("INITIAL_SESSION", "callback id", id, "error", err);
23272
- console.error(err);
23577
+ if ((0, errors_1.isAuthSessionMissingError)(err)) {
23578
+ console.warn(err);
23579
+ } else {
23580
+ console.error(err);
23581
+ }
23273
23582
  }
23274
23583
  });
23275
23584
  }
@@ -24207,12 +24516,280 @@ var require_GoTrueClient = __commonJS((exports) => {
24207
24516
  throw error48;
24208
24517
  }
24209
24518
  }
24519
+ async signInWithPasskey(credentials) {
24520
+ var _a2, _b, _c;
24521
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24522
+ try {
24523
+ if (!(0, webauthn_1.browserSupportsWebAuthn)()) {
24524
+ return this._returnResult({
24525
+ data: null,
24526
+ error: new errors_1.AuthUnknownError("Browser does not support WebAuthn", null)
24527
+ });
24528
+ }
24529
+ const { data: options, error: optionsError } = await this._startPasskeyAuthentication({
24530
+ options: { captchaToken: (_a2 = credentials === null || credentials === undefined ? undefined : credentials.options) === null || _a2 === undefined ? undefined : _a2.captchaToken }
24531
+ });
24532
+ if (optionsError || !options) {
24533
+ return this._returnResult({ data: null, error: optionsError });
24534
+ }
24535
+ const publicKeyOptions = (0, webauthn_1.deserializeCredentialRequestOptions)(options.options);
24536
+ const signal = (_c = (_b = credentials === null || credentials === undefined ? undefined : credentials.options) === null || _b === undefined ? undefined : _b.signal) !== null && _c !== undefined ? _c : webauthn_1.webAuthnAbortService.createNewAbortSignal();
24537
+ const { data: credential, error: credentialError } = await (0, webauthn_1.getCredential)({
24538
+ publicKey: publicKeyOptions,
24539
+ signal
24540
+ });
24541
+ if (credentialError || !credential) {
24542
+ return this._returnResult({
24543
+ data: null,
24544
+ error: credentialError !== null && credentialError !== undefined ? credentialError : new errors_1.AuthUnknownError("WebAuthn ceremony failed", null)
24545
+ });
24546
+ }
24547
+ const serialized = (0, webauthn_1.serializeCredentialRequestResponse)(credential);
24548
+ return this._verifyPasskeyAuthentication({
24549
+ challengeId: options.challenge_id,
24550
+ credential: serialized
24551
+ });
24552
+ } catch (error48) {
24553
+ if ((0, errors_1.isAuthError)(error48)) {
24554
+ return this._returnResult({ data: null, error: error48 });
24555
+ }
24556
+ throw error48;
24557
+ }
24558
+ }
24559
+ async registerPasskey(credentials) {
24560
+ var _a2, _b;
24561
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24562
+ try {
24563
+ if (!(0, webauthn_1.browserSupportsWebAuthn)()) {
24564
+ return this._returnResult({
24565
+ data: null,
24566
+ error: new errors_1.AuthUnknownError("Browser does not support WebAuthn", null)
24567
+ });
24568
+ }
24569
+ const { data: options, error: optionsError } = await this._startPasskeyRegistration();
24570
+ if (optionsError || !options) {
24571
+ return this._returnResult({ data: null, error: optionsError });
24572
+ }
24573
+ const publicKeyOptions = (0, webauthn_1.deserializeCredentialCreationOptions)(options.options);
24574
+ const signal = (_b = (_a2 = credentials === null || credentials === undefined ? undefined : credentials.options) === null || _a2 === undefined ? undefined : _a2.signal) !== null && _b !== undefined ? _b : webauthn_1.webAuthnAbortService.createNewAbortSignal();
24575
+ const { data: credential, error: credentialError } = await (0, webauthn_1.createCredential)({
24576
+ publicKey: publicKeyOptions,
24577
+ signal
24578
+ });
24579
+ if (credentialError || !credential) {
24580
+ return this._returnResult({
24581
+ data: null,
24582
+ error: credentialError !== null && credentialError !== undefined ? credentialError : new errors_1.AuthUnknownError("WebAuthn ceremony failed", null)
24583
+ });
24584
+ }
24585
+ const serialized = (0, webauthn_1.serializeCredentialCreationResponse)(credential);
24586
+ return this._verifyPasskeyRegistration({
24587
+ challengeId: options.challenge_id,
24588
+ credential: serialized
24589
+ });
24590
+ } catch (error48) {
24591
+ if ((0, errors_1.isAuthError)(error48)) {
24592
+ return this._returnResult({ data: null, error: error48 });
24593
+ }
24594
+ throw error48;
24595
+ }
24596
+ }
24597
+ async _startPasskeyRegistration() {
24598
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24599
+ try {
24600
+ return await this._useSession(async (result) => {
24601
+ const { data: { session }, error: sessionError } = result;
24602
+ if (sessionError) {
24603
+ return this._returnResult({ data: null, error: sessionError });
24604
+ }
24605
+ if (!session) {
24606
+ return this._returnResult({ data: null, error: new errors_1.AuthSessionMissingError });
24607
+ }
24608
+ const { data, error: error48 } = await (0, fetch_1._request)(this.fetch, "POST", `${this.url}/passkeys/registration/options`, {
24609
+ headers: this.headers,
24610
+ jwt: session.access_token,
24611
+ body: {}
24612
+ });
24613
+ if (error48) {
24614
+ return this._returnResult({ data: null, error: error48 });
24615
+ }
24616
+ return this._returnResult({ data, error: null });
24617
+ });
24618
+ } catch (error48) {
24619
+ if ((0, errors_1.isAuthError)(error48)) {
24620
+ return this._returnResult({ data: null, error: error48 });
24621
+ }
24622
+ throw error48;
24623
+ }
24624
+ }
24625
+ async _verifyPasskeyRegistration(params) {
24626
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24627
+ try {
24628
+ return await this._useSession(async (result) => {
24629
+ const { data: { session }, error: sessionError } = result;
24630
+ if (sessionError) {
24631
+ return this._returnResult({ data: null, error: sessionError });
24632
+ }
24633
+ if (!session) {
24634
+ return this._returnResult({ data: null, error: new errors_1.AuthSessionMissingError });
24635
+ }
24636
+ const { data, error: error48 } = await (0, fetch_1._request)(this.fetch, "POST", `${this.url}/passkeys/registration/verify`, {
24637
+ headers: this.headers,
24638
+ jwt: session.access_token,
24639
+ body: {
24640
+ challenge_id: params.challengeId,
24641
+ credential: params.credential
24642
+ }
24643
+ });
24644
+ if (error48) {
24645
+ return this._returnResult({ data: null, error: error48 });
24646
+ }
24647
+ return this._returnResult({ data, error: null });
24648
+ });
24649
+ } catch (error48) {
24650
+ if ((0, errors_1.isAuthError)(error48)) {
24651
+ return this._returnResult({ data: null, error: error48 });
24652
+ }
24653
+ throw error48;
24654
+ }
24655
+ }
24656
+ async _startPasskeyAuthentication(params) {
24657
+ var _a2;
24658
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24659
+ try {
24660
+ const { data, error: error48 } = await (0, fetch_1._request)(this.fetch, "POST", `${this.url}/passkeys/authentication/options`, {
24661
+ headers: this.headers,
24662
+ body: {
24663
+ gotrue_meta_security: { captcha_token: (_a2 = params === null || params === undefined ? undefined : params.options) === null || _a2 === undefined ? undefined : _a2.captchaToken }
24664
+ }
24665
+ });
24666
+ if (error48) {
24667
+ return this._returnResult({ data: null, error: error48 });
24668
+ }
24669
+ return this._returnResult({ data, error: null });
24670
+ } catch (error48) {
24671
+ if ((0, errors_1.isAuthError)(error48)) {
24672
+ return this._returnResult({ data: null, error: error48 });
24673
+ }
24674
+ throw error48;
24675
+ }
24676
+ }
24677
+ async _verifyPasskeyAuthentication(params) {
24678
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24679
+ try {
24680
+ const { data, error: error48 } = await (0, fetch_1._request)(this.fetch, "POST", `${this.url}/passkeys/authentication/verify`, {
24681
+ headers: this.headers,
24682
+ body: {
24683
+ challenge_id: params.challengeId,
24684
+ credential: params.credential
24685
+ },
24686
+ xform: fetch_1._sessionResponse
24687
+ });
24688
+ if (error48) {
24689
+ return this._returnResult({ data: null, error: error48 });
24690
+ }
24691
+ if (data.session) {
24692
+ await this._saveSession(data.session);
24693
+ await this._notifyAllSubscribers("SIGNED_IN", data.session);
24694
+ }
24695
+ return this._returnResult({ data, error: null });
24696
+ } catch (error48) {
24697
+ if ((0, errors_1.isAuthError)(error48)) {
24698
+ return this._returnResult({ data: null, error: error48 });
24699
+ }
24700
+ throw error48;
24701
+ }
24702
+ }
24703
+ async _listPasskeys() {
24704
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24705
+ try {
24706
+ return await this._useSession(async (result) => {
24707
+ const { data: { session }, error: sessionError } = result;
24708
+ if (sessionError) {
24709
+ return this._returnResult({ data: null, error: sessionError });
24710
+ }
24711
+ if (!session) {
24712
+ return this._returnResult({ data: null, error: new errors_1.AuthSessionMissingError });
24713
+ }
24714
+ const { data, error: error48 } = await (0, fetch_1._request)(this.fetch, "GET", `${this.url}/passkeys`, {
24715
+ headers: this.headers,
24716
+ jwt: session.access_token,
24717
+ xform: (data2) => ({ data: data2, error: null })
24718
+ });
24719
+ if (error48) {
24720
+ return this._returnResult({ data: null, error: error48 });
24721
+ }
24722
+ return this._returnResult({ data, error: null });
24723
+ });
24724
+ } catch (error48) {
24725
+ if ((0, errors_1.isAuthError)(error48)) {
24726
+ return this._returnResult({ data: null, error: error48 });
24727
+ }
24728
+ throw error48;
24729
+ }
24730
+ }
24731
+ async _updatePasskey(params) {
24732
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24733
+ try {
24734
+ return await this._useSession(async (result) => {
24735
+ const { data: { session }, error: sessionError } = result;
24736
+ if (sessionError) {
24737
+ return this._returnResult({ data: null, error: sessionError });
24738
+ }
24739
+ if (!session) {
24740
+ return this._returnResult({ data: null, error: new errors_1.AuthSessionMissingError });
24741
+ }
24742
+ const { data, error: error48 } = await (0, fetch_1._request)(this.fetch, "PATCH", `${this.url}/passkeys/${params.passkeyId}`, {
24743
+ headers: this.headers,
24744
+ jwt: session.access_token,
24745
+ body: { friendly_name: params.friendlyName }
24746
+ });
24747
+ if (error48) {
24748
+ return this._returnResult({ data: null, error: error48 });
24749
+ }
24750
+ return this._returnResult({ data, error: null });
24751
+ });
24752
+ } catch (error48) {
24753
+ if ((0, errors_1.isAuthError)(error48)) {
24754
+ return this._returnResult({ data: null, error: error48 });
24755
+ }
24756
+ throw error48;
24757
+ }
24758
+ }
24759
+ async _deletePasskey(params) {
24760
+ (0, helpers_1.assertPasskeyExperimentalEnabled)(this.experimental);
24761
+ try {
24762
+ return await this._useSession(async (result) => {
24763
+ const { data: { session }, error: sessionError } = result;
24764
+ if (sessionError) {
24765
+ return this._returnResult({ data: null, error: sessionError });
24766
+ }
24767
+ if (!session) {
24768
+ return this._returnResult({ data: null, error: new errors_1.AuthSessionMissingError });
24769
+ }
24770
+ const { error: error48 } = await (0, fetch_1._request)(this.fetch, "DELETE", `${this.url}/passkeys/${params.passkeyId}`, {
24771
+ headers: this.headers,
24772
+ jwt: session.access_token,
24773
+ noResolveJson: true
24774
+ });
24775
+ if (error48) {
24776
+ return this._returnResult({ data: null, error: error48 });
24777
+ }
24778
+ return this._returnResult({ data: null, error: null });
24779
+ });
24780
+ } catch (error48) {
24781
+ if ((0, errors_1.isAuthError)(error48)) {
24782
+ return this._returnResult({ data: null, error: error48 });
24783
+ }
24784
+ throw error48;
24785
+ }
24786
+ }
24210
24787
  }
24211
24788
  GoTrueClient.nextInstanceID = {};
24212
24789
  exports.default = GoTrueClient;
24213
24790
  });
24214
24791
 
24215
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js
24792
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js
24216
24793
  var require_AuthAdminApi = __commonJS((exports) => {
24217
24794
  Object.defineProperty(exports, "__esModule", { value: true });
24218
24795
  var tslib_1 = require_tslib();
@@ -24221,7 +24798,7 @@ var require_AuthAdminApi = __commonJS((exports) => {
24221
24798
  exports.default = AuthAdminApi;
24222
24799
  });
24223
24800
 
24224
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/AuthClient.js
24801
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/AuthClient.js
24225
24802
  var require_AuthClient = __commonJS((exports) => {
24226
24803
  Object.defineProperty(exports, "__esModule", { value: true });
24227
24804
  var tslib_1 = require_tslib();
@@ -24230,7 +24807,7 @@ var require_AuthClient = __commonJS((exports) => {
24230
24807
  exports.default = AuthClient;
24231
24808
  });
24232
24809
 
24233
- // node_modules/.bun/@supabase+auth-js@2.100.1/node_modules/@supabase/auth-js/dist/main/index.js
24810
+ // node_modules/.bun/@supabase+auth-js@2.105.1/node_modules/@supabase/auth-js/dist/main/index.js
24234
24811
  var require_main3 = __commonJS((exports) => {
24235
24812
  Object.defineProperty(exports, "__esModule", { value: true });
24236
24813
  exports.processLock = exports.lockInternals = exports.NavigatorLockAcquireTimeoutError = exports.navigatorLock = exports.AuthClient = exports.AuthAdminApi = exports.GoTrueClient = exports.GoTrueAdminApi = undefined;
@@ -24260,11 +24837,12 @@ var require_main3 = __commonJS((exports) => {
24260
24837
  } });
24261
24838
  });
24262
24839
 
24263
- // node_modules/.bun/@supabase+supabase-js@2.100.1/node_modules/@supabase/supabase-js/dist/index.mjs
24840
+ // node_modules/.bun/@supabase+supabase-js@2.105.1/node_modules/@supabase/supabase-js/dist/index.mjs
24264
24841
  var exports_dist = {};
24265
24842
  __export(exports_dist, {
24266
24843
  createClient: () => createClient,
24267
24844
  SupabaseClient: () => SupabaseClient,
24845
+ StorageApiError: () => StorageApiError,
24268
24846
  PostgrestError: () => PostgrestError,
24269
24847
  FunctionsRelayError: () => import_functions_js.FunctionsRelayError,
24270
24848
  FunctionsHttpError: () => import_functions_js.FunctionsHttpError,
@@ -24372,7 +24950,7 @@ function shouldShowDeprecationWarning() {
24372
24950
  return false;
24373
24951
  return parseInt(versionMatch[1], 10) <= 18;
24374
24952
  }
24375
- var import_functions_js, import_realtime_js, import_auth_js, version3 = "2.100.1", JS_ENV = "", DEFAULT_HEADERS2, DEFAULT_GLOBAL_OPTIONS, DEFAULT_DB_OPTIONS, DEFAULT_AUTH_OPTIONS, DEFAULT_REALTIME_OPTIONS, resolveFetch2 = (customFetch) => {
24953
+ var import_functions_js, import_realtime_js, import_auth_js, version3 = "2.105.1", JS_ENV = "", DEFAULT_HEADERS2, DEFAULT_GLOBAL_OPTIONS, DEFAULT_DB_OPTIONS, DEFAULT_AUTH_OPTIONS, DEFAULT_REALTIME_OPTIONS, resolveFetch2 = (customFetch) => {
24376
24954
  if (customFetch)
24377
24955
  return (...args) => customFetch(...args);
24378
24956
  return (...args) => fetch(...args);
@@ -24426,7 +25004,8 @@ var import_functions_js, import_realtime_js, import_auth_js, version3 = "2.100.1
24426
25004
  this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch);
24427
25005
  this.realtime = this._initRealtimeClient(_objectSpread23({
24428
25006
  headers: this.headers,
24429
- accessToken: this._getAccessToken.bind(this)
25007
+ accessToken: this._getAccessToken.bind(this),
25008
+ fetch: this.fetch
24430
25009
  }, settings.realtime));
24431
25010
  if (this.accessToken)
24432
25011
  Promise.resolve(this.accessToken()).then((token) => this.realtime.setAuth(token)).catch((e) => console.warn("Failed to set initial Realtime auth token:", e));
@@ -24480,7 +25059,7 @@ var import_functions_js, import_realtime_js, import_auth_js, version3 = "2.100.1
24480
25059
  const { data } = await _this.auth.getSession();
24481
25060
  return (_data$session$access_ = (_data$session = data.session) === null || _data$session === undefined ? undefined : _data$session.access_token) !== null && _data$session$access_ !== undefined ? _data$session$access_ : _this.supabaseKey;
24482
25061
  }
24483
- _initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, userStorage, storageKey, flowType, lock, debug, throwOnError }, headers, fetch$1) {
25062
+ _initSupabaseAuthClient({ autoRefreshToken, persistSession, detectSessionInUrl, storage, userStorage, storageKey, flowType, lock, debug, throwOnError, experimental }, headers, fetch$1) {
24484
25063
  const authHeaders = {
24485
25064
  Authorization: `Bearer ${this.supabaseKey}`,
24486
25065
  apikey: `${this.supabaseKey}`
@@ -24498,6 +25077,7 @@ var import_functions_js, import_realtime_js, import_auth_js, version3 = "2.100.1
24498
25077
  lock,
24499
25078
  debug,
24500
25079
  throwOnError,
25080
+ experimental,
24501
25081
  fetch: fetch$1,
24502
25082
  hasCustomAuthorizationHeader: Object.keys(this.headers).some((key) => key.toLowerCase() === "authorization")
24503
25083
  });
@@ -24798,10 +25378,18 @@ __export(exports_client, {
24798
25378
  function validateEnv() {
24799
25379
  const url2 = process.env.SUPABASE_URL ?? process.env.NEXT_PUBLIC_SUPABASE_URL;
24800
25380
  const key = process.env.SUPABASE_SERVICE_ROLE_KEY ?? process.env.SUPABASE_SERVICE_KEY;
24801
- if (!url2)
24802
- throw new Error("SUPABASE_URL is required");
24803
- if (!key)
24804
- throw new Error("SUPABASE_SERVICE_ROLE_KEY is required");
25381
+ if (!url2) {
25382
+ logger.error("[FATAL] Missing required environment variable: SUPABASE_URL");
25383
+ process.exit(1);
25384
+ }
25385
+ if (!key) {
25386
+ logger.error("[FATAL] Missing required environment variable: SUPABASE_SERVICE_ROLE_KEY");
25387
+ process.exit(1);
25388
+ }
25389
+ if (!key.startsWith("eyJ")) {
25390
+ logger.error("[FATAL] SUPABASE_SERVICE_ROLE_KEY appears malformed (expected a JWT starting with 'eyJ'). " + "Ensure you are using the service_role key, not the anon key.");
25391
+ process.exit(1);
25392
+ }
24805
25393
  return { url: url2, key };
24806
25394
  }
24807
25395
  function getInjectedSupabaseClient() {
@@ -24830,7 +25418,9 @@ function getSupabaseClient() {
24830
25418
  });
24831
25419
  },
24832
25420
  headers: {
24833
- Connection: "keep-alive"
25421
+ Connection: "keep-alive",
25422
+ Accept: "application/json",
25423
+ "Content-Type": "application/json"
24834
25424
  }
24835
25425
  }
24836
25426
  });
@@ -24894,14 +25484,22 @@ async function readLastCheckpoint(userId, sessionId) {
24894
25484
  };
24895
25485
  }
24896
25486
  async function isSessionComplete(sessionId) {
24897
- const supabase = getSupabaseClient();
24898
- const { count, error: error48 } = await supabase.from(CHECKPOINT_TABLE).select("id", { count: "exact", head: true }).eq("session_id", sessionId);
24899
- if (error48) {
24900
- logger.warn("Failed to check session completion:", error48);
24901
- const isProduction = false;
24902
- return isProduction;
25487
+ try {
25488
+ const supabase = getSupabaseClient();
25489
+ const { count, error: error48 } = await supabase.from(CHECKPOINT_TABLE).select("id", { count: "exact", head: true }).eq("session_id", sessionId);
25490
+ if (error48) {
25491
+ logger.error("Failed to check session completion — failing OPEN:", {
25492
+ error: error48.message,
25493
+ code: error48.code,
25494
+ sessionId
25495
+ });
25496
+ return false;
25497
+ }
25498
+ return (count ?? 0) > 0;
25499
+ } catch (err) {
25500
+ logger.error("Unexpected error in isSessionComplete:", err);
25501
+ return false;
24903
25502
  }
24904
- return (count ?? 0) > 0;
24905
25503
  }
24906
25504
  var CHECKPOINT_TABLE = "thinking_checkpoints";
24907
25505
  var init_storage = __esm(() => {
@@ -24911,21 +25509,48 @@ var init_storage = __esm(() => {
24911
25509
  });
24912
25510
 
24913
25511
  // src/tools/thinking/telemetry.ts
25512
+ function deriveTaskComplexity(thoughtNumber, totalThoughts) {
25513
+ if (totalThoughts <= 2)
25514
+ return "simple";
25515
+ if (totalThoughts <= 5)
25516
+ return "moderate";
25517
+ return "complex";
25518
+ }
25519
+ function estimateTokenCount(text) {
25520
+ if (!text)
25521
+ return 0;
25522
+ return Math.ceil(text.length / 4);
25523
+ }
25524
+ function detectHighRisk(riskLevel) {
25525
+ return riskLevel === "high" || riskLevel === "critical";
25526
+ }
25527
+ function buildFieldsPopulated(data) {
25528
+ const fields = ["thought", "thoughtNumber", "totalThoughts", "nextThoughtNeeded", "confidence", "thoughtType"];
25529
+ if (data.goalAnchorPresent)
25530
+ fields.push("goalAnchor");
25531
+ if (data.assumptionsCount > 0)
25532
+ fields.push("assumptions");
25533
+ if (data.checkpointWritten)
25534
+ fields.push("checkpointWritten");
25535
+ return fields;
25536
+ }
24914
25537
  async function trackThinkingMetrics(data) {
24915
25538
  try {
24916
25539
  const supabase = getSupabaseClient();
24917
- const { error: error48 } = await supabase.from("thinking_metrics").insert({
25540
+ const row = {
24918
25541
  user_id: data.userId,
24919
25542
  session_id: data.sessionId,
24920
- thought_number: data.thoughtNumber,
24921
- confidence: data.confidence,
24922
- risk_level: data.riskLevel,
24923
- recommended_tool_name: data.recommendedToolName,
24924
- checkpoint_written: data.checkpointWritten,
24925
- goal_anchor_present: data.goalAnchorPresent,
24926
- assumptions_count: data.assumptionsCount,
24927
- flagged_assumptions_count: data.flaggedAssumptionsCount
24928
- });
25543
+ fields_populated: buildFieldsPopulated(data),
25544
+ task_complexity: deriveTaskComplexity(data.thoughtNumber, data.totalThoughts),
25545
+ token_count: estimateTokenCount(data.thoughtText),
25546
+ high_risk_detected: detectHighRisk(data.riskLevel),
25547
+ project_context_used: false,
25548
+ mode: "reasoning",
25549
+ step_number: data.thoughtNumber,
25550
+ is_new_session: data.thoughtNumber === 1,
25551
+ execution_time_ms: 0
25552
+ };
25553
+ const { error: error48 } = await supabase.from("thinking_metrics").insert(row);
24929
25554
  if (error48) {
24930
25555
  logger.warn("Failed to track thinking metrics:", error48.message);
24931
25556
  }
@@ -24971,7 +25596,7 @@ var init_v4_mini = __esm(() => {
24971
25596
  init_external2();
24972
25597
  });
24973
25598
 
24974
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
25599
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
24975
25600
  function isZ4Schema(s) {
24976
25601
  const schema = s;
24977
25602
  return !!schema._zod;
@@ -25047,7 +25672,7 @@ var init_v4 = __esm(() => {
25047
25672
  init_classic();
25048
25673
  });
25049
25674
 
25050
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25675
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25051
25676
  var exports_types = {};
25052
25677
  __export(exports_types, {
25053
25678
  isTaskAugmentedRequestParams: () => isTaskAugmentedRequestParams,
@@ -25240,7 +25865,7 @@ var init_types2 = __esm(() => {
25240
25865
  ProgressTokenSchema = union([string2(), number2().int()]);
25241
25866
  CursorSchema = string2();
25242
25867
  TaskCreationParamsSchema = looseObject({
25243
- ttl: union([number2(), _null3()]).optional(),
25868
+ ttl: number2().optional(),
25244
25869
  pollInterval: number2().optional()
25245
25870
  });
25246
25871
  TaskMetadataSchema = object({
@@ -25391,7 +26016,8 @@ var init_types2 = __esm(() => {
25391
26016
  roots: object({
25392
26017
  listChanged: boolean2().optional()
25393
26018
  }).optional(),
25394
- tasks: ClientTasksCapabilitySchema.optional()
26019
+ tasks: ClientTasksCapabilitySchema.optional(),
26020
+ extensions: record(string2(), AssertObjectSchema).optional()
25395
26021
  });
25396
26022
  InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
25397
26023
  protocolVersion: string2(),
@@ -25416,7 +26042,8 @@ var init_types2 = __esm(() => {
25416
26042
  tools: object({
25417
26043
  listChanged: boolean2().optional()
25418
26044
  }).optional(),
25419
- tasks: ServerTasksCapabilitySchema.optional()
26045
+ tasks: ServerTasksCapabilitySchema.optional(),
26046
+ extensions: record(string2(), AssertObjectSchema).optional()
25420
26047
  });
25421
26048
  InitializeResultSchema = ResultSchema.extend({
25422
26049
  protocolVersion: string2(),
@@ -25531,6 +26158,7 @@ var init_types2 = __esm(() => {
25531
26158
  uri: string2(),
25532
26159
  description: optional(string2()),
25533
26160
  mimeType: optional(string2()),
26161
+ size: optional(number2()),
25534
26162
  annotations: AnnotationsSchema.optional(),
25535
26163
  _meta: optional(looseObject({}))
25536
26164
  });
@@ -26060,7 +26688,7 @@ var init_types2 = __esm(() => {
26060
26688
  };
26061
26689
  });
26062
26690
 
26063
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
26691
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
26064
26692
  function isTerminal(status) {
26065
26693
  return status === "completed" || status === "failed" || status === "cancelled";
26066
26694
  }
@@ -26278,7 +26906,7 @@ var init_esm = __esm(() => {
26278
26906
  init_zodToJsonSchema();
26279
26907
  });
26280
26908
 
26281
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
26909
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
26282
26910
  function getMethodLiteral(schema) {
26283
26911
  const shape = getObjectShape(schema);
26284
26912
  const methodSchema = shape?.method;
@@ -26303,7 +26931,7 @@ var init_zod_json_schema_compat = __esm(() => {
26303
26931
  init_esm();
26304
26932
  });
26305
26933
 
26306
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
26934
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
26307
26935
  class Protocol {
26308
26936
  constructor(_options) {
26309
26937
  this._options = _options;
@@ -33611,7 +34239,7 @@ var require_dist = __commonJS((exports, module) => {
33611
34239
  exports.default = formatsPlugin;
33612
34240
  });
33613
34241
 
33614
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
34242
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
33615
34243
  function createDefaultAjvInstance() {
33616
34244
  const ajv = new import_ajv.default({
33617
34245
  strict: false,
@@ -33654,7 +34282,7 @@ var init_ajv_provider = __esm(() => {
33654
34282
  import_ajv_formats = __toESM(require_dist(), 1);
33655
34283
  });
33656
34284
 
33657
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
34285
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
33658
34286
  class ExperimentalServerTasks {
33659
34287
  constructor(_server) {
33660
34288
  this._server = _server;
@@ -33735,7 +34363,7 @@ var init_server = __esm(() => {
33735
34363
  init_types2();
33736
34364
  });
33737
34365
 
33738
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
34366
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
33739
34367
  function assertToolsCallTaskCapability(requests, method, entityName) {
33740
34368
  if (!requests) {
33741
34369
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -33770,7 +34398,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
33770
34398
  }
33771
34399
  }
33772
34400
 
33773
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
34401
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
33774
34402
  var exports_server = {};
33775
34403
  __export(exports_server, {
33776
34404
  Server: () => Server
@@ -34115,7 +34743,7 @@ var init_server2 = __esm(() => {
34115
34743
  };
34116
34744
  });
34117
34745
 
34118
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
34746
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
34119
34747
  class ReadBuffer {
34120
34748
  append(chunk) {
34121
34749
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
@@ -34148,7 +34776,7 @@ var init_stdio = __esm(() => {
34148
34776
  init_types2();
34149
34777
  });
34150
34778
 
34151
- // node_modules/.bun/@modelcontextprotocol+sdk@1.28.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
34779
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
34152
34780
  var exports_stdio = {};
34153
34781
  __export(exports_stdio, {
34154
34782
  StdioServerTransport: () => StdioServerTransport
@@ -34243,9 +34871,9 @@ function recommendTool(thought) {
34243
34871
  if (/architecture|how\s+(does|is)\s+it\s+built|explain\s+how|data\s+flow|call\s+graph|dependency\s+graph|system\s+design|service\s+boundaries|entry\s+point|how\s+are\s+.+\s+connected|request\s+lifecycle|middleware\s+chain|pipeline|flow\s+of\s+data|auth\s+flow|payment\s+flow/.test(t))
34244
34872
  return { name: "explain_architecture", confidence: 0.8, rationale: "Thought asks about architecture, flow, or system design", alternative: "get_project_context" };
34245
34873
  if (/url|endpoint|http[s]?:\/\/|api\s+(docs?|reference|endpoint)|documentation\s+page|changelog|swagger|openapi|graphql\s+playground|postman|curl|fetch\s+from|webhook\s+url|callback\s+url|redirect\s+url/.test(t))
34246
- return { name: "inspect_url", confidence: 0.8, rationale: "Thought mentions URL, endpoint, or documentation", alternative: "audit_headers" };
34874
+ return { name: "Zephex_dev_info", confidence: 0.8, rationale: "Thought mentions URL, endpoint, or documentation", alternative: "audit_headers" };
34247
34875
  if (/header|cors|csp|content.security.policy|security\s+header|hsts|x-frame|x-content|cache.control|cdn|cloudflare|nginx\s+config|reverse\s+proxy|load\s+balancer|ssl|tls|certificate/.test(t))
34248
- return { name: "audit_headers", confidence: 0.8, rationale: "Thought mentions HTTP headers, CORS, or security headers", alternative: "inspect_url" };
34876
+ return { name: "audit_headers", confidence: 0.8, rationale: "Thought mentions HTTP headers, CORS, or security headers", alternative: "Zephex_dev_info" };
34249
34877
  if (/package\s+version|npm\s+(install|update|audit)|outdated|vulnerable|CVE|advisory|upgrade\s+(react|next|vue|angular|django|rails|spring|express)|latest\s+version|breaking\s+changes|migration\s+guide|semver|dependency\s+(update|upgrade|check)/.test(t))
34250
34878
  return { name: "check_package", confidence: 0.8, rationale: "Thought mentions package versions, updates, or vulnerabilities", alternative: "audit_package" };
34251
34879
  if (/security\s+audit|supply\s+chain|malicious\s+package|typosquat|compromised|audit\s+dependencies|license\s+compliance|transitive\s+dep/.test(t))
@@ -34333,7 +34961,7 @@ async function handleThink(params, userId) {
34333
34961
  throw new ThinkingError(-32603, "Session complete. Start a new session.");
34334
34962
  }
34335
34963
  if (input.sessionId) {
34336
- const alreadyComplete = await isSessionComplete(input.sessionId).catch(() => true);
34964
+ const alreadyComplete = await isSessionComplete(input.sessionId).catch(() => false);
34337
34965
  if (alreadyComplete) {
34338
34966
  throw new ThinkingError(-32603, "Session complete. Start a new session.");
34339
34967
  }
@@ -34454,13 +35082,16 @@ async function handleThink(params, userId) {
34454
35082
  userId,
34455
35083
  sessionId,
34456
35084
  thoughtNumber: input.thoughtNumber,
35085
+ totalThoughts: input.totalThoughts,
34457
35086
  confidence: input.confidence,
34458
35087
  riskLevel,
34459
35088
  recommendedToolName: rec.name,
34460
35089
  checkpointWritten,
34461
35090
  goalAnchorPresent: !!input.goalAnchor,
34462
35091
  assumptionsCount: (input.assumptions ?? []).length,
34463
- flaggedAssumptionsCount: flaggedAssumptions.length
35092
+ flaggedAssumptionsCount: flaggedAssumptions.length,
35093
+ thoughtText: input.thought,
35094
+ thoughtType: input.thoughtType
34464
35095
  }).catch(() => {});
34465
35096
  const MAX_OUTPUT_CHARS = 4000;
34466
35097
  const outputJson = JSON.stringify(output);
@@ -34513,7 +35144,7 @@ var init_thinking = __esm(async () => {
34513
35144
  }, 5 * 60 * 1000).unref();
34514
35145
  THINKING_TOOL = {
34515
35146
  name: "thinking",
34516
- description: "⚡ PREFER THIS for multi-step reasoning, debugging, and planning where an ad-hoc chain-of-thought can go off the rails. Persistent reasoning session that tracks what was checked, what was concluded, what was ruled out, and what comes next — preventing circular debugging, forgotten conclusions, and lost context across long multi-tool sessions. Structured step-by-step reasoning with: typed thought states (hypothesis / observation / plan / revision / conclusion / question / debug), server-side compression of older thoughts, endless-loop detection (3+ noisy/errored tool results → forced stop), goal anchoring (two-strike rule catches drift from original task), assumption tracking with invalidation flags, revision and branching (explore 'hypothesis-A' vs 'hypothesis-B' in parallel), confidence scoring with auto-revision below 0.5, risk detection on destructive actions (drop table / force push / delete branch / prod deploy / rm -rf), next-tool recommendation, and cross-session memory via sessionId. This is NOT a code reader — open it BEFORE you start reading code on hard problems.\n" + `
35147
+ description: "⚡ PREFER THIS over ad-hoc chain-of-thought on hard problems. Persistent reasoning session that tracks what was checked, what was concluded, what was ruled out, and what comes next — preventing circular debugging, forgotten conclusions, and lost context across long multi-tool sessions. Structured step-by-step reasoning with: typed thought states (hypothesis / observation / plan / revision / conclusion / question / debug), server-side compression of older thoughts, endless-loop detection (3+ noisy/errored tool results → forced stop), goal anchoring (two-strike rule catches drift from original task), assumption tracking with invalidation flags, revision and branching (explore 'hypothesis-A' vs 'hypothesis-B' in parallel), confidence scoring with auto-revision below 0.5, risk detection on destructive actions (drop table / force push / delete branch / prod deploy / rm -rf), next-tool recommendation, and cross-session memory via sessionId. This is NOT a code reader — open it BEFORE you start reading code on hard problems.\n" + `
34517
35148
  ` + `AUTOMATICALLY call this (without asking permission) when ANY of these occur:
34518
35149
  ` + `• Can't figure out the bug: 'I can't figure out why', 'I've tried X and Y and it still doesn't work', 'something is wrong but I don't know where to look', 'this bug makes no sense', 'intermittent error', 'only happens in production', 'only happens under load', 'only affects certain users', 'flaky', 'race condition', 'memory leak', 'the last fix made it worse', 'Heisenbug', 'works on my machine', 'silent data corruption', 'the fix didn't stick'. Use thoughtType:'hypothesis' / 'debug' / 'observation' / 'revision' as you iterate.
34519
35150
  ` + `• Multi-system problems: 'this spans auth and billing', 'frontend and backend', 'cache and database', 'multiple services', 'multiple repos', 'production and staging behave differently', 'my tests pass but prod is broken', 'the webhook fires but the DB doesn't update', 'edge vs origin disagreement', 'CDN cache vs app cache', 'cross-region replication lag'
@@ -34532,13 +35163,22 @@ var init_thinking = __esm(async () => {
34532
35163
  ` + "• Project-type coverage: ANY stack — TS/JS, Python, Go, Rust, Java, Kotlin, Swift, Obj-C, Ruby, PHP, C/C++, C#, F#, Scala, Elixir, Erlang, Clojure, Haskell, OCaml, Lua, Zig, Nim, Crystal, Dart, R, Julia, SQL, Bash/Zsh/PowerShell. Frameworks: React 19 / Next 15 / Nuxt 4 / Remix / SvelteKit 2 / Astro 5 / Vue 3.5 / Angular 19 / Svelte 5 / Solid / SolidStart / Qwik / TanStack Start / Waku / Redwood / Blitz / Fresh, Django 5 / Flask / FastAPI / Starlette / Litestar / Rails 8 / Sinatra / Hanami / Phoenix / Plug / Spring Boot 3 / Micronaut 4 / Quarkus 3 / Ktor / Vert.x / Nest / Express / Fastify / Hono / Elysia / Koa / AdonisJS / ASP.NET 9 / Gin / Echo / Fiber / Chi / Axum 0.8 / Actix 4 / Rocket / Warp / Loco / Salvo, LangChain / LangGraph / LlamaIndex / AI SDK / CrewAI / AutoGen / agentic apps / RAG / vector DBs (Pinecone / Weaviate / Qdrant / Chroma / Milvus / pgvector), React Native / Expo / Flutter / Electron / Tauri 2 / Capacitor / Ionic / KMP / Compose / SwiftUI / UIKit / Jetpack Compose, monorepos (Turborepo / Nx / pnpm / Yarn / Bazel / Moonrepo), ML (PyTorch / TensorFlow / JAX / scikit-learn / Polars / Pandas / Ray / Modal / Airflow / dbt), infra (Docker / K8s / Helm / ArgoCD / Terraform / Pulumi / CDK / Ansible / Vault), edge/serverless (CF Workers / Durable Objects / Vercel / Lambda / Cloud Run / Fly), legacy code.\n" + `
34533
35164
  ` + `Overhead is 300–900 tokens. Worth it every time it prevents a circular loop on a hard problem or a missed failure mode on a high-stakes change. Do NOT call for single-step tasks, trivial questions, or after nextThoughtNeeded:false. Hard ceiling ~10 thoughts per session; use totalThoughts to budget, revise upward only if genuinely needed.
34534
35165
  ` + `
35166
+ ` + `DO NOT CALL FOR: reading a single file (use read_code), finding a symbol (use find_code), getting project info (use get_project_context), simple one-step tasks, syntax questions, after nextThoughtNeeded:false. This is a deliberation tool, not a chain-of-thought narrator.
35167
+ ` + `
35168
+ ` + `LIMITATIONS: does NOT browse the web, read files, or execute code — it structures your own reasoning. Quality ≈ specificity of thought content; vague thoughts trip drift detection. Hard ceiling ~10 thoughts/session; write a conclusion, start new sessionId, carry goalAnchor forward if more needed. Cross-session memory is per-sessionId — do not reuse for unrelated tasks.
35169
+ ` + `
35170
+ ` + `EXAMPLES:
35171
+ ` + `• Hard bug: { thought:'EU users double-charged after v4.7; suspect webhook replay without idempotency key', thoughtNumber:1, totalThoughts:6, nextThoughtNeeded:true, confidence:0.4, thoughtType:'hypothesis' }
35172
+ ` + `• Migration plan: plan→revision→conclusion across 4 steps, each with assumptions[] for constraints (downtime window, replica lag, rollback DDL).
35173
+ ` + `• A/B design: thought 2 branches into branchId:'option-A' and branchId:'option-B'; thought 5 converges with a conclusion.
35174
+ ` + `
34535
35175
  ` + "Required on every call: thought (1-2000 chars), thoughtNumber, totalThoughts, nextThoughtNeeded, confidence (0-1), thoughtType. Pass goalAnchor from thought 2 onward to avoid drift. Pass sessionId on thought 1 to restore the last checkpoint.",
34536
35176
  inputSchema: {
34537
35177
  type: "object",
34538
35178
  properties: {
34539
35179
  thought: {
34540
35180
  type: "string",
34541
- description: "The actual reasoning content for this step (1–2000 chars)"
35181
+ description: "The actual reasoning content for this step (1–2000 chars). Be specific — vague thoughts trip drift detection. Include file names, function names, error messages when relevant."
34542
35182
  },
34543
35183
  thoughtNumber: {
34544
35184
  type: "integer",
@@ -34559,7 +35199,7 @@ var init_thinking = __esm(async () => {
34559
35199
  thoughtType: {
34560
35200
  type: "string",
34561
35201
  enum: ["hypothesis", "observation", "plan", "revision", "conclusion", "question", "debug"],
34562
- description: "Required every call. Controls compression behavior."
35202
+ description: "Required every call. Controls compression behavior. hypothesis=initial theory (kept verbatim in compression), observation=evidence from tool output (masked when old), plan=action steps (truncated when old), revision=corrects a prior thought, conclusion=final answer (kept verbatim), question=asks for clarification, debug=troubleshooting step (masked when old)."
34563
35203
  },
34564
35204
  goalAnchor: {
34565
35205
  type: "string",