@hirohsu/user-web-feedback 2.6.10 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -949,9 +949,9 @@ var require_command = __commonJS({
949
949
  "node_modules/.pnpm/commander@11.1.0/node_modules/commander/lib/command.js"(exports2) {
950
950
  "use strict";
951
951
  init_cjs_shims();
952
- var EventEmitter2 = require("events").EventEmitter;
952
+ var EventEmitter5 = require("events").EventEmitter;
953
953
  var childProcess3 = require("child_process");
954
- var path9 = require("path");
954
+ var path10 = require("path");
955
955
  var fs9 = require("fs");
956
956
  var process10 = require("process");
957
957
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -959,7 +959,7 @@ var require_command = __commonJS({
959
959
  var { Help: Help2 } = require_help();
960
960
  var { Option: Option2, splitOptionFlags, DualOptions } = require_option();
961
961
  var { suggestSimilar } = require_suggestSimilar();
962
- var Command2 = class _Command extends EventEmitter2 {
962
+ var Command2 = class _Command extends EventEmitter5 {
963
963
  /**
964
964
  * Initialize a new `Command`.
965
965
  *
@@ -1775,9 +1775,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1775
1775
  let launchWithNode = false;
1776
1776
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1777
1777
  function findFile(baseDir, baseName) {
1778
- const localBin = path9.resolve(baseDir, baseName);
1778
+ const localBin = path10.resolve(baseDir, baseName);
1779
1779
  if (fs9.existsSync(localBin)) return localBin;
1780
- if (sourceExt.includes(path9.extname(baseName))) return void 0;
1780
+ if (sourceExt.includes(path10.extname(baseName))) return void 0;
1781
1781
  const foundExt = sourceExt.find((ext) => fs9.existsSync(`${localBin}${ext}`));
1782
1782
  if (foundExt) return `${localBin}${foundExt}`;
1783
1783
  return void 0;
@@ -1793,19 +1793,19 @@ Expecting one of '${allowedValues.join("', '")}'`);
1793
1793
  } catch (err) {
1794
1794
  resolvedScriptPath = this._scriptPath;
1795
1795
  }
1796
- executableDir = path9.resolve(path9.dirname(resolvedScriptPath), executableDir);
1796
+ executableDir = path10.resolve(path10.dirname(resolvedScriptPath), executableDir);
1797
1797
  }
1798
1798
  if (executableDir) {
1799
1799
  let localFile = findFile(executableDir, executableFile);
1800
1800
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1801
- const legacyName = path9.basename(this._scriptPath, path9.extname(this._scriptPath));
1801
+ const legacyName = path10.basename(this._scriptPath, path10.extname(this._scriptPath));
1802
1802
  if (legacyName !== this._name) {
1803
1803
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1804
1804
  }
1805
1805
  }
1806
1806
  executableFile = localFile || executableFile;
1807
1807
  }
1808
- launchWithNode = sourceExt.includes(path9.extname(executableFile));
1808
+ launchWithNode = sourceExt.includes(path10.extname(executableFile));
1809
1809
  let proc;
1810
1810
  if (process10.platform !== "win32") {
1811
1811
  if (launchWithNode) {
@@ -2588,7 +2588,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2588
2588
  * @return {Command}
2589
2589
  */
2590
2590
  nameFromFilename(filename) {
2591
- this._name = path9.basename(filename, path9.extname(filename));
2591
+ this._name = path10.basename(filename, path10.extname(filename));
2592
2592
  return this;
2593
2593
  }
2594
2594
  /**
@@ -2602,9 +2602,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2602
2602
  * @param {string} [path]
2603
2603
  * @return {string|null|Command}
2604
2604
  */
2605
- executableDir(path10) {
2606
- if (path10 === void 0) return this._executableDir;
2607
- this._executableDir = path10;
2605
+ executableDir(path11) {
2606
+ if (path11 === void 0) return this._executableDir;
2607
+ this._executableDir = path11;
2608
2608
  return this;
2609
2609
  }
2610
2610
  /**
@@ -2870,8 +2870,8 @@ var require_main = __commonJS({
2870
2870
  "use strict";
2871
2871
  init_cjs_shims();
2872
2872
  var fs9 = require("fs");
2873
- var path9 = require("path");
2874
- var os3 = require("os");
2873
+ var path10 = require("path");
2874
+ var os4 = require("os");
2875
2875
  var crypto4 = require("crypto");
2876
2876
  var packageJson = require_package();
2877
2877
  var version2 = packageJson.version;
@@ -2986,7 +2986,7 @@ var require_main = __commonJS({
2986
2986
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
2987
2987
  }
2988
2988
  } else {
2989
- possibleVaultPath = path9.resolve(process.cwd(), ".env.vault");
2989
+ possibleVaultPath = path10.resolve(process.cwd(), ".env.vault");
2990
2990
  }
2991
2991
  if (fs9.existsSync(possibleVaultPath)) {
2992
2992
  return possibleVaultPath;
@@ -2994,7 +2994,7 @@ var require_main = __commonJS({
2994
2994
  return null;
2995
2995
  }
2996
2996
  function _resolveHome(envPath) {
2997
- return envPath[0] === "~" ? path9.join(os3.homedir(), envPath.slice(1)) : envPath;
2997
+ return envPath[0] === "~" ? path10.join(os4.homedir(), envPath.slice(1)) : envPath;
2998
2998
  }
2999
2999
  function _configVault(options) {
3000
3000
  const debug = Boolean(options && options.debug);
@@ -3011,7 +3011,7 @@ var require_main = __commonJS({
3011
3011
  return { parsed };
3012
3012
  }
3013
3013
  function configDotenv(options) {
3014
- const dotenvPath = path9.resolve(process.cwd(), ".env");
3014
+ const dotenvPath = path10.resolve(process.cwd(), ".env");
3015
3015
  let encoding = "utf8";
3016
3016
  const debug = Boolean(options && options.debug);
3017
3017
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -3035,13 +3035,13 @@ var require_main = __commonJS({
3035
3035
  }
3036
3036
  let lastError;
3037
3037
  const parsedAll = {};
3038
- for (const path10 of optionPaths) {
3038
+ for (const path11 of optionPaths) {
3039
3039
  try {
3040
- const parsed = DotenvModule.parse(fs9.readFileSync(path10, { encoding }));
3040
+ const parsed = DotenvModule.parse(fs9.readFileSync(path11, { encoding }));
3041
3041
  DotenvModule.populate(parsedAll, parsed, options);
3042
3042
  } catch (e) {
3043
3043
  if (debug) {
3044
- _debug(`Failed to load ${path10} ${e.message}`);
3044
+ _debug(`Failed to load ${path11} ${e.message}`);
3045
3045
  }
3046
3046
  lastError = e;
3047
3047
  }
@@ -3056,7 +3056,7 @@ var require_main = __commonJS({
3056
3056
  const shortPaths = [];
3057
3057
  for (const filePath2 of optionPaths) {
3058
3058
  try {
3059
- const relative = path9.relative(process.cwd(), filePath2);
3059
+ const relative = path10.relative(process.cwd(), filePath2);
3060
3060
  shortPaths.push(relative);
3061
3061
  } catch (e) {
3062
3062
  if (debug) {
@@ -3303,6 +3303,7 @@ __export(database_exports, {
3303
3303
  getPinnedPrompts: () => getPinnedPrompts,
3304
3304
  getPromptById: () => getPromptById,
3305
3305
  getRecentMCPServerErrors: () => getRecentMCPServerErrors,
3306
+ getSelfProbeSettings: () => getSelfProbeSettings,
3306
3307
  getToolEnableConfigs: () => getToolEnableConfigs,
3307
3308
  getUserPreferences: () => getUserPreferences,
3308
3309
  initDatabase: () => initDatabase,
@@ -3318,6 +3319,7 @@ __export(database_exports, {
3318
3319
  queryLogs: () => queryLogs,
3319
3320
  queryMCPServerLogs: () => queryMCPServerLogs,
3320
3321
  reorderPrompts: () => reorderPrompts,
3322
+ saveSelfProbeSettings: () => saveSelfProbeSettings,
3321
3323
  setToolEnabled: () => setToolEnabled,
3322
3324
  toggleMCPServerEnabled: () => toggleMCPServerEnabled,
3323
3325
  togglePromptPin: () => togglePromptPin,
@@ -3616,6 +3618,14 @@ function createTables() {
3616
3618
  }
3617
3619
  } catch {
3618
3620
  }
3621
+ db.exec(`
3622
+ CREATE TABLE IF NOT EXISTS self_probe_settings (
3623
+ id INTEGER PRIMARY KEY CHECK (id = 1),
3624
+ enabled INTEGER DEFAULT 0,
3625
+ interval_seconds INTEGER DEFAULT 300,
3626
+ updated_at TEXT DEFAULT CURRENT_TIMESTAMP
3627
+ )
3628
+ `);
3619
3629
  }
3620
3630
  function initDefaultSettings() {
3621
3631
  if (!db) throw new Error("Database not initialized");
@@ -4961,6 +4971,55 @@ function cleanupOldCLIExecutionLogs(daysToKeep = 7) {
4961
4971
  `).run(cutoffDate.toISOString());
4962
4972
  return result.changes;
4963
4973
  }
4974
+ function getSelfProbeSettings() {
4975
+ const db2 = tryGetDb();
4976
+ if (!db2) return void 0;
4977
+ const row = db2.prepare(`
4978
+ SELECT
4979
+ id,
4980
+ enabled,
4981
+ interval_seconds as intervalSeconds,
4982
+ updated_at as updatedAt
4983
+ FROM self_probe_settings
4984
+ WHERE id = 1
4985
+ `).get();
4986
+ if (!row) return void 0;
4987
+ return {
4988
+ id: row.id,
4989
+ enabled: row.enabled === 1,
4990
+ intervalSeconds: row.intervalSeconds,
4991
+ updatedAt: row.updatedAt
4992
+ };
4993
+ }
4994
+ function saveSelfProbeSettings(settings) {
4995
+ const db2 = tryGetDb();
4996
+ if (!db2) throw new Error("Database not initialized");
4997
+ const existing = getSelfProbeSettings();
4998
+ const now = (/* @__PURE__ */ new Date()).toISOString();
4999
+ if (existing) {
5000
+ db2.prepare(`
5001
+ UPDATE self_probe_settings
5002
+ SET enabled = COALESCE(?, enabled),
5003
+ interval_seconds = COALESCE(?, interval_seconds),
5004
+ updated_at = ?
5005
+ WHERE id = 1
5006
+ `).run(
5007
+ settings.enabled !== void 0 ? settings.enabled ? 1 : 0 : null,
5008
+ settings.intervalSeconds ?? null,
5009
+ now
5010
+ );
5011
+ } else {
5012
+ db2.prepare(`
5013
+ INSERT INTO self_probe_settings (id, enabled, interval_seconds, updated_at)
5014
+ VALUES (1, ?, ?, ?)
5015
+ `).run(
5016
+ settings.enabled ? 1 : 0,
5017
+ settings.intervalSeconds ?? 300,
5018
+ now
5019
+ );
5020
+ }
5021
+ return getSelfProbeSettings();
5022
+ }
4964
5023
  var import_better_sqlite3, import_path2, import_fs2, import_crypto2, DB_DIR, DB_PATH, db, SYSTEM_PROMPT_VERSIONS, CURRENT_PROMPT_VERSION;
4965
5024
  var init_database = __esm({
4966
5025
  "src/utils/database.ts"() {
@@ -5909,8 +5968,8 @@ var init_parseUtil = __esm({
5909
5968
  init_errors();
5910
5969
  init_en();
5911
5970
  makeIssue = (params) => {
5912
- const { data, path: path9, errorMaps, issueData } = params;
5913
- const fullPath = [...path9, ...issueData.path || []];
5971
+ const { data, path: path10, errorMaps, issueData } = params;
5972
+ const fullPath = [...path10, ...issueData.path || []];
5914
5973
  const fullIssue = {
5915
5974
  ...issueData,
5916
5975
  path: fullPath
@@ -6224,11 +6283,11 @@ var init_types = __esm({
6224
6283
  init_parseUtil();
6225
6284
  init_util();
6226
6285
  ParseInputLazyPath = class {
6227
- constructor(parent, value, path9, key) {
6286
+ constructor(parent, value, path10, key) {
6228
6287
  this._cachedPath = [];
6229
6288
  this.parent = parent;
6230
6289
  this.data = value;
6231
- this._path = path9;
6290
+ this._path = path10;
6232
6291
  this._key = key;
6233
6292
  }
6234
6293
  get path() {
@@ -9814,10 +9873,10 @@ function assignProp(target, prop, value) {
9814
9873
  configurable: true
9815
9874
  });
9816
9875
  }
9817
- function getElementAtPath(obj, path9) {
9818
- if (!path9)
9876
+ function getElementAtPath(obj, path10) {
9877
+ if (!path10)
9819
9878
  return obj;
9820
- return path9.reduce((acc, key) => acc?.[key], obj);
9879
+ return path10.reduce((acc, key) => acc?.[key], obj);
9821
9880
  }
9822
9881
  function promiseAllObject(promisesObj) {
9823
9882
  const keys = Object.keys(promisesObj);
@@ -10066,11 +10125,11 @@ function aborted(x, startIndex = 0) {
10066
10125
  }
10067
10126
  return false;
10068
10127
  }
10069
- function prefixIssues(path9, issues) {
10128
+ function prefixIssues(path10, issues) {
10070
10129
  return issues.map((iss) => {
10071
10130
  var _a;
10072
10131
  (_a = iss).path ?? (_a.path = []);
10073
- iss.path.unshift(path9);
10132
+ iss.path.unshift(path10);
10074
10133
  return iss;
10075
10134
  });
10076
10135
  }
@@ -18529,7 +18588,7 @@ var init_protocol = __esm({
18529
18588
  return;
18530
18589
  }
18531
18590
  const pollInterval = (_c = (_a = task2.pollInterval) !== null && _a !== void 0 ? _a : (_b = this._options) === null || _b === void 0 ? void 0 : _b.defaultTaskPollInterval) !== null && _c !== void 0 ? _c : 1e3;
18532
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
18591
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
18533
18592
  (_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.throwIfAborted();
18534
18593
  }
18535
18594
  } catch (error2) {
@@ -18546,7 +18605,7 @@ var init_protocol = __esm({
18546
18605
  */
18547
18606
  request(request, resultSchema, options) {
18548
18607
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options !== null && options !== void 0 ? options : {};
18549
- return new Promise((resolve, reject) => {
18608
+ return new Promise((resolve2, reject) => {
18550
18609
  var _a, _b, _c, _d, _e, _f, _g;
18551
18610
  const earlyReject = (error2) => {
18552
18611
  reject(error2);
@@ -18627,7 +18686,7 @@ var init_protocol = __esm({
18627
18686
  if (!parseResult.success) {
18628
18687
  reject(parseResult.error);
18629
18688
  } else {
18630
- resolve(parseResult.data);
18689
+ resolve2(parseResult.data);
18631
18690
  }
18632
18691
  } catch (error2) {
18633
18692
  reject(error2);
@@ -18893,12 +18952,12 @@ var init_protocol = __esm({
18893
18952
  }
18894
18953
  } catch (_d) {
18895
18954
  }
18896
- return new Promise((resolve, reject) => {
18955
+ return new Promise((resolve2, reject) => {
18897
18956
  if (signal.aborted) {
18898
18957
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
18899
18958
  return;
18900
18959
  }
18901
- const timeoutId = setTimeout(resolve, interval);
18960
+ const timeoutId = setTimeout(resolve2, interval);
18902
18961
  signal.addEventListener("abort", () => {
18903
18962
  clearTimeout(timeoutId);
18904
18963
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -21946,7 +22005,7 @@ var require_compile = __commonJS({
21946
22005
  const schOrFunc = root.refs[ref];
21947
22006
  if (schOrFunc)
21948
22007
  return schOrFunc;
21949
- let _sch = resolve.call(this, root, ref);
22008
+ let _sch = resolve2.call(this, root, ref);
21950
22009
  if (_sch === void 0) {
21951
22010
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
21952
22011
  const { schemaId } = this.opts;
@@ -21973,7 +22032,7 @@ var require_compile = __commonJS({
21973
22032
  function sameSchemaEnv(s1, s2) {
21974
22033
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
21975
22034
  }
21976
- function resolve(root, ref) {
22035
+ function resolve2(root, ref) {
21977
22036
  let sch;
21978
22037
  while (typeof (sch = this.refs[ref]) == "string")
21979
22038
  ref = sch;
@@ -22189,8 +22248,8 @@ var require_utils = __commonJS({
22189
22248
  }
22190
22249
  return ind;
22191
22250
  }
22192
- function removeDotSegments(path9) {
22193
- let input = path9;
22251
+ function removeDotSegments(path10) {
22252
+ let input = path10;
22194
22253
  const output = [];
22195
22254
  let nextSlash = -1;
22196
22255
  let len = 0;
@@ -22390,8 +22449,8 @@ var require_schemes = __commonJS({
22390
22449
  wsComponent.secure = void 0;
22391
22450
  }
22392
22451
  if (wsComponent.resourceName) {
22393
- const [path9, query] = wsComponent.resourceName.split("?");
22394
- wsComponent.path = path9 && path9 !== "/" ? path9 : void 0;
22452
+ const [path10, query] = wsComponent.resourceName.split("?");
22453
+ wsComponent.path = path10 && path10 !== "/" ? path10 : void 0;
22395
22454
  wsComponent.query = query;
22396
22455
  wsComponent.resourceName = void 0;
22397
22456
  }
@@ -22551,7 +22610,7 @@ var require_fast_uri = __commonJS({
22551
22610
  }
22552
22611
  return uri;
22553
22612
  }
22554
- function resolve(baseURI, relativeURI, options) {
22613
+ function resolve2(baseURI, relativeURI, options) {
22555
22614
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
22556
22615
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
22557
22616
  schemelessOptions.skipEscape = true;
@@ -22778,7 +22837,7 @@ var require_fast_uri = __commonJS({
22778
22837
  var fastUri = {
22779
22838
  SCHEMES,
22780
22839
  normalize,
22781
- resolve,
22840
+ resolve: resolve2,
22782
22841
  resolveComponent,
22783
22842
  equal,
22784
22843
  serialize,
@@ -27293,7 +27352,7 @@ var require_destroy = __commonJS({
27293
27352
  "node_modules/.pnpm/destroy@1.2.0/node_modules/destroy/index.js"(exports2, module2) {
27294
27353
  "use strict";
27295
27354
  init_cjs_shims();
27296
- var EventEmitter2 = require("events").EventEmitter;
27355
+ var EventEmitter5 = require("events").EventEmitter;
27297
27356
  var ReadStream = require("fs").ReadStream;
27298
27357
  var Stream = require("stream");
27299
27358
  var Zlib = require("zlib");
@@ -27355,7 +27414,7 @@ var require_destroy = __commonJS({
27355
27414
  return stream instanceof Stream && typeof stream.destroy === "function";
27356
27415
  }
27357
27416
  function isEventEmitter(val) {
27358
- return val instanceof EventEmitter2;
27417
+ return val instanceof EventEmitter5;
27359
27418
  }
27360
27419
  function isFsReadStream(stream) {
27361
27420
  return stream instanceof ReadStream;
@@ -30910,10 +30969,10 @@ var require_raw_body = __commonJS({
30910
30969
  if (done) {
30911
30970
  return readStream(stream, encoding, length, limit, wrap(done));
30912
30971
  }
30913
- return new Promise(function executor(resolve, reject) {
30972
+ return new Promise(function executor(resolve2, reject) {
30914
30973
  readStream(stream, encoding, length, limit, function onRead(err, buf) {
30915
30974
  if (err) return reject(err);
30916
- resolve(buf);
30975
+ resolve2(buf);
30917
30976
  });
30918
30977
  });
30919
30978
  }
@@ -40053,11 +40112,11 @@ var require_mime_types = __commonJS({
40053
40112
  }
40054
40113
  return exts[0];
40055
40114
  }
40056
- function lookup(path9) {
40057
- if (!path9 || typeof path9 !== "string") {
40115
+ function lookup(path10) {
40116
+ if (!path10 || typeof path10 !== "string") {
40058
40117
  return false;
40059
40118
  }
40060
- var extension2 = extname("x." + path9).toLowerCase().substr(1);
40119
+ var extension2 = extname("x." + path10).toLowerCase().substr(1);
40061
40120
  if (!extension2) {
40062
40121
  return false;
40063
40122
  }
@@ -43531,7 +43590,7 @@ var require_path_to_regexp = __commonJS({
43531
43590
  init_cjs_shims();
43532
43591
  module2.exports = pathToRegexp;
43533
43592
  var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
43534
- function pathToRegexp(path9, keys, options) {
43593
+ function pathToRegexp(path10, keys, options) {
43535
43594
  options = options || {};
43536
43595
  keys = keys || [];
43537
43596
  var strict = options.strict;
@@ -43545,8 +43604,8 @@ var require_path_to_regexp = __commonJS({
43545
43604
  var pos = 0;
43546
43605
  var backtrack = "";
43547
43606
  var m;
43548
- if (path9 instanceof RegExp) {
43549
- while (m = MATCHING_GROUP_REGEXP.exec(path9.source)) {
43607
+ if (path10 instanceof RegExp) {
43608
+ while (m = MATCHING_GROUP_REGEXP.exec(path10.source)) {
43550
43609
  if (m[0][0] === "\\") continue;
43551
43610
  keys.push({
43552
43611
  name: m[1] || name++,
@@ -43554,18 +43613,18 @@ var require_path_to_regexp = __commonJS({
43554
43613
  offset: m.index
43555
43614
  });
43556
43615
  }
43557
- return path9;
43616
+ return path10;
43558
43617
  }
43559
- if (Array.isArray(path9)) {
43560
- path9 = path9.map(function(value) {
43618
+ if (Array.isArray(path10)) {
43619
+ path10 = path10.map(function(value) {
43561
43620
  return pathToRegexp(value, keys, options).source;
43562
43621
  });
43563
- return new RegExp(path9.join("|"), flags);
43622
+ return new RegExp(path10.join("|"), flags);
43564
43623
  }
43565
- if (typeof path9 !== "string") {
43624
+ if (typeof path10 !== "string") {
43566
43625
  throw new TypeError("path must be a string, array of strings, or regular expression");
43567
43626
  }
43568
- path9 = path9.replace(
43627
+ path10 = path10.replace(
43569
43628
  /\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,
43570
43629
  function(match, slash, format, key, capture, star, optional2, offset) {
43571
43630
  if (match[0] === "\\") {
@@ -43582,7 +43641,7 @@ var require_path_to_regexp = __commonJS({
43582
43641
  if (slash || format) {
43583
43642
  backtrack = "";
43584
43643
  } else {
43585
- backtrack += path9.slice(pos, offset);
43644
+ backtrack += path10.slice(pos, offset);
43586
43645
  }
43587
43646
  pos = offset + match.length;
43588
43647
  if (match === "*") {
@@ -43610,7 +43669,7 @@ var require_path_to_regexp = __commonJS({
43610
43669
  return result;
43611
43670
  }
43612
43671
  );
43613
- while (m = MATCHING_GROUP_REGEXP.exec(path9)) {
43672
+ while (m = MATCHING_GROUP_REGEXP.exec(path10)) {
43614
43673
  if (m[0][0] === "\\") continue;
43615
43674
  if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
43616
43675
  keys.splice(keysOffset + i, 0, {
@@ -43622,13 +43681,13 @@ var require_path_to_regexp = __commonJS({
43622
43681
  }
43623
43682
  i++;
43624
43683
  }
43625
- path9 += strict ? "" : path9[path9.length - 1] === "/" ? "?" : "/?";
43684
+ path10 += strict ? "" : path10[path10.length - 1] === "/" ? "?" : "/?";
43626
43685
  if (end) {
43627
- path9 += "$";
43628
- } else if (path9[path9.length - 1] !== "/") {
43629
- path9 += lookahead ? "(?=/|$)" : "(?:/|$)";
43686
+ path10 += "$";
43687
+ } else if (path10[path10.length - 1] !== "/") {
43688
+ path10 += lookahead ? "(?=/|$)" : "(?:/|$)";
43630
43689
  }
43631
- return new RegExp("^" + path9, flags);
43690
+ return new RegExp("^" + path10, flags);
43632
43691
  }
43633
43692
  }
43634
43693
  });
@@ -43642,19 +43701,19 @@ var require_layer = __commonJS({
43642
43701
  var debug = require_src()("express:router:layer");
43643
43702
  var hasOwnProperty = Object.prototype.hasOwnProperty;
43644
43703
  module2.exports = Layer;
43645
- function Layer(path9, options, fn) {
43704
+ function Layer(path10, options, fn) {
43646
43705
  if (!(this instanceof Layer)) {
43647
- return new Layer(path9, options, fn);
43706
+ return new Layer(path10, options, fn);
43648
43707
  }
43649
- debug("new %o", path9);
43708
+ debug("new %o", path10);
43650
43709
  var opts = options || {};
43651
43710
  this.handle = fn;
43652
43711
  this.name = fn.name || "<anonymous>";
43653
43712
  this.params = void 0;
43654
43713
  this.path = void 0;
43655
- this.regexp = pathRegexp(path9, this.keys = [], opts);
43656
- this.regexp.fast_star = path9 === "*";
43657
- this.regexp.fast_slash = path9 === "/" && opts.end === false;
43714
+ this.regexp = pathRegexp(path10, this.keys = [], opts);
43715
+ this.regexp.fast_star = path10 === "*";
43716
+ this.regexp.fast_slash = path10 === "/" && opts.end === false;
43658
43717
  }
43659
43718
  Layer.prototype.handle_error = function handle_error(error2, req, res, next) {
43660
43719
  var fn = this.handle;
@@ -43678,20 +43737,20 @@ var require_layer = __commonJS({
43678
43737
  next(err);
43679
43738
  }
43680
43739
  };
43681
- Layer.prototype.match = function match(path9) {
43740
+ Layer.prototype.match = function match(path10) {
43682
43741
  var match2;
43683
- if (path9 != null) {
43742
+ if (path10 != null) {
43684
43743
  if (this.regexp.fast_slash) {
43685
43744
  this.params = {};
43686
43745
  this.path = "";
43687
43746
  return true;
43688
43747
  }
43689
43748
  if (this.regexp.fast_star) {
43690
- this.params = { "0": decode_param(path9) };
43691
- this.path = path9;
43749
+ this.params = { "0": decode_param(path10) };
43750
+ this.path = path10;
43692
43751
  return true;
43693
43752
  }
43694
- match2 = this.regexp.exec(path9);
43753
+ match2 = this.regexp.exec(path10);
43695
43754
  }
43696
43755
  if (!match2) {
43697
43756
  this.params = void 0;
@@ -43786,10 +43845,10 @@ var require_route = __commonJS({
43786
43845
  var slice = Array.prototype.slice;
43787
43846
  var toString = Object.prototype.toString;
43788
43847
  module2.exports = Route;
43789
- function Route(path9) {
43790
- this.path = path9;
43848
+ function Route(path10) {
43849
+ this.path = path10;
43791
43850
  this.stack = [];
43792
- debug("new %o", path9);
43851
+ debug("new %o", path10);
43793
43852
  this.methods = {};
43794
43853
  }
43795
43854
  Route.prototype._handles_method = function _handles_method(method) {
@@ -44004,8 +44063,8 @@ var require_router = __commonJS({
44004
44063
  if (++sync > 100) {
44005
44064
  return setImmediate(next, err);
44006
44065
  }
44007
- var path9 = getPathname(req);
44008
- if (path9 == null) {
44066
+ var path10 = getPathname(req);
44067
+ if (path10 == null) {
44009
44068
  return done(layerError);
44010
44069
  }
44011
44070
  var layer;
@@ -44013,7 +44072,7 @@ var require_router = __commonJS({
44013
44072
  var route;
44014
44073
  while (match !== true && idx < stack.length) {
44015
44074
  layer = stack[idx++];
44016
- match = matchLayer(layer, path9);
44075
+ match = matchLayer(layer, path10);
44017
44076
  route = layer.route;
44018
44077
  if (typeof match !== "boolean") {
44019
44078
  layerError = layerError || match;
@@ -44051,18 +44110,18 @@ var require_router = __commonJS({
44051
44110
  } else if (route) {
44052
44111
  layer.handle_request(req, res, next);
44053
44112
  } else {
44054
- trim_prefix(layer, layerError, layerPath, path9);
44113
+ trim_prefix(layer, layerError, layerPath, path10);
44055
44114
  }
44056
44115
  sync = 0;
44057
44116
  });
44058
44117
  }
44059
- function trim_prefix(layer, layerError, layerPath, path9) {
44118
+ function trim_prefix(layer, layerError, layerPath, path10) {
44060
44119
  if (layerPath.length !== 0) {
44061
- if (layerPath !== path9.slice(0, layerPath.length)) {
44120
+ if (layerPath !== path10.slice(0, layerPath.length)) {
44062
44121
  next(layerError);
44063
44122
  return;
44064
44123
  }
44065
- var c = path9[layerPath.length];
44124
+ var c = path10[layerPath.length];
44066
44125
  if (c && c !== "/" && c !== ".") return next(layerError);
44067
44126
  debug("trim prefix (%s) from url %s", layerPath, req.url);
44068
44127
  removed = layerPath;
@@ -44140,7 +44199,7 @@ var require_router = __commonJS({
44140
44199
  };
44141
44200
  proto.use = function use(fn) {
44142
44201
  var offset = 0;
44143
- var path9 = "/";
44202
+ var path10 = "/";
44144
44203
  if (typeof fn !== "function") {
44145
44204
  var arg = fn;
44146
44205
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -44148,7 +44207,7 @@ var require_router = __commonJS({
44148
44207
  }
44149
44208
  if (typeof arg !== "function") {
44150
44209
  offset = 1;
44151
- path9 = fn;
44210
+ path10 = fn;
44152
44211
  }
44153
44212
  }
44154
44213
  var callbacks = flatten(slice.call(arguments, offset));
@@ -44160,8 +44219,8 @@ var require_router = __commonJS({
44160
44219
  if (typeof fn !== "function") {
44161
44220
  throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
44162
44221
  }
44163
- debug("use %o %s", path9, fn.name || "<anonymous>");
44164
- var layer = new Layer(path9, {
44222
+ debug("use %o %s", path10, fn.name || "<anonymous>");
44223
+ var layer = new Layer(path10, {
44165
44224
  sensitive: this.caseSensitive,
44166
44225
  strict: false,
44167
44226
  end: false
@@ -44171,9 +44230,9 @@ var require_router = __commonJS({
44171
44230
  }
44172
44231
  return this;
44173
44232
  };
44174
- proto.route = function route(path9) {
44175
- var route2 = new Route(path9);
44176
- var layer = new Layer(path9, {
44233
+ proto.route = function route(path10) {
44234
+ var route2 = new Route(path10);
44235
+ var layer = new Layer(path10, {
44177
44236
  sensitive: this.caseSensitive,
44178
44237
  strict: this.strict,
44179
44238
  end: true
@@ -44183,8 +44242,8 @@ var require_router = __commonJS({
44183
44242
  return route2;
44184
44243
  };
44185
44244
  methods.concat("all").forEach(function(method) {
44186
- proto[method] = function(path9) {
44187
- var route = this.route(path9);
44245
+ proto[method] = function(path10) {
44246
+ var route = this.route(path10);
44188
44247
  route[method].apply(route, slice.call(arguments, 1));
44189
44248
  return this;
44190
44249
  };
@@ -44220,9 +44279,9 @@ var require_router = __commonJS({
44220
44279
  }
44221
44280
  return toString.call(obj).replace(objectRegExp, "$1");
44222
44281
  }
44223
- function matchLayer(layer, path9) {
44282
+ function matchLayer(layer, path10) {
44224
44283
  try {
44225
- return layer.match(path9);
44284
+ return layer.match(path10);
44226
44285
  } catch (err) {
44227
44286
  return err;
44228
44287
  }
@@ -44343,13 +44402,13 @@ var require_view = __commonJS({
44343
44402
  "use strict";
44344
44403
  init_cjs_shims();
44345
44404
  var debug = require_src()("express:view");
44346
- var path9 = require("path");
44405
+ var path10 = require("path");
44347
44406
  var fs9 = require("fs");
44348
- var dirname2 = path9.dirname;
44349
- var basename = path9.basename;
44350
- var extname = path9.extname;
44351
- var join2 = path9.join;
44352
- var resolve = path9.resolve;
44407
+ var dirname3 = path10.dirname;
44408
+ var basename = path10.basename;
44409
+ var extname = path10.extname;
44410
+ var join2 = path10.join;
44411
+ var resolve2 = path10.resolve;
44353
44412
  module2.exports = View;
44354
44413
  function View(name, options) {
44355
44414
  var opts = options || {};
@@ -44378,39 +44437,39 @@ var require_view = __commonJS({
44378
44437
  this.path = this.lookup(fileName);
44379
44438
  }
44380
44439
  View.prototype.lookup = function lookup(name) {
44381
- var path10;
44440
+ var path11;
44382
44441
  var roots = [].concat(this.root);
44383
44442
  debug('lookup "%s"', name);
44384
- for (var i = 0; i < roots.length && !path10; i++) {
44443
+ for (var i = 0; i < roots.length && !path11; i++) {
44385
44444
  var root = roots[i];
44386
- var loc = resolve(root, name);
44387
- var dir = dirname2(loc);
44445
+ var loc = resolve2(root, name);
44446
+ var dir = dirname3(loc);
44388
44447
  var file = basename(loc);
44389
- path10 = this.resolve(dir, file);
44448
+ path11 = this.resolve(dir, file);
44390
44449
  }
44391
- return path10;
44450
+ return path11;
44392
44451
  };
44393
44452
  View.prototype.render = function render(options, callback) {
44394
44453
  debug('render "%s"', this.path);
44395
44454
  this.engine(this.path, options, callback);
44396
44455
  };
44397
- View.prototype.resolve = function resolve2(dir, file) {
44456
+ View.prototype.resolve = function resolve3(dir, file) {
44398
44457
  var ext = this.ext;
44399
- var path10 = join2(dir, file);
44400
- var stat = tryStat(path10);
44458
+ var path11 = join2(dir, file);
44459
+ var stat = tryStat(path11);
44401
44460
  if (stat && stat.isFile()) {
44402
- return path10;
44461
+ return path11;
44403
44462
  }
44404
- path10 = join2(dir, basename(file, ext), "index" + ext);
44405
- stat = tryStat(path10);
44463
+ path11 = join2(dir, basename(file, ext), "index" + ext);
44464
+ stat = tryStat(path11);
44406
44465
  if (stat && stat.isFile()) {
44407
- return path10;
44466
+ return path11;
44408
44467
  }
44409
44468
  };
44410
- function tryStat(path10) {
44411
- debug('stat "%s"', path10);
44469
+ function tryStat(path11) {
44470
+ debug('stat "%s"', path11);
44412
44471
  try {
44413
- return fs9.statSync(path10);
44472
+ return fs9.statSync(path11);
44414
44473
  } catch (e) {
44415
44474
  return void 0;
44416
44475
  }
@@ -45079,7 +45138,7 @@ var require_mime = __commonJS({
45079
45138
  "node_modules/.pnpm/mime@1.6.0/node_modules/mime/mime.js"(exports2, module2) {
45080
45139
  "use strict";
45081
45140
  init_cjs_shims();
45082
- var path9 = require("path");
45141
+ var path10 = require("path");
45083
45142
  var fs9 = require("fs");
45084
45143
  function Mime() {
45085
45144
  this.types = /* @__PURE__ */ Object.create(null);
@@ -45109,8 +45168,8 @@ var require_mime = __commonJS({
45109
45168
  this.define(map);
45110
45169
  this._loading = null;
45111
45170
  };
45112
- Mime.prototype.lookup = function(path10, fallback) {
45113
- var ext = path10.replace(/^.*[\.\/\\]/, "").toLowerCase();
45171
+ Mime.prototype.lookup = function(path11, fallback) {
45172
+ var ext = path11.replace(/^.*[\.\/\\]/, "").toLowerCase();
45114
45173
  return this.types[ext] || fallback || this.default_type;
45115
45174
  };
45116
45175
  Mime.prototype.extension = function(mimeType) {
@@ -45348,28 +45407,28 @@ var require_send = __commonJS({
45348
45407
  var ms = require_ms2();
45349
45408
  var onFinished = require_on_finished();
45350
45409
  var parseRange = require_range_parser();
45351
- var path9 = require("path");
45410
+ var path10 = require("path");
45352
45411
  var statuses = require_statuses2();
45353
45412
  var Stream = require("stream");
45354
45413
  var util2 = require("util");
45355
- var extname = path9.extname;
45356
- var join2 = path9.join;
45357
- var normalize = path9.normalize;
45358
- var resolve = path9.resolve;
45359
- var sep = path9.sep;
45414
+ var extname = path10.extname;
45415
+ var join2 = path10.join;
45416
+ var normalize = path10.normalize;
45417
+ var resolve2 = path10.resolve;
45418
+ var sep = path10.sep;
45360
45419
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
45361
45420
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
45362
45421
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
45363
45422
  module2.exports = send;
45364
45423
  module2.exports.mime = mime;
45365
- function send(req, path10, options) {
45366
- return new SendStream(req, path10, options);
45424
+ function send(req, path11, options) {
45425
+ return new SendStream(req, path11, options);
45367
45426
  }
45368
- function SendStream(req, path10, options) {
45427
+ function SendStream(req, path11, options) {
45369
45428
  Stream.call(this);
45370
45429
  var opts = options || {};
45371
45430
  this.options = opts;
45372
- this.path = path10;
45431
+ this.path = path11;
45373
45432
  this.req = req;
45374
45433
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
45375
45434
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -45392,7 +45451,7 @@ var require_send = __commonJS({
45392
45451
  this._maxage = opts.maxAge || opts.maxage;
45393
45452
  this._maxage = typeof this._maxage === "string" ? ms(this._maxage) : Number(this._maxage);
45394
45453
  this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
45395
- this._root = opts.root ? resolve(opts.root) : null;
45454
+ this._root = opts.root ? resolve2(opts.root) : null;
45396
45455
  if (!this._root && opts.from) {
45397
45456
  this.from(opts.from);
45398
45457
  }
@@ -45415,8 +45474,8 @@ var require_send = __commonJS({
45415
45474
  this._index = index2;
45416
45475
  return this;
45417
45476
  }, "send.index: pass index as option");
45418
- SendStream.prototype.root = function root(path10) {
45419
- this._root = resolve(String(path10));
45477
+ SendStream.prototype.root = function root(path11) {
45478
+ this._root = resolve2(String(path11));
45420
45479
  debug("root %s", this._root);
45421
45480
  return this;
45422
45481
  };
@@ -45529,10 +45588,10 @@ var require_send = __commonJS({
45529
45588
  var lastModified = this.res.getHeader("Last-Modified");
45530
45589
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
45531
45590
  };
45532
- SendStream.prototype.redirect = function redirect(path10) {
45591
+ SendStream.prototype.redirect = function redirect(path11) {
45533
45592
  var res = this.res;
45534
45593
  if (hasListeners(this, "directory")) {
45535
- this.emit("directory", res, path10);
45594
+ this.emit("directory", res, path11);
45536
45595
  return;
45537
45596
  }
45538
45597
  if (this.hasTrailingSlash()) {
@@ -45552,42 +45611,42 @@ var require_send = __commonJS({
45552
45611
  SendStream.prototype.pipe = function pipe2(res) {
45553
45612
  var root = this._root;
45554
45613
  this.res = res;
45555
- var path10 = decode(this.path);
45556
- if (path10 === -1) {
45614
+ var path11 = decode(this.path);
45615
+ if (path11 === -1) {
45557
45616
  this.error(400);
45558
45617
  return res;
45559
45618
  }
45560
- if (~path10.indexOf("\0")) {
45619
+ if (~path11.indexOf("\0")) {
45561
45620
  this.error(400);
45562
45621
  return res;
45563
45622
  }
45564
45623
  var parts;
45565
45624
  if (root !== null) {
45566
- if (path10) {
45567
- path10 = normalize("." + sep + path10);
45625
+ if (path11) {
45626
+ path11 = normalize("." + sep + path11);
45568
45627
  }
45569
- if (UP_PATH_REGEXP.test(path10)) {
45570
- debug('malicious path "%s"', path10);
45628
+ if (UP_PATH_REGEXP.test(path11)) {
45629
+ debug('malicious path "%s"', path11);
45571
45630
  this.error(403);
45572
45631
  return res;
45573
45632
  }
45574
- parts = path10.split(sep);
45575
- path10 = normalize(join2(root, path10));
45633
+ parts = path11.split(sep);
45634
+ path11 = normalize(join2(root, path11));
45576
45635
  } else {
45577
- if (UP_PATH_REGEXP.test(path10)) {
45578
- debug('malicious path "%s"', path10);
45636
+ if (UP_PATH_REGEXP.test(path11)) {
45637
+ debug('malicious path "%s"', path11);
45579
45638
  this.error(403);
45580
45639
  return res;
45581
45640
  }
45582
- parts = normalize(path10).split(sep);
45583
- path10 = resolve(path10);
45641
+ parts = normalize(path11).split(sep);
45642
+ path11 = resolve2(path11);
45584
45643
  }
45585
45644
  if (containsDotFile(parts)) {
45586
45645
  var access = this._dotfiles;
45587
45646
  if (access === void 0) {
45588
45647
  access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
45589
45648
  }
45590
- debug('%s dotfile "%s"', access, path10);
45649
+ debug('%s dotfile "%s"', access, path11);
45591
45650
  switch (access) {
45592
45651
  case "allow":
45593
45652
  break;
@@ -45601,13 +45660,13 @@ var require_send = __commonJS({
45601
45660
  }
45602
45661
  }
45603
45662
  if (this._index.length && this.hasTrailingSlash()) {
45604
- this.sendIndex(path10);
45663
+ this.sendIndex(path11);
45605
45664
  return res;
45606
45665
  }
45607
- this.sendFile(path10);
45666
+ this.sendFile(path11);
45608
45667
  return res;
45609
45668
  };
45610
- SendStream.prototype.send = function send2(path10, stat) {
45669
+ SendStream.prototype.send = function send2(path11, stat) {
45611
45670
  var len = stat.size;
45612
45671
  var options = this.options;
45613
45672
  var opts = {};
@@ -45619,9 +45678,9 @@ var require_send = __commonJS({
45619
45678
  this.headersAlreadySent();
45620
45679
  return;
45621
45680
  }
45622
- debug('pipe "%s"', path10);
45623
- this.setHeader(path10, stat);
45624
- this.type(path10);
45681
+ debug('pipe "%s"', path11);
45682
+ this.setHeader(path11, stat);
45683
+ this.type(path11);
45625
45684
  if (this.isConditionalGET()) {
45626
45685
  if (this.isPreconditionFailure()) {
45627
45686
  this.error(412);
@@ -45670,26 +45729,26 @@ var require_send = __commonJS({
45670
45729
  res.end();
45671
45730
  return;
45672
45731
  }
45673
- this.stream(path10, opts);
45732
+ this.stream(path11, opts);
45674
45733
  };
45675
- SendStream.prototype.sendFile = function sendFile(path10) {
45734
+ SendStream.prototype.sendFile = function sendFile(path11) {
45676
45735
  var i = 0;
45677
45736
  var self = this;
45678
- debug('stat "%s"', path10);
45679
- fs9.stat(path10, function onstat(err, stat) {
45680
- if (err && err.code === "ENOENT" && !extname(path10) && path10[path10.length - 1] !== sep) {
45737
+ debug('stat "%s"', path11);
45738
+ fs9.stat(path11, function onstat(err, stat) {
45739
+ if (err && err.code === "ENOENT" && !extname(path11) && path11[path11.length - 1] !== sep) {
45681
45740
  return next(err);
45682
45741
  }
45683
45742
  if (err) return self.onStatError(err);
45684
- if (stat.isDirectory()) return self.redirect(path10);
45685
- self.emit("file", path10, stat);
45686
- self.send(path10, stat);
45743
+ if (stat.isDirectory()) return self.redirect(path11);
45744
+ self.emit("file", path11, stat);
45745
+ self.send(path11, stat);
45687
45746
  });
45688
45747
  function next(err) {
45689
45748
  if (self._extensions.length <= i) {
45690
45749
  return err ? self.onStatError(err) : self.error(404);
45691
45750
  }
45692
- var p = path10 + "." + self._extensions[i++];
45751
+ var p = path11 + "." + self._extensions[i++];
45693
45752
  debug('stat "%s"', p);
45694
45753
  fs9.stat(p, function(err2, stat) {
45695
45754
  if (err2) return next(err2);
@@ -45699,7 +45758,7 @@ var require_send = __commonJS({
45699
45758
  });
45700
45759
  }
45701
45760
  };
45702
- SendStream.prototype.sendIndex = function sendIndex(path10) {
45761
+ SendStream.prototype.sendIndex = function sendIndex(path11) {
45703
45762
  var i = -1;
45704
45763
  var self = this;
45705
45764
  function next(err) {
@@ -45707,7 +45766,7 @@ var require_send = __commonJS({
45707
45766
  if (err) return self.onStatError(err);
45708
45767
  return self.error(404);
45709
45768
  }
45710
- var p = join2(path10, self._index[i]);
45769
+ var p = join2(path11, self._index[i]);
45711
45770
  debug('stat "%s"', p);
45712
45771
  fs9.stat(p, function(err2, stat) {
45713
45772
  if (err2) return next(err2);
@@ -45718,10 +45777,10 @@ var require_send = __commonJS({
45718
45777
  }
45719
45778
  next();
45720
45779
  };
45721
- SendStream.prototype.stream = function stream(path10, options) {
45780
+ SendStream.prototype.stream = function stream(path11, options) {
45722
45781
  var self = this;
45723
45782
  var res = this.res;
45724
- var stream2 = fs9.createReadStream(path10, options);
45783
+ var stream2 = fs9.createReadStream(path11, options);
45725
45784
  this.emit("stream", stream2);
45726
45785
  stream2.pipe(res);
45727
45786
  function cleanup() {
@@ -45736,10 +45795,10 @@ var require_send = __commonJS({
45736
45795
  self.emit("end");
45737
45796
  });
45738
45797
  };
45739
- SendStream.prototype.type = function type(path10) {
45798
+ SendStream.prototype.type = function type(path11) {
45740
45799
  var res = this.res;
45741
45800
  if (res.getHeader("Content-Type")) return;
45742
- var type2 = mime.lookup(path10);
45801
+ var type2 = mime.lookup(path11);
45743
45802
  if (!type2) {
45744
45803
  debug("no content-type");
45745
45804
  return;
@@ -45748,9 +45807,9 @@ var require_send = __commonJS({
45748
45807
  debug("content-type %s", type2);
45749
45808
  res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
45750
45809
  };
45751
- SendStream.prototype.setHeader = function setHeader(path10, stat) {
45810
+ SendStream.prototype.setHeader = function setHeader(path11, stat) {
45752
45811
  var res = this.res;
45753
- this.emit("headers", res, path10, stat);
45812
+ this.emit("headers", res, path11, stat);
45754
45813
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
45755
45814
  debug("accept ranges");
45756
45815
  res.setHeader("Accept-Ranges", "bytes");
@@ -45809,9 +45868,9 @@ var require_send = __commonJS({
45809
45868
  }
45810
45869
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
45811
45870
  }
45812
- function decode(path10) {
45871
+ function decode(path11) {
45813
45872
  try {
45814
- return decodeURIComponent(path10);
45873
+ return decodeURIComponent(path11);
45815
45874
  } catch (err) {
45816
45875
  return -1;
45817
45876
  }
@@ -46725,10 +46784,10 @@ var require_utils3 = __commonJS({
46725
46784
  var querystring = require("querystring");
46726
46785
  exports2.etag = createETagGenerator({ weak: false });
46727
46786
  exports2.wetag = createETagGenerator({ weak: true });
46728
- exports2.isAbsolute = function(path9) {
46729
- if ("/" === path9[0]) return true;
46730
- if (":" === path9[1] && ("\\" === path9[2] || "/" === path9[2])) return true;
46731
- if ("\\\\" === path9.substring(0, 2)) return true;
46787
+ exports2.isAbsolute = function(path10) {
46788
+ if ("/" === path10[0]) return true;
46789
+ if (":" === path10[1] && ("\\" === path10[2] || "/" === path10[2])) return true;
46790
+ if ("\\\\" === path10.substring(0, 2)) return true;
46732
46791
  };
46733
46792
  exports2.flatten = deprecate.function(
46734
46793
  flatten,
@@ -46865,7 +46924,7 @@ var require_application = __commonJS({
46865
46924
  var deprecate = require_depd()("express");
46866
46925
  var flatten = require_array_flatten();
46867
46926
  var merge2 = require_utils_merge();
46868
- var resolve = require("path").resolve;
46927
+ var resolve2 = require("path").resolve;
46869
46928
  var setPrototypeOf = require_setprototypeof();
46870
46929
  var hasOwnProperty = Object.prototype.hasOwnProperty;
46871
46930
  var slice = Array.prototype.slice;
@@ -46904,7 +46963,7 @@ var require_application = __commonJS({
46904
46963
  this.mountpath = "/";
46905
46964
  this.locals.settings = this.settings;
46906
46965
  this.set("view", View);
46907
- this.set("views", resolve("views"));
46966
+ this.set("views", resolve2("views"));
46908
46967
  this.set("jsonp callback name", "callback");
46909
46968
  if (env === "production") {
46910
46969
  this.enable("view cache");
@@ -46940,7 +46999,7 @@ var require_application = __commonJS({
46940
46999
  };
46941
47000
  app.use = function use(fn) {
46942
47001
  var offset = 0;
46943
- var path9 = "/";
47002
+ var path10 = "/";
46944
47003
  if (typeof fn !== "function") {
46945
47004
  var arg = fn;
46946
47005
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -46948,7 +47007,7 @@ var require_application = __commonJS({
46948
47007
  }
46949
47008
  if (typeof arg !== "function") {
46950
47009
  offset = 1;
46951
- path9 = fn;
47010
+ path10 = fn;
46952
47011
  }
46953
47012
  }
46954
47013
  var fns = flatten(slice.call(arguments, offset));
@@ -46959,12 +47018,12 @@ var require_application = __commonJS({
46959
47018
  var router = this._router;
46960
47019
  fns.forEach(function(fn2) {
46961
47020
  if (!fn2 || !fn2.handle || !fn2.set) {
46962
- return router.use(path9, fn2);
47021
+ return router.use(path10, fn2);
46963
47022
  }
46964
- debug(".use app under %s", path9);
46965
- fn2.mountpath = path9;
47023
+ debug(".use app under %s", path10);
47024
+ fn2.mountpath = path10;
46966
47025
  fn2.parent = this;
46967
- router.use(path9, function mounted_app(req, res, next) {
47026
+ router.use(path10, function mounted_app(req, res, next) {
46968
47027
  var orig = req.app;
46969
47028
  fn2.handle(req, res, function(err) {
46970
47029
  setPrototypeOf(req, orig.request);
@@ -46976,9 +47035,9 @@ var require_application = __commonJS({
46976
47035
  }, this);
46977
47036
  return this;
46978
47037
  };
46979
- app.route = function route(path9) {
47038
+ app.route = function route(path10) {
46980
47039
  this.lazyrouter();
46981
- return this._router.route(path9);
47040
+ return this._router.route(path10);
46982
47041
  };
46983
47042
  app.engine = function engine(ext, fn) {
46984
47043
  if (typeof fn !== "function") {
@@ -47029,7 +47088,7 @@ var require_application = __commonJS({
47029
47088
  }
47030
47089
  return this;
47031
47090
  };
47032
- app.path = function path9() {
47091
+ app.path = function path10() {
47033
47092
  return this.parent ? this.parent.path() + this.mountpath : "";
47034
47093
  };
47035
47094
  app.enabled = function enabled(setting) {
@@ -47045,19 +47104,19 @@ var require_application = __commonJS({
47045
47104
  return this.set(setting, false);
47046
47105
  };
47047
47106
  methods.forEach(function(method) {
47048
- app[method] = function(path9) {
47107
+ app[method] = function(path10) {
47049
47108
  if (method === "get" && arguments.length === 1) {
47050
- return this.set(path9);
47109
+ return this.set(path10);
47051
47110
  }
47052
47111
  this.lazyrouter();
47053
- var route = this._router.route(path9);
47112
+ var route = this._router.route(path10);
47054
47113
  route[method].apply(route, slice.call(arguments, 1));
47055
47114
  return this;
47056
47115
  };
47057
47116
  });
47058
- app.all = function all(path9) {
47117
+ app.all = function all(path10) {
47059
47118
  this.lazyrouter();
47060
- var route = this._router.route(path9);
47119
+ var route = this._router.route(path10);
47061
47120
  var args = slice.call(arguments, 1);
47062
47121
  for (var i = 0; i < methods.length; i++) {
47063
47122
  route[methods[i]].apply(route, args);
@@ -47823,7 +47882,7 @@ var require_request = __commonJS({
47823
47882
  var subdomains2 = !isIP(hostname2) ? hostname2.split(".").reverse() : [hostname2];
47824
47883
  return subdomains2.slice(offset);
47825
47884
  });
47826
- defineGetter(req, "path", function path9() {
47885
+ defineGetter(req, "path", function path10() {
47827
47886
  return parse3(this).pathname;
47828
47887
  });
47829
47888
  defineGetter(req, "hostname", function hostname2() {
@@ -48150,7 +48209,7 @@ var require_response = __commonJS({
48150
48209
  var http = require("http");
48151
48210
  var isAbsolute = require_utils3().isAbsolute;
48152
48211
  var onFinished = require_on_finished();
48153
- var path9 = require("path");
48212
+ var path10 = require("path");
48154
48213
  var statuses = require_statuses();
48155
48214
  var merge2 = require_utils_merge();
48156
48215
  var sign = require_cookie_signature().sign;
@@ -48159,9 +48218,9 @@ var require_response = __commonJS({
48159
48218
  var setCharset = require_utils3().setCharset;
48160
48219
  var cookie = require_cookie();
48161
48220
  var send = require_send();
48162
- var extname = path9.extname;
48221
+ var extname = path10.extname;
48163
48222
  var mime = send.mime;
48164
- var resolve = path9.resolve;
48223
+ var resolve2 = path10.resolve;
48165
48224
  var vary = require_vary();
48166
48225
  var res = Object.create(http.ServerResponse.prototype);
48167
48226
  module2.exports = res;
@@ -48338,26 +48397,26 @@ var require_response = __commonJS({
48338
48397
  this.type("txt");
48339
48398
  return this.send(body);
48340
48399
  };
48341
- res.sendFile = function sendFile(path10, options, callback) {
48400
+ res.sendFile = function sendFile(path11, options, callback) {
48342
48401
  var done = callback;
48343
48402
  var req = this.req;
48344
48403
  var res2 = this;
48345
48404
  var next = req.next;
48346
48405
  var opts = options || {};
48347
- if (!path10) {
48406
+ if (!path11) {
48348
48407
  throw new TypeError("path argument is required to res.sendFile");
48349
48408
  }
48350
- if (typeof path10 !== "string") {
48409
+ if (typeof path11 !== "string") {
48351
48410
  throw new TypeError("path must be a string to res.sendFile");
48352
48411
  }
48353
48412
  if (typeof options === "function") {
48354
48413
  done = options;
48355
48414
  opts = {};
48356
48415
  }
48357
- if (!opts.root && !isAbsolute(path10)) {
48416
+ if (!opts.root && !isAbsolute(path11)) {
48358
48417
  throw new TypeError("path must be absolute or specify root to res.sendFile");
48359
48418
  }
48360
- var pathname = encodeURI(path10);
48419
+ var pathname = encodeURI(path11);
48361
48420
  var file = send(req, pathname, opts);
48362
48421
  sendfile(res2, file, opts, function(err) {
48363
48422
  if (done) return done(err);
@@ -48367,7 +48426,7 @@ var require_response = __commonJS({
48367
48426
  }
48368
48427
  });
48369
48428
  };
48370
- res.sendfile = function(path10, options, callback) {
48429
+ res.sendfile = function(path11, options, callback) {
48371
48430
  var done = callback;
48372
48431
  var req = this.req;
48373
48432
  var res2 = this;
@@ -48377,7 +48436,7 @@ var require_response = __commonJS({
48377
48436
  done = options;
48378
48437
  opts = {};
48379
48438
  }
48380
- var file = send(req, path10, opts);
48439
+ var file = send(req, path11, opts);
48381
48440
  sendfile(res2, file, opts, function(err) {
48382
48441
  if (done) return done(err);
48383
48442
  if (err && err.code === "EISDIR") return next();
@@ -48390,7 +48449,7 @@ var require_response = __commonJS({
48390
48449
  res.sendfile,
48391
48450
  "res.sendfile: Use res.sendFile instead"
48392
48451
  );
48393
- res.download = function download(path10, filename, options, callback) {
48452
+ res.download = function download(path11, filename, options, callback) {
48394
48453
  var done = callback;
48395
48454
  var name = filename;
48396
48455
  var opts = options || null;
@@ -48407,7 +48466,7 @@ var require_response = __commonJS({
48407
48466
  opts = filename;
48408
48467
  }
48409
48468
  var headers = {
48410
- "Content-Disposition": contentDisposition(name || path10)
48469
+ "Content-Disposition": contentDisposition(name || path11)
48411
48470
  };
48412
48471
  if (opts && opts.headers) {
48413
48472
  var keys = Object.keys(opts.headers);
@@ -48420,7 +48479,7 @@ var require_response = __commonJS({
48420
48479
  }
48421
48480
  opts = Object.create(opts);
48422
48481
  opts.headers = headers;
48423
- var fullPath = !opts.root ? resolve(path10) : path10;
48482
+ var fullPath = !opts.root ? resolve2(path11) : path11;
48424
48483
  return this.sendFile(fullPath, opts, done);
48425
48484
  };
48426
48485
  res.contentType = res.type = function contentType3(type) {
@@ -48712,28 +48771,28 @@ var require_send2 = __commonJS({
48712
48771
  var ms = require_ms2();
48713
48772
  var onFinished = require_on_finished();
48714
48773
  var parseRange = require_range_parser();
48715
- var path9 = require("path");
48774
+ var path10 = require("path");
48716
48775
  var statuses = require_statuses2();
48717
48776
  var Stream = require("stream");
48718
48777
  var util2 = require("util");
48719
- var extname = path9.extname;
48720
- var join2 = path9.join;
48721
- var normalize = path9.normalize;
48722
- var resolve = path9.resolve;
48723
- var sep = path9.sep;
48778
+ var extname = path10.extname;
48779
+ var join2 = path10.join;
48780
+ var normalize = path10.normalize;
48781
+ var resolve2 = path10.resolve;
48782
+ var sep = path10.sep;
48724
48783
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
48725
48784
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
48726
48785
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
48727
48786
  module2.exports = send;
48728
48787
  module2.exports.mime = mime;
48729
- function send(req, path10, options) {
48730
- return new SendStream(req, path10, options);
48788
+ function send(req, path11, options) {
48789
+ return new SendStream(req, path11, options);
48731
48790
  }
48732
- function SendStream(req, path10, options) {
48791
+ function SendStream(req, path11, options) {
48733
48792
  Stream.call(this);
48734
48793
  var opts = options || {};
48735
48794
  this.options = opts;
48736
- this.path = path10;
48795
+ this.path = path11;
48737
48796
  this.req = req;
48738
48797
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
48739
48798
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -48756,7 +48815,7 @@ var require_send2 = __commonJS({
48756
48815
  this._maxage = opts.maxAge || opts.maxage;
48757
48816
  this._maxage = typeof this._maxage === "string" ? ms(this._maxage) : Number(this._maxage);
48758
48817
  this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
48759
- this._root = opts.root ? resolve(opts.root) : null;
48818
+ this._root = opts.root ? resolve2(opts.root) : null;
48760
48819
  if (!this._root && opts.from) {
48761
48820
  this.from(opts.from);
48762
48821
  }
@@ -48779,8 +48838,8 @@ var require_send2 = __commonJS({
48779
48838
  this._index = index2;
48780
48839
  return this;
48781
48840
  }, "send.index: pass index as option");
48782
- SendStream.prototype.root = function root(path10) {
48783
- this._root = resolve(String(path10));
48841
+ SendStream.prototype.root = function root(path11) {
48842
+ this._root = resolve2(String(path11));
48784
48843
  debug("root %s", this._root);
48785
48844
  return this;
48786
48845
  };
@@ -48893,10 +48952,10 @@ var require_send2 = __commonJS({
48893
48952
  var lastModified = this.res.getHeader("Last-Modified");
48894
48953
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
48895
48954
  };
48896
- SendStream.prototype.redirect = function redirect(path10) {
48955
+ SendStream.prototype.redirect = function redirect(path11) {
48897
48956
  var res = this.res;
48898
48957
  if (hasListeners(this, "directory")) {
48899
- this.emit("directory", res, path10);
48958
+ this.emit("directory", res, path11);
48900
48959
  return;
48901
48960
  }
48902
48961
  if (this.hasTrailingSlash()) {
@@ -48916,42 +48975,42 @@ var require_send2 = __commonJS({
48916
48975
  SendStream.prototype.pipe = function pipe2(res) {
48917
48976
  var root = this._root;
48918
48977
  this.res = res;
48919
- var path10 = decode(this.path);
48920
- if (path10 === -1) {
48978
+ var path11 = decode(this.path);
48979
+ if (path11 === -1) {
48921
48980
  this.error(400);
48922
48981
  return res;
48923
48982
  }
48924
- if (~path10.indexOf("\0")) {
48983
+ if (~path11.indexOf("\0")) {
48925
48984
  this.error(400);
48926
48985
  return res;
48927
48986
  }
48928
48987
  var parts;
48929
48988
  if (root !== null) {
48930
- if (path10) {
48931
- path10 = normalize("." + sep + path10);
48989
+ if (path11) {
48990
+ path11 = normalize("." + sep + path11);
48932
48991
  }
48933
- if (UP_PATH_REGEXP.test(path10)) {
48934
- debug('malicious path "%s"', path10);
48992
+ if (UP_PATH_REGEXP.test(path11)) {
48993
+ debug('malicious path "%s"', path11);
48935
48994
  this.error(403);
48936
48995
  return res;
48937
48996
  }
48938
- parts = path10.split(sep);
48939
- path10 = normalize(join2(root, path10));
48997
+ parts = path11.split(sep);
48998
+ path11 = normalize(join2(root, path11));
48940
48999
  } else {
48941
- if (UP_PATH_REGEXP.test(path10)) {
48942
- debug('malicious path "%s"', path10);
49000
+ if (UP_PATH_REGEXP.test(path11)) {
49001
+ debug('malicious path "%s"', path11);
48943
49002
  this.error(403);
48944
49003
  return res;
48945
49004
  }
48946
- parts = normalize(path10).split(sep);
48947
- path10 = resolve(path10);
49005
+ parts = normalize(path11).split(sep);
49006
+ path11 = resolve2(path11);
48948
49007
  }
48949
49008
  if (containsDotFile(parts)) {
48950
49009
  var access = this._dotfiles;
48951
49010
  if (access === void 0) {
48952
49011
  access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
48953
49012
  }
48954
- debug('%s dotfile "%s"', access, path10);
49013
+ debug('%s dotfile "%s"', access, path11);
48955
49014
  switch (access) {
48956
49015
  case "allow":
48957
49016
  break;
@@ -48965,13 +49024,13 @@ var require_send2 = __commonJS({
48965
49024
  }
48966
49025
  }
48967
49026
  if (this._index.length && this.hasTrailingSlash()) {
48968
- this.sendIndex(path10);
49027
+ this.sendIndex(path11);
48969
49028
  return res;
48970
49029
  }
48971
- this.sendFile(path10);
49030
+ this.sendFile(path11);
48972
49031
  return res;
48973
49032
  };
48974
- SendStream.prototype.send = function send2(path10, stat) {
49033
+ SendStream.prototype.send = function send2(path11, stat) {
48975
49034
  var len = stat.size;
48976
49035
  var options = this.options;
48977
49036
  var opts = {};
@@ -48983,9 +49042,9 @@ var require_send2 = __commonJS({
48983
49042
  this.headersAlreadySent();
48984
49043
  return;
48985
49044
  }
48986
- debug('pipe "%s"', path10);
48987
- this.setHeader(path10, stat);
48988
- this.type(path10);
49045
+ debug('pipe "%s"', path11);
49046
+ this.setHeader(path11, stat);
49047
+ this.type(path11);
48989
49048
  if (this.isConditionalGET()) {
48990
49049
  if (this.isPreconditionFailure()) {
48991
49050
  this.error(412);
@@ -49034,26 +49093,26 @@ var require_send2 = __commonJS({
49034
49093
  res.end();
49035
49094
  return;
49036
49095
  }
49037
- this.stream(path10, opts);
49096
+ this.stream(path11, opts);
49038
49097
  };
49039
- SendStream.prototype.sendFile = function sendFile(path10) {
49098
+ SendStream.prototype.sendFile = function sendFile(path11) {
49040
49099
  var i = 0;
49041
49100
  var self = this;
49042
- debug('stat "%s"', path10);
49043
- fs9.stat(path10, function onstat(err, stat) {
49044
- if (err && err.code === "ENOENT" && !extname(path10) && path10[path10.length - 1] !== sep) {
49101
+ debug('stat "%s"', path11);
49102
+ fs9.stat(path11, function onstat(err, stat) {
49103
+ if (err && err.code === "ENOENT" && !extname(path11) && path11[path11.length - 1] !== sep) {
49045
49104
  return next(err);
49046
49105
  }
49047
49106
  if (err) return self.onStatError(err);
49048
- if (stat.isDirectory()) return self.redirect(path10);
49049
- self.emit("file", path10, stat);
49050
- self.send(path10, stat);
49107
+ if (stat.isDirectory()) return self.redirect(path11);
49108
+ self.emit("file", path11, stat);
49109
+ self.send(path11, stat);
49051
49110
  });
49052
49111
  function next(err) {
49053
49112
  if (self._extensions.length <= i) {
49054
49113
  return err ? self.onStatError(err) : self.error(404);
49055
49114
  }
49056
- var p = path10 + "." + self._extensions[i++];
49115
+ var p = path11 + "." + self._extensions[i++];
49057
49116
  debug('stat "%s"', p);
49058
49117
  fs9.stat(p, function(err2, stat) {
49059
49118
  if (err2) return next(err2);
@@ -49063,7 +49122,7 @@ var require_send2 = __commonJS({
49063
49122
  });
49064
49123
  }
49065
49124
  };
49066
- SendStream.prototype.sendIndex = function sendIndex(path10) {
49125
+ SendStream.prototype.sendIndex = function sendIndex(path11) {
49067
49126
  var i = -1;
49068
49127
  var self = this;
49069
49128
  function next(err) {
@@ -49071,7 +49130,7 @@ var require_send2 = __commonJS({
49071
49130
  if (err) return self.onStatError(err);
49072
49131
  return self.error(404);
49073
49132
  }
49074
- var p = join2(path10, self._index[i]);
49133
+ var p = join2(path11, self._index[i]);
49075
49134
  debug('stat "%s"', p);
49076
49135
  fs9.stat(p, function(err2, stat) {
49077
49136
  if (err2) return next(err2);
@@ -49082,10 +49141,10 @@ var require_send2 = __commonJS({
49082
49141
  }
49083
49142
  next();
49084
49143
  };
49085
- SendStream.prototype.stream = function stream(path10, options) {
49144
+ SendStream.prototype.stream = function stream(path11, options) {
49086
49145
  var self = this;
49087
49146
  var res = this.res;
49088
- var stream2 = fs9.createReadStream(path10, options);
49147
+ var stream2 = fs9.createReadStream(path11, options);
49089
49148
  this.emit("stream", stream2);
49090
49149
  stream2.pipe(res);
49091
49150
  function cleanup() {
@@ -49100,10 +49159,10 @@ var require_send2 = __commonJS({
49100
49159
  self.emit("end");
49101
49160
  });
49102
49161
  };
49103
- SendStream.prototype.type = function type(path10) {
49162
+ SendStream.prototype.type = function type(path11) {
49104
49163
  var res = this.res;
49105
49164
  if (res.getHeader("Content-Type")) return;
49106
- var type2 = mime.lookup(path10);
49165
+ var type2 = mime.lookup(path11);
49107
49166
  if (!type2) {
49108
49167
  debug("no content-type");
49109
49168
  return;
@@ -49112,9 +49171,9 @@ var require_send2 = __commonJS({
49112
49171
  debug("content-type %s", type2);
49113
49172
  res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
49114
49173
  };
49115
- SendStream.prototype.setHeader = function setHeader(path10, stat) {
49174
+ SendStream.prototype.setHeader = function setHeader(path11, stat) {
49116
49175
  var res = this.res;
49117
- this.emit("headers", res, path10, stat);
49176
+ this.emit("headers", res, path11, stat);
49118
49177
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
49119
49178
  debug("accept ranges");
49120
49179
  res.setHeader("Accept-Ranges", "bytes");
@@ -49173,9 +49232,9 @@ var require_send2 = __commonJS({
49173
49232
  }
49174
49233
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
49175
49234
  }
49176
- function decode(path10) {
49235
+ function decode(path11) {
49177
49236
  try {
49178
- return decodeURIComponent(path10);
49237
+ return decodeURIComponent(path11);
49179
49238
  } catch (err) {
49180
49239
  return -1;
49181
49240
  }
@@ -49248,7 +49307,7 @@ var require_serve_static = __commonJS({
49248
49307
  var encodeUrl = require_encodeurl();
49249
49308
  var escapeHtml = require_escape_html();
49250
49309
  var parseUrl = require_parseurl();
49251
- var resolve = require("path").resolve;
49310
+ var resolve2 = require("path").resolve;
49252
49311
  var send = require_send2();
49253
49312
  var url2 = require("url");
49254
49313
  module2.exports = serveStatic;
@@ -49268,7 +49327,7 @@ var require_serve_static = __commonJS({
49268
49327
  throw new TypeError("option setHeaders must be function");
49269
49328
  }
49270
49329
  opts.maxage = opts.maxage || opts.maxAge || 0;
49271
- opts.root = resolve(root);
49330
+ opts.root = resolve2(root);
49272
49331
  var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
49273
49332
  return function serveStatic2(req, res, next) {
49274
49333
  if (req.method !== "GET" && req.method !== "HEAD") {
@@ -49283,11 +49342,11 @@ var require_serve_static = __commonJS({
49283
49342
  }
49284
49343
  var forwardError = !fallthrough;
49285
49344
  var originalUrl = parseUrl.original(req);
49286
- var path9 = parseUrl(req).pathname;
49287
- if (path9 === "/" && originalUrl.pathname.substr(-1) !== "/") {
49288
- path9 = "";
49345
+ var path10 = parseUrl(req).pathname;
49346
+ if (path10 === "/" && originalUrl.pathname.substr(-1) !== "/") {
49347
+ path10 = "";
49289
49348
  }
49290
- var stream = send(req, path9, opts);
49349
+ var stream = send(req, path10, opts);
49291
49350
  stream.on("directory", onDirectory);
49292
49351
  if (setHeaders) {
49293
49352
  stream.on("headers", setHeaders);
@@ -49352,7 +49411,7 @@ var require_express = __commonJS({
49352
49411
  "use strict";
49353
49412
  init_cjs_shims();
49354
49413
  var bodyParser = require_body_parser();
49355
- var EventEmitter2 = require("events").EventEmitter;
49414
+ var EventEmitter5 = require("events").EventEmitter;
49356
49415
  var mixin2 = require_merge_descriptors();
49357
49416
  var proto = require_application();
49358
49417
  var Route = require_route();
@@ -49364,7 +49423,7 @@ var require_express = __commonJS({
49364
49423
  var app = function(req2, res2, next) {
49365
49424
  app.handle(req2, res2, next);
49366
49425
  };
49367
- mixin2(app, EventEmitter2.prototype, false);
49426
+ mixin2(app, EventEmitter5.prototype, false);
49368
49427
  mixin2(app, proto, false);
49369
49428
  app.request = Object.create(req, {
49370
49429
  app: { configurable: true, enumerable: true, writable: true, value: app }
@@ -50593,7 +50652,7 @@ var require_supports_color = __commonJS({
50593
50652
  "node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports2, module2) {
50594
50653
  "use strict";
50595
50654
  init_cjs_shims();
50596
- var os3 = require("os");
50655
+ var os4 = require("os");
50597
50656
  var tty = require("tty");
50598
50657
  var hasFlag = require_has_flag();
50599
50658
  var { env } = process;
@@ -50641,7 +50700,7 @@ var require_supports_color = __commonJS({
50641
50700
  return min;
50642
50701
  }
50643
50702
  if (process.platform === "win32") {
50644
- const osRelease = os3.release().split(".");
50703
+ const osRelease = os4.release().split(".");
50645
50704
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
50646
50705
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
50647
50706
  }
@@ -54095,7 +54154,7 @@ var require_websocket2 = __commonJS({
54095
54154
  "node_modules/.pnpm/ws@8.17.1/node_modules/ws/lib/websocket.js"(exports2, module2) {
54096
54155
  "use strict";
54097
54156
  init_cjs_shims();
54098
- var EventEmitter2 = require("events");
54157
+ var EventEmitter5 = require("events");
54099
54158
  var https = require("https");
54100
54159
  var http = require("http");
54101
54160
  var net = require("net");
@@ -54126,7 +54185,7 @@ var require_websocket2 = __commonJS({
54126
54185
  var protocolVersions = [8, 13];
54127
54186
  var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
54128
54187
  var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
54129
- var WebSocket = class _WebSocket extends EventEmitter2 {
54188
+ var WebSocket = class _WebSocket extends EventEmitter5 {
54130
54189
  /**
54131
54190
  * Create a new `WebSocket`.
54132
54191
  *
@@ -55099,7 +55158,7 @@ var require_websocket_server = __commonJS({
55099
55158
  "node_modules/.pnpm/ws@8.17.1/node_modules/ws/lib/websocket-server.js"(exports2, module2) {
55100
55159
  "use strict";
55101
55160
  init_cjs_shims();
55102
- var EventEmitter2 = require("events");
55161
+ var EventEmitter5 = require("events");
55103
55162
  var http = require("http");
55104
55163
  var { Duplex } = require("stream");
55105
55164
  var { createHash: createHash2 } = require("crypto");
@@ -55112,7 +55171,7 @@ var require_websocket_server = __commonJS({
55112
55171
  var RUNNING = 0;
55113
55172
  var CLOSING = 1;
55114
55173
  var CLOSED = 2;
55115
- var WebSocketServer = class extends EventEmitter2 {
55174
+ var WebSocketServer = class extends EventEmitter5 {
55116
55175
  /**
55117
55176
  * Create a `WebSocketServer` instance.
55118
55177
  *
@@ -55859,11 +55918,11 @@ var require_server = __commonJS({
55859
55918
  * @protected
55860
55919
  */
55861
55920
  _computePath(options) {
55862
- let path9 = (options.path || "/engine.io").replace(/\/$/, "");
55921
+ let path10 = (options.path || "/engine.io").replace(/\/$/, "");
55863
55922
  if (options.addTrailingSlash !== false) {
55864
- path9 += "/";
55923
+ path10 += "/";
55865
55924
  }
55866
- return path9;
55925
+ return path10;
55867
55926
  }
55868
55927
  /**
55869
55928
  * Returns a list of available transports for upgrade given a certain transport.
@@ -56361,10 +56420,10 @@ var require_server = __commonJS({
56361
56420
  * @param {Object} options
56362
56421
  */
56363
56422
  attach(server, options = {}) {
56364
- const path9 = this._computePath(options);
56423
+ const path10 = this._computePath(options);
56365
56424
  const destroyUpgradeTimeout = options.destroyUpgradeTimeout || 1e3;
56366
56425
  function check2(req) {
56367
- return path9 === req.url.slice(0, path9.length);
56426
+ return path10 === req.url.slice(0, path10.length);
56368
56427
  }
56369
56428
  const listeners = server.listeners("request").slice(0);
56370
56429
  server.removeAllListeners("request");
@@ -56372,7 +56431,7 @@ var require_server = __commonJS({
56372
56431
  server.on("listening", this.init.bind(this));
56373
56432
  server.on("request", (req, res) => {
56374
56433
  if (check2(req)) {
56375
- debug('intercepting request for path "%s"', path9);
56434
+ debug('intercepting request for path "%s"', path10);
56376
56435
  this.handleRequest(req, res);
56377
56436
  } else {
56378
56437
  let i = 0;
@@ -57215,8 +57274,8 @@ var require_userver = __commonJS({
57215
57274
  * @param options
57216
57275
  */
57217
57276
  attach(app, options = {}) {
57218
- const path9 = this._computePath(options);
57219
- app.any(path9, this.handleRequest.bind(this)).ws(path9, {
57277
+ const path10 = this._computePath(options);
57278
+ app.any(path10, this.handleRequest.bind(this)).ws(path10, {
57220
57279
  compression: options.compression,
57221
57280
  idleTimeout: options.idleTimeout,
57222
57281
  maxBackpressure: options.maxBackpressure,
@@ -58537,13 +58596,13 @@ var require_broadcast_operator = __commonJS({
58537
58596
  * @return a Promise that will be fulfilled when all clients have acknowledged the event
58538
58597
  */
58539
58598
  emitWithAck(ev, ...args) {
58540
- return new Promise((resolve, reject) => {
58599
+ return new Promise((resolve2, reject) => {
58541
58600
  args.push((err, responses) => {
58542
58601
  if (err) {
58543
58602
  err.responses = responses;
58544
58603
  return reject(err);
58545
58604
  } else {
58546
- return resolve(responses);
58605
+ return resolve2(responses);
58547
58606
  }
58548
58607
  });
58549
58608
  this.emit(ev, ...args);
@@ -58898,12 +58957,12 @@ var require_socket2 = __commonJS({
58898
58957
  */
58899
58958
  emitWithAck(ev, ...args) {
58900
58959
  const withErr = this.flags.timeout !== void 0;
58901
- return new Promise((resolve, reject) => {
58960
+ return new Promise((resolve2, reject) => {
58902
58961
  args.push((arg1, arg2) => {
58903
58962
  if (withErr) {
58904
- return arg1 ? reject(arg1) : resolve(arg2);
58963
+ return arg1 ? reject(arg1) : resolve2(arg2);
58905
58964
  } else {
58906
- return resolve(arg1);
58965
+ return resolve2(arg1);
58907
58966
  }
58908
58967
  });
58909
58968
  this.emit(ev, ...args);
@@ -59971,13 +60030,13 @@ var require_namespace = __commonJS({
59971
60030
  * @return a Promise that will be fulfilled when all servers have acknowledged the event
59972
60031
  */
59973
60032
  serverSideEmitWithAck(ev, ...args) {
59974
- return new Promise((resolve, reject) => {
60033
+ return new Promise((resolve2, reject) => {
59975
60034
  args.push((err, responses) => {
59976
60035
  if (err) {
59977
60036
  err.responses = responses;
59978
60037
  return reject(err);
59979
60038
  } else {
59980
- return resolve(responses);
60039
+ return resolve2(responses);
59981
60040
  }
59982
60041
  });
59983
60042
  this.serverSideEmit(ev, ...args);
@@ -60939,7 +60998,7 @@ var require_cluster_adapter = __commonJS({
60939
60998
  return localSockets;
60940
60999
  }
60941
61000
  const requestId = randomId();
60942
- return new Promise((resolve, reject) => {
61001
+ return new Promise((resolve2, reject) => {
60943
61002
  const timeout = setTimeout(() => {
60944
61003
  const storedRequest2 = this.requests.get(requestId);
60945
61004
  if (storedRequest2) {
@@ -60949,7 +61008,7 @@ var require_cluster_adapter = __commonJS({
60949
61008
  }, opts.flags.timeout || DEFAULT_TIMEOUT2);
60950
61009
  const storedRequest = {
60951
61010
  type: MessageType.FETCH_SOCKETS,
60952
- resolve,
61011
+ resolve: resolve2,
60953
61012
  timeout,
60954
61013
  current: 0,
60955
61014
  expected: expectedResponseCount,
@@ -61157,7 +61216,7 @@ var require_cluster_adapter = __commonJS({
61157
61216
  return localSockets;
61158
61217
  }
61159
61218
  const requestId = randomId();
61160
- return new Promise((resolve, reject) => {
61219
+ return new Promise((resolve2, reject) => {
61161
61220
  const timeout = setTimeout(() => {
61162
61221
  const storedRequest2 = this.customRequests.get(requestId);
61163
61222
  if (storedRequest2) {
@@ -61167,7 +61226,7 @@ var require_cluster_adapter = __commonJS({
61167
61226
  }, opts.flags.timeout || DEFAULT_TIMEOUT2);
61168
61227
  const storedRequest = {
61169
61228
  type: MessageType.FETCH_SOCKETS,
61170
- resolve,
61229
+ resolve: resolve2,
61171
61230
  timeout,
61172
61231
  missingUids: /* @__PURE__ */ new Set([...this.nodesMap.keys()]),
61173
61232
  responses: localSockets
@@ -61598,7 +61657,7 @@ var require_dist3 = __commonJS({
61598
61657
  var zlib_1 = require("zlib");
61599
61658
  var accepts = require_accepts();
61600
61659
  var stream_1 = require("stream");
61601
- var path9 = require("path");
61660
+ var path10 = require("path");
61602
61661
  var engine_io_1 = require_engine_io();
61603
61662
  var client_1 = require_client();
61604
61663
  var events_1 = require("events");
@@ -61788,7 +61847,7 @@ var require_dist3 = __commonJS({
61788
61847
  res.writeHeader("cache-control", "public, max-age=0");
61789
61848
  res.writeHeader("content-type", "application/" + (isMap ? "json" : "javascript") + "; charset=utf-8");
61790
61849
  res.writeHeader("etag", expectedEtag);
61791
- const filepath = path9.join(__dirname, "../client-dist/", filename);
61850
+ const filepath = path10.join(__dirname, "../client-dist/", filename);
61792
61851
  (0, uws_1.serveFile)(res, filepath);
61793
61852
  });
61794
61853
  }
@@ -61870,7 +61929,7 @@ var require_dist3 = __commonJS({
61870
61929
  * @private
61871
61930
  */
61872
61931
  static sendFile(filename, req, res) {
61873
- const readStream = (0, fs_1.createReadStream)(path9.join(__dirname, "../client-dist/", filename));
61932
+ const readStream = (0, fs_1.createReadStream)(path10.join(__dirname, "../client-dist/", filename));
61874
61933
  const encoding = accepts(req).encodings(["br", "gzip", "deflate"]);
61875
61934
  const onError = (err) => {
61876
61935
  if (err) {
@@ -74100,7 +74159,7 @@ var require_windows = __commonJS({
74100
74159
  module2.exports = isexe;
74101
74160
  isexe.sync = sync;
74102
74161
  var fs9 = require("fs");
74103
- function checkPathExt(path9, options) {
74162
+ function checkPathExt(path10, options) {
74104
74163
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
74105
74164
  if (!pathext) {
74106
74165
  return true;
@@ -74111,25 +74170,25 @@ var require_windows = __commonJS({
74111
74170
  }
74112
74171
  for (var i = 0; i < pathext.length; i++) {
74113
74172
  var p = pathext[i].toLowerCase();
74114
- if (p && path9.substr(-p.length).toLowerCase() === p) {
74173
+ if (p && path10.substr(-p.length).toLowerCase() === p) {
74115
74174
  return true;
74116
74175
  }
74117
74176
  }
74118
74177
  return false;
74119
74178
  }
74120
- function checkStat(stat, path9, options) {
74179
+ function checkStat(stat, path10, options) {
74121
74180
  if (!stat.isSymbolicLink() && !stat.isFile()) {
74122
74181
  return false;
74123
74182
  }
74124
- return checkPathExt(path9, options);
74183
+ return checkPathExt(path10, options);
74125
74184
  }
74126
- function isexe(path9, options, cb) {
74127
- fs9.stat(path9, function(er, stat) {
74128
- cb(er, er ? false : checkStat(stat, path9, options));
74185
+ function isexe(path10, options, cb) {
74186
+ fs9.stat(path10, function(er, stat) {
74187
+ cb(er, er ? false : checkStat(stat, path10, options));
74129
74188
  });
74130
74189
  }
74131
- function sync(path9, options) {
74132
- return checkStat(fs9.statSync(path9), path9, options);
74190
+ function sync(path10, options) {
74191
+ return checkStat(fs9.statSync(path10), path10, options);
74133
74192
  }
74134
74193
  }
74135
74194
  });
@@ -74142,13 +74201,13 @@ var require_mode = __commonJS({
74142
74201
  module2.exports = isexe;
74143
74202
  isexe.sync = sync;
74144
74203
  var fs9 = require("fs");
74145
- function isexe(path9, options, cb) {
74146
- fs9.stat(path9, function(er, stat) {
74204
+ function isexe(path10, options, cb) {
74205
+ fs9.stat(path10, function(er, stat) {
74147
74206
  cb(er, er ? false : checkStat(stat, options));
74148
74207
  });
74149
74208
  }
74150
- function sync(path9, options) {
74151
- return checkStat(fs9.statSync(path9), options);
74209
+ function sync(path10, options) {
74210
+ return checkStat(fs9.statSync(path10), options);
74152
74211
  }
74153
74212
  function checkStat(stat, options) {
74154
74213
  return stat.isFile() && checkMode(stat, options);
@@ -74183,7 +74242,7 @@ var require_isexe = __commonJS({
74183
74242
  }
74184
74243
  module2.exports = isexe;
74185
74244
  isexe.sync = sync;
74186
- function isexe(path9, options, cb) {
74245
+ function isexe(path10, options, cb) {
74187
74246
  if (typeof options === "function") {
74188
74247
  cb = options;
74189
74248
  options = {};
@@ -74192,17 +74251,17 @@ var require_isexe = __commonJS({
74192
74251
  if (typeof Promise !== "function") {
74193
74252
  throw new TypeError("callback not provided");
74194
74253
  }
74195
- return new Promise(function(resolve, reject) {
74196
- isexe(path9, options || {}, function(er, is) {
74254
+ return new Promise(function(resolve2, reject) {
74255
+ isexe(path10, options || {}, function(er, is) {
74197
74256
  if (er) {
74198
74257
  reject(er);
74199
74258
  } else {
74200
- resolve(is);
74259
+ resolve2(is);
74201
74260
  }
74202
74261
  });
74203
74262
  });
74204
74263
  }
74205
- core(path9, options || {}, function(er, is) {
74264
+ core(path10, options || {}, function(er, is) {
74206
74265
  if (er) {
74207
74266
  if (er.code === "EACCES" || options && options.ignoreErrors) {
74208
74267
  er = null;
@@ -74212,9 +74271,9 @@ var require_isexe = __commonJS({
74212
74271
  cb(er, is);
74213
74272
  });
74214
74273
  }
74215
- function sync(path9, options) {
74274
+ function sync(path10, options) {
74216
74275
  try {
74217
- return core.sync(path9, options || {});
74276
+ return core.sync(path10, options || {});
74218
74277
  } catch (er) {
74219
74278
  if (options && options.ignoreErrors || er.code === "EACCES") {
74220
74279
  return false;
@@ -74232,7 +74291,7 @@ var require_which = __commonJS({
74232
74291
  "use strict";
74233
74292
  init_cjs_shims();
74234
74293
  var isWindows2 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
74235
- var path9 = require("path");
74294
+ var path10 = require("path");
74236
74295
  var COLON = isWindows2 ? ";" : ":";
74237
74296
  var isexe = require_isexe();
74238
74297
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -74265,27 +74324,27 @@ var require_which = __commonJS({
74265
74324
  opt = {};
74266
74325
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
74267
74326
  const found = [];
74268
- const step = (i) => new Promise((resolve, reject) => {
74327
+ const step = (i) => new Promise((resolve2, reject) => {
74269
74328
  if (i === pathEnv.length)
74270
- return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
74329
+ return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
74271
74330
  const ppRaw = pathEnv[i];
74272
74331
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
74273
- const pCmd = path9.join(pathPart, cmd);
74332
+ const pCmd = path10.join(pathPart, cmd);
74274
74333
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
74275
- resolve(subStep(p, i, 0));
74334
+ resolve2(subStep(p, i, 0));
74276
74335
  });
74277
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
74336
+ const subStep = (p, i, ii) => new Promise((resolve2, reject) => {
74278
74337
  if (ii === pathExt.length)
74279
- return resolve(step(i + 1));
74338
+ return resolve2(step(i + 1));
74280
74339
  const ext = pathExt[ii];
74281
74340
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
74282
74341
  if (!er && is) {
74283
74342
  if (opt.all)
74284
74343
  found.push(p + ext);
74285
74344
  else
74286
- return resolve(p + ext);
74345
+ return resolve2(p + ext);
74287
74346
  }
74288
- return resolve(subStep(p, i, ii + 1));
74347
+ return resolve2(subStep(p, i, ii + 1));
74289
74348
  });
74290
74349
  });
74291
74350
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -74297,7 +74356,7 @@ var require_which = __commonJS({
74297
74356
  for (let i = 0; i < pathEnv.length; i++) {
74298
74357
  const ppRaw = pathEnv[i];
74299
74358
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
74300
- const pCmd = path9.join(pathPart, cmd);
74359
+ const pCmd = path10.join(pathPart, cmd);
74301
74360
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
74302
74361
  for (let j = 0; j < pathExt.length; j++) {
74303
74362
  const cur = p + pathExt[j];
@@ -74347,7 +74406,7 @@ var require_resolveCommand = __commonJS({
74347
74406
  "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
74348
74407
  "use strict";
74349
74408
  init_cjs_shims();
74350
- var path9 = require("path");
74409
+ var path10 = require("path");
74351
74410
  var which = require_which();
74352
74411
  var getPathKey = require_path_key();
74353
74412
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -74365,7 +74424,7 @@ var require_resolveCommand = __commonJS({
74365
74424
  try {
74366
74425
  resolved = which.sync(parsed.command, {
74367
74426
  path: env[getPathKey({ env })],
74368
- pathExt: withoutPathExt ? path9.delimiter : void 0
74427
+ pathExt: withoutPathExt ? path10.delimiter : void 0
74369
74428
  });
74370
74429
  } catch (e) {
74371
74430
  } finally {
@@ -74374,7 +74433,7 @@ var require_resolveCommand = __commonJS({
74374
74433
  }
74375
74434
  }
74376
74435
  if (resolved) {
74377
- resolved = path9.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
74436
+ resolved = path10.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
74378
74437
  }
74379
74438
  return resolved;
74380
74439
  }
@@ -74431,8 +74490,8 @@ var require_shebang_command = __commonJS({
74431
74490
  if (!match) {
74432
74491
  return null;
74433
74492
  }
74434
- const [path9, argument] = match[0].replace(/#! ?/, "").split(" ");
74435
- const binary = path9.split("/").pop();
74493
+ const [path10, argument] = match[0].replace(/#! ?/, "").split(" ");
74494
+ const binary = path10.split("/").pop();
74436
74495
  if (binary === "env") {
74437
74496
  return argument;
74438
74497
  }
@@ -74469,7 +74528,7 @@ var require_parse2 = __commonJS({
74469
74528
  "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
74470
74529
  "use strict";
74471
74530
  init_cjs_shims();
74472
- var path9 = require("path");
74531
+ var path10 = require("path");
74473
74532
  var resolveCommand = require_resolveCommand();
74474
74533
  var escape2 = require_escape();
74475
74534
  var readShebang = require_readShebang();
@@ -74494,7 +74553,7 @@ var require_parse2 = __commonJS({
74494
74553
  const needsShell = !isExecutableRegExp.test(commandFile);
74495
74554
  if (parsed.options.forceShell || needsShell) {
74496
74555
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
74497
- parsed.command = path9.normalize(parsed.command);
74556
+ parsed.command = path10.normalize(parsed.command);
74498
74557
  parsed.command = escape2.command(parsed.command);
74499
74558
  parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
74500
74559
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -74666,7 +74725,7 @@ var init_stdio2 = __esm({
74666
74725
  if (this._process) {
74667
74726
  throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
74668
74727
  }
74669
- return new Promise((resolve, reject) => {
74728
+ return new Promise((resolve2, reject) => {
74670
74729
  var _a, _b, _c, _d, _e;
74671
74730
  this._process = (0, import_cross_spawn.default)(this._serverParams.command, (_a = this._serverParams.args) !== null && _a !== void 0 ? _a : [], {
74672
74731
  // merge default env with server env because mcp server needs some env vars
@@ -74685,7 +74744,7 @@ var init_stdio2 = __esm({
74685
74744
  (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error2);
74686
74745
  });
74687
74746
  this._process.on("spawn", () => {
74688
- resolve();
74747
+ resolve2();
74689
74748
  });
74690
74749
  this._process.on("close", (_code) => {
74691
74750
  var _a2;
@@ -74751,22 +74810,22 @@ var init_stdio2 = __esm({
74751
74810
  if (this._process) {
74752
74811
  const processToClose = this._process;
74753
74812
  this._process = void 0;
74754
- const closePromise = new Promise((resolve) => {
74813
+ const closePromise = new Promise((resolve2) => {
74755
74814
  processToClose.once("close", () => {
74756
- resolve();
74815
+ resolve2();
74757
74816
  });
74758
74817
  });
74759
74818
  try {
74760
74819
  (_a = processToClose.stdin) === null || _a === void 0 ? void 0 : _a.end();
74761
74820
  } catch (_b) {
74762
74821
  }
74763
- await Promise.race([closePromise, new Promise((resolve) => setTimeout(resolve, 2e3).unref())]);
74822
+ await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
74764
74823
  if (processToClose.exitCode === null) {
74765
74824
  try {
74766
74825
  processToClose.kill("SIGTERM");
74767
74826
  } catch (_c) {
74768
74827
  }
74769
- await Promise.race([closePromise, new Promise((resolve) => setTimeout(resolve, 2e3).unref())]);
74828
+ await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
74770
74829
  }
74771
74830
  if (processToClose.exitCode === null) {
74772
74831
  try {
@@ -74778,16 +74837,16 @@ var init_stdio2 = __esm({
74778
74837
  this._readBuffer.clear();
74779
74838
  }
74780
74839
  send(message) {
74781
- return new Promise((resolve) => {
74840
+ return new Promise((resolve2) => {
74782
74841
  var _a;
74783
74842
  if (!((_a = this._process) === null || _a === void 0 ? void 0 : _a.stdin)) {
74784
74843
  throw new Error("Not connected");
74785
74844
  }
74786
74845
  const json = serializeMessage(message);
74787
74846
  if (this._process.stdin.write(json)) {
74788
- resolve();
74847
+ resolve2();
74789
74848
  } else {
74790
- this._process.stdin.once("drain", resolve);
74849
+ this._process.stdin.once("drain", resolve2);
74791
74850
  }
74792
74851
  });
74793
74852
  }
@@ -76132,7 +76191,7 @@ var init_sse = __esm({
76132
76191
  _startOrAuth() {
76133
76192
  var _a, _b, _c;
76134
76193
  const fetchImpl = (_c = (_b = (_a = this === null || this === void 0 ? void 0 : this._eventSourceInit) === null || _a === void 0 ? void 0 : _a.fetch) !== null && _b !== void 0 ? _b : this._fetch) !== null && _c !== void 0 ? _c : fetch;
76135
- return new Promise((resolve, reject) => {
76194
+ return new Promise((resolve2, reject) => {
76136
76195
  this._eventSource = new EventSource(this._url.href, {
76137
76196
  ...this._eventSourceInit,
76138
76197
  fetch: async (url2, init) => {
@@ -76154,7 +76213,7 @@ var init_sse = __esm({
76154
76213
  this._eventSource.onerror = (event) => {
76155
76214
  var _a2;
76156
76215
  if (event.code === 401 && this._authProvider) {
76157
- this._authThenStart().then(resolve, reject);
76216
+ this._authThenStart().then(resolve2, reject);
76158
76217
  return;
76159
76218
  }
76160
76219
  const error2 = new SseError(event.code, event.message, event);
@@ -76177,7 +76236,7 @@ var init_sse = __esm({
76177
76236
  void this.close();
76178
76237
  return;
76179
76238
  }
76180
- resolve();
76239
+ resolve2();
76181
76240
  });
76182
76241
  this._eventSource.onmessage = (event) => {
76183
76242
  var _a2, _b2;
@@ -77347,7 +77406,7 @@ async function executeCLI(options) {
77347
77406
  timeoutSec: timeout / 1e3 + "\u79D2",
77348
77407
  workingDirectory: options.workingDirectory
77349
77408
  });
77350
- return new Promise((resolve) => {
77409
+ return new Promise((resolve2) => {
77351
77410
  const args = buildCommandArgs(options);
77352
77411
  const fullCommand = `${options.tool} ${args.join(" ")}`;
77353
77412
  logger.info(`[CLI] \u57F7\u884C\u547D\u4EE4: ${fullCommand}`);
@@ -77400,7 +77459,7 @@ async function executeCLI(options) {
77400
77459
  clearInterval(progressInterval);
77401
77460
  const executionTime = Date.now() - startTime;
77402
77461
  logger.error(`[CLI] \u57F7\u884C\u932F\u8AA4: ${options.tool}`, { error: error2.message });
77403
- resolve({
77462
+ resolve2({
77404
77463
  success: false,
77405
77464
  output: "",
77406
77465
  error: error2.message,
@@ -77413,7 +77472,7 @@ async function executeCLI(options) {
77413
77472
  clearInterval(progressInterval);
77414
77473
  const executionTime = Date.now() - startTime;
77415
77474
  if (killed) {
77416
- resolve({
77475
+ resolve2({
77417
77476
  success: false,
77418
77477
  output: "",
77419
77478
  error: `Execution timeout after ${timeout}ms`,
@@ -77441,7 +77500,7 @@ async function executeCLI(options) {
77441
77500
  executionTime: executionTime + "ms"
77442
77501
  });
77443
77502
  }
77444
- resolve({
77503
+ resolve2({
77445
77504
  success,
77446
77505
  output: parsedOutput,
77447
77506
  error: success ? void 0 : stderr || "Execution failed",
@@ -78716,7 +78775,7 @@ ${toolResults}
78716
78775
  return prompt;
78717
78776
  }
78718
78777
  function sleep(ms) {
78719
- return new Promise((resolve) => setTimeout(resolve, ms));
78778
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
78720
78779
  }
78721
78780
  function cleanExpiredCache() {
78722
78781
  const now = Date.now();
@@ -82577,10 +82636,10 @@ var require_raw_body2 = __commonJS({
82577
82636
  if (done) {
82578
82637
  return readStream(stream, encoding, length, limit, wrap(done));
82579
82638
  }
82580
- return new Promise(function executor(resolve, reject) {
82639
+ return new Promise(function executor(resolve2, reject) {
82581
82640
  readStream(stream, encoding, length, limit, function onRead(err, buf) {
82582
82641
  if (err) return reject(err);
82583
- resolve(buf);
82642
+ resolve2(buf);
82584
82643
  });
82585
82644
  });
82586
82645
  }
@@ -82750,14 +82809,14 @@ var require_is_wsl = __commonJS({
82750
82809
  "node_modules/.pnpm/is-wsl@2.2.0/node_modules/is-wsl/index.js"(exports2, module2) {
82751
82810
  "use strict";
82752
82811
  init_cjs_shims();
82753
- var os3 = require("os");
82812
+ var os4 = require("os");
82754
82813
  var fs9 = require("fs");
82755
82814
  var isDocker2 = require_is_docker();
82756
82815
  var isWsl2 = () => {
82757
82816
  if (process.platform !== "linux") {
82758
82817
  return false;
82759
82818
  }
82760
- if (os3.release().toLowerCase().includes("microsoft")) {
82819
+ if (os4.release().toLowerCase().includes("microsoft")) {
82761
82820
  if (isDocker2()) {
82762
82821
  return false;
82763
82822
  }
@@ -84074,13 +84133,13 @@ var require_bplistParser = __commonJS({
84074
84133
  this.UID = id;
84075
84134
  };
84076
84135
  var parseFile = exports2.parseFile = function(fileNameOrBuffer, callback) {
84077
- return new Promise(function(resolve, reject) {
84136
+ return new Promise(function(resolve2, reject) {
84078
84137
  function tryParseBuffer(buffer) {
84079
84138
  let err = null;
84080
84139
  let result;
84081
84140
  try {
84082
84141
  result = parseBuffer(buffer);
84083
- resolve(result);
84142
+ resolve2(result);
84084
84143
  } catch (ex) {
84085
84144
  err = ex;
84086
84145
  reject(err);
@@ -84389,8 +84448,8 @@ var require_untildify = __commonJS({
84389
84448
  "node_modules/.pnpm/untildify@4.0.0/node_modules/untildify/index.js"(exports2, module2) {
84390
84449
  "use strict";
84391
84450
  init_cjs_shims();
84392
- var os3 = require("os");
84393
- var homeDirectory = os3.homedir();
84451
+ var os4 = require("os");
84452
+ var homeDirectory = os4.homedir();
84394
84453
  module2.exports = (pathWithTilde) => {
84395
84454
  if (typeof pathWithTilde !== "string") {
84396
84455
  throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
@@ -84466,7 +84525,7 @@ var require_npm_run_path = __commonJS({
84466
84525
  "node_modules/.pnpm/npm-run-path@4.0.1/node_modules/npm-run-path/index.js"(exports2, module2) {
84467
84526
  "use strict";
84468
84527
  init_cjs_shims();
84469
- var path9 = require("path");
84528
+ var path10 = require("path");
84470
84529
  var pathKey2 = require_path_key();
84471
84530
  var npmRunPath2 = (options) => {
84472
84531
  options = {
@@ -84476,16 +84535,16 @@ var require_npm_run_path = __commonJS({
84476
84535
  ...options
84477
84536
  };
84478
84537
  let previous;
84479
- let cwdPath = path9.resolve(options.cwd);
84538
+ let cwdPath = path10.resolve(options.cwd);
84480
84539
  const result = [];
84481
84540
  while (previous !== cwdPath) {
84482
- result.push(path9.join(cwdPath, "node_modules/.bin"));
84541
+ result.push(path10.join(cwdPath, "node_modules/.bin"));
84483
84542
  previous = cwdPath;
84484
- cwdPath = path9.resolve(cwdPath, "..");
84543
+ cwdPath = path10.resolve(cwdPath, "..");
84485
84544
  }
84486
- const execPathDir = path9.resolve(options.cwd, options.execPath, "..");
84545
+ const execPathDir = path10.resolve(options.cwd, options.execPath, "..");
84487
84546
  result.push(execPathDir);
84488
- return result.concat(options.path).join(path9.delimiter);
84547
+ return result.concat(options.path).join(path10.delimiter);
84489
84548
  };
84490
84549
  module2.exports = npmRunPath2;
84491
84550
  module2.exports.default = npmRunPath2;
@@ -84495,9 +84554,9 @@ var require_npm_run_path = __commonJS({
84495
84554
  ...options
84496
84555
  };
84497
84556
  const env = { ...options.env };
84498
- const path10 = pathKey2({ env });
84499
- options.path = env[path10];
84500
- env[path10] = module2.exports(options);
84557
+ const path11 = pathKey2({ env });
84558
+ options.path = env[path11];
84559
+ env[path11] = module2.exports(options);
84501
84560
  return env;
84502
84561
  };
84503
84562
  }
@@ -85286,7 +85345,7 @@ var require_kill = __commonJS({
85286
85345
  "node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/kill.js"(exports2, module2) {
85287
85346
  "use strict";
85288
85347
  init_cjs_shims();
85289
- var os3 = require("os");
85348
+ var os4 = require("os");
85290
85349
  var onExit2 = require_signal_exit();
85291
85350
  var DEFAULT_FORCE_KILL_TIMEOUT2 = 1e3 * 5;
85292
85351
  var spawnedKill2 = (kill, signal = "SIGTERM", options = {}) => {
@@ -85310,7 +85369,7 @@ var require_kill = __commonJS({
85310
85369
  return isSigterm2(signal) && forceKillAfterTimeout !== false && killResult;
85311
85370
  };
85312
85371
  var isSigterm2 = (signal) => {
85313
- return signal === os3.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
85372
+ return signal === os4.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
85314
85373
  };
85315
85374
  var getForceKillAfterTimeout2 = ({ forceKillAfterTimeout = true }) => {
85316
85375
  if (forceKillAfterTimeout === true) {
@@ -85336,7 +85395,7 @@ var require_kill = __commonJS({
85336
85395
  return spawnedPromise;
85337
85396
  }
85338
85397
  let timeoutId;
85339
- const timeoutPromise = new Promise((resolve, reject) => {
85398
+ const timeoutPromise = new Promise((resolve2, reject) => {
85340
85399
  timeoutId = setTimeout(() => {
85341
85400
  timeoutKill2(spawned, killSignal, reject);
85342
85401
  }, timeout);
@@ -85458,7 +85517,7 @@ var require_get_stream = __commonJS({
85458
85517
  };
85459
85518
  const { maxBuffer } = options;
85460
85519
  const stream2 = bufferStream(options);
85461
- await new Promise((resolve, reject) => {
85520
+ await new Promise((resolve2, reject) => {
85462
85521
  const rejectPromise = (error2) => {
85463
85522
  if (error2 && stream2.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
85464
85523
  error2.bufferedData = stream2.getBufferedValue();
@@ -85468,7 +85527,7 @@ var require_get_stream = __commonJS({
85468
85527
  (async () => {
85469
85528
  try {
85470
85529
  await streamPipelinePromisified(inputStream, stream2);
85471
- resolve();
85530
+ resolve2();
85472
85531
  } catch (error2) {
85473
85532
  rejectPromise(error2);
85474
85533
  }
@@ -85628,9 +85687,9 @@ var require_promise = __commonJS({
85628
85687
  return spawned;
85629
85688
  };
85630
85689
  var getSpawnedPromise2 = (spawned) => {
85631
- return new Promise((resolve, reject) => {
85690
+ return new Promise((resolve2, reject) => {
85632
85691
  spawned.on("exit", (exitCode, signal) => {
85633
- resolve({ exitCode, signal });
85692
+ resolve2({ exitCode, signal });
85634
85693
  });
85635
85694
  spawned.on("error", (error2) => {
85636
85695
  reject(error2);
@@ -85700,7 +85759,7 @@ var require_execa = __commonJS({
85700
85759
  "node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js"(exports2, module2) {
85701
85760
  "use strict";
85702
85761
  init_cjs_shims();
85703
- var path9 = require("path");
85762
+ var path10 = require("path");
85704
85763
  var childProcess3 = require("child_process");
85705
85764
  var crossSpawn2 = require_cross_spawn();
85706
85765
  var stripFinalNewline2 = require_strip_final_newline();
@@ -85742,7 +85801,7 @@ var require_execa = __commonJS({
85742
85801
  };
85743
85802
  options.env = getEnv2(options);
85744
85803
  options.stdio = normalizeStdio2(options);
85745
- if (process.platform === "win32" && path9.basename(file, ".exe") === "cmd") {
85804
+ if (process.platform === "win32" && path10.basename(file, ".exe") === "cmd") {
85746
85805
  args.unshift("/q");
85747
85806
  }
85748
85807
  return { file, args, options, parsed };
@@ -86701,7 +86760,7 @@ var init_kill = __esm({
86701
86760
  return spawnedPromise;
86702
86761
  }
86703
86762
  let timeoutId;
86704
- const timeoutPromise = new Promise((resolve, reject) => {
86763
+ const timeoutPromise = new Promise((resolve2, reject) => {
86705
86764
  timeoutId = setTimeout(() => {
86706
86765
  timeoutKill(spawned, killSignal, reject);
86707
86766
  }, timeout);
@@ -86902,9 +86961,9 @@ var init_promise2 = __esm({
86902
86961
  Reflect.defineProperty(spawned, property, { ...descriptor, value });
86903
86962
  }
86904
86963
  };
86905
- getSpawnedPromise = (spawned) => new Promise((resolve, reject) => {
86964
+ getSpawnedPromise = (spawned) => new Promise((resolve2, reject) => {
86906
86965
  spawned.on("exit", (exitCode, signal) => {
86907
- resolve({ exitCode, signal });
86966
+ resolve2({ exitCode, signal });
86908
86967
  });
86909
86968
  spawned.on("error", (error2) => {
86910
86969
  reject(error2);
@@ -87594,14 +87653,14 @@ var init_open = __esm({
87594
87653
  }
87595
87654
  const subprocess = import_node_child_process4.default.spawn(command, cliArguments, childProcessOptions);
87596
87655
  if (options.wait) {
87597
- return new Promise((resolve, reject) => {
87656
+ return new Promise((resolve2, reject) => {
87598
87657
  subprocess.once("error", reject);
87599
87658
  subprocess.once("close", (exitCode) => {
87600
87659
  if (!options.allowNonzeroExitCode && exitCode > 0) {
87601
87660
  reject(new Error(`Exited with code ${exitCode}`));
87602
87661
  return;
87603
87662
  }
87604
- resolve(subprocess);
87663
+ resolve2(subprocess);
87605
87664
  });
87606
87665
  });
87607
87666
  }
@@ -88321,6 +88380,40 @@ var MCPError = class extends Error {
88321
88380
  }
88322
88381
  };
88323
88382
 
88383
+ // src/shared/ipc-constants.ts
88384
+ init_cjs_shims();
88385
+ var IPC_METHODS = {
88386
+ HEALTH_CHECK: "health_check",
88387
+ MCP_TOOL: "mcp_tool",
88388
+ SHUTDOWN: "shutdown",
88389
+ READY: "ready",
88390
+ ERROR: "error"
88391
+ };
88392
+ var IPC_ERROR_CODES = {
88393
+ INTERNAL_ERROR: -32603,
88394
+ INVALID_REQUEST: -32600,
88395
+ METHOD_NOT_FOUND: -32601,
88396
+ INVALID_PARAMS: -32602,
88397
+ TIMEOUT: -32e3,
88398
+ WORKER_NOT_AVAILABLE: -32001,
88399
+ WORKER_CRASHED: -32002
88400
+ };
88401
+ var SUPERVISOR_DEFAULTS = {
88402
+ MAX_RESTART_ATTEMPTS: 5,
88403
+ RESTART_DELAY_MS: 2e3,
88404
+ HEALTH_CHECK_INTERVAL_MS: 3e4,
88405
+ HEALTH_CHECK_TIMEOUT_MS: 5e3,
88406
+ REQUEST_TIMEOUT_MS: 3e4,
88407
+ CONSECUTIVE_FAILURES_BEFORE_RESTART: 3
88408
+ };
88409
+ var SUPERVISOR_ENV_KEYS = {
88410
+ ENABLED: "SUPERVISOR_ENABLED",
88411
+ MAX_RESTART_ATTEMPTS: "SUPERVISOR_MAX_RESTART_ATTEMPTS",
88412
+ RESTART_DELAY_MS: "SUPERVISOR_RESTART_DELAY_MS",
88413
+ HEALTH_CHECK_INTERVAL_MS: "SUPERVISOR_HEALTH_CHECK_INTERVAL_MS",
88414
+ HEALTH_CHECK_TIMEOUT_MS: "SUPERVISOR_HEALTH_CHECK_TIMEOUT_MS"
88415
+ };
88416
+
88324
88417
  // src/config/index.ts
88325
88418
  (0, import_dotenv.config)();
88326
88419
  function getEnvVar(key, defaultValue) {
@@ -88344,6 +88437,27 @@ function getEnvBoolean(key, defaultValue) {
88344
88437
  if (!value) return defaultValue;
88345
88438
  return value.toLowerCase() === "true";
88346
88439
  }
88440
+ function createSupervisorConfig() {
88441
+ return {
88442
+ enabled: getEnvBoolean(SUPERVISOR_ENV_KEYS.ENABLED, false),
88443
+ maxRestartAttempts: getEnvNumber(
88444
+ SUPERVISOR_ENV_KEYS.MAX_RESTART_ATTEMPTS,
88445
+ SUPERVISOR_DEFAULTS.MAX_RESTART_ATTEMPTS
88446
+ ),
88447
+ restartDelayMs: getEnvNumber(
88448
+ SUPERVISOR_ENV_KEYS.RESTART_DELAY_MS,
88449
+ SUPERVISOR_DEFAULTS.RESTART_DELAY_MS
88450
+ ),
88451
+ healthCheckIntervalMs: getEnvNumber(
88452
+ SUPERVISOR_ENV_KEYS.HEALTH_CHECK_INTERVAL_MS,
88453
+ SUPERVISOR_DEFAULTS.HEALTH_CHECK_INTERVAL_MS
88454
+ ),
88455
+ healthCheckTimeoutMs: getEnvNumber(
88456
+ SUPERVISOR_ENV_KEYS.HEALTH_CHECK_TIMEOUT_MS,
88457
+ SUPERVISOR_DEFAULTS.HEALTH_CHECK_TIMEOUT_MS
88458
+ )
88459
+ };
88460
+ }
88347
88461
  function createDefaultConfig() {
88348
88462
  return {
88349
88463
  apiKey: process.env["MCP_API_KEY"],
@@ -88375,7 +88489,12 @@ function createDefaultConfig() {
88375
88489
  healthCheckTimeout: getEnvNumber("MCP_HEALTH_CHECK_TIMEOUT", 3e3),
88376
88490
  forceNewInstance: getEnvBoolean("MCP_FORCE_NEW_INSTANCE", false),
88377
88491
  // MCP Server 傳輸模式
88378
- mcpTransport: getEnvVar("MCP_TRANSPORT", "stdio")
88492
+ mcpTransport: getEnvVar("MCP_TRANSPORT", "stdio"),
88493
+ // Self-Probe (Keep-Alive) 設定
88494
+ enableSelfProbe: getEnvBoolean("MCP_ENABLE_SELF_PROBE", false),
88495
+ selfProbeIntervalSeconds: getEnvNumber("MCP_SELF_PROBE_INTERVAL", 300),
88496
+ // Supervisor 配置
88497
+ supervisor: createSupervisorConfig()
88379
88498
  };
88380
88499
  }
88381
88500
  function validateConfig(config2) {
@@ -88412,6 +88531,41 @@ function validateConfig(config2) {
88412
88531
  "INVALID_LOG_LEVEL"
88413
88532
  );
88414
88533
  }
88534
+ if (config2.selfProbeIntervalSeconds !== void 0) {
88535
+ if (config2.selfProbeIntervalSeconds < 60 || config2.selfProbeIntervalSeconds > 600) {
88536
+ throw new MCPError(
88537
+ `Invalid self-probe interval: ${config2.selfProbeIntervalSeconds}. Must be between 60 and 600 seconds.`,
88538
+ "INVALID_SELF_PROBE_INTERVAL"
88539
+ );
88540
+ }
88541
+ }
88542
+ if (config2.supervisor) {
88543
+ const sup = config2.supervisor;
88544
+ if (sup.maxRestartAttempts < 0 || sup.maxRestartAttempts > 20) {
88545
+ throw new MCPError(
88546
+ `Invalid supervisor max restart attempts: ${sup.maxRestartAttempts}. Must be between 0 and 20.`,
88547
+ "INVALID_SUPERVISOR_CONFIG"
88548
+ );
88549
+ }
88550
+ if (sup.restartDelayMs < 100 || sup.restartDelayMs > 3e4) {
88551
+ throw new MCPError(
88552
+ `Invalid supervisor restart delay: ${sup.restartDelayMs}. Must be between 100ms and 30000ms.`,
88553
+ "INVALID_SUPERVISOR_CONFIG"
88554
+ );
88555
+ }
88556
+ if (sup.healthCheckIntervalMs < 5e3 || sup.healthCheckIntervalMs > 3e5) {
88557
+ throw new MCPError(
88558
+ `Invalid supervisor health check interval: ${sup.healthCheckIntervalMs}. Must be between 5s and 300s.`,
88559
+ "INVALID_SUPERVISOR_CONFIG"
88560
+ );
88561
+ }
88562
+ if (sup.healthCheckTimeoutMs < 1e3 || sup.healthCheckTimeoutMs > 3e4) {
88563
+ throw new MCPError(
88564
+ `Invalid supervisor health check timeout: ${sup.healthCheckTimeoutMs}. Must be between 1s and 30s.`,
88565
+ "INVALID_SUPERVISOR_CONFIG"
88566
+ );
88567
+ }
88568
+ }
88415
88569
  }
88416
88570
  function getConfig() {
88417
88571
  const config2 = createDefaultConfig();
@@ -88438,6 +88592,19 @@ function displayConfig(config2) {
88438
88592
  console.log(` Image To Text: ${config2.enableImageToText ? "enabled" : "disabled"}`);
88439
88593
  console.log(` Image To Text Prompt: ${config2.imageToTextPrompt ? config2.imageToTextPrompt.substring(0, 50) + "..." : "default"}`);
88440
88594
  console.log(` MCP Transport: ${config2.mcpTransport || "stdio"}`);
88595
+ console.log(` Self-Probe: ${config2.enableSelfProbe ? "enabled" : "disabled"}`);
88596
+ if (config2.enableSelfProbe) {
88597
+ console.log(` Self-Probe Interval: ${config2.selfProbeIntervalSeconds || 300}s`);
88598
+ }
88599
+ if (config2.supervisor) {
88600
+ console.log(` Supervisor: ${config2.supervisor.enabled ? "enabled" : "disabled"}`);
88601
+ if (config2.supervisor.enabled) {
88602
+ console.log(` Max Restart Attempts: ${config2.supervisor.maxRestartAttempts}`);
88603
+ console.log(` Restart Delay: ${config2.supervisor.restartDelayMs}ms`);
88604
+ console.log(` Health Check Interval: ${config2.supervisor.healthCheckIntervalMs}ms`);
88605
+ console.log(` Health Check Timeout: ${config2.supervisor.healthCheckTimeoutMs}ms`);
88606
+ }
88607
+ }
88441
88608
  }
88442
88609
 
88443
88610
  // src/cli.ts
@@ -89247,7 +89414,7 @@ var McpServer = class {
89247
89414
  let task = createTaskResult.task;
89248
89415
  const pollInterval = (_a = task.pollInterval) !== null && _a !== void 0 ? _a : 5e3;
89249
89416
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
89250
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
89417
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
89251
89418
  const updatedTask = await extra.taskStore.getTask(taskId);
89252
89419
  if (!updatedTask) {
89253
89420
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -89851,12 +90018,12 @@ var StdioServerTransport = class {
89851
90018
  (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
89852
90019
  }
89853
90020
  send(message) {
89854
- return new Promise((resolve) => {
90021
+ return new Promise((resolve2) => {
89855
90022
  const json = serializeMessage(message);
89856
90023
  if (this._stdout.write(json)) {
89857
- resolve();
90024
+ resolve2();
89858
90025
  } else {
89859
- this._stdout.once("drain", resolve);
90026
+ this._stdout.once("drain", resolve2);
89860
90027
  }
89861
90028
  });
89862
90029
  }
@@ -90682,7 +90849,7 @@ var ProcessManager = class {
90682
90849
  * 等待指定时间
90683
90850
  */
90684
90851
  async wait(ms) {
90685
- return new Promise((resolve) => setTimeout(resolve, ms));
90852
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
90686
90853
  }
90687
90854
  /**
90688
90855
  * 检查进程是否已死亡
@@ -90834,14 +91001,14 @@ var PortManager = class {
90834
91001
  * 檢查連接埠是否可用(增強版本)
90835
91002
  */
90836
91003
  async isPortAvailable(port) {
90837
- return new Promise((resolve) => {
91004
+ return new Promise((resolve2) => {
90838
91005
  const server = (0, import_net.createServer)();
90839
91006
  let resolved = false;
90840
91007
  const timeout = setTimeout(() => {
90841
91008
  if (!resolved) {
90842
91009
  resolved = true;
90843
91010
  server.close(() => {
90844
- resolve(false);
91011
+ resolve2(false);
90845
91012
  });
90846
91013
  }
90847
91014
  }, 1e3);
@@ -90850,7 +91017,7 @@ var PortManager = class {
90850
91017
  resolved = true;
90851
91018
  clearTimeout(timeout);
90852
91019
  server.close(() => {
90853
- resolve(true);
91020
+ resolve2(true);
90854
91021
  });
90855
91022
  }
90856
91023
  });
@@ -90858,7 +91025,7 @@ var PortManager = class {
90858
91025
  if (!resolved) {
90859
91026
  resolved = true;
90860
91027
  clearTimeout(timeout);
90861
- resolve(false);
91028
+ resolve2(false);
90862
91029
  }
90863
91030
  });
90864
91031
  });
@@ -91047,7 +91214,7 @@ var PortManager = class {
91047
91214
  logger.info(`\u9023\u63A5\u57E0 ${port} \u5DF2\u5B8C\u5168\u91CB\u653E`);
91048
91215
  return;
91049
91216
  }
91050
- await new Promise((resolve) => setTimeout(resolve, 200));
91217
+ await new Promise((resolve2) => setTimeout(resolve2, 200));
91051
91218
  }
91052
91219
  throw new MCPError(
91053
91220
  `Port ${port} was not released within ${timeoutMs}ms`,
@@ -91928,12 +92095,12 @@ var ProjectManager = class _ProjectManager {
91928
92095
  static resetInstance() {
91929
92096
  _ProjectManager.instance = null;
91930
92097
  }
91931
- generateProjectId(name, path9) {
91932
- const source = path9 || name;
92098
+ generateProjectId(name, path10) {
92099
+ const source = path10 || name;
91933
92100
  return (0, import_crypto3.createHash)("sha256").update(source).digest("hex").slice(0, 16);
91934
92101
  }
91935
- getOrCreateProject(name, path9) {
91936
- const projectId = this.generateProjectId(name, path9);
92102
+ getOrCreateProject(name, path10) {
92103
+ const projectId = this.generateProjectId(name, path10);
91937
92104
  const existing = this.projects.get(projectId);
91938
92105
  if (existing) {
91939
92106
  existing.lastActiveAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -91944,7 +92111,7 @@ var ProjectManager = class _ProjectManager {
91944
92111
  const newProject = {
91945
92112
  id: projectId,
91946
92113
  name,
91947
- path: path9,
92114
+ path: path10,
91948
92115
  createdAt: now,
91949
92116
  lastActiveAt: now
91950
92117
  };
@@ -92238,6 +92405,127 @@ var InstanceLock = class {
92238
92405
 
92239
92406
  // src/server/web-server.ts
92240
92407
  init_database();
92408
+
92409
+ // src/utils/self-probe-service.ts
92410
+ init_cjs_shims();
92411
+ init_logger();
92412
+ init_database();
92413
+ var SelfProbeService = class {
92414
+ constructor(config2) {
92415
+ this.config = config2;
92416
+ this.enabled = config2.enableSelfProbe ?? false;
92417
+ this.intervalSeconds = config2.selfProbeIntervalSeconds ?? 300;
92418
+ }
92419
+ timer = null;
92420
+ lastProbeTime = null;
92421
+ probeCount = 0;
92422
+ enabled = false;
92423
+ intervalSeconds = 300;
92424
+ context = null;
92425
+ setContext(context) {
92426
+ this.context = context;
92427
+ }
92428
+ start() {
92429
+ if (this.timer) {
92430
+ this.stop();
92431
+ }
92432
+ const dbSettings = getSelfProbeSettings();
92433
+ if (dbSettings) {
92434
+ this.enabled = dbSettings.enabled;
92435
+ this.intervalSeconds = dbSettings.intervalSeconds;
92436
+ }
92437
+ if (!this.enabled) {
92438
+ logger.debug("Self-probe is disabled, not starting");
92439
+ return;
92440
+ }
92441
+ const intervalMs = this.intervalSeconds * 1e3;
92442
+ this.timer = setInterval(() => this.probe(), intervalMs);
92443
+ logger.info(`Self-probe started with interval: ${this.intervalSeconds}s`);
92444
+ }
92445
+ stop() {
92446
+ if (this.timer) {
92447
+ clearInterval(this.timer);
92448
+ this.timer = null;
92449
+ logger.info("Self-probe stopped");
92450
+ }
92451
+ }
92452
+ restart() {
92453
+ this.stop();
92454
+ this.start();
92455
+ }
92456
+ updateSettings(settings) {
92457
+ if (settings.enabled !== void 0) {
92458
+ this.enabled = settings.enabled;
92459
+ }
92460
+ if (settings.intervalSeconds !== void 0) {
92461
+ if (settings.intervalSeconds < 60 || settings.intervalSeconds > 600) {
92462
+ throw new Error("Interval must be between 60 and 600 seconds");
92463
+ }
92464
+ this.intervalSeconds = settings.intervalSeconds;
92465
+ }
92466
+ saveSelfProbeSettings(settings);
92467
+ if (this.enabled) {
92468
+ this.restart();
92469
+ } else {
92470
+ this.stop();
92471
+ }
92472
+ }
92473
+ async probe() {
92474
+ this.lastProbeTime = /* @__PURE__ */ new Date();
92475
+ this.probeCount++;
92476
+ try {
92477
+ if (this.context) {
92478
+ this.checkSocketIO();
92479
+ this.checkMCPStatus();
92480
+ this.triggerSessionCleanup();
92481
+ }
92482
+ logger.debug(`Self-probe #${this.probeCount} completed`);
92483
+ } catch (error2) {
92484
+ logger.warn("Self-probe encountered an issue:", error2);
92485
+ }
92486
+ }
92487
+ checkSocketIO() {
92488
+ if (!this.context) return;
92489
+ const connectedSockets = this.context.getSocketIOConnectionCount();
92490
+ logger.debug(`Self-probe: Socket.IO connected clients: ${connectedSockets}`);
92491
+ }
92492
+ checkMCPStatus() {
92493
+ if (!this.context) return;
92494
+ const mcpStatus = this.context.getMCPServerStatus();
92495
+ logger.debug(`Self-probe: MCP Server running: ${mcpStatus?.running ?? "N/A"}`);
92496
+ }
92497
+ triggerSessionCleanup() {
92498
+ if (!this.context) return;
92499
+ const sessionCount = this.context.getSessionCount();
92500
+ if (sessionCount > 0) {
92501
+ this.context.cleanupExpiredSessions();
92502
+ logger.debug(`Self-probe: Triggered session cleanup, active sessions: ${sessionCount}`);
92503
+ }
92504
+ }
92505
+ getStats() {
92506
+ return {
92507
+ enabled: this.enabled,
92508
+ intervalSeconds: this.intervalSeconds,
92509
+ lastProbeTime: this.lastProbeTime,
92510
+ probeCount: this.probeCount,
92511
+ isRunning: this.timer !== null
92512
+ };
92513
+ }
92514
+ isEnabled() {
92515
+ return this.enabled;
92516
+ }
92517
+ isRunning() {
92518
+ return this.timer !== null;
92519
+ }
92520
+ getProbeCount() {
92521
+ return this.probeCount;
92522
+ }
92523
+ getLastProbeTime() {
92524
+ return this.lastProbeTime;
92525
+ }
92526
+ };
92527
+
92528
+ // src/server/web-server.ts
92241
92529
  init_crypto_helper();
92242
92530
  init_ai_service();
92243
92531
  init_mcp_client_manager();
@@ -92413,6 +92701,7 @@ var WebServer = class {
92413
92701
  sseTransports = /* @__PURE__ */ new Map();
92414
92702
  sseTransportsList = [];
92415
92703
  dbInitialized = false;
92704
+ selfProbeService;
92416
92705
  /**
92417
92706
  * 延遲載入 ImageProcessor
92418
92707
  */
@@ -92454,6 +92743,7 @@ var WebServer = class {
92454
92743
  this.config = config2;
92455
92744
  this.portManager = new PortManager();
92456
92745
  this.sessionStorage = new SessionStorage();
92746
+ this.selfProbeService = new SelfProbeService(config2);
92457
92747
  this.app = (0, import_express.default)();
92458
92748
  this.server = (0, import_http.createServer)(this.app);
92459
92749
  this.io = new Server2(this.server, {
@@ -92494,11 +92784,11 @@ var WebServer = class {
92494
92784
  * 支援多種執行環境:開發模式、打包模式、npx 執行模式
92495
92785
  */
92496
92786
  getStaticAssetsPath() {
92497
- const __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
92498
- const __dirname3 = import_path6.default.dirname(__filename2);
92787
+ const __filename3 = (0, import_url2.fileURLToPath)(importMetaUrl);
92788
+ const __dirname4 = import_path6.default.dirname(__filename3);
92499
92789
  const candidates = [];
92500
- candidates.push(import_path6.default.resolve(__dirname3, "static"));
92501
- const projectRoot = import_path6.default.resolve(__dirname3, "..", "..");
92790
+ candidates.push(import_path6.default.resolve(__dirname4, "static"));
92791
+ const projectRoot = import_path6.default.resolve(__dirname4, "..", "..");
92502
92792
  candidates.push(import_path6.default.resolve(projectRoot, "dist/static"));
92503
92793
  candidates.push(import_path6.default.resolve(projectRoot, "src/static"));
92504
92794
  candidates.push(import_path6.default.resolve(process.cwd(), "dist/static"));
@@ -92519,13 +92809,13 @@ var WebServer = class {
92519
92809
  async waitForActiveSessions(maxWaitMs) {
92520
92810
  const intervalMs = 1e3;
92521
92811
  const start = Date.now();
92522
- return new Promise((resolve, reject) => {
92812
+ return new Promise((resolve2, reject) => {
92523
92813
  const check2 = () => {
92524
92814
  try {
92525
92815
  const count = this.sessionStorage.getSessionCount();
92526
92816
  if (count === 0) {
92527
92817
  clearInterval(timer);
92528
- resolve();
92818
+ resolve2();
92529
92819
  return;
92530
92820
  }
92531
92821
  const elapsed = Date.now() - start;
@@ -92718,6 +93008,7 @@ var WebServer = class {
92718
93008
  });
92719
93009
  });
92720
93010
  this.app.get("/api/health", (req, res) => {
93011
+ const selfProbeStats = this.selfProbeService.getStats();
92721
93012
  res.json({
92722
93013
  status: "ok",
92723
93014
  pid: process.pid,
@@ -92725,7 +93016,14 @@ var WebServer = class {
92725
93016
  uptime: process.uptime(),
92726
93017
  version: VERSION,
92727
93018
  activeSessions: this.sessionStorage.getSessionCount(),
92728
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
93019
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
93020
+ selfProbe: {
93021
+ enabled: selfProbeStats.enabled,
93022
+ isRunning: selfProbeStats.isRunning,
93023
+ probeCount: selfProbeStats.probeCount,
93024
+ lastProbeTime: selfProbeStats.lastProbeTime?.toISOString() ?? null,
93025
+ intervalSeconds: selfProbeStats.intervalSeconds
93026
+ }
92729
93027
  });
92730
93028
  });
92731
93029
  this.app.get("/api/dashboard/overview", (req, res) => {
@@ -93253,6 +93551,46 @@ var WebServer = class {
93253
93551
  });
93254
93552
  }
93255
93553
  });
93554
+ this.app.get("/api/settings/self-probe", (req, res) => {
93555
+ try {
93556
+ const settings = getSelfProbeSettings();
93557
+ const stats = this.selfProbeService.getStats();
93558
+ res.json({
93559
+ success: true,
93560
+ settings: settings ?? { enabled: false, intervalSeconds: 300 },
93561
+ stats
93562
+ });
93563
+ } catch (error2) {
93564
+ logger.error("\u7372\u53D6 Self-Probe \u8A2D\u5B9A\u5931\u6557:", error2);
93565
+ res.status(500).json({
93566
+ success: false,
93567
+ error: error2 instanceof Error ? error2.message : "\u7372\u53D6 Self-Probe \u8A2D\u5B9A\u5931\u6557"
93568
+ });
93569
+ }
93570
+ });
93571
+ this.app.post("/api/settings/self-probe", (req, res) => {
93572
+ try {
93573
+ const { enabled, intervalSeconds } = req.body;
93574
+ if (intervalSeconds !== void 0 && (intervalSeconds < 60 || intervalSeconds > 600)) {
93575
+ res.status(400).json({
93576
+ success: false,
93577
+ error: "Interval must be between 60 and 600 seconds"
93578
+ });
93579
+ return;
93580
+ }
93581
+ this.selfProbeService.updateSettings({ enabled, intervalSeconds });
93582
+ const settings = getSelfProbeSettings();
93583
+ const stats = this.selfProbeService.getStats();
93584
+ logger.info(`Self-Probe \u8A2D\u5B9A\u5DF2\u66F4\u65B0: enabled=${enabled}, interval=${intervalSeconds}s`);
93585
+ res.json({ success: true, settings, stats });
93586
+ } catch (error2) {
93587
+ logger.error("\u66F4\u65B0 Self-Probe \u8A2D\u5B9A\u5931\u6557:", error2);
93588
+ res.status(500).json({
93589
+ success: false,
93590
+ error: error2 instanceof Error ? error2.message : "\u66F4\u65B0 Self-Probe \u8A2D\u5B9A\u5931\u6557"
93591
+ });
93592
+ }
93593
+ });
93256
93594
  this.app.get("/api/logs", (req, res) => {
93257
93595
  try {
93258
93596
  const options = {};
@@ -94423,7 +94761,7 @@ var WebServer = class {
94423
94761
  const project = projectName ? projectManager.getOrCreateProject(projectName, projectPath) : projectManager.getDefaultProject();
94424
94762
  logger.info(`\u5EFA\u7ACB\u56DE\u994B\u6703\u8A71: ${sessionId}, \u903E\u6642: ${timeoutSeconds}\u79D2, \u5C08\u6848: ${project.name} (${project.id})`);
94425
94763
  const feedbackUrl = this.generateFeedbackUrl(sessionId);
94426
- return new Promise((resolve, reject) => {
94764
+ return new Promise((resolve2, reject) => {
94427
94765
  const session = {
94428
94766
  workSummary,
94429
94767
  feedback: [],
@@ -94431,7 +94769,7 @@ var WebServer = class {
94431
94769
  timeout: timeoutSeconds * 1e3,
94432
94770
  projectId: project.id,
94433
94771
  projectName: project.name,
94434
- resolve: (feedback = []) => resolve({
94772
+ resolve: (feedback = []) => resolve2({
94435
94773
  feedback,
94436
94774
  sessionId,
94437
94775
  feedbackUrl,
@@ -94581,7 +94919,7 @@ var WebServer = class {
94581
94919
  this.port = await this.portManager.resolvePortConflict(this.config.webPort);
94582
94920
  }
94583
94921
  logger.info(`\u6E96\u5099\u5728\u9023\u63A5\u57E0 ${this.port} \u555F\u52D5\u4F3A\u670D\u5668...`);
94584
- await new Promise((resolve, reject) => {
94922
+ await new Promise((resolve2, reject) => {
94585
94923
  const timeout = setTimeout(() => {
94586
94924
  reject(new Error("Server start timeout"));
94587
94925
  }, 1e4);
@@ -94594,7 +94932,7 @@ var WebServer = class {
94594
94932
  if (address && typeof address === "object") {
94595
94933
  this.port = address.port;
94596
94934
  }
94597
- resolve();
94935
+ resolve2();
94598
94936
  }
94599
94937
  });
94600
94938
  });
@@ -94610,6 +94948,13 @@ var WebServer = class {
94610
94948
  }
94611
94949
  logger.mcpServerStarted(this.port, serverUrl);
94612
94950
  await this.autoStartMCPServers();
94951
+ this.selfProbeService.setContext({
94952
+ getSocketIOConnectionCount: () => this.io.sockets.sockets.size,
94953
+ getMCPServerStatus: () => this.mcpServerRef?.getStatus(),
94954
+ getSessionCount: () => this.sessionStorage.getSessionCount(),
94955
+ cleanupExpiredSessions: () => this.sessionStorage.cleanupExpiredSessions()
94956
+ });
94957
+ this.selfProbeService.start();
94613
94958
  } catch (error2) {
94614
94959
  logger.error("Web\u4F3A\u670D\u5668\u555F\u52D5\u5931\u6557:", error2);
94615
94960
  throw new MCPError(
@@ -94746,7 +95091,7 @@ var WebServer = class {
94746
95091
  message: "\u670D\u52A1\u5668\u5373\u5C06\u5173\u95ED",
94747
95092
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
94748
95093
  });
94749
- await new Promise((resolve) => setTimeout(resolve, 1e3));
95094
+ await new Promise((resolve2) => setTimeout(resolve2, 1e3));
94750
95095
  }
94751
95096
  if (this.io) {
94752
95097
  this.io.close();
@@ -94756,7 +95101,7 @@ var WebServer = class {
94756
95101
  }
94757
95102
  this.sessionStorage.clear();
94758
95103
  this.sessionStorage.stopCleanupTimer();
94759
- await new Promise((resolve) => setTimeout(resolve, 2e3));
95104
+ await new Promise((resolve2) => setTimeout(resolve2, 2e3));
94760
95105
  this.isServerRunning = false;
94761
95106
  logger.info(`Web\u4F3A\u670D\u5668\u5DF2\u512A\u96C5\u505C\u6B62 (\u9023\u63A5\u57E0: ${currentPort})`);
94762
95107
  } catch (error2) {
@@ -94786,11 +95131,12 @@ var WebServer = class {
94786
95131
  logger.warn("\u7B49\u5F85\u6D3B\u8E8D\u6703\u8A71\u5B8C\u6210\u6642\u767C\u751F\u932F\u8AA4\u6216\u8D85\u6642\uFF0C\u5C07\u7E7C\u7E8C\u505C\u6B62\u6D41\u7A0B", waitErr);
94787
95132
  }
94788
95133
  }
95134
+ this.selfProbeService.stop();
94789
95135
  this.sessionStorage.clear();
94790
95136
  this.sessionStorage.stopCleanupTimer();
94791
95137
  this.io.disconnectSockets(true);
94792
95138
  this.io.close();
94793
- await new Promise((resolve, reject) => {
95139
+ await new Promise((resolve2, reject) => {
94794
95140
  const timeout = setTimeout(() => {
94795
95141
  reject(new Error("Server close timeout"));
94796
95142
  }, 5e3);
@@ -94799,7 +95145,7 @@ var WebServer = class {
94799
95145
  if (error2) {
94800
95146
  reject(error2);
94801
95147
  } else {
94802
- resolve();
95148
+ resolve2();
94803
95149
  }
94804
95150
  });
94805
95151
  });
@@ -94829,6 +95175,24 @@ var WebServer = class {
94829
95175
  getPort() {
94830
95176
  return this.port;
94831
95177
  }
95178
+ /**
95179
+ * 取得 Self-Probe 服務實例
95180
+ */
95181
+ getSelfProbeService() {
95182
+ return this.selfProbeService;
95183
+ }
95184
+ /**
95185
+ * 取得 Socket.IO 伺服器實例
95186
+ */
95187
+ getIO() {
95188
+ return this.io;
95189
+ }
95190
+ /**
95191
+ * 取得 Session Storage 實例
95192
+ */
95193
+ getSessionStorage() {
95194
+ return this.sessionStorage;
95195
+ }
94832
95196
  };
94833
95197
 
94834
95198
  // src/server/mcp-server.ts
@@ -95006,8 +95370,8 @@ var MCPServer = class {
95006
95370
  if (project_path && !this.deferredStartupTriggered) {
95007
95371
  this.deferredStartupTriggered = true;
95008
95372
  const { mcpClientManager: mcpClientManager2 } = await Promise.resolve().then(() => (init_mcp_client_manager(), mcp_client_manager_exports));
95009
- const path9 = await import("path");
95010
- const resolvedProjectName = project_name || path9.basename(project_path);
95373
+ const path10 = await import("path");
95374
+ const resolvedProjectName = project_name || path10.basename(project_path);
95011
95375
  logger.info(`\u9996\u6B21\u6536\u5230\u5C08\u6848\u8CC7\u8A0A\uFF0C\u555F\u52D5\u5EF6\u9072\u7684 MCP Servers: ${resolvedProjectName} @ ${project_path}`);
95012
95376
  mcpClientManager2.startDeferredServers({
95013
95377
  projectName: resolvedProjectName,
@@ -95267,6 +95631,932 @@ var MCPServer = class {
95267
95631
  }
95268
95632
  };
95269
95633
 
95634
+ // src/supervisor/index.ts
95635
+ init_cjs_shims();
95636
+ var path9 = __toESM(require("path"), 1);
95637
+ var import_url3 = require("url");
95638
+
95639
+ // src/supervisor/supervisor-service.ts
95640
+ init_cjs_shims();
95641
+ var import_events4 = require("events");
95642
+ var import_child_process4 = require("child_process");
95643
+ var os3 = __toESM(require("os"), 1);
95644
+
95645
+ // src/supervisor/ipc-bridge.ts
95646
+ init_cjs_shims();
95647
+ var import_events2 = require("events");
95648
+ var import_crypto4 = require("crypto");
95649
+ var IPCBridge = class extends import_events2.EventEmitter {
95650
+ worker = null;
95651
+ pendingRequests = /* @__PURE__ */ new Map();
95652
+ messageBuffer = "";
95653
+ requestTimeout;
95654
+ constructor(requestTimeout = SUPERVISOR_DEFAULTS.REQUEST_TIMEOUT_MS) {
95655
+ super();
95656
+ this.requestTimeout = requestTimeout;
95657
+ }
95658
+ /**
95659
+ * Attach to a worker process
95660
+ */
95661
+ attach(worker) {
95662
+ this.worker = worker;
95663
+ if (worker.stdout) {
95664
+ worker.stdout.on("data", (data) => {
95665
+ this.handleData(data.toString());
95666
+ });
95667
+ }
95668
+ if (worker.stderr) {
95669
+ worker.stderr.on("data", (data) => {
95670
+ this.emit("worker:stderr", data.toString());
95671
+ });
95672
+ }
95673
+ worker.on("exit", (code, signal) => {
95674
+ this.handleWorkerExit(code, signal);
95675
+ });
95676
+ worker.on("error", (error2) => {
95677
+ this.emit("worker:error", error2);
95678
+ });
95679
+ }
95680
+ /**
95681
+ * Detach from worker process
95682
+ */
95683
+ detach() {
95684
+ this.worker = null;
95685
+ this.rejectAllPending(new Error("Worker detached"));
95686
+ }
95687
+ /**
95688
+ * Send a request to the worker and wait for response
95689
+ */
95690
+ async request(method, params) {
95691
+ if (!this.worker || !this.worker.stdin) {
95692
+ throw new Error("Worker not attached or stdin not available");
95693
+ }
95694
+ const id = (0, import_crypto4.randomUUID)();
95695
+ const request = {
95696
+ id,
95697
+ type: "request",
95698
+ method,
95699
+ params,
95700
+ timestamp: Date.now()
95701
+ };
95702
+ return new Promise((resolve2, reject) => {
95703
+ const timeout = setTimeout(() => {
95704
+ this.pendingRequests.delete(id);
95705
+ reject(new Error(`Request timeout: ${method}`));
95706
+ }, this.requestTimeout);
95707
+ this.pendingRequests.set(id, { resolve: resolve2, reject, timeout });
95708
+ this.sendMessage(request);
95709
+ });
95710
+ }
95711
+ /**
95712
+ * Send an event to the worker (no response expected)
95713
+ */
95714
+ send(method, params) {
95715
+ if (!this.worker || !this.worker.stdin) {
95716
+ return;
95717
+ }
95718
+ const message = {
95719
+ id: (0, import_crypto4.randomUUID)(),
95720
+ type: "event",
95721
+ method,
95722
+ params,
95723
+ timestamp: Date.now()
95724
+ };
95725
+ this.sendMessage(message);
95726
+ }
95727
+ /**
95728
+ * Check if worker is connected
95729
+ */
95730
+ isConnected() {
95731
+ return this.worker !== null && !this.worker.killed;
95732
+ }
95733
+ /**
95734
+ * Get pending request count
95735
+ */
95736
+ getPendingCount() {
95737
+ return this.pendingRequests.size;
95738
+ }
95739
+ sendMessage(message) {
95740
+ if (!this.worker?.stdin?.writable) {
95741
+ return;
95742
+ }
95743
+ try {
95744
+ const serialized = JSON.stringify(message) + "\n";
95745
+ this.worker.stdin.write(serialized);
95746
+ } catch (error2) {
95747
+ this.emit("send:error", error2);
95748
+ }
95749
+ }
95750
+ handleData(data) {
95751
+ this.messageBuffer += data;
95752
+ const lines = this.messageBuffer.split("\n");
95753
+ this.messageBuffer = lines.pop() || "";
95754
+ for (const line of lines) {
95755
+ if (line.trim()) {
95756
+ this.processLine(line);
95757
+ }
95758
+ }
95759
+ }
95760
+ processLine(line) {
95761
+ try {
95762
+ const message = JSON.parse(line);
95763
+ this.handleMessage(message);
95764
+ } catch {
95765
+ this.emit("worker:output", line);
95766
+ }
95767
+ }
95768
+ handleMessage(message) {
95769
+ if (message.type === "response") {
95770
+ this.handleResponse(message);
95771
+ } else if (message.type === "event") {
95772
+ this.emit("worker:event", message);
95773
+ }
95774
+ }
95775
+ handleResponse(response) {
95776
+ const pending = this.pendingRequests.get(response.id);
95777
+ if (!pending) {
95778
+ return;
95779
+ }
95780
+ clearTimeout(pending.timeout);
95781
+ this.pendingRequests.delete(response.id);
95782
+ if (response.error) {
95783
+ const error2 = new Error(response.error.message);
95784
+ error2.code = response.error.code;
95785
+ pending.reject(error2);
95786
+ } else {
95787
+ pending.resolve(response.result);
95788
+ }
95789
+ }
95790
+ handleWorkerExit(code, signal) {
95791
+ const error2 = new Error(
95792
+ `Worker exited with code ${code}, signal ${signal}`
95793
+ );
95794
+ this.rejectAllPending(error2);
95795
+ this.emit("worker:exit", { code, signal });
95796
+ }
95797
+ rejectAllPending(error2) {
95798
+ for (const [id, pending] of this.pendingRequests) {
95799
+ clearTimeout(pending.timeout);
95800
+ pending.reject(error2);
95801
+ }
95802
+ this.pendingRequests.clear();
95803
+ }
95804
+ /**
95805
+ * Create an IPC error object
95806
+ */
95807
+ static createError(code, message, data) {
95808
+ return { code, message, data };
95809
+ }
95810
+ static ErrorCodes = IPC_ERROR_CODES;
95811
+ };
95812
+
95813
+ // src/supervisor/health-monitor.ts
95814
+ init_cjs_shims();
95815
+ var import_events3 = require("events");
95816
+ var HealthMonitor = class extends import_events3.EventEmitter {
95817
+ config;
95818
+ ipcBridge;
95819
+ checkInterval = null;
95820
+ state;
95821
+ constructor(ipcBridge, config2) {
95822
+ super();
95823
+ this.ipcBridge = ipcBridge;
95824
+ this.config = {
95825
+ checkIntervalMs: config2?.checkIntervalMs ?? SUPERVISOR_DEFAULTS.HEALTH_CHECK_INTERVAL_MS,
95826
+ checkTimeoutMs: config2?.checkTimeoutMs ?? SUPERVISOR_DEFAULTS.HEALTH_CHECK_TIMEOUT_MS,
95827
+ consecutiveFailuresBeforeRestart: config2?.consecutiveFailuresBeforeRestart ?? SUPERVISOR_DEFAULTS.CONSECUTIVE_FAILURES_BEFORE_RESTART
95828
+ };
95829
+ this.state = {
95830
+ status: "not_running",
95831
+ lastCheckTime: null,
95832
+ consecutiveFailures: 0,
95833
+ lastSuccessTime: null,
95834
+ lastResponse: null
95835
+ };
95836
+ }
95837
+ /**
95838
+ * Start periodic health checks
95839
+ */
95840
+ start() {
95841
+ if (this.checkInterval) {
95842
+ return;
95843
+ }
95844
+ this.checkInterval = setInterval(() => {
95845
+ this.performCheck();
95846
+ }, this.config.checkIntervalMs);
95847
+ this.performCheck();
95848
+ }
95849
+ /**
95850
+ * Stop health checks
95851
+ */
95852
+ stop() {
95853
+ if (this.checkInterval) {
95854
+ clearInterval(this.checkInterval);
95855
+ this.checkInterval = null;
95856
+ }
95857
+ }
95858
+ /**
95859
+ * Get current health state
95860
+ */
95861
+ getState() {
95862
+ return { ...this.state };
95863
+ }
95864
+ /**
95865
+ * Reset health state (called when worker is restarted)
95866
+ */
95867
+ reset() {
95868
+ this.state = {
95869
+ status: "not_running",
95870
+ lastCheckTime: null,
95871
+ consecutiveFailures: 0,
95872
+ lastSuccessTime: null,
95873
+ lastResponse: null
95874
+ };
95875
+ }
95876
+ /**
95877
+ * Mark worker as starting
95878
+ */
95879
+ markStarting() {
95880
+ this.state.status = "not_running";
95881
+ this.state.consecutiveFailures = 0;
95882
+ }
95883
+ /**
95884
+ * Perform a single health check
95885
+ */
95886
+ async performCheck() {
95887
+ if (!this.ipcBridge.isConnected()) {
95888
+ this.handleFailure("Worker not connected");
95889
+ return null;
95890
+ }
95891
+ this.state.lastCheckTime = /* @__PURE__ */ new Date();
95892
+ try {
95893
+ const response = await Promise.race([
95894
+ this.ipcBridge.request(IPC_METHODS.HEALTH_CHECK, {}),
95895
+ this.createTimeout()
95896
+ ]);
95897
+ if (response) {
95898
+ this.handleSuccess(response);
95899
+ return response;
95900
+ } else {
95901
+ this.handleFailure("Health check timeout");
95902
+ return null;
95903
+ }
95904
+ } catch (error2) {
95905
+ this.handleFailure(error2 instanceof Error ? error2.message : String(error2));
95906
+ return null;
95907
+ }
95908
+ }
95909
+ createTimeout() {
95910
+ return new Promise((resolve2) => {
95911
+ setTimeout(() => resolve2(null), this.config.checkTimeoutMs);
95912
+ });
95913
+ }
95914
+ handleSuccess(response) {
95915
+ this.state.status = response.status;
95916
+ this.state.consecutiveFailures = 0;
95917
+ this.state.lastSuccessTime = /* @__PURE__ */ new Date();
95918
+ this.state.lastResponse = response;
95919
+ this.emit("health:ok", response);
95920
+ }
95921
+ handleFailure(reason) {
95922
+ this.state.consecutiveFailures++;
95923
+ this.state.status = "error";
95924
+ this.emit("health:failed", {
95925
+ reason,
95926
+ consecutiveFailures: this.state.consecutiveFailures
95927
+ });
95928
+ if (this.state.consecutiveFailures >= this.config.consecutiveFailuresBeforeRestart) {
95929
+ this.emit("health:restart-needed", {
95930
+ reason,
95931
+ consecutiveFailures: this.state.consecutiveFailures
95932
+ });
95933
+ }
95934
+ }
95935
+ /**
95936
+ * Check if worker needs restart based on health state
95937
+ */
95938
+ needsRestart() {
95939
+ return this.state.consecutiveFailures >= this.config.consecutiveFailuresBeforeRestart;
95940
+ }
95941
+ /**
95942
+ * Get time since last successful health check
95943
+ */
95944
+ getTimeSinceLastSuccess() {
95945
+ if (!this.state.lastSuccessTime) {
95946
+ return null;
95947
+ }
95948
+ return Date.now() - this.state.lastSuccessTime.getTime();
95949
+ }
95950
+ };
95951
+
95952
+ // src/supervisor/supervisor-service.ts
95953
+ var SupervisorService = class extends import_events4.EventEmitter {
95954
+ config;
95955
+ worker = null;
95956
+ ipcBridge;
95957
+ healthMonitor;
95958
+ state;
95959
+ startTime;
95960
+ restartHistory = [];
95961
+ isShuttingDown = false;
95962
+ pendingRequests = /* @__PURE__ */ new Map();
95963
+ constructor(config2) {
95964
+ super();
95965
+ this.config = config2;
95966
+ this.startTime = /* @__PURE__ */ new Date();
95967
+ this.state = {
95968
+ pid: null,
95969
+ status: "stopped",
95970
+ restartCount: 0,
95971
+ lastHealthCheck: null,
95972
+ lastCrash: null,
95973
+ startTime: null
95974
+ };
95975
+ this.ipcBridge = new IPCBridge(SUPERVISOR_DEFAULTS.REQUEST_TIMEOUT_MS);
95976
+ this.healthMonitor = new HealthMonitor(this.ipcBridge, {
95977
+ checkIntervalMs: config2.healthCheckIntervalMs,
95978
+ checkTimeoutMs: config2.healthCheckTimeoutMs
95979
+ });
95980
+ this.setupEventHandlers();
95981
+ }
95982
+ setupEventHandlers() {
95983
+ this.ipcBridge.on("worker:event", (event) => {
95984
+ this.handleWorkerEvent(event);
95985
+ });
95986
+ this.ipcBridge.on("worker:exit", ({ code, signal }) => {
95987
+ this.handleWorkerExit(code, signal);
95988
+ });
95989
+ this.ipcBridge.on("worker:error", (error2) => {
95990
+ this.emit("worker:error", error2);
95991
+ });
95992
+ this.healthMonitor.on("health:ok", (response) => {
95993
+ this.state.lastHealthCheck = /* @__PURE__ */ new Date();
95994
+ this.emit("health:ok", response);
95995
+ });
95996
+ this.healthMonitor.on("health:restart-needed", ({ reason }) => {
95997
+ if (!this.isShuttingDown) {
95998
+ this.scheduleRestart(reason);
95999
+ }
96000
+ });
96001
+ }
96002
+ /**
96003
+ * Start the supervisor and spawn worker
96004
+ */
96005
+ async start() {
96006
+ if (this.state.status === "running") {
96007
+ return;
96008
+ }
96009
+ await this.spawnWorker();
96010
+ }
96011
+ /**
96012
+ * Stop the supervisor and worker
96013
+ */
96014
+ async stop() {
96015
+ this.isShuttingDown = true;
96016
+ this.healthMonitor.stop();
96017
+ if (this.worker) {
96018
+ await this.gracefulShutdown();
96019
+ }
96020
+ this.state.status = "stopped";
96021
+ }
96022
+ /**
96023
+ * Restart the worker process
96024
+ */
96025
+ async restart(reason = "Manual restart") {
96026
+ if (this.isShuttingDown) {
96027
+ return;
96028
+ }
96029
+ const previousPid = this.state.pid;
96030
+ await this.killWorker();
96031
+ await this.spawnWorker();
96032
+ this.restartHistory.push({
96033
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
96034
+ reason
96035
+ });
96036
+ if (this.restartHistory.length > 10) {
96037
+ this.restartHistory = this.restartHistory.slice(-10);
96038
+ }
96039
+ this.emit("worker:restarted", { previousPid, newPid: this.state.pid, reason });
96040
+ }
96041
+ /**
96042
+ * Get current worker state
96043
+ */
96044
+ getState() {
96045
+ return { ...this.state };
96046
+ }
96047
+ /**
96048
+ * Get supervisor uptime in milliseconds
96049
+ */
96050
+ getUptime() {
96051
+ return Date.now() - this.startTime.getTime();
96052
+ }
96053
+ /**
96054
+ * Get worker uptime in milliseconds
96055
+ */
96056
+ getWorkerUptime() {
96057
+ if (!this.state.startTime) {
96058
+ return null;
96059
+ }
96060
+ return Date.now() - this.state.startTime.getTime();
96061
+ }
96062
+ /**
96063
+ * Send MCP tool request to worker
96064
+ */
96065
+ async sendMCPToolRequest(toolName, params) {
96066
+ if (!this.isWorkerHealthy()) {
96067
+ throw new Error("Worker is not healthy");
96068
+ }
96069
+ return this.ipcBridge.request(IPC_METHODS.MCP_TOOL, { toolName, params });
96070
+ }
96071
+ /**
96072
+ * Execute self-test with auto-repair
96073
+ */
96074
+ async selfTest() {
96075
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
96076
+ let autoRepair;
96077
+ if (!this.isWorkerHealthy()) {
96078
+ const previousPid = this.state.pid;
96079
+ const reason = this.state.status === "crashed" ? "Worker crashed" : "Worker not healthy";
96080
+ if (this.state.restartCount < this.config.maxRestartAttempts) {
96081
+ await this.restart(reason);
96082
+ autoRepair = {
96083
+ action: "worker_restarted",
96084
+ previousPid,
96085
+ newPid: this.state.pid,
96086
+ reason
96087
+ };
96088
+ }
96089
+ }
96090
+ const healthResponse = await this.healthMonitor.performCheck();
96091
+ const health = this.buildHealthInfo(healthResponse);
96092
+ const diagnostics = this.buildDiagnosticsInfo();
96093
+ const success = health.worker.status === "ok" || health.worker.status === "restarted";
96094
+ const summary = this.buildSummary(health, autoRepair);
96095
+ return {
96096
+ success,
96097
+ timestamp,
96098
+ health,
96099
+ autoRepair,
96100
+ diagnostics,
96101
+ summary
96102
+ };
96103
+ }
96104
+ buildHealthInfo(healthResponse) {
96105
+ const workerStatus = (autoRepairWasPerformed) => {
96106
+ if (autoRepairWasPerformed) return "restarted";
96107
+ if (this.state.status === "running" && healthResponse?.status === "ok") return "ok";
96108
+ if (this.state.restartCount >= this.config.maxRestartAttempts) return "failed";
96109
+ return "error";
96110
+ };
96111
+ return {
96112
+ supervisor: {
96113
+ status: "ok",
96114
+ pid: process.pid,
96115
+ uptime: this.getUptime(),
96116
+ memoryUsage: process.memoryUsage()
96117
+ },
96118
+ worker: {
96119
+ status: workerStatus(false),
96120
+ pid: this.state.pid,
96121
+ uptime: this.getWorkerUptime(),
96122
+ restartCount: this.state.restartCount
96123
+ },
96124
+ webServer: {
96125
+ status: healthResponse?.webServerPort ? "ok" : "not_running",
96126
+ port: healthResponse?.webServerPort ?? null,
96127
+ activeConnections: healthResponse?.activeConnections ?? 0
96128
+ },
96129
+ database: {
96130
+ status: healthResponse?.databaseConnected ? "ok" : "error"
96131
+ }
96132
+ };
96133
+ }
96134
+ buildDiagnosticsInfo() {
96135
+ return {
96136
+ system: {
96137
+ platform: process.platform,
96138
+ nodeVersion: process.version,
96139
+ totalMemory: os3.totalmem(),
96140
+ freeMemory: os3.freemem()
96141
+ },
96142
+ restartHistory: this.restartHistory
96143
+ };
96144
+ }
96145
+ buildSummary(health, autoRepair) {
96146
+ const parts = [];
96147
+ if (autoRepair) {
96148
+ parts.push(`Worker \u5DF2\u81EA\u52D5\u91CD\u555F (\u539F\u56E0: ${autoRepair.reason})`);
96149
+ }
96150
+ if (health.worker.status === "ok") {
96151
+ parts.push("\u7CFB\u7D71\u6B63\u5E38\u904B\u884C");
96152
+ } else if (health.worker.status === "restarted") {
96153
+ parts.push("Worker \u5DF2\u6062\u5FA9");
96154
+ } else if (health.worker.status === "failed") {
96155
+ parts.push("Worker \u91CD\u555F\u5931\u6557\uFF0C\u9700\u8981\u4EBA\u5DE5\u4ECB\u5165");
96156
+ } else {
96157
+ parts.push("Worker \u72C0\u614B\u7570\u5E38");
96158
+ }
96159
+ if (health.worker.restartCount > 0) {
96160
+ parts.push(`(\u91CD\u555F\u6B21\u6578: ${health.worker.restartCount}/${this.config.maxRestartAttempts})`);
96161
+ }
96162
+ return parts.join(" ");
96163
+ }
96164
+ isWorkerHealthy() {
96165
+ return this.state.status === "running" && this.worker !== null && !this.worker.killed;
96166
+ }
96167
+ async spawnWorker() {
96168
+ this.state.status = "starting";
96169
+ this.emit("worker:starting");
96170
+ const workerPath = this.config.workerScript;
96171
+ const workerArgs = this.config.workerArgs || [];
96172
+ this.worker = (0, import_child_process4.fork)(workerPath, workerArgs, {
96173
+ stdio: ["pipe", "pipe", "pipe", "ipc"],
96174
+ env: {
96175
+ ...process.env,
96176
+ IS_WORKER_PROCESS: "true"
96177
+ }
96178
+ });
96179
+ this.state.pid = this.worker.pid ?? null;
96180
+ this.state.startTime = /* @__PURE__ */ new Date();
96181
+ this.ipcBridge.attach(this.worker);
96182
+ try {
96183
+ await this.waitForReady(1e4);
96184
+ this.state.status = "running";
96185
+ this.healthMonitor.reset();
96186
+ this.healthMonitor.start();
96187
+ this.emit("worker:ready", { pid: this.state.pid });
96188
+ } catch (error2) {
96189
+ this.state.status = "crashed";
96190
+ throw error2;
96191
+ }
96192
+ }
96193
+ waitForReady(timeout) {
96194
+ return new Promise((resolve2, reject) => {
96195
+ const timer = setTimeout(() => {
96196
+ reject(new Error("Worker startup timeout"));
96197
+ }, timeout);
96198
+ const handler = (event) => {
96199
+ if (event.method === IPC_METHODS.READY) {
96200
+ clearTimeout(timer);
96201
+ this.ipcBridge.off("worker:event", handler);
96202
+ resolve2();
96203
+ }
96204
+ };
96205
+ this.ipcBridge.on("worker:event", handler);
96206
+ });
96207
+ }
96208
+ async killWorker() {
96209
+ if (!this.worker) {
96210
+ return;
96211
+ }
96212
+ this.healthMonitor.stop();
96213
+ this.ipcBridge.detach();
96214
+ return new Promise((resolve2) => {
96215
+ const timeout = setTimeout(() => {
96216
+ if (this.worker && !this.worker.killed) {
96217
+ this.worker.kill("SIGKILL");
96218
+ }
96219
+ resolve2();
96220
+ }, 5e3);
96221
+ this.worker.once("exit", () => {
96222
+ clearTimeout(timeout);
96223
+ resolve2();
96224
+ });
96225
+ this.worker.kill("SIGTERM");
96226
+ });
96227
+ }
96228
+ async gracefulShutdown() {
96229
+ if (!this.worker || !this.ipcBridge.isConnected()) {
96230
+ return;
96231
+ }
96232
+ try {
96233
+ await this.ipcBridge.request(IPC_METHODS.SHUTDOWN, { graceful: true });
96234
+ } catch {
96235
+ }
96236
+ await this.killWorker();
96237
+ }
96238
+ handleWorkerEvent(event) {
96239
+ if (event.method === IPC_METHODS.READY) {
96240
+ this.emit("worker:ready", event.params);
96241
+ } else if (event.method === IPC_METHODS.ERROR) {
96242
+ this.emit("worker:error", event.params);
96243
+ }
96244
+ }
96245
+ handleWorkerExit(code, signal) {
96246
+ const wasRunning = this.state.status === "running";
96247
+ this.state.status = "crashed";
96248
+ this.state.lastCrash = /* @__PURE__ */ new Date();
96249
+ this.worker = null;
96250
+ this.emit("worker:exited", { code, signal, wasRunning });
96251
+ if (wasRunning && !this.isShuttingDown) {
96252
+ this.scheduleRestart(`Worker exited with code ${code}, signal ${signal}`);
96253
+ }
96254
+ }
96255
+ scheduleRestart(reason) {
96256
+ if (this.state.restartCount >= this.config.maxRestartAttempts) {
96257
+ this.emit("worker:max-restarts-reached", {
96258
+ restartCount: this.state.restartCount,
96259
+ maxAttempts: this.config.maxRestartAttempts
96260
+ });
96261
+ return;
96262
+ }
96263
+ this.state.restartCount++;
96264
+ setTimeout(() => {
96265
+ if (!this.isShuttingDown) {
96266
+ this.restart(reason).catch((error2) => {
96267
+ this.emit("worker:restart-failed", error2);
96268
+ });
96269
+ }
96270
+ }, this.config.restartDelayMs);
96271
+ }
96272
+ };
96273
+
96274
+ // src/supervisor/mcp-proxy.ts
96275
+ init_cjs_shims();
96276
+ init_types2();
96277
+ var MCPProxyHandler = class {
96278
+ supervisor;
96279
+ mcpServer;
96280
+ workerTools = /* @__PURE__ */ new Map();
96281
+ constructor(supervisor, mcpServer) {
96282
+ this.supervisor = supervisor;
96283
+ this.mcpServer = mcpServer;
96284
+ this.setupHandlers();
96285
+ }
96286
+ setupHandlers() {
96287
+ this.mcpServer.setRequestHandler(ListToolsRequestSchema, async () => {
96288
+ const tools = [
96289
+ // Supervisor-level tool
96290
+ {
96291
+ name: "self_test",
96292
+ description: "\u57F7\u884C\u7CFB\u7D71\u81EA\u6211\u8A3A\u65B7\u8207\u4FEE\u5FA9\u3002\u6AA2\u67E5 Supervisor\u3001Worker\u3001Web Server\u3001\u8CC7\u6599\u5EAB\u72C0\u614B\u3002\u82E5 Worker \u5931\u6548\u6703\u81EA\u52D5\u91CD\u555F\u3002\u8FD4\u56DE\u5B8C\u6574\u5065\u5EB7\u72C0\u614B\u8207\u8A3A\u65B7\u8CC7\u8A0A\u3002",
96293
+ inputSchema: {
96294
+ type: "object",
96295
+ properties: {},
96296
+ required: []
96297
+ }
96298
+ }
96299
+ ];
96300
+ for (const [name, tool] of this.workerTools) {
96301
+ tools.push({
96302
+ name,
96303
+ description: tool.description,
96304
+ inputSchema: tool.inputSchema
96305
+ });
96306
+ }
96307
+ return { tools };
96308
+ });
96309
+ this.mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
96310
+ const { name, arguments: args } = request.params;
96311
+ if (name === "self_test") {
96312
+ return this.handleSelfTest();
96313
+ }
96314
+ return this.proxyToWorker(name, args);
96315
+ });
96316
+ }
96317
+ /**
96318
+ * Register tools from worker
96319
+ */
96320
+ registerWorkerTools(tools) {
96321
+ this.workerTools.clear();
96322
+ for (const tool of tools) {
96323
+ this.workerTools.set(tool.name, {
96324
+ description: tool.description,
96325
+ inputSchema: tool.inputSchema
96326
+ });
96327
+ }
96328
+ }
96329
+ /**
96330
+ * Handle self_test tool call
96331
+ */
96332
+ async handleSelfTest() {
96333
+ try {
96334
+ const result = await this.supervisor.selfTest();
96335
+ const text = this.formatSelfTestResult(result);
96336
+ return {
96337
+ content: [{ type: "text", text }]
96338
+ };
96339
+ } catch (error2) {
96340
+ const errorMessage = error2 instanceof Error ? error2.message : String(error2);
96341
+ return {
96342
+ content: [
96343
+ {
96344
+ type: "text",
96345
+ text: `\u274C \u81EA\u6211\u8A3A\u65B7\u57F7\u884C\u5931\u6557: ${errorMessage}`
96346
+ }
96347
+ ]
96348
+ };
96349
+ }
96350
+ }
96351
+ /**
96352
+ * Format self-test result for display
96353
+ */
96354
+ formatSelfTestResult(result) {
96355
+ const lines = [];
96356
+ const emoji2 = result.success ? "\u2705" : "\u26A0\uFE0F";
96357
+ lines.push(`${emoji2} **\u81EA\u6211\u8A3A\u65B7\u7D50\u679C**`);
96358
+ lines.push(`\u6642\u9593: ${result.timestamp}`);
96359
+ lines.push("");
96360
+ lines.push("## \u5065\u5EB7\u72C0\u614B");
96361
+ lines.push(`- Supervisor: ${this.statusEmoji(result.health.supervisor.status)} ${result.health.supervisor.status}`);
96362
+ lines.push(` - PID: ${result.health.supervisor.pid}`);
96363
+ lines.push(` - \u904B\u884C\u6642\u9593: ${this.formatUptime(result.health.supervisor.uptime)}`);
96364
+ lines.push(` - \u8A18\u61B6\u9AD4: ${this.formatMemory(result.health.supervisor.memoryUsage.heapUsed)}`);
96365
+ lines.push("");
96366
+ lines.push(`- Worker: ${this.statusEmoji(result.health.worker.status)} ${result.health.worker.status}`);
96367
+ lines.push(` - PID: ${result.health.worker.pid ?? "N/A"}`);
96368
+ lines.push(` - \u904B\u884C\u6642\u9593: ${result.health.worker.uptime ? this.formatUptime(result.health.worker.uptime) : "N/A"}`);
96369
+ lines.push(` - \u91CD\u555F\u6B21\u6578: ${result.health.worker.restartCount}`);
96370
+ lines.push("");
96371
+ lines.push(`- Web Server: ${this.statusEmoji(result.health.webServer.status)} ${result.health.webServer.status}`);
96372
+ lines.push(` - \u9023\u63A5\u57E0: ${result.health.webServer.port ?? "N/A"}`);
96373
+ lines.push(` - \u6D3B\u52D5\u9023\u7DDA: ${result.health.webServer.activeConnections}`);
96374
+ lines.push("");
96375
+ lines.push(`- \u8CC7\u6599\u5EAB: ${this.statusEmoji(result.health.database.status)} ${result.health.database.status}`);
96376
+ lines.push("");
96377
+ if (result.autoRepair) {
96378
+ lines.push("## \u81EA\u52D5\u4FEE\u5FA9");
96379
+ lines.push(`- \u64CD\u4F5C: ${result.autoRepair.action}`);
96380
+ lines.push(`- \u539F\u56E0: ${result.autoRepair.reason}`);
96381
+ lines.push(`- \u539F PID: ${result.autoRepair.previousPid ?? "N/A"}`);
96382
+ lines.push(`- \u65B0 PID: ${result.autoRepair.newPid}`);
96383
+ lines.push("");
96384
+ }
96385
+ lines.push("## \u7CFB\u7D71\u8CC7\u8A0A");
96386
+ lines.push(`- \u5E73\u53F0: ${result.diagnostics.system.platform}`);
96387
+ lines.push(`- Node.js: ${result.diagnostics.system.nodeVersion}`);
96388
+ lines.push(`- \u7E3D\u8A18\u61B6\u9AD4: ${this.formatMemory(result.diagnostics.system.totalMemory)}`);
96389
+ lines.push(`- \u53EF\u7528\u8A18\u61B6\u9AD4: ${this.formatMemory(result.diagnostics.system.freeMemory)}`);
96390
+ lines.push("");
96391
+ if (result.diagnostics.restartHistory.length > 0) {
96392
+ lines.push("## \u91CD\u555F\u6B77\u53F2");
96393
+ for (const entry of result.diagnostics.restartHistory.slice(-5)) {
96394
+ lines.push(`- ${entry.timestamp}: ${entry.reason}`);
96395
+ }
96396
+ lines.push("");
96397
+ }
96398
+ lines.push("---");
96399
+ lines.push(`**\u7E3D\u7D50**: ${result.summary}`);
96400
+ return lines.join("\n");
96401
+ }
96402
+ statusEmoji(status) {
96403
+ switch (status) {
96404
+ case "ok":
96405
+ return "\u{1F7E2}";
96406
+ case "restarted":
96407
+ return "\u{1F7E1}";
96408
+ case "error":
96409
+ case "failed":
96410
+ return "\u{1F534}";
96411
+ case "not_running":
96412
+ return "\u26AA";
96413
+ default:
96414
+ return "\u26AB";
96415
+ }
96416
+ }
96417
+ formatUptime(ms) {
96418
+ const seconds = Math.floor(ms / 1e3);
96419
+ const minutes = Math.floor(seconds / 60);
96420
+ const hours = Math.floor(minutes / 60);
96421
+ const days = Math.floor(hours / 24);
96422
+ if (days > 0) {
96423
+ return `${days}d ${hours % 24}h`;
96424
+ }
96425
+ if (hours > 0) {
96426
+ return `${hours}h ${minutes % 60}m`;
96427
+ }
96428
+ if (minutes > 0) {
96429
+ return `${minutes}m ${seconds % 60}s`;
96430
+ }
96431
+ return `${seconds}s`;
96432
+ }
96433
+ formatMemory(bytes) {
96434
+ const mb = bytes / 1024 / 1024;
96435
+ if (mb >= 1024) {
96436
+ return `${(mb / 1024).toFixed(2)} GB`;
96437
+ }
96438
+ return `${mb.toFixed(2)} MB`;
96439
+ }
96440
+ /**
96441
+ * Proxy tool call to worker
96442
+ */
96443
+ async proxyToWorker(toolName, args) {
96444
+ try {
96445
+ const result = await this.supervisor.sendMCPToolRequest(toolName, args);
96446
+ if (result && typeof result === "object" && "content" in result) {
96447
+ return result;
96448
+ }
96449
+ return {
96450
+ content: [{ type: "text", text: JSON.stringify(result) }]
96451
+ };
96452
+ } catch (error2) {
96453
+ const errorMessage = error2 instanceof Error ? error2.message : String(error2);
96454
+ return {
96455
+ content: [
96456
+ {
96457
+ type: "text",
96458
+ text: `\u274C \u5DE5\u5177\u57F7\u884C\u5931\u6557: ${errorMessage}
96459
+
96460
+ \u63D0\u793A: \u53EF\u4EE5\u4F7F\u7528 \`self_test\` \u5DE5\u5177\u6AA2\u67E5\u7CFB\u7D71\u72C0\u614B\u4E26\u5617\u8A66\u81EA\u52D5\u4FEE\u5FA9\u3002`
96461
+ }
96462
+ ]
96463
+ };
96464
+ }
96465
+ }
96466
+ };
96467
+
96468
+ // src/supervisor/index.ts
96469
+ init_logger();
96470
+ var __filename2 = (0, import_url3.fileURLToPath)(importMetaUrl);
96471
+ var __dirname3 = path9.dirname(__filename2);
96472
+ async function startSupervisorMode() {
96473
+ logger.info("Starting in Supervisor mode...");
96474
+ const config2 = getConfig();
96475
+ const supervisorConfig = createSupervisorConfig();
96476
+ const workerScript = path9.resolve(__dirname3, "../worker/index.js");
96477
+ const serviceConfig = {
96478
+ ...supervisorConfig,
96479
+ workerScript,
96480
+ workerArgs: []
96481
+ };
96482
+ const mcpServer = new Server(
96483
+ {
96484
+ name: "user-feedback-supervisor",
96485
+ version: "1.0.0"
96486
+ },
96487
+ {
96488
+ capabilities: {
96489
+ tools: {}
96490
+ }
96491
+ }
96492
+ );
96493
+ const supervisor = new SupervisorService(serviceConfig);
96494
+ const mcpProxy = new MCPProxyHandler(supervisor, mcpServer);
96495
+ setupSupervisorEvents(supervisor);
96496
+ setupGracefulShutdown(supervisor);
96497
+ const transport = new StdioServerTransport();
96498
+ await mcpServer.connect(transport);
96499
+ logger.info("MCP transport connected");
96500
+ await supervisor.start();
96501
+ logger.info("Supervisor started successfully");
96502
+ process.stdin.resume();
96503
+ }
96504
+ function setupSupervisorEvents(supervisor) {
96505
+ supervisor.on("worker:starting", () => {
96506
+ logger.info("Worker starting...");
96507
+ });
96508
+ supervisor.on("worker:ready", ({ pid }) => {
96509
+ logger.info(`Worker ready (PID: ${pid})`);
96510
+ });
96511
+ supervisor.on("worker:exited", ({ code, signal, wasRunning }) => {
96512
+ if (wasRunning) {
96513
+ logger.warn(`Worker exited unexpectedly (code: ${code}, signal: ${signal})`);
96514
+ } else {
96515
+ logger.info(`Worker exited (code: ${code}, signal: ${signal})`);
96516
+ }
96517
+ });
96518
+ supervisor.on("worker:restarted", ({ previousPid, newPid, reason }) => {
96519
+ logger.info(`Worker restarted: ${previousPid} -> ${newPid} (reason: ${reason})`);
96520
+ });
96521
+ supervisor.on("worker:error", (error2) => {
96522
+ logger.error("Worker error:", error2);
96523
+ });
96524
+ supervisor.on("worker:max-restarts-reached", ({ restartCount, maxAttempts }) => {
96525
+ logger.error(`Max restart attempts reached (${restartCount}/${maxAttempts}). Worker will not be restarted.`);
96526
+ });
96527
+ supervisor.on("health:ok", () => {
96528
+ logger.debug("Worker health check passed");
96529
+ });
96530
+ }
96531
+ function setupGracefulShutdown(supervisor) {
96532
+ let isShuttingDown = false;
96533
+ const shutdown = async (signal) => {
96534
+ if (isShuttingDown) return;
96535
+ isShuttingDown = true;
96536
+ logger.info(`Received ${signal}, shutting down...`);
96537
+ try {
96538
+ await supervisor.stop();
96539
+ logger.info("Supervisor stopped");
96540
+ process.exit(0);
96541
+ } catch (error2) {
96542
+ logger.error("Error during shutdown:", error2);
96543
+ process.exit(1);
96544
+ }
96545
+ };
96546
+ process.on("SIGINT", () => shutdown("SIGINT"));
96547
+ process.on("SIGTERM", () => shutdown("SIGTERM"));
96548
+ if (process.platform === "win32") {
96549
+ process.on("SIGBREAK", () => shutdown("SIGBREAK"));
96550
+ }
96551
+ process.on("uncaughtException", async (error2) => {
96552
+ logger.error("Uncaught exception in supervisor:", error2);
96553
+ await shutdown("uncaughtException");
96554
+ });
96555
+ process.on("unhandledRejection", (reason) => {
96556
+ logger.error("Unhandled rejection in supervisor:", reason);
96557
+ });
96558
+ }
96559
+
95270
96560
  // src/cli.ts
95271
96561
  var VERSION2 = getPackageVersion();
95272
96562
  var isMCPMode = !process.stdin.isTTY || process.env["NODE_ENV"] === "mcp" || process.argv.includes("--mcp-mode");
@@ -95287,6 +96577,12 @@ function showWelcome() {
95287
96577
  async function startMCPServer(options) {
95288
96578
  try {
95289
96579
  const config2 = getConfig();
96580
+ const useSupervisor = options.supervisor !== false && config2.supervisor?.enabled;
96581
+ if (useSupervisor && !options.web) {
96582
+ logger.info("\u4F7F\u7528 Supervisor \u6A21\u5F0F\u555F\u52D5...");
96583
+ await startSupervisorMode();
96584
+ return;
96585
+ }
95290
96586
  if (!isMCPMode) {
95291
96587
  showWelcome();
95292
96588
  logger.setLevel(config2.logLevel);
@@ -95368,7 +96664,7 @@ async function healthCheck() {
95368
96664
  }
95369
96665
  }
95370
96666
  program.name("user-web-feedback").description("\u57FA\u65BCNode.js\u7684MCP\u56DE\u994B\u6536\u96C6\u5668").version(VERSION2);
95371
- program.command("start", { isDefault: true }).description("\u555F\u52D5MCP\u56DE\u994B\u6536\u96C6\u5668").option("-p, --port <number>", "\u6307\u5B9AWeb\u4F3A\u670D\u5668\u9023\u63A5\u57E0", parseInt).option("-w, --web", "\u50C5\u555F\u52D5Web\u6A21\u5F0F\uFF08\u4E0D\u555F\u52D5MCP\u4F3A\u670D\u5668\uFF09").option("-t, --transport <type>", "MCP\u50B3\u8F38\u6A21\u5F0F (stdio|sse|streamable-http)", "stdio").option("-c, --config <path>", "\u6307\u5B9A\u8A2D\u5B9A\u6A94\u8DEF\u5F91").option("-d, --debug", "\u555F\u7528\u9664\u932F\u6A21\u5F0F\uFF08\u986F\u793A\u8A73\u7D30\u7684MCP\u901A\u8A0A\u65E5\u8A8C\uFF09").option("--mcp-mode", "\u5F37\u5236\u555F\u7528MCP\u6A21\u5F0F\uFF08\u7528\u65BC\u9664\u932F\uFF09").option("-f, --force-new", "\u5F37\u5236\u555F\u52D5\u65B0\u5BE6\u4F8B\uFF08\u5FFD\u7565\u5DF2\u904B\u884C\u7684\u5BE6\u4F8B\uFF09").action(startMCPServer);
96667
+ program.command("start", { isDefault: true }).description("\u555F\u52D5MCP\u56DE\u994B\u6536\u96C6\u5668").option("-p, --port <number>", "\u6307\u5B9AWeb\u4F3A\u670D\u5668\u9023\u63A5\u57E0", parseInt).option("-w, --web", "\u50C5\u555F\u52D5Web\u6A21\u5F0F\uFF08\u4E0D\u555F\u52D5MCP\u4F3A\u670D\u5668\uFF09").option("-t, --transport <type>", "MCP\u50B3\u8F38\u6A21\u5F0F (stdio|sse|streamable-http)", "stdio").option("-c, --config <path>", "\u6307\u5B9A\u8A2D\u5B9A\u6A94\u8DEF\u5F91").option("-d, --debug", "\u555F\u7528\u9664\u932F\u6A21\u5F0F\uFF08\u986F\u793A\u8A73\u7D30\u7684MCP\u901A\u8A0A\u65E5\u8A8C\uFF09").option("--mcp-mode", "\u5F37\u5236\u555F\u7528MCP\u6A21\u5F0F\uFF08\u7528\u65BC\u9664\u932F\uFF09").option("-f, --force-new", "\u5F37\u5236\u555F\u52D5\u65B0\u5BE6\u4F8B\uFF08\u5FFD\u7565\u5DF2\u904B\u884C\u7684\u5BE6\u4F8B\uFF09").option("--no-supervisor", "\u7981\u7528 Supervisor \u6A21\u5F0F\uFF08\u76F4\u63A5\u555F\u52D5\u50B3\u7D71\u6A21\u5F0F\uFF09").action(startMCPServer);
95372
96668
  program.command("health").description("\u6AA2\u67E5\u8A2D\u5B9A\u548C\u7CFB\u7D71\u72C0\u614B").action(healthCheck);
95373
96669
  program.command("config").description("\u986F\u793A\u7576\u524D\u8A2D\u5B9A").action(() => {
95374
96670
  try {
@@ -95387,7 +96683,7 @@ program.command("metrics").description("\u986F\u793A\u6548\u80FD\u76E3\u63A7\u63
95387
96683
  logger.info("\u{1F50D} \u53D6\u5F97\u6548\u80FD\u76E3\u63A7\u6307\u6A19...");
95388
96684
  const server = new MCPServer(config2);
95389
96685
  await server.startWebOnly();
95390
- await new Promise((resolve) => setTimeout(resolve, 1e3));
96686
+ await new Promise((resolve2) => setTimeout(resolve2, 1e3));
95391
96687
  try {
95392
96688
  const runtimeFetch = getRuntimeFetch2();
95393
96689
  const response = await runtimeFetch(`http://localhost:${server.getStatus().webPort}/api/metrics`);
@@ -95416,7 +96712,7 @@ program.command("test-feedback").description("\u6E2C\u8A66collect_feedback\u5DE5
95416
96712
  logger.info("\u958B\u59CB\u6E2C\u8A66collect_feedback\u5DE5\u5177\u51FD\u5F0F...");
95417
96713
  const server = new MCPServer(config2);
95418
96714
  await server.startWebOnly();
95419
- await new Promise((resolve) => setTimeout(resolve, 1e3));
96715
+ await new Promise((resolve2) => setTimeout(resolve2, 1e3));
95420
96716
  logger.info("\u5EFA\u7ACB\u6E2C\u8A66\u6703\u8A71...");
95421
96717
  const timeoutSeconds = parseInt(options.timeout) || 30;
95422
96718
  const testParams = {