@ouro.bot/cli 0.1.0-alpha.24 → 0.1.0-alpha.240
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/README.md +187 -191
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +1 -1
- package/changelog.json +1459 -0
- package/dist/arc/attention-types.js +8 -0
- package/dist/arc/cares.js +140 -0
- package/dist/arc/episodes.js +119 -0
- package/dist/arc/intentions.js +133 -0
- package/dist/arc/json-store.js +120 -0
- package/dist/arc/obligations.js +237 -0
- package/dist/arc/presence.js +185 -0
- package/dist/heart/active-work.js +832 -0
- package/dist/heart/agent-entry.js +37 -2
- package/dist/heart/auth/auth-flow.js +447 -0
- package/dist/heart/bridges/manager.js +358 -0
- package/dist/heart/bridges/state-machine.js +135 -0
- package/dist/heart/bridges/store.js +123 -0
- package/dist/heart/commitments.js +111 -0
- package/dist/heart/config-registry.js +304 -0
- package/dist/heart/config.js +63 -30
- package/dist/heart/core.js +620 -159
- package/dist/heart/cross-chat-delivery.js +131 -0
- package/dist/heart/daemon/agent-config-check.js +149 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/agent-service.js +360 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/cli-defaults.js +557 -0
- package/dist/heart/daemon/cli-exec.js +1847 -0
- package/dist/heart/daemon/cli-parse.js +759 -0
- package/dist/heart/daemon/cli-render.js +399 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/daemon-cli.js +29 -1177
- package/dist/heart/daemon/daemon-entry.js +202 -4
- package/dist/heart/daemon/daemon-health.js +136 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +153 -12
- package/dist/heart/daemon/daemon-tombstone.js +123 -0
- package/dist/heart/daemon/daemon.js +492 -20
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +115 -1
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/launchd.js +39 -8
- package/dist/heart/daemon/log-tailer.js +4 -3
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/os-cron-deps.js +134 -0
- package/dist/heart/daemon/ouro-bot-entry.js +1 -1
- package/dist/heart/daemon/process-manager.js +123 -0
- package/dist/heart/daemon/run-hooks.js +2 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +101 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/safe-mode.js +161 -0
- package/dist/heart/daemon/sense-manager.js +72 -3
- package/dist/heart/daemon/session-id-resolver.js +131 -0
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/task-scheduler.js +3 -25
- package/dist/heart/daemon/thoughts.js +507 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/habits/habit-migration.js +181 -0
- package/dist/heart/habits/habit-parser.js +119 -0
- package/dist/heart/habits/habit-scheduler.js +369 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +30 -120
- package/dist/heart/{daemon → hatch}/hatch-specialist.js +3 -3
- package/dist/heart/{daemon → hatch}/specialist-prompt.js +10 -7
- package/dist/heart/{daemon → hatch}/specialist-tools.js +49 -3
- package/dist/heart/identity.js +157 -55
- package/dist/heart/kicks.js +2 -20
- package/dist/heart/mcp/mcp-server.js +651 -0
- package/dist/heart/migrate-config.js +127 -0
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/outlook/outlook-http.js +439 -0
- package/dist/heart/outlook/outlook-read.js +1618 -0
- package/dist/heart/outlook/outlook-render.js +1032 -0
- package/dist/heart/outlook/outlook-types.js +7 -0
- package/dist/heart/outlook/outlook-view.js +194 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-failover.js +88 -0
- package/dist/heart/provider-ping.js +162 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +187 -41
- package/dist/heart/providers/azure.js +116 -10
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +51 -16
- package/dist/heart/session-activity.js +172 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/start-of-turn-packet.js +330 -0
- package/dist/heart/streaming.js +36 -27
- package/dist/heart/sync.js +217 -0
- package/dist/heart/target-resolution.js +127 -0
- package/dist/heart/tempo.js +93 -0
- package/dist/heart/temporal-view.js +41 -0
- package/dist/heart/tool-activity-callbacks.js +36 -0
- package/dist/heart/tool-description.js +135 -0
- package/dist/heart/tool-loop.js +200 -0
- package/dist/heart/turn-context.js +358 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/heart/versioning/ouro-bot-global-installer.js +128 -0
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
- package/dist/heart/{daemon → versioning}/ouro-path-installer.js +78 -35
- package/dist/heart/versioning/ouro-version-manager.js +171 -0
- package/dist/heart/{daemon → versioning}/staged-restart.js +30 -6
- package/dist/heart/{daemon → versioning}/update-checker.js +9 -1
- package/dist/heart/{daemon → versioning}/update-hooks.js +11 -0
- package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +41 -3
- package/dist/mind/associative-recall.js +126 -66
- package/dist/mind/bundle-manifest.js +8 -1
- package/dist/mind/context.js +125 -14
- package/dist/mind/{memory.js → diary.js} +73 -96
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +56 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/resolver.js +37 -0
- package/dist/mind/friends/store-file.js +58 -3
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +8 -0
- package/dist/mind/journal-index.js +161 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +762 -109
- package/dist/mind/scrutiny.js +173 -0
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/coverage/audit.js +1 -1
- package/dist/nerves/coverage/file-completeness.js +50 -5
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/nerves/event-buffer.js +111 -0
- package/dist/nerves/index.js +64 -4
- package/dist/nerves/observation.js +20 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/outlook-ui/assets/index-Ck8agNeO.js +61 -0
- package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
- package/dist/outlook-ui/index.html +15 -0
- package/dist/repertoire/ado-client.js +15 -56
- package/dist/repertoire/ado-semantic.js +11 -10
- package/dist/repertoire/api-client.js +97 -0
- package/dist/repertoire/bitwarden-store.js +319 -0
- package/dist/repertoire/bw-installer.js +79 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +330 -0
- package/dist/repertoire/coding/feedback.js +197 -30
- package/dist/repertoire/coding/manager.js +149 -2
- package/dist/repertoire/coding/spawner.js +55 -9
- package/dist/repertoire/coding/tools.js +170 -7
- package/dist/repertoire/commerce-errors.js +109 -0
- package/dist/repertoire/commerce-self-test.js +156 -0
- package/dist/repertoire/credential-access.js +515 -0
- package/dist/repertoire/duffel-client.js +185 -0
- package/dist/repertoire/github-client.js +14 -55
- package/dist/repertoire/graph-client.js +11 -52
- package/dist/repertoire/guardrails.js +369 -0
- package/dist/repertoire/mcp-client.js +255 -0
- package/dist/repertoire/mcp-manager.js +303 -0
- package/dist/repertoire/mcp-tools.js +63 -0
- package/dist/repertoire/shell-sessions.js +133 -0
- package/dist/repertoire/skills.js +14 -23
- package/dist/repertoire/stripe-client.js +131 -0
- package/dist/repertoire/tasks/board.js +43 -5
- package/dist/repertoire/tasks/fix.js +182 -0
- package/dist/repertoire/tasks/index.js +28 -10
- package/dist/repertoire/tasks/lifecycle.js +2 -2
- package/dist/repertoire/tasks/parser.js +3 -2
- package/dist/repertoire/tasks/scanner.js +194 -37
- package/dist/repertoire/tasks/transitions.js +11 -28
- package/dist/repertoire/tools-base.js +43 -771
- package/dist/repertoire/tools-bluebubbles.js +94 -0
- package/dist/repertoire/tools-bridge.js +141 -0
- package/dist/repertoire/tools-config.js +185 -0
- package/dist/repertoire/tools-continuity.js +248 -0
- package/dist/repertoire/tools-credential.js +182 -0
- package/dist/repertoire/tools-files.js +342 -0
- package/dist/repertoire/tools-flight.js +224 -0
- package/dist/repertoire/tools-flow.js +62 -0
- package/dist/repertoire/tools-github.js +1 -7
- package/dist/repertoire/tools-memory.js +347 -0
- package/dist/repertoire/tools-session.js +739 -0
- package/dist/repertoire/tools-shell.js +120 -0
- package/dist/repertoire/tools-stripe.js +180 -0
- package/dist/repertoire/tools-surface.js +243 -0
- package/dist/repertoire/tools-teams.js +12 -62
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools-user-profile.js +144 -0
- package/dist/repertoire/tools-vault.js +110 -0
- package/dist/repertoire/tools.js +147 -130
- package/dist/repertoire/travel-api-client.js +360 -0
- package/dist/repertoire/user-profile.js +118 -0
- package/dist/repertoire/vault-setup.js +241 -0
- package/dist/scripts/claude-code-hook.js +41 -0
- package/dist/scripts/claude-code-stop-hook.js +47 -0
- package/dist/senses/attention-queue.js +97 -0
- package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +109 -10
- package/dist/senses/bluebubbles/entry.js +13 -0
- package/dist/senses/bluebubbles/inbound-log.js +109 -0
- package/dist/senses/bluebubbles/index.js +1374 -0
- package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +119 -24
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +13 -5
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +46 -6
- package/dist/senses/bluebubbles/runtime-state.js +109 -0
- package/dist/senses/bluebubbles/session-cleanup.js +72 -0
- package/dist/senses/cli/adapter.js +274 -0
- package/dist/senses/cli/ink-app.js +156 -0
- package/dist/senses/cli/inline-diff.js +64 -0
- package/dist/senses/cli/message-list.js +51 -0
- package/dist/senses/cli/ouro-tui.js +358 -0
- package/dist/senses/cli/spinner-imperative.js +135 -0
- package/dist/senses/cli/spinner.js +101 -0
- package/dist/senses/cli/status-line.js +60 -0
- package/dist/senses/cli/streaming-markdown.js +526 -0
- package/dist/senses/cli/tool-display.js +83 -0
- package/dist/senses/cli/tool-render.js +85 -0
- package/dist/senses/cli/tui-store.js +198 -0
- package/dist/senses/cli/virtual-list.js +35 -0
- package/dist/senses/cli-entry.js +1 -1
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +510 -246
- package/dist/senses/commands.js +65 -1
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/habit-turn-message.js +108 -0
- package/dist/senses/inner-dialog-worker.js +112 -19
- package/dist/senses/inner-dialog.js +593 -85
- package/dist/senses/pipeline.js +559 -0
- package/dist/senses/shared-turn.js +199 -0
- package/dist/senses/surface-tool.js +68 -0
- package/dist/senses/teams.js +664 -165
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +14 -7
- package/skills/agent-commerce.md +106 -0
- package/skills/browser-navigation.md +110 -0
- package/skills/commerce-setup-guide.md +116 -0
- package/skills/commerce-setup.md +84 -0
- package/skills/configure-dev-tools.md +81 -0
- package/skills/travel-planning.md +138 -0
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/dist/senses/bluebubbles-entry.js +0 -11
- package/dist/senses/bluebubbles.js +0 -421
- package/dist/senses/debug-activity.js +0 -107
- package/subagents/README.md +0 -73
- package/subagents/work-doer.md +0 -235
- package/subagents/work-merger.md +0 -618
- package/subagents/work-planner.md +0 -382
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
- /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
- /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
- /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
|
@@ -51,15 +51,23 @@ class DaemonProcessManager {
|
|
|
51
51
|
now;
|
|
52
52
|
setTimeoutFn;
|
|
53
53
|
clearTimeoutFn;
|
|
54
|
+
cooldownRecoveryMs;
|
|
55
|
+
maxCooldownRetries;
|
|
56
|
+
existsSyncFn;
|
|
57
|
+
configCheckFn;
|
|
54
58
|
constructor(options) {
|
|
55
59
|
this.maxRestartsPerHour = options.maxRestartsPerHour ?? 10;
|
|
56
60
|
this.stabilityThresholdMs = options.stabilityThresholdMs ?? 60_000;
|
|
57
61
|
this.initialBackoffMs = options.initialBackoffMs ?? 1_000;
|
|
58
62
|
this.maxBackoffMs = options.maxBackoffMs ?? 60_000;
|
|
63
|
+
this.cooldownRecoveryMs = options.cooldownRecoveryMs ?? 5 * 60 * 1_000;
|
|
64
|
+
this.maxCooldownRetries = options.maxCooldownRetries ?? 3;
|
|
59
65
|
this.spawnFn = options.spawn ?? ((command, args, spawnOptions) => (0, child_process_1.spawn)(command, args, spawnOptions));
|
|
60
66
|
this.now = options.now ?? (() => Date.now());
|
|
61
67
|
this.setTimeoutFn = options.setTimeoutFn ?? ((cb, delay) => setTimeout(cb, delay));
|
|
62
68
|
this.clearTimeoutFn = options.clearTimeoutFn ?? ((timer) => clearTimeout(timer));
|
|
69
|
+
this.existsSyncFn = options.existsSync ?? null;
|
|
70
|
+
this.configCheckFn = options.configCheck ?? null;
|
|
63
71
|
for (const agent of options.agents) {
|
|
64
72
|
this.agents.set(agent.name, {
|
|
65
73
|
config: agent,
|
|
@@ -67,6 +75,9 @@ class DaemonProcessManager {
|
|
|
67
75
|
restartTimer: null,
|
|
68
76
|
crashTimestamps: [],
|
|
69
77
|
stopRequested: false,
|
|
78
|
+
cooldownTimer: null,
|
|
79
|
+
cooldownRetryCount: 0,
|
|
80
|
+
fastCrashCount: 0,
|
|
70
81
|
snapshot: {
|
|
71
82
|
name: agent.name,
|
|
72
83
|
channel: agent.channel,
|
|
@@ -76,6 +87,8 @@ class DaemonProcessManager {
|
|
|
76
87
|
startedAt: null,
|
|
77
88
|
lastCrashAt: null,
|
|
78
89
|
backoffMs: this.initialBackoffMs,
|
|
90
|
+
lastExitCode: null,
|
|
91
|
+
lastSignal: null,
|
|
79
92
|
},
|
|
80
93
|
});
|
|
81
94
|
}
|
|
@@ -94,14 +107,47 @@ class DaemonProcessManager {
|
|
|
94
107
|
this.clearRestartTimer(state);
|
|
95
108
|
state.stopRequested = false;
|
|
96
109
|
state.snapshot.status = "starting";
|
|
110
|
+
if (this.configCheckFn) {
|
|
111
|
+
const result = this.configCheckFn(agent);
|
|
112
|
+
if (!result.ok) {
|
|
113
|
+
state.snapshot.status = "crashed";
|
|
114
|
+
(0, runtime_1.emitNervesEvent)({
|
|
115
|
+
level: "error",
|
|
116
|
+
component: "daemon",
|
|
117
|
+
event: "daemon.agent_config_invalid",
|
|
118
|
+
message: result.error ?? "agent config validation failed",
|
|
119
|
+
meta: { agent, fix: result.fix ?? null },
|
|
120
|
+
});
|
|
121
|
+
process.stderr.write(`[daemon] ${agent}: ${result.error}\n` +
|
|
122
|
+
(result.fix ? ` Fix: ${result.fix}\n` : ""));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
97
126
|
const runCwd = (0, identity_1.getRepoRoot)();
|
|
98
127
|
const entryScript = path.join((0, identity_1.getRepoRoot)(), "dist", state.config.entry);
|
|
128
|
+
if (this.existsSyncFn && !this.existsSyncFn(entryScript)) {
|
|
129
|
+
state.snapshot.status = "crashed";
|
|
130
|
+
(0, runtime_1.emitNervesEvent)({
|
|
131
|
+
level: "error",
|
|
132
|
+
component: "daemon",
|
|
133
|
+
event: "daemon.agent_entry_missing",
|
|
134
|
+
message: "agent entry script does not exist — cannot spawn. Run 'ouro daemon install' from the correct location.",
|
|
135
|
+
meta: { agent, entryScript },
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
99
139
|
const args = [entryScript, "--agent", state.config.agentArg ?? agent, ...(state.config.args ?? [])];
|
|
100
140
|
const child = this.spawnFn("node", args, {
|
|
101
141
|
cwd: runCwd,
|
|
102
142
|
env: state.config.env ? { ...process.env, ...state.config.env } : process.env,
|
|
103
143
|
stdio: ["ignore", "ignore", "ignore", "ipc"],
|
|
104
144
|
});
|
|
145
|
+
/* v8 ignore next 7 -- defensive: spawn should always return a ChildProcess @preserve */
|
|
146
|
+
if (!child) {
|
|
147
|
+
state.snapshot.status = "crashed";
|
|
148
|
+
(0, runtime_1.emitNervesEvent)({ level: "error", component: "daemon", event: "daemon.agent_spawn_failed", message: "spawn returned null", meta: { agent } });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
105
151
|
state.process = child;
|
|
106
152
|
state.snapshot.status = "running";
|
|
107
153
|
state.snapshot.pid = child.pid ?? null;
|
|
@@ -112,6 +158,17 @@ class DaemonProcessManager {
|
|
|
112
158
|
message: "daemon started managed agent process",
|
|
113
159
|
meta: { agent, pid: child.pid ?? null, cwd: runCwd },
|
|
114
160
|
});
|
|
161
|
+
/* v8 ignore start — child process error handler; requires real spawn to trigger */
|
|
162
|
+
child.on("error", (err) => {
|
|
163
|
+
(0, runtime_1.emitNervesEvent)({
|
|
164
|
+
level: "warn",
|
|
165
|
+
component: "daemon",
|
|
166
|
+
event: "daemon.agent_process_error",
|
|
167
|
+
message: "managed agent process emitted error",
|
|
168
|
+
meta: { agent, error: err.message },
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
/* v8 ignore stop */
|
|
115
172
|
child.once("exit", (code, signal) => {
|
|
116
173
|
this.onExit(state, code, signal);
|
|
117
174
|
});
|
|
@@ -119,6 +176,7 @@ class DaemonProcessManager {
|
|
|
119
176
|
async stopAgent(agent) {
|
|
120
177
|
const state = this.requireAgent(agent);
|
|
121
178
|
this.clearRestartTimer(state);
|
|
179
|
+
this.clearCooldownTimer(state);
|
|
122
180
|
state.stopRequested = true;
|
|
123
181
|
if (!state.process) {
|
|
124
182
|
state.snapshot.status = "stopped";
|
|
@@ -179,6 +237,8 @@ class DaemonProcessManager {
|
|
|
179
237
|
return;
|
|
180
238
|
state.process = null;
|
|
181
239
|
state.snapshot.pid = null;
|
|
240
|
+
state.snapshot.lastExitCode = code;
|
|
241
|
+
state.snapshot.lastSignal = signal;
|
|
182
242
|
const crashed = !state.stopRequested && code !== 0;
|
|
183
243
|
const now = this.now();
|
|
184
244
|
const startedAt = state.snapshot.startedAt ? Date.parse(state.snapshot.startedAt) : now;
|
|
@@ -198,6 +258,29 @@ class DaemonProcessManager {
|
|
|
198
258
|
return;
|
|
199
259
|
}
|
|
200
260
|
state.snapshot.lastCrashAt = new Date(now).toISOString();
|
|
261
|
+
// Fast-crash detection: if the agent dies within 5 seconds of starting, it's likely
|
|
262
|
+
// a configuration issue (missing credentials, bad provider, etc.) not a transient failure.
|
|
263
|
+
// After 3 consecutive fast crashes, stop retrying and mark as config-failed.
|
|
264
|
+
const FAST_CRASH_THRESHOLD_MS = 5000;
|
|
265
|
+
const FAST_CRASH_MAX = 3;
|
|
266
|
+
if (runDuration < FAST_CRASH_THRESHOLD_MS) {
|
|
267
|
+
state.fastCrashCount = state.fastCrashCount + 1;
|
|
268
|
+
if (state.fastCrashCount >= FAST_CRASH_MAX) {
|
|
269
|
+
state.snapshot.status = "crashed";
|
|
270
|
+
(0, runtime_1.emitNervesEvent)({
|
|
271
|
+
level: "error",
|
|
272
|
+
component: "daemon",
|
|
273
|
+
event: "daemon.agent_config_failure",
|
|
274
|
+
message: `agent crashed ${FAST_CRASH_MAX} times within ${FAST_CRASH_THRESHOLD_MS}ms of startup — likely a configuration issue (missing credentials, bad provider). Not retrying. Fix the config and run \`ouro up\` to restart.`,
|
|
275
|
+
meta: { agent: state.config.name, fastCrashCount: state.fastCrashCount, avgRunDurationMs: runDuration },
|
|
276
|
+
});
|
|
277
|
+
return; // Don't schedule cooldown recovery — this needs human/agent intervention
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
// Reset fast-crash counter on a stable run
|
|
282
|
+
state.fastCrashCount = 0;
|
|
283
|
+
}
|
|
201
284
|
state.crashTimestamps = state.crashTimestamps.filter((crashTs) => crashTs >= startOfHour(now));
|
|
202
285
|
state.crashTimestamps.push(now);
|
|
203
286
|
if (state.crashTimestamps.length > this.maxRestartsPerHour) {
|
|
@@ -209,6 +292,7 @@ class DaemonProcessManager {
|
|
|
209
292
|
message: "managed agent exceeded restart limit and is marked crashed",
|
|
210
293
|
meta: { agent: state.config.name, maxRestartsPerHour: this.maxRestartsPerHour },
|
|
211
294
|
});
|
|
295
|
+
this.scheduleCooldownRecovery(state);
|
|
212
296
|
return;
|
|
213
297
|
}
|
|
214
298
|
state.snapshot.status = "starting";
|
|
@@ -226,6 +310,45 @@ class DaemonProcessManager {
|
|
|
226
310
|
this.clearTimeoutFn(state.restartTimer);
|
|
227
311
|
state.restartTimer = null;
|
|
228
312
|
}
|
|
313
|
+
scheduleCooldownRecovery(state) {
|
|
314
|
+
if (state.cooldownRetryCount >= this.maxCooldownRetries) {
|
|
315
|
+
(0, runtime_1.emitNervesEvent)({
|
|
316
|
+
level: "error",
|
|
317
|
+
component: "daemon",
|
|
318
|
+
event: "daemon.agent_permanent_failure",
|
|
319
|
+
message: "managed agent exhausted all cooldown retries — permanently stopped",
|
|
320
|
+
meta: { agent: state.config.name, cooldownRetryCount: state.cooldownRetryCount, maxCooldownRetries: this.maxCooldownRetries },
|
|
321
|
+
});
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
this.clearCooldownTimer(state);
|
|
325
|
+
state.cooldownTimer = this.setTimeoutFn(() => {
|
|
326
|
+
state.cooldownRetryCount += 1;
|
|
327
|
+
state.crashTimestamps = [];
|
|
328
|
+
state.snapshot.backoffMs = this.initialBackoffMs;
|
|
329
|
+
state.snapshot.status = "starting";
|
|
330
|
+
state.snapshot.restartCount += 1;
|
|
331
|
+
(0, runtime_1.emitNervesEvent)({
|
|
332
|
+
component: "daemon",
|
|
333
|
+
event: "daemon.agent_cooldown_recovery",
|
|
334
|
+
message: "attempting cooldown recovery for managed agent",
|
|
335
|
+
meta: { agent: state.config.name, cooldownRetryCount: state.cooldownRetryCount },
|
|
336
|
+
});
|
|
337
|
+
void this.startAgent(state.config.name);
|
|
338
|
+
}, this.cooldownRecoveryMs);
|
|
339
|
+
(0, runtime_1.emitNervesEvent)({
|
|
340
|
+
component: "daemon",
|
|
341
|
+
event: "daemon.agent_cooldown_scheduled",
|
|
342
|
+
message: `scheduled cooldown recovery in ${this.cooldownRecoveryMs}ms`,
|
|
343
|
+
meta: { agent: state.config.name, cooldownRecoveryMs: this.cooldownRecoveryMs, cooldownRetryCount: state.cooldownRetryCount },
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
clearCooldownTimer(state) {
|
|
347
|
+
if (state.cooldownTimer === null)
|
|
348
|
+
return;
|
|
349
|
+
this.clearTimeoutFn(state.cooldownTimer);
|
|
350
|
+
state.cooldownTimer = null;
|
|
351
|
+
}
|
|
229
352
|
requireAgent(agent) {
|
|
230
353
|
const state = this.agents.get(agent);
|
|
231
354
|
if (!state) {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runHooks = runHooks;
|
|
4
4
|
const runtime_1 = require("../../nerves/runtime");
|
|
5
5
|
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
6
|
+
const agent_config_v2_1 = require("./hooks/agent-config-v2");
|
|
6
7
|
async function runHooks(deps) {
|
|
7
8
|
(0, runtime_1.emitNervesEvent)({
|
|
8
9
|
component: "daemon",
|
|
@@ -12,6 +13,7 @@ async function runHooks(deps) {
|
|
|
12
13
|
});
|
|
13
14
|
try {
|
|
14
15
|
deps.registerUpdateHook(bundle_meta_1.bundleMetaHook);
|
|
16
|
+
deps.registerUpdateHook(agent_config_v2_1.agentConfigV2Hook);
|
|
15
17
|
const currentVersion = deps.getPackageVersion();
|
|
16
18
|
await deps.applyPendingUpdates(deps.bundlesRoot, currentVersion);
|
|
17
19
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -35,52 +35,95 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.configureDaemonRuntimeLogger = configureDaemonRuntimeLogger;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
|
-
const os = __importStar(require("os"));
|
|
39
38
|
const path = __importStar(require("path"));
|
|
40
39
|
const nerves_1 = require("../../nerves");
|
|
41
40
|
const runtime_1 = require("../../nerves/runtime");
|
|
42
|
-
const
|
|
41
|
+
const identity_1 = require("../identity");
|
|
42
|
+
const LEGACY_SHARED_RUNTIME_LOGGING = {
|
|
43
43
|
level: "info",
|
|
44
44
|
sinks: ["terminal", "ndjson"],
|
|
45
45
|
};
|
|
46
|
-
function
|
|
47
|
-
|
|
46
|
+
function defaultLoggingForProcess(processName) {
|
|
47
|
+
if (processName === "ouro" || processName === "ouro-bot") {
|
|
48
|
+
return {
|
|
49
|
+
level: "info",
|
|
50
|
+
sinks: ["ndjson"],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (processName === "bluebubbles") {
|
|
54
|
+
return {
|
|
55
|
+
level: "warn",
|
|
56
|
+
sinks: ["terminal", "ndjson"],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return { ...LEGACY_SHARED_RUNTIME_LOGGING };
|
|
48
60
|
}
|
|
49
61
|
function isLogLevel(value) {
|
|
50
62
|
return value === "debug" || value === "info" || value === "warn" || value === "error";
|
|
51
63
|
}
|
|
64
|
+
function normalizeSinks(value, fallback) {
|
|
65
|
+
if (!Array.isArray(value)) {
|
|
66
|
+
return [...fallback];
|
|
67
|
+
}
|
|
68
|
+
const sinks = value.filter((entry) => entry === "terminal" || entry === "ndjson");
|
|
69
|
+
return sinks.length > 0 ? [...new Set(sinks)] : [...fallback];
|
|
70
|
+
}
|
|
71
|
+
function isLegacySharedDefaultConfig(candidate, normalizedLevel, normalizedSinks) {
|
|
72
|
+
return normalizedLevel === LEGACY_SHARED_RUNTIME_LOGGING.level
|
|
73
|
+
&& normalizedSinks.length === LEGACY_SHARED_RUNTIME_LOGGING.sinks.length
|
|
74
|
+
&& LEGACY_SHARED_RUNTIME_LOGGING.sinks.every((sink) => normalizedSinks.includes(sink))
|
|
75
|
+
&& Object.keys(candidate).every((key) => key === "level" || key === "sinks");
|
|
76
|
+
}
|
|
52
77
|
function resolveRuntimeLoggingConfig(configPath, processName) {
|
|
53
|
-
const
|
|
78
|
+
const processDefault = defaultLoggingForProcess(processName);
|
|
54
79
|
let parsed = null;
|
|
55
80
|
try {
|
|
56
81
|
const raw = fs.readFileSync(configPath, "utf-8");
|
|
57
82
|
parsed = JSON.parse(raw);
|
|
58
83
|
}
|
|
59
84
|
catch {
|
|
60
|
-
return { ...
|
|
85
|
+
return { ...processDefault };
|
|
61
86
|
}
|
|
62
87
|
if (!parsed || typeof parsed !== "object") {
|
|
63
|
-
return { ...
|
|
88
|
+
return { ...processDefault };
|
|
64
89
|
}
|
|
65
90
|
const candidate = parsed;
|
|
66
|
-
const level = isLogLevel(candidate.level) ? candidate.level :
|
|
67
|
-
const sinks =
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
const level = isLogLevel(candidate.level) ? candidate.level : processDefault.level;
|
|
92
|
+
const sinks = normalizeSinks(candidate.sinks, processDefault.sinks);
|
|
93
|
+
if ((processName === "ouro" || processName === "ouro-bot")
|
|
94
|
+
&& isLegacySharedDefaultConfig(candidate, level, sinks)) {
|
|
95
|
+
return { ...processDefault };
|
|
96
|
+
}
|
|
70
97
|
return {
|
|
71
98
|
level,
|
|
72
|
-
sinks
|
|
99
|
+
sinks,
|
|
73
100
|
};
|
|
74
101
|
}
|
|
102
|
+
function resolveAgentNameForPaths(explicit) {
|
|
103
|
+
if (explicit && explicit.trim().length > 0)
|
|
104
|
+
return explicit.trim();
|
|
105
|
+
try {
|
|
106
|
+
return (0, identity_1.getAgentName)();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return "slugger";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
75
112
|
function configureDaemonRuntimeLogger(processName, options = {}) {
|
|
76
|
-
const
|
|
77
|
-
const configPath = options.configPath
|
|
113
|
+
const agentName = resolveAgentNameForPaths(options.agentName);
|
|
114
|
+
const configPath = options.configPath
|
|
115
|
+
?? (options.homeDir
|
|
116
|
+
? path.join(options.homeDir, "AgentBundles", `${agentName}.ouro`, "state", "daemon", "logging.json")
|
|
117
|
+
: (0, identity_1.getAgentDaemonLoggingConfigPath)(agentName));
|
|
78
118
|
const config = resolveRuntimeLoggingConfig(configPath, processName);
|
|
119
|
+
const logsDir = options.homeDir
|
|
120
|
+
? path.join(options.homeDir, "AgentBundles", `${agentName}.ouro`, "state", "daemon", "logs")
|
|
121
|
+
: (0, identity_1.getAgentDaemonLogsDir)(agentName);
|
|
79
122
|
const sinks = config.sinks.map((sinkName) => {
|
|
80
123
|
if (sinkName === "terminal") {
|
|
81
124
|
return (0, nerves_1.createTerminalSink)();
|
|
82
125
|
}
|
|
83
|
-
const ndjsonPath = path.join(
|
|
126
|
+
const ndjsonPath = path.join(logsDir, `${processName}.ndjson`);
|
|
84
127
|
return (0, nerves_1.createNdjsonFileSink)(ndjsonPath);
|
|
85
128
|
});
|
|
86
129
|
const logger = (0, nerves_1.createLogger)({
|
|
@@ -34,7 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getRuntimeMetadata = getRuntimeMetadata;
|
|
37
|
+
const crypto_1 = require("crypto");
|
|
37
38
|
const fs = __importStar(require("fs"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
38
40
|
const path = __importStar(require("path"));
|
|
39
41
|
const childProcess = __importStar(require("child_process"));
|
|
40
42
|
const identity_1 = require("../identity");
|
|
@@ -85,10 +87,98 @@ function readLastUpdated(repoRoot, packageJsonPath, statSyncImpl, execFileSyncIm
|
|
|
85
87
|
return { value: UNKNOWN_METADATA, source: "unknown" };
|
|
86
88
|
}
|
|
87
89
|
}
|
|
90
|
+
function readHomeDir() {
|
|
91
|
+
const homedirImpl = optionalFunction(os, "homedir");
|
|
92
|
+
if (!homedirImpl) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return homedirImpl.call(os);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function listConfigTargets(bundlesRoot, secretsRoot, daemonLoggingPath, readdirSyncImpl) {
|
|
103
|
+
if (!readdirSyncImpl)
|
|
104
|
+
return [];
|
|
105
|
+
const targets = new Set();
|
|
106
|
+
if (daemonLoggingPath) {
|
|
107
|
+
targets.add(daemonLoggingPath);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const bundleEntries = readdirSyncImpl(bundlesRoot, { withFileTypes: true });
|
|
111
|
+
for (const entry of bundleEntries) {
|
|
112
|
+
if (!entry.isDirectory() || !entry.name.endsWith(".ouro"))
|
|
113
|
+
continue;
|
|
114
|
+
targets.add(path.join(bundlesRoot, entry.name, "agent.json"));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// ignore unreadable bundle roots
|
|
119
|
+
}
|
|
120
|
+
if (secretsRoot) {
|
|
121
|
+
try {
|
|
122
|
+
const secretEntries = readdirSyncImpl(secretsRoot, { withFileTypes: true });
|
|
123
|
+
for (const entry of secretEntries) {
|
|
124
|
+
if (!entry.isDirectory())
|
|
125
|
+
continue;
|
|
126
|
+
targets.add(path.join(secretsRoot, entry.name, "secrets.json"));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// ignore unreadable secrets roots
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return [...targets].sort();
|
|
134
|
+
}
|
|
135
|
+
function readConfigFingerprint(targets, readFileSyncImpl, existsSyncImpl) {
|
|
136
|
+
if (!readFileSyncImpl || !existsSyncImpl) {
|
|
137
|
+
return {
|
|
138
|
+
value: UNKNOWN_METADATA,
|
|
139
|
+
source: "unknown",
|
|
140
|
+
trackedFiles: targets.length,
|
|
141
|
+
presentFiles: 0,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const hash = (0, crypto_1.createHash)("sha256");
|
|
145
|
+
let presentFiles = 0;
|
|
146
|
+
for (const target of targets) {
|
|
147
|
+
hash.update(target);
|
|
148
|
+
hash.update("\0");
|
|
149
|
+
if (!existsSyncImpl(target)) {
|
|
150
|
+
hash.update("missing");
|
|
151
|
+
hash.update("\0");
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
presentFiles += 1;
|
|
155
|
+
hash.update("present");
|
|
156
|
+
hash.update("\0");
|
|
157
|
+
try {
|
|
158
|
+
hash.update(readFileSyncImpl(target, "utf-8"));
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
hash.update("unreadable");
|
|
162
|
+
}
|
|
163
|
+
hash.update("\0");
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
value: hash.digest("hex"),
|
|
167
|
+
source: "content-hash",
|
|
168
|
+
trackedFiles: targets.length,
|
|
169
|
+
presentFiles,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
88
172
|
function getRuntimeMetadata(deps = {}) {
|
|
89
173
|
const repoRoot = deps.repoRoot ?? (0, identity_1.getRepoRoot)();
|
|
174
|
+
const bundlesRoot = deps.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
175
|
+
const homeDir = readHomeDir();
|
|
176
|
+
const secretsRoot = deps.secretsRoot ?? (homeDir ? path.join(homeDir, ".agentsecrets") : null);
|
|
177
|
+
const daemonLoggingPath = deps.daemonLoggingPath ?? (0, identity_1.getAgentDaemonLoggingConfigPath)();
|
|
90
178
|
const readFileSyncImpl = deps.readFileSync ?? optionalFunction(fs, "readFileSync")?.bind(fs) ?? null;
|
|
91
179
|
const statSyncImpl = deps.statSync ?? optionalFunction(fs, "statSync")?.bind(fs) ?? null;
|
|
180
|
+
const readdirSyncImpl = deps.readdirSync ?? optionalFunction(fs, "readdirSync")?.bind(fs) ?? null;
|
|
181
|
+
const existsSyncImpl = deps.existsSync ?? optionalFunction(fs, "existsSync")?.bind(fs) ?? null;
|
|
92
182
|
const execFileSyncImpl = deps.execFileSync
|
|
93
183
|
?? optionalFunction(childProcess, "execFileSync")?.bind(childProcess)
|
|
94
184
|
?? null;
|
|
@@ -101,6 +191,8 @@ function getRuntimeMetadata(deps = {}) {
|
|
|
101
191
|
throw new Error("git unavailable");
|
|
102
192
|
}))
|
|
103
193
|
: { value: UNKNOWN_METADATA, source: "unknown" };
|
|
194
|
+
const configTargets = listConfigTargets(bundlesRoot, secretsRoot, daemonLoggingPath, readdirSyncImpl);
|
|
195
|
+
const configFingerprint = readConfigFingerprint(configTargets, readFileSyncImpl, existsSyncImpl);
|
|
104
196
|
(0, runtime_1.emitNervesEvent)({
|
|
105
197
|
component: "daemon",
|
|
106
198
|
event: "daemon.runtime_metadata_read",
|
|
@@ -109,10 +201,19 @@ function getRuntimeMetadata(deps = {}) {
|
|
|
109
201
|
version,
|
|
110
202
|
lastUpdated: lastUpdated.value,
|
|
111
203
|
lastUpdatedSource: lastUpdated.source,
|
|
204
|
+
repoRoot,
|
|
205
|
+
configFingerprint: configFingerprint.value === UNKNOWN_METADATA
|
|
206
|
+
? UNKNOWN_METADATA
|
|
207
|
+
: configFingerprint.value.slice(0, 12),
|
|
208
|
+
configFingerprintSource: configFingerprint.source,
|
|
209
|
+
configTrackedFiles: configFingerprint.trackedFiles,
|
|
210
|
+
configPresentFiles: configFingerprint.presentFiles,
|
|
112
211
|
},
|
|
113
212
|
});
|
|
114
213
|
return {
|
|
115
214
|
version,
|
|
116
215
|
lastUpdated: lastUpdated.value,
|
|
216
|
+
repoRoot,
|
|
217
|
+
configFingerprint: configFingerprint.value,
|
|
117
218
|
};
|
|
118
219
|
}
|
|
@@ -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
|
+
}
|