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

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 +165 -195
  2. package/package.json +1 -1
package/core.cjs CHANGED
@@ -972,8 +972,6 @@ var require_brand = __commonJS({
972
972
  var ENV_PLATFORM_OVERRIDE = "DSH_PLATFORM_OVERRIDE";
973
973
  var ENV_ESBUILD_VERSION = "DSH_ESBUILD_VERSION";
974
974
  var ENV_VERSION_LIB = "DSH_VERSION_LIB";
975
- var WINDOWS_GUARD_TASK = "Lobox";
976
- var WINDOWS_WATCHDOG_TASK = "Lobox-Watchdog";
977
975
  var WINDOWS_GUI_TASK = "Lobox-Shell";
978
976
  var WINDOWS_RUN_VALUE = "Lobox";
979
977
  var SYSTEMD_UNIT_NAME = "lobox";
@@ -1094,8 +1092,6 @@ var require_brand = __commonJS({
1094
1092
  ENV_PLATFORM_OVERRIDE,
1095
1093
  ENV_ESBUILD_VERSION,
1096
1094
  ENV_VERSION_LIB,
1097
- WINDOWS_GUARD_TASK,
1098
- WINDOWS_WATCHDOG_TASK,
1099
1095
  WINDOWS_GUI_TASK,
1100
1096
  WINDOWS_RUN_VALUE,
1101
1097
  SYSTEMD_UNIT_NAME,
@@ -1471,7 +1467,7 @@ var require_version = __commonJS({
1471
1467
  var fs2 = require("node:fs");
1472
1468
  var path2 = require("node:path");
1473
1469
  function guardVersion() {
1474
- if (true) return String("0.0.14");
1470
+ if (true) return String("0.0.16");
1475
1471
  try {
1476
1472
  return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
1477
1473
  } catch {
@@ -6648,12 +6644,6 @@ var require_portable = __commonJS({
6648
6644
  var OUTCOME = require_outcome();
6649
6645
  var STOP_WAIT_CAP_MS = 3e3;
6650
6646
  var NAP_MS = 150;
6651
- function nap(ms) {
6652
- try {
6653
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
6654
- } catch {
6655
- }
6656
- }
6657
6647
  function readPidFile(pidFile) {
6658
6648
  if (!pidFile) return null;
6659
6649
  try {
@@ -6667,7 +6657,7 @@ var require_portable = __commonJS({
6667
6657
  if (!pid || !Array.isArray(anchors) || !anchors.length) return false;
6668
6658
  const cmd2 = pidlookup.readCmdline(pid);
6669
6659
  if (!cmd2) return false;
6670
- return anchors.every((a) => a && cmd2.indexOf(String(a)) !== -1);
6660
+ return anchors.some((a) => a && cmd2.indexOf(String(a)) !== -1);
6671
6661
  }
6672
6662
  var portOf = (o) => {
6673
6663
  const p = Number(o && o.port);
@@ -6710,6 +6700,15 @@ var require_portable = __commonJS({
6710
6700
  kind: "portable",
6711
6701
  supportsUnits: false,
6712
6702
  supportsTransient: true,
6703
+ /**
6704
+ * 能力协商(根因 B 修法;与 router 域 `supports(cap)` 同一范式,下沉到平台层)。
6705
+ *
6706
+ * 判据来源:capability-profile.js 的 sandboxEnforcement —— 三平台均为 'supervise'
6707
+ * (= 产品自身监控,**无 cgroup 级强制**)。此前该字段全仓 0 处查询,
6708
+ * 于是 governor 在"限额根本无法生效"的前提下仍判违规并重启 ⇒ 永动机(P0)。
6709
+ *
6710
+ * 调用方(governor)必须先问后处置:不支持限额 ⇒ 只观测,绝不重启。
6711
+ */
6713
6712
  supports(cap) {
6714
6713
  if (cap === "treeKill") return true;
6715
6714
  if (cap === "limits") return false;
@@ -6790,73 +6789,19 @@ var require_portable = __commonJS({
6790
6789
  }
6791
6790
  return false;
6792
6791
  },
6793
- daemonReload() {
6794
- return true;
6795
- },
6796
- resetFailed() {
6797
- return true;
6798
- },
6799
- startTransient(o) {
6800
- const opts = o || {};
6801
- const cmd2 = opts.cmd || [];
6802
- if (!cmd2.length) throw new Error("portable \u62C9\u8D77\u62D2\u7EDD\uFF1A\u7A7A\u547D\u4EE4");
6803
- const child = spawner.detached(cmd2[0], cmd2.slice(1), {
6804
- cwd: opts.workingDir || void 0,
6805
- env: Object.assign({}, process.env, opts.env || {})
6806
- });
6807
- child.on("error", () => {
6808
- });
6809
- if (!child.pid) {
6810
- try {
6811
- child.kill();
6812
- } catch {
6813
- }
6814
- throw new Error("portable \u62C9\u8D77\u5931\u8D25\uFF1Aspawn \u672A\u4EA7\u751F\u8FDB\u7A0B");
6815
- }
6816
- try {
6817
- child.unref();
6818
- } catch {
6819
- }
6820
- if (opts.pidFile) {
6821
- try {
6822
- fs2.writeFileSync(opts.pidFile, String(child.pid));
6823
- } catch {
6824
- }
6825
- }
6826
- return true;
6827
- },
6828
- stopUnit(unit, o) {
6829
- const opts = o || {};
6830
- const ours = findOurs(opts);
6831
- if (!ours) {
6832
- removePidFile(opts);
6833
- return true;
6834
- }
6835
- try {
6836
- procOS.killTree(ours.pid, "SIGTERM", void 0, { ownGroup: ours.ownGroup });
6837
- } catch {
6838
- }
6839
- const budget = Math.max(0, Math.min(typeof opts.timeoutMs === "number" ? opts.timeoutMs : STOP_WAIT_CAP_MS, STOP_WAIT_CAP_MS));
6840
- const t0 = Date.now();
6841
- for (; ; ) {
6842
- if (!findOurs(opts)) {
6843
- removePidFile(opts);
6844
- return true;
6845
- }
6846
- if (Date.now() - t0 >= budget) break;
6847
- nap(NAP_MS);
6848
- }
6849
- try {
6850
- procOS.killTree(ours.pid, "SIGKILL", void 0, { ownGroup: ours.ownGroup });
6851
- } catch {
6852
- }
6853
- nap(NAP_MS);
6854
- if (!findOurs(opts)) {
6855
- removePidFile(opts);
6856
- return true;
6857
- }
6858
- return false;
6859
- },
6792
+ /**
6793
+ * 单元是否活跃 —— 返回 Outcome 三态(根因 A 修法)。
6794
+ *
6795
+ * 此前返回 null 表示"未知",而调用方 instance/ops.js:67 用 `active !== false` 判,
6796
+ * 于是 null(未知)被当成"仍活跃" ⇒ removeInstance 把未知报成删除成功(P0)。
6797
+ *
6798
+ * 关键修正:**无 anchors 时不得把"有人在监听"当成"我们的实例在跑"**。
6799
+ * 端口是共享事实、不是身份(与 monitor.js#matchesAnchors 同一条判据);
6800
+ * 缺锚点即无从验证身份 ⇒ 如实返回 unknown,由调用方决定(升级校验须失败并回滚)。
6801
+ *
6802
+ * 兼容:既有调用方若直接判真假,Outcome 对象恒为真值,行为同"true",不会静默反转;
6803
+ * 但显式判据(isOk/isFail/isUnknown)才能区分三态——见 shared/outcome.js。
6804
+ */
6860
6805
  isUnitActive(unit, o) {
6861
6806
  const opts = o || {};
6862
6807
  if (findOurs(opts)) return OUTCOME.OK;
@@ -7413,10 +7358,8 @@ var require_win32 = __commonJS({
7413
7358
  }
7414
7359
  }
7415
7360
  function status() {
7416
- const guard = hasTask(BRAND2.WINDOWS_GUARD_TASK);
7417
7361
  const gui = hasTask(BRAND2.WINDOWS_GUI_TASK);
7418
- const watchdog = hasTask(BRAND2.WINDOWS_WATCHDOG_TASK);
7419
- return { kind: "schtasks", on: guard || gui || watchdog, gui, watchdog, guard };
7362
+ return { kind: "schtasks", on: gui, gui };
7420
7363
  }
7421
7364
  function setAutostart(on, deps) {
7422
7365
  const errors = [];
@@ -7709,13 +7652,7 @@ var require_autostart = __commonJS({
7709
7652
  var isLinux = process.platform === "linux";
7710
7653
  var isMac = process.platform === "darwin";
7711
7654
  var isWindows = process.platform === "win32";
7712
- var CLI_EXE = isWindows ? BRAND2.CLI_NAME + ".exe" : BRAND2.CLI_NAME;
7713
7655
  var GUI_EXE = isWindows ? BRAND2.GUI_BIN_NAME + ".exe" : BRAND2.GUI_BIN_NAME;
7714
- function daemonCommand() {
7715
- const hit = resolveExecutable(BRAND2.CLI_NAME, { envVar: BRAND2.ENV_DAEMON });
7716
- if (hit) return hit;
7717
- return path2.join(os2.homedir(), ".local", "bin", CLI_EXE);
7718
- }
7719
7656
  function guiCommand() {
7720
7657
  const hit = resolveExecutable(BRAND2.GUI_BIN_NAME, { envVar: BRAND2.ENV_SHELL_EXE });
7721
7658
  if (hit) return hit;
@@ -7753,7 +7690,7 @@ var require_autostart = __commonJS({
7753
7690
  if (pl !== "linux") return { ok: false, unsupported: true, platform: pl, enabled: false, error: "\u672A\u77E5\u5E73\u53F0" };
7754
7691
  return linux.setGuiAutostart(on, DEPS);
7755
7692
  }
7756
- module2.exports = { status, setAutostart, setGuiAutostart, daemonCommand, guiCommand };
7693
+ module2.exports = { status, setAutostart, setGuiAutostart, guiCommand };
7757
7694
  }
7758
7695
  });
7759
7696
 
@@ -7884,28 +7821,8 @@ var require_bootstrap = __commonJS({
7884
7821
  const beat = host._beatScheduler;
7885
7822
  const tickMs = host.config.tickIntervalMs || 5e3;
7886
7823
  beat.unregister("main");
7887
- beat.unregister("heartbeat");
7888
- beat.unregister("instance-supervise");
7889
7824
  beat.unregister("upgrade-check");
7890
7825
  beat.register("main", () => host.tick(), { every: 1 });
7891
- beat.register("heartbeat", () => {
7892
- if (host.managedObjects) return host.managedObjects.heartbeat(tickMs);
7893
- return host.tick();
7894
- }, { every: 1, timeoutMs: Math.max(3e4, tickMs * 12) });
7895
- beat.register("instance-supervise", async () => {
7896
- if (!host.instances) return;
7897
- try {
7898
- for (const inst of host.instances.all()) {
7899
- if (inst.domain === "native") continue;
7900
- host.instances.supervise && host.instances.supervise(inst.id);
7901
- }
7902
- } catch (e) {
7903
- }
7904
- try {
7905
- host.instances.governSweep && host.instances.governSweep();
7906
- } catch (e) {
7907
- }
7908
- }, { every: 1 });
7909
7826
  if (host.config.updateCheckEnabled !== false) {
7910
7827
  const checkDelayMs2 = host.config.initialCheckDelayMs || 2e4;
7911
7828
  const checkIntervalMs2 = Math.max(1, Math.round((host.config.updateCheckIntervalMs || 36e5) / tickMs));
@@ -7918,13 +7835,6 @@ var require_bootstrap = __commonJS({
7918
7835
  }
7919
7836
  beat.tick();
7920
7837
  beat.start(tickMs);
7921
- host._timer = null;
7922
- host._heartbeatTimer = null;
7923
- host._upgradeTimer = null;
7924
- host._initialCheckTimer = null;
7925
- host._lastHeartbeatAt = Date.now();
7926
- host._heartbeatStalls = 0;
7927
- host._heartbeatBeat = host._heartbeatBeat || 0;
7928
7838
  if (host.lanDaemonEnabled()) {
7929
7839
  host._syncLanState();
7930
7840
  const lrt = host._ensureLanRuntime(true);
@@ -8052,13 +7962,7 @@ var require_bootstrap = __commonJS({
8052
7962
  const isBare = policies.isBareCommand(cur);
8053
7963
  if (!isBare) return;
8054
7964
  const d = execPath.resolveDsh();
8055
- if (!d || !d.bin) {
8056
- try {
8057
- host.logger.warn && host.logger.warn("\u539F\u751F DSH \u542F\u52A8\u671F\u7ED1\u5B9A\u8DF3\u8FC7\uFF1A\u672A\u89E3\u6790\u5230\u5165\u53E3\uFF08PATH \u53EF\u80FD\u5C1A\u672A\u767B\u8BB0\uFF09\uFF1Bspawn \u671F\u4F1A\u518D\u6B21\u89E3\u6790");
8058
- } catch {
8059
- }
8060
- return;
8061
- }
7965
+ if (!d || !d.bin) return;
8062
7966
  host.config.command = d.isJs ? [d.runtime || process.execPath, d.bin, ...cmd2.slice(2)] : [d.bin, ...cmd2.slice(2)];
8063
7967
  try {
8064
7968
  host.events && host.events.append(BRAND2.EVENT_HARNESS_COMMAND_BOUND, { from: cur || null, to: host.config.command[1] });
@@ -8847,36 +8751,9 @@ var require_registry3 = __commonJS({
8847
8751
  var policies = require_policies2();
8848
8752
  var ref = require_registry_ref();
8849
8753
  var config = require_registry_config();
8850
- var PROBE_MAX_BODY_BYTES = 8 * 1024 * 1024;
8851
8754
  function platformTag() {
8852
8755
  return matrix.npmTag();
8853
8756
  }
8854
- async function probeRegistry(state, origin) {
8855
- const spec = state.contract && state.contract.ok && state.contract.probe || null;
8856
- let tag = null;
8857
- try {
8858
- if (matrix.isSupported()) tag = platformTag();
8859
- } catch {
8860
- tag = null;
8861
- }
8862
- const target = policies.resolveProbe(origin, spec, tag);
8863
- if (!target.url) {
8864
- return { ok: false, latencyMs: 0, probe: target.kind, error: target.violation || "\u955C\u50CF\u57FA\u5740\u975E\u6CD5" };
8865
- }
8866
- const start = Date.now();
8867
- const r = await ref.fetchRegistry(target.url, {
8868
- timeoutMs: target.timeoutMs,
8869
- expect: "text",
8870
- maxBytes: PROBE_MAX_BODY_BYTES
8871
- });
8872
- return { ok: !!r.ok, latencyMs: Date.now() - start, probe: target.kind, error: r.error || null };
8873
- }
8874
- async function probeOrigin(state, origin) {
8875
- const parsed = ref.parseRegistryBase(origin);
8876
- if (!parsed.ok) return { origin: ref.normalizeBase(origin), ok: false, latencyMs: null, error: parsed.violation };
8877
- const p = await probeRegistry(state, parsed.base);
8878
- return { origin: parsed.base, ok: !!p.ok, latencyMs: p.latencyMs, probe: p.probe, error: p.error || null };
8879
- }
8880
8757
  function registryOrigins(state) {
8881
8758
  const seen = /* @__PURE__ */ new Set();
8882
8759
  const out = [];
@@ -8889,21 +8766,13 @@ var require_registry3 = __commonJS({
8889
8766
  }
8890
8767
  return out;
8891
8768
  }
8892
- async function probeAllOrigins(state, origins) {
8893
- const results = await Promise.all(origins.map(async (origin) => {
8894
- const p = await probeRegistry(state, origin);
8895
- return { origin, ok: !!p.ok, latencyMs: p.latencyMs, error: p.error || null };
8896
- }));
8897
- results.sort((a, b) => a.ok === b.ok ? a.latencyMs - b.latencyMs : a.ok ? -1 : 1);
8898
- return results;
8899
- }
8900
8769
  async function probeOrAdopt(state, origins) {
8901
8770
  const c = state.contract;
8902
8771
  if (c && c.ok) {
8903
8772
  const adopted = policies.shellProbeResults(origins, c.measurements, Math.floor(Date.now() / 1e3));
8904
8773
  if (adopted) return adopted;
8905
8774
  }
8906
- return probeAllOrigins(state, origins);
8775
+ return (origins || []).map((origin) => ({ origin, ok: false, latencyMs: null, error: "shell-contract \u672A\u63D0\u4F9B\u6D4B\u901F\u7ED3\u679C\uFF08\u955C\u50CF\u6E90\u5F52\u58F3\u4FA7\u5E95\u5EA7\uFF09", from: "no-contract" }));
8907
8776
  }
8908
8777
  function orderFor(primary, origins, results) {
8909
8778
  const usable = (o) => ref.parseRegistryBase(o).ok;
@@ -9038,9 +8907,6 @@ var require_registry3 = __commonJS({
9038
8907
  }
9039
8908
  module2.exports = {
9040
8909
  platformTag,
9041
- probeRegistry,
9042
- probeOrigin,
9043
- probeAllOrigins,
9044
8910
  registryOrigins,
9045
8911
  orderFor,
9046
8912
  selectRegistry,
@@ -12986,37 +12852,27 @@ var require_env = __commonJS({
12986
12852
  var require_node_lts = __commonJS({
12987
12853
  "src/app/settings/node-lts.js"(exports2, module2) {
12988
12854
  "use strict";
12989
- var fs2 = require("node:fs");
12990
- var path2 = require("node:path");
12855
+ var runtimeContract = require_runtime();
12991
12856
  module2.exports = {
12992
12857
  methods: {
12993
12858
  async nodeLtsStatus() {
12994
12859
  try {
12995
- const cacheFile = path2.join(path2.dirname(this.config.stateFile), "node-lts-cache.json");
12996
12860
  const now = Date.now();
12997
- let cache = null;
12998
- try {
12999
- if (fs2.existsSync(cacheFile)) cache = JSON.parse(fs2.readFileSync(cacheFile, "utf8"));
13000
- } catch {
13001
- }
13002
- if (cache && now - (cache.fetchedAt || 0) < 6 * 3600 * 1e3) {
13003
- return { ok: true, ...cache, cached: true };
13004
- }
13005
- const ver = process.versions.node || "";
12861
+ const rt = runtimeContract.read ? runtimeContract.read() : null;
12862
+ const shellVer = rt && rt.nodeVersion || null;
12863
+ const ver = shellVer || process.versions.node || "";
13006
12864
  const major = parseInt(String(ver).split(".")[0], 10) || 0;
13007
- const ltsLine = major % 2 === 0;
13008
- const data = {
12865
+ const fromShell = !!shellVer;
12866
+ return {
12867
+ ok: true,
13009
12868
  current: ver,
13010
12869
  major,
13011
- ltsLine,
13012
- suggested: "\u5F53\u524D " + ver + (ltsLine ? "\uFF08\u5076\u6570\u4E3B\u7248\u672C\u7EBF\uFF0C\u901A\u5E38\u4E3A LTS\uFF09" : "\uFF08\u5947\u6570\u4E3B\u7248\u672C\u975E LTS \u7EBF\uFF0C\u5EFA\u8BAE\u5076\u6570\u4E3B\u7248\u672C\uFF09"),
13013
- fetchedAt: now
12870
+ ltsLine: fromShell ? rt && rt.ltsLine === true : null,
12871
+ source: fromShell ? "shell-contract" : "process",
12872
+ suggested: fromShell ? "\u5F53\u524D " + ver + (rt && rt.ltsLine === true ? "\uFF08LTS \u7EBF\uFF09" : "") : "shell \u5951\u7EA6\u672A\u63D0\u4F9B Node \u7248\u672C",
12873
+ fetchedAt: now,
12874
+ cached: false
13014
12875
  };
13015
- try {
13016
- fs2.writeFileSync(cacheFile, JSON.stringify(data));
13017
- } catch {
13018
- }
13019
- return { ok: true, ...data, cached: false };
13020
12876
  } catch (e) {
13021
12877
  return { ok: false, error: e.message };
13022
12878
  }
@@ -24324,6 +24180,122 @@ var require_managed_object = __commonJS({
24324
24180
  }
24325
24181
  });
24326
24182
 
24183
+ // src/platform/contract/pm-client.js
24184
+ var require_pm_client = __commonJS({
24185
+ "src/platform/contract/pm-client.js"(exports2, module2) {
24186
+ "use strict";
24187
+ var fs2 = require("node:fs");
24188
+ var path2 = require("node:path");
24189
+ var http2 = require("node:http");
24190
+ var stateRoot2 = require_state_root();
24191
+ var pidlookup = require_pidlookup();
24192
+ var FILE_NAME = "guard-mgmt.json";
24193
+ var SUPPORTED_SCHEMA = 1;
24194
+ var HOST = "127.0.0.1";
24195
+ var TIMEOUT_MS = 1500;
24196
+ var unavailableHook = null;
24197
+ function setUnavailableHook(fn) {
24198
+ unavailableHook = typeof fn === "function" ? fn : null;
24199
+ }
24200
+ function file() {
24201
+ return path2.join(stateRoot2.supervisorDir(), FILE_NAME);
24202
+ }
24203
+ function pidAlive2(pid) {
24204
+ if (!Number.isInteger(pid) || pid <= 0) return false;
24205
+ return pidlookup.probeAlive(pid) === "alive";
24206
+ }
24207
+ function endpoint() {
24208
+ let text;
24209
+ try {
24210
+ text = fs2.readFileSync(file(), "utf8");
24211
+ } catch {
24212
+ return null;
24213
+ }
24214
+ let j;
24215
+ try {
24216
+ j = JSON.parse(text);
24217
+ } catch {
24218
+ return null;
24219
+ }
24220
+ if (!j || typeof j !== "object" || j.schema !== SUPPORTED_SCHEMA) return null;
24221
+ const port = Number(j.port);
24222
+ if (!Number.isInteger(port) || port <= 0 || port > 65535) return null;
24223
+ if (!pidAlive2(Number(j.pid))) return null;
24224
+ return { port, host: typeof j.host === "string" && j.host ? j.host : HOST };
24225
+ }
24226
+ function post(route, payload) {
24227
+ const ep = endpoint();
24228
+ if (!ep) {
24229
+ if (unavailableHook) {
24230
+ try {
24231
+ unavailableHook(route);
24232
+ } catch {
24233
+ }
24234
+ }
24235
+ return false;
24236
+ }
24237
+ let body;
24238
+ try {
24239
+ body = JSON.stringify(payload || {});
24240
+ } catch {
24241
+ return false;
24242
+ }
24243
+ const req = http2.request(
24244
+ {
24245
+ host: ep.host,
24246
+ port: ep.port,
24247
+ path: route,
24248
+ method: "POST",
24249
+ headers: { "content-type": "application/json", "content-length": Buffer.byteLength(body) },
24250
+ timeout: TIMEOUT_MS
24251
+ },
24252
+ (res) => {
24253
+ res.resume();
24254
+ }
24255
+ );
24256
+ req.on("timeout", () => {
24257
+ try {
24258
+ req.destroy();
24259
+ } catch {
24260
+ }
24261
+ });
24262
+ req.on("error", () => {
24263
+ });
24264
+ try {
24265
+ req.end(body);
24266
+ return true;
24267
+ } catch {
24268
+ return false;
24269
+ }
24270
+ }
24271
+ module2.exports = {
24272
+ FILE_NAME,
24273
+ SUPPORTED_SCHEMA,
24274
+ file,
24275
+ endpoint,
24276
+ setUnavailableHook,
24277
+ register(desc) {
24278
+ return post("/pm/register", desc);
24279
+ },
24280
+ setDesired(id, desired) {
24281
+ return post("/pm/set-desired", { id, desired });
24282
+ },
24283
+ onPhase(id, phase) {
24284
+ return post("/pm/on-phase", { id, phase });
24285
+ },
24286
+ recordExit(id, code, signal, startupFailure) {
24287
+ return post("/pm/record-exit", { id, code, signal, startup_failure: startupFailure === true });
24288
+ },
24289
+ requestRestart(id) {
24290
+ return post("/pm/request-restart", { id });
24291
+ },
24292
+ resetBackoff(id) {
24293
+ return post("/pm/reset-backoff", { id });
24294
+ }
24295
+ };
24296
+ }
24297
+ });
24298
+
24327
24299
  // src/app/control/registry.js
24328
24300
  var require_registry4 = __commonJS({
24329
24301
  "src/app/control/registry.js"(exports2, module2) {
@@ -24332,15 +24304,11 @@ var require_registry4 = __commonJS({
24332
24304
  var path2 = require("node:path");
24333
24305
  var { writeAtomic } = require_fs();
24334
24306
  var { DESIRED, MANAGED_KINDS, kindMeta, registerKind: registerManagedKind, createEntry, normalizeOwnership } = require_managed_object();
24335
- var { legacyToEntryPhase } = require_phase();
24336
24307
  var PHASES = ["stopped", "installing", "starting", "running", "draining", "failed"];
24337
- var configDefaults = require_config();
24338
- var RESTART_FALLBACK = { windowMs: 6e4, burst: 5 };
24339
- var restartDefaults = () => {
24340
- const r = configDefaults && configDefaults.restart;
24341
- if (r && Number.isFinite(r.windowMs) && Number.isFinite(r.burst)) return { windowMs: r.windowMs, burst: r.burst };
24342
- return RESTART_FALLBACK;
24343
- };
24308
+ var LEGACY_PHASES = { backoff: "failed", restarting: "starting" };
24309
+ var pmClient = require_pm_client();
24310
+ var PM_PHASE = { installing: "starting" };
24311
+ var pmPhase = (p) => PM_PHASE[p] || p;
24344
24312
  var ManagedRegistry = class {
24345
24313
  constructor(opts) {
24346
24314
  this.file = opts && opts.file;
@@ -24386,8 +24354,7 @@ var require_registry4 = __commonJS({
24386
24354
  try {
24387
24355
  if (!o || !kindMeta(o.kind)) continue;
24388
24356
  const e = createEntry({ kind: o.kind, id: o.id, name: o.name, desired: o.desired, ownership: o.ownership });
24389
- const np = legacyToEntryPhase(o.phase);
24390
- if (PHASES.includes(np)) e.phase = np;
24357
+ if (PHASES.includes(LEGACY_PHASES[o.phase] || o.phase)) e.phase = LEGACY_PHASES[o.phase] || o.phase;
24391
24358
  if (Number.isInteger(o.restartCount) && o.restartCount >= 0) e.restartCount = o.restartCount;
24392
24359
  if (o.startupFailWindowStart === null || typeof o.startupFailWindowStart === "number") e.startupFailWindowStart = o.startupFailWindowStart;
24393
24360
  if (Number.isInteger(o.startupFailCount) && o.startupFailCount >= 0) e.startupFailCount = o.startupFailCount;
@@ -24474,7 +24441,7 @@ var require_registry4 = __commonJS({
24474
24441
  this._syncPortsOwner(e, true);
24475
24442
  this._save();
24476
24443
  this._event("managed_object_registered", { kind: e.kind, id: e.id, name: e.name });
24477
- const rd = restartDefaults();
24444
+ pmClient.register({ id: e.id, spawn_cmd: [] });
24478
24445
  return e;
24479
24446
  }
24480
24447
  update(id, patch) {
@@ -24484,6 +24451,7 @@ var require_registry4 = __commonJS({
24484
24451
  if (p.desired !== void 0) {
24485
24452
  if (!DESIRED.includes(p.desired)) return { ok: false, error: "\u975E\u6CD5 desired: " + p.desired };
24486
24453
  e.desired = p.desired;
24454
+ pmClient.setDesired(e.id, p.desired);
24487
24455
  }
24488
24456
  if (p.name !== void 0) e.name = String(p.name || e.id);
24489
24457
  if (p.ownership !== void 0) {
@@ -24515,6 +24483,7 @@ var require_registry4 = __commonJS({
24515
24483
  this._drop(e);
24516
24484
  this._save();
24517
24485
  this._event("managed_object_removed", { kind: e.kind, id: e.id });
24486
+ pmClient.setDesired(e.id, "stopped");
24518
24487
  return { ok: true };
24519
24488
  }
24520
24489
  _releasePort(port, ownerId) {
@@ -24576,6 +24545,7 @@ var require_registry4 = __commonJS({
24576
24545
  e.lastTransitionAt = (/* @__PURE__ */ new Date()).toISOString();
24577
24546
  this._event("managed_object_phase", { kind: e.kind, id: e.id, phase: p });
24578
24547
  this._save();
24548
+ pmClient.onPhase(e.id, pmPhase(p));
24579
24549
  }
24580
24550
  return e;
24581
24551
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lob-ox/core-darwin-x64",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "DSH lifecycle guard core (Node launcher) for darwin-x64 — requires Node >=18.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {