repoburg 1.3.277 → 1.3.279

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.
@@ -6124,8 +6124,8 @@ var require_req = __commonJS({
6124
6124
  if (req.originalUrl) {
6125
6125
  _req.url = req.originalUrl;
6126
6126
  } else {
6127
- const path10 = req.path;
6128
- _req.url = typeof path10 === "string" ? path10 : req.url ? req.url.path || req.url : void 0;
6127
+ const path11 = req.path;
6128
+ _req.url = typeof path11 === "string" ? path11 : req.url ? req.url.path || req.url : void 0;
6129
6129
  }
6130
6130
  if (req.query) {
6131
6131
  _req.query = req.query;
@@ -6290,14 +6290,14 @@ var require_redact = __commonJS({
6290
6290
  }
6291
6291
  return obj;
6292
6292
  }
6293
- function parsePath(path10) {
6293
+ function parsePath(path11) {
6294
6294
  const parts = [];
6295
6295
  let current = "";
6296
6296
  let inBrackets = false;
6297
6297
  let inQuotes = false;
6298
6298
  let quoteChar = "";
6299
- for (let i = 0; i < path10.length; i++) {
6300
- const char = path10[i];
6299
+ for (let i = 0; i < path11.length; i++) {
6300
+ const char = path11[i];
6301
6301
  if (!inBrackets && char === ".") {
6302
6302
  if (current) {
6303
6303
  parts.push(current);
@@ -6428,10 +6428,10 @@ var require_redact = __commonJS({
6428
6428
  return current;
6429
6429
  }
6430
6430
  function redactPaths(obj, paths, censor, remove = false) {
6431
- for (const path10 of paths) {
6432
- const parts = parsePath(path10);
6431
+ for (const path11 of paths) {
6432
+ const parts = parsePath(path11);
6433
6433
  if (parts.includes("*")) {
6434
- redactWildcardPath(obj, parts, censor, path10, remove);
6434
+ redactWildcardPath(obj, parts, censor, path11, remove);
6435
6435
  } else {
6436
6436
  if (remove) {
6437
6437
  removeKey(obj, parts);
@@ -6516,8 +6516,8 @@ var require_redact = __commonJS({
6516
6516
  }
6517
6517
  } else {
6518
6518
  if (afterWildcard.includes("*")) {
6519
- const wrappedCensor = typeof censor === "function" ? (value, path10) => {
6520
- const fullPath = [...pathArray.slice(0, pathLength), ...path10];
6519
+ const wrappedCensor = typeof censor === "function" ? (value, path11) => {
6520
+ const fullPath = [...pathArray.slice(0, pathLength), ...path11];
6521
6521
  return censor(value, fullPath);
6522
6522
  } : censor;
6523
6523
  redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
@@ -6552,8 +6552,8 @@ var require_redact = __commonJS({
6552
6552
  return null;
6553
6553
  }
6554
6554
  const pathStructure = /* @__PURE__ */ new Map();
6555
- for (const path10 of pathsToClone) {
6556
- const parts = parsePath(path10);
6555
+ for (const path11 of pathsToClone) {
6556
+ const parts = parsePath(path11);
6557
6557
  let current = pathStructure;
6558
6558
  for (let i = 0; i < parts.length; i++) {
6559
6559
  const part = parts[i];
@@ -6605,24 +6605,24 @@ var require_redact = __commonJS({
6605
6605
  }
6606
6606
  return cloneSelectively(obj, pathStructure);
6607
6607
  }
6608
- function validatePath(path10) {
6609
- if (typeof path10 !== "string") {
6608
+ function validatePath(path11) {
6609
+ if (typeof path11 !== "string") {
6610
6610
  throw new Error("Paths must be (non-empty) strings");
6611
6611
  }
6612
- if (path10 === "") {
6612
+ if (path11 === "") {
6613
6613
  throw new Error("Invalid redaction path ()");
6614
6614
  }
6615
- if (path10.includes("..")) {
6616
- throw new Error(`Invalid redaction path (${path10})`);
6615
+ if (path11.includes("..")) {
6616
+ throw new Error(`Invalid redaction path (${path11})`);
6617
6617
  }
6618
- if (path10.includes(",")) {
6619
- throw new Error(`Invalid redaction path (${path10})`);
6618
+ if (path11.includes(",")) {
6619
+ throw new Error(`Invalid redaction path (${path11})`);
6620
6620
  }
6621
6621
  let bracketCount = 0;
6622
6622
  let inQuotes = false;
6623
6623
  let quoteChar = "";
6624
- for (let i = 0; i < path10.length; i++) {
6625
- const char = path10[i];
6624
+ for (let i = 0; i < path11.length; i++) {
6625
+ const char = path11[i];
6626
6626
  if ((char === '"' || char === "'") && bracketCount > 0) {
6627
6627
  if (!inQuotes) {
6628
6628
  inQuotes = true;
@@ -6636,20 +6636,20 @@ var require_redact = __commonJS({
6636
6636
  } else if (char === "]" && !inQuotes) {
6637
6637
  bracketCount--;
6638
6638
  if (bracketCount < 0) {
6639
- throw new Error(`Invalid redaction path (${path10})`);
6639
+ throw new Error(`Invalid redaction path (${path11})`);
6640
6640
  }
6641
6641
  }
6642
6642
  }
6643
6643
  if (bracketCount !== 0) {
6644
- throw new Error(`Invalid redaction path (${path10})`);
6644
+ throw new Error(`Invalid redaction path (${path11})`);
6645
6645
  }
6646
6646
  }
6647
6647
  function validatePaths(paths) {
6648
6648
  if (!Array.isArray(paths)) {
6649
6649
  throw new TypeError("paths must be an array");
6650
6650
  }
6651
- for (const path10 of paths) {
6652
- validatePath(path10);
6651
+ for (const path11 of paths) {
6652
+ validatePath(path11);
6653
6653
  }
6654
6654
  }
6655
6655
  function slowRedact(options = {}) {
@@ -6817,8 +6817,8 @@ var require_redaction = __commonJS({
6817
6817
  if (shape[k] === null) {
6818
6818
  o[k] = (value) => topCensor(value, [k]);
6819
6819
  } else {
6820
- const wrappedCensor = typeof censor === "function" ? (value, path10) => {
6821
- return censor(value, [k, ...path10]);
6820
+ const wrappedCensor = typeof censor === "function" ? (value, path11) => {
6821
+ return censor(value, [k, ...path11]);
6822
6822
  } : censor;
6823
6823
  o[k] = Redact({
6824
6824
  paths: shape[k],
@@ -7039,7 +7039,7 @@ var require_sonic_boom = __commonJS({
7039
7039
  var fs7 = __require("fs");
7040
7040
  var EventEmitter2 = __require("events");
7041
7041
  var inherits = __require("util").inherits;
7042
- var path10 = __require("path");
7042
+ var path11 = __require("path");
7043
7043
  var sleep = require_atomic_sleep();
7044
7044
  var assert = __require("assert");
7045
7045
  var BUSY_WRITE_TIMEOUT = 100;
@@ -7093,7 +7093,7 @@ var require_sonic_boom = __commonJS({
7093
7093
  const mode = sonic.mode;
7094
7094
  if (sonic.sync) {
7095
7095
  try {
7096
- if (sonic.mkdir) fs7.mkdirSync(path10.dirname(file), { recursive: true });
7096
+ if (sonic.mkdir) fs7.mkdirSync(path11.dirname(file), { recursive: true });
7097
7097
  const fd = fs7.openSync(file, flags, mode);
7098
7098
  fileOpened(null, fd);
7099
7099
  } catch (err) {
@@ -7101,7 +7101,7 @@ var require_sonic_boom = __commonJS({
7101
7101
  throw err;
7102
7102
  }
7103
7103
  } else if (sonic.mkdir) {
7104
- fs7.mkdir(path10.dirname(file), { recursive: true }, (err) => {
7104
+ fs7.mkdir(path11.dirname(file), { recursive: true }, (err) => {
7105
7105
  if (err) return fileOpened(err);
7106
7106
  fs7.open(file, flags, mode, fileOpened);
7107
7107
  });
@@ -8433,15 +8433,15 @@ var require_transport = __commonJS({
8433
8433
  if (!unquoted) {
8434
8434
  return false;
8435
8435
  }
8436
- let path10 = unquoted;
8437
- if (path10.startsWith("file://")) {
8436
+ let path11 = unquoted;
8437
+ if (path11.startsWith("file://")) {
8438
8438
  try {
8439
- path10 = fileURLToPath3(path10);
8439
+ path11 = fileURLToPath3(path11);
8440
8440
  } catch {
8441
8441
  return false;
8442
8442
  }
8443
8443
  }
8444
- return isAbsolute(path10) && !existsSync3(path10);
8444
+ return isAbsolute(path11) && !existsSync3(path11);
8445
8445
  }
8446
8446
  function stripQuotes(value) {
8447
8447
  const first = value[0];
@@ -10182,7 +10182,7 @@ var require_pino = __commonJS({
10182
10182
  } = symbols;
10183
10183
  var { epochTime, nullTime } = time;
10184
10184
  var { pid } = process;
10185
- var hostname = os4.hostname();
10185
+ var hostname2 = os4.hostname();
10186
10186
  var defaultErrorSerializer = stdSerializers.err;
10187
10187
  var defaultOptions = {
10188
10188
  level: "info",
@@ -10192,7 +10192,7 @@ var require_pino = __commonJS({
10192
10192
  errorKey: "err",
10193
10193
  nestedKey: null,
10194
10194
  enabled: true,
10195
- base: { pid, hostname },
10195
+ base: { pid, hostname: hostname2 },
10196
10196
  serializers: Object.assign(/* @__PURE__ */ Object.create(null), {
10197
10197
  err: defaultErrorSerializer
10198
10198
  }),
@@ -17117,8 +17117,8 @@ var require_utils = __commonJS({
17117
17117
  }
17118
17118
  return ind;
17119
17119
  }
17120
- function removeDotSegments(path10) {
17121
- let input = path10;
17120
+ function removeDotSegments(path11) {
17121
+ let input = path11;
17122
17122
  const output = [];
17123
17123
  let nextSlash = -1;
17124
17124
  let len = 0;
@@ -17370,8 +17370,8 @@ var require_schemes = __commonJS({
17370
17370
  wsComponent.secure = void 0;
17371
17371
  }
17372
17372
  if (wsComponent.resourceName) {
17373
- const [path10, query2] = wsComponent.resourceName.split("?");
17374
- wsComponent.path = path10 && path10 !== "/" ? path10 : void 0;
17373
+ const [path11, query2] = wsComponent.resourceName.split("?");
17374
+ wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
17375
17375
  wsComponent.query = query2;
17376
17376
  wsComponent.resourceName = void 0;
17377
17377
  }
@@ -20193,9 +20193,9 @@ var require_discriminator = __commonJS({
20193
20193
  function validateMapping() {
20194
20194
  const mapping = getMapping();
20195
20195
  gen.if(false);
20196
- for (const tagValue in mapping) {
20197
- gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
20198
- gen.assign(valid, applyTagSchema(mapping[tagValue]));
20196
+ for (const tagValue2 in mapping) {
20197
+ gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
20198
+ gen.assign(valid, applyTagSchema(mapping[tagValue2]));
20199
20199
  }
20200
20200
  gen.else();
20201
20201
  cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName });
@@ -20239,18 +20239,18 @@ var require_discriminator = __commonJS({
20239
20239
  if (sch.const) {
20240
20240
  addMapping(sch.const, i);
20241
20241
  } else if (sch.enum) {
20242
- for (const tagValue of sch.enum) {
20243
- addMapping(tagValue, i);
20242
+ for (const tagValue2 of sch.enum) {
20243
+ addMapping(tagValue2, i);
20244
20244
  }
20245
20245
  } else {
20246
20246
  throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`);
20247
20247
  }
20248
20248
  }
20249
- function addMapping(tagValue, i) {
20250
- if (typeof tagValue != "string" || tagValue in oneOfMapping) {
20249
+ function addMapping(tagValue2, i) {
20250
+ if (typeof tagValue2 != "string" || tagValue2 in oneOfMapping) {
20251
20251
  throw new Error(`discriminator: "${tagName}" values must be unique strings`);
20252
20252
  }
20253
- oneOfMapping[tagValue] = i;
20253
+ oneOfMapping[tagValue2] = i;
20254
20254
  }
20255
20255
  }
20256
20256
  }
@@ -21028,9 +21028,9 @@ var require_discriminator2 = __commonJS({
21028
21028
  }
21029
21029
  function validateMapping(tag) {
21030
21030
  gen.if(false);
21031
- for (const tagValue in parentSchema.mapping) {
21032
- gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
21033
- gen.assign(valid, applyTagSchema(tagValue));
21031
+ for (const tagValue2 in parentSchema.mapping) {
21032
+ gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
21033
+ gen.assign(valid, applyTagSchema(tagValue2));
21034
21034
  }
21035
21035
  gen.else();
21036
21036
  cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag }, { instancePath: schema, schemaPath: "mapping", parentSchema: true });
@@ -21445,9 +21445,9 @@ var require_serialize = __commonJS({
21445
21445
  const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(discriminator)}`);
21446
21446
  serializeString({ ...cxt, data: tag });
21447
21447
  gen.if(false);
21448
- for (const tagValue in schema.mapping) {
21449
- gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
21450
- const sch = schema.mapping[tagValue];
21448
+ for (const tagValue2 in schema.mapping) {
21449
+ gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
21450
+ const sch = schema.mapping[tagValue2];
21451
21451
  serializeSchemaProperties({ ...cxt, schema: sch }, discriminator);
21452
21452
  }
21453
21453
  gen.endIf();
@@ -21913,9 +21913,9 @@ var require_parse = __commonJS({
21913
21913
  gen.assign(names_1.default.jsonPos, startPos);
21914
21914
  gen.if((0, codegen_1._)`${tag} === undefined`);
21915
21915
  parsingError(cxt, (0, codegen_1.str)`discriminator tag not found`);
21916
- for (const tagValue in mapping) {
21917
- gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
21918
- parseSchemaProperties({ ...cxt, schema: mapping[tagValue] }, discriminator);
21916
+ for (const tagValue2 in mapping) {
21917
+ gen.elseIf((0, codegen_1._)`${tag} === ${tagValue2}`);
21918
+ parseSchemaProperties({ ...cxt, schema: mapping[tagValue2] }, discriminator);
21919
21919
  }
21920
21920
  gen.else();
21921
21921
  parsingError(cxt, (0, codegen_1.str)`discriminator value not in schema`);
@@ -22308,8 +22308,8 @@ var require_utils2 = __commonJS({
22308
22308
  }
22309
22309
  return ind;
22310
22310
  }
22311
- function removeDotSegments(path10) {
22312
- let input = path10;
22311
+ function removeDotSegments(path11) {
22312
+ let input = path11;
22313
22313
  const output = [];
22314
22314
  let nextSlash = -1;
22315
22315
  let len = 0;
@@ -22654,8 +22654,8 @@ var require_schemes2 = __commonJS({
22654
22654
  wsComponent.secure = void 0;
22655
22655
  }
22656
22656
  if (wsComponent.resourceName) {
22657
- const [path10, query2] = wsComponent.resourceName.split("?");
22658
- wsComponent.path = path10 && path10 !== "/" ? path10 : void 0;
22657
+ const [path11, query2] = wsComponent.resourceName.split("?");
22658
+ wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
22659
22659
  wsComponent.query = query2;
22660
22660
  wsComponent.resourceName = void 0;
22661
22661
  }
@@ -24139,8 +24139,8 @@ var require_utils3 = __commonJS({
24139
24139
  }
24140
24140
  return ind;
24141
24141
  }
24142
- function removeDotSegments(path10) {
24143
- let input = path10;
24142
+ function removeDotSegments(path11) {
24143
+ let input = path11;
24144
24144
  const output = [];
24145
24145
  let nextSlash = -1;
24146
24146
  let len = 0;
@@ -24485,8 +24485,8 @@ var require_schemes3 = __commonJS({
24485
24485
  wsComponent.secure = void 0;
24486
24486
  }
24487
24487
  if (wsComponent.resourceName) {
24488
- const [path10, query2] = wsComponent.resourceName.split("?");
24489
- wsComponent.path = path10 && path10 !== "/" ? path10 : void 0;
24488
+ const [path11, query2] = wsComponent.resourceName.split("?");
24489
+ wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
24490
24490
  wsComponent.query = query2;
24491
24491
  wsComponent.resourceName = void 0;
24492
24492
  }
@@ -32003,13 +32003,13 @@ var require_node = __commonJS({
32003
32003
  this.staticChildrenNodes[index] = node;
32004
32004
  }
32005
32005
  }
32006
- findStaticMatchingChild(path10, pathIndex) {
32007
- const charCode = path10.charCodeAt(pathIndex);
32006
+ findStaticMatchingChild(path11, pathIndex) {
32007
+ const charCode = path11.charCodeAt(pathIndex);
32008
32008
  const charCodes = this.staticChildrenCharCodes;
32009
32009
  for (let i = 0; i < charCodes.length; i++) {
32010
32010
  if (charCodes[i] === charCode) {
32011
32011
  const staticChild = this.staticChildrenNodes[i];
32012
- if (staticChild.matchPrefix(path10, pathIndex)) {
32012
+ if (staticChild.matchPrefix(path11, pathIndex)) {
32013
32013
  return staticChild;
32014
32014
  }
32015
32015
  return null;
@@ -32017,34 +32017,34 @@ var require_node = __commonJS({
32017
32017
  }
32018
32018
  return null;
32019
32019
  }
32020
- getStaticChild(path10, pathIndex = 0) {
32021
- if (path10.length === pathIndex) {
32020
+ getStaticChild(path11, pathIndex = 0) {
32021
+ if (path11.length === pathIndex) {
32022
32022
  return this;
32023
32023
  }
32024
- const staticChild = this.findStaticMatchingChild(path10, pathIndex);
32024
+ const staticChild = this.findStaticMatchingChild(path11, pathIndex);
32025
32025
  if (staticChild) {
32026
- return staticChild.getStaticChild(path10, pathIndex + staticChild.prefix.length);
32026
+ return staticChild.getStaticChild(path11, pathIndex + staticChild.prefix.length);
32027
32027
  }
32028
32028
  return null;
32029
32029
  }
32030
- createStaticChild(path10) {
32031
- if (path10.length === 0) {
32030
+ createStaticChild(path11) {
32031
+ if (path11.length === 0) {
32032
32032
  return this;
32033
32033
  }
32034
- const childIndex = this.staticChildrenCharCodes.indexOf(path10.charCodeAt(0));
32034
+ const childIndex = this.staticChildrenCharCodes.indexOf(path11.charCodeAt(0));
32035
32035
  let staticChild = childIndex === -1 ? void 0 : this.staticChildrenNodes[childIndex];
32036
32036
  if (staticChild) {
32037
32037
  let i = 1;
32038
32038
  for (; i < staticChild.prefix.length; i++) {
32039
- if (path10.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
32039
+ if (path11.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
32040
32040
  staticChild = staticChild.split(this, i);
32041
32041
  break;
32042
32042
  }
32043
32043
  }
32044
- return staticChild.createStaticChild(path10.slice(i));
32044
+ return staticChild.createStaticChild(path11.slice(i));
32045
32045
  }
32046
- const node = new StaticNode(path10);
32047
- this.setStaticChild(path10.charAt(0), node);
32046
+ const node = new StaticNode(path11);
32047
+ this.setStaticChild(path11.charAt(0), node);
32048
32048
  return node;
32049
32049
  }
32050
32050
  };
@@ -32068,13 +32068,13 @@ var require_node = __commonJS({
32068
32068
  }
32069
32069
  return null;
32070
32070
  }
32071
- createParametricChild(regex, staticSuffix, nodePath) {
32071
+ createParametricChild(regex, staticSuffix, nodePath2) {
32072
32072
  let parametricChild = this.getParametricChild(regex);
32073
32073
  if (parametricChild) {
32074
- parametricChild.nodePaths.add(nodePath);
32074
+ parametricChild.nodePaths.add(nodePath2);
32075
32075
  return parametricChild;
32076
32076
  }
32077
- parametricChild = new ParametricNode(regex, staticSuffix, nodePath);
32077
+ parametricChild = new ParametricNode(regex, staticSuffix, nodePath2);
32078
32078
  this.parametricChildren.push(parametricChild);
32079
32079
  this.parametricChildren.sort((child1, child2) => {
32080
32080
  if (!child1.isRegex) return 1;
@@ -32104,8 +32104,8 @@ var require_node = __commonJS({
32104
32104
  parentNode.setStaticChild(parentPrefix.charAt(0), staticNode);
32105
32105
  return staticNode;
32106
32106
  }
32107
- getNextNode(path10, pathIndex, nodeStack, paramsCount) {
32108
- let node = this.findStaticMatchingChild(path10, pathIndex);
32107
+ getNextNode(path11, pathIndex, nodeStack, paramsCount) {
32108
+ let node = this.findStaticMatchingChild(path11, pathIndex);
32109
32109
  let parametricBrotherNodeIndex = 0;
32110
32110
  if (node === null) {
32111
32111
  if (this.parametricChildren.length === 0) {
@@ -32144,16 +32144,16 @@ var require_node = __commonJS({
32144
32144
  }
32145
32145
  };
32146
32146
  var ParametricNode = class extends ParentNode {
32147
- constructor(regex, staticSuffix, nodePath) {
32147
+ constructor(regex, staticSuffix, nodePath2) {
32148
32148
  super();
32149
32149
  this.isRegex = !!regex;
32150
32150
  this.regex = regex || null;
32151
32151
  this.staticSuffix = staticSuffix || null;
32152
32152
  this.kind = NODE_TYPES.PARAMETRIC;
32153
- this.nodePaths = /* @__PURE__ */ new Set([nodePath]);
32153
+ this.nodePaths = /* @__PURE__ */ new Set([nodePath2]);
32154
32154
  }
32155
- getNextNode(path10, pathIndex) {
32156
- return this.findStaticMatchingChild(path10, pathIndex);
32155
+ getNextNode(path11, pathIndex) {
32156
+ return this.findStaticMatchingChild(path11, pathIndex);
32157
32157
  }
32158
32158
  };
32159
32159
  var WildcardNode = class extends Node {
@@ -32509,81 +32509,81 @@ var require_url_sanitizer = __commonJS({
32509
32509
  return String.fromCharCode(charCode);
32510
32510
  }
32511
32511
  var MIN_NATIVE_SCAN_LENGTH = 12;
32512
- function safeDecodeURI(path10, useSemicolonDelimiter) {
32513
- if (path10.length >= MIN_NATIVE_SCAN_LENGTH) {
32514
- return safeDecodeURINativeScan(path10, useSemicolonDelimiter);
32512
+ function safeDecodeURI(path11, useSemicolonDelimiter) {
32513
+ if (path11.length >= MIN_NATIVE_SCAN_LENGTH) {
32514
+ return safeDecodeURINativeScan(path11, useSemicolonDelimiter);
32515
32515
  }
32516
- return safeDecodeURICharScan(path10, useSemicolonDelimiter, 1);
32516
+ return safeDecodeURICharScan(path11, useSemicolonDelimiter, 1);
32517
32517
  }
32518
- function safeDecodeURINativeScan(path10, useSemicolonDelimiter) {
32519
- const percentIndex = path10.indexOf("%", 1);
32520
- let delimIndex = path10.indexOf("?", 1);
32521
- const hashIndex = path10.indexOf("#", 1);
32518
+ function safeDecodeURINativeScan(path11, useSemicolonDelimiter) {
32519
+ const percentIndex = path11.indexOf("%", 1);
32520
+ let delimIndex = path11.indexOf("?", 1);
32521
+ const hashIndex = path11.indexOf("#", 1);
32522
32522
  if (hashIndex !== -1 && (delimIndex === -1 || hashIndex < delimIndex)) {
32523
32523
  delimIndex = hashIndex;
32524
32524
  }
32525
32525
  if (useSemicolonDelimiter) {
32526
- const semicolonIndex = path10.indexOf(";", 1);
32526
+ const semicolonIndex = path11.indexOf(";", 1);
32527
32527
  if (semicolonIndex !== -1 && (delimIndex === -1 || semicolonIndex < delimIndex)) {
32528
32528
  delimIndex = semicolonIndex;
32529
32529
  }
32530
32530
  }
32531
32531
  if (percentIndex === -1 || delimIndex !== -1 && percentIndex > delimIndex) {
32532
32532
  if (delimIndex === -1) {
32533
- return { path: path10, querystring: "", shouldDecodeParam: false };
32533
+ return { path: path11, querystring: "", shouldDecodeParam: false };
32534
32534
  }
32535
32535
  return {
32536
- path: path10.slice(0, delimIndex),
32537
- querystring: path10.slice(delimIndex + 1),
32536
+ path: path11.slice(0, delimIndex),
32537
+ querystring: path11.slice(delimIndex + 1),
32538
32538
  shouldDecodeParam: false
32539
32539
  };
32540
32540
  }
32541
- return safeDecodeURIPercentScan(path10, useSemicolonDelimiter, percentIndex);
32541
+ return safeDecodeURIPercentScan(path11, useSemicolonDelimiter, percentIndex);
32542
32542
  }
32543
- function safeDecodeURICharScan(path10, useSemicolonDelimiter, startIndex) {
32544
- for (let i = startIndex; i < path10.length; i++) {
32545
- const charCode = path10.charCodeAt(i);
32543
+ function safeDecodeURICharScan(path11, useSemicolonDelimiter, startIndex) {
32544
+ for (let i = startIndex; i < path11.length; i++) {
32545
+ const charCode = path11.charCodeAt(i);
32546
32546
  if (charCode === 37) {
32547
- return safeDecodeURIPercentScan(path10, useSemicolonDelimiter, i);
32547
+ return safeDecodeURIPercentScan(path11, useSemicolonDelimiter, i);
32548
32548
  } else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
32549
32549
  return {
32550
- path: path10.slice(0, i),
32551
- querystring: path10.slice(i + 1),
32550
+ path: path11.slice(0, i),
32551
+ querystring: path11.slice(i + 1),
32552
32552
  shouldDecodeParam: false
32553
32553
  };
32554
32554
  }
32555
32555
  }
32556
- return { path: path10, querystring: "", shouldDecodeParam: false };
32556
+ return { path: path11, querystring: "", shouldDecodeParam: false };
32557
32557
  }
32558
- function reencodePercentChar(path10, index) {
32559
- return path10.slice(0, index + 1) + "25" + path10.slice(index + 1);
32558
+ function reencodePercentChar(path11, index) {
32559
+ return path11.slice(0, index + 1) + "25" + path11.slice(index + 1);
32560
32560
  }
32561
- function safeDecodeURIPercentScan(path10, useSemicolonDelimiter, startIndex) {
32561
+ function safeDecodeURIPercentScan(path11, useSemicolonDelimiter, startIndex) {
32562
32562
  let shouldDecode = false;
32563
32563
  let shouldDecodeParam = false;
32564
32564
  let querystring = "";
32565
- for (let i = startIndex; i < path10.length; i++) {
32566
- const charCode = path10.charCodeAt(i);
32565
+ for (let i = startIndex; i < path11.length; i++) {
32566
+ const charCode = path11.charCodeAt(i);
32567
32567
  if (charCode === 37) {
32568
- const componentCharCode = decodeComponentCharCode(path10.charCodeAt(i + 1), path10.charCodeAt(i + 2));
32568
+ const componentCharCode = decodeComponentCharCode(path11.charCodeAt(i + 1), path11.charCodeAt(i + 2));
32569
32569
  if (componentCharCode === 0) {
32570
32570
  shouldDecode = true;
32571
32571
  } else {
32572
32572
  shouldDecodeParam = true;
32573
32573
  if (componentCharCode === 37) {
32574
32574
  shouldDecode = true;
32575
- path10 = reencodePercentChar(path10, i);
32575
+ path11 = reencodePercentChar(path11, i);
32576
32576
  i += 2;
32577
32577
  }
32578
32578
  i += 2;
32579
32579
  }
32580
32580
  } else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
32581
- querystring = path10.slice(i + 1);
32582
- path10 = path10.slice(0, i);
32581
+ querystring = path11.slice(i + 1);
32582
+ path11 = path11.slice(0, i);
32583
32583
  break;
32584
32584
  }
32585
32585
  }
32586
- const decodedPath = shouldDecode ? decodeURI(path10) : path10;
32586
+ const decodedPath = shouldDecode ? decodeURI(path11) : path11;
32587
32587
  return { path: decodedPath, querystring, shouldDecodeParam };
32588
32588
  }
32589
32589
  function safeDecodeURIComponent(uriComponent) {
@@ -32678,7 +32678,7 @@ var require_find_my_way = __commonJS({
32678
32678
  this.trees = /* @__PURE__ */ Object.create(null);
32679
32679
  this._treeGET = null;
32680
32680
  }
32681
- Router.prototype.on = function on(method, path10, opts, handler, store) {
32681
+ Router.prototype.on = function on(method, path11, opts, handler, store) {
32682
32682
  if (typeof opts === "function") {
32683
32683
  if (handler !== void 0) {
32684
32684
  store = handler;
@@ -32686,34 +32686,34 @@ var require_find_my_way = __commonJS({
32686
32686
  handler = opts;
32687
32687
  opts = {};
32688
32688
  }
32689
- assert(typeof path10 === "string", "Path should be a string");
32690
- assert(path10.length > 0, "The path could not be empty");
32691
- assert(path10[0] === "/" || path10[0] === "*", "The first character of a path should be `/` or `*`");
32689
+ assert(typeof path11 === "string", "Path should be a string");
32690
+ assert(path11.length > 0, "The path could not be empty");
32691
+ assert(path11[0] === "/" || path11[0] === "*", "The first character of a path should be `/` or `*`");
32692
32692
  assert(typeof handler === "function", "Handler should be a function");
32693
- const optionalParamMatch = path10.match(OPTIONAL_PARAM_REGEXP);
32693
+ const optionalParamMatch = path11.match(OPTIONAL_PARAM_REGEXP);
32694
32694
  if (optionalParamMatch) {
32695
- assert(path10.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32696
- const pathFull = path10.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32697
- const pathOptional = path10.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
32695
+ assert(path11.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32696
+ const pathFull = path11.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32697
+ const pathOptional = path11.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
32698
32698
  this.on(method, pathFull, opts, handler, store);
32699
32699
  this.on(method, pathOptional, opts, handler, store);
32700
32700
  return;
32701
32701
  }
32702
- const route = path10;
32702
+ const route = path11;
32703
32703
  if (this.ignoreDuplicateSlashes) {
32704
- path10 = removeDuplicateSlashes(path10);
32704
+ path11 = removeDuplicateSlashes(path11);
32705
32705
  }
32706
32706
  if (this.ignoreTrailingSlash) {
32707
- path10 = trimLastSlash(path10);
32707
+ path11 = trimLastSlash(path11);
32708
32708
  }
32709
32709
  const methods = Array.isArray(method) ? method : [method];
32710
32710
  for (const method2 of methods) {
32711
32711
  assert(typeof method2 === "string", "Method should be a string");
32712
32712
  assert(httpMethods.includes(method2), `Method '${method2}' is not an http method.`);
32713
- this._on(method2, path10, opts, handler, store, route);
32713
+ this._on(method2, path11, opts, handler, store, route);
32714
32714
  }
32715
32715
  };
32716
- Router.prototype._on = function _on(method, path10, opts, handler, store) {
32716
+ Router.prototype._on = function _on(method, path11, opts, handler, store) {
32717
32717
  let constraints = {};
32718
32718
  if (opts.constraints !== void 0) {
32719
32719
  assert(typeof opts.constraints === "object" && opts.constraints !== null, "Constraints should be an object");
@@ -32726,7 +32726,7 @@ var require_find_my_way = __commonJS({
32726
32726
  if (this.trees[method] === void 0) {
32727
32727
  this.trees[method] = new StaticNode("/");
32728
32728
  }
32729
- let pattern = path10;
32729
+ let pattern = path11;
32730
32730
  if (pattern === "*" && this.trees[method].prefix.length !== 0) {
32731
32731
  const currentRoot = this.trees[method];
32732
32732
  this.trees[method] = new StaticNode("");
@@ -32803,11 +32803,11 @@ var require_find_my_way = __commonJS({
32803
32803
  nodePatternParts += "()" + staticPart;
32804
32804
  if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) {
32805
32805
  const nodePattern = isRegexNode ? nodePatternParts : staticPart;
32806
- const nodePath = pattern.slice(i, j);
32806
+ const nodePath2 = pattern.slice(i, j);
32807
32807
  pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j);
32808
32808
  i += nodePattern.length;
32809
32809
  const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : null;
32810
- currentNode = currentNode.createParametricChild(regex, staticPart || null, nodePath);
32810
+ currentNode = currentNode.createParametricChild(regex, staticPart || null, nodePath2);
32811
32811
  parentNodePathIndex = i + 1;
32812
32812
  break;
32813
32813
  }
@@ -32834,19 +32834,19 @@ var require_find_my_way = __commonJS({
32834
32834
  throw new Error(`Method '${method}' already declared for route '${pattern}' with constraints '${JSON.stringify(constraints)}'`);
32835
32835
  }
32836
32836
  }
32837
- const route = { method, path: path10, pattern, params, opts, handler, store };
32837
+ const route = { method, path: path11, pattern, params, opts, handler, store };
32838
32838
  this.routes.push(route);
32839
32839
  currentNode.addRoute(route, this.constrainer);
32840
32840
  };
32841
- Router.prototype.hasRoute = function hasRoute(method, path10, constraints) {
32842
- const route = this.findRoute(method, path10, constraints);
32841
+ Router.prototype.hasRoute = function hasRoute(method, path11, constraints) {
32842
+ const route = this.findRoute(method, path11, constraints);
32843
32843
  return route !== null;
32844
32844
  };
32845
- Router.prototype.findRoute = function findNode(method, path10, constraints = {}) {
32845
+ Router.prototype.findRoute = function findNode(method, path11, constraints = {}) {
32846
32846
  if (this.trees[method] === void 0) {
32847
32847
  return null;
32848
32848
  }
32849
- let pattern = path10;
32849
+ let pattern = path11;
32850
32850
  let currentNode = this.trees[method];
32851
32851
  let parentNodePathIndex = currentNode.prefix.length;
32852
32852
  const params = [];
@@ -32918,11 +32918,11 @@ var require_find_my_way = __commonJS({
32918
32918
  nodePatternParts += "()" + staticPart;
32919
32919
  if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) {
32920
32920
  const nodePattern = isRegexNode ? nodePatternParts : staticPart;
32921
- const nodePath = pattern.slice(i, j);
32921
+ const nodePath2 = pattern.slice(i, j);
32922
32922
  pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j);
32923
32923
  i += nodePattern.length;
32924
32924
  const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : null;
32925
- currentNode = currentNode.getParametricChild(regex, staticPart || null, nodePath);
32925
+ currentNode = currentNode.getParametricChild(regex, staticPart || null, nodePath2);
32926
32926
  if (currentNode === null) {
32927
32927
  return null;
32928
32928
  }
@@ -32967,39 +32967,39 @@ var require_find_my_way = __commonJS({
32967
32967
  this._treeGET = null;
32968
32968
  this.routes = [];
32969
32969
  };
32970
- Router.prototype.off = function off(method, path10, constraints) {
32971
- assert(typeof path10 === "string", "Path should be a string");
32972
- assert(path10.length > 0, "The path could not be empty");
32973
- assert(path10[0] === "/" || path10[0] === "*", "The first character of a path should be `/` or `*`");
32970
+ Router.prototype.off = function off(method, path11, constraints) {
32971
+ assert(typeof path11 === "string", "Path should be a string");
32972
+ assert(path11.length > 0, "The path could not be empty");
32973
+ assert(path11[0] === "/" || path11[0] === "*", "The first character of a path should be `/` or `*`");
32974
32974
  assert(
32975
32975
  typeof constraints === "undefined" || typeof constraints === "object" && !Array.isArray(constraints) && constraints !== null,
32976
32976
  "Constraints should be an object or undefined."
32977
32977
  );
32978
- const optionalParamMatch = path10.match(OPTIONAL_PARAM_REGEXP);
32978
+ const optionalParamMatch = path11.match(OPTIONAL_PARAM_REGEXP);
32979
32979
  if (optionalParamMatch) {
32980
- assert(path10.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32981
- const pathFull = path10.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32982
- const pathOptional = path10.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
32980
+ assert(path11.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32981
+ const pathFull = path11.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32982
+ const pathOptional = path11.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
32983
32983
  this.off(method, pathFull, constraints);
32984
32984
  this.off(method, pathOptional, constraints);
32985
32985
  return;
32986
32986
  }
32987
32987
  if (this.ignoreDuplicateSlashes) {
32988
- path10 = removeDuplicateSlashes(path10);
32988
+ path11 = removeDuplicateSlashes(path11);
32989
32989
  }
32990
32990
  if (this.ignoreTrailingSlash) {
32991
- path10 = trimLastSlash(path10);
32991
+ path11 = trimLastSlash(path11);
32992
32992
  }
32993
32993
  const methods = Array.isArray(method) ? method : [method];
32994
32994
  for (const method2 of methods) {
32995
- this._off(method2, path10, constraints);
32995
+ this._off(method2, path11, constraints);
32996
32996
  }
32997
32997
  };
32998
- Router.prototype._off = function _off(method, path10, constraints) {
32998
+ Router.prototype._off = function _off(method, path11, constraints) {
32999
32999
  assert(typeof method === "string", "Method should be a string");
33000
33000
  assert(httpMethods.includes(method), `Method '${method}' is not an http method.`);
33001
33001
  function matcherWithoutConstraints(route) {
33002
- return method !== route.method || path10 !== route.path;
33002
+ return method !== route.method || path11 !== route.path;
33003
33003
  }
33004
33004
  function matcherWithConstraints(route) {
33005
33005
  return matcherWithoutConstraints(route) || !deepEqual(constraints, route.opts.constraints || {});
@@ -33036,37 +33036,37 @@ var require_find_my_way = __commonJS({
33036
33036
  if (handle === null) return this._defaultRoute(req, res, ctx);
33037
33037
  return ctx === void 0 ? handle.handler(req, res, handle.params, handle.store, handle.searchParams) : handle.handler.call(ctx, req, res, handle.params, handle.store, handle.searchParams);
33038
33038
  };
33039
- Router.prototype.find = function find(method, path10, derivedConstraints) {
33039
+ Router.prototype.find = function find(method, path11, derivedConstraints) {
33040
33040
  let currentNode = method === "GET" ? this._treeGET : this.trees[method];
33041
33041
  if (currentNode == null) return null;
33042
- if (path10.charCodeAt(0) !== 47) {
33043
- path10 = path10.replace(FULL_PATH_REGEXP, "/");
33042
+ if (path11.charCodeAt(0) !== 47) {
33043
+ path11 = path11.replace(FULL_PATH_REGEXP, "/");
33044
33044
  }
33045
33045
  if (this.ignoreDuplicateSlashes) {
33046
- path10 = removeDuplicateSlashes(path10);
33046
+ path11 = removeDuplicateSlashes(path11);
33047
33047
  }
33048
33048
  let sanitizedUrl;
33049
33049
  let querystring2;
33050
33050
  let shouldDecodeParam;
33051
33051
  try {
33052
- sanitizedUrl = path10.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path10, this.useSemicolonDelimiter) : safeDecodeURICharScan(path10, this.useSemicolonDelimiter, 1);
33053
- path10 = sanitizedUrl.path;
33052
+ sanitizedUrl = path11.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path11, this.useSemicolonDelimiter) : safeDecodeURICharScan(path11, this.useSemicolonDelimiter, 1);
33053
+ path11 = sanitizedUrl.path;
33054
33054
  querystring2 = sanitizedUrl.querystring;
33055
33055
  shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
33056
33056
  } catch (error) {
33057
- return this._onBadUrl(path10);
33057
+ return this._onBadUrl(path11);
33058
33058
  }
33059
33059
  if (this.ignoreTrailingSlash) {
33060
- path10 = trimLastSlash(path10);
33060
+ path11 = trimLastSlash(path11);
33061
33061
  }
33062
- const originPath = path10;
33062
+ const originPath = path11;
33063
33063
  if (this.caseSensitive === false) {
33064
- path10 = path10.toLowerCase();
33064
+ path11 = path11.toLowerCase();
33065
33065
  }
33066
33066
  const maxParamLength = this.maxParamLength;
33067
33067
  let pathIndex = currentNode.prefix.length;
33068
33068
  const params = [];
33069
- const pathLen = path10.length;
33069
+ const pathLen = path11.length;
33070
33070
  const brothersNodesStack = [];
33071
33071
  let maxParamLengthExceeded = false;
33072
33072
  while (true) {
@@ -33081,7 +33081,7 @@ var require_find_my_way = __commonJS({
33081
33081
  };
33082
33082
  }
33083
33083
  }
33084
- let node = currentNode.getNextNode(path10, pathIndex, brothersNodesStack, params.length);
33084
+ let node = currentNode.getNextNode(path11, pathIndex, brothersNodesStack, params.length);
33085
33085
  if (node === null) {
33086
33086
  if (brothersNodesStack.length === 0) {
33087
33087
  if (maxParamLengthExceeded && this.onMaxParamLength) {
@@ -33182,8 +33182,8 @@ var require_find_my_way = __commonJS({
33182
33182
  Router.prototype._rebuild = function(routes) {
33183
33183
  this.reset();
33184
33184
  for (const route of routes) {
33185
- const { method, path: path10, opts, handler, store } = route;
33186
- this._on(method, path10, opts, handler, store);
33185
+ const { method, path: path11, opts, handler, store } = route;
33186
+ this._on(method, path11, opts, handler, store);
33187
33187
  }
33188
33188
  };
33189
33189
  Router.prototype._defaultRoute = function(req, res, ctx) {
@@ -33194,24 +33194,24 @@ var require_find_my_way = __commonJS({
33194
33194
  res.end();
33195
33195
  }
33196
33196
  };
33197
- Router.prototype._onBadUrl = function(path10) {
33197
+ Router.prototype._onBadUrl = function(path11) {
33198
33198
  if (this.onBadUrl === null) {
33199
33199
  return null;
33200
33200
  }
33201
33201
  const onBadUrl = this.onBadUrl;
33202
33202
  return {
33203
- handler: (req, res, ctx) => onBadUrl(path10, req, res),
33203
+ handler: (req, res, ctx) => onBadUrl(path11, req, res),
33204
33204
  params: {},
33205
33205
  store: null
33206
33206
  };
33207
33207
  };
33208
- Router.prototype._onMaxParamLength = function(path10) {
33208
+ Router.prototype._onMaxParamLength = function(path11) {
33209
33209
  if (this.onMaxParamLength === null) {
33210
33210
  return null;
33211
33211
  }
33212
33212
  const onMaxParamLength = this.onMaxParamLength;
33213
33213
  return {
33214
- handler: (req, res, ctx) => onMaxParamLength(path10, req, res),
33214
+ handler: (req, res, ctx) => onMaxParamLength(path11, req, res),
33215
33215
  params: {},
33216
33216
  store: null
33217
33217
  };
@@ -33243,12 +33243,12 @@ var require_find_my_way = __commonJS({
33243
33243
  if (!httpMethods.hasOwnProperty(i)) continue;
33244
33244
  const m = httpMethods[i];
33245
33245
  const methodName = m.toLowerCase();
33246
- Router.prototype[methodName] = function(path10, handler, store) {
33247
- return this.on(m, path10, handler, store);
33246
+ Router.prototype[methodName] = function(path11, handler, store) {
33247
+ return this.on(m, path11, handler, store);
33248
33248
  };
33249
33249
  }
33250
- Router.prototype.all = function(path10, handler, store) {
33251
- this.on(httpMethods, path10, handler, store);
33250
+ Router.prototype.all = function(path11, handler, store) {
33251
+ this.on(httpMethods, path11, handler, store);
33252
33252
  };
33253
33253
  Router.sanitizeUrlPath = function sanitizeUrlPath(url, useSemicolonDelimiter) {
33254
33254
  const decoded = safeDecodeURI(url, useSemicolonDelimiter);
@@ -33263,14 +33263,14 @@ var require_find_my_way = __commonJS({
33263
33263
  function escapeRegExp(string) {
33264
33264
  return string.replace(ESCAPE_REGEXP, "\\$&");
33265
33265
  }
33266
- function removeDuplicateSlashes(path10) {
33267
- return path10.indexOf("//") !== -1 ? path10.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path10;
33266
+ function removeDuplicateSlashes(path11) {
33267
+ return path11.indexOf("//") !== -1 ? path11.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path11;
33268
33268
  }
33269
- function trimLastSlash(path10) {
33270
- if (path10.length > 1 && path10.charCodeAt(path10.length - 1) === 47) {
33271
- return path10.slice(0, -1);
33269
+ function trimLastSlash(path11) {
33270
+ if (path11.length > 1 && path11.charCodeAt(path11.length - 1) === 47) {
33271
+ return path11.slice(0, -1);
33272
33272
  }
33273
- return path10;
33273
+ return path11;
33274
33274
  }
33275
33275
  function trimRegExpStartAndEnd(regexString) {
33276
33276
  if (regexString.charCodeAt(1) === 94) {
@@ -33281,22 +33281,22 @@ var require_find_my_way = __commonJS({
33281
33281
  }
33282
33282
  return regexString;
33283
33283
  }
33284
- function getClosingParenthensePosition(path10, idx) {
33284
+ function getClosingParenthensePosition(path11, idx) {
33285
33285
  let parentheses = 1;
33286
- while (idx < path10.length) {
33286
+ while (idx < path11.length) {
33287
33287
  idx++;
33288
- if (path10.charCodeAt(idx) === 92) {
33288
+ if (path11.charCodeAt(idx) === 92) {
33289
33289
  idx++;
33290
33290
  continue;
33291
33291
  }
33292
- if (path10.charCodeAt(idx) === 41) {
33292
+ if (path11.charCodeAt(idx) === 41) {
33293
33293
  parentheses--;
33294
- } else if (path10.charCodeAt(idx) === 40) {
33294
+ } else if (path11.charCodeAt(idx) === 40) {
33295
33295
  parentheses++;
33296
33296
  }
33297
33297
  if (!parentheses) return idx;
33298
33298
  }
33299
- throw new TypeError('Invalid regexp expression in "' + path10 + '"');
33299
+ throw new TypeError('Invalid regexp expression in "' + path11 + '"');
33300
33300
  }
33301
33301
  function defaultBuildPrettyMeta(route) {
33302
33302
  if (!route) return {};
@@ -33529,12 +33529,12 @@ var require_route = __commonJS({
33529
33529
  function route({ options: options2, isFastify }) {
33530
33530
  throwIfAlreadyStarted("Cannot add route!");
33531
33531
  const opts = { ...options2 };
33532
- const path10 = opts.url || opts.path || "";
33532
+ const path11 = opts.url || opts.path || "";
33533
33533
  if (!opts.handler) {
33534
- throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path10);
33534
+ throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path11);
33535
33535
  }
33536
33536
  if (opts.errorHandler !== void 0 && typeof opts.errorHandler !== "function") {
33537
- throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path10);
33537
+ throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path11);
33538
33538
  }
33539
33539
  validateBodyLimitOption(opts.bodyLimit);
33540
33540
  validateHandlerTimeoutOption(opts.handlerTimeout);
@@ -33544,22 +33544,22 @@ var require_route = __commonJS({
33544
33544
  if (Array.isArray(opts.method)) {
33545
33545
  for (let i = 0; i < opts.method.length; ++i) {
33546
33546
  opts.method[i] = normalizeAndValidateMethod.call(this, opts.method[i]);
33547
- validateSchemaBodyOption.call(this, opts.method[i], path10, opts.schema);
33547
+ validateSchemaBodyOption.call(this, opts.method[i], path11, opts.schema);
33548
33548
  isGetRoute = opts.method.includes("GET");
33549
33549
  isHeadRoute = opts.method.includes("HEAD");
33550
33550
  }
33551
33551
  } else {
33552
33552
  opts.method = normalizeAndValidateMethod.call(this, opts.method);
33553
- validateSchemaBodyOption.call(this, opts.method, path10, opts.schema);
33553
+ validateSchemaBodyOption.call(this, opts.method, path11, opts.schema);
33554
33554
  isGetRoute = opts.method === "GET";
33555
33555
  isHeadRoute = opts.method === "HEAD";
33556
33556
  }
33557
33557
  const headOpts = shouldExposeHead && isGetRoute ? { ...options2 } : null;
33558
33558
  const prefix = this[kRoutePrefix];
33559
- if (path10 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
33559
+ if (path11 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
33560
33560
  switch (opts.prefixTrailingSlash) {
33561
33561
  case "slash":
33562
- addNewRoute.call(this, { path: path10, isFastify });
33562
+ addNewRoute.call(this, { path: path11, isFastify });
33563
33563
  break;
33564
33564
  case "no-slash":
33565
33565
  addNewRoute.call(this, { path: "", isFastify });
@@ -33568,20 +33568,20 @@ var require_route = __commonJS({
33568
33568
  default:
33569
33569
  addNewRoute.call(this, { path: "", isFastify });
33570
33570
  if (ignoreTrailingSlash !== true && (ignoreDuplicateSlashes !== true || !prefix.endsWith("/"))) {
33571
- addNewRoute.call(this, { path: path10, prefixing: true, isFastify });
33571
+ addNewRoute.call(this, { path: path11, prefixing: true, isFastify });
33572
33572
  }
33573
33573
  }
33574
- } else if (path10[0] === "/" && prefix.endsWith("/")) {
33575
- addNewRoute.call(this, { path: path10.slice(1), isFastify });
33574
+ } else if (path11[0] === "/" && prefix.endsWith("/")) {
33575
+ addNewRoute.call(this, { path: path11.slice(1), isFastify });
33576
33576
  } else {
33577
- addNewRoute.call(this, { path: path10, isFastify });
33577
+ addNewRoute.call(this, { path: path11, isFastify });
33578
33578
  }
33579
33579
  return this;
33580
- function addNewRoute({ path: path11, prefixing = false, isFastify: isFastify2 = false }) {
33581
- const url = prefix + path11;
33580
+ function addNewRoute({ path: path12, prefixing = false, isFastify: isFastify2 = false }) {
33581
+ const url = prefix + path12;
33582
33582
  opts.url = url;
33583
33583
  opts.path = url;
33584
- opts.routePath = path11;
33584
+ opts.routePath = path12;
33585
33585
  opts.prefix = prefix;
33586
33586
  opts.logLevel = opts.logLevel || this[kLogLevel];
33587
33587
  validateLogLevelOption(opts.logLevel, opts.method, opts.url, logger);
@@ -33713,7 +33713,7 @@ var require_route = __commonJS({
33713
33713
  });
33714
33714
  if (shouldExposeHead && isGetRoute && !isHeadRoute && !hasHEADHandler) {
33715
33715
  const onSendHandlers = parseHeadOnSendHandlers(headOpts.onSend);
33716
- prepareRoute.call(this, { method: "HEAD", url: path11, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
33716
+ prepareRoute.call(this, { method: "HEAD", url: path12, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
33717
33717
  }
33718
33718
  }
33719
33719
  }
@@ -33837,9 +33837,9 @@ var require_route = __commonJS({
33837
33837
  }
33838
33838
  return method;
33839
33839
  }
33840
- function validateSchemaBodyOption(method, path10, schema) {
33840
+ function validateSchemaBodyOption(method, path11, schema) {
33841
33841
  if (this[kSupportedHTTPMethods].bodyless.has(method) && schema?.body) {
33842
- throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path10);
33842
+ throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path11);
33843
33843
  }
33844
33844
  }
33845
33845
  function validateBodyLimitOption(bodyLimit) {
@@ -33854,11 +33854,11 @@ var require_route = __commonJS({
33854
33854
  throw new FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT(handlerTimeout);
33855
33855
  }
33856
33856
  }
33857
- function validateLogLevelOption(logLevel, method, path10, logger) {
33857
+ function validateLogLevelOption(logLevel, method, path11, logger) {
33858
33858
  if (logLevel == null || logLevel === "") return;
33859
33859
  if (logger?.levels?.values == null) return;
33860
33860
  if (typeof logLevel !== "string" || logger.levels.values[logLevel] === void 0) {
33861
- throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path10, logLevel);
33861
+ throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path11, logLevel);
33862
33862
  }
33863
33863
  }
33864
33864
  function runPreParsing(err, request, reply) {
@@ -33947,7 +33947,7 @@ var require_four_oh_four = __commonJS({
33947
33947
  });
33948
33948
  }
33949
33949
  function createRouteEventHandler() {
33950
- return function onRouteEvent(path10, req, res) {
33950
+ return function onRouteEvent(path11, req, res) {
33951
33951
  const fourOhFourContext = this[kFourOhFourLevelInstance][kFourOhFourContext];
33952
33952
  const id = getGenReqId(fourOhFourContext.server, req);
33953
33953
  const childLogger = createChildLogger(fourOhFourContext, logger, req, id);
@@ -36618,19 +36618,19 @@ var require_fastify = __commonJS({
36618
36618
  }
36619
36619
  fourOhFour.router.lookup(req, res);
36620
36620
  }
36621
- function onBadUrl(path10, req, res) {
36621
+ function onBadUrl(path11, req, res) {
36622
36622
  if (options.frameworkErrors) {
36623
36623
  const id = getGenReqId(routeEventContext.server, req);
36624
36624
  const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
36625
36625
  const request = new Request(id, null, req, null, childLogger, routeEventContext);
36626
36626
  const reply = new Reply(res, request, childLogger);
36627
36627
  routeEventContext.server[kLogController].incomingRequest(request, reply);
36628
- return options.frameworkErrors(new FST_ERR_BAD_URL(path10), request, reply);
36628
+ return options.frameworkErrors(new FST_ERR_BAD_URL(path11), request, reply);
36629
36629
  }
36630
36630
  const body = JSON.stringify({
36631
36631
  error: "Bad Request",
36632
36632
  code: "FST_ERR_BAD_URL",
36633
- message: `'${path10}' is not a valid url component`,
36633
+ message: `'${path11}' is not a valid url component`,
36634
36634
  statusCode: 400
36635
36635
  });
36636
36636
  res.writeHead(400, {
@@ -36639,19 +36639,19 @@ var require_fastify = __commonJS({
36639
36639
  });
36640
36640
  res.end(body);
36641
36641
  }
36642
- function onMaxParamLength(path10, req, res) {
36642
+ function onMaxParamLength(path11, req, res) {
36643
36643
  if (options.frameworkErrors) {
36644
36644
  const id = getGenReqId(routeEventContext.server, req);
36645
36645
  const childLogger = createChildLogger(routeEventContext, options.logger, req, id);
36646
36646
  const request = new Request(id, null, req, null, childLogger, routeEventContext);
36647
36647
  const reply = new Reply(res, request, childLogger);
36648
36648
  routeEventContext.server[kLogController].incomingRequest(request, reply);
36649
- return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path10), request, reply);
36649
+ return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path11), request, reply);
36650
36650
  }
36651
36651
  const body = JSON.stringify({
36652
36652
  error: "Bad Request",
36653
36653
  code: "FST_ERR_MAX_PARAM_LENGTH",
36654
- message: `'${path10}' is exceeding the max param length`,
36654
+ message: `'${path11}' is exceeding the max param length`,
36655
36655
  statusCode: 414
36656
36656
  });
36657
36657
  res.writeHead(414, {
@@ -41001,8 +41001,8 @@ var import_cors = __toESM(require_cors(), 1);
41001
41001
  // src/db/index.ts
41002
41002
  import Database from "better-sqlite3";
41003
41003
  var db;
41004
- function initDb(path10 = "data.db") {
41005
- db = new Database(path10);
41004
+ function initDb(path11 = "data.db") {
41005
+ db = new Database(path11);
41006
41006
  db.pragma("journal_mode = WAL");
41007
41007
  db.pragma("foreign_keys = ON");
41008
41008
  createTables(db);
@@ -41151,6 +41151,9 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
41151
41151
  if (!sessColumns.some((c) => c.name === "user_touched")) {
41152
41152
  database.exec("ALTER TABLE sessions ADD COLUMN user_touched INTEGER NOT NULL DEFAULT 0");
41153
41153
  }
41154
+ if (!sessColumns.some((c) => c.name === "import_source_id")) {
41155
+ database.exec("ALTER TABLE sessions ADD COLUMN import_source_id TEXT");
41156
+ }
41154
41157
  const appInstanceColumns = database.prepare("PRAGMA table_info(app_instances)").all();
41155
41158
  if (!appInstanceColumns.some((c) => c.name === "version")) {
41156
41159
  database.exec("ALTER TABLE app_instances ADD COLUMN version INTEGER NOT NULL DEFAULT 0");
@@ -42698,8 +42701,101 @@ Agent: ${agent}`;
42698
42701
 
42699
42702
  // src/routes/workspaces.ts
42700
42703
  import { execFile } from "node:child_process";
42704
+ import { readdir, stat } from "node:fs/promises";
42705
+ import { homedir, hostname } from "node:os";
42706
+ import nodePath from "node:path";
42701
42707
  import { promisify } from "node:util";
42702
42708
  var execFileAsync = promisify(execFile);
42709
+ async function resolveWorkspacePath(input) {
42710
+ let p = input.trim();
42711
+ if (p === "~" || p.startsWith("~/")) p = nodePath.join(homedir(), p.slice(1));
42712
+ if (!nodePath.isAbsolute(p)) {
42713
+ return { error: "Enter the full path of a folder, e.g. ~/projects/my-app" };
42714
+ }
42715
+ p = nodePath.resolve(p);
42716
+ try {
42717
+ if (!(await stat(p)).isDirectory()) return { error: `${p} is a file, not a folder` };
42718
+ } catch {
42719
+ return { error: `There is no folder at ${p}` };
42720
+ }
42721
+ return { path: p };
42722
+ }
42723
+ var BROWSE_LIMIT = 500;
42724
+ var HOME_STANDARD_FOLDERS = /* @__PURE__ */ new Set([
42725
+ "Applications",
42726
+ "Desktop",
42727
+ "Documents",
42728
+ "Downloads",
42729
+ "Library",
42730
+ "Movies",
42731
+ "Music",
42732
+ "Pictures",
42733
+ "Public"
42734
+ ]);
42735
+ async function exists(p) {
42736
+ try {
42737
+ await stat(p);
42738
+ return true;
42739
+ } catch {
42740
+ return false;
42741
+ }
42742
+ }
42743
+ async function browseFolder(input, opts = {}) {
42744
+ const home = opts.home ?? homedir();
42745
+ let dir = input?.trim() || home;
42746
+ if (dir === "~" || dir.startsWith("~/")) dir = nodePath.join(home, dir.slice(1));
42747
+ if (!nodePath.isAbsolute(dir)) return { status: 400, error: `Not a full path: ${dir}` };
42748
+ dir = nodePath.resolve(dir);
42749
+ let entries;
42750
+ try {
42751
+ entries = await readdir(dir, { withFileTypes: true });
42752
+ } catch (err) {
42753
+ const code = err.code;
42754
+ if (code === "ENOENT") return { status: 404, error: `There is no folder at ${dir}` };
42755
+ if (code === "ENOTDIR") return { status: 400, error: `${dir} is a file, not a folder` };
42756
+ if (code === "EACCES" || code === "EPERM") return { status: 403, error: `No permission to open ${dir}` };
42757
+ throw err;
42758
+ }
42759
+ const names = [];
42760
+ for (const entry of entries) {
42761
+ if (entry.name.startsWith(".")) continue;
42762
+ if (entry.isDirectory()) {
42763
+ names.push(entry.name);
42764
+ } else if (entry.isSymbolicLink()) {
42765
+ try {
42766
+ if ((await stat(nodePath.join(dir, entry.name))).isDirectory()) names.push(entry.name);
42767
+ } catch {
42768
+ }
42769
+ }
42770
+ }
42771
+ names.sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base", numeric: true }));
42772
+ const limit = opts.limit ?? BROWSE_LIMIT;
42773
+ const atHome = dir === nodePath.resolve(home);
42774
+ const folders = await Promise.all(
42775
+ names.slice(0, limit).map(async (name) => {
42776
+ const path11 = nodePath.join(dir, name);
42777
+ const skipProbe = atHome && HOME_STANDARD_FOLDERS.has(name) || dir === "/Volumes";
42778
+ return { name, path: path11, git: !skipProbe && await exists(nodePath.join(path11, ".git")) };
42779
+ })
42780
+ );
42781
+ const parent = nodePath.dirname(dir);
42782
+ return {
42783
+ path: dir,
42784
+ parent: parent === dir ? null : parent,
42785
+ home,
42786
+ hostname: hostname(),
42787
+ folders,
42788
+ truncated: names.length > limit
42789
+ };
42790
+ }
42791
+ var LOOPBACK_HOST = /^(localhost|127(?:\.\d+){3}|\[::1\]|::1|0\.0\.0\.0)(:\d+)?$/i;
42792
+ function pickerAvailability(request, platform = process.platform) {
42793
+ const host = String(request.headers.host ?? "");
42794
+ const remote = Boolean(request.headers["cf-connecting-ip"]) || host !== "" && !LOOPBACK_HOST.test(host);
42795
+ if (remote) return { available: false, reason: "remote" };
42796
+ if (platform !== "darwin") return { available: false, reason: "unsupported" };
42797
+ return { available: true, reason: null };
42798
+ }
42703
42799
  async function registerWorkspaceRoutes(fastify) {
42704
42800
  fastify.get("/api/workspaces", async () => {
42705
42801
  const rows = getDb().prepare("SELECT * FROM workspaces ORDER BY created_at ASC").all();
@@ -42717,11 +42813,15 @@ async function registerWorkspaceRoutes(fastify) {
42717
42813
  }
42718
42814
  }
42719
42815
  }, async (request, reply) => {
42720
- const { path: path10, label = null } = request.body || {};
42721
- if (!path10 || !path10.trim()) {
42816
+ const { path: path11, label = null } = request.body || {};
42817
+ if (!path11 || !path11.trim()) {
42722
42818
  return reply.code(400).send({ error: "Path is required" });
42723
42819
  }
42724
- const trimmedPath = path10.trim();
42820
+ const resolved = await resolveWorkspacePath(path11);
42821
+ if ("error" in resolved) {
42822
+ return reply.code(400).send({ error: resolved.error });
42823
+ }
42824
+ const trimmedPath = resolved.path;
42725
42825
  const db2 = getDb();
42726
42826
  const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
42727
42827
  if (existing) {
@@ -42743,14 +42843,20 @@ async function registerWorkspaceRoutes(fastify) {
42743
42843
  const workspace = db2.prepare("SELECT * FROM workspaces WHERE id = ?").get(id);
42744
42844
  return workspace;
42745
42845
  });
42846
+ fastify.get("/api/workspaces/picker", async (request) => pickerAvailability(request));
42847
+ fastify.get("/api/workspaces/browse", async (request, reply) => {
42848
+ const result = await browseFolder(request.query.path);
42849
+ if ("error" in result) return reply.code(result.status).send({ error: result.error });
42850
+ return result;
42851
+ });
42746
42852
  fastify.get("/api/pick-directory", async (_request, reply) => {
42747
42853
  try {
42748
42854
  const { stdout } = await execFileAsync("osascript", [
42749
42855
  "-e",
42750
42856
  'POSIX path of (choose folder with prompt "Select a workspace directory")'
42751
42857
  ]);
42752
- const path10 = stdout.trim().replace(/\/$/, "");
42753
- return { path: path10 };
42858
+ const path11 = stdout.trim().replace(/\/$/, "");
42859
+ return { path: path11 };
42754
42860
  } catch {
42755
42861
  return reply.code(204).send({ cancelled: true });
42756
42862
  }
@@ -42766,11 +42872,11 @@ async function registerWorkspaceRoutes(fastify) {
42766
42872
  }
42767
42873
  }
42768
42874
  }, async (request, reply) => {
42769
- const { path: path10 } = request.body || {};
42770
- if (!path10 || !path10.trim()) {
42875
+ const { path: path11 } = request.body || {};
42876
+ if (!path11 || !path11.trim()) {
42771
42877
  return reply.code(400).send({ error: "Path is required" });
42772
42878
  }
42773
- const trimmedPath = path10.trim();
42879
+ const trimmedPath = path11.trim();
42774
42880
  const db2 = getDb();
42775
42881
  const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
42776
42882
  if (existing) {
@@ -43375,12 +43481,12 @@ async function registerFileRoutes(fastify) {
43375
43481
 
43376
43482
  // src/routes/perf-log.ts
43377
43483
  import { appendFileSync, mkdirSync, renameSync, statSync } from "node:fs";
43378
- import { homedir } from "node:os";
43484
+ import { homedir as homedir2 } from "node:os";
43379
43485
  import { dirname, join } from "node:path";
43380
43486
  var MAX_BYTES = 5 * 1024 * 1024;
43381
43487
  var MAX_BATCH = 500;
43382
43488
  function perfLogPath() {
43383
- return process.env.AGENT_PANE_PERF_LOG ?? join(homedir(), ".repoburg", "agent-pane", "perf.log");
43489
+ return process.env.AGENT_PANE_PERF_LOG ?? join(homedir2(), ".repoburg", "agent-pane", "perf.log");
43384
43490
  }
43385
43491
  function oneLine(s) {
43386
43492
  return s.replace(/[\r\n\t]+/g, " ");
@@ -43417,17 +43523,17 @@ async function registerPerfLogRoutes(fastify) {
43417
43523
  if (entries.length === 0) {
43418
43524
  return reply.send({ written: 0 });
43419
43525
  }
43420
- const path10 = perfLogPath();
43526
+ const path11 = perfLogPath();
43421
43527
  try {
43422
- mkdirSync(dirname(path10), { recursive: true });
43528
+ mkdirSync(dirname(path11), { recursive: true });
43423
43529
  try {
43424
- if (statSync(path10).size > MAX_BYTES) {
43425
- renameSync(path10, `${path10}.1`);
43530
+ if (statSync(path11).size > MAX_BYTES) {
43531
+ renameSync(path11, `${path11}.1`);
43426
43532
  }
43427
43533
  } catch {
43428
43534
  }
43429
43535
  const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
43430
- appendFileSync(path10, `${lines}
43536
+ appendFileSync(path11, `${lines}
43431
43537
  `, "utf-8");
43432
43538
  return reply.send({ written: entries.length });
43433
43539
  } catch (err) {
@@ -43505,7 +43611,7 @@ import net from "node:net";
43505
43611
  import crypto from "node:crypto";
43506
43612
  import os from "node:os";
43507
43613
  import path2 from "node:path";
43508
- import { mkdir, readdir, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
43614
+ import { mkdir, readdir as readdir2, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
43509
43615
  var VSCODE_WEB_DATA_DIR = path2.join(os.homedir(), ".repoburg", "vscode-web");
43510
43616
  function resolveDesktopUserDir() {
43511
43617
  if (process.platform === "darwin") {
@@ -43538,7 +43644,7 @@ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
43538
43644
  const desktopExt = path2.join(os.homedir(), ".vscode", "extensions");
43539
43645
  let entries;
43540
43646
  try {
43541
- entries = await readdir(desktopExt, { withFileTypes: true });
43647
+ entries = await readdir2(desktopExt, { withFileTypes: true });
43542
43648
  } catch {
43543
43649
  return;
43544
43650
  }
@@ -99080,9 +99186,9 @@ function getAppFile(appId, ref) {
99080
99186
  if (!fileId) return null;
99081
99187
  const file = path6.join(appFilesDir(appId), fileId);
99082
99188
  try {
99083
- const stat = fs3.statSync(file);
99084
- if (!stat.isFile()) return null;
99085
- return { id: fileId, url: appFileUrl(appId, fileId), path: file, type: fileType(fileId), size: stat.size };
99189
+ const stat2 = fs3.statSync(file);
99190
+ if (!stat2.isFile()) return null;
99191
+ return { id: fileId, url: appFileUrl(appId, fileId), path: file, type: fileType(fileId), size: stat2.size };
99086
99192
  } catch {
99087
99193
  return null;
99088
99194
  }
@@ -99767,13 +99873,13 @@ async function registerAppRoutes(fastify, opts) {
99767
99873
 
99768
99874
  // src/sidecar/transcript-locator.ts
99769
99875
  import { existsSync as existsSync2, readdirSync } from "node:fs";
99770
- import { homedir as homedir2 } from "node:os";
99876
+ import { homedir as homedir3 } from "node:os";
99771
99877
  import { join as join2 } from "node:path";
99772
99878
  function claudeConfigDir() {
99773
- return process.env.CLAUDE_CONFIG_DIR || join2(homedir2(), ".claude");
99879
+ return process.env.CLAUDE_CONFIG_DIR || join2(homedir3(), ".claude");
99774
99880
  }
99775
99881
  function codexHome() {
99776
- return process.env.CODEX_HOME || join2(homedir2(), ".codex");
99882
+ return process.env.CODEX_HOME || join2(homedir3(), ".codex");
99777
99883
  }
99778
99884
  function encodeClaudeProjectDir(cwd) {
99779
99885
  return cwd.replace(/[^a-zA-Z0-9]/g, "-");
@@ -99896,7 +100002,7 @@ async function registerSidecarRoutes(fastify) {
99896
100002
 
99897
100003
  // src/usage/usage-service.ts
99898
100004
  import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
99899
- import { homedir as homedir3 } from "node:os";
100005
+ import { homedir as homedir4 } from "node:os";
99900
100006
  import { join as join3 } from "node:path";
99901
100007
 
99902
100008
  // src/usage/usage-pricing.ts
@@ -99961,7 +100067,7 @@ function computeCost(modelId, usage, inputIncludesCached) {
99961
100067
 
99962
100068
  // src/usage/usage-service.ts
99963
100069
  function usageFilesDir() {
99964
- return process.env.AGENT_PANE_USAGE_DIR ?? join3(homedir3(), ".repoburg", "usage");
100070
+ return process.env.AGENT_PANE_USAGE_DIR ?? join3(homedir4(), ".repoburg", "usage");
99965
100071
  }
99966
100072
  function emptyBucket() {
99967
100073
  return { calls: 0, errors: 0, input: 0, cached: 0, cacheWrite: 0, output: 0, cost: 0 };
@@ -100217,6 +100323,619 @@ async function registerUsageRoutes(fastify) {
100217
100323
  );
100218
100324
  }
100219
100325
 
100326
+ // src/claude/session-import.ts
100327
+ import { readFile as readFile2, realpath } from "node:fs/promises";
100328
+ import path8 from "node:path";
100329
+ import { getSessionInfo, listSessions } from "@anthropic-ai/claude-agent-sdk";
100330
+
100331
+ // src/claude/claude-message-mapper.ts
100332
+ function mapAssistantContent(content, messageId, thinkingTexts) {
100333
+ const descriptors = [];
100334
+ for (let i = 0; i < content.length; i++) {
100335
+ const block = content[i];
100336
+ switch (block.type) {
100337
+ case "text": {
100338
+ const tb = block;
100339
+ descriptors.push({
100340
+ type: "agent_message",
100341
+ data: { text: tb.text },
100342
+ externalId: messageId
100343
+ });
100344
+ break;
100345
+ }
100346
+ case "thinking": {
100347
+ const tb = block;
100348
+ let text = tb.thinking;
100349
+ if (!text && thinkingTexts) {
100350
+ text = thinkingTexts.get(i) ?? "";
100351
+ }
100352
+ descriptors.push({
100353
+ type: "reasoning",
100354
+ data: { text },
100355
+ externalId: messageId
100356
+ });
100357
+ break;
100358
+ }
100359
+ case "tool_use": {
100360
+ const tu = block;
100361
+ const desc = mapToolUse(tu);
100362
+ descriptors.push(desc);
100363
+ break;
100364
+ }
100365
+ case "redacted_thinking":
100366
+ break;
100367
+ default:
100368
+ break;
100369
+ }
100370
+ }
100371
+ return descriptors;
100372
+ }
100373
+ function mapToolUse(block) {
100374
+ const input = block.input;
100375
+ if (block.name === "Bash") {
100376
+ return {
100377
+ type: "command_execution",
100378
+ data: {
100379
+ command: input.command ?? "",
100380
+ aggregated_output: null,
100381
+ exit_code: null,
100382
+ status: "in_progress"
100383
+ },
100384
+ externalId: block.id
100385
+ };
100386
+ }
100387
+ if (block.name === "Edit" || block.name === "Write" || block.name === "MultiEdit" || block.name === "NotebookEdit") {
100388
+ return {
100389
+ type: "file_change",
100390
+ data: deriveFileChangeData(input, block.name),
100391
+ externalId: block.id
100392
+ };
100393
+ }
100394
+ return {
100395
+ type: "mcp_tool_call",
100396
+ data: {
100397
+ server: null,
100398
+ tool: block.name,
100399
+ arguments: input,
100400
+ result: null,
100401
+ error: null,
100402
+ status: "in_progress"
100403
+ },
100404
+ externalId: block.id
100405
+ };
100406
+ }
100407
+ function deriveFileChangeData(input, toolName) {
100408
+ const path11 = input.file_path ?? input.notebook_path ?? "";
100409
+ const kind = toolName === "Write" ? "add" : "modify";
100410
+ return { changes: [{ path: path11, kind }], status: "in_progress" };
100411
+ }
100412
+ function extractToolResultText(content) {
100413
+ if (!content) return "";
100414
+ if (typeof content === "string") return content;
100415
+ if (Array.isArray(content)) {
100416
+ return content.map((b) => {
100417
+ if (b && typeof b === "object" && b.type === "text") {
100418
+ return String(b.text ?? "");
100419
+ }
100420
+ return "";
100421
+ }).filter(Boolean).join("\n");
100422
+ }
100423
+ return "";
100424
+ }
100425
+ function applyToolResult(itemType, existingData, toolResult, toolUseResult, isError) {
100426
+ switch (itemType) {
100427
+ case "command_execution": {
100428
+ const text = extractToolResultText(toolResult?.content);
100429
+ const tur = toolUseResult && typeof toolUseResult === "object" ? toolUseResult : {};
100430
+ const stdout = typeof tur.stdout === "string" ? tur.stdout : "";
100431
+ const stderr = typeof tur.stderr === "string" ? tur.stderr : "";
100432
+ let aggregated = text || stdout;
100433
+ if (stderr) aggregated = aggregated ? `${aggregated}
100434
+ ${stderr}` : stderr;
100435
+ return {
100436
+ ...existingData,
100437
+ aggregated_output: aggregated,
100438
+ exit_code: isError ? 1 : 0,
100439
+ status: isError ? "failed" : "completed"
100440
+ };
100441
+ }
100442
+ case "mcp_tool_call": {
100443
+ const text = extractToolResultText(toolResult?.content);
100444
+ return {
100445
+ ...existingData,
100446
+ result: text ? [{ type: "text", text }] : toolUseResult ?? null,
100447
+ error: isError ? text || "Tool error" : null,
100448
+ status: isError ? "failed" : "completed"
100449
+ };
100450
+ }
100451
+ case "file_change": {
100452
+ return { ...existingData, status: isError ? "failed" : "completed" };
100453
+ }
100454
+ default:
100455
+ return existingData;
100456
+ }
100457
+ }
100458
+ function mapPartialDelta(event) {
100459
+ const e = event;
100460
+ if (e.type !== "content_block_delta") return null;
100461
+ const delta = e.delta;
100462
+ if (delta.type === "text_delta") {
100463
+ return { kind: "text", text: delta.text, index: e.index };
100464
+ }
100465
+ if (delta.type === "thinking_delta") {
100466
+ return { kind: "thinking", text: delta.thinking, index: e.index };
100467
+ }
100468
+ return null;
100469
+ }
100470
+ function mapUsage(usage) {
100471
+ return {
100472
+ input_tokens: usage.input_tokens,
100473
+ cached_input_tokens: usage.cache_read_input_tokens ?? 0,
100474
+ cache_write_input_tokens: usage.cache_creation_input_tokens ?? 0,
100475
+ output_tokens: usage.output_tokens,
100476
+ reasoning_output_tokens: 0
100477
+ // Claude SDK does not provide this separately.
100478
+ };
100479
+ }
100480
+
100481
+ // src/claude/transcript-history.ts
100482
+ var MESSAGE_TYPES = /* @__PURE__ */ new Set(["user", "assistant"]);
100483
+ function parseTranscript(text) {
100484
+ const entries = [];
100485
+ for (const line of text.split("\n")) {
100486
+ if (!line.trim()) continue;
100487
+ let raw;
100488
+ try {
100489
+ raw = JSON.parse(line);
100490
+ } catch {
100491
+ continue;
100492
+ }
100493
+ if (typeof raw.uuid !== "string" || typeof raw.type !== "string") continue;
100494
+ const link = {
100495
+ type: raw.type,
100496
+ uuid: raw.uuid,
100497
+ parentUuid: typeof raw.parentUuid === "string" ? raw.parentUuid : null,
100498
+ logicalParentUuid: typeof raw.logicalParentUuid === "string" ? raw.logicalParentUuid : null,
100499
+ isSidechain: raw.isSidechain === true,
100500
+ timestamp: typeof raw.timestamp === "string" ? raw.timestamp : void 0
100501
+ };
100502
+ if (raw.type === "system") {
100503
+ link.subtype = typeof raw.subtype === "string" ? raw.subtype : void 0;
100504
+ if (link.subtype === "compact_boundary") {
100505
+ link.compactMetadata = raw.compactMetadata ?? null;
100506
+ }
100507
+ } else if (MESSAGE_TYPES.has(raw.type)) {
100508
+ link.isMeta = raw.isMeta === true;
100509
+ link.isCompactSummary = raw.isCompactSummary === true;
100510
+ link.isApiErrorMessage = raw.isApiErrorMessage === true;
100511
+ link.cwd = typeof raw.cwd === "string" ? raw.cwd : void 0;
100512
+ link.origin = raw.origin ?? null;
100513
+ link.message = raw.message ?? null;
100514
+ link.toolUseResult = raw.toolUseResult;
100515
+ }
100516
+ entries.push(link);
100517
+ }
100518
+ return entries;
100519
+ }
100520
+ function mainChain(entries) {
100521
+ const byUuid = /* @__PURE__ */ new Map();
100522
+ for (const entry of entries) byUuid.set(entry.uuid, entry);
100523
+ let leaf;
100524
+ for (let i = entries.length - 1; i >= 0; i--) {
100525
+ const entry = entries[i];
100526
+ if (MESSAGE_TYPES.has(entry.type) && !entry.isSidechain) {
100527
+ leaf = entry;
100528
+ break;
100529
+ }
100530
+ }
100531
+ const chain = [];
100532
+ const seen = /* @__PURE__ */ new Set();
100533
+ let current = leaf;
100534
+ while (current && !seen.has(current.uuid)) {
100535
+ seen.add(current.uuid);
100536
+ chain.push(current);
100537
+ const parent = current.parentUuid ?? current.logicalParentUuid ?? null;
100538
+ current = parent ? byUuid.get(parent) : void 0;
100539
+ }
100540
+ return chain.reverse();
100541
+ }
100542
+ var INJECTED_BLOCK = /^\s*<(system-reminder|ide_opened_file|ide_selection|ide_diagnostics)>/;
100543
+ function tagValue(text, tag) {
100544
+ const match = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`).exec(text);
100545
+ return match ? match[1] : null;
100546
+ }
100547
+ function classifyUserInput(entry) {
100548
+ if (entry.origin?.kind && entry.origin.kind !== "human") return { kind: "ignore" };
100549
+ const content = entry.message?.content;
100550
+ let text = "";
100551
+ let images = 0;
100552
+ if (typeof content === "string") {
100553
+ text = content;
100554
+ } else if (Array.isArray(content)) {
100555
+ const parts = [];
100556
+ for (const block of content) {
100557
+ if (!block || typeof block !== "object") continue;
100558
+ if (block.type === "text" && typeof block.text === "string") {
100559
+ if (!INJECTED_BLOCK.test(block.text)) parts.push(block.text);
100560
+ } else if (block.type === "image") {
100561
+ images++;
100562
+ }
100563
+ }
100564
+ text = parts.join("\n");
100565
+ }
100566
+ const trimmed = text.trim();
100567
+ if (trimmed.startsWith("[Request interrupted by user")) return { kind: "interrupt" };
100568
+ const commandName = tagValue(trimmed, "command-name");
100569
+ if (commandName !== null) {
100570
+ const args = (tagValue(trimmed, "command-args") ?? "").trim();
100571
+ const name = commandName.trim();
100572
+ return { kind: "command", text: args ? `${name} ${args}` : name };
100573
+ }
100574
+ const bashInput = tagValue(trimmed, "bash-input");
100575
+ if (bashInput !== null) return { kind: "bash", command: bashInput };
100576
+ const stdout = tagValue(trimmed, "bash-stdout");
100577
+ const stderr = tagValue(trimmed, "bash-stderr");
100578
+ if (stdout !== null || stderr !== null) return { kind: "bash-output", stdout: stdout ?? "", stderr: stderr ?? "" };
100579
+ if (/^<(local-command-stdout|local-command-stderr|local-command-caveat|task-notification|system-reminder)>/.test(
100580
+ trimmed
100581
+ )) {
100582
+ return { kind: "ignore" };
100583
+ }
100584
+ if (!trimmed && images === 0) return { kind: "ignore" };
100585
+ const imageNote = images > 0 && !trimmed.includes("[Image") ? Array(images).fill("[Image]").join(" ") : "";
100586
+ return { kind: "prompt", text: [trimmed, imageNote].filter(Boolean).join("\n") };
100587
+ }
100588
+ var TOOL_ITEM_TYPES = /* @__PURE__ */ new Set(["command_execution", "file_change", "mcp_tool_call"]);
100589
+ function syntheticText(content) {
100590
+ if (typeof content === "string") return content;
100591
+ if (!Array.isArray(content)) return "";
100592
+ return content.map(
100593
+ (b) => b && typeof b === "object" && b.type === "text" ? String(b.text ?? "") : ""
100594
+ ).join("").trim();
100595
+ }
100596
+ function buildTurns(chain) {
100597
+ const turns = [];
100598
+ let current = null;
100599
+ let lastMs = 0;
100600
+ const stamp = (entry) => {
100601
+ const parsed = entry.timestamp ? Date.parse(entry.timestamp) : NaN;
100602
+ lastMs = Number.isFinite(parsed) && parsed > lastMs ? parsed : lastMs + 1;
100603
+ return new Date(lastMs).toISOString();
100604
+ };
100605
+ const openTurn = (prompt, entry, fromCommand = false) => {
100606
+ const at = stamp(entry);
100607
+ const turn = {
100608
+ userPrompt: prompt,
100609
+ status: "completed",
100610
+ agentResponse: null,
100611
+ thoughts: null,
100612
+ externalTurnId: null,
100613
+ createdAt: at,
100614
+ updatedAt: at,
100615
+ items: [],
100616
+ fromCommand,
100617
+ toolItems: /* @__PURE__ */ new Map()
100618
+ };
100619
+ turns.push(turn);
100620
+ return turn;
100621
+ };
100622
+ const addItem = (turn, entry, item) => {
100623
+ const full = { ...item, createdAt: stamp(entry) };
100624
+ turn.items.push(full);
100625
+ turn.updatedAt = full.createdAt;
100626
+ return full;
100627
+ };
100628
+ for (const entry of chain) {
100629
+ if (entry.type === "system") {
100630
+ if (entry.subtype === "compact_boundary" && current) {
100631
+ const meta = entry.compactMetadata ?? {};
100632
+ addItem(current, entry, {
100633
+ type: "context_compaction",
100634
+ externalId: `compact-${entry.uuid}`,
100635
+ data: { trigger: meta.trigger ?? "auto", pre_tokens: meta.preTokens ?? 0, post_tokens: meta.postTokens ?? 0 },
100636
+ status: "completed"
100637
+ });
100638
+ }
100639
+ continue;
100640
+ }
100641
+ if (entry.type === "user") {
100642
+ if (entry.isMeta || entry.isCompactSummary) continue;
100643
+ const content = entry.message?.content;
100644
+ if (Array.isArray(content) && content.some((b) => b?.type === "tool_result")) {
100645
+ if (!current) continue;
100646
+ for (const block of content) {
100647
+ const b = block;
100648
+ if (b?.type !== "tool_result" || !b.tool_use_id) continue;
100649
+ const item = current.toolItems.get(b.tool_use_id);
100650
+ if (!item) continue;
100651
+ const isError = !!b.is_error;
100652
+ item.data = applyToolResult(item.type, item.data, b, entry.toolUseResult, isError);
100653
+ item.status = isError ? "failed" : "completed";
100654
+ }
100655
+ continue;
100656
+ }
100657
+ const input = classifyUserInput(entry);
100658
+ switch (input.kind) {
100659
+ case "prompt":
100660
+ current = openTurn(input.text, entry);
100661
+ break;
100662
+ case "command":
100663
+ current = openTurn(input.text, entry, true);
100664
+ break;
100665
+ case "bash": {
100666
+ const turn = openTurn(`! ${input.command}`, entry);
100667
+ current = turn;
100668
+ const item = addItem(turn, entry, {
100669
+ type: "command_execution",
100670
+ externalId: `bash-${entry.uuid}`,
100671
+ data: { command: input.command, aggregated_output: null, exit_code: null, status: "in_progress" },
100672
+ status: "in_progress"
100673
+ });
100674
+ turn.toolItems.set(item.externalId, item);
100675
+ break;
100676
+ }
100677
+ case "bash-output": {
100678
+ const item = current?.items.find(
100679
+ (i) => i.type === "command_execution" && i.status === "in_progress" && i.externalId.startsWith("bash-")
100680
+ );
100681
+ if (item) {
100682
+ const failed = !!input.stderr.trim() && !input.stdout.trim();
100683
+ const output = [input.stdout, input.stderr].filter((s) => s.trim()).join("\n");
100684
+ item.data = {
100685
+ ...item.data,
100686
+ aggregated_output: output,
100687
+ exit_code: failed ? 1 : 0,
100688
+ status: failed ? "failed" : "completed"
100689
+ };
100690
+ item.status = failed ? "failed" : "completed";
100691
+ }
100692
+ break;
100693
+ }
100694
+ case "interrupt":
100695
+ if (current) current.status = "aborted";
100696
+ break;
100697
+ case "ignore":
100698
+ break;
100699
+ }
100700
+ continue;
100701
+ }
100702
+ if (entry.type === "assistant") {
100703
+ const message = entry.message;
100704
+ if (!message) continue;
100705
+ if (!current) current = openTurn("", entry);
100706
+ const turn = current;
100707
+ if (entry.isApiErrorMessage || message.model === "<synthetic>") {
100708
+ const text = syntheticText(message.content);
100709
+ if (entry.isApiErrorMessage && text) {
100710
+ addItem(turn, entry, {
100711
+ type: "error",
100712
+ externalId: `api-error-${entry.uuid}`,
100713
+ data: { message: text, error: "api_error" },
100714
+ status: "completed"
100715
+ });
100716
+ }
100717
+ continue;
100718
+ }
100719
+ const content = Array.isArray(message.content) ? message.content : [];
100720
+ for (const desc of mapAssistantContent(content, entry.uuid)) {
100721
+ if (desc.type === "reasoning" && !String(desc.data.text ?? "").trim()) continue;
100722
+ if (desc.type === "agent_message") desc.externalId = message.id ?? entry.uuid;
100723
+ const isTool = TOOL_ITEM_TYPES.has(desc.type);
100724
+ const item = addItem(turn, entry, {
100725
+ type: desc.type,
100726
+ externalId: desc.externalId,
100727
+ data: desc.data,
100728
+ status: isTool ? "in_progress" : "completed"
100729
+ });
100730
+ if (isTool) turn.toolItems.set(desc.externalId, item);
100731
+ if (desc.type === "agent_message") turn.agentResponse = String(desc.data.text ?? "");
100732
+ if (desc.type === "reasoning") turn.thoughts = String(desc.data.text ?? "");
100733
+ }
100734
+ turn.externalTurnId = entry.uuid;
100735
+ turn.updatedAt = stamp(entry);
100736
+ }
100737
+ }
100738
+ return turns.filter((turn) => !(turn.fromCommand && turn.items.length === 0)).map(({ fromCommand: _fromCommand, toolItems: _toolItems, ...turn }) => ({
100739
+ ...turn,
100740
+ // A tool that never got its result (interrupted, crashed) did not finish.
100741
+ items: turn.items.map(
100742
+ (item) => item.status === "in_progress" ? { ...item, status: "failed", data: { ...item.data, status: "failed" } } : item
100743
+ )
100744
+ }));
100745
+ }
100746
+ function transcriptToTurns(text) {
100747
+ return buildTurns(mainChain(parseTranscript(text)));
100748
+ }
100749
+
100750
+ // src/claude/session-import.ts
100751
+ var ClaudeImportError = class extends Error {
100752
+ status;
100753
+ paneSessionId;
100754
+ constructor(status, message, paneSessionId = null) {
100755
+ super(message);
100756
+ this.name = "ClaudeImportError";
100757
+ this.status = status;
100758
+ this.paneSessionId = paneSessionId;
100759
+ }
100760
+ };
100761
+ var RECENT_MS = 10 * 6e4;
100762
+ var CHECK_EMPTY_BELOW_BYTES = 64 * 1024;
100763
+ var SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
100764
+ var TITLE_MAX = 100;
100765
+ async function realDir(dir) {
100766
+ try {
100767
+ return await realpath(dir);
100768
+ } catch {
100769
+ return null;
100770
+ }
100771
+ }
100772
+ async function sameDir(a, realB) {
100773
+ const realA = await realDir(a) ?? path8.resolve(a);
100774
+ return realA === realB;
100775
+ }
100776
+ function knownClaudeSessionIds(db2) {
100777
+ const rows = db2.prepare(
100778
+ `SELECT external_thread_id AS id FROM sessions WHERE external_thread_id IS NOT NULL
100779
+ UNION SELECT pre_rewind_thread_id FROM sessions WHERE pre_rewind_thread_id IS NOT NULL
100780
+ UNION SELECT import_source_id FROM sessions WHERE import_source_id IS NOT NULL
100781
+ UNION SELECT external_thread_id FROM discussion_threads WHERE external_thread_id IS NOT NULL`
100782
+ ).all();
100783
+ return new Set(rows.map((row) => row.id));
100784
+ }
100785
+ function paneSessionHolding(db2, claudeSessionId) {
100786
+ const row = db2.prepare(
100787
+ `SELECT id FROM sessions WHERE import_source_id = ? OR external_thread_id = ? OR pre_rewind_thread_id = ?
100788
+ UNION SELECT session_id FROM discussion_threads WHERE external_thread_id = ?
100789
+ LIMIT 1`
100790
+ ).get(claudeSessionId, claudeSessionId, claudeSessionId, claudeSessionId);
100791
+ return row?.id ?? null;
100792
+ }
100793
+ function titleOf(info) {
100794
+ const raw = (info.customTitle || info.summary || info.firstPrompt || "").trim();
100795
+ const firstLine = raw.split("\n")[0].trim();
100796
+ return firstLine.length > TITLE_MAX ? `${firstLine.slice(0, TITLE_MAX - 1)}\u2026` : firstLine;
100797
+ }
100798
+ async function readTranscript(info) {
100799
+ const file = locateTranscript({ runtime_type: "claude", external_thread_id: info.sessionId, cwd: info.cwd ?? null });
100800
+ if (!file) return null;
100801
+ try {
100802
+ return await readFile2(file, "utf8");
100803
+ } catch {
100804
+ return null;
100805
+ }
100806
+ }
100807
+ async function listImportableClaudeSessions(db2, workspacePath, now = Date.now()) {
100808
+ const dir = await realDir(workspacePath);
100809
+ if (!dir) return [];
100810
+ const known = knownClaudeSessionIds(db2);
100811
+ const infos = await listSessions({ dir, includeProgrammatic: false, includeWorktrees: false });
100812
+ const sessions = [];
100813
+ for (const info of infos) {
100814
+ if (known.has(info.sessionId) || !info.cwd) continue;
100815
+ if (!await sameDir(info.cwd, dir)) continue;
100816
+ if ((info.fileSize ?? 0) < CHECK_EMPTY_BELOW_BYTES) {
100817
+ const text = await readTranscript(info);
100818
+ if (!text || transcriptToTurns(text).length === 0) continue;
100819
+ }
100820
+ sessions.push({
100821
+ session_id: info.sessionId,
100822
+ title: titleOf(info) || "Untitled session",
100823
+ cwd: info.cwd,
100824
+ git_branch: info.gitBranch ?? null,
100825
+ created_at: info.createdAt ? new Date(info.createdAt).toISOString() : null,
100826
+ last_modified: new Date(info.lastModified).toISOString(),
100827
+ recently_active: now - info.lastModified < RECENT_MS
100828
+ });
100829
+ }
100830
+ return sessions.sort((a, b) => a.last_modified < b.last_modified ? 1 : -1);
100831
+ }
100832
+ async function importClaudeSession(db2, claudeSessionId, workspacePath) {
100833
+ if (!SESSION_ID.test(claudeSessionId)) throw new ClaudeImportError(400, "Not a Claude Code session id");
100834
+ const holder = paneSessionHolding(db2, claudeSessionId);
100835
+ if (holder) throw new ClaudeImportError(409, "This session is already in the pane", holder);
100836
+ const dir = workspacePath ? await realDir(workspacePath) : null;
100837
+ const info = (dir ? await getSessionInfo(claudeSessionId, { dir }) : void 0) ?? await getSessionInfo(claudeSessionId);
100838
+ if (!info) throw new ClaudeImportError(404, "Claude Code session not found");
100839
+ const text = await readTranscript(info);
100840
+ if (text === null) throw new ClaudeImportError(404, "The session transcript could not be read");
100841
+ const turns = transcriptToTurns(text);
100842
+ if (turns.length === 0) throw new ClaudeImportError(422, "This session has no conversation to import");
100843
+ const cwd = workspacePath && dir && info.cwd && await sameDir(info.cwd, dir) ? workspacePath : info.cwd ?? null;
100844
+ const sessionId = v4_default();
100845
+ const createdAt = turns[0].createdAt;
100846
+ const updatedAt = turns[turns.length - 1].updatedAt;
100847
+ const insertSession = db2.prepare(
100848
+ `INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status,
100849
+ is_running, lifecycle, sort_order, user_touched, import_source_id, created_at, updated_at)
100850
+ VALUES (?, ?, 'claude', NULL, NULL, ?, ?, 'active', 0, 'working', ?, 1, ?, ?, ?)`
100851
+ );
100852
+ const insertTurn = db2.prepare(
100853
+ `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status,
100854
+ error, created_at, updated_at)
100855
+ VALUES (?, ?, ?, ?, ?, NULL, ?, ?, NULL, ?, ?)`
100856
+ );
100857
+ const insertItem2 = db2.prepare(
100858
+ `INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
100859
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
100860
+ );
100861
+ db2.transaction(() => {
100862
+ const raced = paneSessionHolding(db2, claudeSessionId);
100863
+ if (raced) throw new ClaudeImportError(409, "This session is already in the pane", raced);
100864
+ const { m } = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(cwd);
100865
+ insertSession.run(
100866
+ sessionId,
100867
+ titleOf(info) || null,
100868
+ cwd,
100869
+ claudeSessionId,
100870
+ m + 1,
100871
+ claudeSessionId,
100872
+ createdAt,
100873
+ updatedAt
100874
+ );
100875
+ for (const turn of turns) {
100876
+ const turnId = v4_default();
100877
+ insertTurn.run(
100878
+ turnId,
100879
+ sessionId,
100880
+ turn.userPrompt,
100881
+ turn.agentResponse,
100882
+ turn.thoughts,
100883
+ turn.externalTurnId,
100884
+ turn.status,
100885
+ turn.createdAt,
100886
+ turn.updatedAt
100887
+ );
100888
+ for (const item of turn.items) {
100889
+ insertItem2.run(
100890
+ v4_default(),
100891
+ turnId,
100892
+ item.externalId,
100893
+ item.type,
100894
+ JSON.stringify(trimItemData(item.data)),
100895
+ item.status,
100896
+ item.createdAt,
100897
+ item.createdAt
100898
+ );
100899
+ }
100900
+ }
100901
+ })();
100902
+ return db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
100903
+ }
100904
+
100905
+ // src/routes/claude-sessions.ts
100906
+ async function registerClaudeSessionRoutes(fastify) {
100907
+ fastify.get("/api/claude-sessions", async (request, reply) => {
100908
+ const workspace = request.query.workspace?.trim();
100909
+ if (!workspace) return reply.code(400).send({ error: "workspace is required" });
100910
+ try {
100911
+ return { sessions: await listImportableClaudeSessions(getDb(), workspace) };
100912
+ } catch (err) {
100913
+ return reply.code(500).send({ error: `Could not list Claude Code sessions: ${err.message}` });
100914
+ }
100915
+ });
100916
+ fastify.post(
100917
+ "/api/claude-sessions/:id/import",
100918
+ {
100919
+ schema: {
100920
+ body: {
100921
+ type: ["object", "null"],
100922
+ properties: { workspace: { type: ["string", "null"] } }
100923
+ }
100924
+ }
100925
+ },
100926
+ async (request, reply) => {
100927
+ try {
100928
+ return await importClaudeSession(getDb(), request.params.id, request.body?.workspace?.trim() || null);
100929
+ } catch (err) {
100930
+ if (err instanceof ClaudeImportError) {
100931
+ return reply.code(err.status).send({ error: err.message, session_id: err.paneSessionId });
100932
+ }
100933
+ return reply.code(500).send({ error: `Import failed: ${err.message}` });
100934
+ }
100935
+ }
100936
+ );
100937
+ }
100938
+
100220
100939
  // src/codex/item-mapper.ts
100221
100940
  function mapItemData(item) {
100222
100941
  switch (item.type) {
@@ -100287,18 +101006,18 @@ function mapTokenUsage(data) {
100287
101006
 
100288
101007
  // src/apps/register-mcp.ts
100289
101008
  import fs6 from "node:fs";
100290
- import path8 from "node:path";
101009
+ import path9 from "node:path";
100291
101010
  import { fileURLToPath as fileURLToPath2 } from "node:url";
100292
101011
  var MCP_SERVER_NAME = "agentpane-miniapps";
100293
101012
  function panePublicUrl() {
100294
101013
  return (process.env.AGENT_PANE_PUBLIC_URL || process.env.REPOBURG_DAEMON_URL || "http://localhost:9998").replace(/\/+$/, "");
100295
101014
  }
100296
101015
  function stdioScriptPath() {
100297
- const here = path8.dirname(fileURLToPath2(import.meta.url));
101016
+ const here = path9.dirname(fileURLToPath2(import.meta.url));
100298
101017
  const candidates = [
100299
- path8.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
101018
+ path9.resolve(here, "../../scripts/miniapp-mcp-stdio.mjs"),
100300
101019
  // src/apps/ → backend/scripts
100301
- path8.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
101020
+ path9.resolve(here, "../scripts/miniapp-mcp-stdio.mjs")
100302
101021
  // dist bundle → backend/scripts
100303
101022
  ];
100304
101023
  for (const candidate of candidates) {
@@ -100985,156 +101704,6 @@ import { readFileSync as readFileSync3 } from "fs";
100985
101704
  import { tmpdir } from "os";
100986
101705
  import { join as join4 } from "path";
100987
101706
 
100988
- // src/claude/claude-message-mapper.ts
100989
- function mapAssistantContent(content, messageId, thinkingTexts) {
100990
- const descriptors = [];
100991
- for (let i = 0; i < content.length; i++) {
100992
- const block = content[i];
100993
- switch (block.type) {
100994
- case "text": {
100995
- const tb = block;
100996
- descriptors.push({
100997
- type: "agent_message",
100998
- data: { text: tb.text },
100999
- externalId: messageId
101000
- });
101001
- break;
101002
- }
101003
- case "thinking": {
101004
- const tb = block;
101005
- let text = tb.thinking;
101006
- if (!text && thinkingTexts) {
101007
- text = thinkingTexts.get(i) ?? "";
101008
- }
101009
- descriptors.push({
101010
- type: "reasoning",
101011
- data: { text },
101012
- externalId: messageId
101013
- });
101014
- break;
101015
- }
101016
- case "tool_use": {
101017
- const tu = block;
101018
- const desc = mapToolUse(tu);
101019
- descriptors.push(desc);
101020
- break;
101021
- }
101022
- case "redacted_thinking":
101023
- break;
101024
- default:
101025
- break;
101026
- }
101027
- }
101028
- return descriptors;
101029
- }
101030
- function mapToolUse(block) {
101031
- const input = block.input;
101032
- if (block.name === "Bash") {
101033
- return {
101034
- type: "command_execution",
101035
- data: {
101036
- command: input.command ?? "",
101037
- aggregated_output: null,
101038
- exit_code: null,
101039
- status: "in_progress"
101040
- },
101041
- externalId: block.id
101042
- };
101043
- }
101044
- if (block.name === "Edit" || block.name === "Write" || block.name === "MultiEdit" || block.name === "NotebookEdit") {
101045
- return {
101046
- type: "file_change",
101047
- data: deriveFileChangeData(input, block.name),
101048
- externalId: block.id
101049
- };
101050
- }
101051
- return {
101052
- type: "mcp_tool_call",
101053
- data: {
101054
- server: null,
101055
- tool: block.name,
101056
- arguments: input,
101057
- result: null,
101058
- error: null,
101059
- status: "in_progress"
101060
- },
101061
- externalId: block.id
101062
- };
101063
- }
101064
- function deriveFileChangeData(input, toolName) {
101065
- const path10 = input.file_path ?? input.notebook_path ?? "";
101066
- const kind = toolName === "Write" ? "add" : "modify";
101067
- return { changes: [{ path: path10, kind }], status: "in_progress" };
101068
- }
101069
- function extractToolResultText(content) {
101070
- if (!content) return "";
101071
- if (typeof content === "string") return content;
101072
- if (Array.isArray(content)) {
101073
- return content.map((b) => {
101074
- if (b && typeof b === "object" && b.type === "text") {
101075
- return String(b.text ?? "");
101076
- }
101077
- return "";
101078
- }).filter(Boolean).join("\n");
101079
- }
101080
- return "";
101081
- }
101082
- function applyToolResult(itemType, existingData, toolResult, toolUseResult, isError) {
101083
- switch (itemType) {
101084
- case "command_execution": {
101085
- const text = extractToolResultText(toolResult?.content);
101086
- const tur = toolUseResult && typeof toolUseResult === "object" ? toolUseResult : {};
101087
- const stdout = typeof tur.stdout === "string" ? tur.stdout : "";
101088
- const stderr = typeof tur.stderr === "string" ? tur.stderr : "";
101089
- let aggregated = text || stdout;
101090
- if (stderr) aggregated = aggregated ? `${aggregated}
101091
- ${stderr}` : stderr;
101092
- return {
101093
- ...existingData,
101094
- aggregated_output: aggregated,
101095
- exit_code: isError ? 1 : 0,
101096
- status: isError ? "failed" : "completed"
101097
- };
101098
- }
101099
- case "mcp_tool_call": {
101100
- const text = extractToolResultText(toolResult?.content);
101101
- return {
101102
- ...existingData,
101103
- result: text ? [{ type: "text", text }] : toolUseResult ?? null,
101104
- error: isError ? text || "Tool error" : null,
101105
- status: isError ? "failed" : "completed"
101106
- };
101107
- }
101108
- case "file_change": {
101109
- return { ...existingData, status: isError ? "failed" : "completed" };
101110
- }
101111
- default:
101112
- return existingData;
101113
- }
101114
- }
101115
- function mapPartialDelta(event) {
101116
- const e = event;
101117
- if (e.type !== "content_block_delta") return null;
101118
- const delta = e.delta;
101119
- if (delta.type === "text_delta") {
101120
- return { kind: "text", text: delta.text, index: e.index };
101121
- }
101122
- if (delta.type === "thinking_delta") {
101123
- return { kind: "thinking", text: delta.thinking, index: e.index };
101124
- }
101125
- return null;
101126
- }
101127
- function mapUsage(usage) {
101128
- return {
101129
- input_tokens: usage.input_tokens,
101130
- cached_input_tokens: usage.cache_read_input_tokens ?? 0,
101131
- cache_write_input_tokens: usage.cache_creation_input_tokens ?? 0,
101132
- output_tokens: usage.output_tokens,
101133
- reasoning_output_tokens: 0
101134
- // Claude SDK does not provide this separately.
101135
- };
101136
- }
101137
-
101138
101707
  // src/claude/claude-types.ts
101139
101708
  var EFFORT_LABELS2 = {
101140
101709
  low: "Low",
@@ -102492,8 +103061,8 @@ var RepoburgHttpClient = class {
102492
103061
  this.baseUrl = baseUrl.replace(/\/+$/, "");
102493
103062
  }
102494
103063
  /** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
102495
- async request(method, path10, body) {
102496
- const response = await fetch(`${this.baseUrl}${path10}`, {
103064
+ async request(method, path11, body) {
103065
+ const response = await fetch(`${this.baseUrl}${path11}`, {
102497
103066
  method,
102498
103067
  headers: { "Content-Type": "application/json" },
102499
103068
  body: body === void 0 ? void 0 : JSON.stringify(body)
@@ -102502,17 +103071,17 @@ var RepoburgHttpClient = class {
102502
103071
  if (!response.ok) {
102503
103072
  if (isHtml(text)) {
102504
103073
  throw new Error(
102505
- `${method} ${path10} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
103074
+ `${method} ${path11} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
102506
103075
  );
102507
103076
  }
102508
- throw new Error(`${method} ${path10} failed: ${response.status} ${text}`);
103077
+ throw new Error(`${method} ${path11} failed: ${response.status} ${text}`);
102509
103078
  }
102510
103079
  if (text.length === 0) return void 0;
102511
103080
  try {
102512
103081
  return JSON.parse(text);
102513
103082
  } catch {
102514
103083
  throw new Error(
102515
- `${method} ${path10} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
103084
+ `${method} ${path11} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
102516
103085
  );
102517
103086
  }
102518
103087
  }
@@ -102567,7 +103136,7 @@ var RepoburgHttpClient = class {
102567
103136
  };
102568
103137
 
102569
103138
  // src/repoburg/backend-resolver.ts
102570
- import path9 from "node:path";
103139
+ import path10 from "node:path";
102571
103140
  var HEALTH_POLL_INTERVAL_MS = 1e3;
102572
103141
  var HEALTH_TIMEOUT_MS = 3e4;
102573
103142
  function daemonBaseUrl() {
@@ -102622,7 +103191,7 @@ async function backendHealthy(baseUrl, expectedPath) {
102622
103191
  const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
102623
103192
  if (health.status !== "ok") return false;
102624
103193
  if (expectedPath && health.projectPath) {
102625
- return path9.resolve(health.projectPath) === path9.resolve(expectedPath);
103194
+ return path10.resolve(health.projectPath) === path10.resolve(expectedPath);
102626
103195
  }
102627
103196
  return true;
102628
103197
  } catch {
@@ -102643,7 +103212,7 @@ function serviceBaseUrl(service) {
102643
103212
  return `http://localhost:${service.port}`;
102644
103213
  }
102645
103214
  function coveringService(services, absPath) {
102646
- return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path9.sep)).sort((a, b) => b.path.length - a.path.length)[0];
103215
+ return services.filter((s) => absPath === s.path || absPath.startsWith(s.path + path10.sep)).sort((a, b) => b.path.length - a.path.length)[0];
102647
103216
  }
102648
103217
  async function restartService(daemon, name) {
102649
103218
  try {
@@ -102679,7 +103248,7 @@ async function resolveBackendUrl(projectPath, opts = {}) {
102679
103248
  if (envUrl) {
102680
103249
  return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
102681
103250
  }
102682
- const absPath = path9.resolve(projectPath);
103251
+ const absPath = path10.resolve(projectPath);
102683
103252
  const daemon = daemonBaseUrl();
102684
103253
  const cached = resolvedCache.get(absPath);
102685
103254
  if (cached && await backendHealthy(cached.baseUrl, cached.servesPath ?? absPath)) {
@@ -104108,6 +104677,7 @@ async function createAgentPaneApp(dbPath) {
104108
104677
  await registerAppRoutes(fastify);
104109
104678
  await registerSidecarRoutes(fastify);
104110
104679
  await registerUsageRoutes(fastify);
104680
+ await registerClaudeSessionRoutes(fastify);
104111
104681
  const wss2 = initWs();
104112
104682
  wss2.on("connection", (ws) => {
104113
104683
  ws.send(JSON.stringify({ event: "background_tasks:snapshot", data: { sessions: listAllBackgroundTasks() } }));