@lob-ox/core-darwin-x64 0.0.16 → 0.0.17

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.
Files changed (2) hide show
  1. package/core.cjs +447 -295
  2. package/package.json +1 -1
package/core.cjs CHANGED
@@ -917,29 +917,29 @@ var require_brand = __commonJS({
917
917
  "src/shared/brand.js"(exports2, module2) {
918
918
  "use strict";
919
919
  var path2 = require("node:path");
920
- var SHARED = require_shared_constants2();
921
- var PRODUCT_NAME = SHARED.product.name;
922
- var CLI_NAME = SHARED.product.cliName;
923
- var GUI_BIN_NAME = SHARED.product.guiBinName;
924
- var GUI_CRATE_NAME = SHARED.product.guiCrateName;
920
+ var SHARED2 = require_shared_constants2();
921
+ var PRODUCT_NAME = SHARED2.product.name;
922
+ var CLI_NAME = SHARED2.product.cliName;
923
+ var GUI_BIN_NAME = SHARED2.product.guiBinName;
924
+ var GUI_CRATE_NAME = SHARED2.product.guiCrateName;
925
925
  var NPM_SCOPE = "@lob-ox";
926
926
  var CORE_PKG_PREFIX = "core-";
927
927
  var CORE_PKG_TAGS = ["linux-x64", "darwin-arm64", "darwin-x64", "win-x64"];
928
928
  var SHELL_RELEASE_PKG = "@lob-ox/shell-release";
929
929
  var TAURI_IDENTIFIER = "dev.bowen.lobox";
930
930
  var TAURI_PRODUCT_NAME = "lobox";
931
- var STATE_DIR_NAME = SHARED.state.dirName;
932
- var STATE_SUPERVISOR_SUBDIR = SHARED.state.supervisorSubdir;
933
- var STATE_SHELL_SUBDIR = SHARED.state.shellSubdir;
931
+ var STATE_DIR_NAME = SHARED2.state.dirName;
932
+ var STATE_SUPERVISOR_SUBDIR = SHARED2.state.supervisorSubdir;
933
+ var STATE_SHELL_SUBDIR = SHARED2.state.shellSubdir;
934
934
  var LEGACY_PRODUCT_NAME = "dsh-supervisor";
935
- var STATE_ROOT_WIN_BASE_ENV = SHARED.state.winBaseEnv;
935
+ var STATE_ROOT_WIN_BASE_ENV = SHARED2.state.winBaseEnv;
936
936
  var STATE_ROOT_WIN_BASE_FALLBACK_SEGMENTS = ["AppData", "Local"];
937
937
  var STATE_ROOT_MACOS_SEGMENTS = ["Library", "Application Support"];
938
- var STATE_ROOT_LINUX_XDG_ENV = SHARED.state.linuxXdgEnv;
938
+ var STATE_ROOT_LINUX_XDG_ENV = SHARED2.state.linuxXdgEnv;
939
939
  var STATE_ROOT_LINUX_FALLBACK_SEGMENTS = [".local", "state"];
940
- var LEGACY_HARNESS_DIR = SHARED.state.legacyHarnessDir;
941
- var ENV_STATE_ROOT = SHARED.env.stateRoot;
942
- var ENV_CONFIG = SHARED.env.config;
940
+ var LEGACY_HARNESS_DIR = SHARED2.state.legacyHarnessDir;
941
+ var ENV_STATE_ROOT = SHARED2.env.stateRoot;
942
+ var ENV_CONFIG = SHARED2.env.config;
943
943
  var ENV_LOCK_FILE = "DSH_SUPERVISOR_LOCK_FILE";
944
944
  var ENV_DAEMON = "DSH_SUPERVISOR_DAEMON";
945
945
  var ENV_TRAY_PORT = "DSH_SUPERVISOR_TRAY_PORT";
@@ -995,10 +995,10 @@ var require_brand = __commonJS({
995
995
  var CLI_BIN_NAMES = ["lobox.exe", "lobox.cmd", "lobox"];
996
996
  var CLI_SHIM_NAMES = ["lobox", "lobox.cmd", "lobox.ps1"];
997
997
  var GUI_BIN_NAMES = ["lobox-shell", "lobox-shell.exe"];
998
- var PROC_MATCH_GUARD = SHARED.proc.matchGuard;
999
- var BRIDGE_MSG_KERNEL_UPDATE_REQUEST = SHARED.bridge.msgKernelUpdateRequest;
1000
- var BRIDGE_MSG_KERNEL_UPDATE_RESULT = SHARED.bridge.msgKernelUpdateResult;
1001
- var BRIDGE_MSG_KERNEL_UPDATE_PROGRESS = SHARED.bridge.msgKernelUpdateProgress;
998
+ var PROC_MATCH_GUARD = SHARED2.proc.matchGuard;
999
+ var BRIDGE_MSG_KERNEL_UPDATE_REQUEST = SHARED2.bridge.msgKernelUpdateRequest;
1000
+ var BRIDGE_MSG_KERNEL_UPDATE_RESULT = SHARED2.bridge.msgKernelUpdateResult;
1001
+ var BRIDGE_MSG_KERNEL_UPDATE_PROGRESS = SHARED2.bridge.msgKernelUpdateProgress;
1002
1002
  var STORE_KEY_API_ACCESS = "lobox.apiAccessKey";
1003
1003
  var COOKIE_LAN_TOKEN = "lobox_lan_token";
1004
1004
  var EVENT_HARNESS_EXITED = "harness_exited";
@@ -1283,7 +1283,7 @@ var require_config = __commonJS({
1283
1283
  "use strict";
1284
1284
  var os2 = require("node:os");
1285
1285
  var path2 = require("node:path");
1286
- var SHARED = require_shared_constants2();
1286
+ var SHARED2 = require_shared_constants2();
1287
1287
  function expandHome(p) {
1288
1288
  if (typeof p !== "string") return p;
1289
1289
  if (p === "~") return os2.homedir();
@@ -1308,7 +1308,7 @@ var require_config = __commonJS({
1308
1308
  stopGraceMs: 1e4,
1309
1309
  portReleaseWaitMs: 1e4,
1310
1310
  apiHost: "127.0.0.1",
1311
- apiPort: SHARED.net.apiPort,
1311
+ apiPort: SHARED2.net.apiPort,
1312
1312
  portPools: null,
1313
1313
  stateFile: path2.join(SUP, "state.json"),
1314
1314
  logFile: path2.join(SUP, "events", "guard.events.log"),
@@ -1355,7 +1355,7 @@ var require_config = __commonJS({
1355
1355
  return out;
1356
1356
  }
1357
1357
  var DEFAULTS = buildDefaults2(null);
1358
- var DEPRECATED_API_PORTS = SHARED.net.deprecatedApiPorts.slice();
1358
+ var DEPRECATED_API_PORTS = SHARED2.net.deprecatedApiPorts.slice();
1359
1359
  function isDeprecatedApiPort(v) {
1360
1360
  const n = Number(v);
1361
1361
  return Number.isInteger(n) && DEPRECATED_API_PORTS.includes(n);
@@ -1431,13 +1431,13 @@ var require_config = __commonJS({
1431
1431
  var require_domain_config = __commonJS({
1432
1432
  "src/app/settings/domain-config.js"(exports2, module2) {
1433
1433
  "use strict";
1434
- var SHARED = require_shared_constants2();
1434
+ var SHARED2 = require_shared_constants2();
1435
1435
  var defaults = [
1436
1436
  {
1437
1437
  at: "portPools",
1438
1438
  values: {
1439
- routerCtlPort: SHARED.net.routerCtlPort,
1440
- lanCtlPort: SHARED.net.lanCtlPort
1439
+ routerCtlPort: SHARED2.net.routerCtlPort,
1440
+ lanCtlPort: SHARED2.net.lanCtlPort
1441
1441
  }
1442
1442
  },
1443
1443
  {
@@ -1467,7 +1467,7 @@ var require_version = __commonJS({
1467
1467
  var fs2 = require("node:fs");
1468
1468
  var path2 = require("node:path");
1469
1469
  function guardVersion() {
1470
- if (true) return String("0.0.16");
1470
+ if (true) return String("0.0.17");
1471
1471
  try {
1472
1472
  return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
1473
1473
  } catch {
@@ -3358,15 +3358,15 @@ var require_client = __commonJS({
3358
3358
  "src/app/ctl/client.js"(exports2, module2) {
3359
3359
  "use strict";
3360
3360
  var hub = require_hub();
3361
- var SHARED = require_shared_constants2();
3361
+ var SHARED2 = require_shared_constants2();
3362
3362
  function ctlCall(port, method, args, timeoutMs) {
3363
3363
  return hub.ctlCall(port, method, args, timeoutMs || 12e4, { withErrorFields: true });
3364
3364
  }
3365
3365
  function routerCtlPort(config) {
3366
- return Number(config && config.routerCtlPort) || SHARED.net.routerCtlPort;
3366
+ return Number(config && config.routerCtlPort) || SHARED2.net.routerCtlPort;
3367
3367
  }
3368
3368
  function lanCtlPort(config) {
3369
- return Number(config && config.lanCtlPort) || SHARED.net.lanCtlPort;
3369
+ return Number(config && config.lanCtlPort) || SHARED2.net.lanCtlPort;
3370
3370
  }
3371
3371
  function createCtlClient(deps) {
3372
3372
  const g = deps || {};
@@ -3918,8 +3918,7 @@ var require_alloc = __commonJS({
3918
3918
  await new Promise((res) => setTimeout(res, 10));
3919
3919
  waited += 10;
3920
3920
  if (waited >= XLOCK_TIMEOUT_MS) {
3921
- r._allocLock = true;
3922
- break;
3921
+ throw new Error("ports.claimSlot: \u8FDB\u7A0B\u5185\u5206\u914D\u9501\u7B49\u5F85\u8D85\u65F6\uFF08" + XLOCK_TIMEOUT_MS + "ms\uFF09\uFF0C\u62D2\u7EDD\u5728\u65E0\u9501\u72B6\u6001\u4E0B\u5206\u914D");
3923
3922
  }
3924
3923
  }
3925
3924
  this._xrel = await this._acquireXLock();
@@ -3979,9 +3978,9 @@ var require_alloc = __commonJS({
3979
3978
  await new Promise((res) => setTimeout(res, 25));
3980
3979
  continue;
3981
3980
  }
3982
- return null;
3981
+ throw new Error("ports.claimSlot: \u8DE8\u8FDB\u7A0B\u5206\u914D\u9501\u7B49\u5F85\u8D85\u65F6\uFF08" + XLOCK_TIMEOUT_MS + "ms\uFF09\uFF0C\u62D2\u7EDD\u5728\u65E0\u9501\u72B6\u6001\u4E0B\u5206\u914D");
3983
3982
  }
3984
- return null;
3983
+ throw new Error("ports.claimSlot: \u8DE8\u8FDB\u7A0B\u5206\u914D\u9501\u83B7\u53D6\u5931\u8D25\uFF08" + (e && e.code ? e.code : e) + "\uFF09\uFF0C\u62D2\u7EDD\u5728\u65E0\u9501\u72B6\u6001\u4E0B\u5206\u914D");
3985
3984
  }
3986
3985
  }
3987
3986
  }
@@ -4508,6 +4507,19 @@ var require_collaborators = __commonJS({
4508
4507
  ui: { notify: "notify" }
4509
4508
  };
4510
4509
  var THIN_NAMES = Object.keys(THIN_SPEC);
4510
+ function collaboratorSurface(host, name) {
4511
+ const obj = host[name];
4512
+ if (!obj || typeof obj !== "object") return [];
4513
+ return Object.keys(obj).sort();
4514
+ }
4515
+ function requireThin(host, name, prop) {
4516
+ const obj = host[name];
4517
+ if (!obj || typeof obj[prop] !== "function") {
4518
+ const have = collaboratorSurface(host, name);
4519
+ throw new Error("app/assembly/collaborators: " + name + "." + prop + " \u4E0D\u5B58\u5728\uFF08\u5F53\u524D\u63A5\u53E3\u9762: " + (have.join(", ") || "\u7A7A") + "\uFF09");
4520
+ }
4521
+ return obj[prop];
4522
+ }
4511
4523
  function assertCollaboratorTargets(host) {
4512
4524
  const missing = [];
4513
4525
  for (const name of THIN_NAMES) {
@@ -4516,6 +4528,8 @@ var require_collaborators = __commonJS({
4516
4528
  }
4517
4529
  }
4518
4530
  if (missing.length) throw new Error("app/assembly/collaborators: \u63A5\u53E3\u8868\u6307\u5411\u7F3A\u5931\u65B9\u6CD5: " + missing.join(", "));
4531
+ const empty = THIN_NAMES.filter((n) => collaboratorSurface(host, n).length === 0);
4532
+ if (empty.length) throw new Error("app/assembly/collaborators: \u63A5\u53E3\u9762\u4E3A\u7A7A: " + empty.join(", "));
4519
4533
  }
4520
4534
  function installFieldHelpers(host, state) {
4521
4535
  for (const [suf, field] of ENTRY_FIELDS) {
@@ -4681,7 +4695,7 @@ var require_collaborators = __commonJS({
4681
4695
  if (options && options.validate) assertCollaboratorTargets(host);
4682
4696
  return host;
4683
4697
  }
4684
- module2.exports = { THIN_SPEC, assertCollaboratorTargets, installCollaborators };
4698
+ module2.exports = { THIN_SPEC, assertCollaboratorTargets, installCollaborators, collaboratorSurface, requireThin };
4685
4699
  }
4686
4700
  });
4687
4701
 
@@ -6600,6 +6614,71 @@ var require_file_protect = __commonJS({
6600
6614
  }
6601
6615
  });
6602
6616
 
6617
+ // src/platform/os/liveness.js
6618
+ var require_liveness = __commonJS({
6619
+ "src/platform/os/liveness.js"(exports2, module2) {
6620
+ "use strict";
6621
+ var fs2 = require("node:fs");
6622
+ var pidlook = require_pidlookup();
6623
+ function readPidFile(f) {
6624
+ if (!f) return null;
6625
+ try {
6626
+ const t = fs2.readFileSync(f, "utf8").trim();
6627
+ const n = Number.parseInt(t, 10);
6628
+ return Number.isInteger(n) && n > 0 ? n : null;
6629
+ } catch {
6630
+ return null;
6631
+ }
6632
+ }
6633
+ function anchorsHit(pid, anchors) {
6634
+ if (!Array.isArray(anchors) || !anchors.length) return null;
6635
+ const cmd2 = pidlook.readCmdline(pid);
6636
+ if (!cmd2) return null;
6637
+ return anchors.every((a) => a && cmd2.indexOf(String(a)) !== -1);
6638
+ }
6639
+ function judge(identity) {
6640
+ const q = identity || {};
6641
+ const anchors = Array.isArray(q.anchors) ? q.anchors : [];
6642
+ const evidence = [];
6643
+ let pid = Number.isInteger(q.pid) && q.pid > 0 ? q.pid : null;
6644
+ let via = null;
6645
+ if (!pid) {
6646
+ pid = readPidFile(q.pidFile);
6647
+ if (pid) {
6648
+ via = "pidfile";
6649
+ evidence.push("pid \u6765\u81EA pid \u6587\u4EF6");
6650
+ }
6651
+ }
6652
+ const port = Number.isInteger(q.port) && q.port > 0 ? q.port : null;
6653
+ if (!pid && port) {
6654
+ pid = pidlook.findListeningPid(port);
6655
+ if (pid) {
6656
+ via = "port";
6657
+ evidence.push("pid \u6765\u81EA\u7AEF\u53E3\u76D1\u542C\u8005");
6658
+ }
6659
+ }
6660
+ if (!pid) return { state: "dead", pid: null, via: null, evidence: ["\u65E0 pid \u8BC1\u636E"] };
6661
+ const alive = pidlook.probeAlive(pid);
6662
+ if (alive === "dead") return { state: "dead", pid, via, evidence: evidence.concat(["pid \u5DF2\u9000\u51FA"]) };
6663
+ if (alive === "unknown") return { state: "unknown", pid, via, evidence: evidence.concat(["pid \u5B58\u6D3B\u4E0D\u53EF\u5224\u5B9A"]) };
6664
+ const cmd2 = pidlook.readCmdline(pid);
6665
+ if (anchors.length) {
6666
+ if (!cmd2) return { state: "unknown", pid, via, evidence: evidence.concat(["cmdline \u4E0D\u53EF\u8BFB\uFF0C\u951A\u70B9\u65E0\u6CD5\u6821\u9A8C"]) };
6667
+ const hit = anchorsHit(pid, anchors);
6668
+ if (hit === true) return { state: "ours", pid, via, evidence: evidence.concat(["\u951A\u70B9\u5168\u90E8\u547D\u4E2D"]) };
6669
+ return { state: "foreign", pid, via, evidence: evidence.concat(["\u951A\u70B9\u672A\u5168\u90E8\u547D\u4E2D"]) };
6670
+ }
6671
+ if (cmd2) {
6672
+ const known = pidlook.isDshCmdlineText(cmd2);
6673
+ if (known) return { state: "ours", pid, via, evidence: evidence.concat(["cmdline \u547D\u4E2D dsh"]) };
6674
+ return { state: "foreign", pid, via, evidence: evidence.concat(["cmdline \u975E dsh"]) };
6675
+ }
6676
+ return { state: "unknown", pid, via, evidence: evidence.concat(["cmdline \u4E0D\u53EF\u8BFB\uFF0C\u8EAB\u4EFD\u4E0D\u53EF\u5224\u5B9A"]) };
6677
+ }
6678
+ module2.exports = { judge, readPidFile, anchorsHit };
6679
+ }
6680
+ });
6681
+
6603
6682
  // src/platform/os/spawn.js
6604
6683
  var require_spawn = __commonJS({
6605
6684
  "src/platform/os/spawn.js"(exports2, module2) {
@@ -6639,6 +6718,7 @@ var require_portable = __commonJS({
6639
6718
  "use strict";
6640
6719
  var fs2 = require("node:fs");
6641
6720
  var pidlookup = require_pidlookup();
6721
+ var { judge: judgeIdentity } = require_liveness();
6642
6722
  var spawner = require_spawn();
6643
6723
  var procOS = require_process();
6644
6724
  var OUTCOME = require_outcome();
@@ -6654,10 +6734,7 @@ var require_portable = __commonJS({
6654
6734
  }
6655
6735
  }
6656
6736
  function matchesAnchors(pid, anchors) {
6657
- if (!pid || !Array.isArray(anchors) || !anchors.length) return false;
6658
- const cmd2 = pidlookup.readCmdline(pid);
6659
- if (!cmd2) return false;
6660
- return anchors.some((a) => a && cmd2.indexOf(String(a)) !== -1);
6737
+ return judgeIdentity({ pid, anchors }).state === "ours";
6661
6738
  }
6662
6739
  var portOf = (o) => {
6663
6740
  const p = Number(o && o.port);
@@ -8905,6 +8982,39 @@ var require_registry3 = __commonJS({
8905
8982
  }
8906
8983
  return info;
8907
8984
  }
8985
+ var http2 = require("node:http");
8986
+ var https = require("node:https");
8987
+ function probeOriginHttp(origin, timeoutMs) {
8988
+ return new Promise((resolve) => {
8989
+ let u;
8990
+ try {
8991
+ u = new URL(origin);
8992
+ } catch {
8993
+ return resolve({ ok: false, latencyMs: null, error: "origin \u975E\u6CD5" });
8994
+ }
8995
+ const mod = u.protocol === "https:" ? https : http2;
8996
+ const t0 = Date.now();
8997
+ const req = mod.get(u, (res) => {
8998
+ res.resume();
8999
+ resolve({ ok: res.statusCode < 500, latencyMs: Date.now() - t0, status: res.statusCode });
9000
+ });
9001
+ req.setTimeout(Math.max(200, Number(timeoutMs) || 5e3), () => {
9002
+ try {
9003
+ req.destroy();
9004
+ } catch {
9005
+ }
9006
+ resolve({ ok: false, latencyMs: null, error: "\u8D85\u65F6" });
9007
+ });
9008
+ req.on("error", (e) => resolve({ ok: false, latencyMs: null, error: e.message }));
9009
+ });
9010
+ }
9011
+ function probeRegistry(state, origin, opts) {
9012
+ const o = opts || {};
9013
+ return probeOriginHttp(origin, o.timeoutMs);
9014
+ }
9015
+ function probeOrigin(state, origin, opts) {
9016
+ return probeRegistry(state, origin, opts);
9017
+ }
8908
9018
  module2.exports = {
8909
9019
  platformTag,
8910
9020
  registryOrigins,
@@ -8912,7 +9022,9 @@ var require_registry3 = __commonJS({
8912
9022
  selectRegistry,
8913
9023
  registryOrigin,
8914
9024
  registryInfo,
8915
- setRegistryConfig
9025
+ setRegistryConfig,
9026
+ probeOrigin,
9027
+ probeRegistry
8916
9028
  };
8917
9029
  }
8918
9030
  });
@@ -9858,6 +9970,7 @@ var require_monitor = __commonJS({
9858
9970
  "src/platform/service/monitor.js"(exports2, module2) {
9859
9971
  "use strict";
9860
9972
  var pidlook = require_pidlookup();
9973
+ var { judge: judgeIdentity } = require_liveness();
9861
9974
  var probeModule = require_probe2();
9862
9975
  function isPortListening(host, port, timeoutMs) {
9863
9976
  return probeModule.portListening(host, port, timeoutMs || 1e3);
@@ -9877,10 +9990,7 @@ var require_monitor = __commonJS({
9877
9990
  return { up: pid !== null, pid, isDsh };
9878
9991
  }
9879
9992
  function matchesAnchors(pid, anchors) {
9880
- if (!pid || !Array.isArray(anchors) || !anchors.length) return false;
9881
- const cmd2 = pidlook.readCmdline(pid);
9882
- if (!cmd2) return false;
9883
- return anchors.every((a) => a && cmd2.indexOf(String(a)) !== -1);
9993
+ return judgeIdentity({ pid, anchors }).state === "ours";
9884
9994
  }
9885
9995
  function probeInstance(inst, opts) {
9886
9996
  const o = opts || {};
@@ -10365,6 +10475,58 @@ var require_command = __commonJS({
10365
10475
  }
10366
10476
  });
10367
10477
 
10478
+ // src/shared/guardian.js
10479
+ var require_guardian = __commonJS({
10480
+ "src/shared/guardian.js"(exports2, module2) {
10481
+ "use strict";
10482
+ function shouldGuard(inst) {
10483
+ return !!(inst && inst.guardian === true);
10484
+ }
10485
+ function bumpStartupFailure(w, now, cfg) {
10486
+ const windowMs = cfg && Number(cfg.windowMs) > 0 ? Number(cfg.windowMs) : 6e4;
10487
+ const burst = cfg && Number(cfg.burst) >= 1 ? Number(cfg.burst) : 5;
10488
+ let start = w.start;
10489
+ let count = w.count;
10490
+ if (start === null || start === void 0 || now - start > windowMs) {
10491
+ start = now;
10492
+ count = 1;
10493
+ } else {
10494
+ count += 1;
10495
+ }
10496
+ return { start, count, tripped: count >= burst };
10497
+ }
10498
+ function makeBudget(cfg) {
10499
+ const windowMs = cfg && Number(cfg.windowMs) > 0 ? Number(cfg.windowMs) : 6e4;
10500
+ const burst = cfg && Number(cfg.burst) >= 1 ? Number(cfg.burst) : 5;
10501
+ let state = { start: null, count: 0 };
10502
+ const self = {
10503
+ windowMs,
10504
+ burst,
10505
+ get count() {
10506
+ return state.count;
10507
+ },
10508
+ get tripped() {
10509
+ return state.count >= burst;
10510
+ },
10511
+ note(startupFailure) {
10512
+ if (startupFailure === false || startupFailure == null) {
10513
+ return { tripped: false, count: state.count, halted: false };
10514
+ }
10515
+ const dec = bumpStartupFailure(state, Date.now(), { windowMs, burst });
10516
+ state.start = dec.start;
10517
+ state.count = dec.count;
10518
+ return { tripped: dec.tripped, count: state.count, halted: dec.tripped };
10519
+ },
10520
+ reset() {
10521
+ state = { start: null, count: 0 };
10522
+ }
10523
+ };
10524
+ return self;
10525
+ }
10526
+ module2.exports = { shouldGuard, bumpStartupFailure, makeBudget };
10527
+ }
10528
+ });
10529
+
10368
10530
  // src/app/main/port-rederive.js
10369
10531
  var require_port_rederive = __commonJS({
10370
10532
  "src/app/main/port-rederive.js"(exports2, module2) {
@@ -10456,6 +10618,7 @@ var require_process2 = __commonJS({
10456
10618
  var { LineBuffer } = require_log();
10457
10619
  var native = require_command();
10458
10620
  var BRAND2 = require_brand();
10621
+ var guardian = require_guardian();
10459
10622
  var { findManagedDshPort, applyMainPort } = require_port_rederive();
10460
10623
  var DEPS = /* @__PURE__ */ new WeakMap();
10461
10624
  var HELPERS = [
@@ -10470,7 +10633,9 @@ var require_process2 = __commonJS({
10470
10633
  "SetObservedOnly",
10471
10634
  "StartDeadline",
10472
10635
  "SetStartDeadline",
10636
+ "StartupFailWindowStart",
10473
10637
  "SetStartupFailWindowStart",
10638
+ "StartupFailCount",
10474
10639
  "SetStartupFailCount",
10475
10640
  "SetLastFailure",
10476
10641
  "SetLastRestartAt",
@@ -10501,6 +10666,10 @@ var require_process2 = __commonJS({
10501
10666
  beginRestart: (reason, opts) => host._beginRestart(reason, opts),
10502
10667
  writeMainOwner: (pid, port) => host._writeMainOwner(pid, port)
10503
10668
  };
10669
+ const unresolved = HELPERS.filter((n) => typeof host["_m" + n] !== "function");
10670
+ if (unresolved.length) {
10671
+ throw new Error("app/main/process: HELPERS \u6307\u5411\u4E0D\u5B58\u5728\u7684\u65B9\u6CD5: " + unresolved.map((n) => "_m" + n).join(", "));
10672
+ }
10504
10673
  for (const n of HELPERS) d["m" + n] = (...a) => host["_m" + n](...a);
10505
10674
  DEPS.set(host, d);
10506
10675
  }
@@ -10688,13 +10857,31 @@ var require_process2 = __commonJS({
10688
10857
  d.logger().warn("restart triggered: " + reason + (startupFailure ? "\uFF08\u542F\u52A8\u7A97\u53E3\u5185\u9000\u51FA\uFF0C\u8BA1\u4E00\u6B21\u542F\u52A8\u5931\u8D25\uFF09" : "\uFF08\u6B63\u5E38\u91CD\u542F\uFF09"));
10689
10858
  d.tokenService().clear("main");
10690
10859
  if (!manual) d.mSetRestartCount(d.mRestartCount() + 1);
10691
- const throttle = null;
10692
- if (throttle && throttle.failed) {
10860
+ let throttle = null;
10861
+ if (startupFailure) {
10862
+ throttle = guardian.bumpStartupFailure(
10863
+ { start: d.mStartupFailWindowStart(), count: d.mStartupFailCount() },
10864
+ Date.now(),
10865
+ {
10866
+ windowMs: d.config().startupFailWindowMs || 6e4,
10867
+ burst: d.config().startupFailBurst || 5
10868
+ }
10869
+ );
10870
+ d.mSetStartupFailWindowStart(throttle.start);
10871
+ d.mSetStartupFailCount(throttle.count);
10872
+ }
10873
+ if (throttle && throttle.tripped) {
10874
+ d.state().setPhase("FAILED");
10875
+ d.mSetStartDeadline(null);
10693
10876
  d.mSetRestartAt(null);
10694
- } else {
10695
- d.state().setPhase("STARTING");
10696
- d.mSetRestartAt(Date.now() + d.config().portReleaseWaitMs);
10877
+ d.writeCrashHalted(true);
10878
+ d.events().append("main_startup_failed", { reason, count: throttle.count });
10879
+ d.logger().error("\u4E3B\u8FDB\u7A0B\u542F\u52A8\u53CD\u590D\u5931\u8D25\uFF08" + throttle.count + " \u6B21\uFF09\uFF0C\u5DF2\u505C\u6B62\u81EA\u52A8\u91CD\u542F");
10880
+ d.state().write();
10881
+ return;
10697
10882
  }
10883
+ d.state().setPhase("STARTING");
10884
+ d.mSetRestartAt(Date.now() + d.config().portReleaseWaitMs);
10698
10885
  d.mSetStartDeadline(null);
10699
10886
  const child = d.mChild();
10700
10887
  if (child && child.exitCode === null) d.main().killSequence(child);
@@ -12626,7 +12813,7 @@ var require_env_catalog = __commonJS({
12626
12813
  "src/platform/service/env-catalog.js"(exports2, module2) {
12627
12814
  "use strict";
12628
12815
  var runtime = require_runtime();
12629
- var SHARED = require_shared_constants2();
12816
+ var SHARED2 = require_shared_constants2();
12630
12817
  var ex2 = require_exec();
12631
12818
  var BRAND2 = require_brand();
12632
12819
  function whichVersion(bin, args) {
@@ -12664,7 +12851,7 @@ var require_env_catalog = __commonJS({
12664
12851
  if (hit && Date.now() - hit.at < CACHE_TTL) return Promise.resolve(hit.v);
12665
12852
  return whichVersionAsync(bin, args).then((v) => cacheSet(key, v));
12666
12853
  }
12667
- var MIN_NODE_DEFAULT = SHARED.runtime.minNode;
12854
+ var MIN_NODE_DEFAULT = SHARED2.runtime.minNode;
12668
12855
  var _runtimeMetaCache = null;
12669
12856
  var _runtimeMetaAt = 0;
12670
12857
  function runtimeMeta() {
@@ -16241,58 +16428,6 @@ var require_instance_lifecycle = __commonJS({
16241
16428
  }
16242
16429
  });
16243
16430
 
16244
- // src/shared/guardian.js
16245
- var require_guardian = __commonJS({
16246
- "src/shared/guardian.js"(exports2, module2) {
16247
- "use strict";
16248
- function shouldGuard(inst) {
16249
- return !!(inst && inst.guardian === true);
16250
- }
16251
- function bumpStartupFailure(w, now, cfg) {
16252
- const windowMs = cfg && Number(cfg.windowMs) > 0 ? Number(cfg.windowMs) : 6e4;
16253
- const burst = cfg && Number(cfg.burst) >= 1 ? Number(cfg.burst) : 5;
16254
- let start = w.start;
16255
- let count = w.count;
16256
- if (start === null || start === void 0 || now - start > windowMs) {
16257
- start = now;
16258
- count = 1;
16259
- } else {
16260
- count += 1;
16261
- }
16262
- return { start, count, tripped: count >= burst };
16263
- }
16264
- function makeBudget(cfg) {
16265
- const windowMs = cfg && Number(cfg.windowMs) > 0 ? Number(cfg.windowMs) : 6e4;
16266
- const burst = cfg && Number(cfg.burst) >= 1 ? Number(cfg.burst) : 5;
16267
- let state = { start: null, count: 0 };
16268
- const self = {
16269
- windowMs,
16270
- burst,
16271
- get count() {
16272
- return state.count;
16273
- },
16274
- get tripped() {
16275
- return state.count >= burst;
16276
- },
16277
- note(startupFailure) {
16278
- if (startupFailure === false || startupFailure == null) {
16279
- return { tripped: false, count: state.count, halted: false };
16280
- }
16281
- const dec = bumpStartupFailure(state, Date.now(), { windowMs, burst });
16282
- state.start = dec.start;
16283
- state.count = dec.count;
16284
- return { tripped: dec.tripped, count: state.count, halted: dec.tripped };
16285
- },
16286
- reset() {
16287
- state = { start: null, count: 0 };
16288
- }
16289
- };
16290
- return self;
16291
- }
16292
- module2.exports = { shouldGuard, bumpStartupFailure, makeBudget };
16293
- }
16294
- });
16295
-
16296
16431
  // src/domains/router/providers/restart.js
16297
16432
  var require_restart = __commonJS({
16298
16433
  "src/domains/router/providers/restart.js"(exports2, module2) {
@@ -16442,9 +16577,9 @@ var require_restart = __commonJS({
16442
16577
  }
16443
16578
  });
16444
16579
 
16445
- // src/app/control/process-lifecycle.js
16580
+ // src/platform/os/process-lifecycle.js
16446
16581
  var require_process_lifecycle = __commonJS({
16447
- "src/app/control/process-lifecycle.js"(exports2, module2) {
16582
+ "src/platform/os/process-lifecycle.js"(exports2, module2) {
16448
16583
  "use strict";
16449
16584
  var procOS = require_process();
16450
16585
  var pidlook = require_pidlookup();
@@ -24221,7 +24356,9 @@ var require_pm_client = __commonJS({
24221
24356
  const port = Number(j.port);
24222
24357
  if (!Number.isInteger(port) || port <= 0 || port > 65535) return null;
24223
24358
  if (!pidAlive2(Number(j.pid))) return null;
24224
- return { port, host: typeof j.host === "string" && j.host ? j.host : HOST };
24359
+ const token = typeof j.token === "string" ? j.token : "";
24360
+ if (!token) return null;
24361
+ return { port, host: typeof j.host === "string" && j.host ? j.host : HOST, token };
24225
24362
  }
24226
24363
  function post(route, payload) {
24227
24364
  const ep = endpoint();
@@ -24246,7 +24383,7 @@ var require_pm_client = __commonJS({
24246
24383
  port: ep.port,
24247
24384
  path: route,
24248
24385
  method: "POST",
24249
- headers: { "content-type": "application/json", "content-length": Buffer.byteLength(body) },
24386
+ headers: { "content-type": "application/json", "content-length": Buffer.byteLength(body), "x-lobox-mgmt-token": ep.token },
24250
24387
  timeout: TIMEOUT_MS
24251
24388
  },
24252
24389
  (res) => {
@@ -25121,7 +25258,7 @@ var require_upgrade2 = __commonJS({
25121
25258
  host._activeTaskId = null;
25122
25259
  return { ok: true, result: "up-to-date", from: oldV, to: target };
25123
25260
  }
25124
- function finishStopped(host, oldV, target, task) {
25261
+ async function finishStopped(host, oldV, target, task) {
25125
25262
  host.upgradeState = "done";
25126
25263
  host.upgradeFinishedAt = (/* @__PURE__ */ new Date()).toISOString();
25127
25264
  log(host, "DSH \u671F\u671B\u72B6\u6001\u4E3A stopped\uFF1B\u4E0B\u6B21 start \u5C06\u4F7F\u7528\u65B0\u7248\u672C\u3002");
@@ -25131,7 +25268,7 @@ var require_upgrade2 = __commonJS({
25131
25268
  host.tasks.succeed(task.id);
25132
25269
  }
25133
25270
  host._activeTaskId = null;
25134
- if (host.hooks.resumeAfterUpgrade) host.hooks.resumeAfterUpgrade();
25271
+ if (host.hooks.resumeAfterUpgrade) await host.hooks.resumeAfterUpgrade();
25135
25272
  return { ok: true, result: "installed", from: oldV, to: target };
25136
25273
  }
25137
25274
  function finishVerified(host, oldV, target, task) {
@@ -25152,7 +25289,7 @@ var require_upgrade2 = __commonJS({
25152
25289
  markStep(host, task, "\u62C9\u8D77\u5E76\u9A8C\u8BC1");
25153
25290
  log(host, "\u91CD\u65B0\u62C9\u8D77 DSH\uFF0C\u7B49\u5F85\u5065\u5EB7\u9A8C\u8BC1\u2026");
25154
25291
  taskLog(host, task, "\u91CD\u65B0\u62C9\u8D77 DSH\uFF0C\u7B49\u5F85\u5065\u5EB7\u9A8C\u8BC1\u2026");
25155
- if (host.hooks.resumeAfterUpgrade) host.hooks.resumeAfterUpgrade();
25292
+ if (host.hooks.resumeAfterUpgrade) await host.hooks.resumeAfterUpgrade();
25156
25293
  const port = host._targetPort();
25157
25294
  if (!port) {
25158
25295
  const msg = "\u65E0\u6CD5\u786E\u5B9A\u539F\u751F DSH \u7AEF\u53E3\uFF08healthUrl \u7F3A\u5931\uFF09";
@@ -25208,7 +25345,7 @@ var require_upgrade2 = __commonJS({
25208
25345
  } catch (e2) {
25209
25346
  tlog("manifest \u66F4\u65B0\u5931\u8D25: " + e2.message);
25210
25347
  }
25211
- if (host.hooks.resumeAfterUpgrade) host.hooks.resumeAfterUpgrade();
25348
+ if (host.hooks.resumeAfterUpgrade) await host.hooks.resumeAfterUpgrade();
25212
25349
  const port = host._targetPort();
25213
25350
  if (port) {
25214
25351
  const healthy = await host._waitNativeHealthy(port, host._mainUnit(), 6e4);
@@ -25276,7 +25413,7 @@ var require_upgrade2 = __commonJS({
25276
25413
  if (taskId && host.tasks) host.tasks.fail(taskId, err.message, { meta: { rolledBack: false } });
25277
25414
  }
25278
25415
  if (host.hooks.desiredRunning && host.hooks.desiredRunning()) log(host, "\u6062\u590D\u542F\u52A8 DSH\uFF08\u5F53\u524D\u78C1\u76D8\u7248\u672C\uFF09\u3002");
25279
- if (host.hooks.resumeAfterUpgrade) host.hooks.resumeAfterUpgrade();
25416
+ if (host.hooks.resumeAfterUpgrade) await host.hooks.resumeAfterUpgrade();
25280
25417
  host._activeTaskId = null;
25281
25418
  }
25282
25419
  async function upgrade(host, requestedVersion) {
@@ -25791,7 +25928,25 @@ var require_domains = __commonJS({
25791
25928
  isDshActive: () => ["STARTING", "RUNNING"].includes(host._mPhase()),
25792
25929
  desiredRunning: () => host._mDesired() === "running",
25793
25930
  verifyDeadlineMs: () => Math.max(2 * host.config.startsecs * 1e3, 12e4),
25794
- notify: (t, b) => host.notify(t, b)
25931
+ notify: (t, b) => host.notify(t, b),
25932
+ stopForUpgrade: async () => {
25933
+ const want = host._mDesired();
25934
+ if (want !== "stopped") host.setDesired("stopped");
25935
+ host.stopProcess("upgrade-stop");
25936
+ const deadline = Date.now() + Math.max(2 * host.config.startsecs * 1e3, 12e4);
25937
+ while (Date.now() < deadline) {
25938
+ const child = host._mChild();
25939
+ const alive = !!child && child.exitCode === null;
25940
+ if (!alive) return { ok: true, stopped: true };
25941
+ await new Promise((r) => setTimeout(r, 250));
25942
+ }
25943
+ return { ok: false, error: "upgrade-stop-timeout" };
25944
+ },
25945
+ resumeAfterUpgrade: async () => {
25946
+ if (host._mDesired() !== "running") host.setDesired("running");
25947
+ await host.startProcess();
25948
+ return { ok: true };
25949
+ }
25795
25950
  }
25796
25951
  });
25797
25952
  host._registerFixedPorts();
@@ -26085,10 +26240,7 @@ var require_lifecycle3 = __commonJS({
26085
26240
  return send(200, { sessionState: sup.sessionState ? sup.sessionState() : "unknown" });
26086
26241
  }
26087
26242
  if (req.method === "POST" && pathname === "/session/stop") {
26088
- if (!originAllowed(req)) {
26089
- req.resume();
26090
- return send(403, { ok: false, error: "cross-origin request rejected" });
26091
- }
26243
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26092
26244
  req.resume();
26093
26245
  return Promise.resolve(sup.shutdownAll()).then((r) => send(r && r.ok === false ? 400 : 200, r || { ok: true })).catch((e) => send(500, { ok: false, error: e.message }));
26094
26246
  }
@@ -26108,10 +26260,7 @@ var require_lifecycle3 = __commonJS({
26108
26260
  return lc ? send(200, lc.snapshot()) : send(404, { error: "\u6A21\u5757\u672A\u6CE8\u518C: " + id });
26109
26261
  }
26110
26262
  if (req.method === "POST" && action) {
26111
- if (!originAllowed(req)) {
26112
- req.resume();
26113
- return send(403, { ok: false, error: "cross-origin request rejected" });
26114
- }
26263
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26115
26264
  const lc = lm.get(id);
26116
26265
  if (!lc) return send(404, { error: "\u6A21\u5757\u672A\u6CE8\u518C: " + id });
26117
26266
  if (id === "dsh" && sup && (action === "start" || action === "stop" || action === "restart")) {
@@ -26213,18 +26362,12 @@ var require_native = __commonJS({
26213
26362
  });
26214
26363
  }
26215
26364
  if (req.method === "POST" && pathname === "/native/check-update") {
26216
- if (!originAllowed(req)) {
26217
- req.resume();
26218
- return send(403, { ok: false, error: "cross-origin request rejected" });
26219
- }
26365
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26220
26366
  sup.nativeManager.checkUpdate().then((r) => send(200, { ok: true, ...r })).catch((e) => send(500, { ok: false, error: e.message }));
26221
26367
  return;
26222
26368
  }
26223
26369
  if (req.method === "POST" && pathname === "/native/install") {
26224
- if (!originAllowed(req)) {
26225
- req.resume();
26226
- return send(403, { ok: false, error: "cross-origin request rejected" });
26227
- }
26370
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26228
26371
  collectBody(req, res, 1024, (body) => {
26229
26372
  let version = null;
26230
26373
  try {
@@ -26239,10 +26382,7 @@ var require_native = __commonJS({
26239
26382
  return;
26240
26383
  }
26241
26384
  if (req.method === "POST" && pathname === "/native/upgrade") {
26242
- if (!originAllowed(req)) {
26243
- req.resume();
26244
- return send(403, { ok: false, error: "cross-origin request rejected" });
26245
- }
26385
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26246
26386
  collectBody(req, res, 4096, (body) => {
26247
26387
  let requested = null;
26248
26388
  try {
@@ -26260,19 +26400,13 @@ var require_native = __commonJS({
26260
26400
  return;
26261
26401
  }
26262
26402
  if (req.method === "POST" && pathname === "/native/uninstall") {
26263
- if (!originAllowed(req)) {
26264
- req.resume();
26265
- return send(403, { ok: false, error: "cross-origin request rejected" });
26266
- }
26403
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26267
26404
  const r = sup.nativeManager.startUninstall();
26268
26405
  if (r && r.ok === false) return send(400, r);
26269
26406
  return send(202, { ok: true, accepted: true, state: "uninstalling" });
26270
26407
  }
26271
26408
  if (req.method === "POST" && pathname === "/native/settings") {
26272
- if (!originAllowed(req)) {
26273
- req.resume();
26274
- return send(403, { ok: false, error: "cross-origin request rejected" });
26275
- }
26409
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26276
26410
  collectBody(req, res, 4096, (body) => {
26277
26411
  try {
26278
26412
  const j = body ? JSON.parse(body) : {};
@@ -26338,10 +26472,7 @@ var require_guard = __commonJS({
26338
26472
  return send(200, sup.autostartStatus());
26339
26473
  }
26340
26474
  if (req.method === "POST" && pathname === "/autostart") {
26341
- if (!originAllowed(req)) {
26342
- req.resume();
26343
- return send(403, { ok: false, error: "cross-origin request rejected" });
26344
- }
26475
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26345
26476
  collectBody(req, res, 1024, (body) => {
26346
26477
  let enabled = null;
26347
26478
  try {
@@ -26359,10 +26490,7 @@ var require_guard = __commonJS({
26359
26490
  return send(200, sup.lanPanelStatus());
26360
26491
  }
26361
26492
  if (req.method === "POST" && pathname === "/settings/lan") {
26362
- if (!originAllowed(req)) {
26363
- req.resume();
26364
- return send(403, { ok: false, error: "cross-origin request rejected" });
26365
- }
26493
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26366
26494
  collectBody(req, res, 1024, (body) => {
26367
26495
  let enabled = null;
26368
26496
  try {
@@ -26380,10 +26508,7 @@ var require_guard = __commonJS({
26380
26508
  return send(200, sup.accessKeyStatus());
26381
26509
  }
26382
26510
  if (req.method === "POST" && pathname === "/settings/access-key") {
26383
- if (!originAllowed(req)) {
26384
- req.resume();
26385
- return send(403, { ok: false, error: "cross-origin request rejected" });
26386
- }
26511
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26387
26512
  collectBody(req, res, 4096, (body) => {
26388
26513
  let key = null;
26389
26514
  try {
@@ -26402,10 +26527,7 @@ var require_guard = __commonJS({
26402
26527
  return send(200, sup.closeActionStatus());
26403
26528
  }
26404
26529
  if (req.method === "POST" && pathname === "/settings/close-action") {
26405
- if (!originAllowed(req)) {
26406
- req.resume();
26407
- return send(403, {});
26408
- }
26530
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26409
26531
  collectBody(req, res, 1024, (body) => {
26410
26532
  let v = null;
26411
26533
  try {
@@ -26423,10 +26545,7 @@ var require_guard = __commonJS({
26423
26545
  return send(200, sup.externalBrowserStatus());
26424
26546
  }
26425
26547
  if (req.method === "POST" && pathname === "/settings/external-browser") {
26426
- if (!originAllowed(req)) {
26427
- req.resume();
26428
- return send(403, {});
26429
- }
26548
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26430
26549
  collectBody(req, res, 2048, (body) => {
26431
26550
  let id = null;
26432
26551
  let given = false;
@@ -26445,10 +26564,7 @@ var require_guard = __commonJS({
26445
26564
  return;
26446
26565
  }
26447
26566
  if (req.method === "POST" && pathname === "/shutdown") {
26448
- if (!originAllowed(req)) {
26449
- req.resume();
26450
- return send(403, {});
26451
- }
26567
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26452
26568
  req.resume();
26453
26569
  Promise.resolve(sup.shutdownAll()).then((r) => {
26454
26570
  try {
@@ -26460,10 +26576,7 @@ var require_guard = __commonJS({
26460
26576
  return;
26461
26577
  }
26462
26578
  if (req.method === "GET" && pathname === "/self-update/status") {
26463
- if (!originAllowed(req)) {
26464
- req.resume();
26465
- return send(403, {});
26466
- }
26579
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26467
26580
  Promise.resolve(sup.guardSelfUpdateStatus()).then((r) => send(r.ok ? 200 : 400, r));
26468
26581
  return;
26469
26582
  }
@@ -26486,35 +26599,23 @@ var require_guard = __commonJS({
26486
26599
  });
26487
26600
  }
26488
26601
  if (req.method === "GET" && pathname === "/env/dsh") {
26489
- if (!originAllowed(req)) {
26490
- req.resume();
26491
- return send(403, {});
26492
- }
26602
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26493
26603
  return send(200, sup.dshenvStatus());
26494
26604
  }
26495
26605
  if (req.method === "GET" && pathname === "/env/status") {
26496
- if (!originAllowed(req)) {
26497
- req.resume();
26498
- return send(403, {});
26499
- }
26606
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26500
26607
  return Promise.resolve(sup.envStatus()).then((r) => send(200, r)).catch((e) => send(500, { ok: false, error: e.message }));
26501
26608
  }
26502
26609
  if (req.method === "GET" && pathname === "/env/node-lts") {
26503
26610
  return sup.nodeLtsStatus().then((r) => send(200, r)).catch((e) => send(500, { ok: false, error: e.message }));
26504
26611
  }
26505
26612
  if (req.method === "GET" && pathname === "/env/environment") {
26506
- if (!originAllowed(req)) {
26507
- req.resume();
26508
- return send(403, { ok: false, error: "cross-origin request rejected" });
26509
- }
26613
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26510
26614
  const force = /[?&]force=1/.test(String(req.url || ""));
26511
26615
  return Promise.resolve(force ? environment.refresh({ persist: true, force: true }) : environment.form()).then((r) => send(200, r)).catch((e) => send(500, { ok: false, error: "\u73AF\u5883\u8868\u5355\u88C5\u914D\u5931\u8D25\uFF1A" + (e && e.message || e) }));
26512
26616
  }
26513
26617
  if (req.method === "GET" && pathname === "/env/environment/last") {
26514
- if (!originAllowed(req)) {
26515
- req.resume();
26516
- return send(403, { ok: false, error: "cross-origin request rejected" });
26517
- }
26618
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26518
26619
  return send(200, environment.lastSnapshot());
26519
26620
  }
26520
26621
  if (req.method === "POST" && pathname === "/env/open-url") {
@@ -26522,10 +26623,7 @@ var require_guard = __commonJS({
26522
26623
  req.resume();
26523
26624
  return send(403, { ok: false, error: "\u4EC5\u5185\u6838\u6240\u5728\u673A\u5668\u53EF\u8BF7\u5185\u6838\u8C03\u8D77\u6D4F\u89C8\u5668\uFF0C\u8BF7\u590D\u5236\u6216\u81EA\u884C\u6253\u5F00\u8BE5\u5730\u5740" });
26524
26625
  }
26525
- if (!originAllowed(req)) {
26526
- req.resume();
26527
- return send(403, { ok: false, error: "cross-origin request rejected" });
26528
- }
26626
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26529
26627
  collectBody(req, res, 4096, (body) => {
26530
26628
  let url = null;
26531
26629
  try {
@@ -26567,10 +26665,7 @@ var require_router4 = __commonJS({
26567
26665
  return Promise.resolve(sup.routerStatusView()).then((r) => send(200, r)).catch((e) => send(500, { ok: false, running: false, error: e && e.message || String(e) }));
26568
26666
  }
26569
26667
  if (req.method === "POST" && pathname.startsWith("/router/")) {
26570
- if (!originAllowed(req)) {
26571
- req.resume();
26572
- return send(403, { ok: false, error: "cross-origin request rejected" });
26573
- }
26668
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26574
26669
  const action = pathname.slice("/router/".length);
26575
26670
  req.resume();
26576
26671
  if (action === "start") {
@@ -26584,10 +26679,7 @@ var require_router4 = __commonJS({
26584
26679
  return Promise.resolve(sup.routerProviders()).then((r) => send(200, r)).catch((e) => send(500, { ok: false, error: e.message }));
26585
26680
  }
26586
26681
  if (req.method === "POST" && pathname === "/router/providers/add") {
26587
- if (!originAllowed(req)) {
26588
- req.resume();
26589
- return send(403, {});
26590
- }
26682
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26591
26683
  collectBody(req, res, 65536, (body) => {
26592
26684
  let j = {};
26593
26685
  try {
@@ -26603,18 +26695,12 @@ var require_router4 = __commonJS({
26603
26695
  return;
26604
26696
  }
26605
26697
  if (req.method === "POST" && pathname === "/router/proxy/login/start") {
26606
- if (!originAllowed(req)) {
26607
- req.resume();
26608
- return send(403, {});
26609
- }
26698
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26610
26699
  Promise.resolve(sup.routerApi().commandcodeLoginStart()).then((r) => send(r.ok ? 200 : 400, r)).catch((e) => send(500, { ok: false, error: e && e.message || String(e) }));
26611
26700
  return;
26612
26701
  }
26613
26702
  if (req.method === "POST" && pathname === "/router/proxy/login/wait") {
26614
- if (!originAllowed(req)) {
26615
- req.resume();
26616
- return send(403, {});
26617
- }
26703
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26618
26704
  collectBody(req, res, 4096, (body) => {
26619
26705
  const j = {};
26620
26706
  try {
@@ -26628,18 +26714,12 @@ var require_router4 = __commonJS({
26628
26714
  return;
26629
26715
  }
26630
26716
  if (req.method === "POST" && pathname === "/router/proxy/update/check") {
26631
- if (!originAllowed(req)) {
26632
- req.resume();
26633
- return send(403, {});
26634
- }
26717
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26635
26718
  Promise.resolve(sup.routerApi().refreshProxyUpdateInfo(true)).then((r) => send(200, { ok: true, versions: r })).catch((e) => send(500, { ok: false, error: e.message }));
26636
26719
  return;
26637
26720
  }
26638
26721
  if (req.method === "POST" && pathname === "/router/proxy/update/apply") {
26639
- if (!originAllowed(req)) {
26640
- req.resume();
26641
- return send(403, {});
26642
- }
26722
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26643
26723
  collectBody(req, res, 4096, (body) => {
26644
26724
  try {
26645
26725
  const j = body ? JSON.parse(body) : {};
@@ -26655,10 +26735,7 @@ var require_router4 = __commonJS({
26655
26735
  return Promise.resolve(sup.routerApi().proxyUpdateStatus(u.searchParams.get("appId") || "")).then((r) => send(200, r)).catch((e) => send(500, { ok: false, error: e.message }));
26656
26736
  }
26657
26737
  if (req.method === "POST" && pathname === "/router/providers/proxy/key") {
26658
- if (!originAllowed(req)) {
26659
- req.resume();
26660
- return send(403, {});
26661
- }
26738
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26662
26739
  collectBody(req, res, 65536, (body) => {
26663
26740
  try {
26664
26741
  const j = JSON.parse(body);
@@ -26670,10 +26747,7 @@ var require_router4 = __commonJS({
26670
26747
  return;
26671
26748
  }
26672
26749
  if (req.method === "POST" && pathname === "/router/providers/proxy/select") {
26673
- if (!originAllowed(req)) {
26674
- req.resume();
26675
- return send(403, {});
26676
- }
26750
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26677
26751
  collectBody(req, res, 4096, (body) => {
26678
26752
  try {
26679
26753
  const j = JSON.parse(body);
@@ -26685,10 +26759,7 @@ var require_router4 = __commonJS({
26685
26759
  return;
26686
26760
  }
26687
26761
  if (req.method === "POST" && pathname === "/router/providers/proxy/key/remove") {
26688
- if (!originAllowed(req)) {
26689
- req.resume();
26690
- return send(403, {});
26691
- }
26762
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26692
26763
  collectBody(req, res, 4096, (body) => {
26693
26764
  try {
26694
26765
  const j = JSON.parse(body);
@@ -26700,10 +26771,7 @@ var require_router4 = __commonJS({
26700
26771
  return;
26701
26772
  }
26702
26773
  if (req.method === "POST" && pathname === "/router/providers/keys/set") {
26703
- if (!originAllowed(req)) {
26704
- req.resume();
26705
- return send(403, {});
26706
- }
26774
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26707
26775
  collectBody(req, res, 65536, (body) => {
26708
26776
  try {
26709
26777
  const j = JSON.parse(body);
@@ -26716,10 +26784,7 @@ var require_router4 = __commonJS({
26716
26784
  return;
26717
26785
  }
26718
26786
  if (req.method === "POST" && pathname === "/router/providers/remove") {
26719
- if (!originAllowed(req)) {
26720
- req.resume();
26721
- return send(403, {});
26722
- }
26787
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26723
26788
  collectBody(req, res, 4096, (body) => {
26724
26789
  try {
26725
26790
  const j = body ? JSON.parse(body) : {};
@@ -26731,10 +26796,7 @@ var require_router4 = __commonJS({
26731
26796
  return;
26732
26797
  }
26733
26798
  if (req.method === "POST" && pathname === "/router/providers/key/use") {
26734
- if (!originAllowed(req)) {
26735
- req.resume();
26736
- return send(403, {});
26737
- }
26799
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26738
26800
  collectBody(req, res, 4096, (body) => {
26739
26801
  try {
26740
26802
  const j = body ? JSON.parse(body) : {};
@@ -26747,10 +26809,7 @@ var require_router4 = __commonJS({
26747
26809
  return;
26748
26810
  }
26749
26811
  if (req.method === "POST" && pathname === "/router/providers/account/discard") {
26750
- if (!originAllowed(req)) {
26751
- req.resume();
26752
- return send(403, {});
26753
- }
26812
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26754
26813
  collectBody(req, res, 4096, (body) => {
26755
26814
  try {
26756
26815
  const j = JSON.parse(body);
@@ -26762,10 +26821,7 @@ var require_router4 = __commonJS({
26762
26821
  return;
26763
26822
  }
26764
26823
  if (req.method === "POST" && pathname === "/router/providers/refresh") {
26765
- if (!originAllowed(req)) {
26766
- req.resume();
26767
- return send(403, {});
26768
- }
26824
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26769
26825
  collectBody(req, res, 4096, (body) => {
26770
26826
  try {
26771
26827
  const j = body ? JSON.parse(body) : {};
@@ -26778,10 +26834,7 @@ var require_router4 = __commonJS({
26778
26834
  return;
26779
26835
  }
26780
26836
  if (req.method === "POST" && pathname === "/router/providers/activate") {
26781
- if (!originAllowed(req)) {
26782
- req.resume();
26783
- return send(403, {});
26784
- }
26837
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26785
26838
  collectBody(req, res, 4096, (body) => {
26786
26839
  try {
26787
26840
  const j = body ? JSON.parse(body) : {};
@@ -26794,10 +26847,7 @@ var require_router4 = __commonJS({
26794
26847
  return;
26795
26848
  }
26796
26849
  if (req.method === "POST" && pathname === "/router/providers/deactivate") {
26797
- if (!originAllowed(req)) {
26798
- req.resume();
26799
- return send(403, {});
26800
- }
26850
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26801
26851
  collectBody(req, res, 4096, (body) => {
26802
26852
  try {
26803
26853
  const j = body ? JSON.parse(body) : {};
@@ -26844,10 +26894,7 @@ var require_plugins = __commonJS({
26844
26894
  return send(200, sup.pluginManager.installStatus(u.searchParams.get("job")));
26845
26895
  }
26846
26896
  if (req.method === "POST" && pathname.startsWith("/plugins/")) {
26847
- if (!originAllowed(req)) {
26848
- req.resume();
26849
- return send(403, { ok: false, error: "cross-origin request rejected" });
26850
- }
26897
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26851
26898
  const action = pathname.slice("/plugins/".length);
26852
26899
  collectBody(req, res, 65536, (body) => {
26853
26900
  let name = null;
@@ -26920,10 +26967,7 @@ var require_dist = __commonJS({
26920
26967
  return;
26921
26968
  }
26922
26969
  if (req.method === "POST" && pathname === "/dist/registry/set") {
26923
- if (!originAllowed(req)) {
26924
- req.resume();
26925
- return send(403, {});
26926
- }
26970
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26927
26971
  collectBody(req, res, 8192, (body) => {
26928
26972
  let j = {};
26929
26973
  try {
@@ -26939,18 +26983,12 @@ var require_dist = __commonJS({
26939
26983
  return;
26940
26984
  }
26941
26985
  if (req.method === "POST" && pathname === "/dist/registry/refresh") {
26942
- if (!originAllowed(req)) {
26943
- req.resume();
26944
- return send(403, {});
26945
- }
26986
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26946
26987
  sup.dist.selectRegistry(true).then(() => sup.dist.registryInfo()).then((r) => send(200, { ok: true, ...r })).catch((e) => send(500, { ok: false, error: e.message }));
26947
26988
  return;
26948
26989
  }
26949
26990
  if (req.method === "POST" && pathname === "/dist/registry/probe") {
26950
- if (!originAllowed(req)) {
26951
- req.resume();
26952
- return send(403, {});
26953
- }
26991
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
26954
26992
  return collectBody(req, res, 4096, (body) => {
26955
26993
  let j = {};
26956
26994
  try {
@@ -27267,10 +27305,7 @@ var require_instances = __commonJS({
27267
27305
  return render();
27268
27306
  }
27269
27307
  if (req.method === "POST" && pathname.startsWith("/instances/")) {
27270
- if (!originAllowed(req)) {
27271
- req.resume();
27272
- return send(403, {});
27273
- }
27308
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
27274
27309
  const act = pathname.slice("/instances/".length);
27275
27310
  collectBody(req, res, 65536, (body) => {
27276
27311
  try {
@@ -27349,10 +27384,7 @@ var require_relay = __commonJS({
27349
27384
  return Promise.resolve(sup.listLan()).then((r) => send(200, r)).catch((e) => send(500, { ok: false, error: e.message }));
27350
27385
  }
27351
27386
  if (req.method === "POST" && pathname.startsWith("/remote/")) {
27352
- if (!originAllowed(req)) {
27353
- req.resume();
27354
- return send(403, {});
27355
- }
27387
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
27356
27388
  const act = pathname.slice("/remote/".length);
27357
27389
  collectBody(req, res, 65536, (body) => {
27358
27390
  let j = {};
@@ -27412,10 +27444,7 @@ var require_shell2 = __commonJS({
27412
27444
  }
27413
27445
  }
27414
27446
  if (req.method === "POST" && pathname === "/shell/health") {
27415
- if (!originAllowed(req)) {
27416
- req.resume();
27417
- return send(403, {});
27418
- }
27447
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
27419
27448
  return collectBody(req, res, 8192, (body) => {
27420
27449
  let j = {};
27421
27450
  try {
@@ -27430,10 +27459,7 @@ var require_shell2 = __commonJS({
27430
27459
  });
27431
27460
  }
27432
27461
  if (req.method === "POST" && pathname === "/shell/check-update") {
27433
- if (!originAllowed(req)) {
27434
- req.resume();
27435
- return send(403, {});
27436
- }
27462
+ if (!originAllowed(req)) return ctx.rejectCrossOrigin(ctx);
27437
27463
  req.resume();
27438
27464
  return Promise.resolve(shell.checkUpdate(sup.dist, { authoritative: true })).then((r) => {
27439
27465
  if (sup.events) {
@@ -27449,6 +27475,107 @@ var require_shell2 = __commonJS({
27449
27475
  }
27450
27476
  });
27451
27477
 
27478
+ // src/api/contract.js
27479
+ var require_contract = __commonJS({
27480
+ "src/api/contract.js"(exports2, module2) {
27481
+ "use strict";
27482
+ var CATEGORIES = ["public", "operational", "internal", "deprecated"];
27483
+ var SURFACE = [
27484
+ { path: "/status", methods: ["GET"], domain: "lifecycle", category: "public", consumers: ["UI(polling)", "CLI(status)"], note: "\u72B6\u6001\u6458\u8981" },
27485
+ { path: "/events", methods: ["GET"], domain: "lifecycle", category: "public", consumers: ["UI(timeline)"], note: "\u589E\u91CF\u4E8B\u4EF6" },
27486
+ { path: "/healthz", methods: ["GET"], domain: "lifecycle", category: "public", consumers: ["\u58F3(\u63E1\u624B\u63A2\u9488)"], note: "\u5B58\u6D3B\u63A2\u9488" },
27487
+ { path: "/readyz", methods: ["GET"], domain: "lifecycle", category: "operational", consumers: ["\u76D1\u63A7/\u7F16\u6392\u63A2\u9488"], note: "\u5C31\u7EEA\u63A2\u9488\uFF08\u5B88\u536B\u5DF2\u521D\u59CB\u5316\u4E14\u672A\u505C\u673A\uFF09" },
27488
+ { path: "/session/status", methods: ["GET"], domain: "lifecycle", category: "public", consumers: ["\u58F3(get_session_state)"], note: "\u4F1A\u8BDD\u6001\u8BFB\u53D6\u53E3" },
27489
+ { path: "/session/stop", methods: ["POST"], domain: "lifecycle", category: "public", consumers: ["\u58F3(\u9000\u51FA\u63E1\u624B)"], note: "\u505C\u5168\u90E8\u88AB\u7BA1\u5BF9\u8C61 + \u56DE\u6267\uFF08\u5B88\u536B\u4E0D\u81EA\u505C\uFF09" },
27490
+ { path: "/metrics", methods: ["GET"], domain: "lifecycle", category: "operational", consumers: ["\u76D1\u63A7\u63A5\u5165"], note: "\u76D1\u63A7\uFF1A\u4E8B\u4EF6\u6D41\u6D3E\u751F\u9065\u6D4B\uFF08bySource/topTypes/\u4E8B\u4EF6\u7387\uFF09" },
27491
+ { path: "/logs/tail", methods: ["GET"], domain: "lifecycle", category: "operational", consumers: ["\u8FDC\u7A0B\u8BCA\u65AD"], note: "\u8BCA\u65AD\uFF1A\u5404 stream \u65E5\u5FD7\u5C3E\u90E8\uFF08\u8DE8\u673A\u6392\u969C\uFF1B\u672C\u673A CLI \u76F4\u8BFB\u6587\u4EF6\uFF09" },
27492
+ { path: "/logs/export", methods: ["GET"], domain: "lifecycle", category: "operational", consumers: ["\u5BA1\u8BA1/\u79BB\u7EBF\u5907\u4EFD"], note: "\u5BA1\u8BA1\uFF1A\u805A\u5408\u6D41 JSONL \u5BFC\u51FA\uFF08\u79BB\u7EBF\u5907\u4EFD/\u5408\u89C4\u7559\u75D5\uFF09" },
27493
+ { path: "/lifecycle", methods: ["GET"], domain: "lifecycle", category: "public", consumers: ["UI"], note: "\u6A21\u5757\u751F\u547D\u5468\u671F\u4E00\u89C8\uFF08=/lifecycle/status\uFF09" },
27494
+ { path: "/lifecycle/status", methods: ["GET"], domain: "lifecycle", category: "public", consumers: ["UI"], note: "\u540C\u4E0A\uFF08\u663E\u5F0F\u522B\u540D\uFF09" },
27495
+ { path: "/changelog", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(AboutCard)"], note: "DSH \u66F4\u65B0\u65E5\u5FD7\uFF08text/plain\uFF09" },
27496
+ { path: "/guard/changelog", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(AboutCard)"], note: "\u7BA1\u5BB6\u66F4\u65B0\u65E5\u5FD7\uFF08CHANGELOG.md\uFF09" },
27497
+ { path: "/guard/version", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(AboutCard)"], note: "\u672C\u5730\u7248\u672C\uFF08\u65E0\u7F51\u7EDC I/O\uFF09" },
27498
+ { path: "/guard/version/check", methods: ["POST"], domain: "guard", category: "public", consumers: ["UI(AboutCard, \u6E90\u7801\u5F62\u6001)"], note: "git \u4E0A\u6E38\u68C0\u67E5\uFF08\u6E90\u7801\u90E8\u7F72\u5F62\u6001\u66F4\u65B0\u901A\u9053\uFF09" },
27499
+ { path: "/autostart", methods: ["GET", "POST"], domain: "guard", category: "public", consumers: ["UI(StartupCard)"], note: "\u6574\u6761\u670D\u52A1\u94FE\u5F00\u673A\u81EA\u542F" },
27500
+ { path: "/shutdown", methods: ["POST"], domain: "guard", category: "deprecated", consumers: ["\u65E7\u7248\u58F3\u517C\u5BB9"], note: "\u66FF\u4EE3 = POST /session/stop\uFF1B\u4FDD\u7559\u4F9B\u65E7\u58F3\u9000\u51FA\uFF08\u79FB\u9664\u6761\u4EF6\uFF1A\u58F3\u6700\u4F4E\u7248\u672C >= \u4F7F\u7528 /session/stop \u7684\u7248\u672C\uFF09" },
27501
+ { path: "/ports", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(PortPanel)"], note: "\u7AEF\u53E3\u89C6\u56FE\uFF08\u805A\u5408\u4E09\u6CE8\u518C\u8868\uFF09" },
27502
+ { path: "/env/dsh", methods: ["GET"], domain: "guard", category: "public", consumers: ["README \u6587\u6863\u5316\uFF08\u5916\u90E8\u811A\u672C\uFF09"], note: "DSH \u672C\u4F53\u5B89\u88C5/\u7EB3\u7BA1\u5224\u5B9A\uFF08bin/binOk/managed/phase\uFF09" },
27503
+ { path: "/env/status", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(InstancesPage \u80FD\u529B\u77E9\u9635)"], note: "\u73AF\u5883 + \u5E73\u53F0\u80FD\u529B\u77E9\u9635 + catalog" },
27504
+ { path: "/env/node-lts", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(OverviewPage)"], note: "Node \u5F53\u524D vs \u5B98\u65B9\u6700\u65B0 LTS" },
27505
+ { path: "/env/open-url", methods: ["POST"], domain: "guard", category: "public", consumers: ["UI(externalOpen \u5730\u5740\u884C)"], note: "\u8BF7\u5185\u6838\u7528\u7CFB\u7EDF\u9ED8\u8BA4\u6D4F\u89C8\u5668\u6253\u5F00 http(s) \u5730\u5740\uFF08\u4E09\u6863\u7ED3\u679C\u539F\u6837\u56DE\u4F20\uFF0C\u5931\u8D25\u5E26 evidence.diagnostics \u63A2\u6D4B\u7559\u75D5\uFF1B\u4EC5\u56DE\u73AF\u6765\u6E90\uFF0C\u58F3\u5185 webview \u4E22\u5F03 window.open \u65F6\u4EE3\u7684\u552F\u4E00\u4EE3\u5F00\u65B9\uFF09" },
27506
+ { path: "/env/environment", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(OverviewPage \u73AF\u5883\u8868\u5355)", "README \u6587\u6863\u5316\uFF08\u4EBA\u5DE5/\u652F\u6301\u6392\u969C\u76F4\u8BFB\uFF1B\u6253\u5F00\u52A8\u4F5C\u7684\u8BCA\u65AD\u8D70 evidence.diagnostics\uFF09"], note: "\u73AF\u5883\u8868\u5355\uFF08\u53EA\u8BFB\u88C5\u914D\u9762\uFF0Cschema 2 \u7EF4\u5EA6\u53F0\u8D26\uFF09\uFF1A\u5019\u9009\u6D4F\u89C8\u5668 + \u7CFB\u7EDF\u9ED8\u8BA4\u53CA\u5176\u6765\u6E90 + \u56FE\u5F62\u4F1A\u8BDD + \u80FD\u529B\u6863\u4F4D + \u7528\u6237\u504F\u597D + \u8FD9\u4E00\u62CD\u7684\u5206\u53D1\u4F9D\u636E + \u8FD0\u884C\u65F6\uFF08Node/npm/\u955C\u50CF\u6E90/\u5168\u5C40\u524D\u7F00\uFF09+ \u51FA\u7F51\u6761\u4EF6\uFF08\u7CFB\u7EDF\u4EE3\u7406\u4E0E\u76EE\u6807\u57DF\u901A\u8DEF\uFF09+ \u6BCF\u6761\u7CFB\u7EDF\u67E5\u8BE2\u7559\u75D5\uFF1B?force=1 \u5F02\u6B65\u8865\u9F50\u5404\u7EF4\u5EA6\u5E76\u843D\u5FEB\u7167" },
27507
+ { path: "/env/environment/last", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(OverviewPage \u73AF\u5883\u8868\u5355\u7684\u4E0A\u4E00\u62CD\u7559\u75D5)", "README \u6587\u6863\u5316\uFF08\u4EBA\u5DE5/\u652F\u6301\u6392\u969C\u76F4\u8BFB\uFF09"], note: "\u4E0A\u4E00\u62CD\u73AF\u5883\u5FEB\u7167\u7684\u53EA\u8BFB\u56DE\u770B\u53E3\uFF08\u96F6\u6478\u7F51\u96F6\u5199\u76D8\uFF0C\u7EDD\u4E0D\u53C2\u4E0E\u5206\u53D1\u5224\u5B9A\uFF09\uFF1Aavailable/at/ageMs/path + \u6574\u4EFD\u4E0A\u4E00\u62CD\u8868\u5355\uFF1B\u6CA1\u5199\u8FC7\uFF08never-written\uFF09\u4E0E\u8BFB\u4E0D\u51FA\uFF08unreadable-or-schema-mismatch\uFF09\u5206\u5F00\u6807" },
27508
+ { path: "/settings/external-browser", methods: ["GET", "POST"], domain: "guard", category: "public", consumers: ["UI(OverviewPage \u73AF\u5883\u8868\u5355)"], note: "\u5916\u90E8\u6253\u5F00\u7684\u6D4F\u89C8\u5668\u504F\u597D\uFF08id \u5FC5\u987B\u662F\u672C\u673A\u5019\u9009\uFF1B\u7A7A\u4E32\u6E05\u9664\uFF09" },
27509
+ { path: "/settings/access-key", methods: ["GET", "POST"], domain: "guard", category: "public", consumers: ["UI(StartupCard)"], note: "\u8BBF\u95EE\u5BC6\u94A5" },
27510
+ { path: "/settings/close-action", methods: ["GET", "POST"], domain: "guard", category: "public", consumers: ["UI(StartupCard)", "\u58F3(\u8BFB\u53D6\u6267\u884C)"], note: "\u5173\u7A97\u884C\u4E3A\uFF08hide/exit\uFF09" },
27511
+ { path: "/settings/lan", methods: ["GET", "POST"], domain: "guard", category: "public", consumers: ["UI(StartupCard)"], note: "\u9762\u677F\u5C40\u57DF\u7F51\u8BBF\u95EE\u5F00\u5173" },
27512
+ { path: "/self-update/status", methods: ["GET"], domain: "guard", category: "public", consumers: ["UI(AboutCard)"], note: "\u5185\u6838\u66F4\u65B0\u72B6\u6001\uFF08\u53EA\u8BFB\uFF1B\u5B89\u88C5\u5F52\u684C\u9762\u58F3\uFF09" },
27513
+ { path: "/self-update/apply", methods: ["POST"], domain: "guard", category: "deprecated", consumers: ["\u65E0"], note: "\u5355\u5199\u5165\u8005=\u58F3\uFF1A\u8FD4\u56DE 410 KERNEL_UPDATE_SINGLE_WRITER\uFF1B\u66FF\u4EE3 = \u684C\u9762\u58F3 kernel_update_apply" },
27514
+ { path: "/self-update/restart-guard", methods: ["POST"], domain: "guard", category: "deprecated", consumers: ["\u65E0"], note: "\u5B88\u536B\u4E0D\u81EA\u91CD\u542F\uFF1A\u8FD4\u56DE 410\uFF1B\u66FF\u4EE3 = \u58F3\u5728\u5B89\u88C5\u540E\u7ECF\u670D\u52A1\u7BA1\u7406\u5668\u91CD\u542F\u5B88\u536B" },
27515
+ { path: "/native/status", methods: ["GET"], domain: "native", category: "public", consumers: ["UI(OverviewPage)", "CLI(status)"], note: "\u5B89\u88C5\u72B6\u6001 + \u7248\u672C + \u5347\u7EA7\u72B6\u6001\u673A" },
27516
+ { path: "/native/check-update", methods: ["POST"], domain: "native", category: "public", consumers: ["UI(OverviewPage)"], note: "\u89E6\u53D1\u7248\u672C\u68C0\u67E5" },
27517
+ { path: "/native/install", methods: ["POST"], domain: "native", category: "public", consumers: ["UI(OverviewPage)", "CLI"], note: "\u5F02\u6B65\u5B89\u88C5\uFF08202\uFF09" },
27518
+ { path: "/native/uninstall", methods: ["POST"], domain: "native", category: "public", consumers: ["UI(OverviewPage)"], note: "\u5F02\u6B65\u5378\u8F7D\uFF08202\uFF09" },
27519
+ { path: "/native/upgrade", methods: ["POST"], domain: "native", category: "public", consumers: ["UI(OverviewPage)", "CLI(upgrade)"], note: "\u4E00\u952E\u5347\u7EA7\uFF08\u5931\u8D25\u56DE\u6EDA\uFF09" },
27520
+ { path: "/native/settings", methods: ["POST"], domain: "native", category: "public", consumers: ["UI(OverviewPage)"], note: "main \u5143\u6570\u636E\u8865\u4E01\uFF08\u4EC5 guardian\uFF1B\u8FDC\u7A0B\u610F\u56FE\u552F\u4E00\u5165\u53E3\u5728 /remote/*\uFF09" },
27521
+ { path: "/instances", methods: ["GET"], domain: "instances", category: "public", consumers: ["UI(InstancesPage)"], note: "\u5B9E\u4F8B\u5217\u8868\uFF08+ POST /instances/{action}\uFF09\uFF1B\u8FDC\u7A0B\u8BBF\u95EE\u4EE4\u724C\u660E\u6587\u4EC5\u56DE\u73AF\u6765\u6E90\u4E0B\u53D1\uFF08\u5176\u4F59\u53EA\u89C1 tokenSet \u5E03\u5C14\uFF09\uFF0CauthUrl \u7684 ?token= \u540C\u5224\u636E" },
27522
+ { path: "/open", methods: ["GET"], domain: "instances", category: "public", consumers: ["UI(open-web \u2192 \u672C\u673A\u7CFB\u7EDF\u6D4F\u89C8\u5668\u4E00\u6B21\u6027\u7801\u8DF3\u8F6C)"], note: "\u4E00\u6B21\u6027\u7801\u6362\u53D6 dsh-auth cookie \u5E76\u56DE\u8DF3\u5B9E\u4F8B DSH \u9875\u9762\uFF08\u4EE4\u724C\u4E0D\u8FDB URL/argv\uFF09" },
27523
+ { path: "/plugins/market", methods: ["GET"], domain: "plugins", category: "public", consumers: ["UI(PluginsPage)"], note: "\u5E02\u573A\u7D22\u5F15\uFF08TTL \u7F13\u5B58\uFF09" },
27524
+ { path: "/plugins/installed", methods: ["GET"], domain: "plugins", category: "public", consumers: ["UI(PluginsPage)"], note: "\u5DF2\u88C5\u7B2C\u4E09\u65B9\u63D2\u4EF6" },
27525
+ { path: "/plugins/check-updates", methods: ["GET"], domain: "plugins", category: "public", consumers: ["UI(PluginsPage)"], note: "\u5DF2\u88C5\u63D2\u4EF6\u66F4\u65B0\u68C0\u6D4B" },
27526
+ { path: "/plugins/install-status", methods: ["GET"], domain: "plugins", category: "public", consumers: ["UI(PluginsPage, job \u8F6E\u8BE2)"], note: "\u63D2\u4EF6\u4EFB\u52A1\u8FDB\u5EA6" },
27527
+ { path: "/router/status", methods: ["GET"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u4E2D\u8F6C\u72B6\u6001 + \u7528\u91CF" },
27528
+ { path: "/router/providers", methods: ["GET"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u4F9B\u5E94\u5546 + \u8D26\u53F7 + \u5B9E\u4F8B\u89C6\u56FE" },
27529
+ { path: "/router/ports", methods: ["GET"], domain: "router", category: "internal", consumers: ["p2p-api \u5951\u7EA6\u6D4B\u8BD5\uFF08\u57DF\u5206\u79BB\u9A8C\u8BC1\uFF09"], note: "router \u81EA\u6CBB\u6BB5\u7AEF\u53E3\u89C6\u56FE\uFF08daemon \u6A21\u5F0F\u7269\u7406\u5206\u79BB\uFF09" },
27530
+ { path: "/router/domain-summary", methods: ["GET"], domain: "router", category: "internal", consumers: ["\u5B88\u536B\u76D1\u7763\u62CD\u81EA\u6D88\u8D39\uFF08\u5199\u76EE\u5F55 domainSummary\uFF09"], note: "\u57DF\u6458\u8981\u53EA\u8BFB\u7F13\u5B58" },
27531
+ { path: "/router/providers/account/discard", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u8D26\u53F7\u4E22\u5F03" },
27532
+ { path: "/router/providers/activate", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u6FC0\u6D3B\u4F9B\u5E94\u5546" },
27533
+ { path: "/router/providers/add", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u65B0\u589E\u4F9B\u5E94\u5546" },
27534
+ { path: "/router/providers/deactivate", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u505C\u7528\u4F9B\u5E94\u5546" },
27535
+ { path: "/router/providers/key/use", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u5207\u6362\u4F7F\u7528\u4E2D\u7684 Key" },
27536
+ { path: "/router/providers/keys/set", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u8BBE\u7F6E\u4F9B\u5E94\u5546 Key" },
27537
+ { path: "/router/providers/proxy/key", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u53CD\u4EE3 Key \u5199\u5165" },
27538
+ { path: "/router/providers/proxy/key/remove", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u53CD\u4EE3 Key \u79FB\u9664" },
27539
+ { path: "/router/providers/proxy/select", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u9009\u62E9\u53CD\u4EE3" },
27540
+ { path: "/router/providers/refresh", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u5237\u65B0\u4F9B\u5E94\u5546" },
27541
+ { path: "/router/providers/remove", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u5220\u9664\u4F9B\u5E94\u5546" },
27542
+ { path: "/router/proxy/login/start", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "Command Code \u4E00\u952E\u767B\u5F55\uFF08\u53D1\u8D77\uFF09" },
27543
+ { path: "/router/proxy/login/wait", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u767B\u5F55\u7B49\u5F85" },
27544
+ { path: "/router/proxy/update/apply", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u53CD\u4EE3\u66F4\u65B0\uFF08job\uFF09" },
27545
+ { path: "/router/proxy/update/check", methods: ["POST"], domain: "router", category: "public", consumers: ["UI(RouterPage)"], note: "\u53CD\u4EE3\u7248\u672C\u68C0\u6D4B" },
27546
+ { path: "/router/proxy/update/status", methods: ["GET"], domain: "router", category: "public", consumers: ["UI(RouterPage, job \u8F6E\u8BE2)"], note: "\u53CD\u4EE3\u66F4\u65B0\u8FDB\u5EA6" },
27547
+ { path: "/dist/registry", methods: ["GET"], domain: "dist", category: "public", consumers: ["UI(RegistryCard)"], note: "\u955C\u50CF\u6E90\u72B6\u6001" },
27548
+ { path: "/dist/registry/refresh", methods: ["POST"], domain: "dist", category: "public", consumers: ["UI(RegistryCard)"], note: "\u955C\u50CF\u6E90\u6D4B\u901F\u5237\u65B0" },
27549
+ { path: "/dist/registry/set", methods: ["POST"], domain: "dist", category: "public", consumers: ["UI(RegistryCard)"], note: "\u955C\u50CF\u6E90\u624B\u52A8\u56FA\u5B9A" },
27550
+ { path: "/dist/registry/probe", methods: ["POST"], domain: "dist", category: "public", consumers: ["UI(RegistryCard \u6D4B\u8BD5\u6309\u94AE)"], note: "\u540C\u6E90\u5355\u6E90\u63A2\u6D3B\uFF08\u670D\u52A1\u7AEF\uFF0C\u4E0D\u53D7\u9875\u9762 CSP \u9650\u5236\uFF09" },
27551
+ { path: "/lan-access", methods: ["GET"], domain: "relay", category: "public", consumers: ["UI(LanPage)"], note: "\u8FDC\u7A0B\u4EE3\u7406\u5217\u8868\uFF08\u8131\u654F\uFF1A\u4EFB\u4F55\u4EE4\u724C\u5B57\u6BB5\u90FD\u4E0D\u5916\u4F20\uFF1Bremote \u89C6\u56FE\u4E3A\u8BBF\u95EE URL/\u5C31\u7EEA\u5224\u5B9A\u7684\u5355\u4E00\u6765\u6E90\uFF09" },
27552
+ { path: "/remote/frp", methods: ["GET"], domain: "relay", category: "public", consumers: ["UI(LanPage)"], note: "frpc \u72B6\u6001\uFF08\u8BBE\u7F6E + \u8FD0\u884C\u6001 + wan \u66B4\u9732\u6E05\u5355\uFF09" },
27553
+ { path: "/tasks", methods: ["GET"], domain: "tasks", category: "public", consumers: ["UI(TasksPage)"], note: "\u7EDF\u4E00\u4EFB\u52A1\u5217\u8868\uFF08+ /tasks/{id}\uFF09" },
27554
+ { path: "/shell/status", methods: ["GET"], domain: "shell", category: "public", consumers: ["UI(\u58F3\u72B6\u6001\u5361)", "CLI"], note: "\u58F3\u8EAB\u4EFD + \u66F4\u65B0\u8D26\u672C + \u5224\u5B9A\u7ED3\u8BBA" },
27555
+ { path: "/shell/health", methods: ["POST"], domain: "shell", category: "operational", consumers: ["\u8FD0\u7EF4\uFF1A\u6392\u969C\u65F6\u624B\u5DE5\u4E0A\u62A5\u58F3\u9636\u6BB5\uFF08\u58F3\u672A\u63A5\u7EBF\uFF0C\u5B9E\u6D4B\u96F6\u8C03\u7528\uFF09"], note: "\u8BCA\u65AD\u7528\u9014\uFF1Aphase=ready \u5373\u66F4\u65B0\u786E\u8BA4\u4FE1\u53F7\uFF0C\u4F9B\u6392\u969C\u624B\u5DE5\u9A71\u52A8\u5B89\u5168\u7F51\uFF1B\u5F53\u524D evaluate() \u56E0\u7F3A\u8F93\u5165\u6052 idle" },
27556
+ { path: "/shell/update-pending", methods: ["POST"], domain: "shell", category: "operational", consumers: ["\u8FD0\u7EF4\uFF1A\u6392\u969C\u65F6\u624B\u5DE5\u5EFA\u7ACB\u66F4\u65B0\u8D26\u672C\uFF08\u58F3\u672A\u63A5\u7EBF\uFF0C\u5B9E\u6D4B\u96F6\u8C03\u7528\uFF09"], note: "\u8BCA\u65AD\u7528\u9014\uFF1A\u5EFA\u7ACB\u66F4\u65B0\u8D26\u672C\uFF08\u5F85\u91CD\u542F\u786E\u8BA4\uFF09\uFF0C\u4F9B\u6392\u969C\u624B\u5DE5\u9A71\u52A8\u5185\u6838\u4FA7\u5B89\u5168\u7F51" },
27557
+ { path: "/shell/check-update", methods: ["POST"], domain: "shell", category: "public", consumers: ["UI(\u5173\u4E8E\u5361)"], note: "\u58F3\u7248\u672C\u68C0\u6D4B\uFF08\u4E0E\u5185\u6838\u81EA\u66F4\u65B0\u540C\u6E90\uFF1Anpm registry + \u955C\u50CF\u56DE\u9000\uFF09" }
27558
+ ];
27559
+ var PREFIXES = [
27560
+ { prefix: "/dist/", domain: "dist", category: "public", consumers: ["UI"], note: "/dist/registry/{refresh|set}" },
27561
+ { prefix: "/guard/", domain: "guard", category: "public", consumers: ["UI"], note: "/guard/version|changelog \u7B49" },
27562
+ { prefix: "/instances/", domain: "instances", category: "public", consumers: ["UI"], note: "/instances/{add|remove|update|start|stop|check-update|open-web|upgrade}\uFF1Bopen-web \u56DE platform.browser.openBrowser \u7684\u4E09\u6863\u7ED3\u679C {ok,confirmed,handedOff,reason,error,url,evidence}\uFF0Curl \u6052\u5728\u573A\u4F9B\u9762\u677F\u590D\u5236/\u624B\u52A8\u6253\u5F00" },
27563
+ { prefix: "/lifecycle", domain: "lifecycle", category: "public", consumers: ["UI", "CLI"], note: "/lifecycle/{id}[/{action}]\uFF08\u552F\u4E00\u542F\u505C\u5165\u53E3\uFF09" },
27564
+ { prefix: "/lifecycle/", domain: "lifecycle", category: "public", consumers: ["UI", "CLI"], note: "\u540C\u4E0A\uFF08\u663E\u5F0F\u524D\u7F00\uFF09" },
27565
+ { prefix: "/logs", domain: "lifecycle", category: "operational", consumers: ["\u8BCA\u65AD/\u5BA1\u8BA1"], note: "/logs/{tail|export}\uFF08\u65E0 events-tail\uFF1A\u4E0E /events \u8BED\u4E49\u91CD\u590D\uFF09" },
27566
+ { prefix: "/native/", domain: "native", category: "public", consumers: ["UI", "CLI"], note: "/native/{status|install|uninstall|upgrade|...}" },
27567
+ { prefix: "/plugins/", domain: "plugins", category: "public", consumers: ["UI"], note: "/plugins/{install|enable|disable|uninstall|update}" },
27568
+ { prefix: "/remote/", domain: "relay", category: "public", consumers: ["UI"], note: "/remote/{set-mode|set-token|frp-server|frp-install}\uFF08\u610F\u56FE\u552F\u4E00\u5165\u53E3\uFF1Bset-mode \u5F00\u542F\u65F6\u65E0\u4EE4\u724C\u5373\u81EA\u52A8\u5206\u914D\u5E76\u56DE\u6267 tokenAutoAllocated\uFF0Cwan \u524D\u7F6E\u95F8=\u8BBF\u95EE\u4EE4\u724C \u22658 \u4F4D\uFF1Bset-token \u7A7A\u4E32=\u663E\u5F0F\u6E05\u9664\uFF09" },
27569
+ { prefix: "/router/", domain: "router", category: "public", consumers: ["UI"], note: "/router/... \uFF08ports/domain-summary \u4E3A internal\uFF0C\u89C1 SURFACE\uFF09" },
27570
+ { prefix: "/shell/", domain: "shell", category: "public", consumers: ["\u58F3", "UI"], note: "/shell/{status|health|update-pending|check-update|restart}\uFF08\u58F3\u66F4\u65B0\u5F3A\u5236\uFF0C\u65E0\u56DE\u9000\uFF09\uFF1B\u26A0 health/update-pending \u5B9E\u4E3A\u58F3\u96F6\u8C03\u7528\u7684\u6392\u969C\u5165\u53E3\uFF0C\u89C1\u4E0A\u65B9\u6761\u76EE" },
27571
+ { prefix: "/self-update/", domain: "guard", category: "public", consumers: ["UI"], note: "/self-update/status\uFF08\u53EA\u8BFB\uFF09\uFF1Bapply|restart-guard \u8FD4\u56DE 410" },
27572
+ { prefix: "/settings/", domain: "guard", category: "public", consumers: ["UI"], note: "/settings/{lan|access-key|close-action}" },
27573
+ { prefix: "/tasks/", domain: "tasks", category: "public", consumers: ["UI"], note: "/tasks/{id}" }
27574
+ ];
27575
+ module2.exports = { SURFACE, PREFIXES, CATEGORIES };
27576
+ }
27577
+ });
27578
+
27452
27579
  // src/api/router-table.js
27453
27580
  var require_router_table = __commonJS({
27454
27581
  "src/api/router-table.js"(exports2, module2) {
@@ -27465,7 +27592,19 @@ var require_router_table = __commonJS({
27465
27592
  require_relay(),
27466
27593
  require_shell2()
27467
27594
  ];
27468
- module2.exports = { API_DOMAINS };
27595
+ var { SURFACE } = require_contract();
27596
+ function assertSurfaceOwned(domains) {
27597
+ const orphans = [];
27598
+ for (const entry of SURFACE || []) {
27599
+ const path2 = typeof entry === "string" ? entry : entry && entry.path;
27600
+ if (!path2) continue;
27601
+ const owned = domains.some((d) => typeof d.owns === "function" && d.owns(path2));
27602
+ if (!owned) orphans.push(path2);
27603
+ }
27604
+ return orphans;
27605
+ }
27606
+ var API_DOMAINS_ORPHANS = assertSurfaceOwned(API_DOMAINS);
27607
+ module2.exports = { API_DOMAINS, API_DOMAINS_ORPHANS };
27469
27608
  }
27470
27609
  });
27471
27610
 
@@ -27634,6 +27773,14 @@ var require_server = __commonJS({
27634
27773
  } catch {
27635
27774
  }
27636
27775
  }
27776
+ function rejectCrossOrigin(ctx) {
27777
+ const { req, send } = ctx;
27778
+ try {
27779
+ req.resume();
27780
+ } catch {
27781
+ }
27782
+ return send(403, { ok: false, error: "cross-origin request rejected" });
27783
+ }
27637
27784
  function createServer(sup, deps) {
27638
27785
  const browser = deps && deps.browser || browserExit;
27639
27786
  const environment = deps && deps.environment || environmentExit;
@@ -27705,7 +27852,7 @@ var require_server = __commonJS({
27705
27852
  } catch (e) {
27706
27853
  return send(400, { error: "bad request encoding" });
27707
27854
  }
27708
- const ctx = { sup, req, res, pathname: decodedPathname, identity, send, collectBody, originAllowed: originAllowedLive, tokOf, browser, environment, server };
27855
+ const ctx = { sup, req, res, pathname: decodedPathname, identity, send, collectBody, originAllowed: originAllowedLive, rejectCrossOrigin, tokOf, browser, environment, server };
27709
27856
  for (const d of API_DOMAINS) {
27710
27857
  if (d.owns(pathname)) {
27711
27858
  try {
@@ -28276,15 +28423,19 @@ var require_ports3 = __commonJS({
28276
28423
  async function claim(segment, owner, opts) {
28277
28424
  const o = opts || {};
28278
28425
  const reservedPorts = o.reservedPorts || _reservedByOtherLedger(owner);
28279
- return registry.claimSlot(segment, owner, {
28280
- preferred: o.preferred,
28281
- bindingPreferred: !!o.bindingPreferred,
28282
- reservedPorts: reservedPorts || void 0,
28283
- onBindingLost: o.onBindingLost,
28284
- reclaimCmdMark: "domains/relay/daemon.js",
28285
- reclaimCfg: o.configPath || "",
28286
- waitMs: 8e3
28287
- });
28426
+ try {
28427
+ return await registry.claimSlot(segment, owner, {
28428
+ preferred: o.preferred,
28429
+ bindingPreferred: !!o.bindingPreferred,
28430
+ reservedPorts: reservedPorts || void 0,
28431
+ onBindingLost: o.onBindingLost,
28432
+ reclaimCmdMark: "domains/relay/daemon.js",
28433
+ reclaimCfg: o.configPath || "",
28434
+ waitMs: 8e3
28435
+ });
28436
+ } catch (e) {
28437
+ return { conflict: true, reason: "alloc-lock-unavailable", error: e && e.message || String(e) };
28438
+ }
28288
28439
  }
28289
28440
  function releaseOwner(owner) {
28290
28441
  try {
@@ -29294,6 +29445,7 @@ function findPackageRoot(start) {
29294
29445
  var ROOT = findPackageRoot(__dirname);
29295
29446
  var stateRoot = require_state_root();
29296
29447
  var BRAND = require_brand();
29448
+ var SHARED = require_shared_constants2();
29297
29449
  var SUPERVISOR_DIR = stateRoot.supervisorDir();
29298
29450
  var USER_CONFIG = path.join(SUPERVISOR_DIR, "config.json");
29299
29451
  var { buildDefaults } = require_config();
@@ -29339,9 +29491,9 @@ function readApiAddress() {
29339
29491
  const cfg = JSON.parse(fs.readFileSync(cfgPath, "utf8"));
29340
29492
  let host = cfg.apiHost || "127.0.0.1";
29341
29493
  if (host === "0.0.0.0" || host === "::") host = "127.0.0.1";
29342
- return { host, port: cfg.apiPort || 36360 };
29494
+ return { host, port: cfg.apiPort || SHARED.net.apiPort };
29343
29495
  } catch {
29344
- return { host: "127.0.0.1", port: 36360 };
29496
+ return { host: "127.0.0.1", port: SHARED.net.apiPort };
29345
29497
  }
29346
29498
  }
29347
29499
  function logFilePaths() {