@ouro.bot/cli 0.1.0-alpha.52 → 0.1.0-alpha.53

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/changelog.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.53",
6
+ "changes": [
7
+ "Daemon plist now inherits PATH from the installing process, so child agent spawns can find node regardless of launchd's minimal default environment.",
8
+ "Daemon startup and status output now show the entry path and runtime mode (dev vs production) so it's immediately obvious where the daemon is running from and whether it's a dev repo, worktree, or npm install.",
9
+ "Agent spawn in the process manager now validates the entry script exists before calling spawn, setting the agent to crashed with a clear error instead of an opaque ENOENT.",
10
+ "Plist write warns when the entry path doesn't exist on disk, catching stale worktree paths before they cause daemon crashes."
11
+ ]
12
+ },
4
13
  {
5
14
  "version": "0.1.0-alpha.52",
6
15
  "changes": [
@@ -55,6 +55,7 @@ const specialist_orchestrator_1 = require("./specialist-orchestrator");
55
55
  const specialist_prompt_1 = require("./specialist-prompt");
56
56
  const specialist_tools_1 = require("./specialist-tools");
57
57
  const runtime_metadata_1 = require("./runtime-metadata");
58
+ const runtime_mode_1 = require("./runtime-mode");
58
59
  const daemon_runtime_sync_1 = require("./daemon-runtime-sync");
59
60
  const agent_discovery_1 = require("./agent-discovery");
60
61
  const update_hooks_1 = require("./update-hooks");
@@ -94,6 +95,8 @@ function parseStatusPayload(data) {
94
95
  lastUpdated: stringField(overview.lastUpdated) ?? "unknown",
95
96
  workerCount: numberField(overview.workerCount) ?? 0,
96
97
  senseCount: numberField(overview.senseCount) ?? 0,
98
+ entryPath: stringField(overview.entryPath) ?? "unknown",
99
+ mode: stringField(overview.mode) ?? "unknown",
97
100
  };
98
101
  const parsedSenses = senses.map((entry) => {
99
102
  if (!entry || typeof entry !== "object" || Array.isArray(entry))
@@ -174,6 +177,8 @@ function formatDaemonStatusOutput(response, fallback) {
174
177
  ["Socket", payload.overview.socketPath],
175
178
  ["Version", payload.overview.version],
176
179
  ["Last Updated", payload.overview.lastUpdated],
180
+ ["Entry Path", payload.overview.entryPath],
181
+ ["Mode", payload.overview.mode],
177
182
  ["Workers", String(payload.overview.workerCount)],
178
183
  ["Senses", String(payload.overview.senseCount)],
179
184
  ["Health", payload.overview.health],
@@ -272,6 +277,7 @@ function formatVersionOutput() {
272
277
  }
273
278
  function buildStoppedStatusPayload(socketPath) {
274
279
  const metadata = (0, runtime_metadata_1.getRuntimeMetadata)();
280
+ const repoRoot = (0, identity_1.getRepoRoot)();
275
281
  return {
276
282
  overview: {
277
283
  daemon: "stopped",
@@ -281,6 +287,8 @@ function buildStoppedStatusPayload(socketPath) {
281
287
  lastUpdated: metadata.lastUpdated,
282
288
  workerCount: 0,
283
289
  senseCount: 0,
290
+ entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
291
+ mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
284
292
  },
285
293
  senses: [],
286
294
  workers: [],
@@ -729,12 +737,23 @@ function defaultEnsureDaemonBootPersistence(socketPath) {
729
737
  homeDir,
730
738
  };
731
739
  const entryPath = path.join((0, identity_1.getRepoRoot)(), "dist", "heart", "daemon", "daemon-entry.js");
740
+ /* v8 ignore next -- covered via mock in daemon-cli-defaults.test.ts; v8 on CI attributes the real fs.existsSync branch to the non-mock load @preserve */
741
+ if (!fs.existsSync(entryPath)) {
742
+ (0, runtime_1.emitNervesEvent)({
743
+ level: "warn",
744
+ component: "daemon",
745
+ event: "daemon.entry_path_missing",
746
+ message: "entryPath does not exist on disk — plist may point to a stale location. Run 'ouro daemon install' from the correct location.",
747
+ meta: { entryPath },
748
+ });
749
+ }
732
750
  const logDir = path.join(homeDir, ".agentstate", "daemon", "logs");
733
751
  (0, launchd_1.writeLaunchAgentPlist)(launchdDeps, {
734
752
  nodePath: process.execPath,
735
753
  entryPath,
736
754
  socketPath,
737
755
  logDir,
756
+ envPath: process.env.PATH,
738
757
  });
739
758
  }
740
759
  async function defaultInstallSubagents() {
@@ -1,6 +1,41 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
4
39
  const process_manager_1 = require("./process-manager");
5
40
  const daemon_1 = require("./daemon");
6
41
  const runtime_1 = require("../../nerves/runtime");
@@ -10,6 +45,8 @@ const task_scheduler_1 = require("./task-scheduler");
10
45
  const runtime_logging_1 = require("./runtime-logging");
11
46
  const sense_manager_1 = require("./sense-manager");
12
47
  const agent_discovery_1 = require("./agent-discovery");
48
+ const identity_1 = require("../identity");
49
+ const runtime_mode_1 = require("./runtime-mode");
13
50
  function parseSocketPath(argv) {
14
51
  const socketIndex = argv.indexOf("--socket");
15
52
  if (socketIndex >= 0) {
@@ -21,11 +58,13 @@ function parseSocketPath(argv) {
21
58
  }
22
59
  const socketPath = parseSocketPath(process.argv);
23
60
  (0, runtime_logging_1.configureDaemonRuntimeLogger)("daemon");
61
+ const entryPath = path.resolve(__dirname, "daemon-entry.js");
62
+ const mode = (0, runtime_mode_1.detectRuntimeMode)((0, identity_1.getRepoRoot)());
24
63
  (0, runtime_1.emitNervesEvent)({
25
64
  component: "daemon",
26
65
  event: "daemon.entry_start",
27
66
  message: "starting daemon entrypoint",
28
- meta: { socketPath },
67
+ meta: { socketPath, entryPath, mode },
29
68
  });
30
69
  const managedAgents = (0, agent_discovery_1.listEnabledBundleAgents)();
31
70
  const processManager = new process_manager_1.DaemonProcessManager({
@@ -35,6 +74,7 @@ const processManager = new process_manager_1.DaemonProcessManager({
35
74
  channel: "inner-dialog",
36
75
  autoStart: true,
37
76
  })),
77
+ existsSync: fs.existsSync,
38
78
  });
39
79
  const scheduler = new task_scheduler_1.TaskDrivenScheduler({
40
80
  agents: [...managedAgents],
@@ -40,6 +40,7 @@ const path = __importStar(require("path"));
40
40
  const identity_1 = require("../identity");
41
41
  const runtime_1 = require("../../nerves/runtime");
42
42
  const runtime_metadata_1 = require("./runtime-metadata");
43
+ const runtime_mode_1 = require("./runtime-mode");
43
44
  const update_hooks_1 = require("./update-hooks");
44
45
  const bundle_meta_1 = require("./hooks/bundle-meta");
45
46
  const bundle_manifest_1 = require("../../mind/bundle-manifest");
@@ -373,6 +374,7 @@ class OuroDaemon {
373
374
  const snapshots = this.processManager.listAgentSnapshots();
374
375
  const workers = buildWorkerRows(snapshots);
375
376
  const senses = this.senseManager?.listSenseRows() ?? [];
377
+ const repoRoot = (0, identity_1.getRepoRoot)();
376
378
  const data = {
377
379
  overview: {
378
380
  daemon: "running",
@@ -381,6 +383,8 @@ class OuroDaemon {
381
383
  ...(0, runtime_metadata_1.getRuntimeMetadata)(),
382
384
  workerCount: workers.length,
383
385
  senseCount: senses.length,
386
+ entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
387
+ mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
384
388
  },
385
389
  workers,
386
390
  senses,
@@ -71,6 +71,9 @@ function generateDaemonPlist(options) {
71
71
  ` <key>KeepAlive</key>`,
72
72
  ` <true/>`,
73
73
  ];
74
+ if (options.envPath) {
75
+ lines.push(` <key>EnvironmentVariables</key>`, ` <dict>`, ` <key>PATH</key>`, ` <string>${options.envPath}</string>`, ` </dict>`);
76
+ }
74
77
  if (options.logDir) {
75
78
  lines.push(` <key>StandardOutPath</key>`, ` <string>${path.join(options.logDir, "ouro-daemon-stdout.log")}</string>`, ` <key>StandardErrorPath</key>`, ` <string>${path.join(options.logDir, "ouro-daemon-stderr.log")}</string>`);
76
79
  }
@@ -51,6 +51,7 @@ class DaemonProcessManager {
51
51
  now;
52
52
  setTimeoutFn;
53
53
  clearTimeoutFn;
54
+ existsSyncFn;
54
55
  constructor(options) {
55
56
  this.maxRestartsPerHour = options.maxRestartsPerHour ?? 10;
56
57
  this.stabilityThresholdMs = options.stabilityThresholdMs ?? 60_000;
@@ -60,6 +61,7 @@ class DaemonProcessManager {
60
61
  this.now = options.now ?? (() => Date.now());
61
62
  this.setTimeoutFn = options.setTimeoutFn ?? ((cb, delay) => setTimeout(cb, delay));
62
63
  this.clearTimeoutFn = options.clearTimeoutFn ?? ((timer) => clearTimeout(timer));
64
+ this.existsSyncFn = options.existsSync ?? null;
63
65
  for (const agent of options.agents) {
64
66
  this.agents.set(agent.name, {
65
67
  config: agent,
@@ -96,6 +98,17 @@ class DaemonProcessManager {
96
98
  state.snapshot.status = "starting";
97
99
  const runCwd = (0, identity_1.getRepoRoot)();
98
100
  const entryScript = path.join((0, identity_1.getRepoRoot)(), "dist", state.config.entry);
101
+ if (this.existsSyncFn && !this.existsSyncFn(entryScript)) {
102
+ state.snapshot.status = "crashed";
103
+ (0, runtime_1.emitNervesEvent)({
104
+ level: "error",
105
+ component: "daemon",
106
+ event: "daemon.agent_entry_missing",
107
+ message: "agent entry script does not exist — cannot spawn. Run 'ouro daemon install' from the correct location.",
108
+ meta: { agent, entryScript },
109
+ });
110
+ return;
111
+ }
99
112
  const args = [entryScript, "--agent", state.config.agentArg ?? agent, ...(state.config.args ?? [])];
100
113
  const child = this.spawnFn("node", args, {
101
114
  cwd: runCwd,
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.detectRuntimeMode = detectRuntimeMode;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const runtime_1 = require("../../nerves/runtime");
40
+ function detectRuntimeMode(rootPath, deps = {}) {
41
+ const checkExists = deps.existsSync ?? fs.existsSync;
42
+ // 1. Production: installed via npm
43
+ if (rootPath.includes("node_modules/@ouro.bot/cli") ||
44
+ rootPath.includes("node_modules/ouro.bot")) {
45
+ (0, runtime_1.emitNervesEvent)({
46
+ component: "daemon",
47
+ event: "daemon.runtime_mode_detected",
48
+ message: "detected runtime mode",
49
+ meta: { rootPath, mode: "production" },
50
+ });
51
+ return "production";
52
+ }
53
+ // 2-4. Everything else is dev: worktrees, git repos, unknown paths
54
+ // (conservative default: assume dev unless proven production)
55
+ const reason = rootPath.includes(".claude/worktrees/")
56
+ ? "worktree"
57
+ : checkExists(path.join(rootPath, ".git"))
58
+ ? "git-repo"
59
+ : "unknown";
60
+ (0, runtime_1.emitNervesEvent)({
61
+ component: "daemon",
62
+ event: "daemon.runtime_mode_detected",
63
+ message: "detected runtime mode",
64
+ meta: { rootPath, mode: "dev", reason },
65
+ });
66
+ return "dev";
67
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.52",
3
+ "version": "0.1.0-alpha.53",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",