@dsh-sup/dsh-core-linux-x64 0.1.6-BETA.17 → 0.1.6-BETA.19

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 +53 -59
  2. package/package.json +1 -1
package/core.cjs CHANGED
@@ -15,9 +15,7 @@ var require_exec = __commonJS({
15
15
  function options(opts) {
16
16
  const o = opts || {};
17
17
  return {
18
- // timeout 是历史别名(兼容旧调用点拼写,若不与 timeoutMs 归一会被静默忽略):
19
- // 两种拼写都收,timeoutMs 优先;新调用一律用 timeoutMs。
20
- timeout: o.timeoutMs || o.timeout || DEFAULT_TIMEOUT_MS,
18
+ timeout: o.timeoutMs || DEFAULT_TIMEOUT_MS,
21
19
  // 必须 SIGKILL:SIGTERM 对挂起或被停住的进程可能无效。
22
20
  killSignal: o.killSignal || "SIGKILL",
23
21
  maxBuffer: o.maxBuffer || DEFAULT_MAX_BUFFER,
@@ -725,33 +723,51 @@ var require_state_root = __commonJS({
725
723
  function legacyShellDir() {
726
724
  return path2.join(os2.homedir(), ".dsh", "shell");
727
725
  }
726
+ function why(e) {
727
+ return (e && e.code ? e.code + ": " : "") + (e && e.message || String(e));
728
+ }
728
729
  function migrateLegacy() {
729
730
  const moved = [];
731
+ const skipped = [];
732
+ const failed = [];
730
733
  for (const [from, to] of [
731
734
  [legacySupervisorDir(), supervisorDir()],
732
735
  [legacyShellDir(), shellDir()]
733
736
  ]) {
737
+ if (!fs2.existsSync(from)) continue;
734
738
  try {
735
- if (!fs2.existsSync(from)) continue;
736
739
  fs2.mkdirSync(to, { recursive: true });
737
- for (const name of fs2.readdirSync(from)) {
738
- const src = path2.join(from, name);
739
- const dst = path2.join(to, name);
740
- if (fs2.existsSync(dst)) continue;
741
- try {
742
- fs2.renameSync(src, dst);
743
- moved.push(src + " -> " + dst);
744
- } catch {
745
- }
740
+ } catch (e) {
741
+ failed.push({ from, entry: null, error: why(e) });
742
+ continue;
743
+ }
744
+ let names = [];
745
+ try {
746
+ names = fs2.readdirSync(from);
747
+ } catch (e) {
748
+ failed.push({ from, entry: null, error: why(e) });
749
+ continue;
750
+ }
751
+ for (const name of names) {
752
+ const src = path2.join(from, name);
753
+ const dst = path2.join(to, name);
754
+ if (fs2.existsSync(dst)) {
755
+ skipped.push(src);
756
+ continue;
746
757
  }
747
758
  try {
748
- if (fs2.readdirSync(from).length === 0) fs2.rmdirSync(from);
749
- } catch {
759
+ fs2.renameSync(src, dst);
760
+ moved.push(src + " -> " + dst);
761
+ } catch (e) {
762
+ failed.push({ from, entry: name, error: why(e) });
750
763
  }
764
+ }
765
+ try {
766
+ if (fs2.readdirSync(from).length === 0) fs2.rmdirSync(from);
751
767
  } catch {
752
768
  }
753
769
  }
754
- return moved;
770
+ return { moved, skipped, failed };
755
771
  }
756
772
  module2.exports = { SCHEMA, root, supervisorDir, shellDir, migrateLegacy };
757
773
  }
@@ -951,7 +967,7 @@ var require_version = __commonJS({
951
967
  var fs2 = require("node:fs");
952
968
  var path2 = require("node:path");
953
969
  function guardVersion() {
954
- if (true) return String("0.1.6-BETA.17");
970
+ if (true) return String("0.1.6-BETA.19");
955
971
  try {
956
972
  return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
957
973
  } catch {
@@ -2490,9 +2506,6 @@ var require_sources = __commonJS({
2490
2506
  _sources.length = 0;
2491
2507
  registerSources(list);
2492
2508
  }
2493
- function getSources() {
2494
- return _sources.map((s) => ({ name: s.name, key: s.key, local: s.local }));
2495
- }
2496
2509
  function resolvedSources() {
2497
2510
  if (_sources.length) return _sources.slice();
2498
2511
  return [normalizeSource(LOCAL_SOURCE, { local: true })];
@@ -2552,7 +2565,6 @@ var require_sources = __commonJS({
2552
2565
  registerSource,
2553
2566
  registerSources,
2554
2567
  setSources,
2555
- getSources,
2556
2568
  resolvedSources,
2557
2569
  registerInternalType,
2558
2570
  setInternalTypes,
@@ -2963,7 +2975,6 @@ var require_hub = __commonJS({
2963
2975
  registerSource: sources.registerSource,
2964
2976
  registerSources: sources.registerSources,
2965
2977
  setSources: sources.setSources,
2966
- getSources: sources.getSources,
2967
2978
  registerInternalType: sources.registerInternalType,
2968
2979
  setInternalTypes: sources.setInternalTypes
2969
2980
  };
@@ -11237,7 +11248,7 @@ var require_signals = __commonJS({
11237
11248
  if (!cmd2) return false;
11238
11249
  const bin = d.config().command && d.config().command[1];
11239
11250
  if (typeof bin === "string" && bin && cmd2.includes(bin)) return true;
11240
- return pidlook.isDshCmdline(pid);
11251
+ return /(^|\s)web(\s|$)/.test(cmd2) && pidlook.isDshCmdline(pid);
11241
11252
  },
11242
11253
  /** 向进程组发信号(detached spawn 的子进程是组长);组信号失败退回单进程。平台层封装:
11243
11254
  * POSIX 组信号;Windows 无组语义则单进程信号,树语义由 killTree 提供。 */
@@ -11942,9 +11953,6 @@ var require_runtime2 = __commonJS({
11942
11953
  events() {
11943
11954
  return host2.events;
11944
11955
  },
11945
- name() {
11946
- return host2.name;
11947
- },
11948
11956
  daemons() {
11949
11957
  return host2.daemons;
11950
11958
  },
@@ -12032,7 +12040,6 @@ var require_runtime2 = __commonJS({
12032
12040
  },
12033
12041
  /** ensure 结果 -> 旧调用方契约翻译(adopted 不带 spawned:避免监督误报“失联重拉”)。 */
12034
12042
  _daemonEnsureResult(lc, writeOwnerLock) {
12035
- const d = depsOf(this);
12036
12043
  const rr = lc.ensureRunning();
12037
12044
  if (rr.mode === "started" || rr.mode === "adopted") {
12038
12045
  if (writeOwnerLock) writeOwnerLock();
@@ -12041,7 +12048,7 @@ var require_runtime2 = __commonJS({
12041
12048
  if (rr.mode === "barrier") return { active: false, mode: "barrier", reason: "\u751F\u547D\u5468\u671F\u7A97\u53E3\u5185" };
12042
12049
  if (rr.mode === "reclaiming") return { active: false, mode: "reclaiming", stale: rr.stale };
12043
12050
  if (rr.mode === "stopping") return { active: false, mode: "stopping" };
12044
- if (rr.mode === "failed") return { active: false, mode: "error", error: rr.error || "daemon \u672A\u542F\u52A8: " + d.name() };
12051
+ if (rr.mode === "failed") return { active: false, mode: "error", error: rr.error || "daemon \u672A\u542F\u52A8: " + lc.name };
12045
12052
  return { active: false, mode: "error", error: "unexpected lifecycle mode: " + rr.mode };
12046
12053
  },
12047
12054
  /** 实例清单+令牌 -> lan-state.json(原子 0600;daemon 轮询消费)。hash 相同不落盘。 */
@@ -14227,7 +14234,6 @@ var require_facets = __commonJS({
14227
14234
  }
14228
14235
  if (f.mod.methods) installMethods(host2, f.mod.methods);
14229
14236
  if (f.mod.accessors) installAccessors(host2, f.mod.accessors);
14230
- if (typeof f.mod.buildFieldHelpers === "function") f.mod.buildFieldHelpers(host2);
14231
14237
  }
14232
14238
  installCollaborators(host2, { validate: true });
14233
14239
  }
@@ -15395,7 +15401,7 @@ var require_task_store = __commonJS({
15395
15401
  if (t && t.id && !mine.has(t.id)) mine.set(t.id, t);
15396
15402
  }
15397
15403
  merged = Array.from(mine.values());
15398
- merged.sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0));
15404
+ merged.sort((a, b) => (b.startedAt || 0) - (a.startedAt || 0));
15399
15405
  if (merged.length > maxTasks) merged = merged.slice(0, maxTasks);
15400
15406
  }
15401
15407
  writeTasks(file, merged);
@@ -15934,7 +15940,6 @@ var require_core5 = __commonJS({
15934
15940
  host2._routerFacade = null;
15935
15941
  host2._lc = null;
15936
15942
  host2._dshMainLive = null;
15937
- host2._lastStateBody = null;
15938
15943
  host2._shadowSeq = 0;
15939
15944
  host2._shadowConsistentBeats = 0;
15940
15945
  host2._shadowDiffBeats = 0;
@@ -16284,15 +16289,7 @@ var require_quota = __commonJS({
16284
16289
  const now = typeof q.monthlyRemaining === "number" && Number.isFinite(q.monthlyRemaining) ? q.monthlyRemaining : q.credits && typeof q.credits.monthlyCredits === "number" ? q.credits.monthlyCredits : NaN;
16285
16290
  return Number.isFinite(now) && now > base;
16286
16291
  }
16287
- function quotaPercent(acc) {
16288
- const q = acc && acc.quota || {};
16289
- let max = 0;
16290
- for (const w of [q.rolling, q.weekly, q.monthly]) {
16291
- if (w && Number.isFinite(Number(w.percent))) max = Math.max(max, Number(w.percent));
16292
- }
16293
- return max;
16294
- }
16295
- module2.exports = { classifyUpstreamLimited, headerRetryMs, bodyResetMs, normalizeResetTs, fmtClock, isQuotaCreditsLow, quotaOverallStatus, monthlyResetAtOf, accountQuotaSummary, windowExhausted, nextResetAt, creditsResetDue, creditsRefilled, quotaPercent };
16292
+ module2.exports = { classifyUpstreamLimited, headerRetryMs, bodyResetMs, normalizeResetTs, fmtClock, isQuotaCreditsLow, quotaOverallStatus, monthlyResetAtOf, accountQuotaSummary, windowExhausted, nextResetAt, creditsResetDue, creditsRefilled };
16296
16293
  }
16297
16294
  });
16298
16295
 
@@ -16982,10 +16979,7 @@ var require_model2 = __commonJS({
16982
16979
  i.port = o.port || null;
16983
16980
  return i;
16984
16981
  }
16985
- function stateContainer(opts) {
16986
- return new ProxyInstance(opts || {});
16987
- }
16988
- module2.exports = { ProxyInstance, INSTANCE_STATES, isServable, occupiesSlot, stateContainer, serializeInstance, deserializeInstance };
16982
+ module2.exports = { ProxyInstance, INSTANCE_STATES, isServable, occupiesSlot, serializeInstance, deserializeInstance };
16989
16983
  }
16990
16984
  });
16991
16985
 
@@ -20229,8 +20223,6 @@ var require_views = __commonJS({
20229
20223
  keyId: a.keyId,
20230
20224
  maskedKey: a.maskedKey,
20231
20225
  status: a.status,
20232
- validity: a.status,
20233
- // 兼容字段(=status,避免旧前端读 undefined)
20234
20226
  usage: usageOf,
20235
20227
  // 纯派生(activeAccount/实例实况)
20236
20228
  quota: a.quota || null,
@@ -22262,11 +22254,7 @@ var require_dsh_install = __commonJS({
22262
22254
  if (r.ok && r.version) _latestDsh = Object.assign({ at: Date.now() }, r);
22263
22255
  return r;
22264
22256
  }
22265
- async function latestDshVersion() {
22266
- const r = await latestDsh();
22267
- return r.version;
22268
- }
22269
- return { installSandbox, readInstalledVersion, latestDsh, latestDshVersion };
22257
+ return { installSandbox, readInstalledVersion, latestDsh };
22270
22258
  }
22271
22259
  module2.exports = { createDshInstall };
22272
22260
  }
@@ -22317,9 +22305,6 @@ var require_upgrade = __commonJS({
22317
22305
  async function latestDsh() {
22318
22306
  return install.latestDsh();
22319
22307
  }
22320
- async function latestDshVersion() {
22321
- return install.latestDshVersion();
22322
- }
22323
22308
  function versionInfo(inst) {
22324
22309
  const cached = _updCache[inst.id];
22325
22310
  return { version: readInstalledVersion(inst), latest: cached && cached.latest || null };
@@ -22565,7 +22550,7 @@ var require_upgrade = __commonJS({
22565
22550
  if (!job) return { error: "no upgrade job for " + id };
22566
22551
  return { state: job.state, step: job.step, errors: job.errors, error: job.error, startedAt: job.startedAt, finishedAt: job.finishedAt };
22567
22552
  }
22568
- return { _scheduleJobCleanup, installSandbox, readInstalledVersion, latestDshVersion, versionInfo, jobView, checkUpdate, upgradeInstance, upgradeStatus };
22553
+ return { _scheduleJobCleanup, installSandbox, readInstalledVersion, versionInfo, jobView, checkUpdate, upgradeInstance, upgradeStatus };
22569
22554
  }
22570
22555
  module2.exports = { createUpgrade };
22571
22556
  }
@@ -30308,9 +30293,19 @@ function releaseLock() {
30308
30293
  } catch {
30309
30294
  }
30310
30295
  }
30296
+ function migrateStateRoot() {
30297
+ const r = stateRoot.migrateLegacy();
30298
+ for (const m of r.moved) console.log("[migrate] \u72B6\u6001\u76EE\u5F55\u8FC1\u79FB: " + m);
30299
+ for (const s of r.skipped) console.log("[migrate] \u65E7\u6761\u76EE\u4EE5\u65B0\u6839\u540C\u540D\u6587\u4EF6\u4E3A\u51C6\uFF0C\u539F\u6837\u7559\u5728: " + s);
30300
+ if (!r.failed.length) return;
30301
+ for (const f of r.failed) {
30302
+ console.error("[migrate] \u642C\u8FC1\u5931\u8D25: " + f.from + (f.entry ? "/" + f.entry : "") + " \u2014\u2014 " + f.error);
30303
+ }
30304
+ console.error("[migrate] \u62D2\u7EDD\u542F\u52A8\uFF1A\u65E7\u72B6\u6001\u672A\u5B8C\u6574\u8FC1\u81F3\u4EA7\u54C1\u72B6\u6001\u6839 " + stateRoot.root() + "\uFF08\u672C\u6B21\u672A\u5728\u65B0\u6839\u5199\u5165\u4EFB\u4F55\u914D\u7F6E\uFF09\u3002\u8BF7\u4FEE\u6B63\u4E0A\u8FF0\u76EE\u5F55\u6743\u9650/\u6302\u8F7D\u70B9\uFF0C\u6216\u4EE5\u540C\u7528\u6237\u624B\u5DE5\u642C\u79FB\u540E\u91CD\u8BD5\u3002");
30305
+ process.exit(1);
30306
+ }
30311
30307
  function cmdDaemon() {
30312
- const moved = stateRoot.migrateLegacy();
30313
- for (const m of moved) console.log("[migrate] \u72B6\u6001\u76EE\u5F55\u8FC1\u79FB: " + m);
30308
+ migrateStateRoot();
30314
30309
  const lock = acquireLock();
30315
30310
  if (lock !== true) {
30316
30311
  console.error("[supervisor] \u672C\u8FDB\u7A0B\u9000\u51FA\uFF1A\u672A\u53D6\u5F97\u5B88\u536B\u9501\uFF08\u9501 " + LOCK_FILE + "\uFF09\u2014\u2014 " + lock);
@@ -30428,8 +30423,7 @@ function finishControl(r) {
30428
30423
  }
30429
30424
  }
30430
30425
  function cmdInstall() {
30431
- const moved = stateRoot.migrateLegacy();
30432
- for (const m of moved) console.log("[migrate] \u72B6\u6001\u76EE\u5F55\u8FC1\u79FB: " + m);
30426
+ migrateStateRoot();
30433
30427
  fs.mkdirSync(SUPERVISOR_DIR, { recursive: true });
30434
30428
  if (!fs.existsSync(USER_CONFIG)) {
30435
30429
  fs.mkdirSync(SUPERVISOR_DIR, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-sup/dsh-core-linux-x64",
3
- "version": "0.1.6-BETA.17",
3
+ "version": "0.1.6-BETA.19",
4
4
  "description": "DSH lifecycle guard core (Node launcher) for linux-x64 — requires Node >=18.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {