@bli-cockpit/cli 0.2.67 → 0.2.69

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.
@@ -15,8 +15,13 @@
15
15
  * in, so the session file is the evidence — there is no
16
16
  * second thing to ask.
17
17
  * device that same session, still unexpired.
18
- * collector.autostart `autostartStatus`, which asks launchd or Task
19
- * Scheduler what it actually has registered.
18
+ * collector.autostart `readAutostartRegistration`, which asks launchd or
19
+ * Task Scheduler what it actually has registered. That
20
+ * reader is SHARED with doctor's `autostart-alive` row
21
+ * (BLI-3793) — this module used to ask the scheduler
22
+ * itself, without the machine's saved roots, and so
23
+ * printed `autostart_not_loaded` under a doctor row
24
+ * that said the same agent was running.
20
25
  *
21
26
  * The five AGENT-HOST words in the printed block are NOT computed here. They
22
27
  * are BLI-3729's `MemoryInstallReceipt`, already read back off
@@ -36,7 +41,7 @@
36
41
  import os from "node:os";
37
42
  import { SETUP_RECEIPT_SCHEMA_VERSION, setupReceiptGaps, setupReceiptLine, } from "@bli-cockpit/telemetry-core";
38
43
  import { readHeartbeatMemoryReceipt } from "./heartbeat.js";
39
- import { autostartStatus } from "../autostart.js";
44
+ import { autostartSetupPiece, readAutostartRegistration, } from "./autostart-reading.js";
40
45
  import { readLocalSessionReference } from "../local-state.js";
41
46
  import { getCollectorRuntimePaths } from "../local-state-paths.js";
42
47
  import { readJsonFile, writeJsonFile } from "../local-state-files.js";
@@ -63,14 +68,19 @@ export async function buildSetupReceipt(io, options = {}) {
63
68
  });
64
69
  const autostart = await probes.autostart().catch((error) => {
65
70
  console.error(`${TAG} scheduler could not be read`, JSON.stringify({ reason: "autostart_probe_failed", error_name: errorName(error) }));
66
- return { status: "unreadable" };
71
+ return {
72
+ state: "unreadable",
73
+ reason: "autostart_probe_failed",
74
+ message: "the operating-system scheduler could not be read this run",
75
+ roots: [],
76
+ };
67
77
  });
68
78
  const receipt = {
69
79
  schema_version: SETUP_RECEIPT_SCHEMA_VERSION,
70
80
  checked_at: checkedAt,
71
81
  browser: browserPiece(session),
72
82
  device: devicePiece(session),
73
- collector: { autostart: autostartPiece(autostart) },
83
+ collector: { autostart: autostartSetupPiece(autostart) },
74
84
  };
75
85
  const gaps = setupReceiptGaps(receipt, memory);
76
86
  console.error(`${TAG} read back`, JSON.stringify({
@@ -97,19 +107,16 @@ function withDefaultProbes(io, homeDir, options) {
97
107
  };
98
108
  }),
99
109
  autostart: options.probes?.autostart ??
100
- (async () => {
101
- // The scheduler can only be READ through a process runner; a machine
102
- // whose io carries none is unknown, never "absent" (BLI-2541: never
103
- // report a state you did not observe).
104
- const exec = io.exec;
105
- if (!exec)
106
- return { status: "unreadable", message: "runner_unavailable" };
107
- const result = await autostartStatus({ homeDir, exec });
108
- return {
109
- status: result.status,
110
- ...(result.message ? { message: result.message } : {}),
111
- };
112
- }),
110
+ // The one shared reader. It handles the no-process-runner host itself
111
+ // (`unreadable`, never "absent" BLI-2541: never report a state you did
112
+ // not observe) and it hands the scheduler this machine's saved roots,
113
+ // which is what stopped this word from contradicting doctor's row
114
+ // (BLI-3793).
115
+ (async () => readAutostartRegistration({
116
+ exec: io.exec,
117
+ homeDir,
118
+ ...(options.dashboardUrl ? { dashboardUrl: options.dashboardUrl } : {}),
119
+ })),
113
120
  };
114
121
  }
115
122
  /**
@@ -139,32 +146,6 @@ function devicePiece(session) {
139
146
  }
140
147
  return { status: "missing", reason: `session_${session.state}` };
141
148
  }
142
- /**
143
- * The scheduler is `ok` only when the host says it is registered AND loaded.
144
- * `installed` on macOS means the plist is on disk; `loaded` means launchd has
145
- * it. A plist nobody loaded runs nothing, which is exactly the failure that
146
- * looks fine from the outside.
147
- */
148
- function autostartPiece(result) {
149
- if (result.status === "loaded" || result.status === "installed") {
150
- return { status: "ok", reason: `autostart_${result.status}` };
151
- }
152
- if (result.status === "not_loaded") {
153
- return { status: "missing", reason: "autostart_not_loaded" };
154
- }
155
- if (result.status === "absent" || result.status === "uninstalled") {
156
- return { status: "missing", reason: "autostart_absent" };
157
- }
158
- if (result.status === "unsupported") {
159
- return { status: "skipped", reason: "platform_unsupported" };
160
- }
161
- return { status: "unknown", reason: normalizeReason(result.status) };
162
- }
163
- /** Reason labels are `[a-z0-9_:.-]` by schema; anything else becomes one word. */
164
- function normalizeReason(value) {
165
- const cleaned = value.trim().toLowerCase().replace(/[^a-z0-9_:.-]+/gu, "_");
166
- return cleaned.slice(0, 120) || "unlabelled";
167
- }
168
149
  function errorName(error) {
169
150
  return error instanceof Error ? error.name : typeof error;
170
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bli-cockpit/cli",
3
- "version": "0.2.67",
3
+ "version": "0.2.69",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@bli-cockpit/memory-mcp": "0.1.9",
31
- "@bli-cockpit/mcp": "0.1.9",
31
+ "@bli-cockpit/mcp": "0.1.10",
32
32
  "@bli-cockpit/telemetry-core": "0.1.30"
33
33
  }
34
34
  }