@dsh-sup/dsh-core-win-x64 0.1.5-BETA.2 → 0.1.5-BETA.4

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/core.cjs CHANGED
@@ -225,7 +225,7 @@ var require_version = __commonJS({
225
225
  var fs2 = require("node:fs");
226
226
  var path2 = require("node:path");
227
227
  function guardVersion() {
228
- if (true) return String("0.1.5-BETA.2");
228
+ if (true) return String("0.1.5-BETA.4");
229
229
  try {
230
230
  return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
231
231
  } catch {
@@ -236,6 +236,64 @@ var require_version = __commonJS({
236
236
  }
237
237
  });
238
238
 
239
+ // src/platform/matrix.js
240
+ var require_matrix = __commonJS({
241
+ "src/platform/matrix.js"(exports2, module2) {
242
+ "use strict";
243
+ var SUPPORTED = [
244
+ { platform: "linux", arch: "x64", osTag: "linux", npmTag: "linux-x64" },
245
+ { platform: "darwin", arch: "arm64", osTag: "darwin", npmTag: "darwin-arm64" },
246
+ { platform: "darwin", arch: "x64", osTag: "darwin", npmTag: "darwin-x64" },
247
+ { platform: "win32", arch: "x64", osTag: "win", npmTag: "win-x64" }
248
+ ];
249
+ var OS_TAG = { linux: "linux", darwin: "darwin", win32: "win" };
250
+ var FRP_OS = { linux: "linux", darwin: "darwin", win32: "windows" };
251
+ var FRP_ARCH = { x64: "amd64", arm64: "arm64" };
252
+ function osTag(platform) {
253
+ return OS_TAG[platform || process.platform] || null;
254
+ }
255
+ function current(platform, arch) {
256
+ const p = platform || process.platform;
257
+ const a = arch || process.arch;
258
+ return { platform: p, arch: a, osTag: OS_TAG[p] || null, npmTag: npmTag(p, a) };
259
+ }
260
+ function npmTag(platform, arch) {
261
+ const p = platform || process.platform;
262
+ const a = arch || process.arch;
263
+ const os2 = OS_TAG[p];
264
+ if (!os2 || a !== "x64" && a !== "arm64") {
265
+ throw new Error("\u4E0D\u652F\u6301\u7684\u5E73\u53F0\u7EC4\u5408: " + p + "/" + a + "\uFF08\u4EC5 linux/darwin/win32 \xD7 x64/arm64\uFF09");
266
+ }
267
+ return os2 + "-" + a;
268
+ }
269
+ function isSupported(platform, arch) {
270
+ const p = platform || process.platform;
271
+ const a = arch || process.arch;
272
+ return SUPPORTED.some((x) => x.platform === p && x.arch === a);
273
+ }
274
+ function frpTag(platform, arch) {
275
+ const p = platform || process.platform;
276
+ const a = arch || process.arch;
277
+ const os2 = FRP_OS[p];
278
+ const am = FRP_ARCH[a];
279
+ if (!os2 || !am) return null;
280
+ return { os: os2, arch: am, tag: os2 + "_" + am, exe: p === "win32" };
281
+ }
282
+ function supportsProcessGroup(platform) {
283
+ return (platform || process.platform) !== "win32";
284
+ }
285
+ module2.exports = {
286
+ SUPPORTED,
287
+ osTag,
288
+ current,
289
+ npmTag,
290
+ isSupported,
291
+ frpTag,
292
+ supportsProcessGroup
293
+ };
294
+ }
295
+ });
296
+
239
297
  // src/platform/os/pidlookup.js
240
298
  var require_pidlookup = __commonJS({
241
299
  "src/platform/os/pidlookup.js"(exports2, module2) {
@@ -245,6 +303,56 @@ var require_pidlookup = __commonJS({
245
303
  var isLinux = process.platform === "linux";
246
304
  var isMac = process.platform === "darwin";
247
305
  var isWindows = process.platform === "win32";
306
+ function parseProcNetTcpInodes(txt, port) {
307
+ const inodes = /* @__PURE__ */ new Set();
308
+ for (const lineRaw of String(txt || "").split("\n")) {
309
+ const cols = lineRaw.trim().split(/\s+/);
310
+ if (cols.length < 10) continue;
311
+ const local = cols[1];
312
+ const st = cols[3];
313
+ const inode = cols[9];
314
+ if (!local || !inode) continue;
315
+ const p = local.split(":")[1];
316
+ if (st === "0A" && p && parseInt(p, 16) === port) inodes.add("socket:[" + inode + "]");
317
+ }
318
+ return inodes;
319
+ }
320
+ function parseLsofPid(out) {
321
+ for (const line of String(out || "").split("\n")) {
322
+ const m = line.trim().split(/\s+/);
323
+ if (m.length >= 2 && /^\d+$/.test(m[1])) return Number(m[1]);
324
+ }
325
+ return null;
326
+ }
327
+ function parseNetstatPid(out, port) {
328
+ const want = String(port);
329
+ for (const line of String(out || "").split("\n")) {
330
+ const parts = line.trim().split(/\s+/);
331
+ if (parts.length >= 5 && (parts[0] === "TCP" || parts[0] === "TCPv6") && parts[3] === "LISTENING") {
332
+ const lp = parts[1];
333
+ const p = lp.slice(lp.lastIndexOf(":") + 1);
334
+ if (p === want) {
335
+ const pid = Number(parts[4]);
336
+ if (Number.isInteger(pid) && pid > 0) return pid;
337
+ }
338
+ }
339
+ }
340
+ return null;
341
+ }
342
+ function parseSsPid(out) {
343
+ const m = out && /pid=(\d+)/.exec(String(out));
344
+ return m ? Number(m[1]) : null;
345
+ }
346
+ function parseWmicCommandLine(out) {
347
+ if (!out) return null;
348
+ const m = /CommandLine=([\s\S]*)/.exec(String(out));
349
+ const v = m ? m[1].trim() : "";
350
+ return v || null;
351
+ }
352
+ function parsePowerShellCommandLine(out) {
353
+ const v = out ? String(out).trim() : "";
354
+ return v || null;
355
+ }
248
356
  function linuxListeningInodes(port) {
249
357
  const inodes = /* @__PURE__ */ new Set();
250
358
  for (const f of ["/proc/net/tcp", "/proc/net/tcp6"]) {
@@ -254,16 +362,7 @@ var require_pidlookup = __commonJS({
254
362
  } catch {
255
363
  continue;
256
364
  }
257
- for (const lineRaw of txt.split("\n")) {
258
- const cols = lineRaw.trim().split(/\s+/);
259
- if (cols.length < 10) continue;
260
- const local = cols[1];
261
- const st = cols[3];
262
- const inode = cols[9];
263
- if (!local || !inode) continue;
264
- const p = local.split(":")[1];
265
- if (st === "0A" && p && parseInt(p, 16) === port) inodes.add("socket:[" + inode + "]");
266
- }
365
+ for (const x of parseProcNetTcpInodes(txt, port)) inodes.add(x);
267
366
  }
268
367
  return inodes;
269
368
  }
@@ -297,10 +396,7 @@ var require_pidlookup = __commonJS({
297
396
  try {
298
397
  const out = ex2.runOut("lsof", ["-nP", "-iTCP:" + port, "-sTCP:LISTEN"], { timeoutMs: 3e3 });
299
398
  if (!out) return null;
300
- for (const line of out.split("\n")) {
301
- const m = line.trim().split(/\s+/);
302
- if (m.length >= 2 && /^\d+$/.test(m[1])) return Number(m[1]);
303
- }
399
+ return parseLsofPid(out);
304
400
  } catch {
305
401
  }
306
402
  return null;
@@ -309,18 +405,7 @@ var require_pidlookup = __commonJS({
309
405
  try {
310
406
  const out = ex2.runOut("netstat", ["-ano"], { timeoutMs: 3e3 });
311
407
  if (!out) return null;
312
- const want = String(port);
313
- for (const line of out.split("\n")) {
314
- const parts = line.trim().split(/\s+/);
315
- if (parts.length >= 5 && (parts[0] === "TCP" || parts[0] === "TCPv6") && parts[3] === "LISTENING") {
316
- const lp = parts[1];
317
- const p = lp.slice(lp.lastIndexOf(":") + 1);
318
- if (p === want) {
319
- const pid = Number(parts[4]);
320
- if (Number.isInteger(pid) && pid > 0) return pid;
321
- }
322
- }
323
- }
408
+ return parseNetstatPid(out, port);
324
409
  } catch {
325
410
  }
326
411
  return null;
@@ -330,8 +415,8 @@ var require_pidlookup = __commonJS({
330
415
  for (const ssBin of candidates) {
331
416
  try {
332
417
  const out = ex2.runOut(ssBin, ["-tlnHp", "sport = :" + port], { timeoutMs: 3e3 });
333
- const m = out && /pid=(\d+)/.exec(out);
334
- if (m) return Number(m[1]);
418
+ const pid = parseSsPid(out);
419
+ if (pid !== null) return pid;
335
420
  } catch {
336
421
  }
337
422
  }
@@ -375,15 +460,12 @@ var require_pidlookup = __commonJS({
375
460
  }
376
461
  if (isWindows) {
377
462
  const out = ex2.runOut("wmic", ["process", "where", "ProcessId=" + pid, "get", "CommandLine", "/value"], { timeoutMs: 5e3 });
378
- if (out) {
379
- const m = /CommandLine=([\s\S]*)/.exec(out);
380
- const viaWmic = m ? m[1].trim() : "";
381
- if (viaWmic) return viaWmic;
382
- }
463
+ const viaWmic = parseWmicCommandLine(out);
464
+ if (viaWmic) return viaWmic;
383
465
  {
384
466
  const ps = "(Get-CimInstance Win32_Process -Filter 'ProcessId=" + pid + "').CommandLine";
385
467
  const o = ex2.runOut("powershell", ["-NoProfile", "-NonInteractive", "-Command", ps], { timeoutMs: 5e3 });
386
- return o ? o.trim() || null : null;
468
+ return parsePowerShellCommandLine(o);
387
469
  }
388
470
  }
389
471
  return null;
@@ -439,7 +521,21 @@ var require_pidlookup = __commonJS({
439
521
  function normCmdline(s) {
440
522
  return String(s || "").replace(/\\/g, "/");
441
523
  }
442
- module2.exports = { findListeningPid, isAlive, readCmdline, normCmdline, isDshCmdline, pgrepList };
524
+ module2.exports = {
525
+ findListeningPid,
526
+ isAlive,
527
+ readCmdline,
528
+ normCmdline,
529
+ isDshCmdline,
530
+ pgrepList,
531
+ // 平台输出纯解析器(2026-09-13 抽出:使其可在任意宿主上穷举;生产代码直接调用,非平行实现)
532
+ parseProcNetTcpInodes,
533
+ parseLsofPid,
534
+ parseNetstatPid,
535
+ parseSsPid,
536
+ parseWmicCommandLine,
537
+ parsePowerShellCommandLine
538
+ };
443
539
  }
444
540
  });
445
541
 
@@ -868,13 +964,14 @@ var require_exec_path = __commonJS({
868
964
  }
869
965
  return null;
870
966
  }
871
- function standardDirs(platform, home) {
967
+ function standardDirs(platform, home, env) {
872
968
  const pl = platform || process.platform;
873
969
  const h = home || os2.homedir();
970
+ const e = env || process.env;
874
971
  const dirs = [];
875
972
  if (pl === "win32") {
876
- if (process.env.APPDATA) dirs.push(path2.join(process.env.APPDATA, "npm"));
877
- if (process.env.LOCALAPPDATA) dirs.push(path2.join(process.env.LOCALAPPDATA, "Programs", "dsh-supervisor"));
973
+ if (e.APPDATA) dirs.push(path2.join(e.APPDATA, "npm"));
974
+ if (e.LOCALAPPDATA) dirs.push(path2.join(e.LOCALAPPDATA, "Programs", "dsh-supervisor"));
878
975
  dirs.push(path2.join(h, ".local", "bin"));
879
976
  } else {
880
977
  dirs.push(path2.join(h, ".local", "bin"));
@@ -886,8 +983,9 @@ var require_exec_path = __commonJS({
886
983
  }
887
984
  return dirs;
888
985
  }
889
- function inPath(base, platform) {
890
- const raw = process.env.PATH || process.env.Path || "";
986
+ function inPath(base, platform, env) {
987
+ const e = env || process.env;
988
+ const raw = e.PATH || e.Path || "";
891
989
  for (const d of raw.split(path2.delimiter)) {
892
990
  if (!d) continue;
893
991
  const hit = firstExecutable(d, base, platform);
@@ -897,35 +995,42 @@ var require_exec_path = __commonJS({
897
995
  }
898
996
  function resolveExecutable(base, opts) {
899
997
  const o = opts || {};
900
- if (o.envVar && process.env[o.envVar]) {
901
- const v = process.env[o.envVar];
998
+ const pl = o.platform;
999
+ const env = o.env;
1000
+ const E = env || process.env;
1001
+ if (o.envVar && E[o.envVar]) {
1002
+ const v = E[o.envVar];
902
1003
  try {
903
1004
  if (fs2.statSync(v).isFile()) return v;
904
1005
  } catch {
905
1006
  }
906
1007
  }
907
- const inPathHit = inPath(base);
1008
+ const inPathHit = inPath(base, pl, env);
908
1009
  if (inPathHit) return inPathHit;
909
- for (const d of [...o.extraDirs || [], ...standardDirs()]) {
910
- const hit = firstExecutable(d, base);
1010
+ for (const d of [...o.extraDirs || [], ...standardDirs(pl, void 0, env)]) {
1011
+ const hit = firstExecutable(d, base, pl);
911
1012
  if (hit) return hit;
912
1013
  }
913
1014
  return null;
914
1015
  }
915
1016
  function npxBin(opts) {
916
- const pl = opts && opts.platform || process.platform;
1017
+ const o = opts || {};
1018
+ const pl = o.platform || process.platform;
1019
+ const env = o.env || process.env;
917
1020
  if (pl !== "win32") return "npx";
918
- const resolved = resolveExecutable("npx", { extraDirs: [
919
- process.env.APPDATA ? path2.join(process.env.APPDATA, "npm") : null
1021
+ const resolved = resolveExecutable("npx", { platform: pl, env, extraDirs: [
1022
+ env.APPDATA ? path2.join(env.APPDATA, "npm") : null
920
1023
  ].filter(Boolean) });
921
1024
  if (resolved) return resolved;
922
1025
  return "npx.cmd";
923
1026
  }
924
1027
  function npmBin(opts) {
925
- const pl = opts && opts.platform || process.platform;
1028
+ const o = opts || {};
1029
+ const pl = o.platform || process.platform;
1030
+ const env = o.env || process.env;
926
1031
  if (pl !== "win32") return "npm";
927
- const resolved = resolveExecutable("npm", { extraDirs: [
928
- process.env.APPDATA ? path2.join(process.env.APPDATA, "npm") : null
1032
+ const resolved = resolveExecutable("npm", { platform: pl, env, extraDirs: [
1033
+ env.APPDATA ? path2.join(env.APPDATA, "npm") : null
929
1034
  ].filter(Boolean) });
930
1035
  if (resolved) return resolved;
931
1036
  return "npm.cmd";
@@ -1174,53 +1279,54 @@ var require_notify = __commonJS({
1174
1279
  "src/platform/os/notify.js"(exports2, module2) {
1175
1280
  "use strict";
1176
1281
  var { spawn } = require("node:child_process");
1177
- var isLinux = process.platform === "linux";
1178
- var isMac = process.platform === "darwin";
1179
- var isWindows = process.platform === "win32";
1282
+ function appleScriptString(s) {
1283
+ return JSON.stringify(String(s));
1284
+ }
1285
+ function powerShellString(s) {
1286
+ return '"' + String(s).replace(/"/g, '""') + '"';
1287
+ }
1288
+ function notifyCommand(platform, title, body) {
1289
+ const pl = platform || process.platform;
1290
+ const t = String(title == null ? "" : title);
1291
+ const b = String(body == null ? "" : body);
1292
+ if (pl === "linux") {
1293
+ return { cmd: "notify-send", args: ["-a", "dsh-supervisor", t, b] };
1294
+ }
1295
+ if (pl === "darwin") {
1296
+ const script = "display notification " + appleScriptString(b) + " with title " + appleScriptString(t);
1297
+ return { cmd: "osascript", args: ["-e", script] };
1298
+ }
1299
+ if (pl === "win32") {
1300
+ const ps = [
1301
+ '[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null',
1302
+ '[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null',
1303
+ "$n = New-Object System.Windows.Forms.NotifyIcon",
1304
+ "$n.Icon = [System.Drawing.SystemIcons]::Information",
1305
+ "$n.Visible = $true",
1306
+ "$n.ShowBalloonTip(4000, " + powerShellString(t) + ", " + powerShellString(b) + ", [System.Windows.Forms.ToolTipIcon]::None)",
1307
+ "Start-Sleep -Milliseconds 4200",
1308
+ "$n.Dispose(); $n.Visible = $false"
1309
+ ].join("; ");
1310
+ return { cmd: "powershell", args: ["-NoProfile", "-NonInteractive", "-Command", ps] };
1311
+ }
1312
+ return null;
1313
+ }
1180
1314
  function notify(title, body, onError) {
1181
1315
  try {
1182
- if (isLinux) {
1183
- const c = spawn("notify-send", ["-a", "dsh-supervisor", String(title), String(body)], { stdio: "ignore", detached: true });
1184
- c.on("error", () => {
1185
- if (onError) onError();
1186
- });
1187
- c.unref();
1188
- return true;
1189
- }
1190
- if (isMac) {
1191
- const script = "display notification " + JSON.stringify(String(body)) + " with title " + JSON.stringify(String(title));
1192
- const c = spawn("osascript", ["-e", script], { stdio: "ignore" });
1193
- c.on("error", () => {
1194
- if (onError) onError();
1195
- });
1196
- c.unref();
1197
- return true;
1198
- }
1199
- if (isWindows) {
1200
- const ps = [
1201
- '[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null',
1202
- '[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null',
1203
- "$n = New-Object System.Windows.Forms.NotifyIcon",
1204
- "$n.Icon = [System.Drawing.SystemIcons]::Information",
1205
- "$n.Visible = $true",
1206
- "$n.ShowBalloonTip(4000, " + JSON.stringify(String(title)) + ", " + JSON.stringify(String(body)) + ", [System.Windows.Forms.ToolTipIcon]::None)",
1207
- "Start-Sleep -Milliseconds 4200",
1208
- "$n.Dispose(); $n.Visible = $false"
1209
- ].join("; ");
1210
- const c = spawn("powershell", ["-NoProfile", "-NonInteractive", "-Command", ps], { stdio: "ignore" });
1211
- c.on("error", () => {
1212
- if (onError) onError();
1213
- });
1214
- c.unref();
1215
- return true;
1216
- }
1217
- return false;
1316
+ const plan = notifyCommand(process.platform, title, body);
1317
+ if (!plan) return false;
1318
+ const c = spawn(plan.cmd, plan.args, { stdio: "ignore", detached: process.platform === "linux" });
1319
+ c.on("error", () => {
1320
+ if (onError) onError();
1321
+ });
1322
+ c.unref();
1323
+ return true;
1218
1324
  } catch {
1219
1325
  if (onError) onError();
1220
1326
  return false;
1221
1327
  }
1222
1328
  }
1223
- module2.exports = { notify };
1329
+ module2.exports = { notify, notifyCommand, appleScriptString, powerShellString };
1224
1330
  }
1225
1331
  });
1226
1332
 
@@ -1229,9 +1335,16 @@ var require_browser = __commonJS({
1229
1335
  "src/platform/os/browser.js"(exports2, module2) {
1230
1336
  "use strict";
1231
1337
  var { spawn } = require("node:child_process");
1338
+ function openCommand(platform, url) {
1339
+ const pl = platform || process.platform;
1340
+ if (pl === "darwin") return { cmd: "open", args: [url] };
1341
+ if (pl === "win32") return { cmd: "cmd", args: ["/c", "start", "", url] };
1342
+ return { cmd: "xdg-open", args: [url] };
1343
+ }
1232
1344
  function open(url) {
1233
1345
  try {
1234
- const p = process.platform === "darwin" ? spawn("open", [url], { detached: true, stdio: "ignore" }) : process.platform === "win32" ? spawn("cmd", ["/c", "start", "", url], { detached: true, stdio: "ignore" }) : spawn("xdg-open", [url], { detached: true, stdio: "ignore" });
1346
+ const c = openCommand(process.platform, url);
1347
+ const p = spawn(c.cmd, c.args, { detached: true, stdio: "ignore" });
1235
1348
  p.on("error", () => {
1236
1349
  });
1237
1350
  p.unref();
@@ -1258,6 +1371,37 @@ var require_browser = __commonJS({
1258
1371
  child.unref();
1259
1372
  return child;
1260
1373
  }
1374
+ function isolatedPlan(platform, url, opts) {
1375
+ const o = opts || {};
1376
+ const antiArgs = o.antiArgs || [];
1377
+ const profileDir = o.profileDir;
1378
+ const pl = platform || process.platform;
1379
+ if (pl === "darwin") {
1380
+ return { kind: "single", bin: "open", args: ["-na", "Google Chrome", "--args", ...antiArgs], isolated: true, label: "Google Chrome" };
1381
+ }
1382
+ if (pl === "win32") {
1383
+ return {
1384
+ kind: "single",
1385
+ bin: "cmd",
1386
+ args: ["/c", "start", "", "chrome", "--incognito", "--user-data-dir=" + profileDir, url],
1387
+ isolated: true,
1388
+ label: "chrome"
1389
+ };
1390
+ }
1391
+ return {
1392
+ kind: "chain",
1393
+ candidates: [
1394
+ { bin: "microsoft-edge", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
1395
+ { bin: "microsoft-edge-stable", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
1396
+ { bin: "google-chrome", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
1397
+ { bin: "chromium", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
1398
+ { bin: "chromium-browser", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
1399
+ { bin: "firefox", args: ["--private-window", url], isolated: false, watch: true, envKind: "sys" },
1400
+ { bin: "xdg-open", args: [url], isolated: false, watch: false, envKind: "sys" }
1401
+ // 兜底:无隔离
1402
+ ]
1403
+ };
1404
+ }
1261
1405
  function launchIsolated(url, o) {
1262
1406
  const opts = o || {};
1263
1407
  const profileDir = opts.profileDir;
@@ -1266,31 +1410,20 @@ var require_browser = __commonJS({
1266
1410
  const sysEnv = opts.sysEnv || process.env;
1267
1411
  const onExit = opts.onExit;
1268
1412
  try {
1269
- if (process.platform === "darwin") {
1270
- const p = _spawnDetached("open", ["-na", "Google Chrome", "--args", ...antiArgs], antiEnv, onExit);
1271
- return { ok: !!p, bin: p ? "Google Chrome" : null, isolated: true };
1272
- }
1273
- if (process.platform === "win32") {
1274
- const p = _spawnDetached("cmd", ["/c", "start", "", "chrome", "--incognito", "--user-data-dir=" + profileDir, url], sysEnv, onExit);
1275
- return { ok: !!p, bin: p ? "chrome" : null, isolated: true };
1276
- }
1277
- const candidates = [
1278
- { bin: "microsoft-edge", args: antiArgs, env: antiEnv, isolated: true, watch: true },
1279
- { bin: "microsoft-edge-stable", args: antiArgs, env: antiEnv, isolated: true, watch: true },
1280
- { bin: "google-chrome", args: antiArgs, env: antiEnv, isolated: true, watch: true },
1281
- { bin: "chromium", args: antiArgs, env: antiEnv, isolated: true, watch: true },
1282
- { bin: "chromium-browser", args: antiArgs, env: antiEnv, isolated: true, watch: true },
1283
- { bin: "firefox", args: ["--private-window", url], env: sysEnv, isolated: false, watch: true },
1284
- { bin: "xdg-open", args: [url], env: sysEnv, isolated: false, watch: false }
1285
- // 兜底:无隔离
1286
- ];
1413
+ const plan = isolatedPlan(process.platform, url, { profileDir, antiArgs });
1414
+ if (plan.kind === "single") {
1415
+ const env = plan.bin === "open" ? antiEnv : sysEnv;
1416
+ const p = _spawnDetached(plan.bin, plan.args, env, onExit);
1417
+ return { ok: !!p, bin: p ? plan.label : null, isolated: plan.isolated };
1418
+ }
1287
1419
  let idx = 0;
1288
1420
  const tryNext = () => {
1289
- if (idx >= candidates.length) return { ok: false, bin: null, isolated: false };
1290
- const c = candidates[idx++];
1421
+ if (idx >= plan.candidates.length) return { ok: false, bin: null, isolated: false };
1422
+ const c = plan.candidates[idx++];
1423
+ const env = c.envKind === "anti" ? antiEnv : sysEnv;
1291
1424
  let child;
1292
1425
  try {
1293
- child = spawn(c.bin, c.args, { detached: true, stdio: "ignore", env: c.env || sysEnv });
1426
+ child = spawn(c.bin, c.args, { detached: true, stdio: "ignore", env: env || sysEnv });
1294
1427
  } catch {
1295
1428
  return tryNext();
1296
1429
  }
@@ -1311,7 +1444,7 @@ var require_browser = __commonJS({
1311
1444
  return { ok: false, bin: null, isolated: false };
1312
1445
  }
1313
1446
  }
1314
- module2.exports = { open, launchIsolated };
1447
+ module2.exports = { open, launchIsolated, openCommand, isolatedPlan };
1315
1448
  }
1316
1449
  });
1317
1450
 
@@ -1359,7 +1492,7 @@ var require_desktop = __commonJS({
1359
1492
  }
1360
1493
  return {
1361
1494
  platform: PLATFORM,
1362
- available: PLATFORM === "darwin" || PLATFORM === "win32",
1495
+ available: sessionAvailable(),
1363
1496
  reason: "session-scoped-by-launcher"
1364
1497
  };
1365
1498
  }
@@ -1462,6 +1595,9 @@ var require_autostart = __commonJS({
1462
1595
  guiLabel: GUI_LABEL
1463
1596
  };
1464
1597
  }
1598
+ if (!isLinux && !isMac && !isWindows) {
1599
+ return { kind: "none", unit: "unsupported", on: false, gui: false };
1600
+ }
1465
1601
  let unit = "unknown";
1466
1602
  const en = ex2.runDetail("systemctl", ["--user", "is-enabled", "dsh-supervisor.service"]);
1467
1603
  unit = String(en.stdout || en.stderr || "disabled").trim() || "disabled";
@@ -4693,6 +4829,7 @@ var require_dist = __commonJS({
4693
4829
  var fs2 = require("node:fs");
4694
4830
  var path2 = require("node:path");
4695
4831
  var net = require("node:net");
4832
+ var matrix = require_matrix();
4696
4833
  var { spawn } = require("node:child_process");
4697
4834
  var { npmBin } = require_exec_path();
4698
4835
  var registryContract = require_registry_contract();
@@ -4872,14 +5009,7 @@ var require_dist = __commonJS({
4872
5009
  * 并如实上报(见该函数的 try/catch),不会让守卫崩溃。
4873
5010
  */
4874
5011
  _platformTag() {
4875
- const osMap = { darwin: "darwin", win32: "win", linux: "linux" };
4876
- const archMap = { arm64: "arm64", x64: "x64" };
4877
- const os2 = osMap[process.platform];
4878
- const arch = archMap[process.arch];
4879
- if (!os2 || !arch) {
4880
- throw new Error("\u4E0D\u652F\u6301\u7684\u5E73\u53F0\u7EC4\u5408: " + process.platform + "/" + process.arch + "\uFF08\u4EC5 linux/darwin/win32 \xD7 x64/arm64\uFF09");
4881
- }
4882
- return os2 + "-" + arch;
5012
+ return matrix.npmTag();
4883
5013
  }
4884
5014
  /**
4885
5015
  * 探测单个 registry 的可达性 + 延迟。
@@ -7358,20 +7488,14 @@ var require_frpmgr = __commonJS({
7358
7488
  "use strict";
7359
7489
  var fs2 = require("node:fs");
7360
7490
  var path2 = require("node:path");
7491
+ var matrix = require_matrix();
7361
7492
  var http2 = require("node:http");
7362
7493
  var https = require("node:https");
7363
7494
  var { spawn } = require("node:child_process");
7364
7495
  var crypto = require("node:crypto");
7365
7496
  var FRP_VERSION = "0.61.1";
7366
7497
  function frpPlatformTag(platform, arch) {
7367
- const pl = platform || process.platform;
7368
- const ar = arch || process.arch;
7369
- const osMap = { linux: "linux", darwin: "darwin", win32: "windows" };
7370
- const archMap = { x64: "amd64", arm64: "arm64" };
7371
- const os2 = osMap[pl];
7372
- const am = archMap[ar];
7373
- if (!os2 || !am) return null;
7374
- return { os: os2, arch: am, tag: os2 + "_" + am, exe: pl === "win32" };
7498
+ return matrix.frpTag(platform, arch);
7375
7499
  }
7376
7500
  var MIRROR_PREFIXES = [
7377
7501
  "https://ghfast.top/",
@@ -7643,8 +7767,9 @@ var require_frpmgr = __commonJS({
7643
7767
  }
7644
7768
  };
7645
7769
  if (!this.frpTag) {
7646
- if (this.events) this.events.append("frpc_install_failed", { detail: "\u5F53\u524D\u5E73\u53F0\u65E0 frpc \u5B98\u65B9\u4EA7\u7269: " + process.platform + "/" + process.arch });
7647
- return { ok: false, error: "\u5F53\u524D\u5E73\u53F0\u4E0D\u652F\u6301 FRP\uFF08" + process.platform + "/" + process.arch + "\uFF09\uFF0C\u4EC5 linux/darwin/win32 \xD7 x64/arm64" };
7770
+ const cur = matrix.current();
7771
+ if (this.events) this.events.append("frpc_install_failed", { detail: "\u5F53\u524D\u5E73\u53F0\u65E0 frpc \u5B98\u65B9\u4EA7\u7269: " + cur.platform + "/" + cur.arch });
7772
+ return { ok: false, error: "\u5F53\u524D\u5E73\u53F0\u4E0D\u652F\u6301 FRP\uFF08" + cur.platform + "/" + cur.arch + "\uFF09\uFF0C\u4EC5 linux/darwin/win32 \xD7 x64/arm64" };
7648
7773
  }
7649
7774
  const asset = "frp_" + FRP_VERSION + "_" + this.frpTag.tag + ".tar.gz";
7650
7775
  const urls = downloadUrls(asset);
@@ -10361,6 +10486,7 @@ var require_plugins = __commonJS({
10361
10486
  var fs2 = require("node:fs");
10362
10487
  var path2 = require("node:path");
10363
10488
  var os2 = require("node:os");
10489
+ var matrix = require_matrix();
10364
10490
  var { semverCompare } = require_dist();
10365
10491
  var { dirSizeBytes } = require_fs_utils();
10366
10492
  var PROTECTED = /* @__PURE__ */ new Set(["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app"]);
@@ -10728,7 +10854,7 @@ var require_plugins = __commonJS({
10728
10854
  const killTree = (sig) => {
10729
10855
  if (!child) return;
10730
10856
  try {
10731
- if (process.platform !== "win32" && child.pid) process.kill(-child.pid, sig);
10857
+ if (matrix.supportsProcessGroup() && child.pid) process.kill(-child.pid, sig);
10732
10858
  else child.kill(sig);
10733
10859
  } catch {
10734
10860
  try {
@@ -11509,7 +11635,7 @@ var require_watchdog = __commonJS({
11509
11635
  if (inUpdate && !phaseStale) return true;
11510
11636
  try {
11511
11637
  const j = shell.readJournal && shell.readJournal();
11512
- if (j && j.to && !j.confirmed && !j.rolledBack) return true;
11638
+ if (j && j.to && !j.confirmed) return true;
11513
11639
  } catch {
11514
11640
  }
11515
11641
  return false;
@@ -11664,11 +11790,7 @@ var require_shell = __commonJS({
11664
11790
  return readJson(journalPath()) || {
11665
11791
  from: null,
11666
11792
  to: null,
11667
- attempts: 0,
11668
- maxAttempts: 2,
11669
11793
  confirmed: false,
11670
- rolledBack: false,
11671
- pinnedVersions: [],
11672
11794
  startedAt: null,
11673
11795
  lastAttemptAt: null
11674
11796
  };
@@ -11680,9 +11802,7 @@ var require_shell = __commonJS({
11680
11802
  const j = readJournal();
11681
11803
  j.from = from || j.from;
11682
11804
  j.to = to;
11683
- j.attempts = 0;
11684
11805
  j.confirmed = false;
11685
- j.rolledBack = false;
11686
11806
  j.startedAt = (/* @__PURE__ */ new Date()).toISOString();
11687
11807
  writeJournal(j);
11688
11808
  return j;
@@ -11695,45 +11815,19 @@ var require_shell = __commonJS({
11695
11815
  if (cur && cur === j.to && id && id.phase === "ready") {
11696
11816
  if (!j.confirmed) {
11697
11817
  j.confirmed = true;
11698
- j.attempts = 0;
11699
11818
  writeJournal(j);
11700
11819
  }
11701
11820
  return { state: "confirmed", version: cur, reason: "\u58F3\u5DF2\u5065\u5EB7\u8FD0\u884C\u65B0\u7248\u672C", journal: j, identity: id };
11702
11821
  }
11703
- const attempt = id && typeof id.attempt === "number" ? id.attempt : 0;
11704
- if (cur && cur !== j.to && attempt >= (j.maxAttempts || 2)) {
11705
- return {
11706
- state: "should-rollback",
11707
- target: j.to,
11708
- current: cur,
11709
- attempts: attempt,
11710
- reason: `\u58F3 ${attempt} \u6B21\u672A\u80FD\u5728 ${j.to} \u4E0A\u5C31\u7EEA\uFF08\u5F53\u524D ${cur}\uFF09`,
11711
- journal: j,
11712
- identity: id
11713
- };
11714
- }
11715
11822
  return {
11716
11823
  state: "pending",
11717
11824
  target: j.to,
11718
11825
  current: cur,
11719
- attempts: attempt,
11720
11826
  reason: cur === j.to ? "\u7B49\u5F85\u58F3\u4E0A\u62A5\u5C31\u7EEA" : "\u7B49\u5F85\u58F3\u91CD\u542F\u5230\u65B0\u7248\u672C",
11721
11827
  journal: j,
11722
11828
  identity: id
11723
11829
  };
11724
11830
  }
11725
- function rollback(reason) {
11726
- const j = readJournal();
11727
- const bad = j.to;
11728
- if (bad && !j.pinnedVersions.includes(bad)) j.pinnedVersions.push(bad);
11729
- j.rolledBack = true;
11730
- j.confirmed = false;
11731
- j.attempts = 0;
11732
- j.to = null;
11733
- j.lastAttemptAt = (/* @__PURE__ */ new Date()).toISOString();
11734
- writeJournal(j);
11735
- return { ok: true, pinned: bad, reason: reason || null, journal: j };
11736
- }
11737
11831
  function health(payload) {
11738
11832
  const p = payload || {};
11739
11833
  const dir = shellDir();
@@ -11756,7 +11850,6 @@ var require_shell = __commonJS({
11756
11850
  journal: j,
11757
11851
  state: ev.state,
11758
11852
  reason: ev.reason || null,
11759
- pinned: j.pinnedVersions || [],
11760
11853
  dir: shellDir()
11761
11854
  };
11762
11855
  }
@@ -11862,7 +11955,7 @@ var require_shell = __commonJS({
11862
11955
  return { ok: false, error: "\u62C9\u8D77\u65B0\u58F3\u5931\u8D25: " + (e && e.message || e), killed };
11863
11956
  }
11864
11957
  }
11865
- module2.exports = { status, evaluate, health, markPending, rollback, identity, readJournal, shellDir, checkUpdate, restartShell, SHELL_RELEASE_PKG };
11958
+ module2.exports = { status, evaluate, health, markPending, identity, readJournal, shellDir, checkUpdate, restartShell, SHELL_RELEASE_PKG };
11866
11959
  }
11867
11960
  });
11868
11961
 
@@ -16197,26 +16290,6 @@ var require_shell2 = __commonJS({
16197
16290
  return send(r.ok ? 200 : 500, r);
16198
16291
  }).catch((e) => send(500, { ok: false, error: e.message }));
16199
16292
  }
16200
- if (req.method === "POST" && pathname === "/shell/rollback") {
16201
- if (!originAllowed(req, sup.config.apiPort)) {
16202
- req.resume();
16203
- return send(403, {});
16204
- }
16205
- return collectBody(req, res, 8192, (body) => {
16206
- let j = {};
16207
- try {
16208
- j = body ? JSON.parse(body) : {};
16209
- } catch {
16210
- }
16211
- try {
16212
- const r = shell.rollback(j.reason || "manual");
16213
- if (sup.events) sup.events.append("shell_update_rolled_back", { pinned: r.pinned, reason: r.reason });
16214
- return send(200, r);
16215
- } catch (e) {
16216
- return send(500, { ok: false, error: e.message });
16217
- }
16218
- });
16219
- }
16220
16293
  if (req.method === "GET" || req.method === "POST") return send(404, { error: "not found", path: pathname });
16221
16294
  return send(405, { error: "method not allowed" });
16222
16295
  }
@@ -17654,6 +17727,7 @@ var require_settings_view = __commonJS({
17654
17727
  var { spawn } = require("node:child_process");
17655
17728
  var { execFile } = require("node:child_process");
17656
17729
  var ex2 = require_exec();
17730
+ var matrix = require_matrix();
17657
17731
  var netInfo = require_netinfo();
17658
17732
  var { EnvCatalog } = require_env_catalog();
17659
17733
  var { semverCompare } = require_dist();
@@ -17754,7 +17828,7 @@ var require_settings_view = __commonJS({
17754
17828
  }
17755
17829
  /** 守卫自更新「重启生效」衔接:仅当配置 guardRestartAllowed=true 且存在 systemd 用户单元才执行;
17756
17830
  * 否则返回明确指引(避免误杀/误起守卫)。 */
17757
- /** 自更新后的守卫重启(A2):能力按部署形态自动判定(SEA=systemd 重启闭环;源码形态=拒绝),
17831
+ /** 自更新后的守卫重启(A2):能力按部署形态自动判定(打包态=systemd 重启闭环;源码形态=拒绝),
17758
17832
  * 去掉 guardRestartAllowed 人工配置门槛。重启前落盘「预期版本」,重启后 /status 校验自报版本
17759
17833
  * 达标才算更新成功——闭环可观测,不再出现"装了没生效"的静默失败。 */
17760
17834
  guardSelfUpdateRestart() {
@@ -17793,8 +17867,7 @@ var require_settings_view = __commonJS({
17793
17867
  guardCorePkg() {
17794
17868
  const raw = this.config.corePackageName;
17795
17869
  if (!raw) return null;
17796
- const map = { win32: "win", linux: "linux", darwin: "darwin" };
17797
- return String(raw).replace(/{os}/g, map[process.platform] || process.platform).replace(/{arch}/g, String(process.arch)) || null;
17870
+ return String(raw).replace(/{os}/g, matrix.osTag()).replace(/{arch}/g, matrix.current().arch) || null;
17798
17871
  }
17799
17872
  /** 守卫自更新(2026-09 收敛:npm 通道)——查 @dsh-sup/dsh-core-<os>-<arch> 全 tag 最高版本(全更新:
17800
17873
  * BETA/RC/正式都算更新,任一更高即提示可更新),对本机 guardVersion 比较。 */
@@ -19487,6 +19560,7 @@ var require_supervisor = __commonJS({
19487
19560
  var fs2 = require("node:fs");
19488
19561
  var path2 = require("node:path");
19489
19562
  var os2 = require("node:os");
19563
+ var matrix = require_matrix();
19490
19564
  var pidlook = require_pidlookup();
19491
19565
  var { DaemonLifecycle } = require_daemon_lifecycle();
19492
19566
  var platform = require_os();
@@ -20399,7 +20473,7 @@ var require_supervisor = __commonJS({
20399
20473
  if (!this.notifyEnabled) return;
20400
20474
  platform.notify(title, body, () => {
20401
20475
  this.notifyEnabled = false;
20402
- this.logger.warn("\u684C\u9762\u901A\u77E5\u4E0D\u53EF\u7528\uFF08" + process.platform + "\uFF09\uFF0C\u5DF2\u505C\u7528");
20476
+ this.logger.warn("\u684C\u9762\u901A\u77E5\u4E0D\u53EF\u7528\uFF08" + matrix.osTag() + "\uFF09\uFF0C\u5DF2\u505C\u7528");
20403
20477
  });
20404
20478
  }
20405
20479
  // ---- 升级流程挂钩(先停后装,消除运行中替换文件的混合版本窗口)----