@boxes-dev/dvb-runtime 1.0.1115 → 1.0.1116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/dvb.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9cbc3858-b3e6-5f8d-9e71-d79a39e38e58")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4e057937-23ce-557d-8df1-9ba22fd3a10a")}catch(e){}}();
4
4
  import { createRequire as __dvbCreateRequire } from "node:module";
5
5
  import { dirname as __dvbDirname } from "node:path";
6
6
  import { fileURLToPath as __dvbFileURLToPath } from "node:url";
@@ -22756,10 +22756,10 @@ var init_ajvProvider_97rDpkRx = __esm({
22756
22756
  Ajv2.ValidationError = validation_error_1.default;
22757
22757
  Ajv2.MissingRefError = ref_error_1.default;
22758
22758
  exports.default = Ajv2;
22759
- function checkOptions(checkOpts, options, msg, log3 = "error") {
22759
+ function checkOptions(checkOpts, options, msg, log4 = "error") {
22760
22760
  for (const key in checkOpts) {
22761
22761
  const opt = key;
22762
- if (opt in options) this.logger[log3](`${msg}: option ${key}. ${checkOpts[opt]}`);
22762
+ if (opt in options) this.logger[log4](`${msg}: option ${key}. ${checkOpts[opt]}`);
22763
22763
  }
22764
22764
  }
22765
22765
  function getSchEnv(keyRef) {
@@ -27127,7 +27127,7 @@ var init_companion = __esm({
27127
27127
  const profile = resolveMcpOAuthProfile(options.agent);
27128
27128
  const fetchFn = options.fetchFn ?? fetch;
27129
27129
  const serverOrigin = new URL(serverUrl).origin;
27130
- const log3 = (event) => options.log?.(event);
27130
+ const log4 = (event) => options.log?.(event);
27131
27131
  const baseEvent = {
27132
27132
  agent: options.agent,
27133
27133
  profileVersion: profile.profileVersion,
@@ -27146,7 +27146,7 @@ var init_companion = __esm({
27146
27146
  signal: options.signal,
27147
27147
  timeoutMs: options.timeoutMs ?? DEFAULT_CALLBACK_TIMEOUT_MS
27148
27148
  });
27149
- log3({
27149
+ log4({
27150
27150
  ...baseEvent,
27151
27151
  event: "callback_listening",
27152
27152
  errorCode: null
@@ -27162,13 +27162,13 @@ var init_companion = __esm({
27162
27162
  }, sdkAuth);
27163
27163
  throwIfCanceled(options.signal);
27164
27164
  await options.openAuthorizationUrl(prepared.authorizationUrl);
27165
- log3({
27165
+ log4({
27166
27166
  ...baseEvent,
27167
27167
  event: "authorization_opened",
27168
27168
  errorCode: null
27169
27169
  });
27170
27170
  const callback = await callbackListener.waitForCallback;
27171
- log3({
27171
+ log4({
27172
27172
  ...baseEvent,
27173
27173
  event: "callback_received",
27174
27174
  errorCode: null
@@ -27186,7 +27186,7 @@ var init_companion = __esm({
27186
27186
  } catch {
27187
27187
  throw new McpOAuthCompanionError("upload_failed", "boxes.dev could not save the completed MCP authorization.");
27188
27188
  }
27189
- log3({
27189
+ log4({
27190
27190
  ...baseEvent,
27191
27191
  event: "grant_uploaded",
27192
27192
  errorCode: null
@@ -27201,7 +27201,7 @@ var init_companion = __esm({
27201
27201
  };
27202
27202
  } catch (error55) {
27203
27203
  const safeError = toSafeMcpOAuthError(error55);
27204
- log3({
27204
+ log4({
27205
27205
  ...baseEvent,
27206
27206
  event: safeError.code === "canceled" ? "authorization_canceled" : "authorization_failed",
27207
27207
  errorCode: safeError.code
@@ -29960,7 +29960,7 @@ var init_logger = __esm({
29960
29960
  shouldLog = (minLevel, level) => levelOrder[level] >= levelOrder[minLevel];
29961
29961
  createLogger = (component) => {
29962
29962
  const minLevel = normalizeLevel(process.env.DEVBOX_LOG_LEVEL);
29963
- const log3 = (level, message, fields) => {
29963
+ const log4 = (level, message, fields) => {
29964
29964
  if (!shouldLog(minLevel, level))
29965
29965
  return;
29966
29966
  const payload = {
@@ -29973,10 +29973,10 @@ var init_logger = __esm({
29973
29973
  console.error(JSON.stringify(payload));
29974
29974
  };
29975
29975
  return {
29976
- debug: (message, fields) => log3("debug", message, fields),
29977
- info: (message, fields) => log3("info", message, fields),
29978
- warn: (message, fields) => log3("warn", message, fields),
29979
- error: (message, fields) => log3("error", message, fields)
29976
+ debug: (message, fields) => log4("debug", message, fields),
29977
+ info: (message, fields) => log4("info", message, fields),
29978
+ warn: (message, fields) => log4("warn", message, fields),
29979
+ error: (message, fields) => log4("error", message, fields)
29980
29980
  };
29981
29981
  };
29982
29982
  }
@@ -35504,13 +35504,13 @@ function _INTERNAL_captureLog(beforeLog, currentScope = getCurrentScope(), captu
35504
35504
  setLogAttribute(processedLogAttributes, "sentry.trace.parent_span_id", span?.spanContext().spanId);
35505
35505
  const processedLog = { ...beforeLog, attributes: processedLogAttributes };
35506
35506
  client.emit("beforeCaptureLog", processedLog);
35507
- const log3 = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;
35508
- if (!log3) {
35507
+ const log4 = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;
35508
+ if (!log4) {
35509
35509
  client.recordDroppedEvent("before_send", "log_item", 1);
35510
35510
  DEBUG_BUILD && debug.warn("beforeSendLog returned null, log will not be captured.");
35511
35511
  return;
35512
35512
  }
35513
- const { level, message, attributes: logAttributes = {}, severityNumber } = log3;
35513
+ const { level, message, attributes: logAttributes = {}, severityNumber } = log4;
35514
35514
  const timestamp2 = timestampInSeconds();
35515
35515
  const sequenceAttr = getSequenceAttribute(timestamp2);
35516
35516
  const serializedLog = {
@@ -35526,7 +35526,7 @@ function _INTERNAL_captureLog(beforeLog, currentScope = getCurrentScope(), captu
35526
35526
  })
35527
35527
  };
35528
35528
  captureSerializedLog(client, serializedLog);
35529
- client.emit("afterCaptureLog", log3);
35529
+ client.emit("afterCaptureLog", log4);
35530
35530
  }
35531
35531
  function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
35532
35532
  const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
@@ -36291,12 +36291,12 @@ function estimateMetricSizeInBytes(metric) {
36291
36291
  weight += 8;
36292
36292
  return weight + estimateAttributesSizeInBytes(metric.attributes);
36293
36293
  }
36294
- function estimateLogSizeInBytes(log3) {
36294
+ function estimateLogSizeInBytes(log4) {
36295
36295
  let weight = 0;
36296
- if (log3.message) {
36297
- weight += log3.message.length * 2;
36296
+ if (log4.message) {
36297
+ weight += log4.message.length * 2;
36298
36298
  }
36299
- return weight + estimateAttributesSizeInBytes(log3.attributes);
36299
+ return weight + estimateAttributesSizeInBytes(log4.attributes);
36300
36300
  }
36301
36301
  function estimateAttributesSizeInBytes(attributes) {
36302
36302
  if (!attributes) {
@@ -38173,13 +38173,13 @@ function instrumentConsole() {
38173
38173
  originalConsoleMethods[level] = originalConsoleMethod;
38174
38174
  return function(...args) {
38175
38175
  const firstArg = args[0];
38176
- const log3 = originalConsoleMethods[level];
38176
+ const log4 = originalConsoleMethods[level];
38177
38177
  const isFiltered = _filter.size && typeof firstArg === "string" && stringMatchesSomePattern(firstArg, _filter);
38178
38178
  if (!isFiltered) {
38179
38179
  triggerHandlers("console", { args, level });
38180
38180
  }
38181
38181
  if (!isFiltered || DEBUG_BUILD && debug.isEnabled()) {
38182
- log3?.apply(GLOBAL_OBJ.console, args);
38182
+ log4?.apply(GLOBAL_OBJ.console, args);
38183
38183
  }
38184
38184
  };
38185
38185
  });
@@ -47256,7 +47256,7 @@ var require_node = __commonJS({
47256
47256
  var tty3 = __require("tty");
47257
47257
  var util2 = __require("util");
47258
47258
  exports.init = init3;
47259
- exports.log = log3;
47259
+ exports.log = log4;
47260
47260
  exports.formatArgs = formatArgs;
47261
47261
  exports.save = save;
47262
47262
  exports.load = load2;
@@ -47391,7 +47391,7 @@ var require_node = __commonJS({
47391
47391
  }
47392
47392
  return (/* @__PURE__ */ new Date()).toISOString() + " ";
47393
47393
  }
47394
- function log3(...args) {
47394
+ function log4(...args) {
47395
47395
  return process.stderr.write(util2.formatWithOptions(exports.inspectOpts, ...args) + "\n");
47396
47396
  }
47397
47397
  function save(namespaces) {
@@ -57414,12 +57414,12 @@ var init_local_variables_sync = __esm({
57414
57414
  for (const prop of props) {
57415
57415
  if (prop.value?.objectId && prop.value.className === "Array") {
57416
57416
  const id2 = prop.value.objectId;
57417
- add((vars) => this._unrollArray(id2, prop.name, vars, next));
57417
+ add((vars2) => this._unrollArray(id2, prop.name, vars2, next));
57418
57418
  } else if (prop.value?.objectId && prop.value.className === "Object") {
57419
57419
  const id2 = prop.value.objectId;
57420
- add((vars) => this._unrollObject(id2, prop.name, vars, next));
57420
+ add((vars2) => this._unrollObject(id2, prop.name, vars2, next));
57421
57421
  } else if (prop.value) {
57422
- add((vars) => this._unrollOther(prop, vars, next));
57422
+ add((vars2) => this._unrollOther(prop, vars2, next));
57423
57423
  }
57424
57424
  }
57425
57425
  next({});
@@ -57447,42 +57447,42 @@ var init_local_variables_sync = __esm({
57447
57447
  /**
57448
57448
  * Unrolls an array property
57449
57449
  */
57450
- _unrollArray(objectId, name, vars, next) {
57450
+ _unrollArray(objectId, name, vars2, next) {
57451
57451
  this._getProperties(objectId, (props) => {
57452
- vars[name] = props.filter((v2) => v2.name !== "length" && !isNaN(parseInt(v2.name, 10))).sort((a2, b2) => parseInt(a2.name, 10) - parseInt(b2.name, 10)).map((v2) => v2.value?.value);
57453
- next(vars);
57452
+ vars2[name] = props.filter((v2) => v2.name !== "length" && !isNaN(parseInt(v2.name, 10))).sort((a2, b2) => parseInt(a2.name, 10) - parseInt(b2.name, 10)).map((v2) => v2.value?.value);
57453
+ next(vars2);
57454
57454
  });
57455
57455
  }
57456
57456
  /**
57457
57457
  * Unrolls an object property
57458
57458
  */
57459
- _unrollObject(objectId, name, vars, next) {
57459
+ _unrollObject(objectId, name, vars2, next) {
57460
57460
  this._getProperties(objectId, (props) => {
57461
- vars[name] = props.map((v2) => [v2.name, v2.value?.value]).reduce((obj, [key, val]) => {
57461
+ vars2[name] = props.map((v2) => [v2.name, v2.value?.value]).reduce((obj, [key, val]) => {
57462
57462
  obj[key] = val;
57463
57463
  return obj;
57464
57464
  }, {});
57465
- next(vars);
57465
+ next(vars2);
57466
57466
  });
57467
57467
  }
57468
57468
  /**
57469
57469
  * Unrolls other properties
57470
57470
  */
57471
- _unrollOther(prop, vars, next) {
57471
+ _unrollOther(prop, vars2, next) {
57472
57472
  if (prop.value) {
57473
57473
  if ("value" in prop.value) {
57474
57474
  if (prop.value.value === void 0 || prop.value.value === null) {
57475
- vars[prop.name] = `<${prop.value.value}>`;
57475
+ vars2[prop.name] = `<${prop.value.value}>`;
57476
57476
  } else {
57477
- vars[prop.name] = prop.value.value;
57477
+ vars2[prop.name] = prop.value.value;
57478
57478
  }
57479
57479
  } else if ("description" in prop.value && prop.value.type !== "function") {
57480
- vars[prop.name] = `<${prop.value.description}>`;
57480
+ vars2[prop.name] = `<${prop.value.description}>`;
57481
57481
  } else if (prop.value.type === "undefined") {
57482
- vars[prop.name] = "<undefined>";
57482
+ vars2[prop.name] = "<undefined>";
57483
57483
  }
57484
57484
  }
57485
- next(vars);
57485
+ next(vars2);
57486
57486
  }
57487
57487
  };
57488
57488
  INTEGRATION_NAME15 = "LocalVariables";
@@ -57569,8 +57569,8 @@ var init_local_variables_sync = __esm({
57569
57569
  } else {
57570
57570
  const id2 = localScope.object.objectId;
57571
57571
  add(
57572
- (frames) => session.getLocalVariables(id2, (vars) => {
57573
- frames[i2] = { function: fn, vars };
57572
+ (frames) => session.getLocalVariables(id2, (vars2) => {
57573
+ frames[i2] = { function: fn, vars: vars2 };
57574
57574
  next(frames);
57575
57575
  })
57576
57576
  );
@@ -58768,9 +58768,9 @@ var init_client2 = __esm({
58768
58768
  _INTERNAL_flushLogsBuffer(this);
58769
58769
  };
58770
58770
  if (serverName) {
58771
- this.on("beforeCaptureLog", (log3) => {
58772
- log3.attributes = {
58773
- ...log3.attributes,
58771
+ this.on("beforeCaptureLog", (log4) => {
58772
+ log4.attributes = {
58773
+ ...log4.attributes,
58774
58774
  "server.address": serverName
58775
58775
  };
58776
58776
  });
@@ -70565,9 +70565,9 @@ var init_sentry = __esm({
70565
70565
  uncaughtExceptionMonitorInstalled = false;
70566
70566
  currentDevboxSentryUser = null;
70567
70567
  readBuildMetadata = () => {
70568
- const rawPackageVersion = "1.0.1115";
70569
- const rawGitSha = "44b7c199b316cc264c5da5d10ed4ce3c902d24dd";
70570
- const rawSentryRelease = "boxes-dev-dvb@1.0.1115+44b7c199b316cc264c5da5d10ed4ce3c902d24dd";
70568
+ const rawPackageVersion = "1.0.1116";
70569
+ const rawGitSha = "d955b3df0b12f1206e0fffeef958599e70b3c409";
70570
+ const rawSentryRelease = "boxes-dev-dvb@1.0.1116+d955b3df0b12f1206e0fffeef958599e70b3c409";
70571
70571
  const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
70572
70572
  const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
70573
70573
  const sentryRelease = typeof rawSentryRelease === "string" ? rawSentryRelease : void 0;
@@ -75172,7 +75172,7 @@ var init_desktopInitContracts = __esm({
75172
75172
  });
75173
75173
 
75174
75174
  // ../../../../shared/devboxCore/dist/desktopObjectTransfers.js
75175
- var DESKTOP_OBJECT_TRANSFER_MAX_FILE_BYTES, DESKTOP_OBJECT_TRANSFER_MAX_BATCH_BYTES, DESKTOP_OBJECT_TRANSFER_IMPORT_TIMEOUT_MS, DESKTOP_OBJECT_TRANSFER_MULTIPART_THRESHOLD_BYTES, DESKTOP_OBJECT_TRANSFER_MULTIPART_PART_SIZE_BYTES, DESKTOP_OBJECT_TRANSFER_UPLOAD_URL_TTL_SECONDS, DESKTOP_OBJECT_TRANSFER_DOWNLOAD_URL_TTL_SECONDS;
75175
+ var DESKTOP_OBJECT_TRANSFER_MAX_FILE_BYTES, DESKTOP_OBJECT_TRANSFER_MAX_BATCH_BYTES, DESKTOP_OBJECT_TRANSFER_IMPORT_TIMEOUT_MS, DESKTOP_OBJECT_TRANSFER_MULTIPART_THRESHOLD_BYTES, DESKTOP_OBJECT_TRANSFER_MULTIPART_PART_SIZE_BYTES, DESKTOP_OBJECT_TRANSFER_UPLOAD_URL_TTL_SECONDS, DESKTOP_OBJECT_TRANSFER_DOWNLOAD_URL_TTL_SECONDS, DESKTOP_WORKSPACE_DOWNLOAD_UPLOAD_TIMEOUT_MS;
75176
75176
  var init_desktopObjectTransfers = __esm({
75177
75177
  "../../../../shared/devboxCore/dist/desktopObjectTransfers.js"() {
75178
75178
  "use strict";
@@ -75183,6 +75183,7 @@ var init_desktopObjectTransfers = __esm({
75183
75183
  DESKTOP_OBJECT_TRANSFER_MULTIPART_PART_SIZE_BYTES = 64 * 1024 * 1024;
75184
75184
  DESKTOP_OBJECT_TRANSFER_UPLOAD_URL_TTL_SECONDS = 15 * 60;
75185
75185
  DESKTOP_OBJECT_TRANSFER_DOWNLOAD_URL_TTL_SECONDS = 15 * 60;
75186
+ DESKTOP_WORKSPACE_DOWNLOAD_UPLOAD_TIMEOUT_MS = DESKTOP_OBJECT_TRANSFER_UPLOAD_URL_TTL_SECONDS * 1e3 - 6e4;
75186
75187
  }
75187
75188
  });
75188
75189
 
@@ -76240,7 +76241,7 @@ var init_packageVersion = __esm({
76240
76241
  return path18.join(process.cwd(), "dvb");
76241
76242
  };
76242
76243
  readEmbeddedPackageVersion = () => {
76243
- const raw = "1.0.1115";
76244
+ const raw = "1.0.1116";
76244
76245
  return trimVersion(raw);
76245
76246
  };
76246
76247
  readNearestPackageMetadata = (basePath) => {
@@ -78161,6 +78162,12 @@ function jsonToConvex(value) {
78161
78162
  }
78162
78163
  return float;
78163
78164
  }
78165
+ if (key === "$commitTs") {
78166
+ if (value.$commitTs !== null) {
78167
+ throw new Error(`Malformed $commitTs field on ${value}`);
78168
+ }
78169
+ return commitTsPlaceholder;
78170
+ }
78164
78171
  if (key === "$set") {
78165
78172
  throw new Error(
78166
78173
  `Received a Set which is no longer supported as a Convex type.`
@@ -78184,6 +78191,12 @@ function stringifyValueForError(value) {
78184
78191
  if (value2 === void 0) {
78185
78192
  return "undefined";
78186
78193
  }
78194
+ if (typeof value2 === "function") {
78195
+ return "[Function]";
78196
+ }
78197
+ if (typeof value2 === "symbol") {
78198
+ return String(value2);
78199
+ }
78187
78200
  if (typeof value2 === "bigint") {
78188
78201
  return `${value2.toString()}n`;
78189
78202
  }
@@ -78238,6 +78251,9 @@ function convexToJsonInternal(value, originalValue, context34, includeTopLevelUn
78238
78251
  if (value instanceof ArrayBuffer) {
78239
78252
  return { $bytes: fromByteArray(new Uint8Array(value)) };
78240
78253
  }
78254
+ if (value instanceof CommitTsPlaceholder) {
78255
+ return { $commitTs: null };
78256
+ }
78241
78257
  if (Array.isArray(value)) {
78242
78258
  return value.map(
78243
78259
  (value2, i2) => convexToJsonInternal(value2, originalValue, context34 + `[${i2}]`, false)
@@ -78308,7 +78324,7 @@ function convexOrUndefinedToJsonInternal(value, originalValue, context34) {
78308
78324
  function convexToJson(value) {
78309
78325
  return convexToJsonInternal(value, value, "", false);
78310
78326
  }
78311
- var LITTLE_ENDIAN, MIN_INT64, MAX_INT64, ZERO, EIGHT, TWOFIFTYSIX, bigIntToBase64, base64ToBigInt, MAX_IDENTIFIER_LEN, MAX_VALUE_FOR_ERROR_LEN;
78327
+ var LITTLE_ENDIAN, MIN_INT64, MAX_INT64, ZERO, EIGHT, TWOFIFTYSIX, COMMIT_TS_UNRESOLVED, CommitTsPlaceholder, commitTsPlaceholder, bigIntToBase64, base64ToBigInt, MAX_IDENTIFIER_LEN, MAX_VALUE_FOR_ERROR_LEN;
78312
78328
  var init_value = __esm({
78313
78329
  "../../node_modules/convex/dist/esm/values/value.js"() {
78314
78330
  "use strict";
@@ -78320,6 +78336,25 @@ var init_value = __esm({
78320
78336
  ZERO = BigInt("0");
78321
78337
  EIGHT = BigInt("8");
78322
78338
  TWOFIFTYSIX = BigInt("256");
78339
+ COMMIT_TS_UNRESOLVED = "This commit timestamp is unresolved: its value is assigned when the mutation commits. Read the document after the mutation completes to get its value.";
78340
+ CommitTsPlaceholder = class {
78341
+ [Symbol.toPrimitive](hint) {
78342
+ if (hint === "string") {
78343
+ return this.toString();
78344
+ }
78345
+ throw new Error(COMMIT_TS_UNRESOLVED);
78346
+ }
78347
+ valueOf() {
78348
+ throw new Error(COMMIT_TS_UNRESOLVED);
78349
+ }
78350
+ toJSON() {
78351
+ throw new Error(COMMIT_TS_UNRESOLVED);
78352
+ }
78353
+ toString() {
78354
+ return "[unresolved commit timestamp]";
78355
+ }
78356
+ };
78357
+ commitTsPlaceholder = new CommitTsPlaceholder();
78323
78358
  bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
78324
78359
  base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
78325
78360
  MAX_IDENTIFIER_LEN = 1024;
@@ -78334,7 +78369,7 @@ function throwUndefinedValidatorError(context34, fieldName) {
78334
78369
  `A validator is undefined${fieldInfo} in ${context34}. This is often caused by circular imports. See ${UNDEFINED_VALIDATOR_ERROR_URL} for details.`
78335
78370
  );
78336
78371
  }
78337
- var __defProp3, __defNormalProp, __publicField, UNDEFINED_VALIDATOR_ERROR_URL, BaseValidator, VId, VFloat64, VInt64, VBoolean, VBytes, VString, VNull, VAny, VObject, VLiteral, VArray, VRecord, VUnion;
78372
+ var __defProp3, __defNormalProp, __publicField, UNDEFINED_VALIDATOR_ERROR_URL, BaseValidator, VId, VFloat64, VInt64, VCommitTs, VBoolean, VBytes, VString, VNull, VAny, VObject, VLiteral, VArray, VRecord, VUnion;
78338
78373
  var init_validators = __esm({
78339
78374
  "../../node_modules/convex/dist/esm/values/validators.js"() {
78340
78375
  "use strict";
@@ -78373,13 +78408,17 @@ var init_validators = __esm({
78373
78408
  get json() {
78374
78409
  return { type: "id", tableName: this.tableName };
78375
78410
  }
78376
- /** @internal */
78377
- asOptional() {
78411
+ /** Allow this field to be validated as absent. */
78412
+ optional() {
78378
78413
  return new _VId({
78379
78414
  isOptional: "optional",
78380
78415
  tableName: this.tableName
78381
78416
  });
78382
78417
  }
78418
+ /** @internal */
78419
+ asOptional() {
78420
+ return this.optional();
78421
+ }
78383
78422
  };
78384
78423
  VFloat64 = class _VFloat64 extends BaseValidator {
78385
78424
  constructor() {
@@ -78390,12 +78429,16 @@ var init_validators = __esm({
78390
78429
  get json() {
78391
78430
  return { type: "number" };
78392
78431
  }
78393
- /** @internal */
78394
- asOptional() {
78432
+ /** Allow this field to be validated as absent. */
78433
+ optional() {
78395
78434
  return new _VFloat64({
78396
78435
  isOptional: "optional"
78397
78436
  });
78398
78437
  }
78438
+ /** @internal */
78439
+ asOptional() {
78440
+ return this.optional();
78441
+ }
78399
78442
  };
78400
78443
  VInt64 = class _VInt64 extends BaseValidator {
78401
78444
  constructor() {
@@ -78406,26 +78449,54 @@ var init_validators = __esm({
78406
78449
  get json() {
78407
78450
  return { type: "bigint" };
78408
78451
  }
78452
+ /** Allow this validated field to be absent. */
78453
+ optional() {
78454
+ return new _VInt64({ isOptional: "optional" });
78455
+ }
78409
78456
  /** @internal */
78410
78457
  asOptional() {
78411
- return new _VInt64({ isOptional: "optional" });
78458
+ return this.optional();
78412
78459
  }
78413
78460
  };
78414
- VBoolean = class _VBoolean extends BaseValidator {
78461
+ VCommitTs = class _VCommitTs extends BaseValidator {
78415
78462
  constructor() {
78416
78463
  super(...arguments);
78417
- __publicField(this, "kind", "boolean");
78464
+ __publicField(this, "kind", "commitTs");
78418
78465
  }
78419
78466
  /** @internal */
78420
78467
  get json() {
78421
78468
  return { type: this.kind };
78422
78469
  }
78470
+ /** Allow this validated field to be absent. */
78471
+ optional() {
78472
+ return new _VCommitTs({
78473
+ isOptional: "optional"
78474
+ });
78475
+ }
78423
78476
  /** @internal */
78424
78477
  asOptional() {
78478
+ return this.optional();
78479
+ }
78480
+ };
78481
+ VBoolean = class _VBoolean extends BaseValidator {
78482
+ constructor() {
78483
+ super(...arguments);
78484
+ __publicField(this, "kind", "boolean");
78485
+ }
78486
+ /** @internal */
78487
+ get json() {
78488
+ return { type: this.kind };
78489
+ }
78490
+ /** Allow this validated field to be absent. */
78491
+ optional() {
78425
78492
  return new _VBoolean({
78426
78493
  isOptional: "optional"
78427
78494
  });
78428
78495
  }
78496
+ /** @internal */
78497
+ asOptional() {
78498
+ return this.optional();
78499
+ }
78429
78500
  };
78430
78501
  VBytes = class _VBytes extends BaseValidator {
78431
78502
  constructor() {
@@ -78436,9 +78507,13 @@ var init_validators = __esm({
78436
78507
  get json() {
78437
78508
  return { type: this.kind };
78438
78509
  }
78510
+ /** Allow this validated field to be absent. */
78511
+ optional() {
78512
+ return new _VBytes({ isOptional: "optional" });
78513
+ }
78439
78514
  /** @internal */
78440
78515
  asOptional() {
78441
- return new _VBytes({ isOptional: "optional" });
78516
+ return this.optional();
78442
78517
  }
78443
78518
  };
78444
78519
  VString = class _VString extends BaseValidator {
@@ -78450,12 +78525,16 @@ var init_validators = __esm({
78450
78525
  get json() {
78451
78526
  return { type: this.kind };
78452
78527
  }
78453
- /** @internal */
78454
- asOptional() {
78528
+ /** Allow this validated field to be absent. */
78529
+ optional() {
78455
78530
  return new _VString({
78456
78531
  isOptional: "optional"
78457
78532
  });
78458
78533
  }
78534
+ /** @internal */
78535
+ asOptional() {
78536
+ return this.optional();
78537
+ }
78459
78538
  };
78460
78539
  VNull = class _VNull extends BaseValidator {
78461
78540
  constructor() {
@@ -78466,9 +78545,13 @@ var init_validators = __esm({
78466
78545
  get json() {
78467
78546
  return { type: this.kind };
78468
78547
  }
78548
+ /** Allow this validated field to be absent. */
78549
+ optional() {
78550
+ return new _VNull({ isOptional: "optional" });
78551
+ }
78469
78552
  /** @internal */
78470
78553
  asOptional() {
78471
- return new _VNull({ isOptional: "optional" });
78554
+ return this.optional();
78472
78555
  }
78473
78556
  };
78474
78557
  VAny = class _VAny extends BaseValidator {
@@ -78482,12 +78565,16 @@ var init_validators = __esm({
78482
78565
  type: this.kind
78483
78566
  };
78484
78567
  }
78485
- /** @internal */
78486
- asOptional() {
78568
+ /** Allow this validated field to be absent. */
78569
+ optional() {
78487
78570
  return new _VAny({
78488
78571
  isOptional: "optional"
78489
78572
  });
78490
78573
  }
78574
+ /** @internal */
78575
+ asOptional() {
78576
+ return this.optional();
78577
+ }
78491
78578
  };
78492
78579
  VObject = class _VObject extends BaseValidator {
78493
78580
  /**
@@ -78525,13 +78612,17 @@ var init_validators = __esm({
78525
78612
  )
78526
78613
  };
78527
78614
  }
78528
- /** @internal */
78529
- asOptional() {
78615
+ /** Allow this validated field to be absent. */
78616
+ optional() {
78530
78617
  return new _VObject({
78531
78618
  isOptional: "optional",
78532
78619
  fields: this.fields
78533
78620
  });
78534
78621
  }
78622
+ /** @internal */
78623
+ asOptional() {
78624
+ return this.optional();
78625
+ }
78535
78626
  /**
78536
78627
  * Create a new VObject with the specified fields omitted.
78537
78628
  * @param fields The field names to omit from this VObject.
@@ -78604,13 +78695,17 @@ var init_validators = __esm({
78604
78695
  value: convexToJson(this.value)
78605
78696
  };
78606
78697
  }
78607
- /** @internal */
78608
- asOptional() {
78698
+ /** Allow this validated field to be absent. */
78699
+ optional() {
78609
78700
  return new _VLiteral({
78610
78701
  isOptional: "optional",
78611
78702
  value: this.value
78612
78703
  });
78613
78704
  }
78705
+ /** @internal */
78706
+ asOptional() {
78707
+ return this.optional();
78708
+ }
78614
78709
  };
78615
78710
  VArray = class _VArray extends BaseValidator {
78616
78711
  /**
@@ -78635,13 +78730,17 @@ var init_validators = __esm({
78635
78730
  value: this.element.json
78636
78731
  };
78637
78732
  }
78638
- /** @internal */
78639
- asOptional() {
78733
+ /** Allow this validated field to be absent. */
78734
+ optional() {
78640
78735
  return new _VArray({
78641
78736
  isOptional: "optional",
78642
78737
  element: this.element
78643
78738
  });
78644
78739
  }
78740
+ /** @internal */
78741
+ asOptional() {
78742
+ return this.optional();
78743
+ }
78645
78744
  };
78646
78745
  VRecord = class _VRecord extends BaseValidator {
78647
78746
  /**
@@ -78669,7 +78768,7 @@ var init_validators = __esm({
78669
78768
  throw new Error("Record validator cannot have optional values");
78670
78769
  }
78671
78770
  if (!key.isConvexValidator || !value.isConvexValidator) {
78672
- throw new Error("Key and value of v.record() but be validators");
78771
+ throw new Error("Key and value of v.record() must be validators");
78673
78772
  }
78674
78773
  this.key = key;
78675
78774
  this.value = value;
@@ -78686,14 +78785,18 @@ var init_validators = __esm({
78686
78785
  }
78687
78786
  };
78688
78787
  }
78689
- /** @internal */
78690
- asOptional() {
78788
+ /** Allow this validated field to be absent. */
78789
+ optional() {
78691
78790
  return new _VRecord({
78692
78791
  isOptional: "optional",
78693
78792
  key: this.key,
78694
78793
  value: this.value
78695
78794
  });
78696
78795
  }
78796
+ /** @internal */
78797
+ asOptional() {
78798
+ return this.optional();
78799
+ }
78697
78800
  };
78698
78801
  VUnion = class _VUnion extends BaseValidator {
78699
78802
  /**
@@ -78720,20 +78823,24 @@ var init_validators = __esm({
78720
78823
  value: this.members.map((v2) => v2.json)
78721
78824
  };
78722
78825
  }
78723
- /** @internal */
78724
- asOptional() {
78826
+ /** Allow this validated field to be absent. */
78827
+ optional() {
78725
78828
  return new _VUnion({
78726
78829
  isOptional: "optional",
78727
78830
  members: this.members
78728
78831
  });
78729
78832
  }
78833
+ /** @internal */
78834
+ asOptional() {
78835
+ return this.optional();
78836
+ }
78730
78837
  };
78731
78838
  }
78732
78839
  });
78733
78840
 
78734
78841
  // ../../node_modules/convex/dist/esm/values/validator.js
78735
78842
  function isValidator(v2) {
78736
- return !!v2.isConvexValidator;
78843
+ return v2?.isConvexValidator === true;
78737
78844
  }
78738
78845
  var v;
78739
78846
  var init_validator = __esm({
@@ -78742,7 +78849,16 @@ var init_validator = __esm({
78742
78849
  init_validators();
78743
78850
  v = {
78744
78851
  /**
78745
- * Validates that the value corresponds to an ID of a document in given table.
78852
+ * Validates that the value is a document ID for the given table.
78853
+ *
78854
+ * IDs are strings at runtime but are typed as `Id<"tableName">` in
78855
+ * TypeScript for type safety.
78856
+ *
78857
+ * @example
78858
+ * ```typescript
78859
+ * args: { userId: v.id("users") }
78860
+ * ```
78861
+ *
78746
78862
  * @param tableName The name of the table.
78747
78863
  */
78748
78864
  id: (tableName) => {
@@ -78752,79 +78868,165 @@ var init_validator = __esm({
78752
78868
  });
78753
78869
  },
78754
78870
  /**
78755
- * Validates that the value is of type Null.
78871
+ * Validates that the value is `null`.
78872
+ *
78873
+ * Use `returns: v.null()` for functions that don't return a meaningful value.
78874
+ * JavaScript `undefined` is not a valid Convex value, it is automatically
78875
+ * converted to `null`.
78756
78876
  */
78757
78877
  null: () => {
78758
78878
  return new VNull({ isOptional: "required" });
78759
78879
  },
78760
78880
  /**
78761
- * Validates that the value is of Convex type Float64 (Number in JS).
78881
+ * Validates that the value is a JavaScript `number` (Convex Float64).
78882
+ *
78883
+ * Supports all IEEE-754 double-precision floating point numbers including
78884
+ * NaN and Infinity.
78762
78885
  *
78763
- * Alias for `v.float64()`
78886
+ * Alias for `v.float64()`.
78764
78887
  */
78765
78888
  number: () => {
78766
78889
  return new VFloat64({ isOptional: "required" });
78767
78890
  },
78768
78891
  /**
78769
- * Validates that the value is of Convex type Float64 (Number in JS).
78892
+ * Validates that the value is a JavaScript `number` (Convex Float64).
78893
+ *
78894
+ * Supports all IEEE-754 double-precision floating point numbers.
78770
78895
  */
78771
78896
  float64: () => {
78772
78897
  return new VFloat64({ isOptional: "required" });
78773
78898
  },
78774
78899
  /**
78775
- * @deprecated Use `v.int64()` instead
78900
+ * @deprecated Use `v.int64()` instead.
78776
78901
  */
78777
78902
  bigint: () => {
78778
78903
  return new VInt64({ isOptional: "required" });
78779
78904
  },
78780
78905
  /**
78781
- * Validates that the value is of Convex type Int64 (BigInt in JS).
78906
+ * Validates that the value is a JavaScript `bigint` (Convex Int64).
78907
+ *
78908
+ * Supports BigInts between -2^63 and 2^63-1.
78909
+ *
78910
+ * @example
78911
+ * ```typescript
78912
+ * args: { timestamp: v.int64() }
78913
+ * // Usage: createDoc({ timestamp: 1234567890n })
78914
+ * ```
78782
78915
  */
78783
78916
  int64: () => {
78784
78917
  return new VInt64({ isOptional: "required" });
78785
78918
  },
78786
78919
  /**
78787
- * Validates that the value is of type Boolean.
78920
+ * Validates that the value is a commit timestamp: an int64 (`bigint`)
78921
+ * assigned from the transaction's commit timestamp.
78922
+ *
78923
+ * An index on a field with this validator orders documents by commit order.
78924
+ * Accepts any int64 value; write `db.vars.commitTs` to have the field
78925
+ * resolve to the commit timestamp when the mutation commits.
78926
+ */
78927
+ commitTs: () => {
78928
+ return new VCommitTs({ isOptional: "required" });
78929
+ },
78930
+ /**
78931
+ * Validates that the value is a `boolean`.
78788
78932
  */
78789
78933
  boolean: () => {
78790
78934
  return new VBoolean({ isOptional: "required" });
78791
78935
  },
78792
78936
  /**
78793
- * Validates that the value is of type String.
78937
+ * Validates that the value is a `string`.
78938
+ *
78939
+ * Strings are stored as UTF-8 and their storage size is calculated as their
78940
+ * UTF-8 encoded size.
78794
78941
  */
78795
78942
  string: () => {
78796
78943
  return new VString({ isOptional: "required" });
78797
78944
  },
78798
78945
  /**
78799
- * Validates that the value is of Convex type Bytes (constructed in JS via `ArrayBuffer`).
78946
+ * Validates that the value is an `ArrayBuffer` (Convex Bytes).
78947
+ *
78948
+ * Use for binary data.
78800
78949
  */
78801
78950
  bytes: () => {
78802
78951
  return new VBytes({ isOptional: "required" });
78803
78952
  },
78804
78953
  /**
78805
- * Validates that the value is equal to the given literal value.
78954
+ * Validates that the value is exactly equal to the given literal.
78955
+ *
78956
+ * Useful for discriminated unions and enum-like patterns.
78957
+ *
78958
+ * @example
78959
+ * ```typescript
78960
+ * // Discriminated union pattern:
78961
+ * v.union(
78962
+ * v.object({ kind: v.literal("error"), message: v.string() }),
78963
+ * v.object({ kind: v.literal("success"), value: v.number() }),
78964
+ * )
78965
+ * ```
78966
+ *
78806
78967
  * @param literal The literal value to compare against.
78807
78968
  */
78808
78969
  literal: (literal3) => {
78809
78970
  return new VLiteral({ isOptional: "required", value: literal3 });
78810
78971
  },
78811
78972
  /**
78812
- * Validates that the value is an Array of the given element type.
78973
+ * Validates that the value is an `Array` where every element matches the
78974
+ * given validator.
78975
+ *
78976
+ * Arrays can have at most 8192 elements.
78977
+ *
78978
+ * @example
78979
+ * ```typescript
78980
+ * args: { tags: v.array(v.string()) }
78981
+ * args: { coordinates: v.array(v.number()) }
78982
+ * args: { items: v.array(v.object({ name: v.string(), qty: v.number() })) }
78983
+ * ```
78984
+ *
78813
78985
  * @param element The validator for the elements of the array.
78814
78986
  */
78815
78987
  array: (element) => {
78816
78988
  return new VArray({ isOptional: "required", element });
78817
78989
  },
78818
78990
  /**
78819
- * Validates that the value is an Object with the given properties.
78820
- * @param fields An object specifying the validator for each property.
78991
+ * Validates that the value is an `Object` with the specified properties.
78992
+ *
78993
+ * Objects can have at most 1024 entries. Field names must be non-empty and
78994
+ * must not start with `"$"` or `"_"` (`_` is reserved for system fields
78995
+ * like `_id` and `_creationTime`; `$` is reserved for Convex internal use).
78996
+ *
78997
+ * @example
78998
+ * ```typescript
78999
+ * args: {
79000
+ * user: v.object({
79001
+ * name: v.string(),
79002
+ * email: v.string(),
79003
+ * age: v.optional(v.number()),
79004
+ * })
79005
+ * }
79006
+ * ```
79007
+ *
79008
+ * @param fields An object mapping property names to their validators.
78821
79009
  */
78822
79010
  object: (fields) => {
78823
79011
  return new VObject({ isOptional: "required", fields });
78824
79012
  },
78825
79013
  /**
78826
- * Validates that the value is a Record with keys and values that match the given types.
78827
- * @param keys The validator for the keys of the record. This cannot contain string literals.
79014
+ * Validates that the value is a `Record` (object with dynamic keys).
79015
+ *
79016
+ * Records are objects at runtime but allow dynamic keys, unlike `v.object()`
79017
+ * which requires known property names. Keys must be ASCII characters only,
79018
+ * non-empty, and not start with `"$"` or `"_"`.
79019
+ *
79020
+ * @example
79021
+ * ```typescript
79022
+ * // Map of user IDs to scores:
79023
+ * args: { scores: v.record(v.id("users"), v.number()) }
79024
+ *
79025
+ * // Map of string keys to string values:
79026
+ * args: { metadata: v.record(v.string(), v.string()) }
79027
+ * ```
79028
+ *
79029
+ * @param keys The validator for the keys of the record.
78828
79030
  * @param values The validator for the values of the record.
78829
79031
  */
78830
79032
  record: (keys, values) => {
@@ -78835,7 +79037,23 @@ var init_validator = __esm({
78835
79037
  });
78836
79038
  },
78837
79039
  /**
78838
- * Validates that the value matches one of the given validators.
79040
+ * Validates that the value matches at least one of the given validators.
79041
+ *
79042
+ * @example
79043
+ * ```typescript
79044
+ * // Allow string or number:
79045
+ * args: { value: v.union(v.string(), v.number()) }
79046
+ *
79047
+ * // Discriminated union (recommended pattern):
79048
+ * v.union(
79049
+ * v.object({ kind: v.literal("text"), body: v.string() }),
79050
+ * v.object({ kind: v.literal("image"), url: v.string() }),
79051
+ * )
79052
+ *
79053
+ * // Nullable value:
79054
+ * returns: v.union(v.object({ ... }), v.null())
79055
+ * ```
79056
+ *
78839
79057
  * @param members The validators to match against.
78840
79058
  */
78841
79059
  union: (...members) => {
@@ -78845,27 +79063,55 @@ var init_validator = __esm({
78845
79063
  });
78846
79064
  },
78847
79065
  /**
78848
- * Does not validate the value.
79066
+ * A validator that accepts any Convex value without validation.
79067
+ *
79068
+ * Prefer using specific validators when possible for better type safety
79069
+ * and runtime validation.
78849
79070
  */
78850
79071
  any: () => {
78851
79072
  return new VAny({ isOptional: "required" });
78852
79073
  },
78853
79074
  /**
78854
- * Allows not specifying a value for a property in an Object.
78855
- * @param value The property value validator to make optional.
79075
+ * Makes a property optional in an object validator.
78856
79076
  *
79077
+ * An optional property can be omitted entirely when creating a document or
79078
+ * calling a function. This is different from `v.nullable()` which requires
79079
+ * the property to be present but allows `null`.
79080
+ *
79081
+ * @example
78857
79082
  * ```typescript
78858
- * const objectWithOptionalFields = v.object({
78859
- * requiredField: v.string(),
78860
- * optionalField: v.optional(v.string()),
78861
- * });
79083
+ * v.object({
79084
+ * name: v.string(), // required
79085
+ * nickname: v.optional(v.string()), // can be omitted
79086
+ * })
79087
+ *
79088
+ * // Valid: { name: "Alice" }
79089
+ * // Valid: { name: "Alice", nickname: "Ali" }
79090
+ * // Invalid: { name: "Alice", nickname: null } - use v.nullable() for this
78862
79091
  * ```
79092
+ *
79093
+ * @param value The property value validator to make optional.
78863
79094
  */
78864
79095
  optional: (value) => {
78865
79096
  return value.asOptional();
78866
79097
  },
78867
79098
  /**
78868
- * Allows specifying a value or null.
79099
+ * Allows a value to be either the given type or `null`.
79100
+ *
79101
+ * This is shorthand for `v.union(value, v.null())`. Unlike `v.optional()`,
79102
+ * the property must still be present, but may be `null`.
79103
+ *
79104
+ * @example
79105
+ * ```typescript
79106
+ * v.object({
79107
+ * name: v.string(),
79108
+ * deletedAt: v.nullable(v.number()), // must be present, can be null
79109
+ * })
79110
+ *
79111
+ * // Valid: { name: "Alice", deletedAt: null }
79112
+ * // Valid: { name: "Alice", deletedAt: 1234567890 }
79113
+ * // Invalid: { name: "Alice" } - deletedAt is required
79114
+ * ```
78869
79115
  */
78870
79116
  nullable: (value) => {
78871
79117
  return v.union(value, v.null());
@@ -78911,10 +79157,20 @@ var init_compare_utf8 = __esm({
78911
79157
  var init_compare = __esm({
78912
79158
  "../../node_modules/convex/dist/esm/values/compare.js"() {
78913
79159
  "use strict";
79160
+ init_value();
78914
79161
  init_compare_utf8();
78915
79162
  }
78916
79163
  });
78917
79164
 
79165
+ // ../../node_modules/convex/dist/esm/values/size.js
79166
+ var init_size = __esm({
79167
+ "../../node_modules/convex/dist/esm/values/size.js"() {
79168
+ "use strict";
79169
+ init_value();
79170
+ init_common2();
79171
+ }
79172
+ });
79173
+
78918
79174
  // ../../node_modules/convex/dist/esm/values/index.js
78919
79175
  var init_values = __esm({
78920
79176
  "../../node_modules/convex/dist/esm/values/index.js"() {
@@ -78924,6 +79180,7 @@ var init_values = __esm({
78924
79180
  init_base64();
78925
79181
  init_errors3();
78926
79182
  init_compare();
79183
+ init_size();
78927
79184
  }
78928
79185
  });
78929
79186
 
@@ -78932,7 +79189,7 @@ var version2;
78932
79189
  var init_esm6 = __esm({
78933
79190
  "../../node_modules/convex/dist/esm/index.js"() {
78934
79191
  "use strict";
78935
- version2 = "1.31.6";
79192
+ version2 = "1.48.0";
78936
79193
  }
78937
79194
  });
78938
79195
 
@@ -78989,6 +79246,13 @@ var init_paths2 = __esm({
78989
79246
  }
78990
79247
  });
78991
79248
 
79249
+ // ../../node_modules/convex/dist/esm/server/impl/validate.js
79250
+ var init_validate = __esm({
79251
+ "../../node_modules/convex/dist/esm/server/impl/validate.js"() {
79252
+ "use strict";
79253
+ }
79254
+ });
79255
+
78992
79256
  // ../../node_modules/convex/dist/esm/server/impl/actions_impl.js
78993
79257
  var init_actions_impl = __esm({
78994
79258
  "../../node_modules/convex/dist/esm/server/impl/actions_impl.js"() {
@@ -78998,6 +79262,7 @@ var init_actions_impl = __esm({
78998
79262
  init_syscall();
78999
79263
  init_common2();
79000
79264
  init_paths2();
79265
+ init_validate();
79001
79266
  }
79002
79267
  });
79003
79268
 
@@ -79008,13 +79273,6 @@ var init_vector_search = __esm({
79008
79273
  }
79009
79274
  });
79010
79275
 
79011
- // ../../node_modules/convex/dist/esm/server/impl/validate.js
79012
- var init_validate = __esm({
79013
- "../../node_modules/convex/dist/esm/server/impl/validate.js"() {
79014
- "use strict";
79015
- }
79016
- });
79017
-
79018
79276
  // ../../node_modules/convex/dist/esm/server/impl/vector_search_impl.js
79019
79277
  var init_vector_search_impl = __esm({
79020
79278
  "../../node_modules/convex/dist/esm/server/impl/vector_search_impl.js"() {
@@ -79031,6 +79289,7 @@ var init_vector_search_impl = __esm({
79031
79289
  var init_authentication_impl = __esm({
79032
79290
  "../../node_modules/convex/dist/esm/server/impl/authentication_impl.js"() {
79033
79291
  "use strict";
79292
+ init_esm6();
79034
79293
  init_syscall();
79035
79294
  }
79036
79295
  });
@@ -79129,11 +79388,21 @@ var init_storage_impl = __esm({
79129
79388
  "../../node_modules/convex/dist/esm/server/impl/storage_impl.js"() {
79130
79389
  "use strict";
79131
79390
  init_esm6();
79391
+ init_base64();
79132
79392
  init_syscall();
79133
79393
  init_validate();
79134
79394
  }
79135
79395
  });
79136
79396
 
79397
+ // ../../node_modules/convex/dist/esm/server/impl/meta_impl.js
79398
+ var init_meta_impl = __esm({
79399
+ "../../node_modules/convex/dist/esm/server/impl/meta_impl.js"() {
79400
+ "use strict";
79401
+ init_values();
79402
+ init_syscall();
79403
+ }
79404
+ });
79405
+
79137
79406
  // ../../node_modules/convex/dist/esm/server/impl/registration_impl.js
79138
79407
  var init_registration_impl = __esm({
79139
79408
  "../../node_modules/convex/dist/esm/server/impl/registration_impl.js"() {
@@ -79150,6 +79419,7 @@ var init_registration_impl = __esm({
79150
79419
  init_syscall();
79151
79420
  init_validator();
79152
79421
  init_paths2();
79422
+ init_meta_impl();
79153
79423
  }
79154
79424
  });
79155
79425
 
@@ -79250,6 +79520,7 @@ var init_cron = __esm({
79250
79520
  init_api4();
79251
79521
  init_common2();
79252
79522
  init_values();
79523
+ init_paths2();
79253
79524
  }
79254
79525
  });
79255
79526
 
@@ -79265,14 +79536,53 @@ var init_router = __esm({
79265
79536
  var init_components = __esm({
79266
79537
  "../../node_modules/convex/dist/esm/server/components/index.js"() {
79267
79538
  "use strict";
79268
- init_values();
79269
79539
  init_esm6();
79270
79540
  init_syscall();
79271
79541
  init_paths2();
79542
+ init_validator();
79272
79543
  init_paths2();
79273
79544
  }
79274
79545
  });
79275
79546
 
79547
+ // ../../node_modules/convex/dist/esm/server/logVars.js
79548
+ var REQUEST_ID, IP, USER_AGENT, NOW, CONVEX_ACTOR, varNames;
79549
+ var init_logVars = __esm({
79550
+ "../../node_modules/convex/dist/esm/server/logVars.js"() {
79551
+ "use strict";
79552
+ REQUEST_ID = /* @__PURE__ */ Symbol("var.requestId");
79553
+ IP = /* @__PURE__ */ Symbol("var.ip");
79554
+ USER_AGENT = /* @__PURE__ */ Symbol("var.userAgent");
79555
+ NOW = /* @__PURE__ */ Symbol("var.now");
79556
+ CONVEX_ACTOR = /* @__PURE__ */ Symbol("var.convexActor");
79557
+ varNames = {
79558
+ [REQUEST_ID]: "requestId",
79559
+ [IP]: "ip",
79560
+ [USER_AGENT]: "userAgent",
79561
+ [NOW]: "now",
79562
+ [CONVEX_ACTOR]: "convexActor"
79563
+ };
79564
+ }
79565
+ });
79566
+
79567
+ // ../../node_modules/convex/dist/esm/server/audit_logging.js
79568
+ var init_audit_logging = __esm({
79569
+ "../../node_modules/convex/dist/esm/server/audit_logging.js"() {
79570
+ "use strict";
79571
+ init_esm6();
79572
+ init_syscall();
79573
+ init_logVars();
79574
+ }
79575
+ });
79576
+
79577
+ // ../../node_modules/convex/dist/esm/server/log.js
79578
+ var init_log = __esm({
79579
+ "../../node_modules/convex/dist/esm/server/log.js"() {
79580
+ "use strict";
79581
+ init_audit_logging();
79582
+ init_logVars();
79583
+ }
79584
+ });
79585
+
79276
79586
  // ../../node_modules/convex/dist/esm/server/schema.js
79277
79587
  function defineTable(documentSchema) {
79278
79588
  if (isValidator(documentSchema)) {
@@ -79281,6 +79591,42 @@ function defineTable(documentSchema) {
79281
79591
  return new TableDefinition(v.object(documentSchema));
79282
79592
  }
79283
79593
  }
79594
+ function addSystemFields(tableName, validator) {
79595
+ switch (validator.kind) {
79596
+ case "object":
79597
+ return validator.extend({
79598
+ _id: v.id(tableName),
79599
+ _creationTime: v.number()
79600
+ });
79601
+ case "union":
79602
+ return v.union(
79603
+ ...validator.members.map(
79604
+ (member) => addSystemFields(tableName, member)
79605
+ )
79606
+ );
79607
+ // `v.any()` already permits the system fields.
79608
+ case "any":
79609
+ return validator;
79610
+ default:
79611
+ throw new Error(
79612
+ `Invalid validator for table "${tableName}": a table's documents must be objects, or a union of objects (see https://docs.convex.dev/database/schemas)`
79613
+ );
79614
+ }
79615
+ }
79616
+ function docValidator(tableName, table) {
79617
+ return addSystemFields(tableName, table.validator);
79618
+ }
79619
+ function tableInSchema(schema, tableName) {
79620
+ const table = schema.tables[tableName];
79621
+ if (table === void 0) {
79622
+ throw new Error(
79623
+ `Table "${tableName}" is not in this schema. Tables in this schema: ${Object.keys(
79624
+ schema.tables
79625
+ ).join(", ")}`
79626
+ );
79627
+ }
79628
+ return table;
79629
+ }
79284
79630
  function defineSchema(schema, options) {
79285
79631
  return new SchemaDefinition(schema, options);
79286
79632
  }
@@ -79304,6 +79650,7 @@ var init_schema = __esm({
79304
79650
  __publicField3(this, "vectorIndexes");
79305
79651
  __publicField3(this, "stagedVectorIndexes");
79306
79652
  __publicField3(this, "validator");
79653
+ __publicField3(this, "stagedValidator");
79307
79654
  this.indexes = [];
79308
79655
  this.stagedDbIndexes = [];
79309
79656
  this.searchIndexes = [];
@@ -79317,8 +79664,6 @@ var init_schema = __esm({
79317
79664
  *
79318
79665
  * Returns indexes defined on this table.
79319
79666
  * Intended for the advanced use cases of dynamically deciding which index to use for a query.
79320
- * If you think you need this, please chime in on ths issue in the Convex JS GitHub repo.
79321
- * https://github.com/get-convex/convex-js/issues/49
79322
79667
  */
79323
79668
  " indexes"() {
79324
79669
  return this.indexes;
@@ -79376,6 +79721,60 @@ var init_schema = __esm({
79376
79721
  }
79377
79722
  return this;
79378
79723
  }
79724
+ /**
79725
+ * Stage changes to this table's document validator.
79726
+ *
79727
+ * Convex validates the staged validator against the table's existing
79728
+ * documents in the background, while the validator passed to
79729
+ * {@link defineTable} remains the one enforced on writes. Once
79730
+ * the background validation succeeds, apply the staged changes
79731
+ * and remove `.staged()`.
79732
+ *
79733
+ * For an object validator, pass only the fields to add or replace. Fields
79734
+ * omitted from the changes keep their enforced validators.
79735
+ * Set a field to `undefined` to remove it from the staged validator.
79736
+ * For nested objects, you must specify the full object validator.
79737
+ *
79738
+ * ```ts
79739
+ * defineTable({
79740
+ * apple: v.string(),
79741
+ * banana: v.number(),
79742
+ * legacy: v.optional(v.string()),
79743
+ * }).staged({
79744
+ * banana: v.union(v.string(), v.number()),
79745
+ * legacy: undefined,
79746
+ * })
79747
+ * ```
79748
+ *
79749
+ * See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).
79750
+ *
79751
+ * @param documentSchema - Field changes for a table defined as an object or
79752
+ * `v.any()`, or a full schema validator specifying the proposed next document
79753
+ * type. Use a full schema validator for a table defined as a union.
79754
+ * @returns A {@link TableDefinition} with the staged validator attached.
79755
+ */
79756
+ staged(documentSchema) {
79757
+ if (this.stagedValidator !== void 0) {
79758
+ throw new Error("Table cannot have more than one staged validator.");
79759
+ }
79760
+ if (isValidator(documentSchema)) {
79761
+ this.stagedValidator = documentSchema;
79762
+ } else {
79763
+ if (this.validator.kind !== "object" && this.validator.kind !== "any") {
79764
+ throw new Error(
79765
+ "Specifying top-level field changes is only supported for simple table definitions. For a table defined with a union or record validator, you must stage a fully defined object or union validator."
79766
+ );
79767
+ }
79768
+ const enforcedFields = this.validator.kind === "object" ? this.validator.fields : {};
79769
+ const fields = Object.fromEntries(
79770
+ Object.entries({ ...enforcedFields, ...documentSchema }).filter(
79771
+ (entry) => entry[1] !== void 0
79772
+ )
79773
+ );
79774
+ this.stagedValidator = v.object(fields);
79775
+ }
79776
+ return this.self();
79777
+ }
79379
79778
  /**
79380
79779
  * Work around for https://github.com/microsoft/TypeScript/issues/57035
79381
79780
  */
@@ -79395,6 +79794,15 @@ var init_schema = __esm({
79395
79794
  "Invalid validator: please make sure that the parameter of `defineTable` is valid (see https://docs.convex.dev/database/schemas)"
79396
79795
  );
79397
79796
  }
79797
+ let stagedDocumentType = void 0;
79798
+ if (this.stagedValidator !== void 0) {
79799
+ stagedDocumentType = this.stagedValidator.json;
79800
+ if (typeof stagedDocumentType !== "object") {
79801
+ throw new Error(
79802
+ "Invalid staged validator: please make sure that the parameter of `.staged()` is valid (see https://docs.convex.dev/database/schemas)"
79803
+ );
79804
+ }
79805
+ }
79398
79806
  return {
79399
79807
  indexes: this.indexes,
79400
79808
  stagedDbIndexes: this.stagedDbIndexes,
@@ -79402,7 +79810,8 @@ var init_schema = __esm({
79402
79810
  stagedSearchIndexes: this.stagedSearchIndexes,
79403
79811
  vectorIndexes: this.vectorIndexes,
79404
79812
  stagedVectorIndexes: this.stagedVectorIndexes,
79405
- documentType
79813
+ documentType,
79814
+ stagedDocumentType
79406
79815
  };
79407
79816
  }
79408
79817
  };
@@ -79417,6 +79826,37 @@ var init_schema = __esm({
79417
79826
  this.tables = tables;
79418
79827
  this.schemaValidation = options?.schemaValidation === void 0 ? true : options.schemaValidation;
79419
79828
  }
79829
+ /**
79830
+ * The validator for whole documents of a table in this schema: the table's
79831
+ * own validator with the `_id` and `_creationTime` system fields added.
79832
+ *
79833
+ * @example
79834
+ * ```ts
79835
+ * export const get = query({
79836
+ * args: { id: schema.id("messages") },
79837
+ * returns: v.union(schema.doc("messages"), v.null()),
79838
+ * handler: (ctx, args) => ctx.db.get(args.id),
79839
+ * });
79840
+ * ```
79841
+ *
79842
+ * @param tableName - The name of a table in this schema.
79843
+ * @returns A validator matching documents of that table.
79844
+ */
79845
+ doc(tableName) {
79846
+ return docValidator(tableName, tableInSchema(this, tableName));
79847
+ }
79848
+ /**
79849
+ * The validator for IDs of a table in this schema.
79850
+ *
79851
+ * Same as `v.id(tableName)`, but only accepts tables in this schema.
79852
+ *
79853
+ * @param tableName - The name of a table in this schema.
79854
+ * @returns A validator matching IDs of that table.
79855
+ */
79856
+ id(tableName) {
79857
+ tableInSchema(this, tableName);
79858
+ return v.id(tableName);
79859
+ }
79420
79860
  /**
79421
79861
  * Export the contents of this definition.
79422
79862
  *
@@ -79433,7 +79873,8 @@ var init_schema = __esm({
79433
79873
  stagedSearchIndexes,
79434
79874
  vectorIndexes,
79435
79875
  stagedVectorIndexes,
79436
- documentType
79876
+ documentType,
79877
+ stagedDocumentType
79437
79878
  } = definition.export();
79438
79879
  return {
79439
79880
  tableName,
@@ -79443,7 +79884,8 @@ var init_schema = __esm({
79443
79884
  stagedSearchIndexes,
79444
79885
  vectorIndexes,
79445
79886
  stagedVectorIndexes,
79446
- documentType
79887
+ documentType,
79888
+ stagedDocumentType
79447
79889
  };
79448
79890
  }),
79449
79891
  schemaValidation: this.schemaValidation
@@ -79479,6 +79921,7 @@ var init_server = __esm({
79479
79921
  "use strict";
79480
79922
  init_database();
79481
79923
  init_registration_impl();
79924
+ init_actions_impl();
79482
79925
  init_pagination();
79483
79926
  init_search_filter_builder();
79484
79927
  init_storage();
@@ -79488,6 +79931,7 @@ var init_server = __esm({
79488
79931
  init_components();
79489
79932
  init_components();
79490
79933
  init_components();
79934
+ init_log();
79491
79935
  init_schema();
79492
79936
  }
79493
79937
  });
@@ -83687,7 +84131,7 @@ var init_local_state = __esm({
83687
84131
  queryJournal(queryToken) {
83688
84132
  return this.querySet.get(queryToken)?.journal;
83689
84133
  }
83690
- restart(oldRemoteQueryResults) {
84134
+ restart() {
83691
84135
  this.unpause();
83692
84136
  this.outstandingQueriesOlderThanRestart.clear();
83693
84137
  const modifications = [];
@@ -83701,9 +84145,7 @@ var init_local_state = __esm({
83701
84145
  componentPath: localQuery.componentPath
83702
84146
  };
83703
84147
  modifications.push(add);
83704
- if (!oldRemoteQueryResults.has(localQuery.id)) {
83705
- this.outstandingQueriesOlderThanRestart.add(localQuery.id);
83706
- }
84148
+ this.outstandingQueriesOlderThanRestart.add(localQuery.id);
83707
84149
  }
83708
84150
  this.querySetVersion = 1;
83709
84151
  const querySet = {
@@ -84976,6 +85418,7 @@ var init_web_socket_manager = __esm({
84976
85418
  case "ready":
84977
85419
  if (this.socket.paused === "uninitialized") {
84978
85420
  this.socket = { ...this.socket, paused: "no" };
85421
+ this._hasEverConnected = true;
84979
85422
  this.onOpen({
84980
85423
  connectionCount: this.connectionCount,
84981
85424
  lastCloseReason: this.lastCloseReason,
@@ -85165,6 +85608,8 @@ var init_authentication_manager = __esm({
85165
85608
  __publicField11(this, "clearAuth");
85166
85609
  __publicField11(this, "logger");
85167
85610
  __publicField11(this, "refreshTokenLeewaySeconds");
85611
+ __publicField11(this, "initialAuthTokenReuse");
85612
+ __publicField11(this, "lastRefreshChange");
85168
85613
  __publicField11(this, "tokenConfirmationAttempts", 0);
85169
85614
  this.syncState = syncState;
85170
85615
  this.authenticate = callbacks.authenticate;
@@ -85175,8 +85620,16 @@ var init_authentication_manager = __esm({
85175
85620
  this.clearAuth = callbacks.clearAuth;
85176
85621
  this.logger = config5.logger;
85177
85622
  this.refreshTokenLeewaySeconds = config5.refreshTokenLeewaySeconds;
85623
+ this.initialAuthTokenReuse = config5.initialAuthTokenReuse;
85624
+ this.lastRefreshChange = false;
85625
+ }
85626
+ notifyRefreshChange(isRefreshing) {
85627
+ if (this.authState.state !== "noAuth" && this.authState.state !== "initialRefetch" && this.authState.config.onRefreshChange && this.lastRefreshChange !== isRefreshing) {
85628
+ this.lastRefreshChange = isRefreshing;
85629
+ this.authState.config.onRefreshChange(isRefreshing);
85630
+ }
85178
85631
  }
85179
- async setConfig(fetchToken2, onChange) {
85632
+ async setConfig(fetchToken2, onChange, onRefreshChange) {
85180
85633
  this.resetAuthState();
85181
85634
  this._logVerbose("pausing WS for auth token fetch");
85182
85635
  this.pauseSocket();
@@ -85186,17 +85639,22 @@ var init_authentication_manager = __esm({
85186
85639
  if (token.isFromOutdatedConfig) {
85187
85640
  return;
85188
85641
  }
85642
+ const config5 = {
85643
+ fetchToken: fetchToken2,
85644
+ onAuthChange: onChange,
85645
+ onRefreshChange
85646
+ };
85189
85647
  if (token.value) {
85190
85648
  this.setAuthState({
85191
85649
  state: "waitingForServerConfirmationOfCachedToken",
85192
- config: { fetchToken: fetchToken2, onAuthChange: onChange },
85650
+ config: config5,
85193
85651
  hasRetried: false
85194
85652
  });
85195
85653
  this.authenticate(token.value);
85196
85654
  } else {
85197
85655
  this.setAuthState({
85198
85656
  state: "initialRefetch",
85199
- config: { fetchToken: fetchToken2, onAuthChange: onChange }
85657
+ config: config5
85200
85658
  });
85201
85659
  await this.refetchToken();
85202
85660
  }
@@ -85212,14 +85670,24 @@ var init_authentication_manager = __esm({
85212
85670
  if (serverMessage.endVersion.identity <= serverMessage.startVersion.identity) {
85213
85671
  return;
85214
85672
  }
85673
+ this._logVerbose(
85674
+ `auth state is ${this.authState.state} when handling transition`
85675
+ );
85676
+ this.syncState.markAuthCompletion();
85215
85677
  if (this.authState.state === "waitingForServerConfirmationOfCachedToken") {
85216
85678
  this._logVerbose("server confirmed auth token is valid");
85217
- void this.refetchToken();
85679
+ const cachedToken = this.syncState.getAuth()?.value;
85680
+ if (this.initialAuthTokenReuse && cachedToken) {
85681
+ this.scheduleTokenRefetch(cachedToken, serverMessage.clientClockSkew);
85682
+ } else {
85683
+ void this.refetchToken();
85684
+ }
85218
85685
  this.authState.config.onAuthChange(true);
85219
85686
  return;
85220
85687
  }
85221
85688
  if (this.authState.state === "waitingForServerConfirmationOfFreshToken") {
85222
85689
  this._logVerbose("server confirmed new auth token is valid");
85690
+ this.notifyRefreshChange(false);
85223
85691
  this.scheduleTokenRefetch(this.authState.token);
85224
85692
  this.tokenConfirmationAttempts = 0;
85225
85693
  if (!this.authState.hadAuth) {
@@ -85269,7 +85737,11 @@ var init_authentication_manager = __esm({
85269
85737
  `retrying reauthentication, ${MAX_TOKEN_CONFIRMATION_ATTEMPTS - this.tokenConfirmationAttempts} attempts remaining`
85270
85738
  );
85271
85739
  }
85740
+ this.notifyRefreshChange(true);
85272
85741
  await this.stopSocket();
85742
+ if (this.authState.state === "noAuth") {
85743
+ return;
85744
+ }
85273
85745
  const token = await this.fetchTokenAndGuardAgainstRace(
85274
85746
  this.authState.config.fetchToken,
85275
85747
  {
@@ -85340,7 +85812,7 @@ var init_authentication_manager = __esm({
85340
85812
  );
85341
85813
  this.tryRestartSocket();
85342
85814
  }
85343
- scheduleTokenRefetch(token) {
85815
+ scheduleTokenRefetch(token, clientClockSkewMs) {
85344
85816
  if (this.authState.state === "noAuth") {
85345
85817
  return;
85346
85818
  }
@@ -85358,13 +85830,23 @@ var init_authentication_manager = __esm({
85358
85830
  );
85359
85831
  return;
85360
85832
  }
85361
- const tokenValiditySeconds = exp - iat;
85362
- if (tokenValiditySeconds <= 2) {
85833
+ const fullLifetimeSeconds = exp - iat;
85834
+ if (fullLifetimeSeconds <= 2) {
85363
85835
  this.logger.error(
85364
85836
  "Auth token does not live long enough, cannot refetch the token"
85365
85837
  );
85366
85838
  return;
85367
85839
  }
85840
+ let tokenValiditySeconds;
85841
+ if (clientClockSkewMs !== void 0) {
85842
+ const estimatedServerNowSeconds = (Date.now() - clientClockSkewMs) / 1e3;
85843
+ tokenValiditySeconds = exp - estimatedServerNowSeconds;
85844
+ if (tokenValiditySeconds <= 0) {
85845
+ tokenValiditySeconds = 0;
85846
+ }
85847
+ } else {
85848
+ tokenValiditySeconds = fullLifetimeSeconds;
85849
+ }
85368
85850
  let delay7 = Math.min(
85369
85851
  MAXIMUM_REFRESH_DELAY,
85370
85852
  (tokenValiditySeconds - this.refreshTokenLeewaySeconds) * 1e3
@@ -85413,7 +85895,11 @@ var init_authentication_manager = __esm({
85413
85895
  onAuthChange(false);
85414
85896
  this.resetAuthState();
85415
85897
  }
85898
+ // The sole path to `state === "noAuth"`; consumers rely on this firing
85899
+ // `notifyRefreshChange(false)` to pair any in-flight `(true)`. May run
85900
+ // when refresh state is already false.
85416
85901
  resetAuthState() {
85902
+ this.notifyRefreshChange(false);
85417
85903
  this.setAuthState({ state: "noAuth" });
85418
85904
  }
85419
85905
  setAuthState(newAuth) {
@@ -85441,7 +85927,6 @@ var init_authentication_manager = __esm({
85441
85927
  }
85442
85928
  if (this.authState.state === "waitingForScheduledRefetch") {
85443
85929
  clearTimeout(this.authState.refetchTokenTimeoutId);
85444
- this.syncState.markAuthCompletion();
85445
85930
  }
85446
85931
  this.authState = newAuth;
85447
85932
  }
@@ -85575,7 +86060,7 @@ var init_client3 = __esm({
85575
86060
  validateDeploymentUrl(address);
85576
86061
  }
85577
86062
  options = { ...options };
85578
- const authRefreshTokenLeewaySeconds = options.authRefreshTokenLeewaySeconds ?? 2;
86063
+ const authRefreshTokenLeewaySeconds = options.authRefreshTokenLeewaySeconds ?? 10;
85579
86064
  let webSocketConstructor = options.webSocketConstructor;
85580
86065
  if (!webSocketConstructor && typeof WebSocket === "undefined") {
85581
86066
  throw new Error(
@@ -85632,7 +86117,8 @@ var init_client3 = __esm({
85632
86117
  },
85633
86118
  {
85634
86119
  logger: this.logger,
85635
- refreshTokenLeewaySeconds: authRefreshTokenLeewaySeconds
86120
+ refreshTokenLeewaySeconds: authRefreshTokenLeewaySeconds,
86121
+ initialAuthTokenReuse: options.initialAuthTokenReuse ?? false
85636
86122
  }
85637
86123
  );
85638
86124
  this.optimisticQueryResults = new OptimisticQueryResults();
@@ -85669,16 +86155,11 @@ var init_client3 = __esm({
85669
86155
  sessionId: this._sessionId,
85670
86156
  maxObservedTimestamp: this.maxObservedTimestamp
85671
86157
  });
85672
- const oldRemoteQueryResults = new Set(
85673
- this.remoteQuerySet.remoteQueryResults().keys()
85674
- );
85675
86158
  this.remoteQuerySet = new RemoteQuerySet(
85676
86159
  (queryId) => this.state.queryPath(queryId),
85677
86160
  this.logger
85678
86161
  );
85679
- const [querySetModification, authModification] = this.state.restart(
85680
- oldRemoteQueryResults
85681
- );
86162
+ const [querySetModification, authModification] = this.state.restart();
85682
86163
  if (authModification) {
85683
86164
  this.webSocketManager.sendMessage(authModification);
85684
86165
  }
@@ -85773,7 +86254,7 @@ var init_client3 = __esm({
85773
86254
  * potentially led to the restart. Use this to influence when to reset backoff after a failure.
85774
86255
  */
85775
86256
  hasSyncedPastLastReconnect() {
85776
- const hasSyncedPastLastReconnect = this.requestManager.hasSyncedPastLastReconnect() || this.state.hasSyncedPastLastReconnect();
86257
+ const hasSyncedPastLastReconnect = this.requestManager.hasSyncedPastLastReconnect() && this.state.hasSyncedPastLastReconnect();
85777
86258
  return hasSyncedPastLastReconnect;
85778
86259
  }
85779
86260
  observedTimestamp(observedTs) {
@@ -85873,9 +86354,14 @@ var init_client3 = __esm({
85873
86354
  * when the user's rights were permanently revoked.
85874
86355
  * @param fetchToken - an async function returning the JWT-encoded OpenID Connect Identity Token
85875
86356
  * @param onChange - a callback that will be called when the authentication status changes
86357
+ * @param onRefreshChange - a callback called with `true` when the socket is paused to fetch a replacement token after a server rejection, and `false` when refresh completes
85876
86358
  */
85877
- setAuth(fetchToken2, onChange) {
85878
- void this.authenticationManager.setConfig(fetchToken2, onChange);
86359
+ setAuth(fetchToken2, onChange, onRefreshChange) {
86360
+ void this.authenticationManager.setConfig(
86361
+ fetchToken2,
86362
+ onChange,
86363
+ onRefreshChange
86364
+ );
85879
86365
  }
85880
86366
  hasAuth() {
85881
86367
  return this.state.hasAuth();
@@ -86229,470 +86715,6 @@ var init_client3 = __esm({
86229
86715
  }
86230
86716
  });
86231
86717
 
86232
- // ../../node_modules/convex/dist/esm/browser/http_client.js
86233
- function forwardErrorData(errorData, error55) {
86234
- error55.data = jsonToConvex(errorData);
86235
- return error55;
86236
- }
86237
- var __defProp15, __defNormalProp13, __publicField13, STATUS_CODE_UDF_FAILED, specifiedFetch, ConvexHttpClient;
86238
- var init_http_client = __esm({
86239
- "../../node_modules/convex/dist/esm/browser/http_client.js"() {
86240
- "use strict";
86241
- init_api4();
86242
- init_common2();
86243
- init_esm6();
86244
- init_values();
86245
- init_logging();
86246
- __defProp15 = Object.defineProperty;
86247
- __defNormalProp13 = (obj, key, value) => key in obj ? __defProp15(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86248
- __publicField13 = (obj, key, value) => __defNormalProp13(obj, typeof key !== "symbol" ? key + "" : key, value);
86249
- STATUS_CODE_UDF_FAILED = 560;
86250
- specifiedFetch = void 0;
86251
- ConvexHttpClient = class {
86252
- /**
86253
- * Create a new {@link ConvexHttpClient}.
86254
- *
86255
- * @param address - The url of your Convex deployment, often provided
86256
- * by an environment variable. E.g. `https://small-mouse-123.convex.cloud`.
86257
- * @param options - An object of options.
86258
- * - `skipConvexDeploymentUrlCheck` - Skip validating that the Convex deployment URL looks like
86259
- * `https://happy-animal-123.convex.cloud` or localhost. This can be useful if running a self-hosted
86260
- * Convex backend that uses a different URL.
86261
- * - `logger` - A logger or a boolean. If not provided, logs to the console.
86262
- * You can construct your own logger to customize logging to log elsewhere
86263
- * or not log at all, or use `false` as a shorthand for a no-op logger.
86264
- * A logger is an object with 4 methods: log(), warn(), error(), and logVerbose().
86265
- * These methods can receive multiple arguments of any types, like console.log().
86266
- * - `auth` - A JWT containing identity claims accessible in Convex functions.
86267
- * This identity may expire so it may be necessary to call `setAuth()` later,
86268
- * but for short-lived clients it's convenient to specify this value here.
86269
- * - `fetch` - A custom fetch implementation to use for all HTTP requests made by this client.
86270
- */
86271
- constructor(address, options) {
86272
- __publicField13(this, "address");
86273
- __publicField13(this, "auth");
86274
- __publicField13(this, "adminAuth");
86275
- __publicField13(this, "encodedTsPromise");
86276
- __publicField13(this, "debug");
86277
- __publicField13(this, "fetchOptions");
86278
- __publicField13(this, "fetch");
86279
- __publicField13(this, "logger");
86280
- __publicField13(this, "mutationQueue", []);
86281
- __publicField13(this, "isProcessingQueue", false);
86282
- if (typeof options === "boolean") {
86283
- throw new Error(
86284
- "skipConvexDeploymentUrlCheck as the second argument is no longer supported. Please pass an options object, `{ skipConvexDeploymentUrlCheck: true }`."
86285
- );
86286
- }
86287
- const opts = options ?? {};
86288
- if (opts.skipConvexDeploymentUrlCheck !== true) {
86289
- validateDeploymentUrl(address);
86290
- }
86291
- this.logger = options?.logger === false ? instantiateNoopLogger({ verbose: false }) : options?.logger !== true && options?.logger ? options.logger : instantiateDefaultLogger({ verbose: false });
86292
- this.address = address;
86293
- this.debug = true;
86294
- this.auth = void 0;
86295
- this.adminAuth = void 0;
86296
- this.fetch = options?.fetch;
86297
- if (options?.auth) {
86298
- this.setAuth(options.auth);
86299
- }
86300
- }
86301
- /**
86302
- * Obtain the {@link ConvexHttpClient}'s URL to its backend.
86303
- * @deprecated Use url, which returns the url without /api at the end.
86304
- *
86305
- * @returns The URL to the Convex backend, including the client's API version.
86306
- */
86307
- backendUrl() {
86308
- return `${this.address}/api`;
86309
- }
86310
- /**
86311
- * Return the address for this client, useful for creating a new client.
86312
- *
86313
- * Not guaranteed to match the address with which this client was constructed:
86314
- * it may be canonicalized.
86315
- */
86316
- get url() {
86317
- return this.address;
86318
- }
86319
- /**
86320
- * Set the authentication token to be used for subsequent queries and mutations.
86321
- *
86322
- * Should be called whenever the token changes (i.e. due to expiration and refresh).
86323
- *
86324
- * @param value - JWT-encoded OpenID Connect identity token.
86325
- */
86326
- setAuth(value) {
86327
- this.clearAuth();
86328
- this.auth = value;
86329
- }
86330
- /**
86331
- * Set admin auth token to allow calling internal queries, mutations, and actions
86332
- * and acting as an identity.
86333
- *
86334
- * @internal
86335
- */
86336
- setAdminAuth(token, actingAsIdentity) {
86337
- this.clearAuth();
86338
- if (actingAsIdentity !== void 0) {
86339
- const bytes = new TextEncoder().encode(JSON.stringify(actingAsIdentity));
86340
- const actingAsIdentityEncoded = btoa(String.fromCodePoint(...bytes));
86341
- this.adminAuth = `${token}:${actingAsIdentityEncoded}`;
86342
- } else {
86343
- this.adminAuth = token;
86344
- }
86345
- }
86346
- /**
86347
- * Clear the current authentication token if set.
86348
- */
86349
- clearAuth() {
86350
- this.auth = void 0;
86351
- this.adminAuth = void 0;
86352
- }
86353
- /**
86354
- * Sets whether the result log lines should be printed on the console or not.
86355
- *
86356
- * @internal
86357
- */
86358
- setDebug(debug4) {
86359
- this.debug = debug4;
86360
- }
86361
- /**
86362
- * Used to customize the fetch behavior in some runtimes.
86363
- *
86364
- * @internal
86365
- */
86366
- setFetchOptions(fetchOptions) {
86367
- this.fetchOptions = fetchOptions;
86368
- }
86369
- /**
86370
- * This API is experimental: it may change or disappear.
86371
- *
86372
- * Execute a Convex query function at the same timestamp as every other
86373
- * consistent query execution run by this HTTP client.
86374
- *
86375
- * This doesn't make sense for long-lived ConvexHttpClients as Convex
86376
- * backends can read a limited amount into the past: beyond 30 seconds
86377
- * in the past may not be available.
86378
- *
86379
- * Create a new client to use a consistent time.
86380
- *
86381
- * @param name - The name of the query.
86382
- * @param args - The arguments object for the query. If this is omitted,
86383
- * the arguments will be `{}`.
86384
- * @returns A promise of the query's result.
86385
- *
86386
- * @deprecated This API is experimental: it may change or disappear.
86387
- */
86388
- async consistentQuery(query2, ...args) {
86389
- const queryArgs = parseArgs(args[0]);
86390
- const timestampPromise = this.getTimestamp();
86391
- return await this.queryInner(query2, queryArgs, { timestampPromise });
86392
- }
86393
- async getTimestamp() {
86394
- if (this.encodedTsPromise) {
86395
- return this.encodedTsPromise;
86396
- }
86397
- return this.encodedTsPromise = this.getTimestampInner();
86398
- }
86399
- async getTimestampInner() {
86400
- const localFetch = this.fetch || specifiedFetch || fetch;
86401
- const headers = {
86402
- "Content-Type": "application/json",
86403
- "Convex-Client": `npm-${version2}`
86404
- };
86405
- const response = await localFetch(`${this.address}/api/query_ts`, {
86406
- ...this.fetchOptions,
86407
- method: "POST",
86408
- headers
86409
- });
86410
- if (!response.ok) {
86411
- throw new Error(await response.text());
86412
- }
86413
- const { ts } = await response.json();
86414
- return ts;
86415
- }
86416
- /**
86417
- * Execute a Convex query function.
86418
- *
86419
- * @param name - The name of the query.
86420
- * @param args - The arguments object for the query. If this is omitted,
86421
- * the arguments will be `{}`.
86422
- * @returns A promise of the query's result.
86423
- */
86424
- async query(query2, ...args) {
86425
- const queryArgs = parseArgs(args[0]);
86426
- return await this.queryInner(query2, queryArgs, {});
86427
- }
86428
- async queryInner(query2, queryArgs, options) {
86429
- const name = getFunctionName2(query2);
86430
- const args = [convexToJson(queryArgs)];
86431
- const headers = {
86432
- "Content-Type": "application/json",
86433
- "Convex-Client": `npm-${version2}`
86434
- };
86435
- if (this.adminAuth) {
86436
- headers["Authorization"] = `Convex ${this.adminAuth}`;
86437
- } else if (this.auth) {
86438
- headers["Authorization"] = `Bearer ${this.auth}`;
86439
- }
86440
- const localFetch = this.fetch || specifiedFetch || fetch;
86441
- const timestamp2 = options.timestampPromise ? await options.timestampPromise : void 0;
86442
- const body = JSON.stringify({
86443
- path: name,
86444
- format: "convex_encoded_json",
86445
- args,
86446
- ...timestamp2 ? { ts: timestamp2 } : {}
86447
- });
86448
- const endpoint = timestamp2 ? `${this.address}/api/query_at_ts` : `${this.address}/api/query`;
86449
- const response = await localFetch(endpoint, {
86450
- ...this.fetchOptions,
86451
- body,
86452
- method: "POST",
86453
- headers
86454
- });
86455
- if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
86456
- throw new Error(await response.text());
86457
- }
86458
- const respJSON = await response.json();
86459
- if (this.debug) {
86460
- for (const line of respJSON.logLines ?? []) {
86461
- logForFunction(this.logger, "info", "query", name, line);
86462
- }
86463
- }
86464
- switch (respJSON.status) {
86465
- case "success":
86466
- return jsonToConvex(respJSON.value);
86467
- case "error":
86468
- if (respJSON.errorData !== void 0) {
86469
- throw forwardErrorData(
86470
- respJSON.errorData,
86471
- new ConvexError(respJSON.errorMessage)
86472
- );
86473
- }
86474
- throw new Error(respJSON.errorMessage);
86475
- default:
86476
- throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
86477
- }
86478
- }
86479
- async mutationInner(mutation2, mutationArgs) {
86480
- const name = getFunctionName2(mutation2);
86481
- const body = JSON.stringify({
86482
- path: name,
86483
- format: "convex_encoded_json",
86484
- args: [convexToJson(mutationArgs)]
86485
- });
86486
- const headers = {
86487
- "Content-Type": "application/json",
86488
- "Convex-Client": `npm-${version2}`
86489
- };
86490
- if (this.adminAuth) {
86491
- headers["Authorization"] = `Convex ${this.adminAuth}`;
86492
- } else if (this.auth) {
86493
- headers["Authorization"] = `Bearer ${this.auth}`;
86494
- }
86495
- const localFetch = this.fetch || specifiedFetch || fetch;
86496
- const response = await localFetch(`${this.address}/api/mutation`, {
86497
- ...this.fetchOptions,
86498
- body,
86499
- method: "POST",
86500
- headers
86501
- });
86502
- if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
86503
- throw new Error(await response.text());
86504
- }
86505
- const respJSON = await response.json();
86506
- if (this.debug) {
86507
- for (const line of respJSON.logLines ?? []) {
86508
- logForFunction(this.logger, "info", "mutation", name, line);
86509
- }
86510
- }
86511
- switch (respJSON.status) {
86512
- case "success":
86513
- return jsonToConvex(respJSON.value);
86514
- case "error":
86515
- if (respJSON.errorData !== void 0) {
86516
- throw forwardErrorData(
86517
- respJSON.errorData,
86518
- new ConvexError(respJSON.errorMessage)
86519
- );
86520
- }
86521
- throw new Error(respJSON.errorMessage);
86522
- default:
86523
- throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
86524
- }
86525
- }
86526
- async processMutationQueue() {
86527
- if (this.isProcessingQueue) {
86528
- return;
86529
- }
86530
- this.isProcessingQueue = true;
86531
- while (this.mutationQueue.length > 0) {
86532
- const { mutation: mutation2, args, resolve: resolve3, reject } = this.mutationQueue.shift();
86533
- try {
86534
- const result = await this.mutationInner(mutation2, args);
86535
- resolve3(result);
86536
- } catch (error55) {
86537
- reject(error55);
86538
- }
86539
- }
86540
- this.isProcessingQueue = false;
86541
- }
86542
- enqueueMutation(mutation2, args) {
86543
- return new Promise((resolve3, reject) => {
86544
- this.mutationQueue.push({ mutation: mutation2, args, resolve: resolve3, reject });
86545
- void this.processMutationQueue();
86546
- });
86547
- }
86548
- /**
86549
- * Execute a Convex mutation function. Mutations are queued by default.
86550
- *
86551
- * @param name - The name of the mutation.
86552
- * @param args - The arguments object for the mutation. If this is omitted,
86553
- * the arguments will be `{}`.
86554
- * @param options - An optional object containing
86555
- * @returns A promise of the mutation's result.
86556
- */
86557
- async mutation(mutation2, ...args) {
86558
- const [fnArgs, options] = args;
86559
- const mutationArgs = parseArgs(fnArgs);
86560
- const queued = !options?.skipQueue;
86561
- if (queued) {
86562
- return await this.enqueueMutation(mutation2, mutationArgs);
86563
- } else {
86564
- return await this.mutationInner(mutation2, mutationArgs);
86565
- }
86566
- }
86567
- /**
86568
- * Execute a Convex action function. Actions are not queued.
86569
- *
86570
- * @param name - The name of the action.
86571
- * @param args - The arguments object for the action. If this is omitted,
86572
- * the arguments will be `{}`.
86573
- * @returns A promise of the action's result.
86574
- */
86575
- async action(action, ...args) {
86576
- const actionArgs = parseArgs(args[0]);
86577
- const name = getFunctionName2(action);
86578
- const body = JSON.stringify({
86579
- path: name,
86580
- format: "convex_encoded_json",
86581
- args: [convexToJson(actionArgs)]
86582
- });
86583
- const headers = {
86584
- "Content-Type": "application/json",
86585
- "Convex-Client": `npm-${version2}`
86586
- };
86587
- if (this.adminAuth) {
86588
- headers["Authorization"] = `Convex ${this.adminAuth}`;
86589
- } else if (this.auth) {
86590
- headers["Authorization"] = `Bearer ${this.auth}`;
86591
- }
86592
- const localFetch = this.fetch || specifiedFetch || fetch;
86593
- const response = await localFetch(`${this.address}/api/action`, {
86594
- ...this.fetchOptions,
86595
- body,
86596
- method: "POST",
86597
- headers
86598
- });
86599
- if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
86600
- throw new Error(await response.text());
86601
- }
86602
- const respJSON = await response.json();
86603
- if (this.debug) {
86604
- for (const line of respJSON.logLines ?? []) {
86605
- logForFunction(this.logger, "info", "action", name, line);
86606
- }
86607
- }
86608
- switch (respJSON.status) {
86609
- case "success":
86610
- return jsonToConvex(respJSON.value);
86611
- case "error":
86612
- if (respJSON.errorData !== void 0) {
86613
- throw forwardErrorData(
86614
- respJSON.errorData,
86615
- new ConvexError(respJSON.errorMessage)
86616
- );
86617
- }
86618
- throw new Error(respJSON.errorMessage);
86619
- default:
86620
- throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
86621
- }
86622
- }
86623
- /**
86624
- * Execute a Convex function of an unknown type. These function calls are not queued.
86625
- *
86626
- * @param name - The name of the function.
86627
- * @param args - The arguments object for the function. If this is omitted,
86628
- * the arguments will be `{}`.
86629
- * @returns A promise of the function's result.
86630
- *
86631
- * @internal
86632
- */
86633
- async function(anyFunction, componentPath, ...args) {
86634
- const functionArgs = parseArgs(args[0]);
86635
- const name = typeof anyFunction === "string" ? anyFunction : getFunctionName2(anyFunction);
86636
- const body = JSON.stringify({
86637
- componentPath,
86638
- path: name,
86639
- format: "convex_encoded_json",
86640
- args: convexToJson(functionArgs)
86641
- });
86642
- const headers = {
86643
- "Content-Type": "application/json",
86644
- "Convex-Client": `npm-${version2}`
86645
- };
86646
- if (this.adminAuth) {
86647
- headers["Authorization"] = `Convex ${this.adminAuth}`;
86648
- } else if (this.auth) {
86649
- headers["Authorization"] = `Bearer ${this.auth}`;
86650
- }
86651
- const localFetch = this.fetch || specifiedFetch || fetch;
86652
- const response = await localFetch(`${this.address}/api/function`, {
86653
- ...this.fetchOptions,
86654
- body,
86655
- method: "POST",
86656
- headers
86657
- });
86658
- if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
86659
- throw new Error(await response.text());
86660
- }
86661
- const respJSON = await response.json();
86662
- if (this.debug) {
86663
- for (const line of respJSON.logLines ?? []) {
86664
- logForFunction(this.logger, "info", "any", name, line);
86665
- }
86666
- }
86667
- switch (respJSON.status) {
86668
- case "success":
86669
- return jsonToConvex(respJSON.value);
86670
- case "error":
86671
- if (respJSON.errorData !== void 0) {
86672
- throw forwardErrorData(
86673
- respJSON.errorData,
86674
- new ConvexError(respJSON.errorMessage)
86675
- );
86676
- }
86677
- throw new Error(respJSON.errorMessage);
86678
- default:
86679
- throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
86680
- }
86681
- }
86682
- };
86683
- }
86684
- });
86685
-
86686
- // ../../node_modules/convex/dist/esm/browser/index.js
86687
- var init_browser2 = __esm({
86688
- "../../node_modules/convex/dist/esm/browser/index.js"() {
86689
- "use strict";
86690
- init_client3();
86691
- init_simple_client();
86692
- init_http_client();
86693
- }
86694
- });
86695
-
86696
86718
  // ../../node_modules/convex/dist/esm/browser/sync/pagination.js
86697
86719
  function asPaginationResult(value) {
86698
86720
  if (typeof value !== "object" || value === null || !Array.isArray(value.page) || typeof value.isDone !== "boolean" || typeof value.continueCursor !== "string") {
@@ -86707,22 +86729,22 @@ var init_pagination2 = __esm({
86707
86729
  });
86708
86730
 
86709
86731
  // ../../node_modules/convex/dist/esm/browser/sync/paginated_query_client.js
86710
- var __defProp16, __defNormalProp14, __publicField14, PaginatedQueryClient;
86732
+ var __defProp15, __defNormalProp13, __publicField13, PaginatedQueryClient;
86711
86733
  var init_paginated_query_client = __esm({
86712
86734
  "../../node_modules/convex/dist/esm/browser/sync/paginated_query_client.js"() {
86713
86735
  "use strict";
86714
86736
  init_udf_path_utils();
86715
86737
  init_pagination2();
86716
86738
  init_long();
86717
- __defProp16 = Object.defineProperty;
86718
- __defNormalProp14 = (obj, key, value) => key in obj ? __defProp16(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86719
- __publicField14 = (obj, key, value) => __defNormalProp14(obj, typeof key !== "symbol" ? key + "" : key, value);
86739
+ __defProp15 = Object.defineProperty;
86740
+ __defNormalProp13 = (obj, key, value) => key in obj ? __defProp15(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86741
+ __publicField13 = (obj, key, value) => __defNormalProp13(obj, typeof key !== "symbol" ? key + "" : key, value);
86720
86742
  PaginatedQueryClient = class {
86721
86743
  constructor(client, onTransition) {
86722
86744
  this.client = client;
86723
86745
  this.onTransition = onTransition;
86724
- __publicField14(this, "paginatedQuerySet", /* @__PURE__ */ new Map());
86725
- __publicField14(this, "lastTransitionTs");
86746
+ __publicField13(this, "paginatedQuerySet", /* @__PURE__ */ new Map());
86747
+ __publicField13(this, "lastTransitionTs");
86726
86748
  this.lastTransitionTs = Long.fromNumber(0);
86727
86749
  this.client.addOnTransitionHandler(
86728
86750
  (transition) => this.onBaseTransition(transition)
@@ -86941,8 +86963,11 @@ var init_paginated_query_client = __esm({
86941
86963
  if (ongoingSplits.has(pageKey)) {
86942
86964
  continue;
86943
86965
  }
86944
- const pageToken = pageKeyToQuery.get(pageKey).queryToken;
86945
- const pageResult = getResult(pageToken);
86966
+ const pageEntry = pageKeyToQuery.get(pageKey);
86967
+ if (!pageEntry) {
86968
+ throw new Error(`No page query for active pageKey ${pageKey}`);
86969
+ }
86970
+ const pageResult = getResult(pageEntry.queryToken);
86946
86971
  if (!pageResult) {
86947
86972
  continue;
86948
86973
  }
@@ -86953,6 +86978,7 @@ var init_paginated_query_client = __esm({
86953
86978
  this.splitPaginatedQueryPage(
86954
86979
  paginatedQuery,
86955
86980
  pageKey,
86981
+ pageEntry.cursor,
86956
86982
  result.splitCursor,
86957
86983
  // we just checked
86958
86984
  result.continueCursor
@@ -86961,11 +86987,10 @@ var init_paginated_query_client = __esm({
86961
86987
  }
86962
86988
  }
86963
86989
  }
86964
- splitPaginatedQueryPage(paginatedQuery, pageKey, splitCursor, continueCursor) {
86990
+ splitPaginatedQueryPage(paginatedQuery, pageKey, startCursor, splitCursor, continueCursor) {
86965
86991
  const splitKey1 = paginatedQuery.nextPageKey++;
86966
86992
  const splitKey2 = paginatedQuery.nextPageKey++;
86967
86993
  const paginationOpts = {
86968
- cursor: continueCursor,
86969
86994
  numItems: paginatedQuery.options.initialNumItems,
86970
86995
  id: paginatedQuery.id
86971
86996
  };
@@ -86975,13 +87000,15 @@ var init_paginated_query_client = __esm({
86975
87000
  ...paginatedQuery.args,
86976
87001
  paginationOpts: {
86977
87002
  ...paginationOpts,
86978
- cursor: null,
86979
- // Start from beginning for first split
87003
+ cursor: startCursor,
86980
87004
  endCursor: splitCursor
86981
87005
  }
86982
87006
  }
86983
87007
  );
86984
- paginatedQuery.pageKeyToQuery.set(splitKey1, firstSubscription);
87008
+ paginatedQuery.pageKeyToQuery.set(splitKey1, {
87009
+ ...firstSubscription,
87010
+ cursor: startCursor
87011
+ });
86985
87012
  const secondSubscription = this.client.subscribe(
86986
87013
  paginatedQuery.canonicalizedUdfPath,
86987
87014
  {
@@ -86993,7 +87020,10 @@ var init_paginated_query_client = __esm({
86993
87020
  }
86994
87021
  }
86995
87022
  );
86996
- paginatedQuery.pageKeyToQuery.set(splitKey2, secondSubscription);
87023
+ paginatedQuery.pageKeyToQuery.set(splitKey2, {
87024
+ ...secondSubscription,
87025
+ cursor: splitCursor
87026
+ });
86997
87027
  paginatedQuery.ongoingSplits.set(pageKey, [splitKey1, splitKey2]);
86998
87028
  }
86999
87029
  /**
@@ -87016,7 +87046,10 @@ var init_paginated_query_client = __esm({
87016
87046
  pageArgs
87017
87047
  );
87018
87048
  paginatedQuery.pageKeys.push(pageKey);
87019
- paginatedQuery.pageKeyToQuery.set(pageKey, subscription);
87049
+ paginatedQuery.pageKeyToQuery.set(pageKey, {
87050
+ ...subscription,
87051
+ cursor: continueCursor
87052
+ });
87020
87053
  return subscription;
87021
87054
  }
87022
87055
  removePaginatedQuerySubscriber(token) {
@@ -87075,18 +87108,18 @@ var init_paginated_query_client = __esm({
87075
87108
  function setDefaultWebSocketConstructor(ws) {
87076
87109
  defaultWebSocketConstructor = ws;
87077
87110
  }
87078
- var __defProp17, __defNormalProp15, __publicField15, defaultWebSocketConstructor, ConvexClient;
87111
+ var __defProp16, __defNormalProp14, __publicField14, defaultWebSocketConstructor, ConvexClient;
87079
87112
  var init_simple_client = __esm({
87080
87113
  "../../node_modules/convex/dist/esm/browser/simple_client.js"() {
87081
87114
  "use strict";
87082
87115
  init_common2();
87083
- init_browser2();
87084
87116
  init_api4();
87117
+ init_client3();
87085
87118
  init_paginated_query_client();
87086
87119
  init_udf_path_utils();
87087
- __defProp17 = Object.defineProperty;
87088
- __defNormalProp15 = (obj, key, value) => key in obj ? __defProp17(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
87089
- __publicField15 = (obj, key, value) => __defNormalProp15(obj, typeof key !== "symbol" ? key + "" : key, value);
87120
+ __defProp16 = Object.defineProperty;
87121
+ __defNormalProp14 = (obj, key, value) => key in obj ? __defProp16(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
87122
+ __publicField14 = (obj, key, value) => __defNormalProp14(obj, typeof key !== "symbol" ? key + "" : key, value);
87090
87123
  ConvexClient = class {
87091
87124
  /**
87092
87125
  * Construct a client and immediately initiate a WebSocket connection to the passed address.
@@ -87094,12 +87127,12 @@ var init_simple_client = __esm({
87094
87127
  * @public
87095
87128
  */
87096
87129
  constructor(address, options = {}) {
87097
- __publicField15(this, "listeners");
87098
- __publicField15(this, "_client");
87099
- __publicField15(this, "_paginatedClient");
87100
- __publicField15(this, "callNewListenersWithCurrentValuesTimer");
87101
- __publicField15(this, "_closed");
87102
- __publicField15(this, "_disabled");
87130
+ __publicField14(this, "listeners");
87131
+ __publicField14(this, "_client");
87132
+ __publicField14(this, "_paginatedClient");
87133
+ __publicField14(this, "callNewListenersWithCurrentValuesTimer");
87134
+ __publicField14(this, "_closed");
87135
+ __publicField14(this, "_disabled");
87103
87136
  if (options.skipConvexDeploymentUrlCheck !== true) {
87104
87137
  validateDeploymentUrl(address);
87105
87138
  }
@@ -87477,13 +87510,13 @@ var init_simple_client = __esm({
87477
87510
  // ../../node_modules/convex/dist/esm/browser/simple_client-node.js
87478
87511
  import { createRequire } from "module";
87479
87512
  import { resolve as nodePathResolve } from "path";
87480
- var require2, __create3, __defProp18, __getOwnPropDesc3, __getOwnPropNames3, __getProtoOf3, __hasOwnProp3, __require2, __commonJS2, __copyProps3, __toESM3, require_stream3, require_constants4, require_node_gyp_build, require_node_gyp_build2, require_fallback, require_bufferutil, require_buffer_util3, require_limiter3, require_permessage_deflate3, require_validation4, require_receiver3, require_sender3, require_event_target3, require_extension3, require_websocket3, require_subprotocol3, require_websocket_server3, import_stream3, import_receiver3, import_sender3, import_websocket3, import_websocket_server3, wrapper_default3, nodeWebSocket;
87513
+ var require2, __create3, __defProp17, __getOwnPropDesc3, __getOwnPropNames3, __getProtoOf3, __hasOwnProp3, __require2, __commonJS2, __copyProps3, __toESM3, require_constants4, require_node_gyp_build, require_node_gyp_build2, require_fallback, require_bufferutil, require_buffer_util3, require_limiter3, require_permessage_deflate3, require_validation4, require_receiver3, require_sender3, require_event_target3, require_extension3, require_websocket3, require_stream3, require_subprotocol3, require_websocket_server3, import_stream3, import_extension3, import_permessage_deflate3, import_receiver3, import_sender3, import_subprotocol3, import_websocket3, import_websocket_server3, wrapper_default3, nodeWebSocket;
87481
87514
  var init_simple_client_node = __esm({
87482
87515
  "../../node_modules/convex/dist/esm/browser/simple_client-node.js"() {
87483
87516
  init_simple_client();
87484
87517
  require2 = createRequire(nodePathResolve("."));
87485
87518
  __create3 = Object.create;
87486
- __defProp18 = Object.defineProperty;
87519
+ __defProp17 = Object.defineProperty;
87487
87520
  __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
87488
87521
  __getOwnPropNames3 = Object.getOwnPropertyNames;
87489
87522
  __getProtoOf3 = Object.getPrototypeOf;
@@ -87501,7 +87534,7 @@ var init_simple_client_node = __esm({
87501
87534
  if (from && typeof from === "object" || typeof from === "function") {
87502
87535
  for (let key of __getOwnPropNames3(from))
87503
87536
  if (!__hasOwnProp3.call(to, key) && key !== except)
87504
- __defProp18(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable });
87537
+ __defProp17(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable });
87505
87538
  }
87506
87539
  return to;
87507
87540
  };
@@ -87510,112 +87543,18 @@ var init_simple_client_node = __esm({
87510
87543
  // file that has been converted to a CommonJS file using a Babel-
87511
87544
  // compatible transform (i.e. "__esModule" has not been set), then set
87512
87545
  // "default" to the CommonJS "module.exports" for node compatibility.
87513
- isNodeMode || !mod || !mod.__esModule ? __defProp18(target, "default", { value: mod, enumerable: true }) : target,
87546
+ isNodeMode || !mod || !mod.__esModule ? __defProp17(target, "default", { value: mod, enumerable: true }) : target,
87514
87547
  mod
87515
87548
  ));
87516
- require_stream3 = __commonJS2({
87517
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/stream.js"(exports, module2) {
87518
- "use strict";
87519
- var { Duplex } = __require2("stream");
87520
- function emitClose(stream) {
87521
- stream.emit("close");
87522
- }
87523
- function duplexOnEnd() {
87524
- if (!this.destroyed && this._writableState.finished) {
87525
- this.destroy();
87526
- }
87527
- }
87528
- function duplexOnError(err) {
87529
- this.removeListener("error", duplexOnError);
87530
- this.destroy();
87531
- if (this.listenerCount("error") === 0) {
87532
- this.emit("error", err);
87533
- }
87534
- }
87535
- function createWebSocketStream22(ws, options) {
87536
- let terminateOnDestroy = true;
87537
- const duplex = new Duplex({
87538
- ...options,
87539
- autoDestroy: false,
87540
- emitClose: false,
87541
- objectMode: false,
87542
- writableObjectMode: false
87543
- });
87544
- ws.on("message", function message(msg, isBinary) {
87545
- const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
87546
- if (!duplex.push(data)) ws.pause();
87547
- });
87548
- ws.once("error", function error55(err) {
87549
- if (duplex.destroyed) return;
87550
- terminateOnDestroy = false;
87551
- duplex.destroy(err);
87552
- });
87553
- ws.once("close", function close2() {
87554
- if (duplex.destroyed) return;
87555
- duplex.push(null);
87556
- });
87557
- duplex._destroy = function(err, callback) {
87558
- if (ws.readyState === ws.CLOSED) {
87559
- callback(err);
87560
- process.nextTick(emitClose, duplex);
87561
- return;
87562
- }
87563
- let called = false;
87564
- ws.once("error", function error55(err2) {
87565
- called = true;
87566
- callback(err2);
87567
- });
87568
- ws.once("close", function close2() {
87569
- if (!called) callback(err);
87570
- process.nextTick(emitClose, duplex);
87571
- });
87572
- if (terminateOnDestroy) ws.terminate();
87573
- };
87574
- duplex._final = function(callback) {
87575
- if (ws.readyState === ws.CONNECTING) {
87576
- ws.once("open", function open3() {
87577
- duplex._final(callback);
87578
- });
87579
- return;
87580
- }
87581
- if (ws._socket === null) return;
87582
- if (ws._socket._writableState.finished) {
87583
- callback();
87584
- if (duplex._readableState.endEmitted) duplex.destroy();
87585
- } else {
87586
- ws._socket.once("finish", function finish() {
87587
- callback();
87588
- });
87589
- ws.close();
87590
- }
87591
- };
87592
- duplex._read = function() {
87593
- if (ws.isPaused) ws.resume();
87594
- };
87595
- duplex._write = function(chunk2, encoding, callback) {
87596
- if (ws.readyState === ws.CONNECTING) {
87597
- ws.once("open", function open3() {
87598
- duplex._write(chunk2, encoding, callback);
87599
- });
87600
- return;
87601
- }
87602
- ws.send(chunk2, callback);
87603
- };
87604
- duplex.on("end", duplexOnEnd);
87605
- duplex.on("error", duplexOnError);
87606
- return duplex;
87607
- }
87608
- module2.exports = createWebSocketStream22;
87609
- }
87610
- });
87611
87549
  require_constants4 = __commonJS2({
87612
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/constants.js"(exports, module2) {
87550
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/constants.js"(exports, module2) {
87613
87551
  "use strict";
87614
87552
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
87615
87553
  var hasBlob = typeof Blob !== "undefined";
87616
87554
  if (hasBlob) BINARY_TYPES.push("blob");
87617
87555
  module2.exports = {
87618
87556
  BINARY_TYPES,
87557
+ CLOSE_TIMEOUT: 3e4,
87619
87558
  EMPTY_BUFFER: Buffer.alloc(0),
87620
87559
  GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
87621
87560
  hasBlob,
@@ -87629,19 +87568,19 @@ var init_simple_client_node = __esm({
87629
87568
  }
87630
87569
  });
87631
87570
  require_node_gyp_build = __commonJS2({
87632
- "../common/temp/node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js"(exports, module2) {
87571
+ "../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js"(exports, module2) {
87633
87572
  var fs84 = __require2("fs");
87634
87573
  var path108 = __require2("path");
87635
87574
  var os45 = __require2("os");
87636
87575
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require2;
87637
- var vars = process.config && process.config.variables || {};
87576
+ var vars2 = process.config && process.config.variables || {};
87638
87577
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
87639
87578
  var abi = process.versions.modules;
87640
87579
  var runtime = isElectron2() ? "electron" : isNwjs() ? "node-webkit" : "node";
87641
87580
  var arch2 = process.env.npm_config_arch || os45.arch();
87642
87581
  var platform3 = process.env.npm_config_platform || os45.platform();
87643
87582
  var libc = process.env.LIBC || (isAlpine(platform3) ? "musl" : "glibc");
87644
- var armv = process.env.ARM_VERSION || (arch2 === "arm64" ? "8" : vars.arm_version) || "";
87583
+ var armv = process.env.ARM_VERSION || (arch2 === "arm64" ? "8" : vars2.arm_version) || "";
87645
87584
  var uv = (process.versions.uv || "").split(".")[0];
87646
87585
  module2.exports = load2;
87647
87586
  function load2(dir) {
@@ -87725,9 +87664,9 @@ var init_simple_client_node = __esm({
87725
87664
  }
87726
87665
  function parseTags(file3) {
87727
87666
  var arr2 = file3.split(".");
87728
- var extension3 = arr2.pop();
87667
+ var extension22 = arr2.pop();
87729
87668
  var tags = { file: file3, specificity: 0 };
87730
- if (extension3 !== "node") return;
87669
+ if (extension22 !== "node") return;
87731
87670
  for (var i2 = 0; i2 < arr2.length; i2++) {
87732
87671
  var tag = arr2[i2];
87733
87672
  if (tag === "node" || tag === "electron" || tag === "node-webkit") {
@@ -87796,7 +87735,7 @@ var init_simple_client_node = __esm({
87796
87735
  }
87797
87736
  });
87798
87737
  require_node_gyp_build2 = __commonJS2({
87799
- "../common/temp/node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js"(exports, module2) {
87738
+ "../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js"(exports, module2) {
87800
87739
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require2;
87801
87740
  if (typeof runtimeRequire.addon === "function") {
87802
87741
  module2.exports = runtimeRequire.addon.bind(runtimeRequire);
@@ -87806,7 +87745,7 @@ var init_simple_client_node = __esm({
87806
87745
  }
87807
87746
  });
87808
87747
  require_fallback = __commonJS2({
87809
- "../common/temp/node_modules/.pnpm/bufferutil@4.0.9/node_modules/bufferutil/fallback.js"(exports, module2) {
87748
+ "../node_modules/.pnpm/bufferutil@4.0.9/node_modules/bufferutil/fallback.js"(exports, module2) {
87810
87749
  "use strict";
87811
87750
  var mask = (source, mask2, output, offset, length) => {
87812
87751
  for (var i2 = 0; i2 < length; i2++) {
@@ -87823,7 +87762,7 @@ var init_simple_client_node = __esm({
87823
87762
  }
87824
87763
  });
87825
87764
  require_bufferutil = __commonJS2({
87826
- "../common/temp/node_modules/.pnpm/bufferutil@4.0.9/node_modules/bufferutil/index.js"(exports, module2) {
87765
+ "../node_modules/.pnpm/bufferutil@4.0.9/node_modules/bufferutil/index.js"(exports, module2) {
87827
87766
  "use strict";
87828
87767
  try {
87829
87768
  module2.exports = require_node_gyp_build2()(__dirname);
@@ -87833,7 +87772,7 @@ var init_simple_client_node = __esm({
87833
87772
  }
87834
87773
  });
87835
87774
  require_buffer_util3 = __commonJS2({
87836
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/buffer-util.js"(exports, module2) {
87775
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/buffer-util.js"(exports, module2) {
87837
87776
  "use strict";
87838
87777
  var { EMPTY_BUFFER } = require_constants4();
87839
87778
  var FastBuffer = Buffer[Symbol.species];
@@ -87906,7 +87845,7 @@ var init_simple_client_node = __esm({
87906
87845
  }
87907
87846
  });
87908
87847
  require_limiter3 = __commonJS2({
87909
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/limiter.js"(exports, module2) {
87848
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/limiter.js"(exports, module2) {
87910
87849
  "use strict";
87911
87850
  var kDone = /* @__PURE__ */ Symbol("kDone");
87912
87851
  var kRun = /* @__PURE__ */ Symbol("kRun");
@@ -87954,7 +87893,7 @@ var init_simple_client_node = __esm({
87954
87893
  }
87955
87894
  });
87956
87895
  require_permessage_deflate3 = __commonJS2({
87957
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/permessage-deflate.js"(exports, module2) {
87896
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/permessage-deflate.js"(exports, module2) {
87958
87897
  "use strict";
87959
87898
  var zlib = __require2("zlib");
87960
87899
  var bufferUtil = require_buffer_util3();
@@ -87968,7 +87907,7 @@ var init_simple_client_node = __esm({
87968
87907
  var kBuffers = /* @__PURE__ */ Symbol("buffers");
87969
87908
  var kError = /* @__PURE__ */ Symbol("error");
87970
87909
  var zlibLimiter;
87971
- var PerMessageDeflate3 = class {
87910
+ var PerMessageDeflate22 = class {
87972
87911
  /**
87973
87912
  * Creates a PerMessageDeflate instance.
87974
87913
  *
@@ -87979,6 +87918,9 @@ var init_simple_client_node = __esm({
87979
87918
  * acknowledge disabling of client context takeover
87980
87919
  * @param {Number} [options.concurrencyLimit=10] The number of concurrent
87981
87920
  * calls to zlib
87921
+ * @param {Boolean} [options.isServer=false] Create the instance in either
87922
+ * server or client mode
87923
+ * @param {Number} [options.maxPayload=0] The maximum allowed message length
87982
87924
  * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
87983
87925
  * use of a custom server window size
87984
87926
  * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
@@ -87989,15 +87931,12 @@ var init_simple_client_node = __esm({
87989
87931
  * deflate
87990
87932
  * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
87991
87933
  * inflate
87992
- * @param {Boolean} [isServer=false] Create the instance in either server or
87993
- * client mode
87994
- * @param {Number} [maxPayload=0] The maximum allowed message length
87995
87934
  */
87996
- constructor(options, isServer, maxPayload) {
87997
- this._maxPayload = maxPayload | 0;
87935
+ constructor(options) {
87998
87936
  this._options = options || {};
87999
87937
  this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
88000
- this._isServer = !!isServer;
87938
+ this._maxPayload = this._options.maxPayload | 0;
87939
+ this._isServer = !!this._options.isServer;
88001
87940
  this._deflate = null;
88002
87941
  this._inflate = null;
88003
87942
  this.params = null;
@@ -88306,7 +88245,7 @@ var init_simple_client_node = __esm({
88306
88245
  });
88307
88246
  }
88308
88247
  };
88309
- module2.exports = PerMessageDeflate3;
88248
+ module2.exports = PerMessageDeflate22;
88310
88249
  function deflateOnData(chunk2) {
88311
88250
  this[kBuffers].push(chunk2);
88312
88251
  this[kTotalLength] += chunk2.length;
@@ -88325,13 +88264,17 @@ var init_simple_client_node = __esm({
88325
88264
  }
88326
88265
  function inflateOnError(err) {
88327
88266
  this[kPerMessageDeflate]._inflate = null;
88267
+ if (this[kError]) {
88268
+ this[kCallback](this[kError]);
88269
+ return;
88270
+ }
88328
88271
  err[kStatusCode] = 1007;
88329
88272
  this[kCallback](err);
88330
88273
  }
88331
88274
  }
88332
88275
  });
88333
88276
  require_validation4 = __commonJS2({
88334
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/validation.js"(exports, module2) {
88277
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/validation.js"(exports, module2) {
88335
88278
  "use strict";
88336
88279
  var { isUtf8 } = __require2("buffer");
88337
88280
  var { hasBlob } = require_constants4();
@@ -88530,10 +88473,10 @@ var init_simple_client_node = __esm({
88530
88473
  }
88531
88474
  });
88532
88475
  require_receiver3 = __commonJS2({
88533
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/receiver.js"(exports, module2) {
88476
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/receiver.js"(exports, module2) {
88534
88477
  "use strict";
88535
88478
  var { Writable } = __require2("stream");
88536
- var PerMessageDeflate3 = require_permessage_deflate3();
88479
+ var PerMessageDeflate22 = require_permessage_deflate3();
88537
88480
  var {
88538
88481
  BINARY_TYPES,
88539
88482
  EMPTY_BUFFER,
@@ -88563,6 +88506,10 @@ var init_simple_client_node = __esm({
88563
88506
  * extensions
88564
88507
  * @param {Boolean} [options.isServer=false] Specifies whether to operate in
88565
88508
  * client or server mode
88509
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
88510
+ * buffered data chunks
88511
+ * @param {Number} [options.maxFragments=0] The maximum number of message
88512
+ * fragments
88566
88513
  * @param {Number} [options.maxPayload=0] The maximum allowed message length
88567
88514
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
88568
88515
  * not to skip UTF-8 validation for text and close messages
@@ -88573,6 +88520,8 @@ var init_simple_client_node = __esm({
88573
88520
  this._binaryType = options.binaryType || BINARY_TYPES[0];
88574
88521
  this._extensions = options.extensions || {};
88575
88522
  this._isServer = !!options.isServer;
88523
+ this._maxBufferedChunks = options.maxBufferedChunks | 0;
88524
+ this._maxFragments = options.maxFragments | 0;
88576
88525
  this._maxPayload = options.maxPayload | 0;
88577
88526
  this._skipUTF8Validation = !!options.skipUTF8Validation;
88578
88527
  this[kWebSocket] = void 0;
@@ -88602,6 +88551,18 @@ var init_simple_client_node = __esm({
88602
88551
  */
88603
88552
  _write(chunk2, encoding, cb) {
88604
88553
  if (this._opcode === 8 && this._state == GET_INFO) return cb();
88554
+ if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
88555
+ cb(
88556
+ this.createError(
88557
+ RangeError,
88558
+ "Too many buffered chunks",
88559
+ false,
88560
+ 1008,
88561
+ "WS_ERR_TOO_MANY_BUFFERED_PARTS"
88562
+ )
88563
+ );
88564
+ return;
88565
+ }
88605
88566
  this._bufferedBytes += chunk2.length;
88606
88567
  this._buffers.push(chunk2);
88607
88568
  this.startLoop(cb);
@@ -88700,7 +88661,7 @@ var init_simple_client_node = __esm({
88700
88661
  return;
88701
88662
  }
88702
88663
  const compressed = (buf[0] & 64) === 64;
88703
- if (compressed && !this._extensions[PerMessageDeflate3.extensionName]) {
88664
+ if (compressed && !this._extensions[PerMessageDeflate22.extensionName]) {
88704
88665
  const error55 = this.createError(
88705
88666
  RangeError,
88706
88667
  "RSV1 must be clear",
@@ -88931,6 +88892,17 @@ var init_simple_client_node = __esm({
88931
88892
  return;
88932
88893
  }
88933
88894
  if (data.length) {
88895
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
88896
+ const error55 = this.createError(
88897
+ RangeError,
88898
+ "Too many message fragments",
88899
+ false,
88900
+ 1008,
88901
+ "WS_ERR_TOO_MANY_BUFFERED_PARTS"
88902
+ );
88903
+ cb(error55);
88904
+ return;
88905
+ }
88934
88906
  this._messageLength = this._totalPayloadLength;
88935
88907
  this._fragments.push(data);
88936
88908
  }
@@ -88944,7 +88916,7 @@ var init_simple_client_node = __esm({
88944
88916
  * @private
88945
88917
  */
88946
88918
  decompress(data, cb) {
88947
- const perMessageDeflate = this._extensions[PerMessageDeflate3.extensionName];
88919
+ const perMessageDeflate = this._extensions[PerMessageDeflate22.extensionName];
88948
88920
  perMessageDeflate.decompress(data, this._fin, (err, buf) => {
88949
88921
  if (err) return cb(err);
88950
88922
  if (buf.length) {
@@ -88960,6 +88932,17 @@ var init_simple_client_node = __esm({
88960
88932
  cb(error55);
88961
88933
  return;
88962
88934
  }
88935
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
88936
+ const error55 = this.createError(
88937
+ RangeError,
88938
+ "Too many message fragments",
88939
+ false,
88940
+ 1008,
88941
+ "WS_ERR_TOO_MANY_BUFFERED_PARTS"
88942
+ );
88943
+ cb(error55);
88944
+ return;
88945
+ }
88963
88946
  this._fragments.push(buf);
88964
88947
  }
88965
88948
  this.dataMessage(cb);
@@ -89120,11 +89103,14 @@ var init_simple_client_node = __esm({
89120
89103
  }
89121
89104
  });
89122
89105
  require_sender3 = __commonJS2({
89123
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/sender.js"(exports, module2) {
89106
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/sender.js"(exports, module2) {
89124
89107
  "use strict";
89125
89108
  var { Duplex } = __require2("stream");
89126
89109
  var { randomFillSync } = __require2("crypto");
89127
- var PerMessageDeflate3 = require_permessage_deflate3();
89110
+ var {
89111
+ types: { isUint8Array: isUint8Array2 }
89112
+ } = __require2("util");
89113
+ var PerMessageDeflate22 = require_permessage_deflate3();
89128
89114
  var { EMPTY_BUFFER, kWebSocket, NOOP: NOOP2 } = require_constants4();
89129
89115
  var { isBlob, isValidStatusCode } = require_validation4();
89130
89116
  var { mask: applyMask, toBuffer } = require_buffer_util3();
@@ -89277,8 +89263,10 @@ var init_simple_client_node = __esm({
89277
89263
  buf.writeUInt16BE(code2, 0);
89278
89264
  if (typeof data === "string") {
89279
89265
  buf.write(data, 2);
89280
- } else {
89266
+ } else if (isUint8Array2(data)) {
89281
89267
  buf.set(data, 2);
89268
+ } else {
89269
+ throw new TypeError("Second argument must be a string or a Uint8Array");
89282
89270
  }
89283
89271
  }
89284
89272
  const options = {
@@ -89408,7 +89396,7 @@ var init_simple_client_node = __esm({
89408
89396
  * @public
89409
89397
  */
89410
89398
  send(data, options, cb) {
89411
- const perMessageDeflate = this._extensions[PerMessageDeflate3.extensionName];
89399
+ const perMessageDeflate = this._extensions[PerMessageDeflate22.extensionName];
89412
89400
  let opcode = options.binary ? 2 : 1;
89413
89401
  let rsv1 = options.compress;
89414
89402
  let byteLength2;
@@ -89532,7 +89520,7 @@ var init_simple_client_node = __esm({
89532
89520
  this.sendFrame(_Sender.frame(data, options), cb);
89533
89521
  return;
89534
89522
  }
89535
- const perMessageDeflate = this._extensions[PerMessageDeflate3.extensionName];
89523
+ const perMessageDeflate = this._extensions[PerMessageDeflate22.extensionName];
89536
89524
  this._bufferedBytes += options[kByteLength];
89537
89525
  this._state = DEFLATING;
89538
89526
  perMessageDeflate.compress(data, options.fin, (_2, buf) => {
@@ -89575,7 +89563,7 @@ var init_simple_client_node = __esm({
89575
89563
  /**
89576
89564
  * Sends a frame.
89577
89565
  *
89578
- * @param {Buffer[]} list The frame to send
89566
+ * @param {(Buffer | String)[]} list The frame to send
89579
89567
  * @param {Function} [cb] Callback
89580
89568
  * @private
89581
89569
  */
@@ -89606,7 +89594,7 @@ var init_simple_client_node = __esm({
89606
89594
  }
89607
89595
  });
89608
89596
  require_event_target3 = __commonJS2({
89609
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/event-target.js"(exports, module2) {
89597
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/event-target.js"(exports, module2) {
89610
89598
  "use strict";
89611
89599
  var { kForOnEventAttribute, kListener } = require_constants4();
89612
89600
  var kCode = /* @__PURE__ */ Symbol("kCode");
@@ -89833,7 +89821,7 @@ var init_simple_client_node = __esm({
89833
89821
  }
89834
89822
  });
89835
89823
  require_extension3 = __commonJS2({
89836
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/extension.js"(exports, module2) {
89824
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/extension.js"(exports, module2) {
89837
89825
  "use strict";
89838
89826
  var { tokenChars } = require_validation4();
89839
89827
  function push(dest, name, elem) {
@@ -89966,11 +89954,11 @@ var init_simple_client_node = __esm({
89966
89954
  return offers;
89967
89955
  }
89968
89956
  function format2(extensions2) {
89969
- return Object.keys(extensions2).map((extension3) => {
89970
- let configurations = extensions2[extension3];
89957
+ return Object.keys(extensions2).map((extension22) => {
89958
+ let configurations = extensions2[extension22];
89971
89959
  if (!Array.isArray(configurations)) configurations = [configurations];
89972
89960
  return configurations.map((params) => {
89973
- return [extension3].concat(
89961
+ return [extension22].concat(
89974
89962
  Object.keys(params).map((k3) => {
89975
89963
  let values = params[k3];
89976
89964
  if (!Array.isArray(values)) values = [values];
@@ -89984,7 +89972,7 @@ var init_simple_client_node = __esm({
89984
89972
  }
89985
89973
  });
89986
89974
  require_websocket3 = __commonJS2({
89987
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/websocket.js"(exports, module2) {
89975
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/websocket.js"(exports, module2) {
89988
89976
  "use strict";
89989
89977
  var EventEmitter6 = __require2("events");
89990
89978
  var https4 = __require2("https");
@@ -89994,12 +89982,13 @@ var init_simple_client_node = __esm({
89994
89982
  var { randomBytes: randomBytes15, createHash: createHash29 } = __require2("crypto");
89995
89983
  var { Duplex, Readable: Readable3 } = __require2("stream");
89996
89984
  var { URL: URL3 } = __require2("url");
89997
- var PerMessageDeflate3 = require_permessage_deflate3();
89985
+ var PerMessageDeflate22 = require_permessage_deflate3();
89998
89986
  var Receiver22 = require_receiver3();
89999
89987
  var Sender22 = require_sender3();
90000
89988
  var { isBlob } = require_validation4();
90001
89989
  var {
90002
89990
  BINARY_TYPES,
89991
+ CLOSE_TIMEOUT,
90003
89992
  EMPTY_BUFFER,
90004
89993
  GUID,
90005
89994
  kForOnEventAttribute,
@@ -90013,7 +90002,6 @@ var init_simple_client_node = __esm({
90013
90002
  } = require_event_target3();
90014
90003
  var { format: format2, parse: parse8 } = require_extension3();
90015
90004
  var { toBuffer } = require_buffer_util3();
90016
- var closeTimeout = 30 * 1e3;
90017
90005
  var kAborted = /* @__PURE__ */ Symbol("kAborted");
90018
90006
  var protocolVersions = [8, 13];
90019
90007
  var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
@@ -90059,6 +90047,7 @@ var init_simple_client_node = __esm({
90059
90047
  initAsClient(this, address, protocols, options);
90060
90048
  } else {
90061
90049
  this._autoPong = options.autoPong;
90050
+ this._closeTimeout = options.closeTimeout;
90062
90051
  this._isServer = true;
90063
90052
  }
90064
90053
  }
@@ -90152,6 +90141,10 @@ var init_simple_client_node = __esm({
90152
90141
  * multiple times in the same tick
90153
90142
  * @param {Function} [options.generateMask] The function used to generate the
90154
90143
  * masking key
90144
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
90145
+ * buffered data chunks
90146
+ * @param {Number} [options.maxFragments=0] The maximum number of message
90147
+ * fragments
90155
90148
  * @param {Number} [options.maxPayload=0] The maximum allowed message size
90156
90149
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
90157
90150
  * not to skip UTF-8 validation for text and close messages
@@ -90163,6 +90156,8 @@ var init_simple_client_node = __esm({
90163
90156
  binaryType: this.binaryType,
90164
90157
  extensions: this._extensions,
90165
90158
  isServer: this._isServer,
90159
+ maxBufferedChunks: options.maxBufferedChunks,
90160
+ maxFragments: options.maxFragments,
90166
90161
  maxPayload: options.maxPayload,
90167
90162
  skipUTF8Validation: options.skipUTF8Validation
90168
90163
  });
@@ -90201,8 +90196,8 @@ var init_simple_client_node = __esm({
90201
90196
  this.emit("close", this._closeCode, this._closeMessage);
90202
90197
  return;
90203
90198
  }
90204
- if (this._extensions[PerMessageDeflate3.extensionName]) {
90205
- this._extensions[PerMessageDeflate3.extensionName].cleanup();
90199
+ if (this._extensions[PerMessageDeflate22.extensionName]) {
90200
+ this._extensions[PerMessageDeflate22.extensionName].cleanup();
90206
90201
  }
90207
90202
  this._receiver.removeAllListeners();
90208
90203
  this._readyState = _WebSocket.CLOSED;
@@ -90364,7 +90359,7 @@ var init_simple_client_node = __esm({
90364
90359
  fin: true,
90365
90360
  ...options
90366
90361
  };
90367
- if (!this._extensions[PerMessageDeflate3.extensionName]) {
90362
+ if (!this._extensions[PerMessageDeflate22.extensionName]) {
90368
90363
  opts.compress = false;
90369
90364
  }
90370
90365
  this._sender.send(data || EMPTY_BUFFER, opts, cb);
@@ -90460,7 +90455,10 @@ var init_simple_client_node = __esm({
90460
90455
  const opts = {
90461
90456
  allowSynchronousEvents: true,
90462
90457
  autoPong: true,
90458
+ closeTimeout: CLOSE_TIMEOUT,
90463
90459
  protocolVersion: protocolVersions[1],
90460
+ maxBufferedChunks: 1024 * 1024,
90461
+ maxFragments: 128 * 1024,
90464
90462
  maxPayload: 100 * 1024 * 1024,
90465
90463
  skipUTF8Validation: false,
90466
90464
  perMessageDeflate: true,
@@ -90477,6 +90475,7 @@ var init_simple_client_node = __esm({
90477
90475
  port: void 0
90478
90476
  };
90479
90477
  websocket._autoPong = opts.autoPong;
90478
+ websocket._closeTimeout = opts.closeTimeout;
90480
90479
  if (!protocolVersions.includes(opts.protocolVersion)) {
90481
90480
  throw new RangeError(
90482
90481
  `Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
@@ -90488,7 +90487,7 @@ var init_simple_client_node = __esm({
90488
90487
  } else {
90489
90488
  try {
90490
90489
  parsedUrl = new URL3(address);
90491
- } catch (e2) {
90490
+ } catch {
90492
90491
  throw new SyntaxError(`Invalid URL: ${address}`);
90493
90492
  }
90494
90493
  }
@@ -90502,7 +90501,7 @@ var init_simple_client_node = __esm({
90502
90501
  const isIpcUrl = parsedUrl.protocol === "ws+unix:";
90503
90502
  let invalidUrlMessage;
90504
90503
  if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
90505
- invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`;
90504
+ invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;
90506
90505
  } else if (isIpcUrl && !parsedUrl.pathname) {
90507
90506
  invalidUrlMessage = "The URL's pathname is empty";
90508
90507
  } else if (parsedUrl.hash) {
@@ -90536,13 +90535,13 @@ var init_simple_client_node = __esm({
90536
90535
  opts.path = parsedUrl.pathname + parsedUrl.search;
90537
90536
  opts.timeout = opts.handshakeTimeout;
90538
90537
  if (opts.perMessageDeflate) {
90539
- perMessageDeflate = new PerMessageDeflate3(
90540
- opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
90541
- false,
90542
- opts.maxPayload
90543
- );
90538
+ perMessageDeflate = new PerMessageDeflate22({
90539
+ ...opts.perMessageDeflate,
90540
+ isServer: false,
90541
+ maxPayload: opts.maxPayload
90542
+ });
90544
90543
  opts.headers["Sec-WebSocket-Extensions"] = format2({
90545
- [PerMessageDeflate3.extensionName]: perMessageDeflate.offer()
90544
+ [PerMessageDeflate22.extensionName]: perMessageDeflate.offer()
90546
90545
  });
90547
90546
  }
90548
90547
  if (protocols.length) {
@@ -90685,23 +90684,25 @@ var init_simple_client_node = __esm({
90685
90684
  return;
90686
90685
  }
90687
90686
  const extensionNames = Object.keys(extensions2);
90688
- if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate3.extensionName) {
90687
+ if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate22.extensionName) {
90689
90688
  const message = "Server indicated an extension that was not requested";
90690
90689
  abortHandshake(websocket, socket, message);
90691
90690
  return;
90692
90691
  }
90693
90692
  try {
90694
- perMessageDeflate.accept(extensions2[PerMessageDeflate3.extensionName]);
90693
+ perMessageDeflate.accept(extensions2[PerMessageDeflate22.extensionName]);
90695
90694
  } catch (err) {
90696
90695
  const message = "Invalid Sec-WebSocket-Extensions header";
90697
90696
  abortHandshake(websocket, socket, message);
90698
90697
  return;
90699
90698
  }
90700
- websocket._extensions[PerMessageDeflate3.extensionName] = perMessageDeflate;
90699
+ websocket._extensions[PerMessageDeflate22.extensionName] = perMessageDeflate;
90701
90700
  }
90702
90701
  websocket.setSocket(socket, head, {
90703
90702
  allowSynchronousEvents: opts.allowSynchronousEvents,
90704
90703
  generateMask: opts.generateMask,
90704
+ maxBufferedChunks: opts.maxBufferedChunks,
90705
+ maxFragments: opts.maxFragments,
90705
90706
  maxPayload: opts.maxPayload,
90706
90707
  skipUTF8Validation: opts.skipUTF8Validation
90707
90708
  });
@@ -90819,7 +90820,7 @@ var init_simple_client_node = __esm({
90819
90820
  function setCloseTimer(websocket) {
90820
90821
  websocket._closeTimer = setTimeout(
90821
90822
  websocket._socket.destroy.bind(websocket._socket),
90822
- closeTimeout
90823
+ websocket._closeTimeout
90823
90824
  );
90824
90825
  }
90825
90826
  function socketOnClose() {
@@ -90828,8 +90829,8 @@ var init_simple_client_node = __esm({
90828
90829
  this.removeListener("data", socketOnData);
90829
90830
  this.removeListener("end", socketOnEnd);
90830
90831
  websocket._readyState = WebSocket22.CLOSING;
90831
- let chunk2;
90832
- if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && (chunk2 = websocket._socket.read()) !== null) {
90832
+ if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
90833
+ const chunk2 = this.read(this._readableState.length);
90833
90834
  websocket._receiver.write(chunk2);
90834
90835
  }
90835
90836
  websocket._receiver.end();
@@ -90864,8 +90865,104 @@ var init_simple_client_node = __esm({
90864
90865
  }
90865
90866
  }
90866
90867
  });
90868
+ require_stream3 = __commonJS2({
90869
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/stream.js"(exports, module2) {
90870
+ "use strict";
90871
+ var WebSocket22 = require_websocket3();
90872
+ var { Duplex } = __require2("stream");
90873
+ function emitClose(stream) {
90874
+ stream.emit("close");
90875
+ }
90876
+ function duplexOnEnd() {
90877
+ if (!this.destroyed && this._writableState.finished) {
90878
+ this.destroy();
90879
+ }
90880
+ }
90881
+ function duplexOnError(err) {
90882
+ this.removeListener("error", duplexOnError);
90883
+ this.destroy();
90884
+ if (this.listenerCount("error") === 0) {
90885
+ this.emit("error", err);
90886
+ }
90887
+ }
90888
+ function createWebSocketStream22(ws, options) {
90889
+ let terminateOnDestroy = true;
90890
+ const duplex = new Duplex({
90891
+ ...options,
90892
+ autoDestroy: false,
90893
+ emitClose: false,
90894
+ objectMode: false,
90895
+ writableObjectMode: false
90896
+ });
90897
+ ws.on("message", function message(msg, isBinary) {
90898
+ const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
90899
+ if (!duplex.push(data)) ws.pause();
90900
+ });
90901
+ ws.once("error", function error55(err) {
90902
+ if (duplex.destroyed) return;
90903
+ terminateOnDestroy = false;
90904
+ duplex.destroy(err);
90905
+ });
90906
+ ws.once("close", function close2() {
90907
+ if (duplex.destroyed) return;
90908
+ duplex.push(null);
90909
+ });
90910
+ duplex._destroy = function(err, callback) {
90911
+ if (ws.readyState === ws.CLOSED) {
90912
+ callback(err);
90913
+ process.nextTick(emitClose, duplex);
90914
+ return;
90915
+ }
90916
+ let called = false;
90917
+ ws.once("error", function error55(err2) {
90918
+ called = true;
90919
+ callback(err2);
90920
+ });
90921
+ ws.once("close", function close2() {
90922
+ if (!called) callback(err);
90923
+ process.nextTick(emitClose, duplex);
90924
+ });
90925
+ if (terminateOnDestroy) ws.terminate();
90926
+ };
90927
+ duplex._final = function(callback) {
90928
+ if (ws.readyState === ws.CONNECTING) {
90929
+ ws.once("open", function open3() {
90930
+ duplex._final(callback);
90931
+ });
90932
+ return;
90933
+ }
90934
+ if (ws._socket === null) return;
90935
+ if (ws._socket._writableState.finished) {
90936
+ callback();
90937
+ if (duplex._readableState.endEmitted) duplex.destroy();
90938
+ } else {
90939
+ ws._socket.once("finish", function finish() {
90940
+ callback();
90941
+ });
90942
+ ws.close();
90943
+ }
90944
+ };
90945
+ duplex._read = function() {
90946
+ if (ws.isPaused) ws.resume();
90947
+ };
90948
+ duplex._write = function(chunk2, encoding, callback) {
90949
+ if (ws.readyState === ws.CONNECTING) {
90950
+ ws.once("open", function open3() {
90951
+ duplex._write(chunk2, encoding, callback);
90952
+ });
90953
+ return;
90954
+ }
90955
+ ws.send(chunk2, callback);
90956
+ };
90957
+ duplex.on("end", duplexOnEnd);
90958
+ duplex.on("error", duplexOnError);
90959
+ return duplex;
90960
+ }
90961
+ module2.exports = createWebSocketStream22;
90962
+ }
90963
+ });
90867
90964
  require_subprotocol3 = __commonJS2({
90868
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/subprotocol.js"(exports, module2) {
90965
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/subprotocol.js"(exports, module2) {
90869
90966
  "use strict";
90870
90967
  var { tokenChars } = require_validation4();
90871
90968
  function parse8(header) {
@@ -90908,17 +91005,17 @@ var init_simple_client_node = __esm({
90908
91005
  }
90909
91006
  });
90910
91007
  require_websocket_server3 = __commonJS2({
90911
- "../common/temp/node_modules/.pnpm/ws@8.18.0_bufferutil@4.0.9/node_modules/ws/lib/websocket-server.js"(exports, module2) {
91008
+ "../node_modules/.pnpm/ws@8.21.0_bufferutil@4.0.9/node_modules/ws/lib/websocket-server.js"(exports, module2) {
90912
91009
  "use strict";
90913
91010
  var EventEmitter6 = __require2("events");
90914
91011
  var http11 = __require2("http");
90915
91012
  var { Duplex } = __require2("stream");
90916
91013
  var { createHash: createHash29 } = __require2("crypto");
90917
- var extension3 = require_extension3();
90918
- var PerMessageDeflate3 = require_permessage_deflate3();
90919
- var subprotocol3 = require_subprotocol3();
91014
+ var extension22 = require_extension3();
91015
+ var PerMessageDeflate22 = require_permessage_deflate3();
91016
+ var subprotocol22 = require_subprotocol3();
90920
91017
  var WebSocket22 = require_websocket3();
90921
- var { GUID, kWebSocket } = require_constants4();
91018
+ var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants4();
90922
91019
  var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
90923
91020
  var RUNNING = 0;
90924
91021
  var CLOSING = 1;
@@ -90937,8 +91034,15 @@ var init_simple_client_node = __esm({
90937
91034
  * pending connections
90938
91035
  * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
90939
91036
  * track clients
91037
+ * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
91038
+ * wait for the closing handshake to finish after `websocket.close()` is
91039
+ * called
90940
91040
  * @param {Function} [options.handleProtocols] A hook to handle protocols
90941
91041
  * @param {String} [options.host] The hostname where to bind the server
91042
+ * @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
91043
+ * buffered data chunks
91044
+ * @param {Number} [options.maxFragments=131072] The maximum number of message
91045
+ * fragments
90942
91046
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
90943
91047
  * size
90944
91048
  * @param {Boolean} [options.noServer=false] Enable no server mode
@@ -90960,11 +91064,14 @@ var init_simple_client_node = __esm({
90960
91064
  options = {
90961
91065
  allowSynchronousEvents: true,
90962
91066
  autoPong: true,
91067
+ maxBufferedChunks: 1024 * 1024,
91068
+ maxFragments: 128 * 1024,
90963
91069
  maxPayload: 100 * 1024 * 1024,
90964
91070
  skipUTF8Validation: false,
90965
91071
  perMessageDeflate: false,
90966
91072
  handleProtocols: null,
90967
91073
  clientTracking: true,
91074
+ closeTimeout: CLOSE_TIMEOUT,
90968
91075
  verifyClient: null,
90969
91076
  noServer: false,
90970
91077
  backlog: null,
@@ -91120,9 +91227,11 @@ var init_simple_client_node = __esm({
91120
91227
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
91121
91228
  return;
91122
91229
  }
91123
- if (version4 !== 8 && version4 !== 13) {
91230
+ if (version4 !== 13 && version4 !== 8) {
91124
91231
  const message = "Missing or invalid Sec-WebSocket-Version header";
91125
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
91232
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
91233
+ "Sec-WebSocket-Version": "13, 8"
91234
+ });
91126
91235
  return;
91127
91236
  }
91128
91237
  if (!this.shouldHandle(req)) {
@@ -91133,7 +91242,7 @@ var init_simple_client_node = __esm({
91133
91242
  let protocols = /* @__PURE__ */ new Set();
91134
91243
  if (secWebSocketProtocol !== void 0) {
91135
91244
  try {
91136
- protocols = subprotocol3.parse(secWebSocketProtocol);
91245
+ protocols = subprotocol22.parse(secWebSocketProtocol);
91137
91246
  } catch (err) {
91138
91247
  const message = "Invalid Sec-WebSocket-Protocol header";
91139
91248
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
@@ -91143,16 +91252,16 @@ var init_simple_client_node = __esm({
91143
91252
  const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
91144
91253
  const extensions2 = {};
91145
91254
  if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
91146
- const perMessageDeflate = new PerMessageDeflate3(
91147
- this.options.perMessageDeflate,
91148
- true,
91149
- this.options.maxPayload
91150
- );
91255
+ const perMessageDeflate = new PerMessageDeflate22({
91256
+ ...this.options.perMessageDeflate,
91257
+ isServer: true,
91258
+ maxPayload: this.options.maxPayload
91259
+ });
91151
91260
  try {
91152
- const offers = extension3.parse(secWebSocketExtensions);
91153
- if (offers[PerMessageDeflate3.extensionName]) {
91154
- perMessageDeflate.accept(offers[PerMessageDeflate3.extensionName]);
91155
- extensions2[PerMessageDeflate3.extensionName] = perMessageDeflate;
91261
+ const offers = extension22.parse(secWebSocketExtensions);
91262
+ if (offers[PerMessageDeflate22.extensionName]) {
91263
+ perMessageDeflate.accept(offers[PerMessageDeflate22.extensionName]);
91264
+ extensions2[PerMessageDeflate22.extensionName] = perMessageDeflate;
91156
91265
  }
91157
91266
  } catch (err) {
91158
91267
  const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
@@ -91223,10 +91332,10 @@ var init_simple_client_node = __esm({
91223
91332
  ws._protocol = protocol;
91224
91333
  }
91225
91334
  }
91226
- if (extensions2[PerMessageDeflate3.extensionName]) {
91227
- const params = extensions2[PerMessageDeflate3.extensionName].params;
91228
- const value = extension3.format({
91229
- [PerMessageDeflate3.extensionName]: [params]
91335
+ if (extensions2[PerMessageDeflate22.extensionName]) {
91336
+ const params = extensions2[PerMessageDeflate22.extensionName].params;
91337
+ const value = extension22.format({
91338
+ [PerMessageDeflate22.extensionName]: [params]
91230
91339
  });
91231
91340
  headers.push(`Sec-WebSocket-Extensions: ${value}`);
91232
91341
  ws._extensions = extensions2;
@@ -91236,6 +91345,8 @@ var init_simple_client_node = __esm({
91236
91345
  socket.removeListener("error", socketOnError);
91237
91346
  ws.setSocket(socket, head, {
91238
91347
  allowSynchronousEvents: this.options.allowSynchronousEvents,
91348
+ maxBufferedChunks: this.options.maxBufferedChunks,
91349
+ maxFragments: this.options.maxFragments,
91239
91350
  maxPayload: this.options.maxPayload,
91240
91351
  skipUTF8Validation: this.options.skipUTF8Validation
91241
91352
  });
@@ -91281,20 +91392,23 @@ var init_simple_client_node = __esm({
91281
91392
  ` + Object.keys(headers).map((h3) => `${h3}: ${headers[h3]}`).join("\r\n") + "\r\n\r\n" + message
91282
91393
  );
91283
91394
  }
91284
- function abortHandshakeOrEmitwsClientError(server, req, socket, code2, message) {
91395
+ function abortHandshakeOrEmitwsClientError(server, req, socket, code2, message, headers) {
91285
91396
  if (server.listenerCount("wsClientError")) {
91286
91397
  const err = new Error(message);
91287
91398
  Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
91288
91399
  server.emit("wsClientError", err, socket, req);
91289
91400
  } else {
91290
- abortHandshake(socket, code2, message);
91401
+ abortHandshake(socket, code2, message, headers);
91291
91402
  }
91292
91403
  }
91293
91404
  }
91294
91405
  });
91295
91406
  import_stream3 = __toESM3(require_stream3(), 1);
91407
+ import_extension3 = __toESM3(require_extension3(), 1);
91408
+ import_permessage_deflate3 = __toESM3(require_permessage_deflate3(), 1);
91296
91409
  import_receiver3 = __toESM3(require_receiver3(), 1);
91297
91410
  import_sender3 = __toESM3(require_sender3(), 1);
91411
+ import_subprotocol3 = __toESM3(require_subprotocol3(), 1);
91298
91412
  import_websocket3 = __toESM3(require_websocket3(), 1);
91299
91413
  import_websocket_server3 = __toESM3(require_websocket_server3(), 1);
91300
91414
  wrapper_default3 = import_websocket3.default;
@@ -91303,12 +91417,477 @@ var init_simple_client_node = __esm({
91303
91417
  }
91304
91418
  });
91305
91419
 
91420
+ // ../../node_modules/convex/dist/esm/browser/http_client.js
91421
+ function forwardErrorData(errorData, error55) {
91422
+ error55.data = jsonToConvex(errorData);
91423
+ return error55;
91424
+ }
91425
+ var __defProp18, __defNormalProp15, __publicField15, STATUS_CODE_UDF_FAILED, specifiedFetch, ConvexHttpClient;
91426
+ var init_http_client = __esm({
91427
+ "../../node_modules/convex/dist/esm/browser/http_client.js"() {
91428
+ "use strict";
91429
+ init_api4();
91430
+ init_common2();
91431
+ init_esm6();
91432
+ init_values();
91433
+ init_logging();
91434
+ __defProp18 = Object.defineProperty;
91435
+ __defNormalProp15 = (obj, key, value) => key in obj ? __defProp18(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
91436
+ __publicField15 = (obj, key, value) => __defNormalProp15(obj, typeof key !== "symbol" ? key + "" : key, value);
91437
+ STATUS_CODE_UDF_FAILED = 560;
91438
+ specifiedFetch = void 0;
91439
+ ConvexHttpClient = class {
91440
+ /**
91441
+ * Create a new {@link ConvexHttpClient}.
91442
+ *
91443
+ * @param address - The url of your Convex deployment, often provided
91444
+ * by an environment variable. E.g. `https://small-mouse-123.convex.cloud`.
91445
+ * @param options - An object of options.
91446
+ * - `skipConvexDeploymentUrlCheck` - Skip validating that the Convex deployment URL looks like
91447
+ * `https://happy-animal-123.convex.cloud` or localhost. This can be useful if running a self-hosted
91448
+ * Convex backend that uses a different URL.
91449
+ * - `logger` - A logger or a boolean. If not provided, logs to the console.
91450
+ * You can construct your own logger to customize logging to log elsewhere
91451
+ * or not log at all, or use `false` as a shorthand for a no-op logger.
91452
+ * A logger is an object with 4 methods: log(), warn(), error(), and logVerbose().
91453
+ * These methods can receive multiple arguments of any types, like console.log().
91454
+ * - `auth` - A JWT containing identity claims accessible in Convex functions.
91455
+ * This identity may expire so it may be necessary to call `setAuth()` later,
91456
+ * but for short-lived clients it's convenient to specify this value here.
91457
+ * - `fetch` - A custom fetch implementation to use for all HTTP requests made by this client.
91458
+ */
91459
+ constructor(address, options) {
91460
+ __publicField15(this, "address");
91461
+ __publicField15(this, "auth");
91462
+ __publicField15(this, "adminAuth");
91463
+ __publicField15(this, "encodedTsPromise");
91464
+ __publicField15(this, "debug");
91465
+ __publicField15(this, "fetchOptions");
91466
+ __publicField15(this, "fetch");
91467
+ __publicField15(this, "logger");
91468
+ __publicField15(this, "mutationQueue", []);
91469
+ __publicField15(this, "isProcessingQueue", false);
91470
+ if (typeof options === "boolean") {
91471
+ throw new Error(
91472
+ "skipConvexDeploymentUrlCheck as the second argument is no longer supported. Please pass an options object, `{ skipConvexDeploymentUrlCheck: true }`."
91473
+ );
91474
+ }
91475
+ const opts = options ?? {};
91476
+ if (opts.skipConvexDeploymentUrlCheck !== true) {
91477
+ validateDeploymentUrl(address);
91478
+ }
91479
+ this.logger = options?.logger === false ? instantiateNoopLogger({ verbose: false }) : options?.logger !== true && options?.logger ? options.logger : instantiateDefaultLogger({ verbose: false });
91480
+ this.address = address;
91481
+ this.debug = true;
91482
+ this.auth = void 0;
91483
+ this.adminAuth = void 0;
91484
+ this.fetch = options?.fetch;
91485
+ if (options?.auth) {
91486
+ this.setAuth(options.auth);
91487
+ }
91488
+ }
91489
+ /**
91490
+ * Obtain the {@link ConvexHttpClient}'s URL to its backend.
91491
+ * @deprecated Use url, which returns the url without /api at the end.
91492
+ *
91493
+ * @returns The URL to the Convex backend, including the client's API version.
91494
+ */
91495
+ backendUrl() {
91496
+ return `${this.address}/api`;
91497
+ }
91498
+ /**
91499
+ * Return the address for this client, useful for creating a new client.
91500
+ *
91501
+ * Not guaranteed to match the address with which this client was constructed:
91502
+ * it may be canonicalized.
91503
+ */
91504
+ get url() {
91505
+ return this.address;
91506
+ }
91507
+ /**
91508
+ * Set the authentication token to be used for subsequent queries and mutations.
91509
+ *
91510
+ * Should be called whenever the token changes (i.e. due to expiration and refresh).
91511
+ *
91512
+ * @param value - JWT-encoded OpenID Connect identity token.
91513
+ */
91514
+ setAuth(value) {
91515
+ this.clearAuth();
91516
+ this.auth = value;
91517
+ }
91518
+ /**
91519
+ * Set admin auth token to allow calling internal queries, mutations, and actions
91520
+ * and acting as an identity.
91521
+ *
91522
+ * @internal
91523
+ */
91524
+ setAdminAuth(token, actingAsIdentity) {
91525
+ this.clearAuth();
91526
+ if (actingAsIdentity !== void 0) {
91527
+ const bytes = new TextEncoder().encode(JSON.stringify(actingAsIdentity));
91528
+ const actingAsIdentityEncoded = btoa(String.fromCodePoint(...bytes));
91529
+ this.adminAuth = `${token}:${actingAsIdentityEncoded}`;
91530
+ } else {
91531
+ this.adminAuth = token;
91532
+ }
91533
+ }
91534
+ /**
91535
+ * Clear the current authentication token if set.
91536
+ */
91537
+ clearAuth() {
91538
+ this.auth = void 0;
91539
+ this.adminAuth = void 0;
91540
+ }
91541
+ /**
91542
+ * Sets whether the result log lines should be printed on the console or not.
91543
+ *
91544
+ * @internal
91545
+ */
91546
+ setDebug(debug4) {
91547
+ this.debug = debug4;
91548
+ }
91549
+ /**
91550
+ * Used to customize the fetch behavior in some runtimes.
91551
+ *
91552
+ * @internal
91553
+ */
91554
+ setFetchOptions(fetchOptions) {
91555
+ this.fetchOptions = fetchOptions;
91556
+ }
91557
+ /**
91558
+ * This API is experimental: it may change or disappear.
91559
+ *
91560
+ * Execute a Convex query function at the same timestamp as every other
91561
+ * consistent query execution run by this HTTP client.
91562
+ *
91563
+ * This doesn't make sense for long-lived ConvexHttpClients as Convex
91564
+ * backends can read a limited amount into the past: beyond 30 seconds
91565
+ * in the past may not be available.
91566
+ *
91567
+ * Create a new client to use a consistent time.
91568
+ *
91569
+ * @param name - The name of the query.
91570
+ * @param args - The arguments object for the query. If this is omitted,
91571
+ * the arguments will be `{}`.
91572
+ * @returns A promise of the query's result.
91573
+ *
91574
+ * @deprecated This API is experimental: it may change or disappear.
91575
+ */
91576
+ async consistentQuery(query2, ...args) {
91577
+ const queryArgs = parseArgs(args[0]);
91578
+ const timestampPromise = this.getTimestamp();
91579
+ return await this.queryInner(query2, queryArgs, { timestampPromise });
91580
+ }
91581
+ async getTimestamp() {
91582
+ if (this.encodedTsPromise) {
91583
+ return this.encodedTsPromise;
91584
+ }
91585
+ return this.encodedTsPromise = this.getTimestampInner();
91586
+ }
91587
+ async getTimestampInner() {
91588
+ const localFetch = this.fetch || specifiedFetch || fetch;
91589
+ const headers = {
91590
+ "Content-Type": "application/json",
91591
+ "Convex-Client": `npm-${version2}`
91592
+ };
91593
+ const response = await localFetch(`${this.address}/api/query_ts`, {
91594
+ ...this.fetchOptions,
91595
+ method: "POST",
91596
+ headers
91597
+ });
91598
+ if (!response.ok) {
91599
+ throw new Error(await response.text());
91600
+ }
91601
+ const { ts } = await response.json();
91602
+ return ts;
91603
+ }
91604
+ /**
91605
+ * Execute a Convex query function.
91606
+ *
91607
+ * @param name - The name of the query.
91608
+ * @param args - The arguments object for the query. If this is omitted,
91609
+ * the arguments will be `{}`.
91610
+ * @returns A promise of the query's result.
91611
+ */
91612
+ async query(query2, ...args) {
91613
+ const queryArgs = parseArgs(args[0]);
91614
+ return await this.queryInner(query2, queryArgs, {});
91615
+ }
91616
+ async queryInner(query2, queryArgs, options) {
91617
+ const name = getFunctionName2(query2);
91618
+ const args = [convexToJson(queryArgs)];
91619
+ const headers = {
91620
+ "Content-Type": "application/json",
91621
+ "Convex-Client": `npm-${version2}`
91622
+ };
91623
+ if (this.adminAuth) {
91624
+ headers["Authorization"] = `Convex ${this.adminAuth}`;
91625
+ } else if (this.auth) {
91626
+ headers["Authorization"] = `Bearer ${this.auth}`;
91627
+ }
91628
+ const localFetch = this.fetch || specifiedFetch || fetch;
91629
+ const timestamp2 = options.timestampPromise ? await options.timestampPromise : void 0;
91630
+ const body = JSON.stringify({
91631
+ path: name,
91632
+ format: "convex_encoded_json",
91633
+ args,
91634
+ ...timestamp2 ? { ts: timestamp2 } : {}
91635
+ });
91636
+ const endpoint = timestamp2 ? `${this.address}/api/query_at_ts` : `${this.address}/api/query`;
91637
+ const response = await localFetch(endpoint, {
91638
+ ...this.fetchOptions,
91639
+ body,
91640
+ method: "POST",
91641
+ headers
91642
+ });
91643
+ if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
91644
+ throw new Error(await response.text());
91645
+ }
91646
+ const respJSON = await response.json();
91647
+ if (this.debug) {
91648
+ for (const line of respJSON.logLines ?? []) {
91649
+ logForFunction(this.logger, "info", "query", name, line);
91650
+ }
91651
+ }
91652
+ switch (respJSON.status) {
91653
+ case "success":
91654
+ return jsonToConvex(respJSON.value);
91655
+ case "error":
91656
+ if (respJSON.errorData !== void 0) {
91657
+ throw forwardErrorData(
91658
+ respJSON.errorData,
91659
+ new ConvexError(respJSON.errorMessage)
91660
+ );
91661
+ }
91662
+ throw new Error(respJSON.errorMessage);
91663
+ default:
91664
+ throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
91665
+ }
91666
+ }
91667
+ async mutationInner(mutation2, mutationArgs) {
91668
+ const name = getFunctionName2(mutation2);
91669
+ const body = JSON.stringify({
91670
+ path: name,
91671
+ format: "convex_encoded_json",
91672
+ args: [convexToJson(mutationArgs)]
91673
+ });
91674
+ const headers = {
91675
+ "Content-Type": "application/json",
91676
+ "Convex-Client": `npm-${version2}`
91677
+ };
91678
+ if (this.adminAuth) {
91679
+ headers["Authorization"] = `Convex ${this.adminAuth}`;
91680
+ } else if (this.auth) {
91681
+ headers["Authorization"] = `Bearer ${this.auth}`;
91682
+ }
91683
+ const localFetch = this.fetch || specifiedFetch || fetch;
91684
+ const response = await localFetch(`${this.address}/api/mutation`, {
91685
+ ...this.fetchOptions,
91686
+ body,
91687
+ method: "POST",
91688
+ headers
91689
+ });
91690
+ if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
91691
+ throw new Error(await response.text());
91692
+ }
91693
+ const respJSON = await response.json();
91694
+ if (this.debug) {
91695
+ for (const line of respJSON.logLines ?? []) {
91696
+ logForFunction(this.logger, "info", "mutation", name, line);
91697
+ }
91698
+ }
91699
+ switch (respJSON.status) {
91700
+ case "success":
91701
+ return jsonToConvex(respJSON.value);
91702
+ case "error":
91703
+ if (respJSON.errorData !== void 0) {
91704
+ throw forwardErrorData(
91705
+ respJSON.errorData,
91706
+ new ConvexError(respJSON.errorMessage)
91707
+ );
91708
+ }
91709
+ throw new Error(respJSON.errorMessage);
91710
+ default:
91711
+ throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
91712
+ }
91713
+ }
91714
+ async processMutationQueue() {
91715
+ if (this.isProcessingQueue) {
91716
+ return;
91717
+ }
91718
+ this.isProcessingQueue = true;
91719
+ while (this.mutationQueue.length > 0) {
91720
+ const { mutation: mutation2, args, resolve: resolve3, reject } = this.mutationQueue.shift();
91721
+ try {
91722
+ const result = await this.mutationInner(mutation2, args);
91723
+ resolve3(result);
91724
+ } catch (error55) {
91725
+ reject(error55);
91726
+ }
91727
+ }
91728
+ this.isProcessingQueue = false;
91729
+ }
91730
+ enqueueMutation(mutation2, args) {
91731
+ return new Promise((resolve3, reject) => {
91732
+ this.mutationQueue.push({ mutation: mutation2, args, resolve: resolve3, reject });
91733
+ void this.processMutationQueue();
91734
+ });
91735
+ }
91736
+ /**
91737
+ * Execute a Convex mutation function. Mutations are queued by default.
91738
+ *
91739
+ * @param name - The name of the mutation.
91740
+ * @param args - The arguments object for the mutation. If this is omitted,
91741
+ * the arguments will be `{}`.
91742
+ * @param options - An optional object containing
91743
+ * @returns A promise of the mutation's result.
91744
+ */
91745
+ async mutation(mutation2, ...args) {
91746
+ const [fnArgs, options] = args;
91747
+ const mutationArgs = parseArgs(fnArgs);
91748
+ const queued = !options?.skipQueue;
91749
+ if (queued) {
91750
+ return await this.enqueueMutation(mutation2, mutationArgs);
91751
+ } else {
91752
+ return await this.mutationInner(mutation2, mutationArgs);
91753
+ }
91754
+ }
91755
+ /**
91756
+ * Execute a Convex action function. Actions are not queued.
91757
+ *
91758
+ * @param name - The name of the action.
91759
+ * @param args - The arguments object for the action. If this is omitted,
91760
+ * the arguments will be `{}`.
91761
+ * @returns A promise of the action's result.
91762
+ */
91763
+ async action(action, ...args) {
91764
+ const actionArgs = parseArgs(args[0]);
91765
+ const name = getFunctionName2(action);
91766
+ const body = JSON.stringify({
91767
+ path: name,
91768
+ format: "convex_encoded_json",
91769
+ args: [convexToJson(actionArgs)]
91770
+ });
91771
+ const headers = {
91772
+ "Content-Type": "application/json",
91773
+ "Convex-Client": `npm-${version2}`
91774
+ };
91775
+ if (this.adminAuth) {
91776
+ headers["Authorization"] = `Convex ${this.adminAuth}`;
91777
+ } else if (this.auth) {
91778
+ headers["Authorization"] = `Bearer ${this.auth}`;
91779
+ }
91780
+ const localFetch = this.fetch || specifiedFetch || fetch;
91781
+ const response = await localFetch(`${this.address}/api/action`, {
91782
+ ...this.fetchOptions,
91783
+ body,
91784
+ method: "POST",
91785
+ headers
91786
+ });
91787
+ if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
91788
+ throw new Error(await response.text());
91789
+ }
91790
+ const respJSON = await response.json();
91791
+ if (this.debug) {
91792
+ for (const line of respJSON.logLines ?? []) {
91793
+ logForFunction(this.logger, "info", "action", name, line);
91794
+ }
91795
+ }
91796
+ switch (respJSON.status) {
91797
+ case "success":
91798
+ return jsonToConvex(respJSON.value);
91799
+ case "error":
91800
+ if (respJSON.errorData !== void 0) {
91801
+ throw forwardErrorData(
91802
+ respJSON.errorData,
91803
+ new ConvexError(respJSON.errorMessage)
91804
+ );
91805
+ }
91806
+ throw new Error(respJSON.errorMessage);
91807
+ default:
91808
+ throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
91809
+ }
91810
+ }
91811
+ /**
91812
+ * Execute a Convex function of an unknown type. These function calls are not queued.
91813
+ *
91814
+ * @param name - The name of the function.
91815
+ * @param args - The arguments object for the function. If this is omitted,
91816
+ * the arguments will be `{}`.
91817
+ * @returns A promise of the function's result.
91818
+ *
91819
+ * @internal
91820
+ */
91821
+ async function(anyFunction, componentPath, ...args) {
91822
+ const functionArgs = parseArgs(args[0]);
91823
+ const name = typeof anyFunction === "string" ? anyFunction : getFunctionName2(anyFunction);
91824
+ const body = JSON.stringify({
91825
+ componentPath,
91826
+ path: name,
91827
+ format: "convex_encoded_json",
91828
+ args: convexToJson(functionArgs)
91829
+ });
91830
+ const headers = {
91831
+ "Content-Type": "application/json",
91832
+ "Convex-Client": `npm-${version2}`
91833
+ };
91834
+ if (this.adminAuth) {
91835
+ headers["Authorization"] = `Convex ${this.adminAuth}`;
91836
+ } else if (this.auth) {
91837
+ headers["Authorization"] = `Bearer ${this.auth}`;
91838
+ }
91839
+ const localFetch = this.fetch || specifiedFetch || fetch;
91840
+ const response = await localFetch(`${this.address}/api/function`, {
91841
+ ...this.fetchOptions,
91842
+ body,
91843
+ method: "POST",
91844
+ headers
91845
+ });
91846
+ if (!response.ok && response.status !== STATUS_CODE_UDF_FAILED) {
91847
+ throw new Error(await response.text());
91848
+ }
91849
+ const respJSON = await response.json();
91850
+ if (this.debug) {
91851
+ for (const line of respJSON.logLines ?? []) {
91852
+ logForFunction(this.logger, "info", "any", name, line);
91853
+ }
91854
+ }
91855
+ switch (respJSON.status) {
91856
+ case "success":
91857
+ return jsonToConvex(respJSON.value);
91858
+ case "error":
91859
+ if (respJSON.errorData !== void 0) {
91860
+ throw forwardErrorData(
91861
+ respJSON.errorData,
91862
+ new ConvexError(respJSON.errorMessage)
91863
+ );
91864
+ }
91865
+ throw new Error(respJSON.errorMessage);
91866
+ default:
91867
+ throw new Error(`Invalid response: ${JSON.stringify(respJSON)}`);
91868
+ }
91869
+ }
91870
+ };
91871
+ }
91872
+ });
91873
+
91874
+ // ../../node_modules/convex/dist/esm/browser/query_options.js
91875
+ function convexQueryOptions(options) {
91876
+ return options;
91877
+ }
91878
+ var init_query_options = __esm({
91879
+ "../../node_modules/convex/dist/esm/browser/query_options.js"() {
91880
+ "use strict";
91881
+ }
91882
+ });
91883
+
91306
91884
  // ../../node_modules/convex/dist/esm/browser/index-node.js
91307
91885
  var index_node_exports = {};
91308
91886
  __export(index_node_exports, {
91309
91887
  BaseConvexClient: () => BaseConvexClient,
91310
91888
  ConvexClient: () => ConvexClient,
91311
- ConvexHttpClient: () => ConvexHttpClient
91889
+ ConvexHttpClient: () => ConvexHttpClient,
91890
+ convexQueryOptions: () => convexQueryOptions
91312
91891
  });
91313
91892
  var init_index_node2 = __esm({
91314
91893
  "../../node_modules/convex/dist/esm/browser/index-node.js"() {
@@ -91316,6 +91895,7 @@ var init_index_node2 = __esm({
91316
91895
  init_client3();
91317
91896
  init_simple_client_node();
91318
91897
  init_http_client();
91898
+ init_query_options();
91319
91899
  }
91320
91900
  });
91321
91901
 
@@ -102526,10 +103106,10 @@ var require_eventemitter3 = __commonJS({
102526
103106
  });
102527
103107
 
102528
103108
  // ../../node_modules/eventemitter3/index.mjs
102529
- var import_index2;
103109
+ var import_index;
102530
103110
  var init_eventemitter3 = __esm({
102531
103111
  "../../node_modules/eventemitter3/index.mjs"() {
102532
- import_index2 = __toESM(require_eventemitter3(), 1);
103112
+ import_index = __toESM(require_eventemitter3(), 1);
102533
103113
  }
102534
103114
  });
102535
103115
 
@@ -102731,7 +103311,7 @@ var init_dist7 = __esm({
102731
103311
  init_eventemitter3();
102732
103312
  init_p_timeout();
102733
103313
  init_priority_queue();
102734
- PQueue = class extends import_index2.default {
103314
+ PQueue = class extends import_index.default {
102735
103315
  #carryoverIntervalCount;
102736
103316
  #isIntervalIgnored;
102737
103317
  #intervalCount = 0;
@@ -128923,8 +129503,8 @@ var require_dist3 = __commonJS({
128923
129503
  this.name = "VolumeError";
128924
129504
  }
128925
129505
  };
128926
- function formatLog(log3) {
128927
- return JSON.parse(JSON.stringify(log3));
129506
+ function formatLog(log4) {
129507
+ return JSON.parse(JSON.stringify(log4));
128928
129508
  }
128929
129509
  function createRpcLogger(logger13) {
128930
129510
  function logEach(stream) {
@@ -143456,11 +144036,12 @@ var init_threadListWindowData = __esm({
143456
144036
  });
143457
144037
 
143458
144038
  // ../../../../shared/threadRuntime/agentGuidance.ts
143459
- var MAX_AGENT_GUIDANCE_UTF8_BYTES, PROJECT_AGENT_GUIDANCE_START_MARKER, PROJECT_AGENT_GUIDANCE_END_MARKER, MANAGED_SAFETY_START_MARKER, MANAGED_SAFETY_END_MARKER, AGENT_GUIDANCE_RESERVED_MARKER_LINES, reservedMarkerLines;
144039
+ var MAX_AGENT_GUIDANCE_UTF8_BYTES, MAX_COMPOSED_AGENT_GUIDANCE_UTF8_BYTES, PROJECT_AGENT_GUIDANCE_START_MARKER, PROJECT_AGENT_GUIDANCE_END_MARKER, MANAGED_SAFETY_START_MARKER, MANAGED_SAFETY_END_MARKER, AGENT_GUIDANCE_RESERVED_MARKER_LINES, reservedMarkerLines;
143460
144040
  var init_agentGuidance = __esm({
143461
144041
  "../../../../shared/threadRuntime/agentGuidance.ts"() {
143462
144042
  "use strict";
143463
144043
  MAX_AGENT_GUIDANCE_UTF8_BYTES = 16 * 1024;
144044
+ MAX_COMPOSED_AGENT_GUIDANCE_UTF8_BYTES = 2 * MAX_AGENT_GUIDANCE_UTF8_BYTES + 2;
143464
144045
  PROJECT_AGENT_GUIDANCE_START_MARKER = "<!-- BOXES_PROJECT_AGENT_GUIDANCE_START -->";
143465
144046
  PROJECT_AGENT_GUIDANCE_END_MARKER = "<!-- BOXES_PROJECT_AGENT_GUIDANCE_END -->";
143466
144047
  MANAGED_SAFETY_START_MARKER = "<!-- DEVBOX_MANAGED_SAFETY_START -->";
@@ -143770,58 +144351,63 @@ var init_onboxAgentPermissionRequestProtocol = __esm({
143770
144351
  });
143771
144352
 
143772
144353
  // ../../../../shared/onboxAgentPermissionRequestPresentation.ts
143773
- var permissionQuestions, threadGrantScope, describeAwsAccess, teamRoleLabel, presentTeamMembershipChange, presentAction, buildOnboxAgentPermissionRequestPresentation;
144354
+ var permissionActions, coordinatorPermissionActions, permissionQuestion, threadGrantScope, describeAwsAccess, teamRoleLabel, presentTeamMembershipChange, presentAction, boxPermissionScope, coordinatorBoxPermissionScope, buildOnboxAgentPermissionRequestPresentation;
143774
144355
  var init_onboxAgentPermissionRequestPresentation = __esm({
143775
144356
  "../../../../shared/onboxAgentPermissionRequestPresentation.ts"() {
143776
144357
  "use strict";
143777
144358
  init_onboxAgentPermissionRequestProtocol();
143778
- permissionQuestions = {
143779
- "read-project-threads": "Allow agents to read other threads in this project?",
143780
- "read-user-threads": "Allow agents to read threads in all your projects?",
143781
- "read-shared-threads": "Allow agents to read your threads and threads shared with you?",
143782
- "read-team-threads": "Allow agents to read your threads and teammates\u2019 threads you can access?",
143783
- "control-created-threads": "Allow agents to pause and resume agents started from this box?",
143784
- "control-project-threads": "Allow agents to pause and resume your agents in this project?",
143785
- "control-user-threads": "Allow agents to pause and resume your agents in all your projects?",
143786
- "message-agents": "Allow agents to message other agents in this project?",
143787
- "message-teammates-agents": "Allow agents to message your teammates\u2019 agents?",
143788
- "destroy-devbox": "Allow agents to destroy and archive this devbox?",
143789
- "destroy-created-devboxes": "Allow agents to destroy and archive devboxes they create?",
143790
- "destroy-project-devboxes": "Allow agents to destroy and archive your devboxes in this project?",
143791
- "create-devboxes-and-threads": "Allow agents to create devboxes and threads?",
143792
- "create-team-templates": "Allow agents to create Team Templates?",
143793
- "edit-devbox-lifecycle": "Allow agents to edit devbox lifecycle?",
143794
- "edit-template-maintenance": "Allow agents to edit template maintenance?",
143795
- "update-thread-titles": "Allow agents to rename threads and devboxes?",
143796
- "move-devboxes-to-folders": "Allow agents to move devboxes to folders?",
143797
- "create-devbox-folders": "Allow agents to create and manage devbox folders?",
143798
- "edit-template-box": "Allow this thread to edit the Template box?",
143799
- "edit-project-settings": "Allow this thread to edit settings?",
143800
- "edit-team-template": "Allow this thread to edit team settings?",
143801
- "edit-personal-environment": "Allow this thread to edit your environment variables?",
143802
- "edit-automations": "Allow this thread to edit your automations?",
143803
- "edit-tailscale-integration": "Allow this thread to change Tailscale auto-connect?",
143804
- "edit-google-cloud-integration": "Allow this thread to choose the Google Cloud project?",
143805
- "change-aws-profile": "Allow this thread to change an AWS profile?",
143806
- "enable-tailscale-integration": "Allow this thread to enable Tailscale?",
143807
- "change-team-membership": "Allow this thread to change your team's members?"
143808
- };
143809
- threadGrantScope = (permission, teamTemplateName) => {
144359
+ permissionActions = {
144360
+ "read-project-threads": "read other threads in this project?",
144361
+ "read-user-threads": "read threads in all your projects?",
144362
+ "read-shared-threads": "read your threads and threads shared with you?",
144363
+ "read-team-threads": "read your threads and teammates\u2019 threads you can access?",
144364
+ "control-created-threads": "pause and resume agents started from this box?",
144365
+ "control-project-threads": "pause and resume your agents in this project?",
144366
+ "control-user-threads": "pause and resume your agents in all your projects?",
144367
+ "message-agents": "message other agents in this project?",
144368
+ "message-teammates-agents": "message your teammates\u2019 agents?",
144369
+ "destroy-devbox": "destroy and archive this devbox?",
144370
+ "destroy-created-devboxes": "destroy and archive devboxes they create?",
144371
+ "destroy-project-devboxes": "destroy and archive your devboxes in this project?",
144372
+ "create-devboxes-and-threads": "create devboxes and threads?",
144373
+ "create-team-templates": "create Team Templates?",
144374
+ "edit-devbox-lifecycle": "edit devbox lifecycle?",
144375
+ "edit-template-maintenance": "edit template maintenance?",
144376
+ "update-thread-titles": "rename threads and devboxes?",
144377
+ "move-devboxes-to-folders": "move devboxes to folders?",
144378
+ "create-devbox-folders": "create and manage devbox folders?",
144379
+ "edit-template-box": "edit the Template box?",
144380
+ "edit-project-settings": "edit settings?",
144381
+ "edit-team-template": "edit team settings?",
144382
+ "edit-personal-environment": "edit your environment variables?",
144383
+ "edit-automations": "edit your automations?",
144384
+ "edit-tailscale-integration": "change Tailscale auto-connect?",
144385
+ "edit-google-cloud-integration": "choose the Google Cloud project?",
144386
+ "change-aws-profile": "change an AWS profile?",
144387
+ "enable-tailscale-integration": "enable Tailscale?",
144388
+ "change-team-membership": "change your team's members?"
144389
+ };
144390
+ coordinatorPermissionActions = {
144391
+ "destroy-created-devboxes": "destroy and archive devboxes it started?",
144392
+ "control-created-threads": "pause and resume agents it started?"
144393
+ };
144394
+ permissionQuestion = (permission, sourceBoxKind) => sourceBoxKind === "coordinator" ? `Allow the coordinator to ${coordinatorPermissionActions[permission] ?? permissionActions[permission]}` : `Allow ${isOnboxAgentThreadGrantPermission(permission) || isOnboxAgentExactActionPermission(permission) ? "this thread" : "agents"} to ${permissionActions[permission]}`;
144395
+ threadGrantScope = (permission, teamTemplateName, subject) => {
143810
144396
  switch (permission) {
143811
144397
  case "edit-template-box":
143812
- return "For the next 3 hours, the agent in this thread will be able to run commands on this project's Template box, change project settings and environment variables, change your account preferences, and take snapshots that future devboxes will use. Agent permission defaults remain user-only.";
144398
+ return `For the next 3 hours, ${subject} will be able to run commands on this project's Template box, change project settings and environment variables, change your account preferences, and take snapshots that future devboxes will use. Agent permission defaults remain user-only.`;
143813
144399
  case "edit-project-settings":
143814
- return "For the next 3 hours, the agent in this thread will be able to change this project's settings, Project URLs, and your environment and member-file values in it, and share this thread with your team. It will also be able to change your account preferences, such as notifications, idle sleep, Git identity, and agent replies. Agent permission defaults remain user-only.";
144400
+ return `For the next 3 hours, ${subject} will be able to change this project's settings, Project URLs, and your environment and member-file values in it, and share this thread with your team. It will also be able to change your account preferences, such as notifications, idle sleep, Git identity, and agent replies. Agent permission defaults remain user-only.`;
143815
144401
  case "edit-personal-environment":
143816
- return "For the next 3 hours, the agent in this thread will be able to add, change, and remove your own environment variables in this project. Changes will reach all your devboxes in this project.";
144402
+ return `For the next 3 hours, ${subject} will be able to add, change, and remove your own environment variables in this project. Changes will reach all your devboxes in this project.`;
143817
144403
  case "edit-tailscale-integration":
143818
- return "For the next 3 hours, the agent in this thread will be able to choose whether new devboxes in this project connect to Tailscale automatically. Saved changes will stay in place after this permission expires.";
144404
+ return `For the next 3 hours, ${subject} will be able to choose whether new devboxes in this project connect to Tailscale automatically. Saved changes will stay in place after this permission expires.`;
143819
144405
  case "edit-google-cloud-integration":
143820
- return "For the next 3 hours, the agent in this thread will be able to choose the Google Cloud project this project uses by default and for quota. Your Google account's access won't change. Saved changes will stay in place after this permission expires.";
144406
+ return `For the next 3 hours, ${subject} will be able to choose the Google Cloud project this project uses by default and for quota. Your Google account's access won't change. Saved changes will stay in place after this permission expires.`;
143821
144407
  case "edit-automations":
143822
- return "For the next 3 hours, the agent in this thread will be able to create, change, pause, run, and delete your automations in this project. Each run will either start a new agent thread on a new devbox, without this conversation, or send the prompt to an existing thread, such as this one. Runs will use box-hours.";
144408
+ return `For the next 3 hours, ${subject} will be able to create, change, pause, run, and delete your automations in this project. Each run will either start a new agent thread on a new devbox, without this conversation, or send the prompt to an existing thread, such as this one. Runs will use box-hours.`;
143823
144409
  case "edit-team-template":
143824
- return teamTemplateName === null ? "For the next 3 hours, the agent in this thread will be able to change your team's settings, such as its name, teammate thread access, idle sleep default, allowed domains, and static egress destinations, and change settings in this project and your account preferences. Membership changes will still need your approval each time. Agent permission defaults remain user-only." : `For the next 3 hours, the agent in this thread will be able to change your team's settings and edit the "${teamTemplateName}" Team Template, including its settings and environment variables, change settings in this project and your account preferences, and save new versions for your team. Membership changes will still need your approval each time. Agent permission defaults remain user-only.`;
144410
+ return teamTemplateName === null ? `For the next 3 hours, ${subject} will be able to change your team's settings, such as its name, teammate thread access, idle sleep default, allowed domains, and static egress destinations, and change settings in any of your team's projects and your account preferences. Membership changes will still need your approval each time. Agent permission defaults remain user-only.` : `For the next 3 hours, ${subject} will be able to change your team's settings and edit the "${teamTemplateName}" Team Template, including its settings and environment variables, change settings in any of your team's projects and your account preferences, and save new versions for your team. Membership changes will still need your approval each time. Agent permission defaults remain user-only.`;
143825
144411
  }
143826
144412
  };
143827
144413
  describeAwsAccess = (choice) => `${choice.roleName} in ${choice.accountName} (${choice.accountId})`;
@@ -143919,6 +144505,37 @@ var init_onboxAgentPermissionRequestPresentation = __esm({
143919
144505
  allowLabel: "Enable Tailscale"
143920
144506
  };
143921
144507
  };
144508
+ boxPermissionScope = ({
144509
+ permission,
144510
+ box,
144511
+ projectScopeAvailable
144512
+ }) => {
144513
+ const projectApproval = projectScopeAvailable ? " Project approval will also apply to your existing and future devboxes, except those you've configured separately." : "";
144514
+ switch (permission) {
144515
+ case "destroy-devbox":
144516
+ return `This will allow every agent on this devbox to request its deletion after all agents finish. Files will be permanently deleted and thread history archived. You can turn this off in Agent permissions.${projectScopeAvailable ? " Project approval will extend this permission to your existing and future devboxes, except those you've configured separately. Agents will only be able to destroy their own devbox." : ""}`;
144517
+ case "destroy-created-devboxes":
144518
+ case "destroy-project-devboxes":
144519
+ return `This will allow agents on this ${box} to request deletion of ${permission === "destroy-created-devboxes" ? "devboxes they created" : "your other devboxes in this project"}. Each devbox will be deleted after all of its agents finish. Its files will be permanently deleted, and its thread history will be archived.${box === "devbox" ? " Agents will also be able to archive threads created by agents on this devbox." : ""} You can turn this off in Agent permissions.${projectApproval}`;
144520
+ case "message-agents":
144521
+ return `Allow will let agents on this ${box} message your other agents in this project and receive their messages until you turn it off. A message will start an idle agent and wake its devbox if it's asleep.${projectApproval}`;
144522
+ case "message-teammates-agents":
144523
+ return `Allow will let agents on this ${box} message your teammates\u2019 agents until you turn it off. Your teammates\u2019 agents will also be able to message agents here once you allow their messages. An allowed message will start an idle agent and wake this ${box} if it's asleep.${projectApproval}`;
144524
+ default:
144525
+ return `Allow will enable this permission on this ${box} until you turn it off.${projectApproval}`;
144526
+ }
144527
+ };
144528
+ coordinatorBoxPermissionScope = (permission) => {
144529
+ switch (permission) {
144530
+ case "destroy-created-devboxes":
144531
+ case "destroy-project-devboxes":
144532
+ return `This will allow the coordinator to request deletion of ${permission === "destroy-created-devboxes" ? "devboxes it started" : "your devboxes in this project"}. Each devbox will be deleted after all of its agents finish. Its files will be permanently deleted, and its thread history will be archived. You can turn this off in the coordinator's Agent permissions.`;
144533
+ case "message-teammates-agents":
144534
+ return "Allow will let the coordinator message your teammates\u2019 agents until you turn it off. Your teammates\u2019 agents will also be able to message the coordinator once you allow their messages.";
144535
+ default:
144536
+ return "Allow will turn this permission on for the coordinator until you turn it off.";
144537
+ }
144538
+ };
143922
144539
  buildOnboxAgentPermissionRequestPresentation = ({
143923
144540
  permission,
143924
144541
  sourceBoxKind,
@@ -143929,7 +144546,7 @@ var init_onboxAgentPermissionRequestPresentation = __esm({
143929
144546
  if (action) return presentAction(action);
143930
144547
  if (isOnboxAgentExactActionPermission(permission))
143931
144548
  return {
143932
- question: permissionQuestions[permission],
144549
+ question: permissionQuestion(permission, sourceBoxKind),
143933
144550
  scope: "Update boxes.dev to see this change.",
143934
144551
  automationsSectionSentence: null,
143935
144552
  details: [],
@@ -143938,11 +144555,17 @@ var init_onboxAgentPermissionRequestPresentation = __esm({
143938
144555
  declineLabel: "Deny",
143939
144556
  projectAllowLabel: "Always allow for project"
143940
144557
  };
143941
- const box = sourceBoxKind === "template_box" ? "Template box" : "devbox";
143942
- const boxScope = permission === "message-agents" ? `Allow will let agents on this ${box} message your other agents in this project and receive their messages until you turn it off. A message will start an idle agent and wake its devbox if it's asleep.` : permission === "message-teammates-agents" ? `Allow will let agents on this ${box} message your teammates\u2019 agents until you turn it off. Your teammates\u2019 agents will also be able to message agents here once you allow their messages. An allowed message will start an idle agent and wake this ${box} if it's asleep.` : `Allow will enable this permission on this ${box} until you turn it off.`;
143943
144558
  return {
143944
- question: permissionQuestions[permission],
143945
- scope: isOnboxAgentThreadGrantPermission(permission) ? threadGrantScope(permission, teamTemplateName) : permission === "destroy-devbox" ? `This will allow every agent on this devbox to request its deletion after all agents finish. Files will be permanently deleted and thread history archived. You can turn this off in Agent permissions.${projectScopeAvailable ? " Project approval will extend this permission to your existing and future devboxes, except those you've configured separately. Agents will only be able to destroy their own devbox." : ""}` : permission === "destroy-created-devboxes" || permission === "destroy-project-devboxes" ? `This will allow agents on this ${box} to request deletion of ${permission === "destroy-created-devboxes" ? "devboxes they created" : "your other devboxes in this project"}. Each devbox will be deleted after all of its agents finish. Its files will be permanently deleted, and its thread history will be archived.${sourceBoxKind === "devbox" ? " Agents will also be able to archive threads created by agents on this devbox." : ""} You can turn this off in Agent permissions.${projectScopeAvailable ? " Project approval will also apply to your existing and future devboxes, except those you've configured separately." : ""}` : `${boxScope}${projectScopeAvailable ? " Project approval will also apply to your existing and future devboxes, except those you've configured separately." : ""}`,
144559
+ question: permissionQuestion(permission, sourceBoxKind),
144560
+ scope: isOnboxAgentThreadGrantPermission(permission) ? threadGrantScope(
144561
+ permission,
144562
+ teamTemplateName,
144563
+ sourceBoxKind === "coordinator" ? "the coordinator" : "the agent in this thread"
144564
+ ) : sourceBoxKind === "coordinator" ? coordinatorBoxPermissionScope(permission) : boxPermissionScope({
144565
+ permission,
144566
+ box: sourceBoxKind === "template_box" ? "Template box" : "devbox",
144567
+ projectScopeAvailable
144568
+ }),
143946
144569
  automationsSectionSentence: permission === "edit-automations" ? {
143947
144570
  before: "Manage these in the ",
143948
144571
  linkText: "automations",
@@ -146989,7 +147612,7 @@ var require_node6 = __commonJS({
146989
147612
  var tty3 = __require("tty");
146990
147613
  var util2 = __require("util");
146991
147614
  exports.init = init3;
146992
- exports.log = log3;
147615
+ exports.log = log4;
146993
147616
  exports.formatArgs = formatArgs;
146994
147617
  exports.save = save;
146995
147618
  exports.load = load2;
@@ -147124,7 +147747,7 @@ var require_node6 = __commonJS({
147124
147747
  }
147125
147748
  return (/* @__PURE__ */ new Date()).toISOString() + " ";
147126
147749
  }
147127
- function log3(...args) {
147750
+ function log4(...args) {
147128
147751
  return process.stderr.write(util2.formatWithOptions(exports.inspectOpts, ...args) + "\n");
147129
147752
  }
147130
147753
  function save(namespaces) {
@@ -175955,7 +176578,7 @@ var require_react_reconciler_production = __commonJS({
175955
176578
  return 2 < lanes ? 8 < lanes ? 0 !== (lanes & 134217727) ? 32 : 268435456 : 8 : 2;
175956
176579
  }
175957
176580
  function setIsStrictModeForDevtools(newIsStrictMode) {
175958
- "function" === typeof log3 && unstable_setDisableYieldValue(newIsStrictMode);
176581
+ "function" === typeof log4 && unstable_setDisableYieldValue(newIsStrictMode);
175959
176582
  if (injectedHook && "function" === typeof injectedHook.setStrictMode)
175960
176583
  try {
175961
176584
  injectedHook.setStrictMode(rendererID, newIsStrictMode);
@@ -183005,7 +183628,7 @@ var require_react_reconciler_production = __commonJS({
183005
183628
  $$$config.diffHydratedPropsForDevWarnings;
183006
183629
  $$$config.diffHydratedTextForDevWarnings;
183007
183630
  $$$config.describeHydratableInstanceForDevWarnings;
183008
- var validateHydratableInstance = $$$config.validateHydratableInstance, validateHydratableTextInstance = $$$config.validateHydratableTextInstance, supportsResources = $$$config.supportsResources, isHostHoistableType = $$$config.isHostHoistableType, getHoistableRoot = $$$config.getHoistableRoot, getResource = $$$config.getResource, acquireResource = $$$config.acquireResource, releaseResource = $$$config.releaseResource, hydrateHoistable = $$$config.hydrateHoistable, mountHoistable = $$$config.mountHoistable, unmountHoistable = $$$config.unmountHoistable, createHoistableInstance = $$$config.createHoistableInstance, prepareToCommitHoistables = $$$config.prepareToCommitHoistables, mayResourceSuspendCommit = $$$config.mayResourceSuspendCommit, preloadResource = $$$config.preloadResource, suspendResource = $$$config.suspendResource, supportsSingletons = $$$config.supportsSingletons, resolveSingletonInstance = $$$config.resolveSingletonInstance, acquireSingletonInstance = $$$config.acquireSingletonInstance, releaseSingletonInstance = $$$config.releaseSingletonInstance, isHostSingletonType = $$$config.isHostSingletonType, isSingletonScope = $$$config.isSingletonScope, valueStack = [], index$jscomp$0 = -1, emptyContextObject = {}, clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log$1 = Math.log, LN2 = Math.LN2, nextTransitionUpdateLane = 256, nextTransitionDeferredLane = 262144, nextRetryLane = 4194304, scheduleCallback$3 = Scheduler2.unstable_scheduleCallback, cancelCallback$1 = Scheduler2.unstable_cancelCallback, shouldYield = Scheduler2.unstable_shouldYield, requestPaint = Scheduler2.unstable_requestPaint, now = Scheduler2.unstable_now, ImmediatePriority = Scheduler2.unstable_ImmediatePriority, UserBlockingPriority = Scheduler2.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler2.unstable_NormalPriority, IdlePriority = Scheduler2.unstable_IdlePriority, log3 = Scheduler2.log, unstable_setDisableYieldValue = Scheduler2.unstable_setDisableYieldValue, rendererID = null, injectedHook = null, objectIs = "function" === typeof Object.is ? Object.is : is, reportGlobalError = "function" === typeof reportError ? reportError : function(error55) {
183631
+ var validateHydratableInstance = $$$config.validateHydratableInstance, validateHydratableTextInstance = $$$config.validateHydratableTextInstance, supportsResources = $$$config.supportsResources, isHostHoistableType = $$$config.isHostHoistableType, getHoistableRoot = $$$config.getHoistableRoot, getResource = $$$config.getResource, acquireResource = $$$config.acquireResource, releaseResource = $$$config.releaseResource, hydrateHoistable = $$$config.hydrateHoistable, mountHoistable = $$$config.mountHoistable, unmountHoistable = $$$config.unmountHoistable, createHoistableInstance = $$$config.createHoistableInstance, prepareToCommitHoistables = $$$config.prepareToCommitHoistables, mayResourceSuspendCommit = $$$config.mayResourceSuspendCommit, preloadResource = $$$config.preloadResource, suspendResource = $$$config.suspendResource, supportsSingletons = $$$config.supportsSingletons, resolveSingletonInstance = $$$config.resolveSingletonInstance, acquireSingletonInstance = $$$config.acquireSingletonInstance, releaseSingletonInstance = $$$config.releaseSingletonInstance, isHostSingletonType = $$$config.isHostSingletonType, isSingletonScope = $$$config.isSingletonScope, valueStack = [], index$jscomp$0 = -1, emptyContextObject = {}, clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log$1 = Math.log, LN2 = Math.LN2, nextTransitionUpdateLane = 256, nextTransitionDeferredLane = 262144, nextRetryLane = 4194304, scheduleCallback$3 = Scheduler2.unstable_scheduleCallback, cancelCallback$1 = Scheduler2.unstable_cancelCallback, shouldYield = Scheduler2.unstable_shouldYield, requestPaint = Scheduler2.unstable_requestPaint, now = Scheduler2.unstable_now, ImmediatePriority = Scheduler2.unstable_ImmediatePriority, UserBlockingPriority = Scheduler2.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler2.unstable_NormalPriority, IdlePriority = Scheduler2.unstable_IdlePriority, log4 = Scheduler2.log, unstable_setDisableYieldValue = Scheduler2.unstable_setDisableYieldValue, rendererID = null, injectedHook = null, objectIs = "function" === typeof Object.is ? Object.is : is, reportGlobalError = "function" === typeof reportError ? reportError : function(error55) {
183009
183632
  if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
183010
183633
  var event = new window.ErrorEvent("error", {
183011
183634
  bubbles: true,
@@ -184328,7 +184951,7 @@ var require_react_reconciler_development = __commonJS({
184328
184951
  return hook.checkDCE ? true : false;
184329
184952
  }
184330
184953
  function setIsStrictModeForDevtools(newIsStrictMode) {
184331
- "function" === typeof log3 && unstable_setDisableYieldValue(newIsStrictMode);
184954
+ "function" === typeof log4 && unstable_setDisableYieldValue(newIsStrictMode);
184332
184955
  if (injectedHook && "function" === typeof injectedHook.setStrictMode)
184333
184956
  try {
184334
184957
  injectedHook.setStrictMode(rendererID, newIsStrictMode);
@@ -195597,7 +196220,7 @@ var require_react_reconciler_development = __commonJS({
195597
196220
  var fiberStack = [];
195598
196221
  var index$jscomp$0 = -1, emptyContextObject = {};
195599
196222
  Object.freeze(emptyContextObject);
195600
- var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log$1 = Math.log, LN2 = Math.LN2, nextTransitionUpdateLane = 256, nextTransitionDeferredLane = 262144, nextRetryLane = 4194304, scheduleCallback$3 = Scheduler2.unstable_scheduleCallback, cancelCallback$1 = Scheduler2.unstable_cancelCallback, shouldYield = Scheduler2.unstable_shouldYield, requestPaint = Scheduler2.unstable_requestPaint, now$1 = Scheduler2.unstable_now, ImmediatePriority = Scheduler2.unstable_ImmediatePriority, UserBlockingPriority = Scheduler2.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler2.unstable_NormalPriority, IdlePriority = Scheduler2.unstable_IdlePriority, log3 = Scheduler2.log, unstable_setDisableYieldValue = Scheduler2.unstable_setDisableYieldValue, rendererID = null, injectedHook = null, hasLoggedError = false, isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__, lastResetTime = 0;
196223
+ var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log$1 = Math.log, LN2 = Math.LN2, nextTransitionUpdateLane = 256, nextTransitionDeferredLane = 262144, nextRetryLane = 4194304, scheduleCallback$3 = Scheduler2.unstable_scheduleCallback, cancelCallback$1 = Scheduler2.unstable_cancelCallback, shouldYield = Scheduler2.unstable_shouldYield, requestPaint = Scheduler2.unstable_requestPaint, now$1 = Scheduler2.unstable_now, ImmediatePriority = Scheduler2.unstable_ImmediatePriority, UserBlockingPriority = Scheduler2.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler2.unstable_NormalPriority, IdlePriority = Scheduler2.unstable_IdlePriority, log4 = Scheduler2.log, unstable_setDisableYieldValue = Scheduler2.unstable_setDisableYieldValue, rendererID = null, injectedHook = null, hasLoggedError = false, isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__, lastResetTime = 0;
195601
196224
  if ("object" === typeof performance && "function" === typeof performance.now) {
195602
196225
  var localPerformance = performance;
195603
196226
  var getCurrentTime = function() {
@@ -236192,7 +236815,7 @@ var init_agentConfigScan = __esm({
236192
236815
  env: env3 = process.env,
236193
236816
  homeDir: homeDir2 = os20.homedir(),
236194
236817
  localRepoRoot = null,
236195
- log: log3 = console.info,
236818
+ log: log4 = console.info,
236196
236819
  individualSkills = false
236197
236820
  } = {}) => {
236198
236821
  const scannedAt = nowIso3();
@@ -236215,7 +236838,7 @@ var init_agentConfigScan = __esm({
236215
236838
  for (const item of items) {
236216
236839
  countsByCategory[item.category] = (countsByCategory[item.category] ?? 0) + 1;
236217
236840
  }
236218
- log3("[desktop-agent-config-scan]", {
236841
+ log4("[desktop-agent-config-scan]", {
236219
236842
  itemCount: items.length,
236220
236843
  credentialFileCount,
236221
236844
  countsByCategory,
@@ -255943,7 +256566,7 @@ var require_merge3 = __commonJS({
255943
256566
  var require_addPairToJSMap = __commonJS({
255944
256567
  "../../node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports) {
255945
256568
  "use strict";
255946
- var log3 = require_log();
256569
+ var log4 = require_log();
255947
256570
  var merge4 = require_merge3();
255948
256571
  var stringify3 = require_stringify();
255949
256572
  var identity = require_identity();
@@ -255992,7 +256615,7 @@ var require_addPairToJSMap = __commonJS({
255992
256615
  let jsonStr = JSON.stringify(strKey);
255993
256616
  if (jsonStr.length > 40)
255994
256617
  jsonStr = jsonStr.substring(0, 36) + '..."';
255995
- log3.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
256618
+ log4.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
255996
256619
  ctx.mapKeyWarned = true;
255997
256620
  }
255998
256621
  return strKey;
@@ -261408,7 +262031,7 @@ var require_public_api = __commonJS({
261408
262031
  var composer = require_composer();
261409
262032
  var Document = require_Document();
261410
262033
  var errors = require_errors2();
261411
- var log3 = require_log();
262034
+ var log4 = require_log();
261412
262035
  var identity = require_identity();
261413
262036
  var lineCounter = require_line_counter();
261414
262037
  var parser = require_parser2();
@@ -261460,7 +262083,7 @@ var require_public_api = __commonJS({
261460
262083
  const doc = parseDocument(src, options);
261461
262084
  if (!doc)
261462
262085
  return null;
261463
- doc.warnings.forEach((warning3) => log3.warn(doc.options.logLevel, warning3));
262086
+ doc.warnings.forEach((warning3) => log4.warn(doc.options.logLevel, warning3));
261464
262087
  if (doc.errors.length > 0) {
261465
262088
  if (doc.options.logLevel !== "silent")
261466
262089
  throw doc.errors[0];
@@ -261768,7 +262391,7 @@ var init_parse6 = __esm({
261768
262391
  if (!filePath) {
261769
262392
  return;
261770
262393
  }
261771
- const vars = [];
262394
+ const vars2 = [];
261772
262395
  if (record3.vars !== void 0 && record3.vars !== null) {
261773
262396
  const varsArray = readArray(
261774
262397
  sink,
@@ -261801,7 +262424,7 @@ var init_parse6 = __esm({
261801
262424
  "Set `secret` to true when the value is sensitive."
261802
262425
  );
261803
262426
  if (name !== null && secret !== null) {
261804
- vars.push({ name, secret });
262427
+ vars2.push({ name, secret });
261805
262428
  }
261806
262429
  });
261807
262430
  }
@@ -261809,7 +262432,7 @@ var init_parse6 = __esm({
261809
262432
  path: filePath,
261810
262433
  note: readOptionalString(sink, `${location}.note`, record3.note),
261811
262434
  from: readOptionalString(sink, `${location}.from`, record3.from),
261812
- vars
262435
+ vars: vars2
261813
262436
  });
261814
262437
  });
261815
262438
  return out;
@@ -272419,9 +273042,9 @@ var renderTemplate2;
272419
273042
  var init_template = __esm({
272420
273043
  "src/devbox/commands/init/codex/template.ts"() {
272421
273044
  "use strict";
272422
- renderTemplate2 = (template, vars) => template.replace(
273045
+ renderTemplate2 = (template, vars2) => template.replace(
272423
273046
  /\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,
272424
- (match, key) => vars[key] ?? match
273047
+ (match, key) => vars2[key] ?? match
272425
273048
  );
272426
273049
  }
272427
273050
  });
@@ -272455,7 +273078,7 @@ var init_prompts = __esm({
272455
273078
  const raw = await fsPromises4.readFile(promptPath, "utf8");
272456
273079
  return raw;
272457
273080
  };
272458
- loadPrompt = async (name, vars = {}) => renderTemplate2(await readPromptTemplate(name), vars).trim();
273081
+ loadPrompt = async (name, vars2 = {}) => renderTemplate2(await readPromptTemplate(name), vars2).trim();
272459
273082
  loadLocalEnvSecretsScanPrompt = async () => loadPrompt("local-scan-env-secrets.md");
272460
273083
  loadLocalExternalScanPrompt = async () => loadPrompt("local-scan-external.md");
272461
273084
  loadLocalExtraArtifactsScanPrompt = async () => loadPrompt("local-scan-extra-artifacts.md");
@@ -274322,7 +274945,7 @@ ${stdout}`;
274322
274945
  const relative2 = path79.relative(repoRoot, resolved) || filePath;
274323
274946
  return toPosixPath(relative2);
274324
274947
  };
274325
- countSecretVars = (vars) => vars.reduce((count, entry) => count + (entry.isSecret ? 1 : 0), 0);
274948
+ countSecretVars = (vars2) => vars2.reduce((count, entry) => count + (entry.isSecret ? 1 : 0), 0);
274326
274949
  buildEnvFileHint = (entry) => {
274327
274950
  const usageText = entry.usage?.trim() || "none";
274328
274951
  const secrets = countSecretVars(entry.vars);
@@ -274722,7 +275345,7 @@ var init_artifacts = __esm({
274722
275345
  }
274723
275346
  return value;
274724
275347
  };
274725
- buildArtifactEntry = (repoRoot, kind, name, artifactPath, homeDir2, description, vars, usage2) => {
275348
+ buildArtifactEntry = (repoRoot, kind, name, artifactPath, homeDir2, description, vars2, usage2) => {
274726
275349
  const expanded = expandHomePath2(artifactPath, homeDir2);
274727
275350
  const resolved = path80.isAbsolute(expanded) ? expanded : path80.resolve(repoRoot, expanded);
274728
275351
  const base = {
@@ -274734,8 +275357,8 @@ var init_artifacts = __esm({
274734
275357
  if (description !== void 0) {
274735
275358
  base.description = description;
274736
275359
  }
274737
- if (vars !== void 0) {
274738
- base.vars = vars;
275360
+ if (vars2 !== void 0) {
275361
+ base.vars = vars2;
274739
275362
  }
274740
275363
  if (usage2 !== void 0) {
274741
275364
  base.usage = usage2;
@@ -279553,17 +280176,17 @@ var init_setupPlanFlow = __esm({
279553
280176
  }
279554
280177
  });
279555
280178
  } else {
279556
- const log3 = zt({
280179
+ const log4 = zt({
279557
280180
  title: LOCAL_SCAN_TASK_TITLE,
279558
280181
  limit: 1,
279559
280182
  spacing: 0
279560
280183
  });
279561
280184
  let active = true;
279562
- const envSecretsRow = log3.group("");
279563
- const externalRow = log3.group("");
279564
- const extraArtifactsRow = log3.group("");
279565
- const databasesRow = log3.group("");
279566
- const servicesRow = log3.group("");
280185
+ const envSecretsRow = log4.group("");
280186
+ const externalRow = log4.group("");
280187
+ const extraArtifactsRow = log4.group("");
280188
+ const databasesRow = log4.group("");
280189
+ const servicesRow = log4.group("");
279567
280190
  const makeUpdater = (row, label) => {
279568
280191
  let state = createInitialScanRowState("starting");
279569
280192
  const render2 = () => {
@@ -279622,10 +280245,10 @@ var init_setupPlanFlow = __esm({
279622
280245
  updateServices
279623
280246
  });
279624
280247
  active = false;
279625
- log3.success(LOCAL_SCAN_TASK_TITLE);
280248
+ log4.success(LOCAL_SCAN_TASK_TITLE);
279626
280249
  } catch (error55) {
279627
280250
  active = false;
279628
- log3.error(LOCAL_SCAN_TASK_TITLE);
280251
+ log4.error(LOCAL_SCAN_TASK_TITLE);
279629
280252
  throw error55;
279630
280253
  }
279631
280254
  }
@@ -280301,17 +280924,17 @@ var init_setupPlanFlow = __esm({
280301
280924
  }
280302
280925
  });
280303
280926
  } else {
280304
- const log3 = zt({
280927
+ const log4 = zt({
280305
280928
  title: "Applying Codex feedback",
280306
280929
  limit: 1,
280307
280930
  spacing: 0
280308
280931
  });
280309
280932
  let active = true;
280310
- const envSecretsRow = envSecretsFeedback ? log3.group("") : null;
280311
- const externalRow = externalFeedback ? log3.group("") : null;
280312
- const extraArtifactsRow = extraArtifactsFeedback ? log3.group("") : null;
280313
- const databasesRow = databasesFeedback ? log3.group("") : null;
280314
- const servicesRow = servicesFeedback ? log3.group("") : null;
280933
+ const envSecretsRow = envSecretsFeedback ? log4.group("") : null;
280934
+ const externalRow = externalFeedback ? log4.group("") : null;
280935
+ const extraArtifactsRow = extraArtifactsFeedback ? log4.group("") : null;
280936
+ const databasesRow = databasesFeedback ? log4.group("") : null;
280937
+ const servicesRow = servicesFeedback ? log4.group("") : null;
280315
280938
  const makeUpdater = (row, label) => {
280316
280939
  let state = createInitialScanRowState("starting");
280317
280940
  const render2 = () => {
@@ -280359,10 +280982,10 @@ var init_setupPlanFlow = __esm({
280359
280982
  updateServices
280360
280983
  });
280361
280984
  active = false;
280362
- log3.success("Applying Codex feedback");
280985
+ log4.success("Applying Codex feedback");
280363
280986
  } catch (error55) {
280364
280987
  active = false;
280365
- log3.error("Applying Codex feedback");
280988
+ log4.error("Applying Codex feedback");
280366
280989
  throw error55;
280367
280990
  }
280368
280991
  }
@@ -295047,7 +295670,7 @@ var init_agentPermissionRequests = __esm({
295047
295670
  init_resourceOutput();
295048
295671
  listPending = makeFunctionReference("onboxAgentPermissionRequestList:listPendingForViewer");
295049
295672
  respond = makeFunctionReference("onboxAgentPermissionRequests:respondForViewer");
295050
- boxLabel = (entry) => `${entry.sourceBoxKind === "template_box" ? "Template box" : "devbox"} ${entry.boxAlias}`;
295673
+ boxLabel = (entry) => entry.sourceBoxKind === "coordinator" ? "the coordinator" : `${entry.sourceBoxKind === "template_box" ? "Template box" : "devbox"} ${entry.boxAlias}`;
295051
295674
  describeRequest = (entry) => {
295052
295675
  const { permission } = entry.request;
295053
295676
  if (!isOnboxAgentPermission(permission)) {
@@ -295171,7 +295794,7 @@ var init_agentPermissionRequests = __esm({
295171
295794
  if (isOnboxAgentPermission(permission) && isOnboxAgentThreadGrantPermission(permission)) {
295172
295795
  return `Allowed ${permission} for 3 hours in thread "${entry.threadTitle}".`;
295173
295796
  }
295174
- return scope === "project" ? `Allowed ${permission} for the project. It will apply to ${boxLabel(entry)} and to devboxes you haven't configured separately.` : `Allowed ${permission} on ${boxLabel(entry)}.`;
295797
+ return scope === "project" ? `Allowed ${permission} for the project. It will apply to ${boxLabel(entry)} and to devboxes you haven't configured separately.` : `Allowed ${permission} ${entry.sourceBoxKind === "coordinator" ? "for" : "on"} ${boxLabel(entry)}.`;
295175
295798
  };
295176
295799
  runAnswer = async (decision, args, dependencies) => {
295177
295800
  const parsed = parseAnswerArgs(decision, args);
@@ -301839,4 +302462,4 @@ react/cjs/react-jsx-runtime.development.js:
301839
302462
  *)
301840
302463
  */
301841
302464
 
301842
- //# debugId=9cbc3858-b3e6-5f8d-9e71-d79a39e38e58
302465
+ //# debugId=4e057937-23ce-557d-8df1-9ba22fd3a10a