@lob-ox/core-darwin-x64 0.0.10 → 0.0.12

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 +62 -22
  2. package/package.json +1 -1
package/core.cjs CHANGED
@@ -1471,7 +1471,7 @@ var require_version = __commonJS({
1471
1471
  var fs2 = require("node:fs");
1472
1472
  var path2 = require("node:path");
1473
1473
  function guardVersion() {
1474
- if (true) return String("0.0.10");
1474
+ if (true) return String("0.0.12");
1475
1475
  try {
1476
1476
  return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
1477
1477
  } catch {
@@ -1824,10 +1824,7 @@ var require_phase = __commonJS({
1824
1824
  STARTING: "starting",
1825
1825
  RUNNING: "running",
1826
1826
  STOPPING: "draining",
1827
- FAILED: "failed",
1828
- OBSERVED: "stopped",
1829
- RESTARTING: "starting",
1830
- BACKOFF: "failed"
1827
+ FAILED: "failed"
1831
1828
  };
1832
1829
  function entryToLegacyPhase(ph) {
1833
1830
  return ENTRY_TO_LEGACY[ph] || "STOPPED";
@@ -1865,10 +1862,7 @@ var require_fields = __commonJS({
1865
1862
  }
1866
1863
  function phase() {
1867
1864
  const e = record.storeOf();
1868
- const p = e.process || null;
1869
- const upper = entryToLegacyPhase(e.phase || "stopped");
1870
- if (upper === "STOPPED" && p && p.observedOnly && p.adopted) return "OBSERVED";
1871
- return upper;
1865
+ return entryToLegacyPhase(e.phase || "stopped");
1872
1866
  }
1873
1867
  function setPhase(upper) {
1874
1868
  const e = record.storeOf();
@@ -2126,11 +2120,11 @@ var require_desired = __commonJS({
2126
2120
  if (it) it.register("start");
2127
2121
  setCrashHalted(false);
2128
2122
  }
2129
- if (v === "running" && fields.phase() === "OBSERVED") {
2123
+ if (v === "running" && fields.observedOnly() && fields.accessors.adoptedPid.get() !== null) {
2130
2124
  fields.setObservedOnly(false);
2131
2125
  fields.setPhase("STOPPED");
2132
2126
  }
2133
- if (v === "stopped" && fields.phase() === "OBSERVED" && fields.observedOnly()) {
2127
+ if (v === "stopped" && fields.observedOnly() && fields.accessors.adoptedPid.get() !== null) {
2134
2128
  stopProcess("desired_stopped");
2135
2129
  }
2136
2130
  if (fields.desired() !== v) {
@@ -4830,7 +4824,10 @@ var require_collaborators = __commonJS({
4830
4824
  crashHalted: () => host._crashHalted
4831
4825
  });
4832
4826
  host.session = session;
4833
- host.sessionState = () => session.state();
4827
+ host.sessionState = () => {
4828
+ const p = String(host._mPhase ? host._mPhase() : "").toUpperCase();
4829
+ return p === "STARTING" || p === "RUNNING" ? "running" : "stopped";
4830
+ };
4834
4831
  host._setSessionState = (s) => {
4835
4832
  session.setState(s);
4836
4833
  };
@@ -8407,7 +8404,13 @@ var require_bootstrap = __commonJS({
8407
8404
  const isBare = policies.isBareCommand(cur);
8408
8405
  if (!isBare) return;
8409
8406
  const d = execPath.resolveDsh();
8410
- if (!d || !d.bin) return;
8407
+ if (!d || !d.bin) {
8408
+ try {
8409
+ 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");
8410
+ } catch {
8411
+ }
8412
+ return;
8413
+ }
8411
8414
  host.config.command = d.isJs ? [d.runtime || process.execPath, d.bin, ...cmd2.slice(2)] : [d.bin, ...cmd2.slice(2)];
8412
8415
  try {
8413
8416
  host.events && host.events.append(BRAND2.EVENT_HARNESS_COMMAND_BOUND, { from: cur || null, to: host.config.command[1] });
@@ -10416,7 +10419,8 @@ var require_controller = __commonJS({
10416
10419
  host._crashHalted = v;
10417
10420
  },
10418
10421
  sessionState() {
10419
- return host._sessionState;
10422
+ const p = String(host._mPhase() || "").toUpperCase();
10423
+ return p === "STARTING" || p === "RUNNING" ? "running" : "stopped";
10420
10424
  },
10421
10425
  mChild() {
10422
10426
  return host._mChild();
@@ -10491,8 +10495,8 @@ var require_controller = __commonJS({
10491
10495
  if (managedAlive) {
10492
10496
  d.main().stopProcess("desired_stopped");
10493
10497
  } else if (adoptedAlive && d.mObservedOnly()) {
10494
- if (d.state().phase() !== "OBSERVED") {
10495
- d.state().setPhase("OBSERVED");
10498
+ d.state().setObservedOnly(true);
10499
+ if (d.state().phase() !== "STOPPED") {
10496
10500
  d.state().write();
10497
10501
  }
10498
10502
  } else if (portUp) {
@@ -10537,6 +10541,16 @@ var require_controller = __commonJS({
10537
10541
  d.intents().consume("start");
10538
10542
  }
10539
10543
  }
10544
+ {
10545
+ const nst = host.nativeManager ? host.nativeManager.status() : null;
10546
+ if (nst && nst.installed === false) {
10547
+ const ph0 = String(d.state().phase() || "").toUpperCase();
10548
+ if (ph0 === "STARTING" || ph0 === "RUNNING") {
10549
+ d.events().append("state_corrected", { from: ph0, to: "STOPPED", reason: "harness_not_installed" });
10550
+ d.state().setPhase("STOPPED");
10551
+ }
10552
+ }
10553
+ }
10540
10554
  switch (d.state().phase()) {
10541
10555
  case "STOPPED": {
10542
10556
  if (portUp) {
@@ -10617,7 +10631,7 @@ var require_controller = __commonJS({
10617
10631
  d.logger().error("tick error: " + (e && e.stack || e));
10618
10632
  } finally {
10619
10633
  d.writeTicking(false);
10620
- if (d.sessionState() === "starting") d.session().setState("running");
10634
+ if (d.sessionState() === "running") d.session().setState("running");
10621
10635
  try {
10622
10636
  d.control().syncDshView();
10623
10637
  } catch (e) {
@@ -10761,8 +10775,20 @@ var require_command = __commonJS({
10761
10775
  "use strict";
10762
10776
  var fs2 = require("node:fs");
10763
10777
  var dshCli = require_dsh_cli();
10778
+ var execPath = require_exec_path();
10779
+ var policies = require_policies();
10780
+ function resolveBareCommand(command) {
10781
+ if (!Array.isArray(command) || command.length === 0) return command;
10782
+ const idx = command.length > 1 ? 1 : 0;
10783
+ const cur = command[idx];
10784
+ if (!policies.isBareCommand(cur)) return command;
10785
+ const d = execPath.resolveDsh();
10786
+ if (!d || !d.bin) return command;
10787
+ const rest = command.slice(idx + 1);
10788
+ return d.isJs ? [d.runtime || process.execPath, d.bin, ...rest] : [d.bin, ...rest];
10789
+ }
10764
10790
  function nativeCommand(config, pluginManager) {
10765
- const command = config.command || [];
10791
+ const command = resolveBareCommand(config.command || []);
10766
10792
  const patchFile = pluginManager && pluginManager.overlayFile && fs2.existsSync(pluginManager.overlayFile) ? pluginManager.overlayFile : null;
10767
10793
  const out = [];
10768
10794
  let portSet = false;
@@ -11054,7 +11080,8 @@ var require_process2 = __commonJS({
11054
11080
  },
11055
11081
  _adoptObserved() {
11056
11082
  const d = depsOf(this);
11057
- d.state().setPhase("OBSERVED");
11083
+ d.state().setObservedOnly(true);
11084
+ d.state().setPhase("STOPPED");
11058
11085
  d.mSetAdopted(true);
11059
11086
  d.mSetObservedOnly(true);
11060
11087
  d.mSetChild(null);
@@ -12762,12 +12789,26 @@ var require_status = __commonJS({
12762
12789
  "src/app/facade/status.js"(exports2, module2) {
12763
12790
  "use strict";
12764
12791
  var { installId } = require_install_id();
12792
+ function deriveState(host) {
12793
+ const nat = host.nativeManager ? host.nativeManager.status() : null;
12794
+ if (nat && nat.installed === false) return "uninstalled";
12795
+ if (host._mMissingNotified && host._mMissingNotified()) return "command_missing";
12796
+ const ph = String(host._mPhase() || "").toUpperCase();
12797
+ if (ph === "RUNNING") return "running";
12798
+ if (ph === "STARTING") return "starting";
12799
+ if (ph === "FAILED") return "failed";
12800
+ return "stopped";
12801
+ }
12765
12802
  function statusSummary(host) {
12766
12803
  const dshPidNow = host._mChild() ? host._mChild().pid : host._mAdoptPid();
12767
12804
  return {
12768
12805
  desired: host._mDesired(),
12769
12806
  phase: host._mPhase(),
12770
- sessionState: host._sessionState,
12807
+ state: deriveState(host),
12808
+ sessionState: (function() {
12809
+ const p = String(host._mPhase() || "").toUpperCase();
12810
+ return p === "STARTING" || p === "RUNNING" ? "running" : "stopped";
12811
+ })(),
12771
12812
  dataDirProtected: Array.isArray(host._fileProtectStatus) ? host._fileProtectStatus.length > 0 && host._fileProtectStatus.every((r) => r.ok) : null,
12772
12813
  guardVersion: host.guardVersion,
12773
12814
  installId: installId(),
@@ -12782,7 +12823,7 @@ var require_status = __commonJS({
12782
12823
  lastRestartAt: host._mLastRestartAt(),
12783
12824
  upgradeHold: host._upgradeHold,
12784
12825
  shellHalted: host._shellHalted === true,
12785
- commandMissing: !!(host._mSpawnBlockedUntil() && Date.now() < host._mSpawnBlockedUntil()),
12826
+ commandMissing: !!(host._mMissingNotified && host._mMissingNotified()),
12786
12827
  dshTokenCaptured: !!(host.tokenService && host.tokenService.get("main")),
12787
12828
  tasks: host.tasks ? host.tasks.running().map((t) => ({ id: t.id, kind: t.kind, action: t.action, target: t.target, state: t.state })) : [],
12788
12829
  native: host.nativeManager ? host.nativeManager.status() : null,
@@ -15645,7 +15686,6 @@ var require_core5 = __commonJS({
15645
15686
  host._ticking = false;
15646
15687
  host.intents = new IntentLedger();
15647
15688
  host._stopping = false;
15648
- host._sessionState = "starting";
15649
15689
  host._crashHalted = false;
15650
15690
  host._shellHalted = false;
15651
15691
  host._upgradeHold = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lob-ox/core-darwin-x64",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "DSH lifecycle guard core (Node launcher) for darwin-x64 — requires Node >=18.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {