tandem-editor 0.14.0 → 0.14.2

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.
@@ -40,7 +40,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
40
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
41
 
42
42
  // src/shared/constants.ts
43
- var DEFAULT_WS_PORT, DEFAULT_MCP_PORT, TANDEM_REPO_URL, TANDEM_ISSUES_NEW_URL, SUPPORTED_EXTENSIONS, MAX_FILE_SIZE, SESSION_MAX_AGE, TANDEM_MODE_DEFAULT, SELECTION_DWELL_DEFAULT_MS, SELECTION_DWELL_MIN_MS, SELECTION_DWELL_MAX_MS, CHARS_PER_PAGE, LARGE_FILE_PAGE_THRESHOLD, VERY_LARGE_FILE_PAGE_THRESHOLD, CTRL_ROOM, Y_MAP_ANNOTATIONS, Y_MAP_AWARENESS, Y_MAP_USER_AWARENESS, Y_MAP_MODE, Y_MAP_DWELL_MS, Y_MAP_CHAT, Y_MAP_DOCUMENT_META, Y_MAP_ANNOTATION_REPLIES, Y_MAP_SAVED_AT_VERSION, Y_MAP_AUTHORSHIP, Y_MAP_SELECTION, Y_MAP_ACTIVITY, Y_MAP_CLAUDE, Y_MAP_OPEN_DOCUMENTS, Y_MAP_ACTIVE_DOCUMENT_ID, Y_MAP_ACTIVE_DOCUMENT_EPOCH, Y_MAP_READ_ONLY, Y_MAP_STORE_READ_ONLY, Y_MAP_EXTERNAL_CONFLICT, NOTIFICATION_BUFFER_SIZE, ACTIVITY_INFO_TTL_MS, TUTORIAL_ANNOTATION_PREFIX, CHANNEL_EVENT_BUFFER_SIZE, CHANNEL_EVENT_BUFFER_AGE_MS, CHANNEL_SSE_KEEPALIVE_MS, TOKEN_FILE_NAME, DEFAULT_BIND_HOST, TANDEM_ALLOW_UNAUTHENTICATED_LAN_ENV, TANDEM_DISABLE_FIRST_RUN_WIZARD_ENV, TAURI_HOSTNAME;
43
+ var DEFAULT_WS_PORT, DEFAULT_MCP_PORT, TANDEM_REPO_URL, TANDEM_ISSUES_NEW_URL, SUPPORTED_EXTENSIONS, MAX_FILE_SIZE, SESSION_MAX_AGE, TANDEM_MODE_DEFAULT, SELECTION_DWELL_DEFAULT_MS, SELECTION_DWELL_MIN_MS, SELECTION_DWELL_MAX_MS, CHARS_PER_PAGE, LARGE_FILE_PAGE_THRESHOLD, VERY_LARGE_FILE_PAGE_THRESHOLD, CTRL_ROOM, Y_MAP_ANNOTATIONS, Y_MAP_AWARENESS, Y_MAP_USER_AWARENESS, Y_MAP_MODE, Y_MAP_DWELL_MS, Y_MAP_CHAT, Y_MAP_DOCUMENT_META, Y_MAP_ANNOTATION_REPLIES, Y_MAP_SAVED_AT_VERSION, Y_MAP_AUTHORSHIP, Y_MAP_SELECTION, Y_MAP_ACTIVITY, Y_MAP_CLAUDE, Y_MAP_OPEN_DOCUMENTS, Y_MAP_ACTIVE_DOCUMENT_ID, Y_MAP_ACTIVE_DOCUMENT_EPOCH, Y_MAP_READ_ONLY, Y_MAP_STORE_READ_ONLY, Y_MAP_EXTERNAL_CONFLICT, NOTIFICATION_BUFFER_SIZE, ACTIVITY_INFO_TTL_MS, TUTORIAL_ANNOTATION_PREFIX, CHANNEL_EVENT_BUFFER_SIZE, CHANNEL_EVENT_BUFFER_AGE_MS, CHANNEL_SSE_KEEPALIVE_MS, TOKEN_FILE_NAME, DEFAULT_BIND_HOST, TANDEM_ALLOW_UNAUTHENTICATED_LAN_ENV, TANDEM_DISABLE_FIRST_RUN_WIZARD_ENV, TAURI_HOSTNAME, TAURI_LINUX_ORIGIN;
44
44
  var init_constants = __esm({
45
45
  "src/shared/constants.ts"() {
46
46
  "use strict";
@@ -89,6 +89,7 @@ var init_constants = __esm({
89
89
  TANDEM_ALLOW_UNAUTHENTICATED_LAN_ENV = "TANDEM_ALLOW_UNAUTHENTICATED_LAN";
90
90
  TANDEM_DISABLE_FIRST_RUN_WIZARD_ENV = "TANDEM_DISABLE_FIRST_RUN_WIZARD";
91
91
  TAURI_HOSTNAME = "tauri.localhost";
92
+ TAURI_LINUX_ORIGIN = "tauri://localhost";
92
93
  }
93
94
  });
94
95
 
@@ -1135,14 +1136,14 @@ var callAll, id, isOneOf;
1135
1136
  var init_function = __esm({
1136
1137
  "node_modules/lib0/function.js"() {
1137
1138
  "use strict";
1138
- callAll = (fs19, args2, i = 0) => {
1139
+ callAll = (fs20, args2, i = 0) => {
1139
1140
  try {
1140
- for (; i < fs19.length; i++) {
1141
- fs19[i](...args2);
1141
+ for (; i < fs20.length; i++) {
1142
+ fs20[i](...args2);
1142
1143
  }
1143
1144
  } finally {
1144
- if (i < fs19.length) {
1145
- callAll(fs19, args2, i + 1);
1145
+ if (i < fs20.length) {
1146
+ callAll(fs20, args2, i + 1);
1146
1147
  }
1147
1148
  }
1148
1149
  };
@@ -3167,15 +3168,15 @@ var init_yjs = __esm({
3167
3168
  sortAndMergeDeleteSet(ds);
3168
3169
  transaction.afterState = getStateVector(transaction.doc.store);
3169
3170
  doc.emit("beforeObserverCalls", [transaction, doc]);
3170
- const fs19 = [];
3171
+ const fs20 = [];
3171
3172
  transaction.changed.forEach(
3172
- (subs, itemtype) => fs19.push(() => {
3173
+ (subs, itemtype) => fs20.push(() => {
3173
3174
  if (itemtype._item === null || !itemtype._item.deleted) {
3174
3175
  itemtype._callObserver(transaction, subs);
3175
3176
  }
3176
3177
  })
3177
3178
  );
3178
- fs19.push(() => {
3179
+ fs20.push(() => {
3179
3180
  transaction.changedParentTypes.forEach((events2, type3) => {
3180
3181
  if (type3._dEH.l.length > 0 && (type3._item === null || !type3._item.deleted)) {
3181
3182
  events2 = events2.filter(
@@ -3186,19 +3187,19 @@ var init_yjs = __esm({
3186
3187
  event._path = null;
3187
3188
  });
3188
3189
  events2.sort((event1, event2) => event1.path.length - event2.path.length);
3189
- fs19.push(() => {
3190
+ fs20.push(() => {
3190
3191
  callEventHandlerListeners(type3._dEH, events2, transaction);
3191
3192
  });
3192
3193
  }
3193
3194
  });
3194
- fs19.push(() => doc.emit("afterTransaction", [transaction, doc]));
3195
- fs19.push(() => {
3195
+ fs20.push(() => doc.emit("afterTransaction", [transaction, doc]));
3196
+ fs20.push(() => {
3196
3197
  if (transaction._needFormattingCleanup) {
3197
3198
  cleanupYTextAfterTransaction(transaction);
3198
3199
  }
3199
3200
  });
3200
3201
  });
3201
- callAll(fs19, []);
3202
+ callAll(fs20, []);
3202
3203
  } finally {
3203
3204
  if (doc.gc) {
3204
3205
  tryGcDeleteSet(ds, store, doc.gcFilter);
@@ -3739,10 +3740,10 @@ var init_yjs = __esm({
3739
3740
  }
3740
3741
  };
3741
3742
  getPathTo = (parent, child) => {
3742
- const path30 = [];
3743
+ const path31 = [];
3743
3744
  while (child._item !== null && child !== parent) {
3744
3745
  if (child._item.parentSub !== null) {
3745
- path30.unshift(child._item.parentSub);
3746
+ path31.unshift(child._item.parentSub);
3746
3747
  } else {
3747
3748
  let i = 0;
3748
3749
  let c = (
@@ -3755,12 +3756,12 @@ var init_yjs = __esm({
3755
3756
  }
3756
3757
  c = c.right;
3757
3758
  }
3758
- path30.unshift(i);
3759
+ path31.unshift(i);
3759
3760
  }
3760
3761
  child = /** @type {AbstractType<any>} */
3761
3762
  child._item.parent;
3762
3763
  }
3763
- return path30;
3764
+ return path31;
3764
3765
  };
3765
3766
  warnPrematureAccess = () => {
3766
3767
  warn("Invalid access: Add Yjs type to a document before reading data.");
@@ -8528,7 +8529,7 @@ function transformGfmAutolinkLiterals(tree) {
8528
8529
  { ignore: ["link", "linkReference"] }
8529
8530
  );
8530
8531
  }
8531
- function findUrl(_3, protocol, domain2, path30, match) {
8532
+ function findUrl(_3, protocol, domain2, path31, match) {
8532
8533
  let prefix = "";
8533
8534
  if (!previous(match)) {
8534
8535
  return false;
@@ -8541,7 +8542,7 @@ function findUrl(_3, protocol, domain2, path30, match) {
8541
8542
  if (!isCorrectDomain(domain2)) {
8542
8543
  return false;
8543
8544
  }
8544
- const parts = splitUrl(domain2 + path30);
8545
+ const parts = splitUrl(domain2 + path31);
8545
8546
  if (!parts[0]) return false;
8546
8547
  const result2 = {
8547
8548
  type: "link",
@@ -20347,8 +20348,8 @@ function assertNonEmpty(part, name2) {
20347
20348
  throw new Error("`" + name2 + "` cannot be empty");
20348
20349
  }
20349
20350
  }
20350
- function assertPath(path30, name2) {
20351
- if (!path30) {
20351
+ function assertPath(path31, name2) {
20352
+ if (!path31) {
20352
20353
  throw new Error("Setting `" + name2 + "` requires `path` to be set too");
20353
20354
  }
20354
20355
  }
@@ -20534,13 +20535,13 @@ var init_lib21 = __esm({
20534
20535
  * @returns {undefined}
20535
20536
  * Nothing.
20536
20537
  */
20537
- set path(path30) {
20538
- if (isUrl(path30)) {
20539
- path30 = fileURLToPath(path30);
20538
+ set path(path31) {
20539
+ if (isUrl(path31)) {
20540
+ path31 = fileURLToPath(path31);
20540
20541
  }
20541
- assertNonEmpty(path30, "path");
20542
- if (this.path !== path30) {
20543
- this.history.push(path30);
20542
+ assertNonEmpty(path31, "path");
20543
+ if (this.path !== path31) {
20544
+ this.history.push(path31);
20544
20545
  }
20545
20546
  }
20546
20547
  /**
@@ -23310,8 +23311,8 @@ var init_tap = __esm({
23310
23311
  });
23311
23312
 
23312
23313
  // node_modules/underscore/modules/toPath.js
23313
- function toPath(path30) {
23314
- return isArray_default(path30) ? path30 : [path30];
23314
+ function toPath(path31) {
23315
+ return isArray_default(path31) ? path31 : [path31];
23315
23316
  }
23316
23317
  var init_toPath = __esm({
23317
23318
  "node_modules/underscore/modules/toPath.js"() {
@@ -23323,8 +23324,8 @@ var init_toPath = __esm({
23323
23324
  });
23324
23325
 
23325
23326
  // node_modules/underscore/modules/_toPath.js
23326
- function toPath2(path30) {
23327
- return _.toPath(path30);
23327
+ function toPath2(path31) {
23328
+ return _.toPath(path31);
23328
23329
  }
23329
23330
  var init_toPath2 = __esm({
23330
23331
  "node_modules/underscore/modules/_toPath.js"() {
@@ -23335,11 +23336,11 @@ var init_toPath2 = __esm({
23335
23336
  });
23336
23337
 
23337
23338
  // node_modules/underscore/modules/_deepGet.js
23338
- function deepGet(obj2, path30) {
23339
- var length3 = path30.length;
23339
+ function deepGet(obj2, path31) {
23340
+ var length3 = path31.length;
23340
23341
  for (var i = 0; i < length3; i++) {
23341
23342
  if (obj2 == null) return void 0;
23342
- obj2 = obj2[path30[i]];
23343
+ obj2 = obj2[path31[i]];
23343
23344
  }
23344
23345
  return length3 ? obj2 : void 0;
23345
23346
  }
@@ -23350,8 +23351,8 @@ var init_deepGet = __esm({
23350
23351
  });
23351
23352
 
23352
23353
  // node_modules/underscore/modules/get.js
23353
- function get(object4, path30, defaultValue) {
23354
- var value = deepGet(object4, toPath2(path30));
23354
+ function get(object4, path31, defaultValue) {
23355
+ var value = deepGet(object4, toPath2(path31));
23355
23356
  return isUndefined(value) ? defaultValue : value;
23356
23357
  }
23357
23358
  var init_get = __esm({
@@ -23364,11 +23365,11 @@ var init_get = __esm({
23364
23365
  });
23365
23366
 
23366
23367
  // node_modules/underscore/modules/has.js
23367
- function has2(obj2, path30) {
23368
- path30 = toPath2(path30);
23369
- var length3 = path30.length;
23368
+ function has2(obj2, path31) {
23369
+ path31 = toPath2(path31);
23370
+ var length3 = path31.length;
23370
23371
  for (var i = 0; i < length3; i++) {
23371
- var key = path30[i];
23372
+ var key = path31[i];
23372
23373
  if (!has(obj2, key)) return false;
23373
23374
  obj2 = obj2[key];
23374
23375
  }
@@ -23408,10 +23409,10 @@ var init_matcher = __esm({
23408
23409
  });
23409
23410
 
23410
23411
  // node_modules/underscore/modules/property.js
23411
- function property(path30) {
23412
- path30 = toPath2(path30);
23412
+ function property(path31) {
23413
+ path31 = toPath2(path31);
23413
23414
  return function(obj2) {
23414
- return deepGet(obj2, path30);
23415
+ return deepGet(obj2, path31);
23415
23416
  };
23416
23417
  }
23417
23418
  var init_property = __esm({
@@ -23527,8 +23528,8 @@ var init_noop = __esm({
23527
23528
  // node_modules/underscore/modules/propertyOf.js
23528
23529
  function propertyOf(obj2) {
23529
23530
  if (obj2 == null) return noop;
23530
- return function(path30) {
23531
- return get(obj2, path30);
23531
+ return function(path31) {
23532
+ return get(obj2, path31);
23532
23533
  };
23533
23534
  }
23534
23535
  var init_propertyOf = __esm({
@@ -23733,14 +23734,14 @@ var init_template = __esm({
23733
23734
  });
23734
23735
 
23735
23736
  // node_modules/underscore/modules/result.js
23736
- function result(obj2, path30, fallback) {
23737
- path30 = toPath2(path30);
23738
- var length3 = path30.length;
23737
+ function result(obj2, path31, fallback) {
23738
+ path31 = toPath2(path31);
23739
+ var length3 = path31.length;
23739
23740
  if (!length3) {
23740
23741
  return isFunction_default(fallback) ? fallback.call(obj2) : fallback;
23741
23742
  }
23742
23743
  for (var i = 0; i < length3; i++) {
23743
- var prop = obj2 == null ? void 0 : obj2[path30[i]];
23744
+ var prop = obj2 == null ? void 0 : obj2[path31[i]];
23744
23745
  if (prop === void 0) {
23745
23746
  prop = fallback;
23746
23747
  i = length3;
@@ -24464,14 +24465,14 @@ var init_invoke = __esm({
24464
24465
  init_map2();
24465
24466
  init_deepGet();
24466
24467
  init_toPath2();
24467
- invoke_default = restArguments(function(obj2, path30, args2) {
24468
+ invoke_default = restArguments(function(obj2, path31, args2) {
24468
24469
  var contextPath, func;
24469
- if (isFunction_default(path30)) {
24470
- func = path30;
24470
+ if (isFunction_default(path31)) {
24471
+ func = path31;
24471
24472
  } else {
24472
- path30 = toPath2(path30);
24473
- contextPath = path30.slice(0, -1);
24474
- path30 = path30[path30.length - 1];
24473
+ path31 = toPath2(path31);
24474
+ contextPath = path31.slice(0, -1);
24475
+ path31 = path31[path31.length - 1];
24475
24476
  }
24476
24477
  return map4(obj2, function(context2) {
24477
24478
  var method = func;
@@ -24480,7 +24481,7 @@ var init_invoke = __esm({
24480
24481
  context2 = deepGet(context2, contextPath);
24481
24482
  }
24482
24483
  if (context2 == null) return void 0;
24483
- method = context2[path30];
24484
+ method = context2[path31];
24484
24485
  }
24485
24486
  return method == null ? method : method.apply(context2, args2);
24486
24487
  });
@@ -33998,8 +33999,8 @@ var require_utils = __commonJS({
33998
33999
  var result2 = transform2[inputType][outputType](input);
33999
34000
  return result2;
34000
34001
  };
34001
- exports3.resolve = function(path30) {
34002
- var parts = path30.split("/");
34002
+ exports3.resolve = function(path31) {
34003
+ var parts = path31.split("/");
34003
34004
  var result2 = [];
34004
34005
  for (var index2 = 0; index2 < parts.length; index2++) {
34005
34006
  var part = parts[index2];
@@ -39852,18 +39853,18 @@ var require_object = __commonJS({
39852
39853
  var object4 = new ZipObject(name2, zipObjectContent, o);
39853
39854
  this.files[name2] = object4;
39854
39855
  };
39855
- var parentFolder = function(path30) {
39856
- if (path30.slice(-1) === "/") {
39857
- path30 = path30.substring(0, path30.length - 1);
39856
+ var parentFolder = function(path31) {
39857
+ if (path31.slice(-1) === "/") {
39858
+ path31 = path31.substring(0, path31.length - 1);
39858
39859
  }
39859
- var lastSlash = path30.lastIndexOf("/");
39860
- return lastSlash > 0 ? path30.substring(0, lastSlash) : "";
39860
+ var lastSlash = path31.lastIndexOf("/");
39861
+ return lastSlash > 0 ? path31.substring(0, lastSlash) : "";
39861
39862
  };
39862
- var forceTrailingSlash = function(path30) {
39863
- if (path30.slice(-1) !== "/") {
39864
- path30 += "/";
39863
+ var forceTrailingSlash = function(path31) {
39864
+ if (path31.slice(-1) !== "/") {
39865
+ path31 += "/";
39865
39866
  }
39866
- return path30;
39867
+ return path31;
39867
39868
  };
39868
39869
  var folderAdd = function(name2, createFolders) {
39869
39870
  createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
@@ -40902,27 +40903,27 @@ var require_zipfile = __commonJS({
40902
40903
  };
40903
40904
  });
40904
40905
  }
40905
- function splitPath2(path30) {
40906
- var lastIndex = path30.lastIndexOf("/");
40906
+ function splitPath2(path31) {
40907
+ var lastIndex = path31.lastIndexOf("/");
40907
40908
  if (lastIndex === -1) {
40908
- return { dirname: "", basename: path30 };
40909
+ return { dirname: "", basename: path31 };
40909
40910
  } else {
40910
40911
  return {
40911
- dirname: path30.substring(0, lastIndex),
40912
- basename: path30.substring(lastIndex + 1)
40912
+ dirname: path31.substring(0, lastIndex),
40913
+ basename: path31.substring(lastIndex + 1)
40913
40914
  };
40914
40915
  }
40915
40916
  }
40916
40917
  function joinPath() {
40917
- var nonEmptyPaths = Array.prototype.filter.call(arguments, function(path30) {
40918
- return path30;
40918
+ var nonEmptyPaths = Array.prototype.filter.call(arguments, function(path31) {
40919
+ return path31;
40919
40920
  });
40920
40921
  var relevantPaths = [];
40921
- nonEmptyPaths.forEach(function(path30) {
40922
- if (/^\//.test(path30)) {
40923
- relevantPaths = [path30];
40922
+ nonEmptyPaths.forEach(function(path31) {
40923
+ if (/^\//.test(path31)) {
40924
+ relevantPaths = [path31];
40924
40925
  } else {
40925
- relevantPaths.push(path30);
40926
+ relevantPaths.push(path31);
40926
40927
  }
40927
40928
  });
40928
40929
  return relevantPaths.join("/");
@@ -48347,9 +48348,9 @@ var require_office_xml_reader = __commonJS({
48347
48348
  return collapseAlternateContent(document4)[0];
48348
48349
  });
48349
48350
  }
48350
- function readXmlFromZipFile(docxFile, path30) {
48351
- if (docxFile.exists(path30)) {
48352
- return docxFile.read(path30, "utf-8").then(stripUtf8Bom).then(read);
48351
+ function readXmlFromZipFile(docxFile, path31) {
48352
+ if (docxFile.exists(path31)) {
48353
+ return docxFile.read(path31, "utf-8").then(stripUtf8Bom).then(read);
48353
48354
  } else {
48354
48355
  return promises.resolve(null);
48355
48356
  }
@@ -50116,10 +50117,10 @@ var require_body_reader = __commonJS({
50116
50117
  }
50117
50118
  }
50118
50119
  function findEmbeddedImageFile(relationshipId) {
50119
- var path30 = uris.uriToZipEntryName("word", relationships.findTargetByRelationshipId(relationshipId));
50120
+ var path31 = uris.uriToZipEntryName("word", relationships.findTargetByRelationshipId(relationshipId));
50120
50121
  return {
50121
- path: path30,
50122
- read: docxFile.read.bind(docxFile, path30)
50122
+ path: path31,
50123
+ read: docxFile.read.bind(docxFile, path31)
50123
50124
  };
50124
50125
  }
50125
50126
  function readImage(imageFile, altText) {
@@ -50359,12 +50360,12 @@ var require_content_types_reader = __commonJS({
50359
50360
  }
50360
50361
  function contentTypes(overrides, extensionDefaults) {
50361
50362
  return {
50362
- findContentType: function(path30) {
50363
- var overrideContentType = overrides[path30];
50363
+ findContentType: function(path31) {
50364
+ var overrideContentType = overrides[path31];
50364
50365
  if (overrideContentType) {
50365
50366
  return overrideContentType;
50366
50367
  } else {
50367
- var pathParts = path30.split(".");
50368
+ var pathParts = path31.split(".");
50368
50369
  var extension3 = pathParts[pathParts.length - 1];
50369
50370
  if (extensionDefaults.hasOwnProperty(extension3)) {
50370
50371
  return extensionDefaults[extension3];
@@ -50611,12 +50612,12 @@ var require_comments_reader = __commonJS({
50611
50612
  var require_path_is_absolute = __commonJS({
50612
50613
  "node_modules/path-is-absolute/index.js"(exports3, module3) {
50613
50614
  "use strict";
50614
- function posix2(path30) {
50615
- return path30.charAt(0) === "/";
50615
+ function posix2(path31) {
50616
+ return path31.charAt(0) === "/";
50616
50617
  }
50617
- function win32(path30) {
50618
+ function win32(path31) {
50618
50619
  var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
50619
- var result2 = splitDeviceRe.exec(path30);
50620
+ var result2 = splitDeviceRe.exec(path31);
50620
50621
  var device = result2[1] || "";
50621
50622
  var isUnc = Boolean(device && device.charAt(1) !== ":");
50622
50623
  return Boolean(result2[2] || isUnc);
@@ -50631,7 +50632,7 @@ var require_path_is_absolute = __commonJS({
50631
50632
  var require_files = __commonJS({
50632
50633
  "node_modules/mammoth/lib/docx/files.js"(exports3) {
50633
50634
  "use strict";
50634
- var fs19 = __require("fs");
50635
+ var fs20 = __require("fs");
50635
50636
  var url = __require("url");
50636
50637
  var os5 = __require("os");
50637
50638
  var dirname6 = __require("path").dirname;
@@ -50651,19 +50652,19 @@ var require_files = __commonJS({
50651
50652
  }
50652
50653
  var base = options.relativeToFile ? dirname6(options.relativeToFile) : null;
50653
50654
  function read(uri2, encoding) {
50654
- return resolveUri(uri2).then(function(path30) {
50655
- return readFile4(path30, encoding).caught(function(error5) {
50655
+ return resolveUri(uri2).then(function(path31) {
50656
+ return readFile4(path31, encoding).caught(function(error5) {
50656
50657
  var message = "could not open external image: '" + uri2 + "' (document directory: '" + base + "')\n" + error5.message;
50657
50658
  return promises.reject(new Error(message));
50658
50659
  });
50659
50660
  });
50660
50661
  }
50661
50662
  function resolveUri(uri2) {
50662
- var path30 = uriToPath(uri2);
50663
- if (isAbsolutePath(path30)) {
50664
- return promises.resolve(path30);
50663
+ var path31 = uriToPath(uri2);
50664
+ if (isAbsolutePath(path31)) {
50665
+ return promises.resolve(path31);
50665
50666
  } else if (base) {
50666
- return promises.resolve(resolvePath(base, path30));
50667
+ return promises.resolve(resolvePath(base, path31));
50667
50668
  } else {
50668
50669
  return promises.reject(new Error("could not find external image '" + uri2 + "', path of input document is unknown"));
50669
50670
  }
@@ -50672,18 +50673,18 @@ var require_files = __commonJS({
50672
50673
  read
50673
50674
  };
50674
50675
  }
50675
- var readFile4 = promises.promisify(fs19.readFile.bind(fs19));
50676
+ var readFile4 = promises.promisify(fs20.readFile.bind(fs20));
50676
50677
  function uriToPath(uriString, platform3) {
50677
50678
  if (!platform3) {
50678
50679
  platform3 = os5.platform();
50679
50680
  }
50680
50681
  var uri2 = url.parse(uriString);
50681
50682
  if (isLocalFileUri(uri2) || isRelativeUri(uri2)) {
50682
- var path30 = decodeURIComponent(uri2.path);
50683
- if (platform3 === "win32" && /^\/[a-z]:/i.test(path30)) {
50684
- return path30.slice(1);
50683
+ var path31 = decodeURIComponent(uri2.path);
50684
+ if (platform3 === "win32" && /^\/[a-z]:/i.test(path31)) {
50685
+ return path31.slice(1);
50685
50686
  } else {
50686
- return path30;
50687
+ return path31;
50687
50688
  }
50688
50689
  } else {
50689
50690
  throw new Error("Could not convert URI to path: " + uriString);
@@ -50884,18 +50885,18 @@ var require_docx_reader = __commonJS({
50884
50885
  readElement: contentTypesReader.readContentTypesFromXml,
50885
50886
  defaultValue: contentTypesReader.defaultContentTypes
50886
50887
  });
50887
- function readNumberingFromZipFile(zipFile, path30, styles) {
50888
+ function readNumberingFromZipFile(zipFile, path31, styles) {
50888
50889
  return xmlFileReader({
50889
- filename: path30,
50890
+ filename: path31,
50890
50891
  readElement: function(element) {
50891
50892
  return numberingXml.readNumberingXml(element, { styles });
50892
50893
  },
50893
50894
  defaultValue: numberingXml.defaultNumbering
50894
50895
  })(zipFile);
50895
50896
  }
50896
- function readStylesFromZipFile(zipFile, path30) {
50897
+ function readStylesFromZipFile(zipFile, path31) {
50897
50898
  return xmlFileReader({
50898
- filename: path30,
50899
+ filename: path31,
50899
50900
  readElement: stylesReader.readStylesXml,
50900
50901
  defaultValue: stylesReader.defaultStyles
50901
50902
  })(zipFile);
@@ -50927,10 +50928,10 @@ var require_style_map = __commonJS({
50927
50928
  });
50928
50929
  }
50929
50930
  function updateRelationships(docxFile) {
50930
- var path30 = "word/_rels/document.xml.rels";
50931
+ var path31 = "word/_rels/document.xml.rels";
50931
50932
  var relationshipsUri = "http://schemas.openxmlformats.org/package/2006/relationships";
50932
50933
  var relationshipElementName = "{" + relationshipsUri + "}Relationship";
50933
- return docxFile.read(path30, "utf8").then(xml2.readString).then(function(relationshipsContainer) {
50934
+ return docxFile.read(path31, "utf8").then(xml2.readString).then(function(relationshipsContainer) {
50934
50935
  var relationships = relationshipsContainer.children;
50935
50936
  addOrUpdateElement(relationships, relationshipElementName, "Id", {
50936
50937
  "Id": "rMammothStyleMap",
@@ -50938,21 +50939,21 @@ var require_style_map = __commonJS({
50938
50939
  "Target": styleMapAbsolutePath
50939
50940
  });
50940
50941
  var namespaces = { "": relationshipsUri };
50941
- return docxFile.write(path30, xml2.writeString(relationshipsContainer, namespaces));
50942
+ return docxFile.write(path31, xml2.writeString(relationshipsContainer, namespaces));
50942
50943
  });
50943
50944
  }
50944
50945
  function updateContentTypes(docxFile) {
50945
- var path30 = "[Content_Types].xml";
50946
+ var path31 = "[Content_Types].xml";
50946
50947
  var contentTypesUri = "http://schemas.openxmlformats.org/package/2006/content-types";
50947
50948
  var overrideName = "{" + contentTypesUri + "}Override";
50948
- return docxFile.read(path30, "utf8").then(xml2.readString).then(function(typesElement) {
50949
+ return docxFile.read(path31, "utf8").then(xml2.readString).then(function(typesElement) {
50949
50950
  var children = typesElement.children;
50950
50951
  addOrUpdateElement(children, overrideName, "PartName", {
50951
50952
  "PartName": styleMapAbsolutePath,
50952
50953
  "ContentType": "text/prs.mammoth.style-map"
50953
50954
  });
50954
50955
  var namespaces = { "": contentTypesUri };
50955
- return docxFile.write(path30, xml2.writeString(typesElement, namespaces));
50956
+ return docxFile.write(path31, xml2.writeString(typesElement, namespaces));
50956
50957
  });
50957
50958
  }
50958
50959
  function addOrUpdateElement(elements, name2, identifyingAttribute, attributes) {
@@ -51649,9 +51650,9 @@ var require_document_to_html = __commonJS({
51649
51650
  };
51650
51651
  var paths = [];
51651
51652
  if (run2.highlight !== null) {
51652
- var path30 = findHtmlPath({ type: "highlight", color: run2.highlight });
51653
- if (path30) {
51654
- paths.push(path30);
51653
+ var path31 = findHtmlPath({ type: "highlight", color: run2.highlight });
51654
+ if (path31) {
51655
+ paths.push(path31);
51655
51656
  }
51656
51657
  }
51657
51658
  if (run2.isSmallCaps) {
@@ -51686,15 +51687,15 @@ var require_document_to_html = __commonJS({
51686
51687
  messages.push(unrecognisedStyleWarning("run", run2));
51687
51688
  }
51688
51689
  paths.push(stylePath);
51689
- paths.forEach(function(path31) {
51690
- nodes = path31.wrap.bind(path31, nodes);
51690
+ paths.forEach(function(path32) {
51691
+ nodes = path32.wrap.bind(path32, nodes);
51691
51692
  });
51692
51693
  return nodes();
51693
51694
  }
51694
51695
  function findHtmlPathForRunProperty(elementType, defaultTagName) {
51695
- var path30 = findHtmlPath({ type: elementType });
51696
- if (path30) {
51697
- return path30;
51696
+ var path31 = findHtmlPath({ type: elementType });
51697
+ if (path31) {
51698
+ return path31;
51698
51699
  } else if (defaultTagName) {
51699
51700
  return htmlPaths.element(defaultTagName, {}, { fresh: false });
51700
51701
  } else {
@@ -53414,11 +53415,11 @@ var require_options_reader = __commonJS({
53414
53415
  var require_unzip = __commonJS({
53415
53416
  "node_modules/mammoth/lib/unzip.js"(exports3) {
53416
53417
  "use strict";
53417
- var fs19 = __require("fs");
53418
+ var fs20 = __require("fs");
53418
53419
  var promises = require_promises();
53419
53420
  var zipfile = require_zipfile();
53420
53421
  exports3.openZip = openZip;
53421
- var readFile4 = promises.promisify(fs19.readFile);
53422
+ var readFile4 = promises.promisify(fs20.readFile);
53422
53423
  function openZip(options) {
53423
53424
  if (options.path) {
53424
53425
  return readFile4(options.path).then(zipfile.openArrayBuffer);
@@ -57355,8 +57356,8 @@ var init_parseUtil = __esm({
57355
57356
  init_errors();
57356
57357
  init_en();
57357
57358
  makeIssue = (params2) => {
57358
- const { data, path: path30, errorMaps, issueData } = params2;
57359
- const fullPath = [...path30, ...issueData.path || []];
57359
+ const { data, path: path31, errorMaps, issueData } = params2;
57360
+ const fullPath = [...path31, ...issueData.path || []];
57360
57361
  const fullIssue = {
57361
57362
  ...issueData,
57362
57363
  path: fullPath
@@ -57667,11 +57668,11 @@ var init_types = __esm({
57667
57668
  init_parseUtil();
57668
57669
  init_util();
57669
57670
  ParseInputLazyPath = class {
57670
- constructor(parent, value, path30, key) {
57671
+ constructor(parent, value, path31, key) {
57671
57672
  this._cachedPath = [];
57672
57673
  this.parent = parent;
57673
57674
  this.data = value;
57674
- this._path = path30;
57675
+ this._path = path31;
57675
57676
  this._key = key;
57676
57677
  }
57677
57678
  get path() {
@@ -72556,8 +72557,8 @@ function requireHash() {
72556
72557
  })(hash$1);
72557
72558
  return hash$1;
72558
72559
  }
72559
- function commonjsRequire(path30) {
72560
- throw new Error('Could not dynamically require "' + path30 + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
72560
+ function commonjsRequire(path31) {
72561
+ throw new Error('Could not dynamically require "' + path31 + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
72561
72562
  }
72562
72563
  function requireJszip_min() {
72563
72564
  if (hasRequiredJszip_min) return jszip_min.exports;
@@ -84014,6 +84015,38 @@ var init_platform = __esm({
84014
84015
  }
84015
84016
  });
84016
84017
 
84018
+ // src/server/annotations/lockfile.ts
84019
+ function lockfilePayload() {
84020
+ return JSON.stringify({ pid: process.pid, startedAtMs: Date.now(), app: LOCK_APP_ID });
84021
+ }
84022
+ function parseLockfile(raw) {
84023
+ const trimmed = raw.trim();
84024
+ if (trimmed.startsWith("{")) {
84025
+ try {
84026
+ const parsed = JSON.parse(trimmed);
84027
+ const pid2 = parsed.pid;
84028
+ if (typeof pid2 !== "number" || !Number.isInteger(pid2) || pid2 <= 0) return null;
84029
+ return {
84030
+ pid: pid2,
84031
+ startedAtMs: typeof parsed.startedAtMs === "number" ? parsed.startedAtMs : void 0,
84032
+ app: typeof parsed.app === "string" ? parsed.app : void 0
84033
+ };
84034
+ } catch {
84035
+ return null;
84036
+ }
84037
+ }
84038
+ const pid = Number.parseInt(trimmed, 10);
84039
+ if (!Number.isFinite(pid) || pid <= 0) return null;
84040
+ return { pid };
84041
+ }
84042
+ var LOCK_APP_ID;
84043
+ var init_lockfile = __esm({
84044
+ "src/server/annotations/lockfile.ts"() {
84045
+ "use strict";
84046
+ LOCK_APP_ID = "tandem";
84047
+ }
84048
+ });
84049
+
84017
84050
  // src/server/annotations/process-identity.ts
84018
84051
  import { execFile } from "child_process";
84019
84052
  import fs2 from "fs/promises";
@@ -84110,29 +84143,6 @@ async function ensureDirReady() {
84110
84143
  await fs3.mkdir(getAnnotationsDir(), { recursive: true });
84111
84144
  annotationsDirReady = true;
84112
84145
  }
84113
- function lockfilePayload() {
84114
- return JSON.stringify({ pid: process.pid, startedAtMs: Date.now(), app: LOCK_APP_ID });
84115
- }
84116
- function parseLockfile(raw) {
84117
- const trimmed = raw.trim();
84118
- if (trimmed.startsWith("{")) {
84119
- try {
84120
- const parsed = JSON.parse(trimmed);
84121
- const pid2 = parsed.pid;
84122
- if (typeof pid2 !== "number" || !Number.isInteger(pid2) || pid2 <= 0) return null;
84123
- return {
84124
- pid: pid2,
84125
- startedAtMs: typeof parsed.startedAtMs === "number" ? parsed.startedAtMs : void 0,
84126
- app: typeof parsed.app === "string" ? parsed.app : void 0
84127
- };
84128
- } catch {
84129
- return null;
84130
- }
84131
- }
84132
- const pid = Number.parseInt(trimmed, 10);
84133
- if (!Number.isFinite(pid) || pid <= 0) return null;
84134
- return { pid };
84135
- }
84136
84146
  function isPidAlive(pid) {
84137
84147
  try {
84138
84148
  process.kill(pid, 0);
@@ -84488,13 +84498,14 @@ async function closeStore(docHash2) {
84488
84498
  }
84489
84499
  }
84490
84500
  }
84491
- var DEBOUNCE_MS, NOTIFY_THROTTLE_MS, DISABLE_AFTER_FAILURES, LOCK_FILE, annotationsDirReady, readOnly, pending, failureState, LOCK_APP_ID, reclaimInFlight;
84501
+ var DEBOUNCE_MS, NOTIFY_THROTTLE_MS, DISABLE_AFTER_FAILURES, LOCK_FILE, annotationsDirReady, readOnly, pending, failureState, reclaimInFlight;
84492
84502
  var init_store = __esm({
84493
84503
  "src/server/annotations/store.ts"() {
84494
84504
  "use strict";
84495
84505
  init_file_io();
84496
84506
  init_notifications();
84497
84507
  init_platform();
84508
+ init_lockfile();
84498
84509
  init_process_identity();
84499
84510
  init_schema();
84500
84511
  DEBOUNCE_MS = 100;
@@ -84505,7 +84516,6 @@ var init_store = __esm({
84505
84516
  readOnly = false;
84506
84517
  pending = /* @__PURE__ */ new Map();
84507
84518
  failureState = /* @__PURE__ */ new Map();
84508
- LOCK_APP_ID = "tandem";
84509
84519
  reclaimInFlight = null;
84510
84520
  }
84511
84521
  });
@@ -91037,6 +91047,7 @@ function assertAllowedOrigin(origin) {
91037
91047
  console.error("[Hocuspocus] Rejected connection: missing Origin header");
91038
91048
  throw new Error("Connection rejected: missing origin header");
91039
91049
  }
91050
+ if (origin === TAURI_LINUX_ORIGIN) return;
91040
91051
  let url;
91041
91052
  try {
91042
91053
  url = new URL(origin);
@@ -91805,30 +91816,30 @@ async function getCurrentUserSid() {
91805
91816
  cachedCurrentUserSid = match[1];
91806
91817
  return cachedCurrentUserSid;
91807
91818
  }
91808
- async function setRestrictiveAcl(path30) {
91819
+ async function setRestrictiveAcl(path31) {
91809
91820
  if (process.platform !== "win32") return;
91810
91821
  const sid = await getCurrentUserSid();
91811
91822
  try {
91812
- await execFileAsync2(systemBin("icacls.exe"), [path30, "/inheritance:r", "/grant:r", `*${sid}:F`]);
91823
+ await execFileAsync2(systemBin("icacls.exe"), [path31, "/inheritance:r", "/grant:r", `*${sid}:F`]);
91813
91824
  } catch (err) {
91814
- throw new Error(`setRestrictiveAcl: icacls failed on ${path30}: ${err.message}`, {
91825
+ throw new Error(`setRestrictiveAcl: icacls failed on ${path31}: ${err.message}`, {
91815
91826
  cause: err
91816
91827
  });
91817
91828
  }
91818
- await assertNoBroadAce(path30);
91829
+ await assertNoBroadAce(path31);
91819
91830
  }
91820
- async function assertNoBroadAce(path30) {
91831
+ async function assertNoBroadAce(path31) {
91821
91832
  if (process.platform !== "win32") return;
91822
91833
  const script = "Import-Module Microsoft.PowerShell.Security; (Get-Acl -LiteralPath $env:TANDEM_ACL_PATH).Sddl";
91823
91834
  const { stdout } = await runPowerShell(script, {
91824
91835
  ...process.env,
91825
- TANDEM_ACL_PATH: path30
91836
+ TANDEM_ACL_PATH: path31
91826
91837
  });
91827
91838
  const sddl = stdout.trim();
91828
91839
  for (const fragment of BROAD_SDDL_FRAGMENTS) {
91829
91840
  if (sddl.includes(fragment)) {
91830
91841
  throw new Error(
91831
- `assertNoBroadAce: ${path30} has a broad-principal ACE (SDDL fragment ${fragment}). SDDL:
91842
+ `assertNoBroadAce: ${path31} has a broad-principal ACE (SDDL fragment ${fragment}). SDDL:
91832
91843
  ${sddl}`
91833
91844
  );
91834
91845
  }
@@ -92641,15 +92652,15 @@ async function atomicWrite2(content3, dest) {
92641
92652
  }
92642
92653
  }
92643
92654
  }
92644
- async function unlinkOrLeak(path30, originalErr) {
92655
+ async function unlinkOrLeak(path31, originalErr) {
92645
92656
  try {
92646
- await unlink(path30);
92657
+ await unlink(path31);
92647
92658
  } catch (cleanupErr) {
92648
92659
  if (originalErr instanceof Error && originalErr.cause === void 0) {
92649
92660
  originalErr.cause = cleanupErr;
92650
92661
  }
92651
92662
  console.error(
92652
- ` Warning: could not remove ${path30} after a previous failure: ${cleanupErr.message}`
92663
+ ` Warning: could not remove ${path31} after a previous failure: ${cleanupErr.message}`
92653
92664
  );
92654
92665
  }
92655
92666
  }
@@ -92833,8 +92844,8 @@ async function refreshSkillIfStale(opts = {}) {
92833
92844
  let onDiskVersion = -1;
92834
92845
  let readErr;
92835
92846
  try {
92836
- const fs19 = await import("fs/promises");
92837
- const current = await fs19.readFile(skillPath, "utf8");
92847
+ const fs20 = await import("fs/promises");
92848
+ const current = await fs20.readFile(skillPath, "utf8");
92838
92849
  onDiskVersion = readSkillVersion(current);
92839
92850
  } catch (err) {
92840
92851
  if (err.code !== "ENOENT") readErr = err;
@@ -92912,9 +92923,9 @@ var init_apply = __esm({
92912
92923
  MCP_URL = `http://127.0.0.1:${DEFAULT_MCP_PORT}`;
92913
92924
  MAX_CONFIG_BYTES = 5 * 1024 * 1024;
92914
92925
  PathRejectedError = class extends Error {
92915
- constructor(path30, reason, message) {
92926
+ constructor(path31, reason, message) {
92916
92927
  super(message);
92917
- this.path = path30;
92928
+ this.path = path31;
92918
92929
  this.reason = reason;
92919
92930
  }
92920
92931
  name = "PathRejectedError";
@@ -112150,11 +112161,11 @@ var require_mime_types = __commonJS({
112150
112161
  }
112151
112162
  return exts[0];
112152
112163
  }
112153
- function lookup(path30) {
112154
- if (!path30 || typeof path30 !== "string") {
112164
+ function lookup(path31) {
112165
+ if (!path31 || typeof path31 !== "string") {
112155
112166
  return false;
112156
112167
  }
112157
- var extension4 = extname("x." + path30).toLowerCase().slice(1);
112168
+ var extension4 = extname("x." + path31).toLowerCase().slice(1);
112158
112169
  if (!extension4) {
112159
112170
  return false;
112160
112171
  }
@@ -115652,13 +115663,13 @@ var require_view = __commonJS({
115652
115663
  "node_modules/express/lib/view.js"(exports3, module3) {
115653
115664
  "use strict";
115654
115665
  var debug4 = require_src()("express:view");
115655
- var path30 = __require("path");
115656
- var fs19 = __require("fs");
115657
- var dirname6 = path30.dirname;
115658
- var basename3 = path30.basename;
115659
- var extname = path30.extname;
115660
- var join12 = path30.join;
115661
- var resolve5 = path30.resolve;
115666
+ var path31 = __require("path");
115667
+ var fs20 = __require("fs");
115668
+ var dirname6 = path31.dirname;
115669
+ var basename3 = path31.basename;
115670
+ var extname = path31.extname;
115671
+ var join12 = path31.join;
115672
+ var resolve5 = path31.resolve;
115662
115673
  module3.exports = View;
115663
115674
  function View(name2, options) {
115664
115675
  var opts = options || {};
@@ -115687,17 +115698,17 @@ var require_view = __commonJS({
115687
115698
  this.path = this.lookup(fileName);
115688
115699
  }
115689
115700
  View.prototype.lookup = function lookup(name2) {
115690
- var path31;
115701
+ var path32;
115691
115702
  var roots = [].concat(this.root);
115692
115703
  debug4('lookup "%s"', name2);
115693
- for (var i = 0; i < roots.length && !path31; i++) {
115704
+ for (var i = 0; i < roots.length && !path32; i++) {
115694
115705
  var root3 = roots[i];
115695
115706
  var loc = resolve5(root3, name2);
115696
115707
  var dir = dirname6(loc);
115697
115708
  var file = basename3(loc);
115698
- path31 = this.resolve(dir, file);
115709
+ path32 = this.resolve(dir, file);
115699
115710
  }
115700
- return path31;
115711
+ return path32;
115701
115712
  };
115702
115713
  View.prototype.render = function render2(options, callback) {
115703
115714
  var sync = true;
@@ -115719,21 +115730,21 @@ var require_view = __commonJS({
115719
115730
  };
115720
115731
  View.prototype.resolve = function resolve6(dir, file) {
115721
115732
  var ext = this.ext;
115722
- var path31 = join12(dir, file);
115723
- var stat2 = tryStat(path31);
115733
+ var path32 = join12(dir, file);
115734
+ var stat2 = tryStat(path32);
115724
115735
  if (stat2 && stat2.isFile()) {
115725
- return path31;
115736
+ return path32;
115726
115737
  }
115727
- path31 = join12(dir, basename3(file, ext), "index" + ext);
115728
- stat2 = tryStat(path31);
115738
+ path32 = join12(dir, basename3(file, ext), "index" + ext);
115739
+ stat2 = tryStat(path32);
115729
115740
  if (stat2 && stat2.isFile()) {
115730
- return path31;
115741
+ return path32;
115731
115742
  }
115732
115743
  };
115733
- function tryStat(path31) {
115734
- debug4('stat "%s"', path31);
115744
+ function tryStat(path32) {
115745
+ debug4('stat "%s"', path32);
115735
115746
  try {
115736
- return fs19.statSync(path31);
115747
+ return fs20.statSync(path32);
115737
115748
  } catch (e) {
115738
115749
  return void 0;
115739
115750
  }
@@ -115746,14 +115757,14 @@ var require_etag = __commonJS({
115746
115757
  "node_modules/etag/index.js"(exports3, module3) {
115747
115758
  "use strict";
115748
115759
  module3.exports = etag;
115749
- var crypto8 = __require("crypto");
115760
+ var crypto9 = __require("crypto");
115750
115761
  var Stats = __require("fs").Stats;
115751
115762
  var toString3 = Object.prototype.toString;
115752
115763
  function entitytag(entity) {
115753
115764
  if (entity.length === 0) {
115754
115765
  return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
115755
115766
  }
115756
- var hash2 = crypto8.createHash("sha1").update(entity, "utf8").digest("base64").substring(0, 27);
115767
+ var hash2 = crypto9.createHash("sha1").update(entity, "utf8").digest("base64").substring(0, 27);
115757
115768
  var len = typeof entity === "string" ? Buffer.byteLength(entity, "utf8") : entity.length;
115758
115769
  return '"' + len.toString(16) + "-" + hash2 + '"';
115759
115770
  }
@@ -116923,15 +116934,15 @@ var require_dist2 = __commonJS({
116923
116934
  if (token.type === endType)
116924
116935
  break;
116925
116936
  if (token.type === "char" || token.type === "escape") {
116926
- let path30 = token.value;
116937
+ let path31 = token.value;
116927
116938
  let cur = tokens[pos];
116928
116939
  while (cur.type === "char" || cur.type === "escape") {
116929
- path30 += cur.value;
116940
+ path31 += cur.value;
116930
116941
  cur = tokens[++pos];
116931
116942
  }
116932
116943
  output.push({
116933
116944
  type: "text",
116934
- value: encodePath(path30)
116945
+ value: encodePath(path31)
116935
116946
  });
116936
116947
  continue;
116937
116948
  }
@@ -116955,16 +116966,16 @@ var require_dist2 = __commonJS({
116955
116966
  }
116956
116967
  return new TokenData(consumeUntil("end"), str);
116957
116968
  }
116958
- function compile(path30, options = {}) {
116969
+ function compile(path31, options = {}) {
116959
116970
  const { encode = encodeURIComponent, delimiter: delimiter2 = DEFAULT_DELIMITER } = options;
116960
- const data = typeof path30 === "object" ? path30 : parse5(path30, options);
116971
+ const data = typeof path31 === "object" ? path31 : parse5(path31, options);
116961
116972
  const fn = tokensToFunction(data.tokens, delimiter2, encode);
116962
- return function path31(params2 = {}) {
116963
- const [path32, ...missing] = fn(params2);
116973
+ return function path32(params2 = {}) {
116974
+ const [path33, ...missing] = fn(params2);
116964
116975
  if (missing.length) {
116965
116976
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
116966
116977
  }
116967
- return path32;
116978
+ return path33;
116968
116979
  };
116969
116980
  }
116970
116981
  function tokensToFunction(tokens, delimiter2, encode) {
@@ -117020,9 +117031,9 @@ var require_dist2 = __commonJS({
117020
117031
  return [encodeValue(value)];
117021
117032
  };
117022
117033
  }
117023
- function match(path30, options = {}) {
117034
+ function match(path31, options = {}) {
117024
117035
  const { decode: decode2 = decodeURIComponent, delimiter: delimiter2 = DEFAULT_DELIMITER } = options;
117025
- const { regexp, keys: keys4 } = pathToRegexp(path30, options);
117036
+ const { regexp, keys: keys4 } = pathToRegexp(path31, options);
117026
117037
  const decoders = keys4.map((key) => {
117027
117038
  if (decode2 === false)
117028
117039
  return NOOP_VALUE;
@@ -117034,7 +117045,7 @@ var require_dist2 = __commonJS({
117034
117045
  const m = regexp.exec(input);
117035
117046
  if (!m)
117036
117047
  return false;
117037
- const path31 = m[0];
117048
+ const path32 = m[0];
117038
117049
  const params2 = /* @__PURE__ */ Object.create(null);
117039
117050
  for (let i = 1; i < m.length; i++) {
117040
117051
  if (m[i] === void 0)
@@ -117043,21 +117054,21 @@ var require_dist2 = __commonJS({
117043
117054
  const decoder = decoders[i - 1];
117044
117055
  params2[key.name] = decoder(m[i]);
117045
117056
  }
117046
- return { path: path31, params: params2 };
117057
+ return { path: path32, params: params2 };
117047
117058
  };
117048
117059
  }
117049
- function pathToRegexp(path30, options = {}) {
117060
+ function pathToRegexp(path31, options = {}) {
117050
117061
  const { delimiter: delimiter2 = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
117051
117062
  const root3 = new SourceNode("^");
117052
- const paths = [path30];
117063
+ const paths = [path31];
117053
117064
  let combinations = 0;
117054
117065
  while (paths.length) {
117055
- const path31 = paths.shift();
117056
- if (Array.isArray(path31)) {
117057
- paths.push(...path31);
117066
+ const path32 = paths.shift();
117067
+ if (Array.isArray(path32)) {
117068
+ paths.push(...path32);
117058
117069
  continue;
117059
117070
  }
117060
- const data = typeof path31 === "object" ? path31 : parse5(path31, options);
117071
+ const data = typeof path32 === "object" ? path32 : parse5(path32, options);
117061
117072
  flatten4(data.tokens, 0, [], (tokens) => {
117062
117073
  if (combinations++ >= 256) {
117063
117074
  throw new PathError("Too many path combinations", data.originalPath);
@@ -117231,18 +117242,18 @@ var require_layer = __commonJS({
117231
117242
  var TRAILING_SLASH_REGEXP = /\/+$/;
117232
117243
  var MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g;
117233
117244
  module3.exports = Layer;
117234
- function Layer(path30, options, fn) {
117245
+ function Layer(path31, options, fn) {
117235
117246
  if (!(this instanceof Layer)) {
117236
- return new Layer(path30, options, fn);
117247
+ return new Layer(path31, options, fn);
117237
117248
  }
117238
- debug4("new %o", path30);
117249
+ debug4("new %o", path31);
117239
117250
  const opts = options || {};
117240
117251
  this.handle = fn;
117241
117252
  this.keys = [];
117242
117253
  this.name = fn.name || "<anonymous>";
117243
117254
  this.params = void 0;
117244
117255
  this.path = void 0;
117245
- this.slash = path30 === "/" && opts.end === false;
117256
+ this.slash = path31 === "/" && opts.end === false;
117246
117257
  function matcher2(_path) {
117247
117258
  if (_path instanceof RegExp) {
117248
117259
  const keys4 = [];
@@ -117281,7 +117292,7 @@ var require_layer = __commonJS({
117281
117292
  decode: decodeParam
117282
117293
  });
117283
117294
  }
117284
- this.matchers = Array.isArray(path30) ? path30.map(matcher2) : [matcher2(path30)];
117295
+ this.matchers = Array.isArray(path31) ? path31.map(matcher2) : [matcher2(path31)];
117285
117296
  }
117286
117297
  Layer.prototype.handleError = function handleError(error5, req, res, next) {
117287
117298
  const fn = this.handle;
@@ -117321,9 +117332,9 @@ var require_layer = __commonJS({
117321
117332
  next(err);
117322
117333
  }
117323
117334
  };
117324
- Layer.prototype.match = function match(path30) {
117335
+ Layer.prototype.match = function match(path31) {
117325
117336
  let match2;
117326
- if (path30 != null) {
117337
+ if (path31 != null) {
117327
117338
  if (this.slash) {
117328
117339
  this.params = {};
117329
117340
  this.path = "";
@@ -117331,7 +117342,7 @@ var require_layer = __commonJS({
117331
117342
  }
117332
117343
  let i = 0;
117333
117344
  while (!match2 && i < this.matchers.length) {
117334
- match2 = this.matchers[i](path30);
117345
+ match2 = this.matchers[i](path31);
117335
117346
  i++;
117336
117347
  }
117337
117348
  }
@@ -117359,13 +117370,13 @@ var require_layer = __commonJS({
117359
117370
  throw err;
117360
117371
  }
117361
117372
  }
117362
- function loosen(path30) {
117363
- if (path30 instanceof RegExp || path30 === "/") {
117364
- return path30;
117373
+ function loosen(path31) {
117374
+ if (path31 instanceof RegExp || path31 === "/") {
117375
+ return path31;
117365
117376
  }
117366
- return Array.isArray(path30) ? path30.map(function(p) {
117377
+ return Array.isArray(path31) ? path31.map(function(p) {
117367
117378
  return loosen(p);
117368
- }) : String(path30).replace(TRAILING_SLASH_REGEXP, "");
117379
+ }) : String(path31).replace(TRAILING_SLASH_REGEXP, "");
117369
117380
  }
117370
117381
  }
117371
117382
  });
@@ -117381,9 +117392,9 @@ var require_route = __commonJS({
117381
117392
  var flatten4 = Array.prototype.flat;
117382
117393
  var methods = METHODS.map((method) => method.toLowerCase());
117383
117394
  module3.exports = Route;
117384
- function Route(path30) {
117385
- debug4("new %o", path30);
117386
- this.path = path30;
117395
+ function Route(path31) {
117396
+ debug4("new %o", path31);
117397
+ this.path = path31;
117387
117398
  this.stack = [];
117388
117399
  this.methods = /* @__PURE__ */ Object.create(null);
117389
117400
  }
@@ -117591,8 +117602,8 @@ var require_router = __commonJS({
117591
117602
  if (++sync > 100) {
117592
117603
  return setImmediate(next, err);
117593
117604
  }
117594
- const path30 = getPathname(req);
117595
- if (path30 == null) {
117605
+ const path31 = getPathname(req);
117606
+ if (path31 == null) {
117596
117607
  return done(layerError);
117597
117608
  }
117598
117609
  let layer;
@@ -117600,7 +117611,7 @@ var require_router = __commonJS({
117600
117611
  let route;
117601
117612
  while (match !== true && idx < stack.length) {
117602
117613
  layer = stack[idx++];
117603
- match = matchLayer(layer, path30);
117614
+ match = matchLayer(layer, path31);
117604
117615
  route = layer.route;
117605
117616
  if (typeof match !== "boolean") {
117606
117617
  layerError = layerError || match;
@@ -117638,18 +117649,18 @@ var require_router = __commonJS({
117638
117649
  } else if (route) {
117639
117650
  layer.handleRequest(req, res, next);
117640
117651
  } else {
117641
- trimPrefix(layer, layerError, layerPath, path30);
117652
+ trimPrefix(layer, layerError, layerPath, path31);
117642
117653
  }
117643
117654
  sync = 0;
117644
117655
  });
117645
117656
  }
117646
- function trimPrefix(layer, layerError, layerPath, path30) {
117657
+ function trimPrefix(layer, layerError, layerPath, path31) {
117647
117658
  if (layerPath.length !== 0) {
117648
- if (layerPath !== path30.substring(0, layerPath.length)) {
117659
+ if (layerPath !== path31.substring(0, layerPath.length)) {
117649
117660
  next(layerError);
117650
117661
  return;
117651
117662
  }
117652
- const c = path30[layerPath.length];
117663
+ const c = path31[layerPath.length];
117653
117664
  if (c && c !== "/") {
117654
117665
  next(layerError);
117655
117666
  return;
@@ -117673,7 +117684,7 @@ var require_router = __commonJS({
117673
117684
  };
117674
117685
  Router.prototype.use = function use(handler) {
117675
117686
  let offset = 0;
117676
- let path30 = "/";
117687
+ let path31 = "/";
117677
117688
  if (typeof handler !== "function") {
117678
117689
  let arg = handler;
117679
117690
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -117681,7 +117692,7 @@ var require_router = __commonJS({
117681
117692
  }
117682
117693
  if (typeof arg !== "function") {
117683
117694
  offset = 1;
117684
- path30 = handler;
117695
+ path31 = handler;
117685
117696
  }
117686
117697
  }
117687
117698
  const callbacks = flatten4.call(slice2.call(arguments, offset), Infinity);
@@ -117693,8 +117704,8 @@ var require_router = __commonJS({
117693
117704
  if (typeof fn !== "function") {
117694
117705
  throw new TypeError("argument handler must be a function");
117695
117706
  }
117696
- debug4("use %o %s", path30, fn.name || "<anonymous>");
117697
- const layer = new Layer(path30, {
117707
+ debug4("use %o %s", path31, fn.name || "<anonymous>");
117708
+ const layer = new Layer(path31, {
117698
117709
  sensitive: this.caseSensitive,
117699
117710
  strict: false,
117700
117711
  end: false
@@ -117704,9 +117715,9 @@ var require_router = __commonJS({
117704
117715
  }
117705
117716
  return this;
117706
117717
  };
117707
- Router.prototype.route = function route(path30) {
117708
- const route2 = new Route(path30);
117709
- const layer = new Layer(path30, {
117718
+ Router.prototype.route = function route(path31) {
117719
+ const route2 = new Route(path31);
117720
+ const layer = new Layer(path31, {
117710
117721
  sensitive: this.caseSensitive,
117711
117722
  strict: this.strict,
117712
117723
  end: true
@@ -117719,8 +117730,8 @@ var require_router = __commonJS({
117719
117730
  return route2;
117720
117731
  };
117721
117732
  methods.concat("all").forEach(function(method) {
117722
- Router.prototype[method] = function(path30) {
117723
- const route = this.route(path30);
117733
+ Router.prototype[method] = function(path31) {
117734
+ const route = this.route(path31);
117724
117735
  route[method].apply(route, slice2.call(arguments, 1));
117725
117736
  return this;
117726
117737
  };
@@ -117749,9 +117760,9 @@ var require_router = __commonJS({
117749
117760
  const fqdnIndex = url.substring(0, pathLength).indexOf("://");
117750
117761
  return fqdnIndex !== -1 ? url.substring(0, url.indexOf("/", 3 + fqdnIndex)) : void 0;
117751
117762
  }
117752
- function matchLayer(layer, path30) {
117763
+ function matchLayer(layer, path31) {
117753
117764
  try {
117754
- return layer.match(path30);
117765
+ return layer.match(path31);
117755
117766
  } catch (err) {
117756
117767
  return err;
117757
117768
  }
@@ -117979,7 +117990,7 @@ var require_application = __commonJS({
117979
117990
  };
117980
117991
  app.use = function use(fn) {
117981
117992
  var offset = 0;
117982
- var path30 = "/";
117993
+ var path31 = "/";
117983
117994
  if (typeof fn !== "function") {
117984
117995
  var arg = fn;
117985
117996
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -117987,7 +117998,7 @@ var require_application = __commonJS({
117987
117998
  }
117988
117999
  if (typeof arg !== "function") {
117989
118000
  offset = 1;
117990
- path30 = fn;
118001
+ path31 = fn;
117991
118002
  }
117992
118003
  }
117993
118004
  var fns = flatten4.call(slice2.call(arguments, offset), Infinity);
@@ -117997,12 +118008,12 @@ var require_application = __commonJS({
117997
118008
  var router = this.router;
117998
118009
  fns.forEach(function(fn2) {
117999
118010
  if (!fn2 || !fn2.handle || !fn2.set) {
118000
- return router.use(path30, fn2);
118011
+ return router.use(path31, fn2);
118001
118012
  }
118002
- debug4(".use app under %s", path30);
118003
- fn2.mountpath = path30;
118013
+ debug4(".use app under %s", path31);
118014
+ fn2.mountpath = path31;
118004
118015
  fn2.parent = this;
118005
- router.use(path30, function mounted_app(req, res, next) {
118016
+ router.use(path31, function mounted_app(req, res, next) {
118006
118017
  var orig = req.app;
118007
118018
  fn2.handle(req, res, function(err) {
118008
118019
  Object.setPrototypeOf(req, orig.request);
@@ -118014,8 +118025,8 @@ var require_application = __commonJS({
118014
118025
  }, this);
118015
118026
  return this;
118016
118027
  };
118017
- app.route = function route(path30) {
118018
- return this.router.route(path30);
118028
+ app.route = function route(path31) {
118029
+ return this.router.route(path31);
118019
118030
  };
118020
118031
  app.engine = function engine(ext, fn) {
118021
118032
  if (typeof fn !== "function") {
@@ -118058,7 +118069,7 @@ var require_application = __commonJS({
118058
118069
  }
118059
118070
  return this;
118060
118071
  };
118061
- app.path = function path30() {
118072
+ app.path = function path31() {
118062
118073
  return this.parent ? this.parent.path() + this.mountpath : "";
118063
118074
  };
118064
118075
  app.enabled = function enabled(setting) {
@@ -118074,17 +118085,17 @@ var require_application = __commonJS({
118074
118085
  return this.set(setting, false);
118075
118086
  };
118076
118087
  methods.forEach(function(method) {
118077
- app[method] = function(path30) {
118088
+ app[method] = function(path31) {
118078
118089
  if (method === "get" && arguments.length === 1) {
118079
- return this.set(path30);
118090
+ return this.set(path31);
118080
118091
  }
118081
- var route = this.route(path30);
118092
+ var route = this.route(path31);
118082
118093
  route[method].apply(route, slice2.call(arguments, 1));
118083
118094
  return this;
118084
118095
  };
118085
118096
  });
118086
- app.all = function all3(path30) {
118087
- var route = this.route(path30);
118097
+ app.all = function all3(path31) {
118098
+ var route = this.route(path31);
118088
118099
  var args2 = slice2.call(arguments, 1);
118089
118100
  for (var i = 0; i < methods.length; i++) {
118090
118101
  route[methods[i]].apply(route, args2);
@@ -118994,7 +119005,7 @@ var require_request = __commonJS({
118994
119005
  var subdomains2 = !isIP4(hostname3) ? hostname3.split(".").reverse() : [hostname3];
118995
119006
  return subdomains2.slice(offset);
118996
119007
  });
118997
- defineGetter(req, "path", function path30() {
119008
+ defineGetter(req, "path", function path31() {
118998
119009
  return parse5(this).pathname;
118999
119010
  });
119000
119011
  defineGetter(req, "host", function host() {
@@ -119211,17 +119222,17 @@ var require_content_disposition = __commonJS({
119211
119222
  var require_cookie_signature = __commonJS({
119212
119223
  "node_modules/cookie-signature/index.js"(exports3) {
119213
119224
  "use strict";
119214
- var crypto8 = __require("crypto");
119225
+ var crypto9 = __require("crypto");
119215
119226
  exports3.sign = function(val, secret) {
119216
119227
  if ("string" != typeof val) throw new TypeError("Cookie value must be provided as a string.");
119217
119228
  if (null == secret) throw new TypeError("Secret key must be provided.");
119218
- return val + "." + crypto8.createHmac("sha256", secret).update(val).digest("base64").replace(/\=+$/, "");
119229
+ return val + "." + crypto9.createHmac("sha256", secret).update(val).digest("base64").replace(/\=+$/, "");
119219
119230
  };
119220
119231
  exports3.unsign = function(input, secret) {
119221
119232
  if ("string" != typeof input) throw new TypeError("Signed cookie string must be provided.");
119222
119233
  if (null == secret) throw new TypeError("Secret key must be provided.");
119223
119234
  var tentativeValue = input.slice(0, input.lastIndexOf(".")), expectedInput = exports3.sign(tentativeValue, secret), expectedBuffer = Buffer.from(expectedInput), inputBuffer = Buffer.from(input);
119224
- return expectedBuffer.length === inputBuffer.length && crypto8.timingSafeEqual(expectedBuffer, inputBuffer) ? tentativeValue : false;
119235
+ return expectedBuffer.length === inputBuffer.length && crypto9.timingSafeEqual(expectedBuffer, inputBuffer) ? tentativeValue : false;
119225
119236
  };
119226
119237
  }
119227
119238
  });
@@ -119402,32 +119413,32 @@ var require_send = __commonJS({
119402
119413
  var escapeHtml = require_escape_html();
119403
119414
  var etag = require_etag();
119404
119415
  var fresh = require_fresh();
119405
- var fs19 = __require("fs");
119416
+ var fs20 = __require("fs");
119406
119417
  var mime = require_mime_types();
119407
119418
  var ms = require_ms();
119408
119419
  var onFinished = require_on_finished();
119409
119420
  var parseRange = require_range_parser();
119410
- var path30 = __require("path");
119421
+ var path31 = __require("path");
119411
119422
  var statuses = require_statuses();
119412
119423
  var Stream = __require("stream");
119413
119424
  var util4 = __require("util");
119414
- var extname = path30.extname;
119415
- var join12 = path30.join;
119416
- var normalize5 = path30.normalize;
119417
- var resolve5 = path30.resolve;
119418
- var sep4 = path30.sep;
119425
+ var extname = path31.extname;
119426
+ var join12 = path31.join;
119427
+ var normalize5 = path31.normalize;
119428
+ var resolve5 = path31.resolve;
119429
+ var sep4 = path31.sep;
119419
119430
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
119420
119431
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
119421
119432
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
119422
119433
  module3.exports = send;
119423
- function send(req, path31, options) {
119424
- return new SendStream(req, path31, options);
119434
+ function send(req, path32, options) {
119435
+ return new SendStream(req, path32, options);
119425
119436
  }
119426
- function SendStream(req, path31, options) {
119437
+ function SendStream(req, path32, options) {
119427
119438
  Stream.call(this);
119428
119439
  var opts = options || {};
119429
119440
  this.options = opts;
119430
- this.path = path31;
119441
+ this.path = path32;
119431
119442
  this.req = req;
119432
119443
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
119433
119444
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -119541,10 +119552,10 @@ var require_send = __commonJS({
119541
119552
  var lastModified = this.res.getHeader("Last-Modified");
119542
119553
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
119543
119554
  };
119544
- SendStream.prototype.redirect = function redirect(path31) {
119555
+ SendStream.prototype.redirect = function redirect(path32) {
119545
119556
  var res = this.res;
119546
119557
  if (hasListeners(this, "directory")) {
119547
- this.emit("directory", res, path31);
119558
+ this.emit("directory", res, path32);
119548
119559
  return;
119549
119560
  }
119550
119561
  if (this.hasTrailingSlash()) {
@@ -119564,38 +119575,38 @@ var require_send = __commonJS({
119564
119575
  SendStream.prototype.pipe = function pipe2(res) {
119565
119576
  var root3 = this._root;
119566
119577
  this.res = res;
119567
- var path31 = decode2(this.path);
119568
- if (path31 === -1) {
119578
+ var path32 = decode2(this.path);
119579
+ if (path32 === -1) {
119569
119580
  this.error(400);
119570
119581
  return res;
119571
119582
  }
119572
- if (~path31.indexOf("\0")) {
119583
+ if (~path32.indexOf("\0")) {
119573
119584
  this.error(400);
119574
119585
  return res;
119575
119586
  }
119576
119587
  var parts;
119577
119588
  if (root3 !== null) {
119578
- if (path31) {
119579
- path31 = normalize5("." + sep4 + path31);
119589
+ if (path32) {
119590
+ path32 = normalize5("." + sep4 + path32);
119580
119591
  }
119581
- if (UP_PATH_REGEXP.test(path31)) {
119582
- debug4('malicious path "%s"', path31);
119592
+ if (UP_PATH_REGEXP.test(path32)) {
119593
+ debug4('malicious path "%s"', path32);
119583
119594
  this.error(403);
119584
119595
  return res;
119585
119596
  }
119586
- parts = path31.split(sep4);
119587
- path31 = normalize5(join12(root3, path31));
119597
+ parts = path32.split(sep4);
119598
+ path32 = normalize5(join12(root3, path32));
119588
119599
  } else {
119589
- if (UP_PATH_REGEXP.test(path31)) {
119590
- debug4('malicious path "%s"', path31);
119600
+ if (UP_PATH_REGEXP.test(path32)) {
119601
+ debug4('malicious path "%s"', path32);
119591
119602
  this.error(403);
119592
119603
  return res;
119593
119604
  }
119594
- parts = normalize5(path31).split(sep4);
119595
- path31 = resolve5(path31);
119605
+ parts = normalize5(path32).split(sep4);
119606
+ path32 = resolve5(path32);
119596
119607
  }
119597
119608
  if (containsDotFile(parts)) {
119598
- debug4('%s dotfile "%s"', this._dotfiles, path31);
119609
+ debug4('%s dotfile "%s"', this._dotfiles, path32);
119599
119610
  switch (this._dotfiles) {
119600
119611
  case "allow":
119601
119612
  break;
@@ -119609,13 +119620,13 @@ var require_send = __commonJS({
119609
119620
  }
119610
119621
  }
119611
119622
  if (this._index.length && this.hasTrailingSlash()) {
119612
- this.sendIndex(path31);
119623
+ this.sendIndex(path32);
119613
119624
  return res;
119614
119625
  }
119615
- this.sendFile(path31);
119626
+ this.sendFile(path32);
119616
119627
  return res;
119617
119628
  };
119618
- SendStream.prototype.send = function send2(path31, stat2) {
119629
+ SendStream.prototype.send = function send2(path32, stat2) {
119619
119630
  var len = stat2.size;
119620
119631
  var options = this.options;
119621
119632
  var opts = {};
@@ -119627,9 +119638,9 @@ var require_send = __commonJS({
119627
119638
  this.headersAlreadySent();
119628
119639
  return;
119629
119640
  }
119630
- debug4('pipe "%s"', path31);
119631
- this.setHeader(path31, stat2);
119632
- this.type(path31);
119641
+ debug4('pipe "%s"', path32);
119642
+ this.setHeader(path32, stat2);
119643
+ this.type(path32);
119633
119644
  if (this.isConditionalGET()) {
119634
119645
  if (this.isPreconditionFailure()) {
119635
119646
  this.error(412);
@@ -119678,30 +119689,30 @@ var require_send = __commonJS({
119678
119689
  res.end();
119679
119690
  return;
119680
119691
  }
119681
- this.stream(path31, opts);
119692
+ this.stream(path32, opts);
119682
119693
  };
119683
- SendStream.prototype.sendFile = function sendFile(path31) {
119694
+ SendStream.prototype.sendFile = function sendFile(path32) {
119684
119695
  var i = 0;
119685
119696
  var self2 = this;
119686
- debug4('stat "%s"', path31);
119687
- fs19.stat(path31, function onstat(err, stat2) {
119688
- var pathEndsWithSep = path31[path31.length - 1] === sep4;
119689
- if (err && err.code === "ENOENT" && !extname(path31) && !pathEndsWithSep) {
119697
+ debug4('stat "%s"', path32);
119698
+ fs20.stat(path32, function onstat(err, stat2) {
119699
+ var pathEndsWithSep = path32[path32.length - 1] === sep4;
119700
+ if (err && err.code === "ENOENT" && !extname(path32) && !pathEndsWithSep) {
119690
119701
  return next(err);
119691
119702
  }
119692
119703
  if (err) return self2.onStatError(err);
119693
- if (stat2.isDirectory()) return self2.redirect(path31);
119704
+ if (stat2.isDirectory()) return self2.redirect(path32);
119694
119705
  if (pathEndsWithSep) return self2.error(404);
119695
- self2.emit("file", path31, stat2);
119696
- self2.send(path31, stat2);
119706
+ self2.emit("file", path32, stat2);
119707
+ self2.send(path32, stat2);
119697
119708
  });
119698
119709
  function next(err) {
119699
119710
  if (self2._extensions.length <= i) {
119700
119711
  return err ? self2.onStatError(err) : self2.error(404);
119701
119712
  }
119702
- var p = path31 + "." + self2._extensions[i++];
119713
+ var p = path32 + "." + self2._extensions[i++];
119703
119714
  debug4('stat "%s"', p);
119704
- fs19.stat(p, function(err2, stat2) {
119715
+ fs20.stat(p, function(err2, stat2) {
119705
119716
  if (err2) return next(err2);
119706
119717
  if (stat2.isDirectory()) return next();
119707
119718
  self2.emit("file", p, stat2);
@@ -119709,7 +119720,7 @@ var require_send = __commonJS({
119709
119720
  });
119710
119721
  }
119711
119722
  };
119712
- SendStream.prototype.sendIndex = function sendIndex(path31) {
119723
+ SendStream.prototype.sendIndex = function sendIndex(path32) {
119713
119724
  var i = -1;
119714
119725
  var self2 = this;
119715
119726
  function next(err) {
@@ -119717,9 +119728,9 @@ var require_send = __commonJS({
119717
119728
  if (err) return self2.onStatError(err);
119718
119729
  return self2.error(404);
119719
119730
  }
119720
- var p = join12(path31, self2._index[i]);
119731
+ var p = join12(path32, self2._index[i]);
119721
119732
  debug4('stat "%s"', p);
119722
- fs19.stat(p, function(err2, stat2) {
119733
+ fs20.stat(p, function(err2, stat2) {
119723
119734
  if (err2) return next(err2);
119724
119735
  if (stat2.isDirectory()) return next();
119725
119736
  self2.emit("file", p, stat2);
@@ -119728,10 +119739,10 @@ var require_send = __commonJS({
119728
119739
  }
119729
119740
  next();
119730
119741
  };
119731
- SendStream.prototype.stream = function stream(path31, options) {
119742
+ SendStream.prototype.stream = function stream(path32, options) {
119732
119743
  var self2 = this;
119733
119744
  var res = this.res;
119734
- var stream2 = fs19.createReadStream(path31, options);
119745
+ var stream2 = fs20.createReadStream(path32, options);
119735
119746
  this.emit("stream", stream2);
119736
119747
  stream2.pipe(res);
119737
119748
  function cleanup() {
@@ -119746,17 +119757,17 @@ var require_send = __commonJS({
119746
119757
  self2.emit("end");
119747
119758
  });
119748
119759
  };
119749
- SendStream.prototype.type = function type3(path31) {
119760
+ SendStream.prototype.type = function type3(path32) {
119750
119761
  var res = this.res;
119751
119762
  if (res.getHeader("Content-Type")) return;
119752
- var ext = extname(path31);
119763
+ var ext = extname(path32);
119753
119764
  var type4 = mime.contentType(ext) || "application/octet-stream";
119754
119765
  debug4("content-type %s", type4);
119755
119766
  res.setHeader("Content-Type", type4);
119756
119767
  };
119757
- SendStream.prototype.setHeader = function setHeader(path31, stat2) {
119768
+ SendStream.prototype.setHeader = function setHeader(path32, stat2) {
119758
119769
  var res = this.res;
119759
- this.emit("headers", res, path31, stat2);
119770
+ this.emit("headers", res, path32, stat2);
119760
119771
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
119761
119772
  debug4("accept ranges");
119762
119773
  res.setHeader("Accept-Ranges", "bytes");
@@ -119814,9 +119825,9 @@ var require_send = __commonJS({
119814
119825
  }
119815
119826
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
119816
119827
  }
119817
- function decode2(path31) {
119828
+ function decode2(path32) {
119818
119829
  try {
119819
- return decodeURIComponent(path31);
119830
+ return decodeURIComponent(path32);
119820
119831
  } catch (err) {
119821
119832
  return -1;
119822
119833
  }
@@ -119960,7 +119971,7 @@ var require_response = __commonJS({
119960
119971
  var http5 = __require("http");
119961
119972
  var onFinished = require_on_finished();
119962
119973
  var mime = require_mime_types();
119963
- var path30 = __require("path");
119974
+ var path31 = __require("path");
119964
119975
  var pathIsAbsolute = __require("path").isAbsolute;
119965
119976
  var statuses = require_statuses();
119966
119977
  var sign2 = require_cookie_signature().sign;
@@ -119969,8 +119980,8 @@ var require_response = __commonJS({
119969
119980
  var setCharset = require_utils4().setCharset;
119970
119981
  var cookie = require_cookie();
119971
119982
  var send = require_send();
119972
- var extname = path30.extname;
119973
- var resolve5 = path30.resolve;
119983
+ var extname = path31.extname;
119984
+ var resolve5 = path31.resolve;
119974
119985
  var vary = require_vary();
119975
119986
  var { Buffer: Buffer2 } = __require("buffer");
119976
119987
  var res = Object.create(http5.ServerResponse.prototype);
@@ -120116,26 +120127,26 @@ var require_response = __commonJS({
120116
120127
  this.type("txt");
120117
120128
  return this.send(body);
120118
120129
  };
120119
- res.sendFile = function sendFile(path31, options, callback) {
120130
+ res.sendFile = function sendFile(path32, options, callback) {
120120
120131
  var done = callback;
120121
120132
  var req = this.req;
120122
120133
  var res2 = this;
120123
120134
  var next = req.next;
120124
120135
  var opts = options || {};
120125
- if (!path31) {
120136
+ if (!path32) {
120126
120137
  throw new TypeError("path argument is required to res.sendFile");
120127
120138
  }
120128
- if (typeof path31 !== "string") {
120139
+ if (typeof path32 !== "string") {
120129
120140
  throw new TypeError("path must be a string to res.sendFile");
120130
120141
  }
120131
120142
  if (typeof options === "function") {
120132
120143
  done = options;
120133
120144
  opts = {};
120134
120145
  }
120135
- if (!opts.root && !pathIsAbsolute(path31)) {
120146
+ if (!opts.root && !pathIsAbsolute(path32)) {
120136
120147
  throw new TypeError("path must be absolute or specify root to res.sendFile");
120137
120148
  }
120138
- var pathname = encodeURI(path31);
120149
+ var pathname = encodeURI(path32);
120139
120150
  opts.etag = this.app.enabled("etag");
120140
120151
  var file = send(req, pathname, opts);
120141
120152
  sendfile(res2, file, opts, function(err) {
@@ -120146,7 +120157,7 @@ var require_response = __commonJS({
120146
120157
  }
120147
120158
  });
120148
120159
  };
120149
- res.download = function download(path31, filename, options, callback) {
120160
+ res.download = function download(path32, filename, options, callback) {
120150
120161
  var done = callback;
120151
120162
  var name2 = filename;
120152
120163
  var opts = options || null;
@@ -120163,7 +120174,7 @@ var require_response = __commonJS({
120163
120174
  opts = filename;
120164
120175
  }
120165
120176
  var headers = {
120166
- "Content-Disposition": contentDisposition(name2 || path31)
120177
+ "Content-Disposition": contentDisposition(name2 || path32)
120167
120178
  };
120168
120179
  if (opts && opts.headers) {
120169
120180
  var keys4 = Object.keys(opts.headers);
@@ -120176,7 +120187,7 @@ var require_response = __commonJS({
120176
120187
  }
120177
120188
  opts = Object.create(opts);
120178
120189
  opts.headers = headers;
120179
- var fullPath = !opts.root ? resolve5(path31) : path31;
120190
+ var fullPath = !opts.root ? resolve5(path32) : path32;
120180
120191
  return this.sendFile(fullPath, opts, done);
120181
120192
  };
120182
120193
  res.contentType = res.type = function contentType(type3) {
@@ -120459,11 +120470,11 @@ var require_serve_static = __commonJS({
120459
120470
  }
120460
120471
  var forwardError = !fallthrough;
120461
120472
  var originalUrl = parseUrl2.original(req);
120462
- var path30 = parseUrl2(req).pathname;
120463
- if (path30 === "/" && originalUrl.pathname.substr(-1) !== "/") {
120464
- path30 = "";
120473
+ var path31 = parseUrl2(req).pathname;
120474
+ if (path31 === "/" && originalUrl.pathname.substr(-1) !== "/") {
120475
+ path31 = "";
120465
120476
  }
120466
- var stream = send(req, path30, opts);
120477
+ var stream = send(req, path31, opts);
120467
120478
  stream.on("directory", onDirectory);
120468
120479
  if (setHeaders) {
120469
120480
  stream.on("headers", setHeaders);
@@ -123766,8 +123777,8 @@ var require_utils5 = __commonJS({
123766
123777
  }
123767
123778
  return ind;
123768
123779
  }
123769
- function removeDotSegments(path30) {
123770
- let input = path30;
123780
+ function removeDotSegments(path31) {
123781
+ let input = path31;
123771
123782
  const output = [];
123772
123783
  let nextSlash = -1;
123773
123784
  let len = 0;
@@ -124019,8 +124030,8 @@ var require_schemes = __commonJS({
124019
124030
  wsComponent.secure = void 0;
124020
124031
  }
124021
124032
  if (wsComponent.resourceName) {
124022
- const [path30, query] = wsComponent.resourceName.split("?");
124023
- wsComponent.path = path30 && path30 !== "/" ? path30 : void 0;
124033
+ const [path31, query] = wsComponent.resourceName.split("?");
124034
+ wsComponent.path = path31 && path31 !== "/" ? path31 : void 0;
124024
124035
  wsComponent.query = query;
124025
124036
  wsComponent.resourceName = void 0;
124026
124037
  }
@@ -127413,12 +127424,12 @@ var require_dist3 = __commonJS({
127413
127424
  throw new Error(`Unknown format "${name2}"`);
127414
127425
  return f;
127415
127426
  };
127416
- function addFormats(ajv, list4, fs19, exportName) {
127427
+ function addFormats(ajv, list4, fs20, exportName) {
127417
127428
  var _a3;
127418
127429
  var _b2;
127419
127430
  (_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
127420
127431
  for (const f of list4)
127421
- ajv.addFormat(f, fs19[f]);
127432
+ ajv.addFormat(f, fs20[f]);
127422
127433
  }
127423
127434
  module3.exports = exports3 = formatsPlugin;
127424
127435
  Object.defineProperty(exports3, "__esModule", { value: true });
@@ -128524,8 +128535,8 @@ function checkAnnotationStore(r) {
128524
128535
  }
128525
128536
  try {
128526
128537
  const raw = readFileSync3(lockPath, "utf-8").trim();
128527
- const pid = Number.parseInt(raw, 10);
128528
- if (!Number.isFinite(pid)) {
128538
+ const lock = parseLockfile(raw);
128539
+ if (lock === null) {
128529
128540
  r.warn(
128530
128541
  `Annotation store lock at ${lockPath} has unparseable content: "${raw}"`,
128531
128542
  "Restart Tandem or delete the lock file if no server is running.",
@@ -128533,6 +128544,7 @@ function checkAnnotationStore(r) {
128533
128544
  );
128534
128545
  return;
128535
128546
  }
128547
+ const { pid } = lock;
128536
128548
  if (isPidLive(pid)) {
128537
128549
  r.pass(`Annotation store lock held by live PID ${pid}`, void 0, {
128538
128550
  lockHeld: true,
@@ -128589,6 +128601,7 @@ var Recorder;
128589
128601
  var init_doctor = __esm({
128590
128602
  "src/cli/doctor.ts"() {
128591
128603
  "use strict";
128604
+ init_lockfile();
128592
128605
  init_constants();
128593
128606
  Recorder = class {
128594
128607
  failures = 0;
@@ -129308,7 +129321,7 @@ function escapeRegExp3(s) {
129308
129321
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
129309
129322
  }
129310
129323
  function isLocalhostOrigin(origin) {
129311
- return LOCALHOST_ORIGIN_RE.test(origin ?? "");
129324
+ return origin === TAURI_LINUX_ORIGIN || LOCALHOST_ORIGIN_RE.test(origin ?? "");
129312
129325
  }
129313
129326
  function createApiMiddleware(extraHosts = []) {
129314
129327
  return function apiMiddlewareFn(req, res, next) {
@@ -130850,7 +130863,7 @@ var init_launcher = __esm({
130850
130863
  });
130851
130864
 
130852
130865
  // src/shared/launcher/contract.ts
130853
- var LAUNCHER_ERROR_INVALID_BODY, LAUNCHER_ERROR_INVALID_NONCE, LAUNCHER_ERROR_PATH_REJECTED, LAUNCHER_ERROR_IN_PROGRESS, LAUNCHER_ERROR_NOT_AVAILABLE, LAUNCHER_ERROR_NO_INTEGRATION, LAUNCHER_CWD_MAX_LENGTH;
130866
+ var LAUNCHER_ERROR_INVALID_BODY, LAUNCHER_ERROR_INVALID_NONCE, LAUNCHER_ERROR_PATH_REJECTED, LAUNCHER_ERROR_IN_PROGRESS, LAUNCHER_ERROR_NOT_AVAILABLE, LAUNCHER_ERROR_NO_INTEGRATION, LAUNCHER_ERROR_REAPER_NOT_FOUND, REAPER_NOT_FOUND_MARKER, LAUNCHER_CWD_MAX_LENGTH;
130854
130867
  var init_contract2 = __esm({
130855
130868
  "src/shared/launcher/contract.ts"() {
130856
130869
  "use strict";
@@ -130860,6 +130873,8 @@ var init_contract2 = __esm({
130860
130873
  LAUNCHER_ERROR_IN_PROGRESS = "LAUNCHER_IN_PROGRESS";
130861
130874
  LAUNCHER_ERROR_NOT_AVAILABLE = "LAUNCHER_NOT_AVAILABLE";
130862
130875
  LAUNCHER_ERROR_NO_INTEGRATION = "NO_CLAUDE_INTEGRATION";
130876
+ LAUNCHER_ERROR_REAPER_NOT_FOUND = "REAPER_NOT_FOUND";
130877
+ REAPER_NOT_FOUND_MARKER = "tandem-reaper binary not found";
130863
130878
  LAUNCHER_CWD_MAX_LENGTH = 1024;
130864
130879
  }
130865
130880
  });
@@ -130873,9 +130888,9 @@ __export(supervisor_exports, {
130873
130888
  });
130874
130889
  import { spawn as spawn2 } from "child_process";
130875
130890
  import { randomUUID as randomUUID9 } from "crypto";
130876
- import fs17 from "fs";
130891
+ import fs18 from "fs";
130877
130892
  import os2 from "os";
130878
- import path25 from "path";
130893
+ import path26 from "path";
130879
130894
  function createSupervisor(opts) {
130880
130895
  let child = null;
130881
130896
  let currentCwd;
@@ -130905,11 +130920,11 @@ function createSupervisor(opts) {
130905
130920
  return found ?? null;
130906
130921
  }
130907
130922
  function sessionFilePath() {
130908
- return path25.join(opts.integrationsBase, SESSION_FILE_NAME);
130923
+ return path26.join(opts.integrationsBase, SESSION_FILE_NAME);
130909
130924
  }
130910
130925
  function readSavedSession() {
130911
130926
  try {
130912
- const raw = fs17.readFileSync(sessionFilePath(), "utf8");
130927
+ const raw = fs18.readFileSync(sessionFilePath(), "utf8");
130913
130928
  const parsed = JSON.parse(raw);
130914
130929
  if (typeof parsed.sessionId !== "string") return void 0;
130915
130930
  if (!UUID_V4_PATTERN.test(parsed.sessionId)) {
@@ -130923,7 +130938,7 @@ function createSupervisor(opts) {
130923
130938
  }
130924
130939
  function writeSavedSession(sessionId) {
130925
130940
  try {
130926
- fs17.writeFileSync(sessionFilePath(), JSON.stringify({ sessionId }, null, 2), {
130941
+ fs18.writeFileSync(sessionFilePath(), JSON.stringify({ sessionId }, null, 2), {
130927
130942
  encoding: "utf8",
130928
130943
  mode: 384
130929
130944
  });
@@ -130933,7 +130948,7 @@ function createSupervisor(opts) {
130933
130948
  }
130934
130949
  function clearSavedSession() {
130935
130950
  try {
130936
- fs17.unlinkSync(sessionFilePath());
130951
+ fs18.unlinkSync(sessionFilePath());
130937
130952
  } catch {
130938
130953
  }
130939
130954
  }
@@ -130950,18 +130965,18 @@ function createSupervisor(opts) {
130950
130965
  }
130951
130966
  function reaperPath() {
130952
130967
  const exeName = process.platform === "win32" ? "tandem-reaper.exe" : "tandem-reaper";
130953
- if (process.env.NODE_ENV !== "production" && process.env.TANDEM_TAURI_SIDECAR !== "1" && process.env.TANDEM_REAPER_PATH && fs17.existsSync(process.env.TANDEM_REAPER_PATH)) {
130968
+ if (process.env.NODE_ENV !== "production" && process.env.TANDEM_TAURI_SIDECAR !== "1" && process.env.TANDEM_REAPER_PATH && fs18.existsSync(process.env.TANDEM_REAPER_PATH)) {
130954
130969
  return process.env.TANDEM_REAPER_PATH;
130955
130970
  }
130956
- const adjacent = path25.join(path25.dirname(process.execPath), exeName);
130957
- if (fs17.existsSync(adjacent)) return adjacent;
130971
+ const adjacent = path26.join(path26.dirname(process.execPath), exeName);
130972
+ if (fs18.existsSync(adjacent)) return adjacent;
130958
130973
  if (process.env.TANDEM_TAURI_SIDECAR) {
130959
- const tauriBin = path25.join(path25.dirname(process.execPath), "binaries", exeName);
130960
- if (fs17.existsSync(tauriBin)) return tauriBin;
130974
+ const tauriBin = path26.join(path26.dirname(process.execPath), "binaries", exeName);
130975
+ if (fs18.existsSync(tauriBin)) return tauriBin;
130961
130976
  }
130962
- const devPath = path25.resolve(process.cwd(), "reaper", "target", "release", exeName);
130963
- if (fs17.existsSync(devPath) && process.env.NODE_ENV !== "production") return devPath;
130964
- throw new Error(`tandem-reaper binary not found (checked ${adjacent})`);
130977
+ const devPath = path26.resolve(process.cwd(), "reaper", "target", "release", exeName);
130978
+ if (fs18.existsSync(devPath) && process.env.NODE_ENV !== "production") return devPath;
130979
+ throw new Error(`${REAPER_NOT_FOUND_MARKER} (checked ${adjacent})`);
130965
130980
  }
130966
130981
  function claudeCommand() {
130967
130982
  return process.env.TANDEM_CLAUDE_CMD || "claude";
@@ -131041,6 +131056,33 @@ function createSupervisor(opts) {
131041
131056
  if (stopRequested) return;
131042
131057
  scheduleRestart();
131043
131058
  });
131059
+ const spawned = child;
131060
+ await new Promise((resolve5, reject2) => {
131061
+ const cleanup = () => {
131062
+ spawned.off("spawn", onSpawn);
131063
+ spawned.off("error", onEarlyError);
131064
+ spawned.off("exit", onEarlyExit);
131065
+ };
131066
+ const onSpawn = () => {
131067
+ cleanup();
131068
+ resolve5();
131069
+ };
131070
+ const onEarlyError = (err) => {
131071
+ cleanup();
131072
+ if (err.code === "ENOENT" || err.code === "EACCES" || err.code === "EISDIR") {
131073
+ reject2(new Error(`${REAPER_NOT_FOUND_MARKER} (spawn ${err.code}: ${err.message})`));
131074
+ } else {
131075
+ reject2(err);
131076
+ }
131077
+ };
131078
+ const onEarlyExit = (code3, signal) => {
131079
+ cleanup();
131080
+ reject2(new Error(`reaper exited before spawn (code=${code3} signal=${signal})`));
131081
+ };
131082
+ spawned.once("spawn", onSpawn);
131083
+ spawned.once("error", onEarlyError);
131084
+ spawned.once("exit", onEarlyExit);
131085
+ });
131044
131086
  }
131045
131087
  function scheduleRestart() {
131046
131088
  if (restartTimer) clearTimeout(restartTimer);
@@ -131164,14 +131206,14 @@ function createSupervisor(opts) {
131164
131206
  return { start, relaunch, stop, startFresh, status };
131165
131207
  }
131166
131208
  function resolveSafeCwd(candidate) {
131167
- if (typeof candidate !== "string" || !path25.isAbsolute(candidate)) return null;
131209
+ if (typeof candidate !== "string" || !path26.isAbsolute(candidate)) return null;
131168
131210
  if (process.platform === "win32") {
131169
131211
  if (candidate.startsWith("\\\\?\\") || candidate.startsWith("\\\\.\\")) return null;
131170
131212
  if (candidate.startsWith("\\\\")) return null;
131171
131213
  }
131172
131214
  try {
131173
- const real = fs17.realpathSync(candidate);
131174
- const stat2 = fs17.statSync(real);
131215
+ const real = fs18.realpathSync(candidate);
131216
+ const stat2 = fs18.statSync(real);
131175
131217
  if (!stat2.isDirectory()) return null;
131176
131218
  return real;
131177
131219
  } catch {
@@ -131183,19 +131225,20 @@ function resolveRouteCwd(candidate, opts = {}) {
131183
131225
  if (safe2 === null) return null;
131184
131226
  let homeReal;
131185
131227
  try {
131186
- homeReal = fs17.realpathSync(opts.homeOverride ?? os2.homedir());
131228
+ homeReal = fs18.realpathSync(opts.homeOverride ?? os2.homedir());
131187
131229
  } catch {
131188
131230
  return null;
131189
131231
  }
131190
- const rel = path25.relative(homeReal, safe2);
131232
+ const rel = path26.relative(homeReal, safe2);
131191
131233
  if (rel === "") return safe2;
131192
- if (rel.startsWith("..") || path25.isAbsolute(rel)) return null;
131234
+ if (rel.startsWith("..") || path26.isAbsolute(rel)) return null;
131193
131235
  return safe2;
131194
131236
  }
131195
131237
  var SESSION_FILE_NAME, RESUME_GRACE_MS, RESTART_BACKOFFS_MS, CIRCUIT_BREAKER_MAX_ATTEMPTS, CIRCUIT_BREAKER_WINDOW_MS, UUID_V4_PATTERN;
131196
131238
  var init_supervisor = __esm({
131197
131239
  "src/server/launcher/supervisor.ts"() {
131198
131240
  "use strict";
131241
+ init_contract2();
131199
131242
  init_storage2();
131200
131243
  SESSION_FILE_NAME = "launcher-session.json";
131201
131244
  RESUME_GRACE_MS = 5e3;
@@ -131495,9 +131538,23 @@ function makeWorkingDirHandler(deps) {
131495
131538
  function sendUnexpected(res, err, label) {
131496
131539
  console.error(`[Launcher routes] ${label}:`, err);
131497
131540
  if (res.headersSent) return;
131498
- res.status(500).json({ error: "INTERNAL_ERROR", code: "INTERNAL_ERROR", message: label });
131541
+ const detail = err instanceof Error ? err.message : String(err);
131542
+ if (detail.includes(REAPER_NOT_FOUND_MARKER)) {
131543
+ res.status(500).json({
131544
+ error: "INTERNAL_ERROR",
131545
+ code: LAUNCHER_ERROR_REAPER_NOT_FOUND,
131546
+ message: "Claude launcher binary missing \u2014 reinstall Tandem to restore it."
131547
+ });
131548
+ return;
131549
+ }
131550
+ const truncated = detail.length > MAX_ERROR_DETAIL ? `${detail.slice(0, MAX_ERROR_DETAIL)}\u2026` : detail;
131551
+ res.status(500).json({
131552
+ error: "INTERNAL_ERROR",
131553
+ code: "INTERNAL_ERROR",
131554
+ message: truncated || label
131555
+ });
131499
131556
  }
131500
- var gate, inflight;
131557
+ var gate, inflight, MAX_ERROR_DETAIL;
131501
131558
  var init_api_routes3 = __esm({
131502
131559
  "src/server/launcher/api-routes.ts"() {
131503
131560
  "use strict";
@@ -131512,6 +131569,7 @@ var init_api_routes3 = __esm({
131512
131569
  startFresh: false,
131513
131570
  workingDirectory: false
131514
131571
  };
131572
+ MAX_ERROR_DETAIL = 300;
131515
131573
  }
131516
131574
  });
131517
131575
 
@@ -131741,8 +131799,8 @@ function getFramesFromEvent(event) {
131741
131799
  }
131742
131800
  return void 0;
131743
131801
  }
131744
- function normalizeStackTracePath(path30) {
131745
- let filename = path30?.startsWith("file://") ? path30.slice(7) : path30;
131802
+ function normalizeStackTracePath(path31) {
131803
+ let filename = path31?.startsWith("file://") ? path31.slice(7) : path31;
131746
131804
  if (filename?.match(/\/[A-Z]:/)) {
131747
131805
  filename = filename.slice(1);
131748
131806
  }
@@ -132237,10 +132295,10 @@ function getCrypto() {
132237
132295
  function getRandomByte() {
132238
132296
  return safeMathRandom() * 16;
132239
132297
  }
132240
- function uuid4(crypto8 = getCrypto()) {
132298
+ function uuid4(crypto9 = getCrypto()) {
132241
132299
  try {
132242
- if (crypto8?.randomUUID) {
132243
- return withRandomSafeContext(() => crypto8.randomUUID()).replace(/-/g, "");
132300
+ if (crypto9?.randomUUID) {
132301
+ return withRandomSafeContext(() => crypto9.randomUUID()).replace(/-/g, "");
132244
132302
  }
132245
132303
  } catch {
132246
132304
  }
@@ -133739,8 +133797,8 @@ function isValidProtocol(protocol) {
133739
133797
  return protocol === "http" || protocol === "https";
133740
133798
  }
133741
133799
  function dsnToString(dsn, withPassword = false) {
133742
- const { host, path: path30, pass, port, projectId, protocol, publicKey } = dsn;
133743
- return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${path30 ? `${path30}/` : path30}${projectId}`;
133800
+ const { host, path: path31, pass, port, projectId, protocol, publicKey } = dsn;
133801
+ return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${path31 ? `${path31}/` : path31}${projectId}`;
133744
133802
  }
133745
133803
  function dsnFromString(str) {
133746
133804
  const match = DSN_REGEX.exec(str);
@@ -133751,11 +133809,11 @@ function dsnFromString(str) {
133751
133809
  return void 0;
133752
133810
  }
133753
133811
  const [protocol, publicKey, pass = "", host = "", port = "", lastPath = ""] = match.slice(1);
133754
- let path30 = "";
133812
+ let path31 = "";
133755
133813
  let projectId = lastPath;
133756
133814
  const split = projectId.split("/");
133757
133815
  if (split.length > 1) {
133758
- path30 = split.slice(0, -1).join("/");
133816
+ path31 = split.slice(0, -1).join("/");
133759
133817
  projectId = split.pop();
133760
133818
  }
133761
133819
  if (projectId) {
@@ -133764,7 +133822,7 @@ function dsnFromString(str) {
133764
133822
  projectId = projectMatch[0];
133765
133823
  }
133766
133824
  }
133767
- return dsnFromComponents({ host, pass, path: path30, projectId, port, protocol, publicKey });
133825
+ return dsnFromComponents({ host, pass, path: path31, projectId, port, protocol, publicKey });
133768
133826
  }
133769
133827
  function dsnFromComponents(components) {
133770
133828
  return {
@@ -135876,9 +135934,9 @@ function stripUrlQueryAndFragment(urlPath) {
135876
135934
  return urlPath.split(/[?#]/, 1)[0];
135877
135935
  }
135878
135936
  function getSanitizedUrlString(url) {
135879
- const { protocol, host, path: path30 } = url;
135937
+ const { protocol, host, path: path31 } = url;
135880
135938
  const filteredHost = host?.replace(/^.*@/, "[filtered]:[filtered]@").replace(/(:80)$/, "").replace(/(:443)$/, "") || "";
135881
- return `${protocol ? `${protocol}://` : ""}${filteredHost}${path30}`;
135939
+ return `${protocol ? `${protocol}://` : ""}${filteredHost}${path31}`;
135882
135940
  }
135883
135941
  function stripDataUrlContent(url, includeDataPrefix = true) {
135884
135942
  if (url.startsWith("data:")) {
@@ -140284,12 +140342,12 @@ function resolve4(...args2) {
140284
140342
  let resolvedPath = "";
140285
140343
  let resolvedAbsolute = false;
140286
140344
  for (let i = args2.length - 1; i >= -1 && !resolvedAbsolute; i--) {
140287
- const path30 = i >= 0 ? args2[i] : "/";
140288
- if (!path30) {
140345
+ const path31 = i >= 0 ? args2[i] : "/";
140346
+ if (!path31) {
140289
140347
  continue;
140290
140348
  }
140291
- resolvedPath = `${path30}/${resolvedPath}`;
140292
- resolvedAbsolute = path30.charAt(0) === "/";
140349
+ resolvedPath = `${path31}/${resolvedPath}`;
140350
+ resolvedAbsolute = path31.charAt(0) === "/";
140293
140351
  }
140294
140352
  resolvedPath = normalizeArray(
140295
140353
  resolvedPath.split("/").filter((p) => !!p),
@@ -140335,8 +140393,8 @@ function relative(from3, to) {
140335
140393
  outputParts = outputParts.concat(toParts.slice(samePartsLength));
140336
140394
  return outputParts.join("/");
140337
140395
  }
140338
- function dirname4(path30) {
140339
- const result2 = splitPath(path30);
140396
+ function dirname4(path31) {
140397
+ const result2 = splitPath(path31);
140340
140398
  const root3 = result2[0] || "";
140341
140399
  let dir = result2[1];
140342
140400
  if (!root3 && !dir) {
@@ -140347,8 +140405,8 @@ function dirname4(path30) {
140347
140405
  }
140348
140406
  return root3 + dir;
140349
140407
  }
140350
- function basename2(path30, ext) {
140351
- let f = splitPath(path30)[2] || "";
140408
+ function basename2(path31, ext) {
140409
+ let f = splitPath(path31)[2] || "";
140352
140410
  if (ext && f.slice(ext.length * -1) === ext) {
140353
140411
  f = f.slice(0, f.length - ext.length);
140354
140412
  }
@@ -140850,8 +140908,8 @@ function flattenIssue(issue2) {
140850
140908
  unionErrors: "unionErrors" in issue2 ? JSON.stringify(issue2.unionErrors) : void 0
140851
140909
  };
140852
140910
  }
140853
- function flattenIssuePath(path30) {
140854
- return path30.map((p) => {
140911
+ function flattenIssuePath(path31) {
140912
+ return path31.map((p) => {
140855
140913
  if (typeof p === "number") {
140856
140914
  return "<array>";
140857
140915
  } else {
@@ -145506,12 +145564,12 @@ function captureIfError(nextResult) {
145506
145564
  }
145507
145565
  function trpcMiddleware(options = {}) {
145508
145566
  return async function(opts) {
145509
- const { path: path30, type: type3, next, rawInput, getRawInput } = opts;
145567
+ const { path: path31, type: type3, next, rawInput, getRawInput } = opts;
145510
145568
  const client = getClient();
145511
145569
  const clientOptions = client?.getOptions();
145512
145570
  const dataCollection = client?.getDataCollectionOptions();
145513
145571
  const trpcContext = {
145514
- procedure_path: path30,
145572
+ procedure_path: path31,
145515
145573
  procedure_type: type3
145516
145574
  };
145517
145575
  setNormalizationDepthOverrideHint(
@@ -145536,7 +145594,7 @@ function trpcMiddleware(options = {}) {
145536
145594
  scope.setContext("trpc", trpcContext);
145537
145595
  return startSpanManual(
145538
145596
  {
145539
- name: `trpc/${path30}`,
145597
+ name: `trpc/${path31}`,
145540
145598
  op: "rpc.server",
145541
145599
  attributes: {
145542
145600
  [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "route",
@@ -146806,7 +146864,7 @@ function getActualMatchedRoute(req, constructedRoute) {
146806
146864
  if (layersStore.length === 0) {
146807
146865
  return void 0;
146808
146866
  }
146809
- if (layersStore.every((path30) => path30 === "/")) {
146867
+ if (layersStore.every((path31) => path31 === "/")) {
146810
146868
  return req.originalUrl === "/" ? "/" : void 0;
146811
146869
  }
146812
146870
  if (constructedRoute === "*") {
@@ -146822,11 +146880,11 @@ function getActualMatchedRoute(req, constructedRoute) {
146822
146880
  function getConstructedRoute(req) {
146823
146881
  const layersStore = getStoredLayers(req);
146824
146882
  let constructedRoute = "";
146825
- for (const path30 of layersStore) {
146826
- if (path30 === "/" || path30 === "/*") {
146883
+ for (const path31 of layersStore) {
146884
+ if (path31 === "/" || path31 === "/*") {
146827
146885
  continue;
146828
146886
  }
146829
- constructedRoute += !constructedRoute || constructedRoute.endsWith("/") ? path30 : `/${path30}`;
146887
+ constructedRoute += !constructedRoute || constructedRoute.endsWith("/") ? path31 : `/${path31}`;
146830
146888
  }
146831
146889
  return constructedRoute.replace(/\/{2,}/g, "/");
146832
146890
  }
@@ -146875,15 +146933,15 @@ var init_utils11 = __esm({
146875
146933
  };
146876
146934
  }
146877
146935
  };
146878
- getRouterPath = (path30, layer) => {
146936
+ getRouterPath = (path31, layer) => {
146879
146937
  const stackLayer = Array.isArray(layer.handle?.stack) ? layer.handle?.stack?.[0] : void 0;
146880
146938
  if (stackLayer?.route?.path) {
146881
- return `${path30}${stackLayer.route.path}`;
146939
+ return `${path31}${stackLayer.route.path}`;
146882
146940
  }
146883
146941
  if (stackLayer && Array.isArray(stackLayer?.handle?.stack)) {
146884
- return getRouterPath(path30, stackLayer);
146942
+ return getRouterPath(path31, stackLayer);
146885
146943
  }
146886
- return path30;
146944
+ return path31;
146887
146945
  };
146888
146946
  isLayerIgnored = (name2, type3, config4) => {
146889
146947
  if (Array.isArray(config4?.ignoreLayersType) && config4?.ignoreLayersType?.includes(type3)) {
@@ -147480,8 +147538,8 @@ function getRequestUrlObject(requestOptions) {
147480
147538
  const hostHeader = requestOptions.headers?.host && String(requestOptions.headers?.host);
147481
147539
  const hostname3 = hostHeader || requestOptions.hostname || requestOptions.host || "";
147482
147540
  const port = !requestOptions.port || requestOptions.port === 80 || requestOptions.port === 443 || /^(.*):(\d+)$/.test(hostname3) ? "" : `:${requestOptions.port}`;
147483
- const path30 = requestOptions.path ? requestOptions.path : "/";
147484
- return new URL(path30, `${protocol}//${hostname3}${port}`);
147541
+ const path31 = requestOptions.path ? requestOptions.path : "/";
147542
+ return new URL(path31, `${protocol}//${hostname3}${port}`);
147485
147543
  }
147486
147544
  function getRequestUrlFromClientRequest(request3) {
147487
147545
  return String(getRequestUrl(getRequestOptions(request3)));
@@ -148248,11 +148306,11 @@ function shouldIgnoreSpansForIncomingRequest(request3, {
148248
148306
  return false;
148249
148307
  }
148250
148308
  function isStaticAssetRequest(urlPath) {
148251
- const path30 = stripUrlQueryAndFragment(urlPath);
148252
- if (path30.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
148309
+ const path31 = stripUrlQueryAndFragment(urlPath);
148310
+ if (path31.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
148253
148311
  return true;
148254
148312
  }
148255
- if (path30.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
148313
+ if (path31.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
148256
148314
  return true;
148257
148315
  }
148258
148316
  return false;
@@ -150729,19 +150787,19 @@ var require_module_details_from_path = __commonJS({
150729
150787
  basedir += segments[i] + sep4;
150730
150788
  }
150731
150789
  }
150732
- var path30 = "";
150790
+ var path31 = "";
150733
150791
  var lastSegmentIndex = segments.length - 1;
150734
150792
  for (var i2 = index2 + offset; i2 <= lastSegmentIndex; i2++) {
150735
150793
  if (i2 === lastSegmentIndex) {
150736
- path30 += segments[i2];
150794
+ path31 += segments[i2];
150737
150795
  } else {
150738
- path30 += segments[i2] + sep4;
150796
+ path31 += segments[i2] + sep4;
150739
150797
  }
150740
150798
  }
150741
150799
  return {
150742
150800
  name: name2,
150743
150801
  basedir,
150744
- path: path30
150802
+ path: path31
150745
150803
  };
150746
150804
  };
150747
150805
  }
@@ -150751,7 +150809,7 @@ var require_module_details_from_path = __commonJS({
150751
150809
  var require_require_in_the_middle = __commonJS({
150752
150810
  "node_modules/require-in-the-middle/index.js"(exports3, module3) {
150753
150811
  "use strict";
150754
- var path30 = __require("path");
150812
+ var path31 = __require("path");
150755
150813
  var Module = __require("module");
150756
150814
  var debug4 = require_src()("require-in-the-middle");
150757
150815
  var moduleDetailsFromPath = require_module_details_from_path();
@@ -150896,7 +150954,7 @@ var require_require_in_the_middle = __commonJS({
150896
150954
  }
150897
150955
  moduleName = filename;
150898
150956
  } else if (hasWhitelist === true && modules.includes(filename)) {
150899
- const parsedPath = path30.parse(filename);
150957
+ const parsedPath = path31.parse(filename);
150900
150958
  moduleName = parsedPath.name;
150901
150959
  basedir = parsedPath.dir;
150902
150960
  } else {
@@ -150934,7 +150992,7 @@ var require_require_in_the_middle = __commonJS({
150934
150992
  }
150935
150993
  if (res !== filename) {
150936
150994
  if (internals === true) {
150937
- moduleName = moduleName + path30.sep + path30.relative(basedir, filename);
150995
+ moduleName = moduleName + path31.sep + path31.relative(basedir, filename);
150938
150996
  debug4("preparing to process require of internal file: %s", moduleName);
150939
150997
  } else {
150940
150998
  debug4("ignoring require of non-main module file: %s", res);
@@ -150970,8 +151028,8 @@ var require_require_in_the_middle = __commonJS({
150970
151028
  }
150971
151029
  };
150972
151030
  function resolveModuleName(stat2) {
150973
- const normalizedPath = path30.sep !== "/" ? stat2.path.split(path30.sep).join("/") : stat2.path;
150974
- return path30.posix.join(stat2.name, normalizedPath).replace(normalize5, "");
151031
+ const normalizedPath = path31.sep !== "/" ? stat2.path.split(path31.sep).join("/") : stat2.path;
151032
+ return path31.posix.join(stat2.name, normalizedPath).replace(normalize5, "");
150975
151033
  }
150976
151034
  }
150977
151035
  });
@@ -151048,9 +151106,9 @@ var init_ModuleNameTrie = __esm({
151048
151106
  });
151049
151107
 
151050
151108
  // node_modules/@opentelemetry/instrumentation/build/esm/platform/node/RequireInTheMiddleSingleton.js
151051
- import * as path26 from "path";
151109
+ import * as path27 from "path";
151052
151110
  function normalizePathSeparators(moduleNameOrPath) {
151053
- return path26.sep !== ModuleNameSeparator ? moduleNameOrPath.split(path26.sep).join(ModuleNameSeparator) : moduleNameOrPath;
151111
+ return path27.sep !== ModuleNameSeparator ? moduleNameOrPath.split(path27.sep).join(ModuleNameSeparator) : moduleNameOrPath;
151054
151112
  }
151055
151113
  var import_require_in_the_middle, isMocha, RequireInTheMiddleSingleton;
151056
151114
  var init_RequireInTheMiddleSingleton = __esm({
@@ -151179,7 +151237,7 @@ var require_register = __commonJS({
151179
151237
  var require_import_in_the_middle = __commonJS({
151180
151238
  "node_modules/import-in-the-middle/index.js"(exports3, module3) {
151181
151239
  "use strict";
151182
- var path30 = __require("path");
151240
+ var path31 = __require("path");
151183
151241
  var moduleDetailsFromPath = require_module_details_from_path();
151184
151242
  var { fileURLToPath: fileURLToPath6 } = __require("url");
151185
151243
  var { MessageChannel: MessageChannel2 } = __require("worker_threads");
@@ -151298,7 +151356,7 @@ var require_import_in_the_middle = __commonJS({
151298
151356
  } else if (baseDir.endsWith(specifiers.get(loadUrl)) || isTurbopackSpecifier(specifiers.get(loadUrl), baseDir)) {
151299
151357
  callHookFn(hookFn, namespace, name2, baseDir);
151300
151358
  } else if (internals) {
151301
- const internalPath = name2 + path30.sep + path30.relative(baseDir, filePath);
151359
+ const internalPath = name2 + path31.sep + path31.relative(baseDir, filePath);
151302
151360
  callHookFn(hookFn, namespace, internalPath, baseDir);
151303
151361
  }
151304
151362
  } else if (matchArg === specifier) {
@@ -151348,7 +151406,7 @@ var init_utils13 = __esm({
151348
151406
  });
151349
151407
 
151350
151408
  // node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
151351
- import * as path27 from "path";
151409
+ import * as path28 from "path";
151352
151410
  import { types as utilTypes } from "util";
151353
151411
  import { readFileSync as readFileSync4 } from "fs";
151354
151412
  function isSupported(supportedVersions9, version3, includePrerelease) {
@@ -151461,7 +151519,7 @@ var init_instrumentation2 = __esm({
151461
151519
  }
151462
151520
  _extractPackageVersion(baseDir) {
151463
151521
  try {
151464
- const json = readFileSync4(path27.join(baseDir, "package.json"), {
151522
+ const json = readFileSync4(path28.join(baseDir, "package.json"), {
151465
151523
  encoding: "utf8"
151466
151524
  });
151467
151525
  const version3 = JSON.parse(json).version;
@@ -151503,7 +151561,7 @@ var init_instrumentation2 = __esm({
151503
151561
  return exports3;
151504
151562
  }
151505
151563
  const files2 = module3.files ?? [];
151506
- const normalizedName = path27.normalize(name2);
151564
+ const normalizedName = path28.normalize(name2);
151507
151565
  const supportedFileInstrumentations = files2.filter((f) => f.name === normalizedName && isSupported(f.supportedVersions, version3, module3.includePrerelease));
151508
151566
  return supportedFileInstrumentations.reduce((patchedExports, file) => {
151509
151567
  file.moduleExports = patchedExports;
@@ -151549,8 +151607,8 @@ var init_instrumentation2 = __esm({
151549
151607
  this._warnOnPreloadedModules();
151550
151608
  for (const module3 of this._modules) {
151551
151609
  const hookFn = (exports3, name2, baseDir) => {
151552
- if (!baseDir && path27.isAbsolute(name2)) {
151553
- const parsedPath = path27.parse(name2);
151610
+ if (!baseDir && path28.isAbsolute(name2)) {
151611
+ const parsedPath = path28.parse(name2);
151554
151612
  name2 = parsedPath.name;
151555
151613
  baseDir = parsedPath.dir;
151556
151614
  }
@@ -151559,7 +151617,7 @@ var init_instrumentation2 = __esm({
151559
151617
  const onRequire = (exports3, name2, baseDir) => {
151560
151618
  return this._onRequire(module3, exports3, name2, baseDir);
151561
151619
  };
151562
- const hook = path27.isAbsolute(module3.name) ? new import_require_in_the_middle2.Hook([module3.name], { internals: true }, onRequire) : this._requireInTheMiddleSingleton.register(module3.name, onRequire);
151620
+ const hook = path28.isAbsolute(module3.name) ? new import_require_in_the_middle2.Hook([module3.name], { internals: true }, onRequire) : this._requireInTheMiddleSingleton.register(module3.name, onRequire);
151563
151621
  this._hooks.push(hook);
151564
151622
  const esmHook = new import_import_in_the_middle.Hook([module3.name], { internals: true }, hookFn);
151565
151623
  this._hooks.push(esmHook);
@@ -152782,11 +152840,11 @@ function isKnownPrefetchRequest2(req) {
152782
152840
  return req.headers["next-router-prefetch"] === "1";
152783
152841
  }
152784
152842
  function isStaticAssetRequest2(urlPath) {
152785
- const path30 = stripUrlQueryAndFragment(urlPath);
152786
- if (path30.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
152843
+ const path31 = stripUrlQueryAndFragment(urlPath);
152844
+ if (path31.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
152787
152845
  return true;
152788
152846
  }
152789
- if (path30.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
152847
+ if (path31.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
152790
152848
  return true;
152791
152849
  }
152792
152850
  return false;
@@ -153326,19 +153384,19 @@ function getBreadcrumbData(request3) {
153326
153384
  return {};
153327
153385
  }
153328
153386
  }
153329
- function getAbsoluteUrl2(origin, path30 = "/") {
153387
+ function getAbsoluteUrl2(origin, path31 = "/") {
153330
153388
  try {
153331
- const url = new URL(path30, origin);
153389
+ const url = new URL(path31, origin);
153332
153390
  return url.toString();
153333
153391
  } catch {
153334
153392
  const url = `${origin}`;
153335
- if (url.endsWith("/") && path30.startsWith("/")) {
153336
- return `${url}${path30.slice(1)}`;
153393
+ if (url.endsWith("/") && path31.startsWith("/")) {
153394
+ return `${url}${path31.slice(1)}`;
153337
153395
  }
153338
- if (!url.endsWith("/") && !path30.startsWith("/")) {
153339
- return `${url}/${path30}`;
153396
+ if (!url.endsWith("/") && !path31.startsWith("/")) {
153397
+ return `${url}/${path31}`;
153340
153398
  }
153341
- return `${url}${path30}`;
153399
+ return `${url}${path31}`;
153342
153400
  }
153343
153401
  }
153344
153402
  var SENTRY_TRACE_HEADER, SENTRY_BAGGAGE_HEADER, W3C_TRACEPARENT_HEADER;
@@ -156905,12 +156963,12 @@ function emplace(map5, key, contents) {
156905
156963
  }
156906
156964
  return value;
156907
156965
  }
156908
- function shouldSkipContextLinesForFile(path30) {
156909
- if (path30.startsWith("node:")) return true;
156910
- if (path30.endsWith(".min.js")) return true;
156911
- if (path30.endsWith(".min.cjs")) return true;
156912
- if (path30.endsWith(".min.mjs")) return true;
156913
- if (path30.startsWith("data:")) return true;
156966
+ function shouldSkipContextLinesForFile(path31) {
156967
+ if (path31.startsWith("node:")) return true;
156968
+ if (path31.endsWith(".min.js")) return true;
156969
+ if (path31.endsWith(".min.cjs")) return true;
156970
+ if (path31.endsWith(".min.mjs")) return true;
156971
+ if (path31.startsWith("data:")) return true;
156914
156972
  return false;
156915
156973
  }
156916
156974
  function shouldSkipContextLinesForFrame(frame) {
@@ -156958,9 +157016,9 @@ function makeLineReaderRanges(lines, linecontext) {
156958
157016
  }
156959
157017
  return out;
156960
157018
  }
156961
- function getContextLinesFromFile(path30, ranges, output) {
157019
+ function getContextLinesFromFile(path31, ranges, output) {
156962
157020
  return new Promise((resolve5, _reject) => {
156963
- const stream = createReadStream(path30);
157021
+ const stream = createReadStream(path31);
156964
157022
  const lineReaded = createInterface({
156965
157023
  input: stream
156966
157024
  });
@@ -156978,8 +157036,8 @@ function getContextLinesFromFile(path30, ranges, output) {
156978
157036
  let rangeStart = range3[0];
156979
157037
  let rangeEnd = range3[1];
156980
157038
  function onStreamError(e) {
156981
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path30, 1);
156982
- DEBUG_BUILD2 && debug.error(`Failed to read file: ${path30}. Error: ${e}`);
157039
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path31, 1);
157040
+ DEBUG_BUILD2 && debug.error(`Failed to read file: ${path31}. Error: ${e}`);
156983
157041
  lineReaded.close();
156984
157042
  lineReaded.removeAllListeners();
156985
157043
  destroyStreamAndResolve();
@@ -157670,8 +157728,8 @@ function collectRequireModules() {
157670
157728
  const paths = getRequireCachePaths();
157671
157729
  const infos = {};
157672
157730
  const seen = /* @__PURE__ */ new Set();
157673
- paths.forEach((path30) => {
157674
- let dir = path30;
157731
+ paths.forEach((path31) => {
157732
+ let dir = path31;
157675
157733
  const updir = () => {
157676
157734
  const orig = dir;
157677
157735
  dir = dirname5(orig);
@@ -158618,8 +158676,8 @@ var init_spotlight2 = __esm({
158618
158676
 
158619
158677
  // node_modules/@sentry/node-core/build/esm/utils/module.js
158620
158678
  import { posix, sep as sep3 } from "path";
158621
- function normalizeWindowsPath(path30) {
158622
- return path30.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
158679
+ function normalizeWindowsPath(path31) {
158680
+ return path31.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
158623
158681
  }
158624
158682
  function createGetModuleFromFilename(basePath = process.argv[1] ? dirname4(process.argv[1]) : process.cwd(), isWindows = sep3 === "\\") {
158625
158683
  const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
@@ -160421,15 +160479,15 @@ var init_undici = __esm({
160421
160479
  });
160422
160480
 
160423
160481
  // node_modules/@sentry/node/build/esm/integrations/node-fetch/index.js
160424
- function getAbsoluteUrl3(origin, path30 = "/") {
160482
+ function getAbsoluteUrl3(origin, path31 = "/") {
160425
160483
  const url = `${origin}`;
160426
- if (url.endsWith("/") && path30.startsWith("/")) {
160427
- return `${url}${path30.slice(1)}`;
160484
+ if (url.endsWith("/") && path31.startsWith("/")) {
160485
+ return `${url}${path31.slice(1)}`;
160428
160486
  }
160429
- if (!url.endsWith("/") && !path30.startsWith("/")) {
160430
- return `${url}/${path30}`;
160487
+ if (!url.endsWith("/") && !path31.startsWith("/")) {
160488
+ return `${url}/${path31}`;
160431
160489
  }
160432
- return `${url}${path30}`;
160490
+ return `${url}${path31}`;
160433
160491
  }
160434
160492
  function _shouldInstrumentSpans(options, clientOptions = {}) {
160435
160493
  return typeof options.spans === "boolean" ? options.spans : !clientOptions.skipOpenTelemetrySetup && hasSpansEnabled(clientOptions);
@@ -160651,18 +160709,18 @@ function splitTwoLevels(functionName) {
160651
160709
  return [functionName];
160652
160710
  }
160653
160711
  }
160654
- function indexFs(fs19, member) {
160712
+ function indexFs(fs20, member) {
160655
160713
  if (!member) throw new Error(JSON.stringify({ member }));
160656
160714
  const splitResult = splitTwoLevels(member);
160657
160715
  const [functionName1, functionName2] = splitResult;
160658
160716
  if (functionName2) {
160659
160717
  return {
160660
- objectToPatch: fs19[functionName1],
160718
+ objectToPatch: fs20[functionName1],
160661
160719
  functionNameToPatch: functionName2
160662
160720
  };
160663
160721
  } else {
160664
160722
  return {
160665
- objectToPatch: fs19,
160723
+ objectToPatch: fs20,
160666
160724
  functionNameToPatch: functionName1
160667
160725
  };
160668
160726
  }
@@ -160698,16 +160756,16 @@ var init_instrumentation3 = __esm({
160698
160756
  new InstrumentationNodeModuleDefinition(
160699
160757
  "fs",
160700
160758
  ["*"],
160701
- (fs19) => {
160759
+ (fs20) => {
160702
160760
  for (const fName of SYNC_FUNCTIONS) {
160703
- const { objectToPatch, functionNameToPatch } = indexFs(fs19, fName);
160761
+ const { objectToPatch, functionNameToPatch } = indexFs(fs20, fName);
160704
160762
  if (isWrapped(objectToPatch[functionNameToPatch])) {
160705
160763
  this._unwrap(objectToPatch, functionNameToPatch);
160706
160764
  }
160707
160765
  this._wrap(objectToPatch, functionNameToPatch, this._patchSyncFunction.bind(this, fName));
160708
160766
  }
160709
160767
  for (const fName of CALLBACK_FUNCTIONS) {
160710
- const { objectToPatch, functionNameToPatch } = indexFs(fs19, fName);
160768
+ const { objectToPatch, functionNameToPatch } = indexFs(fs20, fName);
160711
160769
  if (isWrapped(objectToPatch[functionNameToPatch])) {
160712
160770
  this._unwrap(objectToPatch, functionNameToPatch);
160713
160771
  }
@@ -160722,30 +160780,30 @@ var init_instrumentation3 = __esm({
160722
160780
  this._wrap(objectToPatch, functionNameToPatch, this._patchCallbackFunction.bind(this, fName));
160723
160781
  }
160724
160782
  for (const fName of PROMISE_FUNCTIONS) {
160725
- if (isWrapped(fs19.promises[fName])) {
160726
- this._unwrap(fs19.promises, fName);
160783
+ if (isWrapped(fs20.promises[fName])) {
160784
+ this._unwrap(fs20.promises, fName);
160727
160785
  }
160728
- this._wrap(fs19.promises, fName, this._patchPromiseFunction.bind(this, fName));
160786
+ this._wrap(fs20.promises, fName, this._patchPromiseFunction.bind(this, fName));
160729
160787
  }
160730
- return fs19;
160788
+ return fs20;
160731
160789
  },
160732
- (fs19) => {
160733
- if (fs19 === void 0) return;
160790
+ (fs20) => {
160791
+ if (fs20 === void 0) return;
160734
160792
  for (const fName of SYNC_FUNCTIONS) {
160735
- const { objectToPatch, functionNameToPatch } = indexFs(fs19, fName);
160793
+ const { objectToPatch, functionNameToPatch } = indexFs(fs20, fName);
160736
160794
  if (isWrapped(objectToPatch[functionNameToPatch])) {
160737
160795
  this._unwrap(objectToPatch, functionNameToPatch);
160738
160796
  }
160739
160797
  }
160740
160798
  for (const fName of CALLBACK_FUNCTIONS) {
160741
- const { objectToPatch, functionNameToPatch } = indexFs(fs19, fName);
160799
+ const { objectToPatch, functionNameToPatch } = indexFs(fs20, fName);
160742
160800
  if (isWrapped(objectToPatch[functionNameToPatch])) {
160743
160801
  this._unwrap(objectToPatch, functionNameToPatch);
160744
160802
  }
160745
160803
  }
160746
160804
  for (const fName of PROMISE_FUNCTIONS) {
160747
- if (isWrapped(fs19.promises[fName])) {
160748
- this._unwrap(fs19.promises, fName);
160805
+ if (isWrapped(fs20.promises[fName])) {
160806
+ this._unwrap(fs20.promises, fName);
160749
160807
  }
160750
160808
  }
160751
160809
  }
@@ -160903,8 +160961,8 @@ var init_instrumentation3 = __esm({
160903
160961
  }
160904
160962
  };
160905
160963
  const functionWithOriginalProperties = patchedFunctionWithOriginalProperties(patchedFunction, original);
160906
- const promisified = function(path30) {
160907
- return new Promise((resolve5) => functionWithOriginalProperties(path30, resolve5));
160964
+ const promisified = function(path31) {
160965
+ return new Promise((resolve5) => functionWithOriginalProperties(path31, resolve5));
160908
160966
  };
160909
160967
  Object.defineProperty(promisified, "name", { value: functionName });
160910
160968
  Object.defineProperty(functionWithOriginalProperties, promisify5.custom, {
@@ -162172,23 +162230,23 @@ function addSpanSource(span, loc, allowValues, start, end) {
162172
162230
  const source = getSourceFromLocation(loc, allowValues, start, end);
162173
162231
  span.setAttribute(AttributeNames2.SOURCE, source);
162174
162232
  }
162175
- function createFieldIfNotExists(tracer, getConfig3, contextValue, info3, path30) {
162176
- let field = getField(contextValue, path30);
162233
+ function createFieldIfNotExists(tracer, getConfig3, contextValue, info3, path31) {
162234
+ let field = getField(contextValue, path31);
162177
162235
  if (field) {
162178
162236
  return { field, spanAdded: false };
162179
162237
  }
162180
162238
  const config4 = getConfig3();
162181
- const parentSpan = config4.flatResolveSpans ? getRootSpan2(contextValue) : getParentFieldSpan(contextValue, path30);
162239
+ const parentSpan = config4.flatResolveSpans ? getRootSpan2(contextValue) : getParentFieldSpan(contextValue, path31);
162182
162240
  field = {
162183
- span: createResolverSpan(tracer, getConfig3, contextValue, info3, path30, parentSpan)
162241
+ span: createResolverSpan(tracer, getConfig3, contextValue, info3, path31, parentSpan)
162184
162242
  };
162185
- addField(contextValue, path30, field);
162243
+ addField(contextValue, path31, field);
162186
162244
  return { field, spanAdded: true };
162187
162245
  }
162188
- function createResolverSpan(tracer, getConfig3, contextValue, info3, path30, parentSpan) {
162246
+ function createResolverSpan(tracer, getConfig3, contextValue, info3, path31, parentSpan) {
162189
162247
  const attributes = {
162190
162248
  [AttributeNames2.FIELD_NAME]: info3.fieldName,
162191
- [AttributeNames2.FIELD_PATH]: path30.join("."),
162249
+ [AttributeNames2.FIELD_PATH]: path31.join("."),
162192
162250
  [AttributeNames2.FIELD_TYPE]: info3.returnType.toString(),
162193
162251
  [AttributeNames2.PARENT_NAME]: info3.parentType.name
162194
162252
  };
@@ -162222,15 +162280,15 @@ function getOperation(document4, operationName) {
162222
162280
  return document4.definitions.find((definition3) => OPERATION_VALUES.indexOf(definition3?.operation) !== -1);
162223
162281
  }
162224
162282
  }
162225
- function addField(contextValue, path30, field) {
162226
- return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path30.join(".")] = field;
162283
+ function addField(contextValue, path31, field) {
162284
+ return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path31.join(".")] = field;
162227
162285
  }
162228
- function getField(contextValue, path30) {
162229
- return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path30.join(".")];
162286
+ function getField(contextValue, path31) {
162287
+ return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path31.join(".")];
162230
162288
  }
162231
- function getParentFieldSpan(contextValue, path30) {
162232
- for (let i = path30.length - 1; i > 0; i--) {
162233
- const field = getField(contextValue, path30.slice(0, i));
162289
+ function getParentFieldSpan(contextValue, path31) {
162290
+ for (let i = path31.length - 1; i > 0; i--) {
162291
+ const field = getField(contextValue, path31.slice(0, i));
162234
162292
  if (field) {
162235
162293
  return field.span;
162236
162294
  }
@@ -162240,9 +162298,9 @@ function getParentFieldSpan(contextValue, path30) {
162240
162298
  function getRootSpan2(contextValue) {
162241
162299
  return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].span;
162242
162300
  }
162243
- function pathToArray(mergeItems, path30) {
162301
+ function pathToArray(mergeItems, path31) {
162244
162302
  const flattened = [];
162245
- let curr = path30;
162303
+ let curr = path31;
162246
162304
  while (curr) {
162247
162305
  let key = curr.key;
162248
162306
  if (mergeItems && typeof key === "number") {
@@ -162370,14 +162428,14 @@ function wrapFieldResolver(tracer, getConfig3, fieldResolver, isDefaultResolver
162370
162428
  if (!contextValue[OTEL_GRAPHQL_DATA_SYMBOL]) {
162371
162429
  return fieldResolver.call(this, source, args2, contextValue, info3);
162372
162430
  }
162373
- const path30 = pathToArray(config4.mergeItems, info3 && info3.path);
162374
- const depth = path30.filter((item) => typeof item === "string").length;
162431
+ const path31 = pathToArray(config4.mergeItems, info3 && info3.path);
162432
+ const depth = path31.filter((item) => typeof item === "string").length;
162375
162433
  let span;
162376
162434
  let shouldEndSpan = false;
162377
162435
  if (config4.depth >= 0 && config4.depth < depth) {
162378
- span = getParentFieldSpan(contextValue, path30);
162436
+ span = getParentFieldSpan(contextValue, path31);
162379
162437
  } else {
162380
- const { field, spanAdded } = createFieldIfNotExists(tracer, getConfig3, contextValue, info3, path30);
162438
+ const { field, spanAdded } = createFieldIfNotExists(tracer, getConfig3, contextValue, info3, path31);
162381
162439
  span = field.span;
162382
162440
  shouldEndSpan = spanAdded;
162383
162441
  }
@@ -167528,10 +167586,10 @@ var init_postgresjs2 = __esm({
167528
167586
  },
167529
167587
  (exports3) => exports3
167530
167588
  );
167531
- ["src", "cf/src", "cjs/src"].forEach((path30) => {
167589
+ ["src", "cf/src", "cjs/src"].forEach((path31) => {
167532
167590
  module3.files.push(
167533
167591
  new InstrumentationNodeModuleFile(
167534
- `postgres/${path30}/query.js`,
167592
+ `postgres/${path31}/query.js`,
167535
167593
  SUPPORTED_VERSIONS3,
167536
167594
  this._patchQueryPrototype.bind(this),
167537
167595
  this._unpatchQueryPrototype.bind(this)
@@ -168628,13 +168686,13 @@ var init_instrumentation15 = __esm({
168628
168686
  return function(original) {
168629
168687
  return function wrappedHandler(...args2) {
168630
168688
  if (typeof args2[0] === "string") {
168631
- const path30 = args2[0];
168689
+ const path31 = args2[0];
168632
168690
  if (args2.length === 1) {
168633
- return original.apply(this, [path30]);
168691
+ return original.apply(this, [path31]);
168634
168692
  }
168635
168693
  const handlers2 = args2.slice(1);
168636
168694
  return original.apply(this, [
168637
- path30,
168695
+ path31,
168638
168696
  ...handlers2.map((handler) => instrumentation._wrapHandler(handler))
168639
168697
  ]);
168640
168698
  }
@@ -168668,13 +168726,13 @@ var init_instrumentation15 = __esm({
168668
168726
  return function(original) {
168669
168727
  return function wrappedHandler(...args2) {
168670
168728
  if (typeof args2[0] === "string") {
168671
- const path30 = args2[0];
168729
+ const path31 = args2[0];
168672
168730
  if (args2.length === 1) {
168673
- return original.apply(this, [path30]);
168731
+ return original.apply(this, [path31]);
168674
168732
  }
168675
168733
  const handlers2 = args2.slice(1);
168676
168734
  return original.apply(this, [
168677
- path30,
168735
+ path31,
168678
168736
  ...handlers2.map((handler) => instrumentation._wrapHandler(handler))
168679
168737
  ]);
168680
168738
  }
@@ -168694,8 +168752,8 @@ var init_instrumentation15 = __esm({
168694
168752
  if (!instrumentation.isEnabled()) {
168695
168753
  return handler.apply(this, [c, next]);
168696
168754
  }
168697
- const path30 = c.req.path;
168698
- const span = instrumentation.tracer.startSpan(path30);
168755
+ const path31 = c.req.path;
168756
+ const span = instrumentation.tracer.startSpan(path31);
168699
168757
  return context.with(trace2.setSpan(context.active(), span), () => {
168700
168758
  return instrumentation._safeExecute(
168701
168759
  () => {
@@ -168705,7 +168763,7 @@ var init_instrumentation15 = __esm({
168705
168763
  const type3 = instrumentation._determineHandlerType(result22);
168706
168764
  span.setAttributes({
168707
168765
  [AttributeNames6.HONO_TYPE]: type3,
168708
- [AttributeNames6.HONO_NAME]: type3 === HonoTypes.REQUEST_HANDLER ? path30 : handler.name || "anonymous"
168766
+ [AttributeNames6.HONO_NAME]: type3 === HonoTypes.REQUEST_HANDLER ? path31 : handler.name || "anonymous"
168709
168767
  });
168710
168768
  instrumentation.getConfig().responseHook?.(span);
168711
168769
  return result22;
@@ -168714,7 +168772,7 @@ var init_instrumentation15 = __esm({
168714
168772
  const type3 = instrumentation._determineHandlerType(result2);
168715
168773
  span.setAttributes({
168716
168774
  [AttributeNames6.HONO_TYPE]: type3,
168717
- [AttributeNames6.HONO_NAME]: type3 === HonoTypes.REQUEST_HANDLER ? path30 : handler.name || "anonymous"
168775
+ [AttributeNames6.HONO_NAME]: type3 === HonoTypes.REQUEST_HANDLER ? path31 : handler.name || "anonymous"
168718
168776
  });
168719
168777
  instrumentation.getConfig().responseHook?.(span);
168720
168778
  return result2;
@@ -168998,11 +169056,11 @@ var init_instrumentation16 = __esm({
168998
169056
  const router = dispatchLayer.router;
168999
169057
  const routesStack = router?.stack ?? [];
169000
169058
  for (const pathLayer of routesStack) {
169001
- const path30 = pathLayer.path;
169059
+ const path31 = pathLayer.path;
169002
169060
  const pathStack = pathLayer.stack;
169003
169061
  for (let j = 0; j < pathStack.length; j++) {
169004
169062
  const routedMiddleware = pathStack[j];
169005
- pathStack[j] = this._patchLayer(routedMiddleware, true, path30);
169063
+ pathStack[j] = this._patchLayer(routedMiddleware, true, path31);
169006
169064
  }
169007
169065
  }
169008
169066
  return dispatchLayer;
@@ -173041,7 +173099,7 @@ init_doc_hash();
173041
173099
  init_store();
173042
173100
  init_token_store();
173043
173101
  import { isIP as isIP3 } from "net";
173044
- import path29 from "path";
173102
+ import path30 from "path";
173045
173103
  import { fileURLToPath as fileURLToPath5 } from "url";
173046
173104
 
173047
173105
  // src/server/bind-check.ts
@@ -173452,10 +173510,10 @@ function assignProp(target, prop, value) {
173452
173510
  configurable: true
173453
173511
  });
173454
173512
  }
173455
- function getElementAtPath(obj2, path30) {
173456
- if (!path30)
173513
+ function getElementAtPath(obj2, path31) {
173514
+ if (!path31)
173457
173515
  return obj2;
173458
- return path30.reduce((acc, key) => acc?.[key], obj2);
173516
+ return path31.reduce((acc, key) => acc?.[key], obj2);
173459
173517
  }
173460
173518
  function promiseAllObject(promisesObj) {
173461
173519
  const keys4 = Object.keys(promisesObj);
@@ -173775,11 +173833,11 @@ function aborted(x, startIndex = 0) {
173775
173833
  }
173776
173834
  return false;
173777
173835
  }
173778
- function prefixIssues(path30, issues) {
173836
+ function prefixIssues(path31, issues) {
173779
173837
  return issues.map((iss) => {
173780
173838
  var _a3;
173781
173839
  (_a3 = iss).path ?? (_a3.path = []);
173782
- iss.path.unshift(path30);
173840
+ iss.path.unshift(path31);
173783
173841
  return iss;
173784
173842
  });
173785
173843
  }
@@ -184721,6 +184779,192 @@ init_storage2();
184721
184779
  import { randomUUID as randomUUID10 } from "crypto";
184722
184780
  import { createRequire as createRequire2 } from "module";
184723
184781
 
184782
+ // src/server/license/webhook.ts
184783
+ import crypto8 from "crypto";
184784
+ import fs17 from "fs";
184785
+ import path25 from "path";
184786
+
184787
+ // src/server/license/grandfather-list.ts
184788
+ var GRANDFATHER_EMAILS = /* @__PURE__ */ new Set([
184789
+ "bryan@tandem.chat"
184790
+ // Add actual beta-user emails here before v1.0 grandfathering runs.
184791
+ // Do not add @example.com placeholders — they will match real webhook events.
184792
+ ]);
184793
+ function isGrandfathered(email2) {
184794
+ if (!email2) return false;
184795
+ return GRANDFATHER_EMAILS.has(email2.toLowerCase().trim());
184796
+ }
184797
+
184798
+ // src/server/license/verifier.ts
184799
+ function canonicalObject(obj2) {
184800
+ if (typeof obj2 !== "object" || obj2 === null) {
184801
+ return obj2;
184802
+ }
184803
+ if (Array.isArray(obj2)) {
184804
+ return obj2.map(canonicalObject);
184805
+ }
184806
+ const sortedKeys = Object.keys(obj2).sort();
184807
+ const sortedObj = {};
184808
+ for (const key of sortedKeys) {
184809
+ sortedObj[key] = canonicalObject(obj2[key]);
184810
+ }
184811
+ return sortedObj;
184812
+ }
184813
+ function canonicalize(obj2) {
184814
+ return JSON.stringify(canonicalObject(obj2));
184815
+ }
184816
+
184817
+ // src/server/license/webhook.ts
184818
+ function getPrivateKey() {
184819
+ if (process.env.TANDEM_PRIVATE_KEY) {
184820
+ return process.env.TANDEM_PRIVATE_KEY;
184821
+ }
184822
+ const localPrivKeyPath = path25.join(process.cwd(), "keys", "tandem-private-key.pem");
184823
+ if (fs17.existsSync(localPrivKeyPath)) {
184824
+ return fs17.readFileSync(localPrivKeyPath, "utf8");
184825
+ }
184826
+ return null;
184827
+ }
184828
+ var MAX_WEBHOOK_AGE_S = 300;
184829
+ function verifyPolarSignature(payload, signatureHeader, secret) {
184830
+ if (!signatureHeader) return false;
184831
+ const parts = signatureHeader.split(",");
184832
+ const tPart = parts.find((p) => p.startsWith("t="));
184833
+ const v1Part = parts.find((p) => p.startsWith("v1="));
184834
+ if (!tPart || !v1Part) return false;
184835
+ const timestamp = tPart.split("=")[1];
184836
+ const signature = v1Part.split("=")[1];
184837
+ if (Math.abs(Date.now() / 1e3 - parseInt(timestamp, 10)) > MAX_WEBHOOK_AGE_S) return false;
184838
+ const signedPayload = `${timestamp}.${payload}`;
184839
+ const expectedSignature = crypto8.createHmac("sha256", secret).update(signedPayload).digest("hex");
184840
+ try {
184841
+ return crypto8.timingSafeEqual(
184842
+ Buffer.from(signature, "hex"),
184843
+ Buffer.from(expectedSignature, "hex")
184844
+ );
184845
+ } catch {
184846
+ return false;
184847
+ }
184848
+ }
184849
+ function verifyPaddleSignature(payload, signatureHeader, secret) {
184850
+ if (!signatureHeader) return false;
184851
+ const parts = signatureHeader.split(";");
184852
+ const tsPart = parts.find((p) => p.startsWith("ts="));
184853
+ const h1Part = parts.find((p) => p.startsWith("h1="));
184854
+ if (!tsPart || !h1Part) return false;
184855
+ const timestamp = tsPart.split("=")[1];
184856
+ const signature = h1Part.split("=")[1];
184857
+ if (Math.abs(Date.now() / 1e3 - parseInt(timestamp, 10)) > MAX_WEBHOOK_AGE_S) return false;
184858
+ const signedPayload = `${timestamp}:${payload}`;
184859
+ const expectedSignature = crypto8.createHmac("sha256", secret).update(signedPayload).digest("hex");
184860
+ try {
184861
+ return crypto8.timingSafeEqual(
184862
+ Buffer.from(signature, "hex"),
184863
+ Buffer.from(expectedSignature, "hex")
184864
+ );
184865
+ } catch {
184866
+ return false;
184867
+ }
184868
+ }
184869
+ async function handleLicenseWebhook(req, res) {
184870
+ const isDev = process.env.NODE_ENV === "development";
184871
+ try {
184872
+ const rawBody = Buffer.isBuffer(req.body) ? req.body.toString("utf8") : "";
184873
+ const polarSecret = process.env.POLAR_WEBHOOK_SECRET;
184874
+ const paddleSecret = process.env.PADDLE_WEBHOOK_SECRET;
184875
+ let isVerified = false;
184876
+ let customerName = "";
184877
+ let customerEmail = "";
184878
+ let isTestPurchase = false;
184879
+ const polarSig = req.headers["webhook-signature"] || req.headers["stripe-signature"];
184880
+ const paddleSig = req.headers["paddle-signature"];
184881
+ if (polarSig && polarSecret) {
184882
+ isVerified = verifyPolarSignature(rawBody, polarSig, polarSecret);
184883
+ } else if (paddleSig && paddleSecret) {
184884
+ isVerified = verifyPaddleSignature(rawBody, paddleSig, paddleSecret);
184885
+ } else if (isDev) {
184886
+ isVerified = true;
184887
+ }
184888
+ if (!isVerified) {
184889
+ res.status(401).json({ error: "Invalid webhook signature" });
184890
+ return;
184891
+ }
184892
+ let payload;
184893
+ try {
184894
+ payload = rawBody ? JSON.parse(rawBody) : null;
184895
+ } catch {
184896
+ res.status(400).json({ error: "Invalid JSON body" });
184897
+ return;
184898
+ }
184899
+ if (!payload || !payload.event) {
184900
+ res.status(400).json({ error: "Invalid payload: missing event type" });
184901
+ return;
184902
+ }
184903
+ if (payload.event === "order.created" || payload.event === "subscription.created") {
184904
+ const order2 = payload.data;
184905
+ customerName = order2?.customer?.name || order2?.user?.name || "Valued Customer";
184906
+ customerEmail = order2?.customer?.email || order2?.user?.email;
184907
+ isTestPurchase = order2?.is_test || false;
184908
+ } else if (payload.event === "transaction.completed") {
184909
+ const transaction = payload.data;
184910
+ customerName = transaction?.customer?.name || "Valued Customer";
184911
+ customerEmail = transaction?.customer?.email;
184912
+ isTestPurchase = transaction?.billing_details?.is_test || false;
184913
+ } else if (isDev) {
184914
+ customerName = payload.name || "Test User";
184915
+ customerEmail = payload.email;
184916
+ isTestPurchase = true;
184917
+ } else {
184918
+ res.status(200).json({ status: "ignored", event: payload.event });
184919
+ return;
184920
+ }
184921
+ if (!customerEmail) {
184922
+ res.status(400).json({ error: "Customer email missing from webhook payload" });
184923
+ return;
184924
+ }
184925
+ const privateKey = getPrivateKey();
184926
+ if (!privateKey) {
184927
+ console.error("Webhook Error: Private key not configured for signing licenses.");
184928
+ res.status(500).json({ error: "Licensing server configuration error: missing private key" });
184929
+ return;
184930
+ }
184931
+ const type3 = isGrandfathered(customerEmail) ? "grandfathered" : "personal";
184932
+ const id2 = crypto8.randomUUID();
184933
+ const createdAt = (/* @__PURE__ */ new Date()).toISOString();
184934
+ const expires = /* @__PURE__ */ new Date();
184935
+ expires.setFullYear(expires.getFullYear() + 1);
184936
+ const expiresAt = type3 === "grandfathered" ? null : expires.toISOString();
184937
+ const metadata = {
184938
+ id: id2,
184939
+ name: customerName,
184940
+ email: customerEmail,
184941
+ type: type3,
184942
+ createdAt,
184943
+ expiresAt,
184944
+ version: "1.0"
184945
+ };
184946
+ const dataStr = canonicalize(metadata);
184947
+ const signature = crypto8.sign(null, Buffer.from(dataStr), privateKey);
184948
+ const signedLicense = {
184949
+ metadata,
184950
+ signature: signature.toString("hex")
184951
+ };
184952
+ const base64License = Buffer.from(JSON.stringify(signedLicense)).toString("base64");
184953
+ console.error(`[license] generated for ${customerEmail} (ID: ${id2})`);
184954
+ if (process.env.RESEND_API_KEY) {
184955
+ console.error(`[license] dispatching to ${customerEmail}`);
184956
+ }
184957
+ res.status(200).json({
184958
+ status: "success",
184959
+ license: base64License,
184960
+ test: isTestPurchase
184961
+ });
184962
+ } catch (err) {
184963
+ console.error("Webhook processing error:", err);
184964
+ res.status(500).json({ error: `Webhook internal error: ${err.message}` });
184965
+ }
184966
+ }
184967
+
184724
184968
  // src/server/models/api-routes.ts
184725
184969
  init_contract();
184726
184970
  init_api_routes2();
@@ -185308,7 +185552,7 @@ function registerNavigationTools(server) {
185308
185552
 
185309
185553
  // src/server/mcp/server.ts
185310
185554
  var esmRequire2 = createRequire2(import.meta.url);
185311
- var APP_VERSION = true ? "0.14.0" : _readVersionFromDisk();
185555
+ var APP_VERSION = true ? "0.14.2" : _readVersionFromDisk();
185312
185556
  var MCP_SDK_VERSION = true ? "1.27.1" : "0.0.0-unknown";
185313
185557
  var __dirname3 = dirname3(fileURLToPath4(import.meta.url));
185314
185558
  var CLIENT_DIST = join7(__dirname3, "../client");
@@ -185436,6 +185680,11 @@ async function startMcpServerHttp(port, host = DEFAULT_BIND_HOST, token, resolve
185436
185680
  await currentTransport.handleRequest(req, res, req.body);
185437
185681
  currentTransport = null;
185438
185682
  });
185683
+ app.post(
185684
+ "/webhooks/license",
185685
+ express2.raw({ type: "application/json" }),
185686
+ handleLicenseWebhook
185687
+ );
185439
185688
  app.use("/mcp", authMiddleware);
185440
185689
  app.use("/api", authMiddleware);
185441
185690
  app.get(
@@ -185639,12 +185888,12 @@ async function maybeOpenStartupFile(envPath) {
185639
185888
  }
185640
185889
 
185641
185890
  // src/server/version-check.ts
185642
- import fs18 from "fs/promises";
185643
- import path28 from "path";
185891
+ import fs19 from "fs/promises";
185892
+ import path29 from "path";
185644
185893
  async function checkVersionChange(currentVersion, versionFilePath) {
185645
185894
  let storedVersion = null;
185646
185895
  try {
185647
- storedVersion = (await fs18.readFile(versionFilePath, "utf-8")).trim();
185896
+ storedVersion = (await fs19.readFile(versionFilePath, "utf-8")).trim();
185648
185897
  } catch (err) {
185649
185898
  if (err.code !== "ENOENT") {
185650
185899
  console.error("[Tandem] Failed to read last-seen-version:", err);
@@ -185652,8 +185901,8 @@ async function checkVersionChange(currentVersion, versionFilePath) {
185652
185901
  }
185653
185902
  const result2 = storedVersion === null ? "first-install" : storedVersion === currentVersion ? "current" : "upgraded";
185654
185903
  if (result2 !== "current") {
185655
- await fs18.mkdir(path28.dirname(versionFilePath), { recursive: true });
185656
- await fs18.writeFile(versionFilePath, currentVersion, "utf-8");
185904
+ await fs19.mkdir(path29.dirname(versionFilePath), { recursive: true });
185905
+ await fs19.writeFile(versionFilePath, currentVersion, "utf-8");
185657
185906
  }
185658
185907
  return result2;
185659
185908
  }
@@ -185945,11 +186194,11 @@ async function main2() {
185945
186194
  } catch (err) {
185946
186195
  console.error(`[Tandem] ${err instanceof Error ? err.message : err} \u2014 proceeding anyway`);
185947
186196
  }
185948
- const projectRoot = path29.resolve(path29.dirname(fileURLToPath5(import.meta.url)), "../..");
186197
+ const projectRoot = path30.resolve(path30.dirname(fileURLToPath5(import.meta.url)), "../..");
185949
186198
  try {
185950
186199
  const versionStatus = await checkVersionChange(APP_VERSION, LAST_SEEN_VERSION_FILE);
185951
186200
  if (versionStatus === "upgraded") {
185952
- await openFileByPath(path29.join(projectRoot, "CHANGELOG.md"), { readOnly: true });
186201
+ await openFileByPath(path30.join(projectRoot, "CHANGELOG.md"), { readOnly: true });
185953
186202
  console.error(`[Tandem] Opened CHANGELOG.md (upgraded to v${APP_VERSION})`);
185954
186203
  }
185955
186204
  } catch (err) {
@@ -185962,7 +186211,7 @@ async function main2() {
185962
186211
  console.error("[Tandem] Falling back to welcome.md after TANDEM_OPEN_FILE failure");
185963
186212
  }
185964
186213
  const sampleBase = process.env.TANDEM_DATA_DIR || projectRoot;
185965
- const samplePath = path29.join(sampleBase, "sample/welcome.md");
186214
+ const samplePath = path30.join(sampleBase, "sample/welcome.md");
185966
186215
  try {
185967
186216
  await openFileByPath(samplePath);
185968
186217
  } catch (err) {