repoburg 1.3.231 → 1.3.233

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.
@@ -401,8 +401,8 @@ var require_error = __commonJS({
401
401
  });
402
402
  if (shouldCreateFastifyGenericError) {
403
403
  Object.defineProperty(FastifyError, Symbol.hasInstance, {
404
- value(instance) {
405
- return instance && instance[FastifyGenericErrorSymbol];
404
+ value(instance2) {
405
+ return instance2 && instance2[FastifyGenericErrorSymbol];
406
406
  },
407
407
  configurable: false,
408
408
  writable: false,
@@ -410,8 +410,8 @@ var require_error = __commonJS({
410
410
  });
411
411
  } else {
412
412
  Object.defineProperty(FastifyError, Symbol.hasInstance, {
413
- value(instance) {
414
- return instance && instance[FastifySpecificErrorSymbol];
413
+ value(instance2) {
414
+ return instance2 && instance2[FastifySpecificErrorSymbol];
415
415
  },
416
416
  configurable: false,
417
417
  writable: false,
@@ -1058,10 +1058,10 @@ var require_avvio = __commonJS({
1058
1058
  this._closeQ.drain = noop;
1059
1059
  };
1060
1060
  this._doStart = null;
1061
- const instance = this;
1061
+ const instance2 = this;
1062
1062
  this._root = new Plugin(fastq(this, this._loadPluginNextTick, 1), function root(server2, opts2, done2) {
1063
- instance._doStart = done2;
1064
- opts2.autostart && instance.start();
1063
+ instance2._doStart = done2;
1064
+ opts2.autostart && instance2.start();
1065
1065
  }, opts, false, 0);
1066
1066
  this._trackPluginLoading(this._root);
1067
1067
  this._loadPlugin(this._root, (err) => {
@@ -1147,8 +1147,8 @@ var require_avvio = __commonJS({
1147
1147
  return plugin;
1148
1148
  };
1149
1149
  Boot.prototype._expose = function _expose() {
1150
- const instance = this;
1151
- const server = instance._server;
1150
+ const instance2 = this;
1151
+ const server = instance2._server;
1152
1152
  const {
1153
1153
  use: useKey = "use",
1154
1154
  after: afterKey = "after",
@@ -1160,7 +1160,7 @@ var require_avvio = __commonJS({
1160
1160
  throw new AVV_ERR_EXPOSE_ALREADY_DEFINED(useKey, "use");
1161
1161
  }
1162
1162
  server[useKey] = function(fn, opts) {
1163
- instance.use(fn, opts);
1163
+ instance2.use(fn, opts);
1164
1164
  return this;
1165
1165
  };
1166
1166
  if (server[afterKey]) {
@@ -1168,9 +1168,9 @@ var require_avvio = __commonJS({
1168
1168
  }
1169
1169
  server[afterKey] = function(func) {
1170
1170
  if (typeof func !== "function") {
1171
- return instance._loadRegistered();
1171
+ return instance2._loadRegistered();
1172
1172
  }
1173
- instance.after(encapsulateThreeParam(func, this));
1173
+ instance2.after(encapsulateThreeParam(func, this));
1174
1174
  return this;
1175
1175
  };
1176
1176
  if (server[readyKey]) {
@@ -1180,7 +1180,7 @@ var require_avvio = __commonJS({
1180
1180
  if (func && typeof func !== "function") {
1181
1181
  throw new AVV_ERR_CALLBACK_NOT_FN(readyKey, typeof func);
1182
1182
  }
1183
- return instance.ready(func ? encapsulateThreeParam(func, this) : void 0);
1183
+ return instance2.ready(func ? encapsulateThreeParam(func, this) : void 0);
1184
1184
  };
1185
1185
  if (server[onCloseKey]) {
1186
1186
  throw new AVV_ERR_EXPOSE_ALREADY_DEFINED(onCloseKey, "onClose");
@@ -1189,7 +1189,7 @@ var require_avvio = __commonJS({
1189
1189
  if (typeof func !== "function") {
1190
1190
  throw new AVV_ERR_CALLBACK_NOT_FN(onCloseKey, typeof func);
1191
1191
  }
1192
- instance.onClose(encapsulateTwoParam(func, this));
1192
+ instance2.onClose(encapsulateTwoParam(func, this));
1193
1193
  return this;
1194
1194
  };
1195
1195
  if (server[closeKey]) {
@@ -1200,15 +1200,15 @@ var require_avvio = __commonJS({
1200
1200
  throw new AVV_ERR_CALLBACK_NOT_FN(closeKey, typeof func);
1201
1201
  }
1202
1202
  if (func) {
1203
- instance.close(encapsulateThreeParam(func, this));
1203
+ instance2.close(encapsulateThreeParam(func, this));
1204
1204
  return this;
1205
1205
  }
1206
- return instance.close();
1206
+ return instance2.close();
1207
1207
  };
1208
1208
  if (server.then) {
1209
1209
  throw new AVV_ERR_ATTRIBUTE_ALREADY_DEFINED("then");
1210
1210
  }
1211
- Object.defineProperty(server, "then", { get: thenify.bind(instance) });
1211
+ Object.defineProperty(server, "then", { get: thenify.bind(instance2) });
1212
1212
  server[kAvvio] = true;
1213
1213
  };
1214
1214
  Boot.prototype.after = function(func) {
@@ -1293,7 +1293,7 @@ var require_avvio = __commonJS({
1293
1293
  return this.pluginTree.toJSON();
1294
1294
  };
1295
1295
  Boot.prototype._loadPlugin = function(plugin, callback) {
1296
- const instance = this;
1296
+ const instance2 = this;
1297
1297
  if (isPromiseLike(plugin.func)) {
1298
1298
  plugin.func.then((fn) => {
1299
1299
  if (typeof fn.default === "function") {
@@ -1304,17 +1304,17 @@ var require_avvio = __commonJS({
1304
1304
  }, callback);
1305
1305
  return;
1306
1306
  }
1307
- const last = instance._current[0];
1308
- instance._current.unshift(plugin);
1309
- if (instance._error && !plugin.isAfter) {
1307
+ const last = instance2._current[0];
1308
+ instance2._current.unshift(plugin);
1309
+ if (instance2._error && !plugin.isAfter) {
1310
1310
  debug("skipping loading of plugin as instance errored and it is not an after", plugin.name);
1311
1311
  process.nextTick(execCallback);
1312
1312
  return;
1313
1313
  }
1314
- let server = last?.server || instance._server;
1314
+ let server = last?.server || instance2._server;
1315
1315
  if (!plugin.isAfter) {
1316
1316
  try {
1317
- server = instance.override(server, plugin.func, plugin.options);
1317
+ server = instance2.override(server, plugin.func, plugin.options);
1318
1318
  } catch (overrideErr) {
1319
1319
  debug("override errored", plugin.name);
1320
1320
  return execCallback(overrideErr);
@@ -1323,7 +1323,7 @@ var require_avvio = __commonJS({
1323
1323
  plugin.exec(server, execCallback);
1324
1324
  function execCallback(err) {
1325
1325
  plugin.finish(err, (err2) => {
1326
- instance._current.shift();
1326
+ instance2._current.shift();
1327
1327
  callback(err2);
1328
1328
  });
1329
1329
  }
@@ -2672,11 +2672,11 @@ var require_promise = __commonJS({
2672
2672
  var require_server = __commonJS({
2673
2673
  "node_modules/fastify/lib/server.js"(exports, module) {
2674
2674
  "use strict";
2675
- var http = __require("node:http");
2675
+ var http3 = __require("node:http");
2676
2676
  var https = __require("node:https");
2677
- var http2 = __require("node:http2");
2677
+ var http22 = __require("node:http2");
2678
2678
  var dns = __require("node:dns");
2679
- var os = __require("node:os");
2679
+ var os2 = __require("node:os");
2680
2680
  var { kState, kOptions, kServerBindings, kHttp2ServerSessions } = require_symbols2();
2681
2681
  var { FSTWRN003 } = require_warnings();
2682
2682
  var { onListenHookRunner } = require_hooks();
@@ -2917,7 +2917,7 @@ var require_server = __commonJS({
2917
2917
  }
2918
2918
  const httpsOptions = options.https === true ? {} : options.https;
2919
2919
  if (options.http2) {
2920
- const server2 = typeof httpsOptions === "object" ? http2.createSecureServer(httpsOptions, httpHandler) : http2.createServer(options.http, httpHandler);
2920
+ const server2 = typeof httpsOptions === "object" ? http22.createSecureServer(httpsOptions, httpHandler) : http22.createServer(options.http, httpHandler);
2921
2921
  server2.on("session", (session) => session.setTimeout(options.http2SessionTimeout, () => {
2922
2922
  session.close();
2923
2923
  }));
@@ -2927,7 +2927,7 @@ var require_server = __commonJS({
2927
2927
  server2.setTimeout(options.connectionTimeout);
2928
2928
  return server2;
2929
2929
  }
2930
- const server = httpsOptions ? https.createServer(httpsOptions, httpHandler) : http.createServer(options.http, httpHandler);
2930
+ const server = httpsOptions ? https.createServer(httpsOptions, httpHandler) : http3.createServer(options.http, httpHandler);
2931
2931
  server.keepAliveTimeout = options.keepAliveTimeout;
2932
2932
  server.requestTimeout = options.requestTimeout;
2933
2933
  server.setTimeout(options.connectionTimeout);
@@ -2938,7 +2938,7 @@ var require_server = __commonJS({
2938
2938
  }
2939
2939
  function getAddresses(address) {
2940
2940
  if (address.address === "0.0.0.0") {
2941
- return Object.values(os.networkInterfaces()).flatMap((iface) => {
2941
+ return Object.values(os2.networkInterfaces()).flatMap((iface) => {
2942
2942
  return iface.filter((iface2) => iface2.family === "IPv4");
2943
2943
  }).sort((iface) => {
2944
2944
  return iface.internal ? -1 : 1;
@@ -6124,8 +6124,8 @@ var require_req = __commonJS({
6124
6124
  if (req.originalUrl) {
6125
6125
  _req.url = req.originalUrl;
6126
6126
  } else {
6127
- const path3 = req.path;
6128
- _req.url = typeof path3 === "string" ? path3 : req.url ? req.url.path || req.url : void 0;
6127
+ const path4 = req.path;
6128
+ _req.url = typeof path4 === "string" ? path4 : 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(path3) {
6293
+ function parsePath(path4) {
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 < path3.length; i++) {
6300
- const char = path3[i];
6299
+ for (let i = 0; i < path4.length; i++) {
6300
+ const char = path4[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 path3 of paths) {
6432
- const parts = parsePath(path3);
6431
+ for (const path4 of paths) {
6432
+ const parts = parsePath(path4);
6433
6433
  if (parts.includes("*")) {
6434
- redactWildcardPath(obj, parts, censor, path3, remove);
6434
+ redactWildcardPath(obj, parts, censor, path4, 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, path3) => {
6520
- const fullPath = [...pathArray.slice(0, pathLength), ...path3];
6519
+ const wrappedCensor = typeof censor === "function" ? (value, path4) => {
6520
+ const fullPath = [...pathArray.slice(0, pathLength), ...path4];
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 path3 of pathsToClone) {
6556
- const parts = parsePath(path3);
6555
+ for (const path4 of pathsToClone) {
6556
+ const parts = parsePath(path4);
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(path3) {
6609
- if (typeof path3 !== "string") {
6608
+ function validatePath(path4) {
6609
+ if (typeof path4 !== "string") {
6610
6610
  throw new Error("Paths must be (non-empty) strings");
6611
6611
  }
6612
- if (path3 === "") {
6612
+ if (path4 === "") {
6613
6613
  throw new Error("Invalid redaction path ()");
6614
6614
  }
6615
- if (path3.includes("..")) {
6616
- throw new Error(`Invalid redaction path (${path3})`);
6615
+ if (path4.includes("..")) {
6616
+ throw new Error(`Invalid redaction path (${path4})`);
6617
6617
  }
6618
- if (path3.includes(",")) {
6619
- throw new Error(`Invalid redaction path (${path3})`);
6618
+ if (path4.includes(",")) {
6619
+ throw new Error(`Invalid redaction path (${path4})`);
6620
6620
  }
6621
6621
  let bracketCount = 0;
6622
6622
  let inQuotes = false;
6623
6623
  let quoteChar = "";
6624
- for (let i = 0; i < path3.length; i++) {
6625
- const char = path3[i];
6624
+ for (let i = 0; i < path4.length; i++) {
6625
+ const char = path4[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 (${path3})`);
6639
+ throw new Error(`Invalid redaction path (${path4})`);
6640
6640
  }
6641
6641
  }
6642
6642
  }
6643
6643
  if (bracketCount !== 0) {
6644
- throw new Error(`Invalid redaction path (${path3})`);
6644
+ throw new Error(`Invalid redaction path (${path4})`);
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 path3 of paths) {
6652
- validatePath(path3);
6651
+ for (const path4 of paths) {
6652
+ validatePath(path4);
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, path3) => {
6821
- return censor(value, [k, ...path3]);
6820
+ const wrappedCensor = typeof censor === "function" ? (value, path4) => {
6821
+ return censor(value, [k, ...path4]);
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 fs = __require("fs");
7040
7040
  var EventEmitter2 = __require("events");
7041
7041
  var inherits = __require("util").inherits;
7042
- var path3 = __require("path");
7042
+ var path4 = __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) fs.mkdirSync(path3.dirname(file), { recursive: true });
7096
+ if (sonic.mkdir) fs.mkdirSync(path4.dirname(file), { recursive: true });
7097
7097
  const fd = fs.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
- fs.mkdir(path3.dirname(file), { recursive: true }, (err) => {
7104
+ fs.mkdir(path4.dirname(file), { recursive: true }, (err) => {
7105
7105
  if (err) return fileOpened(err);
7106
7106
  fs.open(file, flags, mode, fileOpened);
7107
7107
  });
@@ -7113,7 +7113,7 @@ var require_sonic_boom = __commonJS({
7113
7113
  if (!(this instanceof SonicBoom)) {
7114
7114
  return new SonicBoom(opts);
7115
7115
  }
7116
- let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
7116
+ let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir: mkdir2, retryEAGAIN, fsync, contentMode, mode } = opts || {};
7117
7117
  fd = fd || dest;
7118
7118
  this._len = 0;
7119
7119
  this.fd = -1;
@@ -7138,7 +7138,7 @@ var require_sonic_boom = __commonJS({
7138
7138
  this.append = append || false;
7139
7139
  this.mode = mode;
7140
7140
  this.retryEAGAIN = retryEAGAIN || (() => true);
7141
- this.mkdir = mkdir || false;
7141
+ this.mkdir = mkdir2 || false;
7142
7142
  let fsWriteSync;
7143
7143
  let fsWrite;
7144
7144
  if (contentMode === kContentModeBuffer) {
@@ -7850,7 +7850,7 @@ var require_thread_stream = __commonJS({
7850
7850
  var { version } = require_package();
7851
7851
  var { EventEmitter: EventEmitter2 } = __require("events");
7852
7852
  var { Worker } = __require("worker_threads");
7853
- var { join: join2 } = __require("path");
7853
+ var { join: join3 } = __require("path");
7854
7854
  var { pathToFileURL } = __require("url");
7855
7855
  var { wait } = require_wait();
7856
7856
  var {
@@ -7901,7 +7901,7 @@ var require_thread_stream = __commonJS({
7901
7901
  function createWorker(stream, opts) {
7902
7902
  const { filename, workerData } = opts;
7903
7903
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
7904
- const toExecute = bundlerOverrides["thread-stream-worker"] || join2(__dirname, "lib", "worker.js");
7904
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join3(__dirname, "lib", "worker.js");
7905
7905
  const worker = new Worker(toExecute, {
7906
7906
  ...opts.workerOpts,
7907
7907
  name: opts.workerOpts?.name || "thread-stream",
@@ -8367,9 +8367,9 @@ var require_transport = __commonJS({
8367
8367
  "node_modules/pino/lib/transport.js"(exports, module) {
8368
8368
  "use strict";
8369
8369
  var { createRequire } = __require("module");
8370
- var { existsSync } = __require("node:fs");
8370
+ var { existsSync: existsSync2 } = __require("node:fs");
8371
8371
  var getCallers = require_caller();
8372
- var { join: join2, isAbsolute, sep } = __require("node:path");
8372
+ var { join: join3, isAbsolute, sep } = __require("node:path");
8373
8373
  var { fileURLToPath } = __require("node:url");
8374
8374
  var sleep = require_atomic_sleep();
8375
8375
  var onExit = require_on_exit_leak_free();
@@ -8433,15 +8433,15 @@ var require_transport = __commonJS({
8433
8433
  if (!unquoted) {
8434
8434
  return false;
8435
8435
  }
8436
- let path3 = unquoted;
8437
- if (path3.startsWith("file://")) {
8436
+ let path4 = unquoted;
8437
+ if (path4.startsWith("file://")) {
8438
8438
  try {
8439
- path3 = fileURLToPath(path3);
8439
+ path4 = fileURLToPath(path4);
8440
8440
  } catch {
8441
8441
  return false;
8442
8442
  }
8443
8443
  }
8444
- return isAbsolute(path3) && !existsSync(path3);
8444
+ return isAbsolute(path4) && !existsSync2(path4);
8445
8445
  }
8446
8446
  function stripQuotes(value) {
8447
8447
  const first = value[0];
@@ -8522,7 +8522,7 @@ var require_transport = __commonJS({
8522
8522
  throw new Error("only one of target or targets can be specified");
8523
8523
  }
8524
8524
  if (targets) {
8525
- target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
8525
+ target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
8526
8526
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
8527
8527
  return {
8528
8528
  ...dest,
@@ -8540,7 +8540,7 @@ var require_transport = __commonJS({
8540
8540
  });
8541
8541
  });
8542
8542
  } else if (pipeline) {
8543
- target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
8543
+ target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
8544
8544
  options.pipelines = [pipeline.map((dest) => {
8545
8545
  return {
8546
8546
  ...dest,
@@ -8563,7 +8563,7 @@ var require_transport = __commonJS({
8563
8563
  return origin;
8564
8564
  }
8565
8565
  if (origin === "pino/file") {
8566
- return join2(__dirname, "..", "file.js");
8566
+ return join3(__dirname, "..", "file.js");
8567
8567
  }
8568
8568
  let fixTarget2;
8569
8569
  for (const filePath of callers) {
@@ -8766,15 +8766,15 @@ var require_tools = __commonJS({
8766
8766
  return data + propStr + msgStr + end;
8767
8767
  }
8768
8768
  }
8769
- function asChindings(instance, bindings) {
8769
+ function asChindings(instance2, bindings) {
8770
8770
  let value;
8771
- let data = instance[chindingsSym];
8772
- const stringify2 = instance[stringifySym];
8773
- const stringifySafe = instance[stringifySafeSym];
8774
- const stringifiers = instance[stringifiersSym];
8771
+ let data = instance2[chindingsSym];
8772
+ const stringify2 = instance2[stringifySym];
8773
+ const stringifySafe = instance2[stringifySafeSym];
8774
+ const stringifiers = instance2[stringifiersSym];
8775
8775
  const wildcardStringifier = stringifiers[wildcardFirstSym];
8776
- const serializers = instance[serializersSym];
8777
- const formatter = instance[formattersSym].bindings;
8776
+ const serializers = instance2[serializersSym];
8777
+ const formatter = instance2[formattersSym].bindings;
8778
8778
  bindings = formatter(bindings);
8779
8779
  for (const key in bindings) {
8780
8780
  value = bindings[key];
@@ -8827,7 +8827,7 @@ var require_tools = __commonJS({
8827
8827
  }
8828
8828
  }
8829
8829
  function createArgsNormalizer(defaultOptions) {
8830
- return function normalizeArgs(instance, caller, opts = {}, stream) {
8830
+ return function normalizeArgs(instance2, caller, opts = {}, stream) {
8831
8831
  if (typeof opts === "string") {
8832
8832
  stream = buildSafeSonicBoom({ dest: opts });
8833
8833
  opts = {};
@@ -8979,16 +8979,16 @@ var require_levels = __commonJS({
8979
8979
  o[k] = '{"level":' + Number(k);
8980
8980
  return o;
8981
8981
  }, {});
8982
- function genLsCache(instance) {
8983
- const formatter = instance[formattersSym].level;
8984
- const { labels } = instance.levels;
8982
+ function genLsCache(instance2) {
8983
+ const formatter = instance2[formattersSym].level;
8984
+ const { labels } = instance2.levels;
8985
8985
  const cache2 = {};
8986
8986
  for (const label in labels) {
8987
8987
  const level = formatter(labels[label], Number(label));
8988
8988
  cache2[label] = JSON.stringify(level).slice(0, -1);
8989
8989
  }
8990
- instance[lsCacheSym] = cache2;
8991
- return instance;
8990
+ instance2[lsCacheSym] = cache2;
8991
+ return instance2;
8992
8992
  }
8993
8993
  function isStandardLevel(level, useOnlyCustomLevels) {
8994
8994
  if (useOnlyCustomLevels) {
@@ -9233,49 +9233,49 @@ var require_proto = __commonJS({
9233
9233
  }
9234
9234
  const serializers = this[serializersSym];
9235
9235
  const formatters = this[formattersSym];
9236
- const instance = Object.create(this);
9236
+ const instance2 = Object.create(this);
9237
9237
  if (options == null) {
9238
- if (instance[formattersSym].bindings !== resetChildingsFormatter) {
9239
- instance[formattersSym] = buildFormatters(
9238
+ if (instance2[formattersSym].bindings !== resetChildingsFormatter) {
9239
+ instance2[formattersSym] = buildFormatters(
9240
9240
  formatters.level,
9241
9241
  resetChildingsFormatter,
9242
9242
  formatters.log
9243
9243
  );
9244
9244
  }
9245
- instance[chindingsSym] = asChindings(instance, bindings2);
9245
+ instance2[chindingsSym] = asChindings(instance2, bindings2);
9246
9246
  if (this.onChild !== noop) {
9247
- this.onChild(instance);
9247
+ this.onChild(instance2);
9248
9248
  }
9249
- return instance;
9249
+ return instance2;
9250
9250
  }
9251
9251
  if (options.hasOwnProperty("serializers") === true) {
9252
- instance[serializersSym] = /* @__PURE__ */ Object.create(null);
9252
+ instance2[serializersSym] = /* @__PURE__ */ Object.create(null);
9253
9253
  for (const k in serializers) {
9254
- instance[serializersSym][k] = serializers[k];
9254
+ instance2[serializersSym][k] = serializers[k];
9255
9255
  }
9256
9256
  const parentSymbols = Object.getOwnPropertySymbols(serializers);
9257
9257
  for (var i = 0; i < parentSymbols.length; i++) {
9258
9258
  const ks = parentSymbols[i];
9259
- instance[serializersSym][ks] = serializers[ks];
9259
+ instance2[serializersSym][ks] = serializers[ks];
9260
9260
  }
9261
9261
  for (const bk in options.serializers) {
9262
- instance[serializersSym][bk] = options.serializers[bk];
9262
+ instance2[serializersSym][bk] = options.serializers[bk];
9263
9263
  }
9264
9264
  const bindingsSymbols = Object.getOwnPropertySymbols(options.serializers);
9265
9265
  for (var bi = 0; bi < bindingsSymbols.length; bi++) {
9266
9266
  const bks = bindingsSymbols[bi];
9267
- instance[serializersSym][bks] = options.serializers[bks];
9267
+ instance2[serializersSym][bks] = options.serializers[bks];
9268
9268
  }
9269
- } else instance[serializersSym] = serializers;
9269
+ } else instance2[serializersSym] = serializers;
9270
9270
  if (options.hasOwnProperty("formatters")) {
9271
9271
  const { level, bindings: chindings, log } = options.formatters;
9272
- instance[formattersSym] = buildFormatters(
9272
+ instance2[formattersSym] = buildFormatters(
9273
9273
  level || formatters.level,
9274
9274
  chindings || resetChildingsFormatter,
9275
9275
  log || formatters.log
9276
9276
  );
9277
9277
  } else {
9278
- instance[formattersSym] = buildFormatters(
9278
+ instance2[formattersSym] = buildFormatters(
9279
9279
  formatters.level,
9280
9280
  resetChildingsFormatter,
9281
9281
  formatters.log
@@ -9283,27 +9283,27 @@ var require_proto = __commonJS({
9283
9283
  }
9284
9284
  if (options.hasOwnProperty("customLevels") === true) {
9285
9285
  assertNoLevelCollisions(this.levels, options.customLevels);
9286
- instance.levels = mappings(options.customLevels, instance[useOnlyCustomLevelsSym]);
9287
- genLsCache(instance);
9286
+ instance2.levels = mappings(options.customLevels, instance2[useOnlyCustomLevelsSym]);
9287
+ genLsCache(instance2);
9288
9288
  }
9289
9289
  if (typeof options.redact === "object" && options.redact !== null || Array.isArray(options.redact)) {
9290
- instance.redact = options.redact;
9291
- const stringifiers = redaction(instance.redact, stringify);
9290
+ instance2.redact = options.redact;
9291
+ const stringifiers = redaction(instance2.redact, stringify);
9292
9292
  const formatOpts = { stringify: stringifiers[redactFmtSym] };
9293
- instance[stringifySym] = stringify;
9294
- instance[stringifiersSym] = stringifiers;
9295
- instance[formatOptsSym] = formatOpts;
9293
+ instance2[stringifySym] = stringify;
9294
+ instance2[stringifiersSym] = stringifiers;
9295
+ instance2[formatOptsSym] = formatOpts;
9296
9296
  }
9297
9297
  if (typeof options.msgPrefix === "string") {
9298
- instance[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
9298
+ instance2[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
9299
9299
  }
9300
- instance[chindingsSym] = asChindings(instance, bindings2);
9300
+ instance2[chindingsSym] = asChindings(instance2, bindings2);
9301
9301
  if (options.level !== void 0 && options.level !== this.level || options.hasOwnProperty("customLevels")) {
9302
9302
  const childLevel = options.level || this.level;
9303
- instance[setLevelSym](childLevel);
9303
+ instance2[setLevelSym](childLevel);
9304
9304
  }
9305
- this.onChild(instance);
9306
- return instance;
9305
+ this.onChild(instance2);
9306
+ return instance2;
9307
9307
  }
9308
9308
  function bindings() {
9309
9309
  const chindings = this[chindingsSym];
@@ -9543,7 +9543,7 @@ var require_safe_stable_stringify = __commonJS({
9543
9543
  return circularValue;
9544
9544
  }
9545
9545
  let res = "";
9546
- let join2 = ",";
9546
+ let join3 = ",";
9547
9547
  const originalIndentation = indentation;
9548
9548
  if (Array.isArray(value)) {
9549
9549
  if (value.length === 0) {
@@ -9557,7 +9557,7 @@ var require_safe_stable_stringify = __commonJS({
9557
9557
  indentation += spacer;
9558
9558
  res += `
9559
9559
  ${indentation}`;
9560
- join2 = `,
9560
+ join3 = `,
9561
9561
  ${indentation}`;
9562
9562
  }
9563
9563
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -9565,13 +9565,13 @@ ${indentation}`;
9565
9565
  for (; i < maximumValuesToStringify - 1; i++) {
9566
9566
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
9567
9567
  res += tmp2 !== void 0 ? tmp2 : "null";
9568
- res += join2;
9568
+ res += join3;
9569
9569
  }
9570
9570
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
9571
9571
  res += tmp !== void 0 ? tmp : "null";
9572
9572
  if (value.length - 1 > maximumBreadth) {
9573
9573
  const removedKeys = value.length - maximumBreadth - 1;
9574
- res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
9574
+ res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
9575
9575
  }
9576
9576
  if (spacer !== "") {
9577
9577
  res += `
@@ -9592,7 +9592,7 @@ ${originalIndentation}`;
9592
9592
  let separator = "";
9593
9593
  if (spacer !== "") {
9594
9594
  indentation += spacer;
9595
- join2 = `,
9595
+ join3 = `,
9596
9596
  ${indentation}`;
9597
9597
  whitespace = " ";
9598
9598
  }
@@ -9606,13 +9606,13 @@ ${indentation}`;
9606
9606
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
9607
9607
  if (tmp !== void 0) {
9608
9608
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
9609
- separator = join2;
9609
+ separator = join3;
9610
9610
  }
9611
9611
  }
9612
9612
  if (keyLength > maximumBreadth) {
9613
9613
  const removedKeys = keyLength - maximumBreadth;
9614
9614
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
9615
- separator = join2;
9615
+ separator = join3;
9616
9616
  }
9617
9617
  if (spacer !== "" && separator.length > 1) {
9618
9618
  res = `
@@ -9653,7 +9653,7 @@ ${originalIndentation}`;
9653
9653
  }
9654
9654
  const originalIndentation = indentation;
9655
9655
  let res = "";
9656
- let join2 = ",";
9656
+ let join3 = ",";
9657
9657
  if (Array.isArray(value)) {
9658
9658
  if (value.length === 0) {
9659
9659
  return "[]";
@@ -9666,7 +9666,7 @@ ${originalIndentation}`;
9666
9666
  indentation += spacer;
9667
9667
  res += `
9668
9668
  ${indentation}`;
9669
- join2 = `,
9669
+ join3 = `,
9670
9670
  ${indentation}`;
9671
9671
  }
9672
9672
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -9674,13 +9674,13 @@ ${indentation}`;
9674
9674
  for (; i < maximumValuesToStringify - 1; i++) {
9675
9675
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
9676
9676
  res += tmp2 !== void 0 ? tmp2 : "null";
9677
- res += join2;
9677
+ res += join3;
9678
9678
  }
9679
9679
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
9680
9680
  res += tmp !== void 0 ? tmp : "null";
9681
9681
  if (value.length - 1 > maximumBreadth) {
9682
9682
  const removedKeys = value.length - maximumBreadth - 1;
9683
- res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
9683
+ res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
9684
9684
  }
9685
9685
  if (spacer !== "") {
9686
9686
  res += `
@@ -9693,7 +9693,7 @@ ${originalIndentation}`;
9693
9693
  let whitespace = "";
9694
9694
  if (spacer !== "") {
9695
9695
  indentation += spacer;
9696
- join2 = `,
9696
+ join3 = `,
9697
9697
  ${indentation}`;
9698
9698
  whitespace = " ";
9699
9699
  }
@@ -9702,7 +9702,7 @@ ${indentation}`;
9702
9702
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
9703
9703
  if (tmp !== void 0) {
9704
9704
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
9705
- separator = join2;
9705
+ separator = join3;
9706
9706
  }
9707
9707
  }
9708
9708
  if (spacer !== "" && separator.length > 1) {
@@ -9760,20 +9760,20 @@ ${originalIndentation}`;
9760
9760
  indentation += spacer;
9761
9761
  let res2 = `
9762
9762
  ${indentation}`;
9763
- const join3 = `,
9763
+ const join4 = `,
9764
9764
  ${indentation}`;
9765
9765
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
9766
9766
  let i = 0;
9767
9767
  for (; i < maximumValuesToStringify - 1; i++) {
9768
9768
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
9769
9769
  res2 += tmp2 !== void 0 ? tmp2 : "null";
9770
- res2 += join3;
9770
+ res2 += join4;
9771
9771
  }
9772
9772
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
9773
9773
  res2 += tmp !== void 0 ? tmp : "null";
9774
9774
  if (value.length - 1 > maximumBreadth) {
9775
9775
  const removedKeys = value.length - maximumBreadth - 1;
9776
- res2 += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
9776
+ res2 += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
9777
9777
  }
9778
9778
  res2 += `
9779
9779
  ${originalIndentation}`;
@@ -9789,16 +9789,16 @@ ${originalIndentation}`;
9789
9789
  return '"[Object]"';
9790
9790
  }
9791
9791
  indentation += spacer;
9792
- const join2 = `,
9792
+ const join3 = `,
9793
9793
  ${indentation}`;
9794
9794
  let res = "";
9795
9795
  let separator = "";
9796
9796
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
9797
9797
  if (isTypedArrayWithEntries(value)) {
9798
- res += stringifyTypedArray(value, join2, maximumBreadth);
9798
+ res += stringifyTypedArray(value, join3, maximumBreadth);
9799
9799
  keys = keys.slice(value.length);
9800
9800
  maximumPropertiesToStringify -= value.length;
9801
- separator = join2;
9801
+ separator = join3;
9802
9802
  }
9803
9803
  if (deterministic) {
9804
9804
  keys = sort(keys, comparator);
@@ -9809,13 +9809,13 @@ ${indentation}`;
9809
9809
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
9810
9810
  if (tmp !== void 0) {
9811
9811
  res += `${separator}${strEscape(key2)}: ${tmp}`;
9812
- separator = join2;
9812
+ separator = join3;
9813
9813
  }
9814
9814
  }
9815
9815
  if (keyLength > maximumBreadth) {
9816
9816
  const removedKeys = keyLength - maximumBreadth;
9817
9817
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
9818
- separator = join2;
9818
+ separator = join3;
9819
9819
  }
9820
9820
  if (separator !== "") {
9821
9821
  res = `
@@ -10135,7 +10135,7 @@ var require_multistream = __commonJS({
10135
10135
  var require_pino = __commonJS({
10136
10136
  "node_modules/pino/pino.js"(exports, module) {
10137
10137
  "use strict";
10138
- var os = __require("node:os");
10138
+ var os2 = __require("node:os");
10139
10139
  var stdSerializers = require_pino_std_serializers();
10140
10140
  var caller = require_caller();
10141
10141
  var redaction = require_redaction();
@@ -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 = os.hostname();
10185
+ var hostname = os2.hostname();
10186
10186
  var defaultErrorSerializer = stdSerializers.err;
10187
10187
  var defaultOptions = {
10188
10188
  level: "info",
@@ -10219,8 +10219,8 @@ var require_pino = __commonJS({
10219
10219
  var normalize = createArgsNormalizer(defaultOptions);
10220
10220
  var serializers = Object.assign(/* @__PURE__ */ Object.create(null), stdSerializers);
10221
10221
  function pino(...args) {
10222
- const instance = {};
10223
- const { opts, stream } = normalize(instance, caller(), ...args);
10222
+ const instance2 = {};
10223
+ const { opts, stream } = normalize(instance2, caller(), ...args);
10224
10224
  if (opts.level && typeof opts.level === "string" && DEFAULT_LEVELS[opts.level.toLowerCase()] !== void 0) opts.level = opts.level.toLowerCase();
10225
10225
  const {
10226
10226
  redact,
@@ -10288,7 +10288,7 @@ var require_pino = __commonJS({
10288
10288
  }
10289
10289
  assertLevelComparison(levelComparison);
10290
10290
  const levelCompFunc = genLevelComparison(levelComparison);
10291
- Object.assign(instance, {
10291
+ Object.assign(instance2, {
10292
10292
  levels,
10293
10293
  [levelCompSym]: levelCompFunc,
10294
10294
  [useOnlyCustomLevelsSym]: useOnlyCustomLevels,
@@ -10315,10 +10315,10 @@ var require_pino = __commonJS({
10315
10315
  onChild,
10316
10316
  [msgPrefixSym]: msgPrefix
10317
10317
  });
10318
- Object.setPrototypeOf(instance, proto());
10319
- genLsCache(instance);
10320
- instance[setLevelSym](level);
10321
- return instance;
10318
+ Object.setPrototypeOf(instance2, proto());
10319
+ genLsCache(instance2);
10320
+ instance2[setLevelSym](level);
10321
+ return instance2;
10322
10322
  }
10323
10323
  module.exports = pino;
10324
10324
  module.exports.destination = (dest = process.stdout.fd) => {
@@ -11048,18 +11048,18 @@ var require_decorate = __commonJS({
11048
11048
  FST_ERR_DEC_DEPENDENCY_INVALID_TYPE,
11049
11049
  FST_ERR_DEC_UNDECLARED
11050
11050
  } = require_errors2();
11051
- function decorate(instance, name, fn, dependencies) {
11052
- if (Object.hasOwn(instance, name)) {
11051
+ function decorate(instance2, name, fn, dependencies) {
11052
+ if (Object.hasOwn(instance2, name)) {
11053
11053
  throw new FST_ERR_DEC_ALREADY_PRESENT(name);
11054
11054
  }
11055
- checkDependencies(instance, name, dependencies);
11055
+ checkDependencies(instance2, name, dependencies);
11056
11056
  if (fn && (typeof fn.getter === "function" || typeof fn.setter === "function")) {
11057
- Object.defineProperty(instance, name, {
11057
+ Object.defineProperty(instance2, name, {
11058
11058
  get: fn.getter,
11059
11059
  set: fn.setter
11060
11060
  });
11061
11061
  } else {
11062
- instance[name] = fn;
11062
+ instance2[name] = fn;
11063
11063
  }
11064
11064
  }
11065
11065
  function getInstanceDecorator(name) {
@@ -11072,19 +11072,19 @@ var require_decorate = __commonJS({
11072
11072
  return this[name];
11073
11073
  }
11074
11074
  function decorateConstructor(konstructor, name, fn, dependencies) {
11075
- const instance = konstructor.prototype;
11076
- if (Object.hasOwn(instance, name) || hasKey(konstructor, name) || hasInstanceProperty(konstructor, name)) {
11075
+ const instance2 = konstructor.prototype;
11076
+ if (Object.hasOwn(instance2, name) || hasKey(konstructor, name) || hasInstanceProperty(konstructor, name)) {
11077
11077
  throw new FST_ERR_DEC_ALREADY_PRESENT(name);
11078
11078
  }
11079
11079
  konstructor[kHasBeenDecorated] = true;
11080
11080
  checkDependencies(konstructor, name, dependencies);
11081
11081
  if (fn && (typeof fn.getter === "function" || typeof fn.setter === "function")) {
11082
- Object.defineProperty(instance, name, {
11082
+ Object.defineProperty(instance2, name, {
11083
11083
  get: fn.getter,
11084
11084
  set: fn.setter
11085
11085
  });
11086
11086
  } else if (typeof fn === "function") {
11087
- instance[name] = fn;
11087
+ instance2[name] = fn;
11088
11088
  } else {
11089
11089
  konstructor.props.push({ key: name, value: fn });
11090
11090
  }
@@ -11099,11 +11099,11 @@ var require_decorate = __commonJS({
11099
11099
  decorate(this, name, fn, dependencies);
11100
11100
  return this;
11101
11101
  }
11102
- function checkExistence(instance, name) {
11102
+ function checkExistence(instance2, name) {
11103
11103
  if (name) {
11104
- return name in instance || instance.prototype && name in instance.prototype || hasKey(instance, name);
11104
+ return name in instance2 || instance2.prototype && name in instance2.prototype || hasKey(instance2, name);
11105
11105
  }
11106
- return instance in this;
11106
+ return instance2 in this;
11107
11107
  }
11108
11108
  function hasKey(fn, name) {
11109
11109
  return fn.props ? fn.props.some((p) => p.key === name) : false;
@@ -11126,7 +11126,7 @@ var require_decorate = __commonJS({
11126
11126
  if (name && hasInstanceProperty(this[kReply], name)) return true;
11127
11127
  return checkExistence(this[kReply].prototype, name);
11128
11128
  }
11129
- function checkDependencies(instance, name, deps) {
11129
+ function checkDependencies(instance2, name, deps) {
11130
11130
  if (deps === void 0 || deps === null) {
11131
11131
  return;
11132
11132
  }
@@ -11134,7 +11134,7 @@ var require_decorate = __commonJS({
11134
11134
  throw new FST_ERR_DEC_DEPENDENCY_INVALID_TYPE(name);
11135
11135
  }
11136
11136
  for (let i = 0; i !== deps.length; ++i) {
11137
- if (!checkExistence(instance, deps[i]) && !hasInstanceProperty(instance, deps[i])) {
11137
+ if (!checkExistence(instance2, deps[i]) && !hasInstanceProperty(instance2, deps[i])) {
11138
11138
  throw new FST_ERR_DEC_MISSING_DEPENDENCY(deps[i]);
11139
11139
  }
11140
11140
  }
@@ -11151,8 +11151,8 @@ var require_decorate = __commonJS({
11151
11151
  decorateConstructor(this[kRequest], name, fn, dependencies);
11152
11152
  return this;
11153
11153
  }
11154
- function assertNotStarted(instance, name) {
11155
- if (instance[kState].started) {
11154
+ function assertNotStarted(instance2, name) {
11155
+ if (instance2[kState].started) {
11156
11156
  throw new FST_ERR_DEC_AFTER_START(name);
11157
11157
  }
11158
11158
  }
@@ -17117,8 +17117,8 @@ var require_utils = __commonJS({
17117
17117
  }
17118
17118
  return ind;
17119
17119
  }
17120
- function removeDotSegments(path3) {
17121
- let input = path3;
17120
+ function removeDotSegments(path4) {
17121
+ let input = path4;
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 [path3, query2] = wsComponent.resourceName.split("?");
17374
- wsComponent.path = path3 && path3 !== "/" ? path3 : void 0;
17373
+ const [path4, query2] = wsComponent.resourceName.split("?");
17374
+ wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
17375
17375
  wsComponent.query = query2;
17376
17376
  wsComponent.resourceName = void 0;
17377
17377
  }
@@ -17430,7 +17430,7 @@ var require_schemes = __commonJS({
17430
17430
  urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
17431
17431
  return urnComponent;
17432
17432
  }
17433
- var http = (
17433
+ var http3 = (
17434
17434
  /** @type {SchemeHandler} */
17435
17435
  {
17436
17436
  scheme: "http",
@@ -17443,7 +17443,7 @@ var require_schemes = __commonJS({
17443
17443
  /** @type {SchemeHandler} */
17444
17444
  {
17445
17445
  scheme: "https",
17446
- domainHost: http.domainHost,
17446
+ domainHost: http3.domainHost,
17447
17447
  parse: httpParse,
17448
17448
  serialize: httpSerialize
17449
17449
  }
@@ -17487,7 +17487,7 @@ var require_schemes = __commonJS({
17487
17487
  var SCHEMES = (
17488
17488
  /** @type {Record<SchemeName, SchemeHandler>} */
17489
17489
  {
17490
- http,
17490
+ http: http3,
17491
17491
  https,
17492
17492
  ws,
17493
17493
  wss: wss2,
@@ -22308,8 +22308,8 @@ var require_utils2 = __commonJS({
22308
22308
  }
22309
22309
  return ind;
22310
22310
  }
22311
- function removeDotSegments(path3) {
22312
- let input = path3;
22311
+ function removeDotSegments(path4) {
22312
+ let input = path4;
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 [path3, query2] = wsComponent.resourceName.split("?");
22658
- wsComponent.path = path3 && path3 !== "/" ? path3 : void 0;
22657
+ const [path4, query2] = wsComponent.resourceName.split("?");
22658
+ wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
22659
22659
  wsComponent.query = query2;
22660
22660
  wsComponent.resourceName = void 0;
22661
22661
  }
@@ -22714,7 +22714,7 @@ var require_schemes2 = __commonJS({
22714
22714
  urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
22715
22715
  return urnComponent;
22716
22716
  }
22717
- var http = (
22717
+ var http3 = (
22718
22718
  /** @type {SchemeHandler} */
22719
22719
  {
22720
22720
  scheme: "http",
@@ -22727,7 +22727,7 @@ var require_schemes2 = __commonJS({
22727
22727
  /** @type {SchemeHandler} */
22728
22728
  {
22729
22729
  scheme: "https",
22730
- domainHost: http.domainHost,
22730
+ domainHost: http3.domainHost,
22731
22731
  parse: httpParse,
22732
22732
  serialize: httpSerialize
22733
22733
  }
@@ -22771,7 +22771,7 @@ var require_schemes2 = __commonJS({
22771
22771
  var SCHEMES = (
22772
22772
  /** @type {Record<SchemeName, SchemeHandler>} */
22773
22773
  {
22774
- http,
22774
+ http: http3,
22775
22775
  https,
22776
22776
  ws,
22777
22777
  wss: wss2,
@@ -24139,8 +24139,8 @@ var require_utils3 = __commonJS({
24139
24139
  }
24140
24140
  return ind;
24141
24141
  }
24142
- function removeDotSegments(path3) {
24143
- let input = path3;
24142
+ function removeDotSegments(path4) {
24143
+ let input = path4;
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 [path3, query2] = wsComponent.resourceName.split("?");
24489
- wsComponent.path = path3 && path3 !== "/" ? path3 : void 0;
24488
+ const [path4, query2] = wsComponent.resourceName.split("?");
24489
+ wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
24490
24490
  wsComponent.query = query2;
24491
24491
  wsComponent.resourceName = void 0;
24492
24492
  }
@@ -24545,7 +24545,7 @@ var require_schemes3 = __commonJS({
24545
24545
  urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
24546
24546
  return urnComponent;
24547
24547
  }
24548
- var http = (
24548
+ var http3 = (
24549
24549
  /** @type {SchemeHandler} */
24550
24550
  {
24551
24551
  scheme: "http",
@@ -24558,7 +24558,7 @@ var require_schemes3 = __commonJS({
24558
24558
  /** @type {SchemeHandler} */
24559
24559
  {
24560
24560
  scheme: "https",
24561
- domainHost: http.domainHost,
24561
+ domainHost: http3.domainHost,
24562
24562
  parse: httpParse,
24563
24563
  serialize: httpSerialize
24564
24564
  }
@@ -24602,7 +24602,7 @@ var require_schemes3 = __commonJS({
24602
24602
  var SCHEMES = (
24603
24603
  /** @type {Record<SchemeName, SchemeHandler>} */
24604
24604
  {
24605
- http,
24605
+ http: http3,
24606
24606
  https,
24607
24607
  ws,
24608
24608
  wss: wss2,
@@ -29958,12 +29958,12 @@ var require_plugin_utils = __commonJS({
29958
29958
  Request: existRequest,
29959
29959
  Reply: existReply
29960
29960
  };
29961
- function _checkDecorators(that, instance, decorators, name) {
29961
+ function _checkDecorators(that, instance2, decorators, name) {
29962
29962
  assert(Array.isArray(decorators), "The decorators should be an array of strings");
29963
29963
  decorators.forEach((decorator) => {
29964
29964
  const withPluginName = typeof name === "string" ? ` required by '${name}'` : "";
29965
- if (!checks[instance].call(that, decorator)) {
29966
- throw new FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE(decorator, withPluginName, instance);
29965
+ if (!checks[instance2].call(that, decorator)) {
29966
+ throw new FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE(decorator, withPluginName, instance2);
29967
29967
  }
29968
29968
  });
29969
29969
  }
@@ -32003,13 +32003,13 @@ var require_node = __commonJS({
32003
32003
  this.staticChildrenNodes[index] = node;
32004
32004
  }
32005
32005
  }
32006
- findStaticMatchingChild(path3, pathIndex) {
32007
- const charCode = path3.charCodeAt(pathIndex);
32006
+ findStaticMatchingChild(path4, pathIndex) {
32007
+ const charCode = path4.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(path3, pathIndex)) {
32012
+ if (staticChild.matchPrefix(path4, 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(path3, pathIndex = 0) {
32021
- if (path3.length === pathIndex) {
32020
+ getStaticChild(path4, pathIndex = 0) {
32021
+ if (path4.length === pathIndex) {
32022
32022
  return this;
32023
32023
  }
32024
- const staticChild = this.findStaticMatchingChild(path3, pathIndex);
32024
+ const staticChild = this.findStaticMatchingChild(path4, pathIndex);
32025
32025
  if (staticChild) {
32026
- return staticChild.getStaticChild(path3, pathIndex + staticChild.prefix.length);
32026
+ return staticChild.getStaticChild(path4, pathIndex + staticChild.prefix.length);
32027
32027
  }
32028
32028
  return null;
32029
32029
  }
32030
- createStaticChild(path3) {
32031
- if (path3.length === 0) {
32030
+ createStaticChild(path4) {
32031
+ if (path4.length === 0) {
32032
32032
  return this;
32033
32033
  }
32034
- const childIndex = this.staticChildrenCharCodes.indexOf(path3.charCodeAt(0));
32034
+ const childIndex = this.staticChildrenCharCodes.indexOf(path4.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 (path3.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
32039
+ if (path4.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
32040
32040
  staticChild = staticChild.split(this, i);
32041
32041
  break;
32042
32042
  }
32043
32043
  }
32044
- return staticChild.createStaticChild(path3.slice(i));
32044
+ return staticChild.createStaticChild(path4.slice(i));
32045
32045
  }
32046
- const node = new StaticNode(path3);
32047
- this.setStaticChild(path3.charAt(0), node);
32046
+ const node = new StaticNode(path4);
32047
+ this.setStaticChild(path4.charAt(0), node);
32048
32048
  return node;
32049
32049
  }
32050
32050
  };
@@ -32104,8 +32104,8 @@ var require_node = __commonJS({
32104
32104
  parentNode.setStaticChild(parentPrefix.charAt(0), staticNode);
32105
32105
  return staticNode;
32106
32106
  }
32107
- getNextNode(path3, pathIndex, nodeStack, paramsCount) {
32108
- let node = this.findStaticMatchingChild(path3, pathIndex);
32107
+ getNextNode(path4, pathIndex, nodeStack, paramsCount) {
32108
+ let node = this.findStaticMatchingChild(path4, pathIndex);
32109
32109
  let parametricBrotherNodeIndex = 0;
32110
32110
  if (node === null) {
32111
32111
  if (this.parametricChildren.length === 0) {
@@ -32152,8 +32152,8 @@ var require_node = __commonJS({
32152
32152
  this.kind = NODE_TYPES.PARAMETRIC;
32153
32153
  this.nodePaths = /* @__PURE__ */ new Set([nodePath]);
32154
32154
  }
32155
- getNextNode(path3, pathIndex) {
32156
- return this.findStaticMatchingChild(path3, pathIndex);
32155
+ getNextNode(path4, pathIndex) {
32156
+ return this.findStaticMatchingChild(path4, 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(path3, useSemicolonDelimiter) {
32513
- if (path3.length >= MIN_NATIVE_SCAN_LENGTH) {
32514
- return safeDecodeURINativeScan(path3, useSemicolonDelimiter);
32512
+ function safeDecodeURI(path4, useSemicolonDelimiter) {
32513
+ if (path4.length >= MIN_NATIVE_SCAN_LENGTH) {
32514
+ return safeDecodeURINativeScan(path4, useSemicolonDelimiter);
32515
32515
  }
32516
- return safeDecodeURICharScan(path3, useSemicolonDelimiter, 1);
32516
+ return safeDecodeURICharScan(path4, useSemicolonDelimiter, 1);
32517
32517
  }
32518
- function safeDecodeURINativeScan(path3, useSemicolonDelimiter) {
32519
- const percentIndex = path3.indexOf("%", 1);
32520
- let delimIndex = path3.indexOf("?", 1);
32521
- const hashIndex = path3.indexOf("#", 1);
32518
+ function safeDecodeURINativeScan(path4, useSemicolonDelimiter) {
32519
+ const percentIndex = path4.indexOf("%", 1);
32520
+ let delimIndex = path4.indexOf("?", 1);
32521
+ const hashIndex = path4.indexOf("#", 1);
32522
32522
  if (hashIndex !== -1 && (delimIndex === -1 || hashIndex < delimIndex)) {
32523
32523
  delimIndex = hashIndex;
32524
32524
  }
32525
32525
  if (useSemicolonDelimiter) {
32526
- const semicolonIndex = path3.indexOf(";", 1);
32526
+ const semicolonIndex = path4.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: path3, querystring: "", shouldDecodeParam: false };
32533
+ return { path: path4, querystring: "", shouldDecodeParam: false };
32534
32534
  }
32535
32535
  return {
32536
- path: path3.slice(0, delimIndex),
32537
- querystring: path3.slice(delimIndex + 1),
32536
+ path: path4.slice(0, delimIndex),
32537
+ querystring: path4.slice(delimIndex + 1),
32538
32538
  shouldDecodeParam: false
32539
32539
  };
32540
32540
  }
32541
- return safeDecodeURIPercentScan(path3, useSemicolonDelimiter, percentIndex);
32541
+ return safeDecodeURIPercentScan(path4, useSemicolonDelimiter, percentIndex);
32542
32542
  }
32543
- function safeDecodeURICharScan(path3, useSemicolonDelimiter, startIndex) {
32544
- for (let i = startIndex; i < path3.length; i++) {
32545
- const charCode = path3.charCodeAt(i);
32543
+ function safeDecodeURICharScan(path4, useSemicolonDelimiter, startIndex) {
32544
+ for (let i = startIndex; i < path4.length; i++) {
32545
+ const charCode = path4.charCodeAt(i);
32546
32546
  if (charCode === 37) {
32547
- return safeDecodeURIPercentScan(path3, useSemicolonDelimiter, i);
32547
+ return safeDecodeURIPercentScan(path4, useSemicolonDelimiter, i);
32548
32548
  } else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
32549
32549
  return {
32550
- path: path3.slice(0, i),
32551
- querystring: path3.slice(i + 1),
32550
+ path: path4.slice(0, i),
32551
+ querystring: path4.slice(i + 1),
32552
32552
  shouldDecodeParam: false
32553
32553
  };
32554
32554
  }
32555
32555
  }
32556
- return { path: path3, querystring: "", shouldDecodeParam: false };
32556
+ return { path: path4, querystring: "", shouldDecodeParam: false };
32557
32557
  }
32558
- function reencodePercentChar(path3, index) {
32559
- return path3.slice(0, index + 1) + "25" + path3.slice(index + 1);
32558
+ function reencodePercentChar(path4, index) {
32559
+ return path4.slice(0, index + 1) + "25" + path4.slice(index + 1);
32560
32560
  }
32561
- function safeDecodeURIPercentScan(path3, useSemicolonDelimiter, startIndex) {
32561
+ function safeDecodeURIPercentScan(path4, useSemicolonDelimiter, startIndex) {
32562
32562
  let shouldDecode = false;
32563
32563
  let shouldDecodeParam = false;
32564
32564
  let querystring = "";
32565
- for (let i = startIndex; i < path3.length; i++) {
32566
- const charCode = path3.charCodeAt(i);
32565
+ for (let i = startIndex; i < path4.length; i++) {
32566
+ const charCode = path4.charCodeAt(i);
32567
32567
  if (charCode === 37) {
32568
- const componentCharCode = decodeComponentCharCode(path3.charCodeAt(i + 1), path3.charCodeAt(i + 2));
32568
+ const componentCharCode = decodeComponentCharCode(path4.charCodeAt(i + 1), path4.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
- path3 = reencodePercentChar(path3, i);
32575
+ path4 = reencodePercentChar(path4, 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 = path3.slice(i + 1);
32582
- path3 = path3.slice(0, i);
32581
+ querystring = path4.slice(i + 1);
32582
+ path4 = path4.slice(0, i);
32583
32583
  break;
32584
32584
  }
32585
32585
  }
32586
- const decodedPath = shouldDecode ? decodeURI(path3) : path3;
32586
+ const decodedPath = shouldDecode ? decodeURI(path4) : path4;
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, path3, opts, handler, store) {
32681
+ Router.prototype.on = function on(method, path4, 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 path3 === "string", "Path should be a string");
32690
- assert(path3.length > 0, "The path could not be empty");
32691
- assert(path3[0] === "/" || path3[0] === "*", "The first character of a path should be `/` or `*`");
32689
+ assert(typeof path4 === "string", "Path should be a string");
32690
+ assert(path4.length > 0, "The path could not be empty");
32691
+ assert(path4[0] === "/" || path4[0] === "*", "The first character of a path should be `/` or `*`");
32692
32692
  assert(typeof handler === "function", "Handler should be a function");
32693
- const optionalParamMatch = path3.match(OPTIONAL_PARAM_REGEXP);
32693
+ const optionalParamMatch = path4.match(OPTIONAL_PARAM_REGEXP);
32694
32694
  if (optionalParamMatch) {
32695
- assert(path3.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32696
- const pathFull = path3.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32697
- const pathOptional = path3.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
32695
+ assert(path4.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32696
+ const pathFull = path4.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32697
+ const pathOptional = path4.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 = path3;
32702
+ const route = path4;
32703
32703
  if (this.ignoreDuplicateSlashes) {
32704
- path3 = removeDuplicateSlashes(path3);
32704
+ path4 = removeDuplicateSlashes(path4);
32705
32705
  }
32706
32706
  if (this.ignoreTrailingSlash) {
32707
- path3 = trimLastSlash(path3);
32707
+ path4 = trimLastSlash(path4);
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, path3, opts, handler, store, route);
32713
+ this._on(method2, path4, opts, handler, store, route);
32714
32714
  }
32715
32715
  };
32716
- Router.prototype._on = function _on(method, path3, opts, handler, store) {
32716
+ Router.prototype._on = function _on(method, path4, 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 = path3;
32729
+ let pattern = path4;
32730
32730
  if (pattern === "*" && this.trees[method].prefix.length !== 0) {
32731
32731
  const currentRoot = this.trees[method];
32732
32732
  this.trees[method] = new StaticNode("");
@@ -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: path3, pattern, params, opts, handler, store };
32837
+ const route = { method, path: path4, 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, path3, constraints) {
32842
- const route = this.findRoute(method, path3, constraints);
32841
+ Router.prototype.hasRoute = function hasRoute(method, path4, constraints) {
32842
+ const route = this.findRoute(method, path4, constraints);
32843
32843
  return route !== null;
32844
32844
  };
32845
- Router.prototype.findRoute = function findNode(method, path3, constraints = {}) {
32845
+ Router.prototype.findRoute = function findNode(method, path4, constraints = {}) {
32846
32846
  if (this.trees[method] === void 0) {
32847
32847
  return null;
32848
32848
  }
32849
- let pattern = path3;
32849
+ let pattern = path4;
32850
32850
  let currentNode = this.trees[method];
32851
32851
  let parentNodePathIndex = currentNode.prefix.length;
32852
32852
  const params = [];
@@ -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, path3, constraints) {
32971
- assert(typeof path3 === "string", "Path should be a string");
32972
- assert(path3.length > 0, "The path could not be empty");
32973
- assert(path3[0] === "/" || path3[0] === "*", "The first character of a path should be `/` or `*`");
32970
+ Router.prototype.off = function off(method, path4, constraints) {
32971
+ assert(typeof path4 === "string", "Path should be a string");
32972
+ assert(path4.length > 0, "The path could not be empty");
32973
+ assert(path4[0] === "/" || path4[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 = path3.match(OPTIONAL_PARAM_REGEXP);
32978
+ const optionalParamMatch = path4.match(OPTIONAL_PARAM_REGEXP);
32979
32979
  if (optionalParamMatch) {
32980
- assert(path3.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32981
- const pathFull = path3.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32982
- const pathOptional = path3.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
32980
+ assert(path4.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
32981
+ const pathFull = path4.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
32982
+ const pathOptional = path4.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
- path3 = removeDuplicateSlashes(path3);
32988
+ path4 = removeDuplicateSlashes(path4);
32989
32989
  }
32990
32990
  if (this.ignoreTrailingSlash) {
32991
- path3 = trimLastSlash(path3);
32991
+ path4 = trimLastSlash(path4);
32992
32992
  }
32993
32993
  const methods = Array.isArray(method) ? method : [method];
32994
32994
  for (const method2 of methods) {
32995
- this._off(method2, path3, constraints);
32995
+ this._off(method2, path4, constraints);
32996
32996
  }
32997
32997
  };
32998
- Router.prototype._off = function _off(method, path3, constraints) {
32998
+ Router.prototype._off = function _off(method, path4, 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 || path3 !== route.path;
33002
+ return method !== route.method || path4 !== 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, path3, derivedConstraints) {
33039
+ Router.prototype.find = function find(method, path4, derivedConstraints) {
33040
33040
  let currentNode = method === "GET" ? this._treeGET : this.trees[method];
33041
33041
  if (currentNode == null) return null;
33042
- if (path3.charCodeAt(0) !== 47) {
33043
- path3 = path3.replace(FULL_PATH_REGEXP, "/");
33042
+ if (path4.charCodeAt(0) !== 47) {
33043
+ path4 = path4.replace(FULL_PATH_REGEXP, "/");
33044
33044
  }
33045
33045
  if (this.ignoreDuplicateSlashes) {
33046
- path3 = removeDuplicateSlashes(path3);
33046
+ path4 = removeDuplicateSlashes(path4);
33047
33047
  }
33048
33048
  let sanitizedUrl;
33049
33049
  let querystring2;
33050
33050
  let shouldDecodeParam;
33051
33051
  try {
33052
- sanitizedUrl = path3.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path3, this.useSemicolonDelimiter) : safeDecodeURICharScan(path3, this.useSemicolonDelimiter, 1);
33053
- path3 = sanitizedUrl.path;
33052
+ sanitizedUrl = path4.length >= MIN_NATIVE_SCAN_LENGTH ? safeDecodeURINativeScan(path4, this.useSemicolonDelimiter) : safeDecodeURICharScan(path4, this.useSemicolonDelimiter, 1);
33053
+ path4 = sanitizedUrl.path;
33054
33054
  querystring2 = sanitizedUrl.querystring;
33055
33055
  shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
33056
33056
  } catch (error) {
33057
- return this._onBadUrl(path3);
33057
+ return this._onBadUrl(path4);
33058
33058
  }
33059
33059
  if (this.ignoreTrailingSlash) {
33060
- path3 = trimLastSlash(path3);
33060
+ path4 = trimLastSlash(path4);
33061
33061
  }
33062
- const originPath = path3;
33062
+ const originPath = path4;
33063
33063
  if (this.caseSensitive === false) {
33064
- path3 = path3.toLowerCase();
33064
+ path4 = path4.toLowerCase();
33065
33065
  }
33066
33066
  const maxParamLength = this.maxParamLength;
33067
33067
  let pathIndex = currentNode.prefix.length;
33068
33068
  const params = [];
33069
- const pathLen = path3.length;
33069
+ const pathLen = path4.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(path3, pathIndex, brothersNodesStack, params.length);
33084
+ let node = currentNode.getNextNode(path4, 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: path3, opts, handler, store } = route;
33186
- this._on(method, path3, opts, handler, store);
33185
+ const { method, path: path4, opts, handler, store } = route;
33186
+ this._on(method, path4, 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(path3) {
33197
+ Router.prototype._onBadUrl = function(path4) {
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(path3, req, res),
33203
+ handler: (req, res, ctx) => onBadUrl(path4, req, res),
33204
33204
  params: {},
33205
33205
  store: null
33206
33206
  };
33207
33207
  };
33208
- Router.prototype._onMaxParamLength = function(path3) {
33208
+ Router.prototype._onMaxParamLength = function(path4) {
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(path3, req, res),
33214
+ handler: (req, res, ctx) => onMaxParamLength(path4, 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(path3, handler, store) {
33247
- return this.on(m, path3, handler, store);
33246
+ Router.prototype[methodName] = function(path4, handler, store) {
33247
+ return this.on(m, path4, handler, store);
33248
33248
  };
33249
33249
  }
33250
- Router.prototype.all = function(path3, handler, store) {
33251
- this.on(httpMethods, path3, handler, store);
33250
+ Router.prototype.all = function(path4, handler, store) {
33251
+ this.on(httpMethods, path4, 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(path3) {
33267
- return path3.indexOf("//") !== -1 ? path3.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path3;
33266
+ function removeDuplicateSlashes(path4) {
33267
+ return path4.indexOf("//") !== -1 ? path4.replace(REMOVE_DUPLICATE_SLASHES_REGEXP, "/") : path4;
33268
33268
  }
33269
- function trimLastSlash(path3) {
33270
- if (path3.length > 1 && path3.charCodeAt(path3.length - 1) === 47) {
33271
- return path3.slice(0, -1);
33269
+ function trimLastSlash(path4) {
33270
+ if (path4.length > 1 && path4.charCodeAt(path4.length - 1) === 47) {
33271
+ return path4.slice(0, -1);
33272
33272
  }
33273
- return path3;
33273
+ return path4;
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(path3, idx) {
33284
+ function getClosingParenthensePosition(path4, idx) {
33285
33285
  let parentheses = 1;
33286
- while (idx < path3.length) {
33286
+ while (idx < path4.length) {
33287
33287
  idx++;
33288
- if (path3.charCodeAt(idx) === 92) {
33288
+ if (path4.charCodeAt(idx) === 92) {
33289
33289
  idx++;
33290
33290
  continue;
33291
33291
  }
33292
- if (path3.charCodeAt(idx) === 41) {
33292
+ if (path4.charCodeAt(idx) === 41) {
33293
33293
  parentheses--;
33294
- } else if (path3.charCodeAt(idx) === 40) {
33294
+ } else if (path4.charCodeAt(idx) === 40) {
33295
33295
  parentheses++;
33296
33296
  }
33297
33297
  if (!parentheses) return idx;
33298
33298
  }
33299
- throw new TypeError('Invalid regexp expression in "' + path3 + '"');
33299
+ throw new TypeError('Invalid regexp expression in "' + path4 + '"');
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 path3 = opts.url || opts.path || "";
33532
+ const path4 = opts.url || opts.path || "";
33533
33533
  if (!opts.handler) {
33534
- throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path3);
33534
+ throw new FST_ERR_ROUTE_MISSING_HANDLER(opts.method, path4);
33535
33535
  }
33536
33536
  if (opts.errorHandler !== void 0 && typeof opts.errorHandler !== "function") {
33537
- throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path3);
33537
+ throw new FST_ERR_ROUTE_HANDLER_NOT_FN(opts.method, path4);
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], path3, opts.schema);
33547
+ validateSchemaBodyOption.call(this, opts.method[i], path4, 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, path3, opts.schema);
33553
+ validateSchemaBodyOption.call(this, opts.method, path4, 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 (path3 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
33559
+ if (path4 === "/" && prefix.length > 0 && opts.method !== "HEAD") {
33560
33560
  switch (opts.prefixTrailingSlash) {
33561
33561
  case "slash":
33562
- addNewRoute.call(this, { path: path3, isFastify });
33562
+ addNewRoute.call(this, { path: path4, 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: path3, prefixing: true, isFastify });
33571
+ addNewRoute.call(this, { path: path4, prefixing: true, isFastify });
33572
33572
  }
33573
33573
  }
33574
- } else if (path3[0] === "/" && prefix.endsWith("/")) {
33575
- addNewRoute.call(this, { path: path3.slice(1), isFastify });
33574
+ } else if (path4[0] === "/" && prefix.endsWith("/")) {
33575
+ addNewRoute.call(this, { path: path4.slice(1), isFastify });
33576
33576
  } else {
33577
- addNewRoute.call(this, { path: path3, isFastify });
33577
+ addNewRoute.call(this, { path: path4, isFastify });
33578
33578
  }
33579
33579
  return this;
33580
- function addNewRoute({ path: path4, prefixing = false, isFastify: isFastify2 = false }) {
33581
- const url = prefix + path4;
33580
+ function addNewRoute({ path: path5, prefixing = false, isFastify: isFastify2 = false }) {
33581
+ const url = prefix + path5;
33582
33582
  opts.url = url;
33583
33583
  opts.path = url;
33584
- opts.routePath = path4;
33584
+ opts.routePath = path5;
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: path4, options: { ...headOpts, onSend: onSendHandlers }, isFastify: true });
33716
+ prepareRoute.call(this, { method: "HEAD", url: path5, 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, path3, schema) {
33840
+ function validateSchemaBodyOption(method, path4, schema) {
33841
33841
  if (this[kSupportedHTTPMethods].bodyless.has(method) && schema?.body) {
33842
- throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path3);
33842
+ throw new FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED(method, path4);
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, path3, logger) {
33857
+ function validateLogLevelOption(logLevel, method, path4, 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, path3, logLevel);
33861
+ throw new FST_ERR_ROUTE_LOG_LEVEL_INVALID(method, path4, logLevel);
33862
33862
  }
33863
33863
  }
33864
33864
  function runPreParsing(err, request, reply) {
@@ -33930,12 +33930,12 @@ var require_four_oh_four = __commonJS({
33930
33930
  });
33931
33931
  let _routeEventHandler = null;
33932
33932
  return { router, setNotFoundHandler, setContext, arrange404 };
33933
- function arrange404(instance) {
33934
- instance[kFourOhFourLevelInstance] = instance;
33935
- instance[kCanSetNotFoundHandler] = true;
33936
- router.onBadUrl = router.onBadUrl.bind(instance);
33937
- router.onMaxParamLength = router.onMaxParamLength.bind(instance);
33938
- router.defaultRoute = router.defaultRoute.bind(instance);
33933
+ function arrange404(instance2) {
33934
+ instance2[kFourOhFourLevelInstance] = instance2;
33935
+ instance2[kCanSetNotFoundHandler] = true;
33936
+ router.onBadUrl = router.onBadUrl.bind(instance2);
33937
+ router.onMaxParamLength = router.onMaxParamLength.bind(instance2);
33938
+ router.defaultRoute = router.defaultRoute.bind(instance2);
33939
33939
  }
33940
33940
  function basic404(request, reply) {
33941
33941
  request.server[kLogController].routeNotFound(request, reply);
@@ -33947,7 +33947,7 @@ var require_four_oh_four = __commonJS({
33947
33947
  });
33948
33948
  }
33949
33949
  function createRouteEventHandler() {
33950
- return function onRouteEvent(path3, req, res) {
33950
+ return function onRouteEvent(path4, 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);
@@ -33956,8 +33956,8 @@ var require_four_oh_four = __commonJS({
33956
33956
  _routeEventHandler(request, reply);
33957
33957
  };
33958
33958
  }
33959
- function setContext(instance, context) {
33960
- const _404Context = Object.assign({}, instance[kFourOhFourContext]);
33959
+ function setContext(instance2, context) {
33960
+ const _404Context = Object.assign({}, instance2[kFourOhFourContext]);
33961
33961
  _404Context.onSend = context.onSend;
33962
33962
  context[kFourOhFourContext] = _404Context;
33963
33963
  }
@@ -34078,30 +34078,30 @@ var require_plugin_override = __commonJS({
34078
34078
  old[kPluginNameChain].push(fnName);
34079
34079
  return old;
34080
34080
  }
34081
- const instance = Object.create(old);
34082
- old[kChildren].push(instance);
34083
- instance.ready = old[kAvvioBoot].bind(instance);
34084
- instance[kChildren] = [];
34085
- instance[kReply] = Reply.buildReply(instance[kReply]);
34086
- instance[kRequest] = Request.buildRequest(instance[kRequest]);
34087
- instance[kContentTypeParser] = ContentTypeParser.helpers.buildContentTypeParser(instance[kContentTypeParser]);
34088
- instance[kHooks] = buildHooks(instance[kHooks]);
34089
- instance[kRoutePrefix] = buildRoutePrefix(instance[kRoutePrefix], opts.prefix);
34090
- instance[kLogLevel] = opts.logLevel || instance[kLogLevel];
34091
- instance[kSchemaController] = SchemaController.buildSchemaController(old[kSchemaController]);
34092
- instance.getSchema = instance[kSchemaController].getSchema.bind(instance[kSchemaController]);
34093
- instance.getSchemas = instance[kSchemaController].getSchemas.bind(instance[kSchemaController]);
34094
- instance[pluginUtils.kRegisteredPlugins] = Object.create(instance[pluginUtils.kRegisteredPlugins]);
34095
- instance[kPluginNameChain] = [fnName];
34096
- instance[kErrorHandlerAlreadySet] = false;
34097
- if (instance[kLogSerializers] || opts.logSerializers) {
34098
- instance[kLogSerializers] = Object.assign(Object.create(instance[kLogSerializers]), opts.logSerializers);
34081
+ const instance2 = Object.create(old);
34082
+ old[kChildren].push(instance2);
34083
+ instance2.ready = old[kAvvioBoot].bind(instance2);
34084
+ instance2[kChildren] = [];
34085
+ instance2[kReply] = Reply.buildReply(instance2[kReply]);
34086
+ instance2[kRequest] = Request.buildRequest(instance2[kRequest]);
34087
+ instance2[kContentTypeParser] = ContentTypeParser.helpers.buildContentTypeParser(instance2[kContentTypeParser]);
34088
+ instance2[kHooks] = buildHooks(instance2[kHooks]);
34089
+ instance2[kRoutePrefix] = buildRoutePrefix(instance2[kRoutePrefix], opts.prefix);
34090
+ instance2[kLogLevel] = opts.logLevel || instance2[kLogLevel];
34091
+ instance2[kSchemaController] = SchemaController.buildSchemaController(old[kSchemaController]);
34092
+ instance2.getSchema = instance2[kSchemaController].getSchema.bind(instance2[kSchemaController]);
34093
+ instance2.getSchemas = instance2[kSchemaController].getSchemas.bind(instance2[kSchemaController]);
34094
+ instance2[pluginUtils.kRegisteredPlugins] = Object.create(instance2[pluginUtils.kRegisteredPlugins]);
34095
+ instance2[kPluginNameChain] = [fnName];
34096
+ instance2[kErrorHandlerAlreadySet] = false;
34097
+ if (instance2[kLogSerializers] || opts.logSerializers) {
34098
+ instance2[kLogSerializers] = Object.assign(Object.create(instance2[kLogSerializers]), opts.logSerializers);
34099
34099
  }
34100
34100
  if (opts.prefix) {
34101
- instance[kFourOhFour].arrange404(instance);
34101
+ instance2[kFourOhFour].arrange404(instance2);
34102
34102
  }
34103
- for (const hook of instance[kHooks].onRegister) hook.call(old, instance, opts);
34104
- return instance;
34103
+ for (const hook of instance2[kHooks].onRegister) hook.call(old, instance2, opts);
34104
+ return instance2;
34105
34105
  };
34106
34106
  function buildRoutePrefix(instancePrefix, pluginPrefix) {
34107
34107
  if (!pluginPrefix) {
@@ -34895,12 +34895,12 @@ var require_set_cookie = __commonJS({
34895
34895
  var require_response = __commonJS({
34896
34896
  "node_modules/light-my-request/lib/response.js"(exports, module) {
34897
34897
  "use strict";
34898
- var http = __require("node:http");
34898
+ var http3 = __require("node:http");
34899
34899
  var { Writable, Readable, addAbortSignal } = __require("node:stream");
34900
34900
  var util = __require("node:util");
34901
34901
  var setCookie = require_set_cookie();
34902
34902
  function Response(req, onEnd, reject) {
34903
- http.ServerResponse.call(this, req);
34903
+ http3.ServerResponse.call(this, req);
34904
34904
  if (req._lightMyRequest?.payloadAsStream) {
34905
34905
  const read = this.emit.bind(this, "drain");
34906
34906
  this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable({ read }) };
@@ -34965,7 +34965,7 @@ var require_response = __commonJS({
34965
34965
  this.once("error", onEndFailure);
34966
34966
  this.once("close", onEndFailure);
34967
34967
  }
34968
- util.inherits(Response, http.ServerResponse);
34968
+ util.inherits(Response, http3.ServerResponse);
34969
34969
  Response.prototype.setTimeout = function(msecs, callback) {
34970
34970
  this.timeoutHandle = setTimeout(() => {
34971
34971
  this.emit("timeout");
@@ -34974,7 +34974,7 @@ var require_response = __commonJS({
34974
34974
  return this;
34975
34975
  };
34976
34976
  Response.prototype.writeHead = function() {
34977
- const result = http.ServerResponse.prototype.writeHead.apply(this, arguments);
34977
+ const result = http3.ServerResponse.prototype.writeHead.apply(this, arguments);
34978
34978
  copyHeaders(this);
34979
34979
  if (this._lightMyRequest.stream) {
34980
34980
  this._lightMyRequest.onEndSuccess(generatePayload(this));
@@ -34985,7 +34985,7 @@ var require_response = __commonJS({
34985
34985
  if (this.timeoutHandle) {
34986
34986
  clearTimeout(this.timeoutHandle);
34987
34987
  }
34988
- http.ServerResponse.prototype.write.call(this, data, encoding, callback);
34988
+ http3.ServerResponse.prototype.write.call(this, data, encoding, callback);
34989
34989
  if (this._lightMyRequest.stream) {
34990
34990
  return this._lightMyRequest.stream.push(Buffer.from(data, encoding));
34991
34991
  } else {
@@ -34997,7 +34997,7 @@ var require_response = __commonJS({
34997
34997
  if (data) {
34998
34998
  this.write(data, encoding);
34999
34999
  }
35000
- http.ServerResponse.prototype.end.call(this, callback);
35000
+ http3.ServerResponse.prototype.end.call(this, callback);
35001
35001
  this.emit("finish");
35002
35002
  this.destroy();
35003
35003
  };
@@ -36078,7 +36078,7 @@ var require_fastify = __commonJS({
36078
36078
  "use strict";
36079
36079
  var VERSION = "5.12.0";
36080
36080
  var Avvio = require_avvio();
36081
- var http = __require("node:http");
36081
+ var http3 = __require("node:http");
36082
36082
  var diagnostics = __require("node:diagnostics_channel");
36083
36083
  var lightMyRequest;
36084
36084
  var {
@@ -36430,15 +36430,15 @@ var require_fastify = __commonJS({
36430
36430
  fastify2.ready = ready;
36431
36431
  fastify2.printPlugins = avvio.prettyPrint.bind(avvio);
36432
36432
  avvio.once("preReady", () => {
36433
- fastify2.onClose((instance, done) => {
36433
+ fastify2.onClose((instance2, done) => {
36434
36434
  fastify2[kState].closing = true;
36435
36435
  router.closeRoutes();
36436
36436
  hookRunnerApplication("preClose", fastify2[kAvvioBoot], fastify2, function() {
36437
36437
  if (fastify2[kState].listening) {
36438
36438
  if (forceCloseConnections === "idle" && options.serverFactory) {
36439
- instance.server.closeIdleConnections();
36439
+ instance2.server.closeIdleConnections();
36440
36440
  } else if (serverHasCloseAllConnections && forceCloseConnections === true) {
36441
- instance.server.closeAllConnections();
36441
+ instance2.server.closeAllConnections();
36442
36442
  } else if (forceCloseConnections === true) {
36443
36443
  for (const conn of fastify2[kKeepAliveConnections]) {
36444
36444
  conn.destroy();
@@ -36447,10 +36447,10 @@ var require_fastify = __commonJS({
36447
36447
  }
36448
36448
  }
36449
36449
  if (serverHasCloseHttp2Sessions) {
36450
- instance.server.closeHttp2Sessions();
36450
+ instance2.server.closeHttp2Sessions();
36451
36451
  }
36452
36452
  if (!options.serverFactory || fastify2[kState].listening) {
36453
- instance.server.close(function(err) {
36453
+ instance2.server.close(function(err) {
36454
36454
  if (err && err.code !== "ERR_SERVER_NOT_RUNNING") {
36455
36455
  done(null);
36456
36456
  } else {
@@ -36618,19 +36618,19 @@ var require_fastify = __commonJS({
36618
36618
  }
36619
36619
  fourOhFour.router.lookup(req, res);
36620
36620
  }
36621
- function onBadUrl(path3, req, res) {
36621
+ function onBadUrl(path4, 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(path3), request, reply);
36628
+ return options.frameworkErrors(new FST_ERR_BAD_URL(path4), request, reply);
36629
36629
  }
36630
36630
  const body = JSON.stringify({
36631
36631
  error: "Bad Request",
36632
36632
  code: "FST_ERR_BAD_URL",
36633
- message: `'${path3}' is not a valid url component`,
36633
+ message: `'${path4}' 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(path3, req, res) {
36642
+ function onMaxParamLength(path4, 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(path3), request, reply);
36649
+ return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path4), 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: `'${path3}' is exceeding the max param length`,
36654
+ message: `'${path4}' is exceeding the max param length`,
36655
36655
  statusCode: 414
36656
36656
  });
36657
36657
  res.writeHead(414, {
@@ -36765,7 +36765,7 @@ var require_fastify = __commonJS({
36765
36765
  return this;
36766
36766
  }
36767
36767
  function addHttpMethod(method, { hasBody = false, overrideExisting = false } = {}) {
36768
- if (typeof method !== "string" || http.METHODS.indexOf(method) === -1) {
36768
+ if (typeof method !== "string" || http3.METHODS.indexOf(method) === -1) {
36769
36769
  throw new FST_ERR_ROUTE_METHOD_INVALID();
36770
36770
  }
36771
36771
  const alreadyExists = this[kSupportedHTTPMethods].bodyless.has(method) || this[kSupportedHTTPMethods].bodywith.has(method);
@@ -36868,17 +36868,17 @@ var require_fastify = __commonJS({
36868
36868
  let body, errorCode, errorStatus, errorLabel;
36869
36869
  if (err.code === "ERR_HTTP_REQUEST_TIMEOUT") {
36870
36870
  errorCode = "408";
36871
- errorStatus = http.STATUS_CODES[errorCode];
36871
+ errorStatus = http3.STATUS_CODES[errorCode];
36872
36872
  body = `{"error":"${errorStatus}","message":"Client Timeout","statusCode":408}`;
36873
36873
  errorLabel = "timeout";
36874
36874
  } else if (err.code === "HPE_HEADER_OVERFLOW") {
36875
36875
  errorCode = "431";
36876
- errorStatus = http.STATUS_CODES[errorCode];
36876
+ errorStatus = http3.STATUS_CODES[errorCode];
36877
36877
  body = `{"error":"${errorStatus}","message":"Exceeded maximum allowed HTTP header size","statusCode":431}`;
36878
36878
  errorLabel = "header_overflow";
36879
36879
  } else {
36880
36880
  errorCode = "400";
36881
- errorStatus = http.STATUS_CODES[errorCode];
36881
+ errorStatus = http3.STATUS_CODES[errorCode];
36882
36882
  body = `{"error":"${errorStatus}","message":"Client Error","statusCode":400}`;
36883
36883
  errorLabel = "error";
36884
36884
  }
@@ -39560,8 +39560,8 @@ var require_websocket = __commonJS({
39560
39560
  "use strict";
39561
39561
  var EventEmitter2 = __require("events");
39562
39562
  var https = __require("https");
39563
- var http = __require("http");
39564
- var net = __require("net");
39563
+ var http3 = __require("http");
39564
+ var net2 = __require("net");
39565
39565
  var tls = __require("tls");
39566
39566
  var { randomBytes, createHash } = __require("crypto");
39567
39567
  var { Duplex, Readable } = __require("stream");
@@ -40102,7 +40102,7 @@ var require_websocket = __commonJS({
40102
40102
  }
40103
40103
  const defaultPort = isSecure ? 443 : 80;
40104
40104
  const key = randomBytes(16).toString("base64");
40105
- const request = isSecure ? https.request : http.request;
40105
+ const request = isSecure ? https.request : http3.request;
40106
40106
  const protocolSet = /* @__PURE__ */ new Set();
40107
40107
  let perMessageDeflate;
40108
40108
  opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
@@ -40305,12 +40305,12 @@ var require_websocket = __commonJS({
40305
40305
  }
40306
40306
  function netConnect(options) {
40307
40307
  options.path = options.socketPath;
40308
- return net.connect(options);
40308
+ return net2.connect(options);
40309
40309
  }
40310
40310
  function tlsConnect(options) {
40311
40311
  options.path = void 0;
40312
40312
  if (!options.servername && options.servername !== "") {
40313
- options.servername = net.isIP(options.host) ? "" : options.host;
40313
+ options.servername = net2.isIP(options.host) ? "" : options.host;
40314
40314
  }
40315
40315
  return tls.connect(options);
40316
40316
  }
@@ -40598,7 +40598,7 @@ var require_websocket_server = __commonJS({
40598
40598
  "node_modules/ws/lib/websocket-server.js"(exports, module) {
40599
40599
  "use strict";
40600
40600
  var EventEmitter2 = __require("events");
40601
- var http = __require("http");
40601
+ var http3 = __require("http");
40602
40602
  var { Duplex } = __require("stream");
40603
40603
  var { createHash } = __require("crypto");
40604
40604
  var extension2 = require_extension();
@@ -40679,8 +40679,8 @@ var require_websocket_server = __commonJS({
40679
40679
  );
40680
40680
  }
40681
40681
  if (options.port != null) {
40682
- this._server = http.createServer((req, res) => {
40683
- const body = http.STATUS_CODES[426];
40682
+ this._server = http3.createServer((req, res) => {
40683
+ const body = http3.STATUS_CODES[426];
40684
40684
  res.writeHead(426, {
40685
40685
  "Content-Length": body.length,
40686
40686
  "Content-Type": "text/plain"
@@ -40969,7 +40969,7 @@ var require_websocket_server = __commonJS({
40969
40969
  this.destroy();
40970
40970
  }
40971
40971
  function abortHandshake(socket, code, message, headers) {
40972
- message = message || http.STATUS_CODES[code];
40972
+ message = message || http3.STATUS_CODES[code];
40973
40973
  headers = {
40974
40974
  Connection: "close",
40975
40975
  "Content-Type": "text/html",
@@ -40978,7 +40978,7 @@ var require_websocket_server = __commonJS({
40978
40978
  };
40979
40979
  socket.once("finish", socket.destroy);
40980
40980
  socket.end(
40981
- `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
40981
+ `HTTP/1.1 ${code} ${http3.STATUS_CODES[code]}\r
40982
40982
  ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
40983
40983
  );
40984
40984
  }
@@ -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(path3 = "data.db") {
41005
- db = new Database(path3);
41004
+ function initDb(path4 = "data.db") {
41005
+ db = new Database(path4);
41006
41006
  db.pragma("journal_mode = WAL");
41007
41007
  db.pragma("foreign_keys = ON");
41008
41008
  createTables(db);
@@ -41087,13 +41087,14 @@ function createTables(database) {
41087
41087
  CREATE TABLE IF NOT EXISTS discussion_threads (
41088
41088
  id TEXT PRIMARY KEY,
41089
41089
  session_id TEXT NOT NULL,
41090
- item_id TEXT NOT NULL,
41091
- turn_id TEXT NOT NULL,
41092
- start_offset INTEGER NOT NULL,
41093
- end_offset INTEGER NOT NULL,
41094
- selected_text TEXT NOT NULL,
41090
+ item_id TEXT,
41091
+ turn_id TEXT,
41092
+ start_offset INTEGER,
41093
+ end_offset INTEGER,
41094
+ selected_text TEXT,
41095
41095
  status TEXT NOT NULL DEFAULT 'open',
41096
41096
  resolved_at TEXT,
41097
+ external_thread_id TEXT,
41097
41098
  created_at TEXT NOT NULL,
41098
41099
  updated_at TEXT NOT NULL,
41099
41100
  FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
@@ -41164,13 +41165,14 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
41164
41165
  CREATE TABLE IF NOT EXISTS discussion_threads (
41165
41166
  id TEXT PRIMARY KEY,
41166
41167
  session_id TEXT NOT NULL,
41167
- item_id TEXT NOT NULL,
41168
- turn_id TEXT NOT NULL,
41169
- start_offset INTEGER NOT NULL,
41170
- end_offset INTEGER NOT NULL,
41171
- selected_text TEXT NOT NULL,
41168
+ item_id TEXT,
41169
+ turn_id TEXT,
41170
+ start_offset INTEGER,
41171
+ end_offset INTEGER,
41172
+ selected_text TEXT,
41172
41173
  status TEXT NOT NULL DEFAULT 'open',
41173
41174
  resolved_at TEXT,
41175
+ external_thread_id TEXT,
41174
41176
  created_at TEXT NOT NULL,
41175
41177
  updated_at TEXT NOT NULL,
41176
41178
  FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
@@ -41179,6 +41181,37 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
41179
41181
  CREATE INDEX IF NOT EXISTS idx_discussion_threads_item_id ON discussion_threads(item_id);
41180
41182
  `);
41181
41183
  }
41184
+ const threadAnchorCols = database.prepare("PRAGMA table_info(discussion_threads)").all();
41185
+ const anchorCol = threadAnchorCols.find((c) => c.name === "item_id");
41186
+ if (anchorCol && anchorCol.notnull === 1) {
41187
+ database.exec(`
41188
+ CREATE TABLE discussion_threads_new (
41189
+ id TEXT PRIMARY KEY,
41190
+ session_id TEXT NOT NULL,
41191
+ item_id TEXT,
41192
+ turn_id TEXT,
41193
+ start_offset INTEGER,
41194
+ end_offset INTEGER,
41195
+ selected_text TEXT,
41196
+ status TEXT NOT NULL DEFAULT 'open',
41197
+ resolved_at TEXT,
41198
+ external_thread_id TEXT,
41199
+ created_at TEXT NOT NULL,
41200
+ updated_at TEXT NOT NULL,
41201
+ FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
41202
+ );
41203
+ INSERT INTO discussion_threads_new
41204
+ (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text,
41205
+ status, resolved_at, external_thread_id, created_at, updated_at)
41206
+ SELECT id, session_id, item_id, turn_id, start_offset, end_offset, selected_text,
41207
+ status, resolved_at, external_thread_id, created_at, updated_at
41208
+ FROM discussion_threads;
41209
+ DROP TABLE discussion_threads;
41210
+ ALTER TABLE discussion_threads_new RENAME TO discussion_threads;
41211
+ CREATE INDEX IF NOT EXISTS idx_discussion_threads_session_id ON discussion_threads(session_id);
41212
+ CREATE INDEX IF NOT EXISTS idx_discussion_threads_item_id ON discussion_threads(item_id);
41213
+ `);
41214
+ }
41182
41215
  }
41183
41216
 
41184
41217
  // node_modules/ws/wrapper.mjs
@@ -41697,6 +41730,50 @@ async function registerSessionRoutes(fastify) {
41697
41730
  );
41698
41731
  }
41699
41732
 
41733
+ // src/routes/session-guard.ts
41734
+ var LIVE_TURN_SQL = `SELECT id FROM turns WHERE session_id = ? AND status IN ('pending', 'running') LIMIT 1`;
41735
+ var LIVE_MAIN_TURN_SQL = `SELECT id FROM turns WHERE session_id = ? AND status IN ('pending', 'running') AND thread_id IS NULL LIMIT 1`;
41736
+ var LIVE_THREAD_TURN_SQL = `SELECT id FROM turns WHERE thread_id = ? AND status IN ('pending', 'running') LIMIT 1`;
41737
+ function isSessionBusy(db2, session, opts) {
41738
+ if (opts?.threadId) {
41739
+ return !!db2.prepare(LIVE_THREAD_TURN_SQL).get(opts.threadId);
41740
+ }
41741
+ if (opts?.mainOnly) {
41742
+ if (db2.prepare(LIVE_MAIN_TURN_SQL).get(session.id)) return true;
41743
+ if (db2.prepare(LIVE_TURN_SQL).get(session.id)) return false;
41744
+ } else {
41745
+ if (db2.prepare(LIVE_TURN_SQL).get(session.id)) return true;
41746
+ }
41747
+ if (!session.is_running) return false;
41748
+ const now = (/* @__PURE__ */ new Date()).toISOString();
41749
+ db2.prepare("UPDATE sessions SET is_running = 0, status = ?, updated_at = ? WHERE id = ?").run(
41750
+ "active",
41751
+ now,
41752
+ session.id
41753
+ );
41754
+ return false;
41755
+ }
41756
+ function recomputeSessionRunning(db2, sessionId, idleStatus = "active", hasUnreviewed = false) {
41757
+ const live = db2.prepare(`SELECT COUNT(*) AS c FROM turns WHERE session_id = ? AND status IN ('pending', 'running')`).get(sessionId);
41758
+ const isRunning = live.c > 0 ? 1 : 0;
41759
+ const now = (/* @__PURE__ */ new Date()).toISOString();
41760
+ if (hasUnreviewed && isRunning === 0) {
41761
+ db2.prepare("UPDATE sessions SET is_running = ?, status = ?, has_unreviewed = 1, updated_at = ? WHERE id = ?").run(
41762
+ isRunning,
41763
+ idleStatus,
41764
+ now,
41765
+ sessionId
41766
+ );
41767
+ } else {
41768
+ db2.prepare("UPDATE sessions SET is_running = ?, status = ?, updated_at = ? WHERE id = ?").run(
41769
+ isRunning,
41770
+ isRunning ? "running" : idleStatus,
41771
+ now,
41772
+ sessionId
41773
+ );
41774
+ }
41775
+ }
41776
+
41700
41777
  // src/routes/turns.ts
41701
41778
  async function registerTurnRoutes(fastify) {
41702
41779
  fastify.post(
@@ -41735,7 +41812,7 @@ async function registerTurnRoutes(fastify) {
41735
41812
  if (!session) {
41736
41813
  return reply.code(404).send({ error: "Session not found" });
41737
41814
  }
41738
- if (session.is_running) {
41815
+ if (isSessionBusy(db2, session, { mainOnly: true })) {
41739
41816
  return reply.code(409).send({ error: "A turn is already running for this session" });
41740
41817
  }
41741
41818
  const turnId = v4_default();
@@ -41757,14 +41834,37 @@ async function registerTurnRoutes(fastify) {
41757
41834
  return parsedTurn;
41758
41835
  }
41759
41836
  );
41837
+ fastify.get(
41838
+ "/api/sessions/:id/turns/:turnId",
41839
+ async (request, reply) => {
41840
+ const { id, turnId } = request.params;
41841
+ const db2 = getDb();
41842
+ const session = db2.prepare("SELECT id FROM sessions WHERE id = ?").get(id);
41843
+ if (!session) {
41844
+ return reply.code(404).send({ error: "Session not found" });
41845
+ }
41846
+ const raw = db2.prepare("SELECT * FROM turns WHERE id = ? AND session_id = ?").get(turnId, id);
41847
+ if (!raw) {
41848
+ return reply.code(404).send({ error: "Turn not found" });
41849
+ }
41850
+ const itemRows = db2.prepare("SELECT * FROM items WHERE turn_id = ? ORDER BY created_at ASC").all(turnId);
41851
+ return {
41852
+ ...raw,
41853
+ token_usage: raw.token_usage ? JSON.parse(raw.token_usage) : null,
41854
+ attachments: raw.attachments ? JSON.parse(raw.attachments) : null,
41855
+ items: itemRows.map((it) => ({ ...it, data: it.data ? JSON.parse(it.data) : null }))
41856
+ };
41857
+ }
41858
+ );
41760
41859
  fastify.post("/api/sessions/:id/cancel", async (request, reply) => {
41761
41860
  const { id } = request.params;
41861
+ const { threadId } = request.query ?? {};
41762
41862
  const db2 = getDb();
41763
41863
  const session = db2.prepare("SELECT runtime_type FROM sessions WHERE id = ?").get(id);
41764
41864
  if (!session) {
41765
41865
  return reply.code(404).send({ error: "Session not found" });
41766
41866
  }
41767
- const cancelled = await getProvider(session.runtime_type).interruptTurn(id);
41867
+ const cancelled = await getProvider(session.runtime_type).interruptTurn(id, threadId);
41768
41868
  if (!cancelled) {
41769
41869
  return reply.code(409).send({ error: "No running turn to cancel" });
41770
41870
  }
@@ -41773,6 +41873,14 @@ async function registerTurnRoutes(fastify) {
41773
41873
  }
41774
41874
 
41775
41875
  // src/routes/threads.ts
41876
+ function parseTurnRow(row, items = []) {
41877
+ return {
41878
+ ...row,
41879
+ token_usage: row.token_usage ? JSON.parse(row.token_usage) : null,
41880
+ attachments: row.attachments ? JSON.parse(row.attachments) : null,
41881
+ items
41882
+ };
41883
+ }
41776
41884
  async function registerThreadRoutes(fastify) {
41777
41885
  fastify.post(
41778
41886
  "/api/sessions/:sessionId/threads",
@@ -41780,75 +41888,109 @@ async function registerThreadRoutes(fastify) {
41780
41888
  schema: {
41781
41889
  body: {
41782
41890
  type: "object",
41783
- required: ["itemId", "turnId", "startOffset", "endOffset", "selectedText", "message"],
41891
+ required: ["message"],
41784
41892
  properties: {
41785
41893
  itemId: { type: "string" },
41786
41894
  turnId: { type: "string" },
41787
41895
  startOffset: { type: "number" },
41788
41896
  endOffset: { type: "number" },
41789
41897
  selectedText: { type: "string" },
41790
- message: { type: "string", minLength: 1 }
41898
+ message: { type: "string", minLength: 1 },
41899
+ attachments: {
41900
+ type: "array",
41901
+ items: {
41902
+ type: "object",
41903
+ required: ["name", "media_type", "data"],
41904
+ properties: {
41905
+ name: { type: "string" },
41906
+ media_type: { type: "string" },
41907
+ data: { type: "string" }
41908
+ }
41909
+ }
41910
+ }
41791
41911
  }
41792
41912
  }
41793
41913
  }
41794
41914
  },
41795
41915
  async (request, reply) => {
41796
41916
  const { sessionId } = request.params;
41797
- const { itemId, turnId, startOffset, endOffset, selectedText, message } = request.body || {};
41917
+ const { itemId, turnId, startOffset, endOffset, selectedText, message, attachments } = request.body || {};
41798
41918
  const db2 = getDb();
41799
41919
  const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
41800
41920
  if (!session) {
41801
41921
  return reply.code(404).send({ error: "Session not found" });
41802
41922
  }
41803
- if (session.is_running) {
41923
+ if (isSessionBusy(db2, session)) {
41804
41924
  return reply.code(409).send({ error: "A turn is already running for this session" });
41805
41925
  }
41926
+ const isAnchored = Boolean(itemId && turnId && selectedText);
41806
41927
  const threadId = v4_default();
41807
41928
  const now = (/* @__PURE__ */ new Date()).toISOString();
41808
41929
  db2.prepare(
41809
41930
  `INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, status, created_at, updated_at)
41810
41931
  VALUES (?, ?, ?, ?, ?, ?, ?, 'open', ?, ?)`
41811
- ).run(threadId, sessionId, itemId, turnId, startOffset, endOffset, selectedText, now, now);
41932
+ ).run(
41933
+ threadId,
41934
+ sessionId,
41935
+ itemId ?? null,
41936
+ turnId ?? null,
41937
+ startOffset ?? null,
41938
+ endOffset ?? null,
41939
+ selectedText ?? null,
41940
+ now,
41941
+ now
41942
+ );
41812
41943
  const provider = getProvider(session.runtime_type);
41813
41944
  if (provider.forkSession) {
41814
41945
  try {
41815
41946
  if (!session.external_thread_id) {
41816
- console.warn(`[threads] cannot fork for thread ${threadId}: session ${sessionId} has no external_thread_id \u2014 thread will start a fresh isolated session`);
41947
+ console.warn(
41948
+ `[threads] cannot fork for thread ${threadId}: session ${sessionId} has no external_thread_id \u2014 thread will start a fresh isolated session`
41949
+ );
41817
41950
  } else {
41818
- const anchorTurn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(turnId);
41951
+ const anchorTurn = isAnchored ? db2.prepare("SELECT * FROM turns WHERE id = ?").get(turnId) : db2.prepare(
41952
+ "SELECT * FROM turns WHERE session_id = ? AND thread_id IS NULL ORDER BY created_at DESC LIMIT 1"
41953
+ ).get(sessionId);
41819
41954
  if (anchorTurn) {
41820
41955
  const forkedSessionId = await provider.forkSession(session, anchorTurn);
41821
41956
  if (forkedSessionId) {
41822
- db2.prepare("UPDATE discussion_threads SET external_thread_id = ? WHERE id = ?").run(forkedSessionId, threadId);
41957
+ db2.prepare("UPDATE discussion_threads SET external_thread_id = ? WHERE id = ?").run(
41958
+ forkedSessionId,
41959
+ threadId
41960
+ );
41823
41961
  console.log(`[threads] forked to ${forkedSessionId} for thread ${threadId} (session ${sessionId})`);
41824
41962
  } else {
41825
- console.warn(`[threads] forkSession returned null for thread ${threadId} (external_thread_id=${session.external_thread_id}, upToMessageId=${anchorTurn.external_turn_id}) \u2014 thread will start a fresh isolated session`);
41963
+ console.warn(
41964
+ `[threads] forkSession returned null for thread ${threadId} (external_thread_id=${session.external_thread_id}) \u2014 thread will start a fresh isolated session`
41965
+ );
41826
41966
  }
41827
41967
  } else {
41828
- console.warn(`[threads] anchor turn ${turnId} not found for thread ${threadId} \u2014 cannot fork`);
41968
+ console.warn(`[threads] no anchor turn found for thread ${threadId} \u2014 cannot fork`);
41829
41969
  }
41830
41970
  }
41831
41971
  } catch (err) {
41832
41972
  console.error(`[threads] forkSession failed for thread ${threadId}:`, err);
41833
41973
  }
41834
41974
  }
41835
- const formattedPrompt = `[Quoting from your previous response]:
41975
+ const formattedPrompt = isAnchored ? `[Quoting from your previous response]:
41836
41976
  > ${selectedText}
41837
41977
 
41838
- ${message}`;
41978
+ ${message}` : message;
41839
41979
  const newTurnId = v4_default();
41980
+ const attachmentsJson = attachments && attachments.length > 0 ? JSON.stringify(attachments) : null;
41840
41981
  db2.prepare(
41841
- `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, created_at, updated_at)
41842
- VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?)`
41843
- ).run(newTurnId, sessionId, formattedPrompt, threadId, now, now);
41844
- const turn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(newTurnId);
41845
- provider.startTurn(session, turn).catch((err) => {
41982
+ `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, attachments, created_at, updated_at)
41983
+ VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?, ?)`
41984
+ ).run(newTurnId, sessionId, formattedPrompt, threadId, attachmentsJson, now, now);
41985
+ const rawTurn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(newTurnId);
41986
+ provider.startTurn(session, rawTurn).catch((err) => {
41846
41987
  console.error(`[threads] Unhandled error for session ${sessionId}:`, err);
41847
41988
  });
41848
41989
  const threadRow = db2.prepare("SELECT * FROM discussion_threads WHERE id = ?").get(threadId);
41990
+ const turn = parseTurnRow(rawTurn);
41849
41991
  const thread = {
41850
41992
  ...threadRow,
41851
- turns: [{ ...turn, items: [] }]
41993
+ turns: [turn]
41852
41994
  };
41853
41995
  broadcast("thread:created", { sessionId, thread, turn });
41854
41996
  return { thread, turn };
@@ -41862,21 +42004,34 @@ ${message}`;
41862
42004
  type: "object",
41863
42005
  required: ["message"],
41864
42006
  properties: {
41865
- message: { type: "string", minLength: 1 }
42007
+ message: { type: "string", minLength: 1 },
42008
+ attachments: {
42009
+ type: "array",
42010
+ items: {
42011
+ type: "object",
42012
+ required: ["name", "media_type", "data"],
42013
+ properties: {
42014
+ name: { type: "string" },
42015
+ media_type: { type: "string" },
42016
+ data: { type: "string" }
42017
+ }
42018
+ }
42019
+ }
41866
42020
  }
41867
42021
  }
41868
42022
  }
41869
42023
  },
41870
42024
  async (request, reply) => {
41871
42025
  const { sessionId, threadId } = request.params;
41872
- const { message } = request.body || {};
42026
+ const { message, attachments } = request.body || {};
41873
42027
  const db2 = getDb();
41874
42028
  const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
41875
42029
  if (!session) {
41876
42030
  return reply.code(404).send({ error: "Session not found" });
41877
42031
  }
41878
- if (session.is_running) {
41879
- return reply.code(409).send({ error: "A turn is already running for this session" });
42032
+ isSessionBusy(db2, session);
42033
+ if (isSessionBusy(db2, session, { threadId })) {
42034
+ return reply.code(409).send({ error: "A turn is still running in this thread" });
41880
42035
  }
41881
42036
  const thread = db2.prepare("SELECT * FROM discussion_threads WHERE id = ? AND session_id = ?").get(threadId, sessionId);
41882
42037
  if (!thread) {
@@ -41887,14 +42042,16 @@ ${message}`;
41887
42042
  }
41888
42043
  const newTurnId = v4_default();
41889
42044
  const now = (/* @__PURE__ */ new Date()).toISOString();
42045
+ const attachmentsJson = attachments && attachments.length > 0 ? JSON.stringify(attachments) : null;
41890
42046
  db2.prepare(
41891
- `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, created_at, updated_at)
41892
- VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?)`
41893
- ).run(newTurnId, sessionId, message, threadId, now, now);
41894
- const turn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(newTurnId);
41895
- getProvider(session.runtime_type).startTurn(session, turn).catch((err) => {
42047
+ `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, attachments, created_at, updated_at)
42048
+ VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?, ?, ?)`
42049
+ ).run(newTurnId, sessionId, message, threadId, attachmentsJson, now, now);
42050
+ const rawTurn = db2.prepare("SELECT * FROM turns WHERE id = ?").get(newTurnId);
42051
+ getProvider(session.runtime_type).startTurn(session, rawTurn).catch((err) => {
41896
42052
  console.error(`[threads] followup error for session ${sessionId}:`, err);
41897
42053
  });
42054
+ const turn = parseTurnRow(rawTurn);
41898
42055
  broadcast("thread:followup", { sessionId, threadId, turn });
41899
42056
  return { turn };
41900
42057
  }
@@ -41946,9 +42103,12 @@ Agent: ${agent}`;
41946
42103
  return reply.code(500).send({ error: "Summarization failed \u2014 thread was not resolved. Try again or resolve without sharing." });
41947
42104
  }
41948
42105
  const now = (/* @__PURE__ */ new Date()).toISOString();
41949
- db2.prepare(
41950
- "UPDATE discussion_threads SET status = ?, resolved_at = ?, updated_at = ? WHERE id = ?"
41951
- ).run("resolved", now, now, threadId);
42106
+ db2.prepare("UPDATE discussion_threads SET status = ?, resolved_at = ?, updated_at = ? WHERE id = ?").run(
42107
+ "resolved",
42108
+ now,
42109
+ now,
42110
+ threadId
42111
+ );
41952
42112
  broadcast("thread:resolved", { sessionId, threadId, status: "resolved" });
41953
42113
  return { summary, resolved: true };
41954
42114
  }
@@ -41976,9 +42136,12 @@ Agent: ${agent}`;
41976
42136
  }
41977
42137
  const now = (/* @__PURE__ */ new Date()).toISOString();
41978
42138
  const resolvedAt = status === "resolved" ? now : null;
41979
- db2.prepare(
41980
- "UPDATE discussion_threads SET status = ?, resolved_at = ?, updated_at = ? WHERE id = ?"
41981
- ).run(status, resolvedAt, now, threadId);
42139
+ db2.prepare("UPDATE discussion_threads SET status = ?, resolved_at = ?, updated_at = ? WHERE id = ?").run(
42140
+ status,
42141
+ resolvedAt,
42142
+ now,
42143
+ threadId
42144
+ );
41982
42145
  broadcast("thread:resolved", { sessionId, threadId, status });
41983
42146
  return { id: threadId, status, resolved_at: resolvedAt };
41984
42147
  }
@@ -41997,9 +42160,7 @@ Agent: ${agent}`;
41997
42160
  const provider = getProvider(session.runtime_type);
41998
42161
  provider.clearThreadBranch?.(sessionId, threadId);
41999
42162
  }
42000
- db2.prepare(
42001
- "DELETE FROM items WHERE turn_id IN (SELECT id FROM turns WHERE thread_id = ?)"
42002
- ).run(threadId);
42163
+ db2.prepare("DELETE FROM items WHERE turn_id IN (SELECT id FROM turns WHERE thread_id = ?)").run(threadId);
42003
42164
  db2.prepare("DELETE FROM turns WHERE thread_id = ?").run(threadId);
42004
42165
  db2.prepare("DELETE FROM discussion_threads WHERE id = ?").run(threadId);
42005
42166
  broadcast("thread:deleted", { sessionId, threadId });
@@ -42029,11 +42190,7 @@ Agent: ${agent}`;
42029
42190
  }
42030
42191
  result.push({
42031
42192
  ...tr,
42032
- turns: turnRows.map((row) => ({
42033
- ...row,
42034
- token_usage: row.token_usage ? JSON.parse(row.token_usage) : null,
42035
- items: itemsByTurn.get(row.id) ?? []
42036
- }))
42193
+ turns: turnRows.map((row) => parseTurnRow(row, itemsByTurn.get(row.id) ?? []))
42037
42194
  });
42038
42195
  }
42039
42196
  return result;
@@ -42061,11 +42218,11 @@ async function registerWorkspaceRoutes(fastify) {
42061
42218
  }
42062
42219
  }
42063
42220
  }, async (request, reply) => {
42064
- const { path: path3, label = null } = request.body || {};
42065
- if (!path3 || !path3.trim()) {
42221
+ const { path: path4, label = null } = request.body || {};
42222
+ if (!path4 || !path4.trim()) {
42066
42223
  return reply.code(400).send({ error: "Path is required" });
42067
42224
  }
42068
- const trimmedPath = path3.trim();
42225
+ const trimmedPath = path4.trim();
42069
42226
  const db2 = getDb();
42070
42227
  const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
42071
42228
  if (existing) {
@@ -42093,8 +42250,8 @@ async function registerWorkspaceRoutes(fastify) {
42093
42250
  "-e",
42094
42251
  'POSIX path of (choose folder with prompt "Select a workspace directory")'
42095
42252
  ]);
42096
- const path3 = stdout.trim().replace(/\/$/, "");
42097
- return { path: path3 };
42253
+ const path4 = stdout.trim().replace(/\/$/, "");
42254
+ return { path: path4 };
42098
42255
  } catch {
42099
42256
  return reply.code(204).send({ cancelled: true });
42100
42257
  }
@@ -42110,11 +42267,11 @@ async function registerWorkspaceRoutes(fastify) {
42110
42267
  }
42111
42268
  }
42112
42269
  }, async (request, reply) => {
42113
- const { path: path3 } = request.body || {};
42114
- if (!path3 || !path3.trim()) {
42270
+ const { path: path4 } = request.body || {};
42271
+ if (!path4 || !path4.trim()) {
42115
42272
  return reply.code(400).send({ error: "Path is required" });
42116
42273
  }
42117
- const trimmedPath = path3.trim();
42274
+ const trimmedPath = path4.trim();
42118
42275
  const db2 = getDb();
42119
42276
  const existing = db2.prepare("SELECT * FROM workspaces WHERE path = ?").get(trimmedPath);
42120
42277
  if (existing) {
@@ -42688,6 +42845,622 @@ async function registerFileRoutes(fastify) {
42688
42845
  });
42689
42846
  }
42690
42847
 
42848
+ // src/routes/perf-log.ts
42849
+ import { appendFileSync, mkdirSync, renameSync, statSync } from "node:fs";
42850
+ import { homedir } from "node:os";
42851
+ import { dirname, join } from "node:path";
42852
+ var MAX_BYTES = 5 * 1024 * 1024;
42853
+ var MAX_BATCH = 500;
42854
+ function perfLogPath() {
42855
+ return process.env.AGENT_PANE_PERF_LOG ?? join(homedir(), ".repoburg", "agent-pane", "perf.log");
42856
+ }
42857
+ function oneLine(s) {
42858
+ return s.replace(/[\r\n\t]+/g, " ");
42859
+ }
42860
+ async function registerPerfLogRoutes(fastify) {
42861
+ fastify.post(
42862
+ "/api/perf-log",
42863
+ {
42864
+ schema: {
42865
+ body: {
42866
+ type: "object",
42867
+ required: ["entries"],
42868
+ properties: {
42869
+ entries: {
42870
+ type: "array",
42871
+ maxItems: MAX_BATCH,
42872
+ items: {
42873
+ type: "object",
42874
+ required: ["t", "cat", "msg"],
42875
+ properties: {
42876
+ t: { type: "number" },
42877
+ cat: { type: "string", maxLength: 16 },
42878
+ msg: { type: "string", maxLength: 4e3 },
42879
+ ms: { type: "number" }
42880
+ }
42881
+ }
42882
+ }
42883
+ }
42884
+ }
42885
+ }
42886
+ },
42887
+ async (request, reply) => {
42888
+ const entries = (request.body?.entries ?? []).slice(0, MAX_BATCH);
42889
+ if (entries.length === 0) {
42890
+ return reply.send({ written: 0 });
42891
+ }
42892
+ const path4 = perfLogPath();
42893
+ try {
42894
+ mkdirSync(dirname(path4), { recursive: true });
42895
+ try {
42896
+ if (statSync(path4).size > MAX_BYTES) {
42897
+ renameSync(path4, `${path4}.1`);
42898
+ }
42899
+ } catch {
42900
+ }
42901
+ const lines = entries.map((e) => `${new Date(e.t).toISOString()} [${oneLine(e.cat)}] ${oneLine(e.msg)}`).join("\n");
42902
+ appendFileSync(path4, `${lines}
42903
+ `, "utf-8");
42904
+ return reply.send({ written: entries.length });
42905
+ } catch (err) {
42906
+ request.log.warn(`perf-log write failed: ${err.message}`);
42907
+ return reply.send({ written: 0 });
42908
+ }
42909
+ }
42910
+ );
42911
+ }
42912
+
42913
+ // src/routes/maintenance.ts
42914
+ var TRIMMABLE_KEYS = ["aggregated_output", "output"];
42915
+ async function registerMaintenanceRoutes(fastify) {
42916
+ fastify.post(
42917
+ "/api/maintenance/prune-items",
42918
+ {
42919
+ schema: {
42920
+ body: {
42921
+ type: "object",
42922
+ properties: {
42923
+ maxBytes: { type: "number" },
42924
+ vacuum: { type: "boolean" }
42925
+ },
42926
+ additionalProperties: false
42927
+ }
42928
+ }
42929
+ },
42930
+ async (request) => {
42931
+ const maxBytes = Math.max(1024, Math.min(1e6, request.body?.maxBytes ?? 5e4));
42932
+ const vacuum = request.body?.vacuum === true;
42933
+ const db2 = getDb();
42934
+ let bytesBefore = 0;
42935
+ let bytesAfter = 0;
42936
+ let pruned = 0;
42937
+ const rows = db2.prepare("SELECT id, data FROM items WHERE LENGTH(data) > ?").all(maxBytes);
42938
+ const update = db2.prepare("UPDATE items SET data = ? WHERE id = ?");
42939
+ for (const row of rows) {
42940
+ if (!row.data) continue;
42941
+ let data;
42942
+ try {
42943
+ data = JSON.parse(row.data);
42944
+ } catch {
42945
+ continue;
42946
+ }
42947
+ let changed = false;
42948
+ for (const key of TRIMMABLE_KEYS) {
42949
+ const v = data[key];
42950
+ if (typeof v === "string" && v.length > maxBytes) {
42951
+ data[key] = `\u2026 [pruned: kept newest ${maxBytes} bytes]
42952
+ ` + v.slice(-maxBytes);
42953
+ changed = true;
42954
+ }
42955
+ }
42956
+ if (!changed) continue;
42957
+ const next = JSON.stringify(data);
42958
+ bytesBefore += row.data.length;
42959
+ bytesAfter += next.length;
42960
+ pruned++;
42961
+ update.run(next, row.id);
42962
+ }
42963
+ if (vacuum) {
42964
+ db2.exec("VACUUM");
42965
+ }
42966
+ return {
42967
+ pruned_items: pruned,
42968
+ bytes_before: bytesBefore,
42969
+ bytes_after: bytesAfter,
42970
+ bytes_freed: bytesBefore - bytesAfter,
42971
+ max_bytes: maxBytes,
42972
+ vacuum
42973
+ };
42974
+ }
42975
+ );
42976
+ }
42977
+
42978
+ // src/routes/vscode-web.ts
42979
+ import http2 from "node:http";
42980
+
42981
+ // src/vscode-web/manager.ts
42982
+ import { spawn as spawn2 } from "node:child_process";
42983
+ import { existsSync } from "node:fs";
42984
+ import http from "node:http";
42985
+ import net from "node:net";
42986
+ import crypto from "node:crypto";
42987
+ import os from "node:os";
42988
+ import path2 from "node:path";
42989
+ import { mkdir, readdir, symlink, lstat, access, readFile, writeFile, unlink } from "node:fs/promises";
42990
+ var VSCODE_WEB_DATA_DIR = path2.join(os.homedir(), ".repoburg", "vscode-web");
42991
+ function resolveDesktopUserDir() {
42992
+ if (process.platform === "darwin") {
42993
+ return path2.join(os.homedir(), "Library", "Application Support", "Code", "User");
42994
+ }
42995
+ if (process.platform === "win32" && process.env.APPDATA) {
42996
+ return path2.join(process.env.APPDATA, "Code", "User");
42997
+ }
42998
+ if (process.platform === "linux") {
42999
+ return path2.join(os.homedir(), ".config", "Code", "User");
43000
+ }
43001
+ return null;
43002
+ }
43003
+ async function linkUnlessExists(src, dst) {
43004
+ await mkdir(path2.dirname(dst), { recursive: true });
43005
+ try {
43006
+ await lstat(dst);
43007
+ return false;
43008
+ } catch {
43009
+ await symlink(src, dst);
43010
+ return true;
43011
+ }
43012
+ }
43013
+ function fileRegistryUri(dir) {
43014
+ const external = `file://${dir}`;
43015
+ return { $mid: 1, fsPath: dir, external, path: dir, scheme: "file" };
43016
+ }
43017
+ async function syncProfile(dataDir = VSCODE_WEB_DATA_DIR) {
43018
+ try {
43019
+ const desktopExt = path2.join(os.homedir(), ".vscode", "extensions");
43020
+ let entries;
43021
+ try {
43022
+ entries = await readdir(desktopExt, { withFileTypes: true });
43023
+ } catch {
43024
+ return;
43025
+ }
43026
+ const serverExt = path2.join(dataDir, "extensions");
43027
+ const linkedFolders = [];
43028
+ for (const entry of entries) {
43029
+ if (!entry.isDirectory()) continue;
43030
+ const target = path2.join(serverExt, entry.name);
43031
+ await linkUnlessExists(path2.join(desktopExt, entry.name), target);
43032
+ const st = await lstat(target).catch(() => null);
43033
+ if (st?.isSymbolicLink()) linkedFolders.push(entry.name);
43034
+ }
43035
+ await mergeExtensionRegistry(desktopExt, serverExt, linkedFolders);
43036
+ await pruneObsolete(serverExt, linkedFolders);
43037
+ const desktopUser = resolveDesktopUserDir();
43038
+ if (!desktopUser) return;
43039
+ const serverUser = path2.join(dataDir, "data", "User");
43040
+ for (const item of ["settings.json", "keybindings.json", "snippets"]) {
43041
+ const src = path2.join(desktopUser, item);
43042
+ try {
43043
+ await access(src);
43044
+ } catch {
43045
+ continue;
43046
+ }
43047
+ await linkUnlessExists(src, path2.join(serverUser, item));
43048
+ }
43049
+ } catch {
43050
+ }
43051
+ }
43052
+ async function mergeExtensionRegistry(desktopExt, serverExt, linkedFolders) {
43053
+ let desktopEntries = [];
43054
+ try {
43055
+ desktopEntries = JSON.parse(await readFile(path2.join(desktopExt, "extensions.json"), "utf8"));
43056
+ } catch {
43057
+ return;
43058
+ }
43059
+ const linked = new Set(linkedFolders);
43060
+ const toAdd = desktopEntries.filter((e) => e.identifier?.id && linked.has(e.relativeLocation));
43061
+ const serverRegistryPath = path2.join(serverExt, "extensions.json");
43062
+ let serverEntries = [];
43063
+ try {
43064
+ serverEntries = JSON.parse(await readFile(serverRegistryPath, "utf8"));
43065
+ } catch {
43066
+ }
43067
+ const known = new Set(serverEntries.map((e) => `${e.identifier.id.toLowerCase()}@${e.version}`));
43068
+ const additions = toAdd.filter((e) => !known.has(`${e.identifier.id.toLowerCase()}@${e.version}`));
43069
+ if (additions.length === 0) return;
43070
+ for (const entry of additions) {
43071
+ const dir = path2.join(serverExt, entry.relativeLocation);
43072
+ serverEntries.push({ ...entry, location: fileRegistryUri(dir) });
43073
+ }
43074
+ await writeFile(serverRegistryPath, JSON.stringify(serverEntries));
43075
+ }
43076
+ async function pruneObsolete(serverExt, linkedFolders) {
43077
+ const obsoletePath = path2.join(serverExt, ".obsolete");
43078
+ let obsolete;
43079
+ try {
43080
+ obsolete = JSON.parse(await readFile(obsoletePath, "utf8"));
43081
+ } catch {
43082
+ return;
43083
+ }
43084
+ const linked = new Set(linkedFolders);
43085
+ const next = Object.fromEntries(Object.entries(obsolete).filter(([name]) => !linked.has(name)));
43086
+ if (Object.keys(next).length === Object.keys(obsolete).length) return;
43087
+ if (Object.keys(next).length === 0) {
43088
+ try {
43089
+ await unlink(obsoletePath);
43090
+ } catch {
43091
+ }
43092
+ } else {
43093
+ await writeFile(obsoletePath, JSON.stringify(next));
43094
+ }
43095
+ }
43096
+ var IDLE_STOP_MS = 15 * 60 * 1e3;
43097
+ var MAX_INSTANCES = 2;
43098
+ var IDLE_CHECK_MS = 3e4;
43099
+ var STARTUP_TIMEOUT_MS = 9e4;
43100
+ var PROBE_INTERVAL_MS = 500;
43101
+ var SIGKILL_GRACE_MS = 5e3;
43102
+ function resolveCodeCli() {
43103
+ const override = process.env.AGENTPANE_VSCODE_CLI;
43104
+ if (override) return override;
43105
+ if (process.platform === "darwin") {
43106
+ const bundled = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
43107
+ if (existsSync(bundled)) return bundled;
43108
+ }
43109
+ return "code";
43110
+ }
43111
+ function defaultSpawnServeWeb(port, token, folder, id) {
43112
+ const args = [
43113
+ "serve-web",
43114
+ "--host",
43115
+ "127.0.0.1",
43116
+ "--port",
43117
+ String(port),
43118
+ "--connection-token",
43119
+ token,
43120
+ // Instance-scoped base path: the proxy routes /vscode/<id>/* to this port.
43121
+ "--server-base-path",
43122
+ `/vscode/${id}`,
43123
+ "--server-data-dir",
43124
+ VSCODE_WEB_DATA_DIR,
43125
+ "--accept-server-license-terms",
43126
+ "--disable-telemetry"
43127
+ ];
43128
+ if (folder) args.push("--default-folder", folder);
43129
+ return spawn2(resolveCodeCli(), args, { stdio: ["ignore", "pipe", "pipe"], detached: true });
43130
+ }
43131
+ function defaultProbe(port, token) {
43132
+ return new Promise((resolve, reject) => {
43133
+ const req = http.get(`http://127.0.0.1:${port}/vscode/?tkn=${token}`, (res) => {
43134
+ res.resume();
43135
+ resolve();
43136
+ });
43137
+ req.on("error", reject);
43138
+ req.setTimeout(2e3, () => {
43139
+ req.destroy(new Error("probe timeout"));
43140
+ });
43141
+ });
43142
+ }
43143
+ function findFreePort() {
43144
+ return new Promise((resolve, reject) => {
43145
+ const server = net.createServer();
43146
+ server.listen(0, "127.0.0.1", () => {
43147
+ const { port } = server.address();
43148
+ server.close(() => resolve(port));
43149
+ });
43150
+ server.on("error", reject);
43151
+ });
43152
+ }
43153
+ function idOfFolder(folder) {
43154
+ if (!folder) return "default";
43155
+ return crypto.createHash("sha256").update(folder).digest("hex").slice(0, 8);
43156
+ }
43157
+ function statusOf(inst) {
43158
+ return { id: inst.id, state: inst.state, port: inst.port, token: inst.token, error: inst.error, folder: inst.folder };
43159
+ }
43160
+ function stoppedStatus() {
43161
+ return { id: null, state: "stopped", port: null, token: null, error: null, folder: null };
43162
+ }
43163
+ var VscodeWebManager = class {
43164
+ constructor(deps) {
43165
+ this.deps = deps;
43166
+ }
43167
+ instances = /* @__PURE__ */ new Map();
43168
+ checkTimer = null;
43169
+ /** Instance by id (proxy + WS upgrade lookup). */
43170
+ getInstance(id) {
43171
+ return this.instances.get(id) ?? null;
43172
+ }
43173
+ status(id) {
43174
+ const inst = this.instances.get(id);
43175
+ return inst ? statusOf(inst) : stoppedStatus();
43176
+ }
43177
+ /** Reset the idle clock — called on every proxied request/WS frame/heartbeat. */
43178
+ markAccessed(id) {
43179
+ const inst = this.instances.get(id);
43180
+ if (inst) inst.lastAccessedAt = this.deps.now();
43181
+ }
43182
+ /**
43183
+ * Start (or reuse) the instance serving `folder`. Returns 'starting'
43184
+ * immediately; readiness is reached in the background — poll `status()`.
43185
+ */
43186
+ async start(folder) {
43187
+ const id = idOfFolder(folder);
43188
+ const existing = this.instances.get(id);
43189
+ if (existing && (existing.state === "running" || existing.state === "starting")) {
43190
+ this.markAccessed(id);
43191
+ return statusOf(existing);
43192
+ }
43193
+ await this.evictIfNeeded();
43194
+ await this.spawnInstance(id, folder);
43195
+ this.startIdleCheck();
43196
+ return this.status(id);
43197
+ }
43198
+ /** Enforce the cap: stop the least-recently-accessed active instance. */
43199
+ async evictIfNeeded() {
43200
+ const active = [...this.instances.values()].filter((i) => i.state === "running" || i.state === "starting");
43201
+ for (let i = active.length; i >= MAX_INSTANCES; i--) {
43202
+ let oldest = null;
43203
+ for (const inst of active) {
43204
+ if (!oldest || inst.lastAccessedAt < oldest.lastAccessedAt) oldest = inst;
43205
+ }
43206
+ if (!oldest) return;
43207
+ active.splice(active.indexOf(oldest), 1);
43208
+ await this.stop(oldest.id);
43209
+ }
43210
+ }
43211
+ async spawnInstance(id, folder) {
43212
+ await this.deps.syncProfile(VSCODE_WEB_DATA_DIR);
43213
+ const token = crypto.randomBytes(24).toString("hex");
43214
+ const port = await findFreePort();
43215
+ const child = this.deps.spawnServeWeb(port, token, folder, id);
43216
+ const inst = {
43217
+ id,
43218
+ folder,
43219
+ port,
43220
+ token,
43221
+ state: "starting",
43222
+ error: null,
43223
+ child,
43224
+ lastAccessedAt: this.deps.now(),
43225
+ stopping: false
43226
+ };
43227
+ this.instances.set(id, inst);
43228
+ child.on("error", (err) => {
43229
+ if (inst.stopping) return;
43230
+ inst.child = null;
43231
+ inst.state = "error";
43232
+ inst.error = String(err);
43233
+ });
43234
+ child.on("exit", (code) => {
43235
+ inst.child = null;
43236
+ if (inst.stopping) {
43237
+ inst.stopping = false;
43238
+ } else if (inst.state === "starting") {
43239
+ inst.state = "error";
43240
+ inst.error = `serve-web exited during startup (code ${code})`;
43241
+ } else {
43242
+ inst.state = "stopped";
43243
+ }
43244
+ });
43245
+ void this.waitForReady(inst);
43246
+ }
43247
+ /** Poll the port until serve-web answers, or fail after the startup timeout. */
43248
+ waitForReady(inst) {
43249
+ const deadline = this.deps.now() + STARTUP_TIMEOUT_MS;
43250
+ return new Promise((resolve) => {
43251
+ const timer = setInterval(async () => {
43252
+ if (inst.state !== "starting") {
43253
+ clearInterval(timer);
43254
+ resolve();
43255
+ return;
43256
+ }
43257
+ if (this.deps.now() > deadline) {
43258
+ clearInterval(timer);
43259
+ inst.state = "error";
43260
+ inst.error = `serve-web did not become ready within ${STARTUP_TIMEOUT_MS / 1e3}s`;
43261
+ inst.stopping = true;
43262
+ const child = inst.child;
43263
+ inst.child = null;
43264
+ this.killChild(child, inst.id);
43265
+ resolve();
43266
+ return;
43267
+ }
43268
+ try {
43269
+ await this.deps.probe(inst.port, inst.token);
43270
+ clearInterval(timer);
43271
+ if (inst.state === "starting") {
43272
+ inst.state = "running";
43273
+ this.markAccessed(inst.id);
43274
+ }
43275
+ resolve();
43276
+ } catch {
43277
+ }
43278
+ }, PROBE_INTERVAL_MS);
43279
+ });
43280
+ }
43281
+ /** Stop the child process and drop the instance entry (SIGTERM → SIGKILL). */
43282
+ async stop(id) {
43283
+ const inst = this.instances.get(id);
43284
+ if (!inst) return stoppedStatus();
43285
+ inst.stopping = true;
43286
+ const child = inst.child;
43287
+ inst.child = null;
43288
+ this.instances.delete(id);
43289
+ this.killChild(child, id);
43290
+ return { ...statusOf(inst), state: "stopped" };
43291
+ }
43292
+ /** Kill the instance's whole process tree (SIGTERM → SIGKILL after grace).
43293
+ * The group kill misses the code-server node child (it re-sessions itself),
43294
+ * so also sweep by the instance-unique --server-base-path argument. */
43295
+ killChild(child, id) {
43296
+ if (child?.pid) {
43297
+ try {
43298
+ process.kill(-child.pid, "SIGTERM");
43299
+ } catch {
43300
+ child.kill("SIGTERM");
43301
+ }
43302
+ }
43303
+ this.sweepTree(id, "SIGTERM");
43304
+ setTimeout(() => this.sweepTree(id, "SIGKILL"), SIGKILL_GRACE_MS).unref();
43305
+ }
43306
+ /** Signal every process whose command line carries this instance's base path. */
43307
+ sweepTree(id, signal) {
43308
+ try {
43309
+ spawn2("pkill", [signal === "SIGKILL" ? "-9" : "-TERM", "-f", `server-base-path /vscode/${id}`], {
43310
+ stdio: "ignore"
43311
+ });
43312
+ } catch {
43313
+ }
43314
+ }
43315
+ /** Periodic idle check — stops instances silent past the 15-minute window. */
43316
+ startIdleCheck() {
43317
+ if (this.checkTimer) return;
43318
+ this.checkTimer = setInterval(() => {
43319
+ const now = this.deps.now();
43320
+ for (const inst of [...this.instances.values()]) {
43321
+ if (inst.state === "running" || inst.state === "starting") {
43322
+ if (now - inst.lastAccessedAt > IDLE_STOP_MS) void this.stop(inst.id);
43323
+ }
43324
+ }
43325
+ }, IDLE_CHECK_MS);
43326
+ this.checkTimer.unref?.();
43327
+ }
43328
+ };
43329
+ var instance = null;
43330
+ function getVscodeWebManager() {
43331
+ if (!instance) {
43332
+ instance = new VscodeWebManager({
43333
+ spawnServeWeb: defaultSpawnServeWeb,
43334
+ probe: defaultProbe,
43335
+ now: () => Date.now(),
43336
+ syncProfile
43337
+ });
43338
+ }
43339
+ return instance;
43340
+ }
43341
+ function handleVscodeWebUpgrade(request, socket, head) {
43342
+ const manager = getVscodeWebManager();
43343
+ const match = /^\/vscode\/([^/?]+)/.exec(request.url || "");
43344
+ const id = match?.[1] ?? "";
43345
+ const inst = manager.getInstance(id);
43346
+ if (!inst || inst.state !== "running") {
43347
+ socket.write("HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\n\r\n");
43348
+ socket.destroy();
43349
+ return;
43350
+ }
43351
+ const upstream = http.request({
43352
+ host: "127.0.0.1",
43353
+ port: inst.port,
43354
+ method: "GET",
43355
+ path: request.url,
43356
+ headers: request.headers
43357
+ });
43358
+ upstream.on("upgrade", (res, upSocket, upHead) => {
43359
+ manager.markAccessed(id);
43360
+ let header = "HTTP/1.1 101 Switching Protocols\r\n";
43361
+ for (const [name, value] of Object.entries(res.headers)) {
43362
+ if (value === void 0) continue;
43363
+ if (Array.isArray(value)) for (const v of value) header += `${name}: ${v}\r
43364
+ `;
43365
+ else header += `${name}: ${value}\r
43366
+ `;
43367
+ }
43368
+ header += "\r\n";
43369
+ socket.write(header);
43370
+ if (head.length) upSocket.write(head);
43371
+ if (upHead.length) socket.write(upHead);
43372
+ socket.pipe(upSocket);
43373
+ upSocket.pipe(socket);
43374
+ socket.on("data", () => manager.markAccessed(id));
43375
+ socket.on("error", () => upSocket.destroy());
43376
+ upSocket.on("error", () => socket.destroy());
43377
+ socket.on("close", () => upSocket.destroy());
43378
+ upSocket.on("close", () => socket.destroy());
43379
+ });
43380
+ upstream.on("response", () => {
43381
+ socket.write("HTTP/1.1 502 Bad Gateway\r\nConnection: close\r\n\r\n");
43382
+ socket.destroy();
43383
+ });
43384
+ upstream.on("error", () => socket.destroy());
43385
+ upstream.end();
43386
+ }
43387
+
43388
+ // src/routes/vscode-web.ts
43389
+ var PROXY_METHODS = ["GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"];
43390
+ async function registerVscodeWebRoutes(fastify) {
43391
+ fastify.get(
43392
+ "/api/vscode-web/status",
43393
+ async (request) => getVscodeWebManager().status(request.query.id ?? idOfFolder(request.query.folder ?? null))
43394
+ );
43395
+ fastify.post(
43396
+ "/api/vscode-web/start",
43397
+ async (request) => getVscodeWebManager().start(request.body?.folder ?? null)
43398
+ );
43399
+ fastify.post(
43400
+ "/api/vscode-web/stop",
43401
+ async (request) => getVscodeWebManager().stop(request.body?.id ?? idOfFolder(request.body?.folder ?? null))
43402
+ );
43403
+ fastify.post(
43404
+ "/api/vscode-web/heartbeat",
43405
+ async (request) => {
43406
+ const manager = getVscodeWebManager();
43407
+ if (request.body?.id) manager.markAccessed(request.body.id);
43408
+ return manager.status(request.body?.id ?? "");
43409
+ }
43410
+ );
43411
+ await fastify.register(async (scope) => {
43412
+ scope.addContentTypeParser("*", { parseAs: "buffer" }, (_req, body, done) => done(null, body));
43413
+ scope.route({
43414
+ method: [...PROXY_METHODS],
43415
+ url: "/vscode/:id",
43416
+ handler: proxyHandler
43417
+ });
43418
+ scope.route({
43419
+ method: [...PROXY_METHODS],
43420
+ url: "/vscode/:id/*",
43421
+ handler: proxyHandler
43422
+ });
43423
+ });
43424
+ }
43425
+ function proxyHandler(request, reply) {
43426
+ const manager = getVscodeWebManager();
43427
+ const inst = manager.getInstance(String(request.params.id));
43428
+ if (!inst || inst.state !== "running") {
43429
+ reply.code(503);
43430
+ void reply.send({ error: "VS Code web server is not running" });
43431
+ return;
43432
+ }
43433
+ manager.markAccessed(inst.id);
43434
+ const upstream = http2.request(
43435
+ {
43436
+ host: "127.0.0.1",
43437
+ port: inst.port,
43438
+ method: request.method,
43439
+ path: request.raw.url,
43440
+ headers: request.raw.headers
43441
+ },
43442
+ (res) => {
43443
+ reply.hijack();
43444
+ reply.raw.writeHead(res.statusCode ?? 502, res.headers);
43445
+ res.pipe(reply.raw);
43446
+ }
43447
+ );
43448
+ upstream.on("error", () => {
43449
+ if (reply.raw.headersSent) {
43450
+ reply.raw.destroy();
43451
+ return;
43452
+ }
43453
+ reply.hijack();
43454
+ reply.raw.writeHead(502, { "content-type": "application/json" });
43455
+ reply.raw.end('{"error":"vscode serve-web unreachable"}');
43456
+ });
43457
+ const body = request.body;
43458
+ if (body && body.length > 0 && request.method !== "GET" && request.method !== "HEAD") {
43459
+ upstream.write(body);
43460
+ }
43461
+ upstream.end();
43462
+ }
43463
+
42691
43464
  // src/codex/item-mapper.ts
42692
43465
  function mapItemData(item) {
42693
43466
  switch (item.type) {
@@ -42868,7 +43641,7 @@ async function startTurn(session, turn) {
42868
43641
  now2,
42869
43642
  turn.id
42870
43643
  );
42871
- setSessionStatus(db2, session.id, 0, "failed", now2);
43644
+ recomputeSessionRunning(db2, session.id, "failed");
42872
43645
  broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
42873
43646
  return;
42874
43647
  }
@@ -42919,7 +43692,7 @@ async function startTurn(session, turn) {
42919
43692
  db3.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now2, turn.id);
42920
43693
  broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, hasUnreviewed: true });
42921
43694
  }
42922
- setSessionStatus(db3, session.id, 0, "active", now2, true);
43695
+ recomputeSessionRunning(db3, session.id, "active", true);
42923
43696
  syncThreadTitle(session.id);
42924
43697
  };
42925
43698
  const handleTurnFailed = (params) => {
@@ -42935,7 +43708,7 @@ async function startTurn(session, turn) {
42935
43708
  now2,
42936
43709
  turn.id
42937
43710
  );
42938
- setSessionStatus(db3, session.id, 0, "failed", now2);
43711
+ recomputeSessionRunning(db3, session.id, "failed");
42939
43712
  broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: p.error.message });
42940
43713
  };
42941
43714
  const handleAgentMessageDelta = (params) => {
@@ -42989,7 +43762,7 @@ async function startTurn(session, turn) {
42989
43762
  now2,
42990
43763
  turn.id
42991
43764
  );
42992
- setSessionStatus(db3, session.id, 0, "failed", now2);
43765
+ recomputeSessionRunning(db3, session.id, "failed");
42993
43766
  broadcast("turn:failed", {
42994
43767
  sessionId: session.id,
42995
43768
  turnId: turn.id,
@@ -43006,7 +43779,7 @@ async function startTurn(session, turn) {
43006
43779
  now2,
43007
43780
  turn.id
43008
43781
  );
43009
- setSessionStatus(db2, session.id, 0, "failed", now2);
43782
+ recomputeSessionRunning(db2, session.id, "failed");
43010
43783
  broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
43011
43784
  turnDone = true;
43012
43785
  }
@@ -43057,7 +43830,7 @@ function handleItemEvent(params, sessionId, turnId, status, broadcastEvent) {
43057
43830
  };
43058
43831
  broadcast(broadcastEvent, { sessionId, turnId, item: wsItem });
43059
43832
  }
43060
- async function interruptTurn(sessionId) {
43833
+ async function interruptTurn(sessionId, _threadId) {
43061
43834
  const entry = sessionMap.get(sessionId);
43062
43835
  if (!entry || !entry.turnId) return false;
43063
43836
  try {
@@ -43068,7 +43841,7 @@ async function interruptTurn(sessionId) {
43068
43841
  const db2 = getDb();
43069
43842
  const now = (/* @__PURE__ */ new Date()).toISOString();
43070
43843
  db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, entry.turnId);
43071
- setSessionStatus(db2, sessionId, 0, "active", now);
43844
+ recomputeSessionRunning(db2, sessionId);
43072
43845
  broadcast("turn:cancelled", { sessionId, turnId: entry.turnId });
43073
43846
  entry.turnId = null;
43074
43847
  return true;
@@ -43286,7 +44059,7 @@ var codexProvider = {
43286
44059
  import { query, forkSession as sdkForkSession } from "@anthropic-ai/claude-agent-sdk";
43287
44060
  import { readFileSync as readFileSync2 } from "fs";
43288
44061
  import { tmpdir } from "os";
43289
- import { join } from "path";
44062
+ import { join as join2 } from "path";
43290
44063
 
43291
44064
  // src/claude/claude-message-mapper.ts
43292
44065
  function mapAssistantContent(content, messageId, thinkingTexts) {
@@ -43365,9 +44138,9 @@ function mapToolUse(block) {
43365
44138
  };
43366
44139
  }
43367
44140
  function deriveFileChangeData(input, toolName) {
43368
- const path3 = input.file_path ?? input.notebook_path ?? "";
44141
+ const path4 = input.file_path ?? input.notebook_path ?? "";
43369
44142
  const kind = toolName === "Write" ? "add" : "modify";
43370
- return { changes: [{ path: path3, kind }], status: "in_progress" };
44143
+ return { changes: [{ path: path4, kind }], status: "in_progress" };
43371
44144
  }
43372
44145
  function extractToolResultText(content) {
43373
44146
  if (!content) return "";
@@ -43558,8 +44331,13 @@ async function ensureSessionStarted(session, mapKey, resumeSessionId) {
43558
44331
  const staleItems = db2.prepare(
43559
44332
  "UPDATE items SET status = 'failed', updated_at = ? WHERE status = 'in_progress' AND turn_id IN (SELECT id FROM turns WHERE session_id = ?)"
43560
44333
  ).run(now, session.id);
43561
- db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run("failed", errMsg, now, entry.turnId);
43562
- setSessionStatus2(db2, session.id, 0, "failed", now);
44334
+ db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
44335
+ "failed",
44336
+ errMsg,
44337
+ now,
44338
+ entry.turnId
44339
+ );
44340
+ recomputeSessionRunning(db2, session.id, "failed");
43563
44341
  broadcast("turn:failed", { sessionId: session.id, turnId: entry.turnId, error: errMsg });
43564
44342
  if (staleItems.changes > 0) {
43565
44343
  const staleRows = db2.prepare(
@@ -43608,8 +44386,13 @@ async function startTurn2(session, turn) {
43608
44386
  } catch (err) {
43609
44387
  const errMsg = `Failed to start Claude query: ${err.message}`;
43610
44388
  const now2 = (/* @__PURE__ */ new Date()).toISOString();
43611
- db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run("failed", errMsg, now2, turn.id);
43612
- setSessionStatus2(db2, session.id, 0, "failed", now2);
44389
+ db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
44390
+ "failed",
44391
+ errMsg,
44392
+ now2,
44393
+ turn.id
44394
+ );
44395
+ recomputeSessionRunning(db2, session.id, "failed");
43613
44396
  broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
43614
44397
  return;
43615
44398
  }
@@ -43644,7 +44427,11 @@ async function startTurn2(session, turn) {
43644
44427
  if (att.media_type.startsWith("image/")) {
43645
44428
  blocks.push({
43646
44429
  type: "image",
43647
- source: { type: "base64", media_type: att.media_type, data: att.data }
44430
+ source: {
44431
+ type: "base64",
44432
+ media_type: att.media_type,
44433
+ data: att.data
44434
+ }
43648
44435
  });
43649
44436
  } else if (att.media_type === "application/pdf") {
43650
44437
  blocks.push({
@@ -43685,17 +44472,43 @@ async function handleMessage(message, sessionId, turnId, entry, db2) {
43685
44472
  );
43686
44473
  }
43687
44474
  } else if (sub === "compact_boundary") {
43688
- handleCompactBoundary(message, sessionId, turnId, db2);
44475
+ handleCompactBoundary(
44476
+ message,
44477
+ sessionId,
44478
+ turnId,
44479
+ db2
44480
+ );
43689
44481
  } else if (sub === "task_started") {
43690
- handleTaskStarted(message, sessionId, turnId, entry, db2);
44482
+ handleTaskStarted(
44483
+ message,
44484
+ sessionId,
44485
+ turnId,
44486
+ entry,
44487
+ db2
44488
+ );
43691
44489
  } else if (sub === "task_progress") {
43692
- handleTaskProgress(message, sessionId, turnId, entry, db2);
44490
+ handleTaskProgress(
44491
+ message,
44492
+ sessionId,
44493
+ turnId,
44494
+ entry,
44495
+ db2
44496
+ );
43693
44497
  } else if (sub === "task_updated") {
43694
44498
  handleTaskUpdated(message, sessionId, turnId, db2);
43695
44499
  } else if (sub === "task_notification") {
43696
- handleTaskNotification(message, sessionId, turnId, entry, db2);
44500
+ handleTaskNotification(
44501
+ message,
44502
+ sessionId,
44503
+ turnId,
44504
+ entry,
44505
+ db2
44506
+ );
43697
44507
  } else if (sub === "background_tasks_changed") {
43698
- handleBackgroundTasksChanged(message, sessionId);
44508
+ handleBackgroundTasksChanged(
44509
+ message,
44510
+ sessionId
44511
+ );
43699
44512
  }
43700
44513
  }
43701
44514
  break;
@@ -43839,7 +44652,7 @@ function constructMonitorOutputPath(entry, taskId) {
43839
44652
  if (!entry.sessionId) return "";
43840
44653
  const uid = typeof process.getuid === "function" ? process.getuid() : 0;
43841
44654
  const encodedCwd = entry.cwd.replace(/\//g, "-");
43842
- return join(tmpdir(), `claude-${uid}`, encodedCwd, entry.sessionId, "tasks", `${taskId}.output`);
44655
+ return join2(tmpdir(), `claude-${uid}`, encodedCwd, entry.sessionId, "tasks", `${taskId}.output`);
43843
44656
  }
43844
44657
  function handleTaskStarted(message, sessionId, turnId, entry, db2) {
43845
44658
  const m = message;
@@ -43969,11 +44782,7 @@ async function handleResultMessage(message, sessionId, turnId, entry, db2) {
43969
44782
  if (message.subtype === "success") {
43970
44783
  const usage = mapUsage(message.usage);
43971
44784
  const now = (/* @__PURE__ */ new Date()).toISOString();
43972
- db2.prepare("UPDATE turns SET token_usage = ?, updated_at = ? WHERE id = ?").run(
43973
- JSON.stringify(usage),
43974
- now,
43975
- turnId
43976
- );
44785
+ db2.prepare("UPDATE turns SET token_usage = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(usage), now, turnId);
43977
44786
  broadcast("turn:tokenUsage", { sessionId, turnId, usage });
43978
44787
  try {
43979
44788
  const ctx = await entry.query.getContextUsage();
@@ -43997,8 +44806,13 @@ async function handleResultMessage(message, sessionId, turnId, entry, db2) {
43997
44806
  } else {
43998
44807
  const errorMsg = message.errors?.join("; ") ?? "Claude turn failed";
43999
44808
  const now = (/* @__PURE__ */ new Date()).toISOString();
44000
- db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run("failed", errorMsg, now, turnId);
44001
- setSessionStatus2(db2, sessionId, 0, "failed", now);
44809
+ db2.prepare("UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?").run(
44810
+ "failed",
44811
+ errorMsg,
44812
+ now,
44813
+ turnId
44814
+ );
44815
+ recomputeSessionRunning(db2, sessionId, "failed");
44002
44816
  broadcast("turn:failed", { sessionId, turnId, error: errorMsg });
44003
44817
  }
44004
44818
  }
@@ -44016,7 +44830,7 @@ function completeTurn(db2, sessionId, turnId, usage) {
44016
44830
  db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now, turnId);
44017
44831
  broadcast("turn:completed", { sessionId, turnId, hasUnreviewed: true });
44018
44832
  }
44019
- setSessionStatus2(db2, sessionId, 0, "active", now, true);
44833
+ recomputeSessionRunning(db2, sessionId, "active", true);
44020
44834
  syncThreadTitle2(sessionId);
44021
44835
  }
44022
44836
  function upsertItem(db2, desc, sessionId, turnId, status, broadcastEvent) {
@@ -44047,26 +44861,56 @@ function upsertItem(db2, desc, sessionId, turnId, status, broadcastEvent) {
44047
44861
  };
44048
44862
  broadcast(broadcastEvent, { sessionId, turnId, item: wsItem });
44049
44863
  }
44050
- async function interruptTurn2(sessionId) {
44051
- let entry = sessionMap2.get(sessionId);
44052
- if (!entry || !entry.turnId) {
44053
- for (const [key, threadEntry] of sessionMap2) {
44054
- if (key.startsWith(`${sessionId}:thread:`) && threadEntry.turnId) {
44055
- entry = threadEntry;
44056
- break;
44864
+ async function interruptTurn2(sessionId, threadId) {
44865
+ let entry;
44866
+ let entryKey = null;
44867
+ if (threadId) {
44868
+ entryKey = `${sessionId}:thread:${threadId}`;
44869
+ entry = sessionMap2.get(entryKey);
44870
+ } else {
44871
+ entry = sessionMap2.get(sessionId);
44872
+ entryKey = sessionId;
44873
+ if (!entry || !entry.turnId) {
44874
+ entryKey = null;
44875
+ for (const [key, threadEntry] of sessionMap2) {
44876
+ if (key.startsWith(`${sessionId}:thread:`) && threadEntry.turnId) {
44877
+ entry = threadEntry;
44878
+ entryKey = key;
44879
+ break;
44880
+ }
44057
44881
  }
44058
44882
  }
44059
44883
  }
44060
- if (!entry || !entry.turnId) return false;
44884
+ if (entry && entry.turnId && entryKey) {
44885
+ const turnId = entry.turnId;
44886
+ try {
44887
+ await entry.query.interrupt();
44888
+ const db2 = getDb();
44889
+ const now = (/* @__PURE__ */ new Date()).toISOString();
44890
+ db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, turnId);
44891
+ recomputeSessionRunning(db2, sessionId);
44892
+ broadcast("turn:cancelled", { sessionId, turnId });
44893
+ streamingMessageIds.delete(turnId);
44894
+ entry.turnId = null;
44895
+ return true;
44896
+ } catch {
44897
+ entry.promptQueue.close();
44898
+ entry.query.close();
44899
+ streamingMessageIds.delete(turnId);
44900
+ sessionMap2.delete(entryKey);
44901
+ }
44902
+ }
44061
44903
  try {
44062
- await entry.query.interrupt();
44063
44904
  const db2 = getDb();
44905
+ const orphan = db2.prepare(
44906
+ `SELECT id FROM turns WHERE session_id = ? ${threadId ? "AND thread_id = ?" : ""} AND status IN ('pending', 'running') ORDER BY created_at DESC LIMIT 1`
44907
+ ).get(...threadId ? [sessionId, threadId] : [sessionId]);
44908
+ if (!orphan) return false;
44064
44909
  const now = (/* @__PURE__ */ new Date()).toISOString();
44065
- db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, entry.turnId);
44066
- setSessionStatus2(db2, sessionId, 0, "active", now);
44067
- broadcast("turn:cancelled", { sessionId, turnId: entry.turnId });
44068
- streamingMessageIds.delete(entry.turnId);
44069
- entry.turnId = null;
44910
+ db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, orphan.id);
44911
+ recomputeSessionRunning(db2, sessionId);
44912
+ broadcast("turn:cancelled", { sessionId, turnId: orphan.id });
44913
+ streamingMessageIds.delete(orphan.id);
44070
44914
  return true;
44071
44915
  } catch {
44072
44916
  return false;
@@ -44327,8 +45171,8 @@ var RepoburgHttpClient = class {
44327
45171
  this.baseUrl = baseUrl.replace(/\/+$/, "");
44328
45172
  }
44329
45173
  /** Perform a JSON request. Throws a concise error on non-OK/non-JSON responses. */
44330
- async request(method, path3, body) {
44331
- const response = await fetch(`${this.baseUrl}${path3}`, {
45174
+ async request(method, path4, body) {
45175
+ const response = await fetch(`${this.baseUrl}${path4}`, {
44332
45176
  method,
44333
45177
  headers: { "Content-Type": "application/json" },
44334
45178
  body: body === void 0 ? void 0 : JSON.stringify(body)
@@ -44337,17 +45181,17 @@ var RepoburgHttpClient = class {
44337
45181
  if (!response.ok) {
44338
45182
  if (isHtml(text)) {
44339
45183
  throw new Error(
44340
- `${method} ${path3} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
45184
+ `${method} ${path4} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
44341
45185
  );
44342
45186
  }
44343
- throw new Error(`${method} ${path3} failed: ${response.status} ${text}`);
45187
+ throw new Error(`${method} ${path4} failed: ${response.status} ${text}`);
44344
45188
  }
44345
45189
  if (text.length === 0) return void 0;
44346
45190
  try {
44347
45191
  return JSON.parse(text);
44348
45192
  } catch {
44349
45193
  throw new Error(
44350
- `${method} ${path3} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
45194
+ `${method} ${path4} failed: non-JSON response from ${this.baseUrl} \u2014 the URL points to the wrong server`
44351
45195
  );
44352
45196
  }
44353
45197
  }
@@ -44402,7 +45246,7 @@ var RepoburgHttpClient = class {
44402
45246
  };
44403
45247
 
44404
45248
  // src/repoburg/backend-resolver.ts
44405
- import path2 from "node:path";
45249
+ import path3 from "node:path";
44406
45250
  var HEALTH_POLL_INTERVAL_MS = 1e3;
44407
45251
  var HEALTH_TIMEOUT_MS = 3e4;
44408
45252
  function daemonBaseUrl() {
@@ -44457,7 +45301,7 @@ async function backendHealthy(baseUrl, expectedPath) {
44457
45301
  const health = await fetchJson(`${baseUrl}/health`, void 0, 2e3);
44458
45302
  if (health.status !== "ok") return false;
44459
45303
  if (expectedPath && health.projectPath) {
44460
- return path2.resolve(health.projectPath) === path2.resolve(expectedPath);
45304
+ return path3.resolve(health.projectPath) === path3.resolve(expectedPath);
44461
45305
  }
44462
45306
  return true;
44463
45307
  } catch {
@@ -44510,7 +45354,7 @@ async function resolveBackendUrl(projectPath, opts = {}) {
44510
45354
  if (envUrl) {
44511
45355
  return { baseUrl: envUrl.replace(/\/+$/, ""), port: 0, name: "REPOBURG_BACKEND_URL" };
44512
45356
  }
44513
- const absPath = path2.resolve(projectPath);
45357
+ const absPath = path3.resolve(projectPath);
44514
45358
  const daemon = daemonBaseUrl();
44515
45359
  const cached = resolvedCache.get(absPath);
44516
45360
  if (cached && await backendHealthy(cached.baseUrl, absPath)) {
@@ -45150,7 +45994,7 @@ var TurnProjector = class {
45150
45994
  db2.prepare(
45151
45995
  "UPDATE turns SET status = ?, agent_response = ?, token_usage = ?, updated_at = ? WHERE id = ?"
45152
45996
  ).run("completed", responseText || null, usage ? JSON.stringify(usage) : null, now, this.deps.turnId);
45153
- setSessionStatus3(db2, this.deps.agentPaneSessionId, 0, "active", now, true);
45997
+ recomputeSessionRunning(db2, this.deps.agentPaneSessionId, "active", true);
45154
45998
  broadcast("turn:completed", {
45155
45999
  sessionId: this.deps.agentPaneSessionId,
45156
46000
  turnId: this.deps.turnId,
@@ -45287,7 +46131,7 @@ var TurnProjector = class {
45287
46131
  now,
45288
46132
  this.deps.turnId
45289
46133
  );
45290
- setSessionStatus3(db2, this.deps.agentPaneSessionId, 0, "failed", now);
46134
+ recomputeSessionRunning(db2, this.deps.agentPaneSessionId, "failed");
45291
46135
  broadcast("turn:failed", {
45292
46136
  sessionId: this.deps.agentPaneSessionId,
45293
46137
  turnId: this.deps.turnId,
@@ -45304,7 +46148,7 @@ var TurnProjector = class {
45304
46148
  now,
45305
46149
  this.deps.turnId
45306
46150
  );
45307
- setSessionStatus3(db2, this.deps.agentPaneSessionId, 0, "active", now);
46151
+ recomputeSessionRunning(db2, this.deps.agentPaneSessionId);
45308
46152
  broadcast("turn:cancelled", {
45309
46153
  sessionId: this.deps.agentPaneSessionId,
45310
46154
  turnId: this.deps.turnId
@@ -45373,7 +46217,7 @@ var TurnProjector = class {
45373
46217
  db2.prepare(
45374
46218
  "UPDATE turns SET status = ?, agent_response = ?, token_usage = ?, updated_at = ? WHERE id = ?"
45375
46219
  ).run("completed", responseText || null, usage ? JSON.stringify(usage) : null, now, this.deps.turnId);
45376
- setSessionStatus3(db2, this.deps.agentPaneSessionId, 0, "active", now, true);
46220
+ recomputeSessionRunning(db2, this.deps.agentPaneSessionId, "active", true);
45377
46221
  broadcast("turn:completed", {
45378
46222
  sessionId: this.deps.agentPaneSessionId,
45379
46223
  turnId: this.deps.turnId,
@@ -45599,7 +46443,7 @@ function failTurnBeforeStart(db2, sessionId, turnId, error) {
45599
46443
  now,
45600
46444
  turnId
45601
46445
  );
45602
- setSessionStatus3(db2, sessionId, 0, "failed", now);
46446
+ recomputeSessionRunning(db2, sessionId, "failed");
45603
46447
  broadcast("turn:failed", { sessionId, turnId, error });
45604
46448
  }
45605
46449
  function failTurn(entry, error) {
@@ -45622,7 +46466,7 @@ function failTurn(entry, error) {
45622
46466
  active.turnId,
45623
46467
  "in_progress"
45624
46468
  );
45625
- setSessionStatus3(db2, entry.agentPaneSessionId, 0, "failed", now);
46469
+ recomputeSessionRunning(db2, entry.agentPaneSessionId, "failed");
45626
46470
  broadcast("turn:failed", { sessionId: entry.agentPaneSessionId, turnId: active.turnId, error });
45627
46471
  }
45628
46472
  async function runStreamLoop(entry, projector) {
@@ -45739,9 +46583,9 @@ async function startTurn3(session, turn) {
45739
46583
  failTurn(entry, err.message);
45740
46584
  }
45741
46585
  }
45742
- async function interruptTurn3(sessionId) {
45743
- let entry = sessionMap3.get(sessionId);
45744
- if (!entry?.activeTurn) {
46586
+ async function interruptTurn3(sessionId, threadId) {
46587
+ let entry = threadId ? sessionMap3.get(`${sessionId}:thread:${threadId}`) : sessionMap3.get(sessionId);
46588
+ if (!threadId && !entry?.activeTurn) {
45745
46589
  for (const [key, threadEntry] of sessionMap3) {
45746
46590
  if (key.startsWith(`${sessionId}:thread:`) && threadEntry.activeTurn) {
45747
46591
  entry = threadEntry;
@@ -45765,7 +46609,7 @@ async function interruptTurn3(sessionId) {
45765
46609
  active.turnId,
45766
46610
  "in_progress"
45767
46611
  );
45768
- setSessionStatus3(db2, sessionId, 0, "active", now);
46612
+ recomputeSessionRunning(db2, sessionId);
45769
46613
  broadcast("turn:cancelled", { sessionId, turnId: active.turnId });
45770
46614
  return true;
45771
46615
  }
@@ -45921,11 +46765,15 @@ async function createAgentPaneApp(dbPath) {
45921
46765
  await registerPluginRoutes(fastify);
45922
46766
  await registerMcpRoutes(fastify);
45923
46767
  await registerFileRoutes(fastify);
46768
+ await registerPerfLogRoutes(fastify);
46769
+ await registerMaintenanceRoutes(fastify);
46770
+ await registerVscodeWebRoutes(fastify);
45924
46771
  const wss2 = initWs();
45925
46772
  return { fastify, wss: wss2 };
45926
46773
  }
45927
46774
  export {
45928
46775
  createAgentPaneApp,
46776
+ handleVscodeWebUpgrade,
45929
46777
  shutdownAllProviders
45930
46778
  };
45931
46779
  /*! Bundled license information: