@ouro.bot/cli 0.1.0-alpha.13 → 0.1.0-alpha.131
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/AdoptionSpecialist.ouro/psyche/SOUL.md +2 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +147 -205
- package/changelog.json +814 -0
- package/dist/heart/active-work.js +622 -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 +105 -0
- package/dist/heart/config.js +66 -21
- package/dist/heart/core.js +518 -100
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/auth-flow.js +457 -0
- package/dist/heart/daemon/daemon-cli.js +1516 -195
- package/dist/heart/daemon/daemon-entry.js +43 -2
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon.js +261 -1
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +7 -72
- package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
- package/dist/heart/daemon/launchd.js +159 -0
- package/dist/heart/daemon/log-tailer.js +4 -3
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-path-installer.js +57 -29
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- package/dist/heart/daemon/process-manager.js +13 -0
- package/dist/heart/daemon/run-hooks.js +37 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +219 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/sense-manager.js +50 -2
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/specialist-orchestrator.js +2 -2
- package/dist/heart/daemon/specialist-prompt.js +7 -4
- package/dist/heart/daemon/specialist-tools.js +52 -3
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +507 -0
- package/dist/heart/daemon/update-checker.js +111 -0
- package/dist/heart/daemon/update-hooks.js +138 -0
- package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/identity.js +64 -21
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/obligations.js +197 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-failover.js +88 -0
- package/dist/heart/provider-ping.js +159 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +195 -34
- package/dist/heart/providers/azure.js +115 -9
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +49 -14
- package/dist/heart/safe-workspace.js +381 -0
- package/dist/heart/session-activity.js +173 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/streaming.js +108 -24
- package/dist/heart/target-resolution.js +123 -0
- package/dist/heart/tool-loop.js +194 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/mind/associative-recall.js +14 -2
- package/dist/mind/bundle-manifest.js +12 -0
- package/dist/mind/context.js +60 -14
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +35 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/store-file.js +19 -0
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +8 -0
- package/dist/mind/memory.js +27 -26
- 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 +456 -77
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +15 -2
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/nerves/index.js +12 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/repertoire/ado-client.js +4 -2
- package/dist/repertoire/coding/context-pack.js +254 -0
- package/dist/repertoire/coding/feedback.js +301 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +210 -4
- package/dist/repertoire/coding/spawner.js +39 -9
- package/dist/repertoire/coding/tools.js +171 -4
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +290 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +198 -0
- package/dist/repertoire/skills.js +3 -26
- package/dist/repertoire/tasks/board.js +12 -0
- package/dist/repertoire/tasks/index.js +23 -9
- package/dist/repertoire/tasks/transitions.js +1 -2
- package/dist/repertoire/tools-base.js +925 -250
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +106 -53
- package/dist/senses/bluebubbles-client.js +210 -5
- package/dist/senses/bluebubbles-entry.js +2 -0
- package/dist/senses/bluebubbles-inbound-log.js +109 -0
- package/dist/senses/bluebubbles-media.js +339 -0
- package/dist/senses/bluebubbles-model.js +12 -4
- package/dist/senses/bluebubbles-mutation-log.js +45 -5
- package/dist/senses/bluebubbles-runtime-state.js +109 -0
- package/dist/senses/bluebubbles-session-cleanup.js +72 -0
- package/dist/senses/bluebubbles.js +915 -45
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +374 -131
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +154 -0
- package/dist/senses/inner-dialog-worker.js +47 -18
- package/dist/senses/inner-dialog.js +388 -83
- package/dist/senses/pipeline.js +444 -0
- package/dist/senses/teams.js +607 -129
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +9 -3
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- package/subagents/work-planner.md +0 -373
|
@@ -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");
|
|
@@ -9,6 +44,9 @@ const health_monitor_1 = require("./health-monitor");
|
|
|
9
44
|
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");
|
|
47
|
+
const agent_discovery_1 = require("./agent-discovery");
|
|
48
|
+
const identity_1 = require("../identity");
|
|
49
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
12
50
|
function parseSocketPath(argv) {
|
|
13
51
|
const socketIndex = argv.indexOf("--socket");
|
|
14
52
|
if (socketIndex >= 0) {
|
|
@@ -20,13 +58,15 @@ function parseSocketPath(argv) {
|
|
|
20
58
|
}
|
|
21
59
|
const socketPath = parseSocketPath(process.argv);
|
|
22
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)());
|
|
23
63
|
(0, runtime_1.emitNervesEvent)({
|
|
24
64
|
component: "daemon",
|
|
25
65
|
event: "daemon.entry_start",
|
|
26
66
|
message: "starting daemon entrypoint",
|
|
27
|
-
meta: { socketPath },
|
|
67
|
+
meta: { socketPath, entryPath, mode },
|
|
28
68
|
});
|
|
29
|
-
const managedAgents =
|
|
69
|
+
const managedAgents = (0, agent_discovery_1.listEnabledBundleAgents)();
|
|
30
70
|
const processManager = new process_manager_1.DaemonProcessManager({
|
|
31
71
|
agents: managedAgents.map((agent) => ({
|
|
32
72
|
name: agent,
|
|
@@ -34,6 +74,7 @@ const processManager = new process_manager_1.DaemonProcessManager({
|
|
|
34
74
|
channel: "inner-dialog",
|
|
35
75
|
autoStart: true,
|
|
36
76
|
})),
|
|
77
|
+
existsSync: fs.existsSync,
|
|
37
78
|
});
|
|
38
79
|
const scheduler = new task_scheduler_1.TaskDrivenScheduler({
|
|
39
80
|
agents: [...managedAgents],
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureCurrentDaemonRuntime = ensureCurrentDaemonRuntime;
|
|
4
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
5
|
+
function isKnownVersion(version) {
|
|
6
|
+
return version !== "unknown" && version.trim().length > 0;
|
|
7
|
+
}
|
|
8
|
+
function isKnownRuntimeValue(value) {
|
|
9
|
+
return typeof value === "string" && value.trim().length > 0 && value !== "unknown";
|
|
10
|
+
}
|
|
11
|
+
function formatErrorReason(error) {
|
|
12
|
+
return error instanceof Error ? error.message : String(error);
|
|
13
|
+
}
|
|
14
|
+
function normalizeRuntimeIdentity(value) {
|
|
15
|
+
return {
|
|
16
|
+
version: typeof value.version === "string" ? value.version : "unknown",
|
|
17
|
+
lastUpdated: typeof value.lastUpdated === "string" ? value.lastUpdated : "unknown",
|
|
18
|
+
repoRoot: typeof value.repoRoot === "string" ? value.repoRoot : "unknown",
|
|
19
|
+
configFingerprint: typeof value.configFingerprint === "string" ? value.configFingerprint : "unknown",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function readRunningRuntimeIdentity(deps) {
|
|
23
|
+
if (!deps.fetchRunningRuntimeMetadata) {
|
|
24
|
+
return normalizeRuntimeIdentity({
|
|
25
|
+
version: await deps.fetchRunningVersion(),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const metadata = normalizeRuntimeIdentity(await deps.fetchRunningRuntimeMetadata());
|
|
29
|
+
if (isKnownVersion(metadata.version))
|
|
30
|
+
return metadata;
|
|
31
|
+
return normalizeRuntimeIdentity({
|
|
32
|
+
...metadata,
|
|
33
|
+
version: await deps.fetchRunningVersion(),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function collectRuntimeDriftReasons(local, running) {
|
|
37
|
+
const reasons = [];
|
|
38
|
+
const comparableVersions = isKnownVersion(local.version) && isKnownVersion(running.version);
|
|
39
|
+
if (comparableVersions && local.version !== running.version) {
|
|
40
|
+
reasons.push({ key: "version", label: "version", local: local.version, running: running.version });
|
|
41
|
+
}
|
|
42
|
+
if (comparableVersions && isKnownRuntimeValue(local.lastUpdated) && isKnownRuntimeValue(running.lastUpdated) && local.lastUpdated !== running.lastUpdated) {
|
|
43
|
+
reasons.push({ key: "lastUpdated", label: "last updated", local: local.lastUpdated, running: running.lastUpdated });
|
|
44
|
+
}
|
|
45
|
+
if (isKnownRuntimeValue(local.repoRoot) && isKnownRuntimeValue(running.repoRoot) && local.repoRoot !== running.repoRoot) {
|
|
46
|
+
reasons.push({ key: "repoRoot", label: "code path", local: local.repoRoot, running: running.repoRoot });
|
|
47
|
+
}
|
|
48
|
+
if (isKnownRuntimeValue(local.configFingerprint)
|
|
49
|
+
&& isKnownRuntimeValue(running.configFingerprint)
|
|
50
|
+
&& local.configFingerprint !== running.configFingerprint) {
|
|
51
|
+
reasons.push({
|
|
52
|
+
key: "configFingerprint",
|
|
53
|
+
label: "config fingerprint",
|
|
54
|
+
local: local.configFingerprint,
|
|
55
|
+
running: running.configFingerprint,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return reasons;
|
|
59
|
+
}
|
|
60
|
+
function formatRuntimeValue(reason) {
|
|
61
|
+
if (reason.key === "configFingerprint") {
|
|
62
|
+
return `${reason.running.slice(0, 12)} -> ${reason.local.slice(0, 12)}`;
|
|
63
|
+
}
|
|
64
|
+
return `${reason.running} -> ${reason.local}`;
|
|
65
|
+
}
|
|
66
|
+
function formatRuntimeDriftSummary(reasons) {
|
|
67
|
+
return reasons.map((reason) => `${reason.label} ${formatRuntimeValue(reason)}`).join("; ");
|
|
68
|
+
}
|
|
69
|
+
async function ensureCurrentDaemonRuntime(deps) {
|
|
70
|
+
const localRuntime = normalizeRuntimeIdentity({
|
|
71
|
+
version: deps.localVersion,
|
|
72
|
+
lastUpdated: deps.localLastUpdated,
|
|
73
|
+
repoRoot: deps.localRepoRoot,
|
|
74
|
+
configFingerprint: deps.localConfigFingerprint,
|
|
75
|
+
});
|
|
76
|
+
try {
|
|
77
|
+
const runningRuntime = await readRunningRuntimeIdentity(deps);
|
|
78
|
+
const runningVersion = runningRuntime.version;
|
|
79
|
+
const driftReasons = collectRuntimeDriftReasons(localRuntime, runningRuntime);
|
|
80
|
+
let result;
|
|
81
|
+
if (driftReasons.length > 0) {
|
|
82
|
+
const includesVersionDrift = driftReasons.some((entry) => entry.key === "version");
|
|
83
|
+
const driftSummary = formatRuntimeDriftSummary(driftReasons);
|
|
84
|
+
try {
|
|
85
|
+
await deps.stopDaemon();
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const reason = formatErrorReason(error);
|
|
89
|
+
result = {
|
|
90
|
+
alreadyRunning: true,
|
|
91
|
+
message: includesVersionDrift
|
|
92
|
+
? `daemon already running (${deps.socketPath}; could not replace stale daemon ${runningVersion} -> ${deps.localVersion}: ${reason})`
|
|
93
|
+
: `daemon already running (${deps.socketPath}; could not replace drifted daemon ${driftSummary}: ${reason})`,
|
|
94
|
+
};
|
|
95
|
+
(0, runtime_1.emitNervesEvent)({
|
|
96
|
+
level: "warn",
|
|
97
|
+
component: "daemon",
|
|
98
|
+
event: "daemon.runtime_sync_decision",
|
|
99
|
+
message: "evaluated daemon runtime sync outcome",
|
|
100
|
+
meta: {
|
|
101
|
+
socketPath: deps.socketPath,
|
|
102
|
+
localVersion: deps.localVersion,
|
|
103
|
+
localLastUpdated: localRuntime.lastUpdated,
|
|
104
|
+
localRepoRoot: localRuntime.repoRoot,
|
|
105
|
+
localConfigFingerprint: localRuntime.configFingerprint,
|
|
106
|
+
runningVersion,
|
|
107
|
+
runningLastUpdated: runningRuntime.lastUpdated,
|
|
108
|
+
runningRepoRoot: runningRuntime.repoRoot,
|
|
109
|
+
runningConfigFingerprint: runningRuntime.configFingerprint,
|
|
110
|
+
action: "stale_replace_failed",
|
|
111
|
+
driftKeys: driftReasons.map((entry) => entry.key),
|
|
112
|
+
reason,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
deps.cleanupStaleSocket(deps.socketPath);
|
|
118
|
+
const started = await deps.startDaemonProcess(deps.socketPath);
|
|
119
|
+
result = {
|
|
120
|
+
alreadyRunning: false,
|
|
121
|
+
message: includesVersionDrift
|
|
122
|
+
? `restarted stale daemon from ${runningVersion} to ${deps.localVersion} (pid ${started.pid ?? "unknown"})`
|
|
123
|
+
: `restarted drifted daemon (${driftSummary}) (pid ${started.pid ?? "unknown"})`,
|
|
124
|
+
};
|
|
125
|
+
(0, runtime_1.emitNervesEvent)({
|
|
126
|
+
component: "daemon",
|
|
127
|
+
event: "daemon.runtime_sync_decision",
|
|
128
|
+
message: "evaluated daemon runtime sync outcome",
|
|
129
|
+
meta: {
|
|
130
|
+
socketPath: deps.socketPath,
|
|
131
|
+
localVersion: deps.localVersion,
|
|
132
|
+
localLastUpdated: localRuntime.lastUpdated,
|
|
133
|
+
localRepoRoot: localRuntime.repoRoot,
|
|
134
|
+
localConfigFingerprint: localRuntime.configFingerprint,
|
|
135
|
+
runningVersion,
|
|
136
|
+
runningLastUpdated: runningRuntime.lastUpdated,
|
|
137
|
+
runningRepoRoot: runningRuntime.repoRoot,
|
|
138
|
+
runningConfigFingerprint: runningRuntime.configFingerprint,
|
|
139
|
+
action: "stale_restarted",
|
|
140
|
+
driftKeys: driftReasons.map((entry) => entry.key),
|
|
141
|
+
pid: started.pid ?? null,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
if (!isKnownVersion(localRuntime.version) || !isKnownVersion(runningVersion)) {
|
|
147
|
+
result = {
|
|
148
|
+
alreadyRunning: true,
|
|
149
|
+
message: `daemon already running (${deps.socketPath}; unable to verify version)`,
|
|
150
|
+
};
|
|
151
|
+
(0, runtime_1.emitNervesEvent)({
|
|
152
|
+
component: "daemon",
|
|
153
|
+
event: "daemon.runtime_sync_decision",
|
|
154
|
+
message: "evaluated daemon runtime sync outcome",
|
|
155
|
+
meta: {
|
|
156
|
+
socketPath: deps.socketPath,
|
|
157
|
+
localVersion: deps.localVersion,
|
|
158
|
+
localLastUpdated: localRuntime.lastUpdated,
|
|
159
|
+
localRepoRoot: localRuntime.repoRoot,
|
|
160
|
+
localConfigFingerprint: localRuntime.configFingerprint,
|
|
161
|
+
runningVersion,
|
|
162
|
+
runningLastUpdated: runningRuntime.lastUpdated,
|
|
163
|
+
runningRepoRoot: runningRuntime.repoRoot,
|
|
164
|
+
runningConfigFingerprint: runningRuntime.configFingerprint,
|
|
165
|
+
action: "unknown_version",
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
const reason = formatErrorReason(error);
|
|
173
|
+
const result = {
|
|
174
|
+
alreadyRunning: true,
|
|
175
|
+
message: `daemon already running (${deps.socketPath}; unable to verify version: ${reason})`,
|
|
176
|
+
};
|
|
177
|
+
(0, runtime_1.emitNervesEvent)({
|
|
178
|
+
level: "warn",
|
|
179
|
+
component: "daemon",
|
|
180
|
+
event: "daemon.runtime_sync_decision",
|
|
181
|
+
message: "evaluated daemon runtime sync outcome",
|
|
182
|
+
meta: {
|
|
183
|
+
socketPath: deps.socketPath,
|
|
184
|
+
localVersion: deps.localVersion,
|
|
185
|
+
localLastUpdated: localRuntime.lastUpdated,
|
|
186
|
+
localRepoRoot: localRuntime.repoRoot,
|
|
187
|
+
localConfigFingerprint: localRuntime.configFingerprint,
|
|
188
|
+
action: "status_lookup_failed",
|
|
189
|
+
reason,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
const result = {
|
|
195
|
+
alreadyRunning: true,
|
|
196
|
+
message: `daemon already running (${deps.socketPath})`,
|
|
197
|
+
};
|
|
198
|
+
(0, runtime_1.emitNervesEvent)({
|
|
199
|
+
component: "daemon",
|
|
200
|
+
event: "daemon.runtime_sync_decision",
|
|
201
|
+
message: "evaluated daemon runtime sync outcome",
|
|
202
|
+
meta: {
|
|
203
|
+
socketPath: deps.socketPath,
|
|
204
|
+
localVersion: deps.localVersion,
|
|
205
|
+
localLastUpdated: localRuntime.lastUpdated,
|
|
206
|
+
localRepoRoot: localRuntime.repoRoot,
|
|
207
|
+
localConfigFingerprint: localRuntime.configFingerprint,
|
|
208
|
+
action: "already_current",
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
@@ -34,11 +34,98 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.OuroDaemon = void 0;
|
|
37
|
+
exports.killOrphanProcesses = killOrphanProcesses;
|
|
38
|
+
exports.writePidfile = writePidfile;
|
|
37
39
|
const fs = __importStar(require("fs"));
|
|
38
40
|
const net = __importStar(require("net"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
39
42
|
const path = __importStar(require("path"));
|
|
40
43
|
const identity_1 = require("../identity");
|
|
41
44
|
const runtime_1 = require("../../nerves/runtime");
|
|
45
|
+
const runtime_metadata_1 = require("./runtime-metadata");
|
|
46
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
47
|
+
const update_hooks_1 = require("./update-hooks");
|
|
48
|
+
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
49
|
+
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
50
|
+
const update_checker_1 = require("./update-checker");
|
|
51
|
+
const staged_restart_1 = require("./staged-restart");
|
|
52
|
+
const child_process_1 = require("child_process");
|
|
53
|
+
const pending_1 = require("../../mind/pending");
|
|
54
|
+
const channel_1 = require("../../mind/friends/channel");
|
|
55
|
+
const mcp_manager_1 = require("../../repertoire/mcp-manager");
|
|
56
|
+
const PIDFILE_PATH = path.join(os.homedir(), ".ouro-cli", "daemon.pids");
|
|
57
|
+
/**
|
|
58
|
+
* Kill all ouro processes from the previous daemon instance using the pidfile.
|
|
59
|
+
* On startup, reads PIDs from ~/.ouro-cli/daemon.pids, kills them all, then
|
|
60
|
+
* deletes the file. The new daemon writes its own PIDs after spawning.
|
|
61
|
+
*
|
|
62
|
+
* Falls back to ps-based scanning if the pidfile doesn't exist (first run
|
|
63
|
+
* or manual cleanup).
|
|
64
|
+
*/
|
|
65
|
+
/* v8 ignore start -- process lifecycle: uses kill/ps, tested via deployment @preserve */
|
|
66
|
+
function killOrphanProcesses() {
|
|
67
|
+
try {
|
|
68
|
+
let pidsToKill = [];
|
|
69
|
+
// Primary: read pidfile from previous daemon
|
|
70
|
+
try {
|
|
71
|
+
const raw = fs.readFileSync(PIDFILE_PATH, "utf-8");
|
|
72
|
+
pidsToKill = raw.split("\n").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n !== process.pid);
|
|
73
|
+
fs.unlinkSync(PIDFILE_PATH);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// No pidfile — fall back to ps scan
|
|
77
|
+
}
|
|
78
|
+
// Fallback: scan ps for any ouro entry processes we missed
|
|
79
|
+
if (pidsToKill.length === 0) {
|
|
80
|
+
try {
|
|
81
|
+
const result = (0, child_process_1.execSync)("ps -eo pid,command", { encoding: "utf-8", timeout: 5000 });
|
|
82
|
+
for (const line of result.split("\n")) {
|
|
83
|
+
if (!line.includes("agent-entry.js") && !line.includes("daemon-entry.js") && !line.includes("-entry.js --agent"))
|
|
84
|
+
continue;
|
|
85
|
+
const pid = parseInt(line.trim(), 10);
|
|
86
|
+
if (!isNaN(pid) && pid !== process.pid)
|
|
87
|
+
pidsToKill.push(pid);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch { /* ps failed — best effort */ }
|
|
91
|
+
}
|
|
92
|
+
if (pidsToKill.length > 0) {
|
|
93
|
+
for (const pid of pidsToKill) {
|
|
94
|
+
try {
|
|
95
|
+
process.kill(pid, "SIGTERM");
|
|
96
|
+
}
|
|
97
|
+
catch { /* already exited */ }
|
|
98
|
+
}
|
|
99
|
+
(0, runtime_1.emitNervesEvent)({
|
|
100
|
+
component: "daemon",
|
|
101
|
+
event: "daemon.orphan_cleanup",
|
|
102
|
+
message: `killed ${pidsToKill.length} orphaned ouro processes`,
|
|
103
|
+
meta: { pids: pidsToKill },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
(0, runtime_1.emitNervesEvent)({
|
|
109
|
+
level: "warn",
|
|
110
|
+
component: "daemon",
|
|
111
|
+
event: "daemon.orphan_cleanup_error",
|
|
112
|
+
message: "failed to clean up orphaned ouro processes",
|
|
113
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Write all managed PIDs (daemon + children) to the pidfile.
|
|
119
|
+
* Called after all agents and senses are spawned.
|
|
120
|
+
*/
|
|
121
|
+
function writePidfile(extraPids = []) {
|
|
122
|
+
try {
|
|
123
|
+
const pids = [process.pid, ...extraPids].filter(Boolean);
|
|
124
|
+
fs.mkdirSync(path.dirname(PIDFILE_PATH), { recursive: true });
|
|
125
|
+
fs.writeFileSync(PIDFILE_PATH, pids.join("\n") + "\n", "utf-8");
|
|
126
|
+
}
|
|
127
|
+
catch { /* best effort */ }
|
|
128
|
+
}
|
|
42
129
|
function buildWorkerRows(snapshots) {
|
|
43
130
|
return snapshots.map((snapshot) => ({
|
|
44
131
|
agent: snapshot.name,
|
|
@@ -106,11 +193,62 @@ class OuroDaemon {
|
|
|
106
193
|
message: "starting daemon server",
|
|
107
194
|
meta: { socketPath: this.socketPath },
|
|
108
195
|
});
|
|
196
|
+
// Register update hooks and apply pending updates before starting agents
|
|
197
|
+
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
198
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
199
|
+
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
200
|
+
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
201
|
+
const bundlesRoot = this.bundlesRoot;
|
|
202
|
+
const daemon = this;
|
|
203
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
204
|
+
currentVersion,
|
|
205
|
+
deps: {
|
|
206
|
+
distTag: "alpha",
|
|
207
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
208
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
209
|
+
return res.json();
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
213
|
+
if (!result.latestVersion)
|
|
214
|
+
return;
|
|
215
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
216
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
217
|
+
spawnSync: child_process_1.spawnSync,
|
|
218
|
+
resolveNewCodePath: (_version) => {
|
|
219
|
+
try {
|
|
220
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
221
|
+
return resolved ? path.dirname(resolved) : null;
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
gracefulShutdown: () => daemon.stop(),
|
|
228
|
+
nodePath: process.execPath,
|
|
229
|
+
bundlesRoot,
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
/* v8 ignore stop */
|
|
233
|
+
});
|
|
234
|
+
// Pre-initialize MCP connections so they're ready for the first command (non-blocking)
|
|
235
|
+
/* v8 ignore next -- catch callback: getSharedMcpManager logs errors internally @preserve */
|
|
236
|
+
(0, mcp_manager_1.getSharedMcpManager)().catch(() => { });
|
|
237
|
+
/* v8 ignore start -- orphan cleanup + pidfile: calls process management functions @preserve */
|
|
238
|
+
killOrphanProcesses();
|
|
239
|
+
/* v8 ignore stop */
|
|
109
240
|
await this.processManager.startAutoStartAgents();
|
|
110
241
|
await this.senseManager?.startAutoStartSenses();
|
|
242
|
+
// Write all managed PIDs to disk so the next daemon can clean up
|
|
243
|
+
/* v8 ignore start -- pidfile write: collects PIDs from process managers @preserve */
|
|
244
|
+
const agentPids = this.processManager.listAgentSnapshots().map((s) => s.pid).filter((p) => p !== null);
|
|
245
|
+
const sensePids = this.senseManager?.listManagedPids?.() ?? [];
|
|
246
|
+
writePidfile([...agentPids, ...sensePids]);
|
|
247
|
+
/* v8 ignore stop */
|
|
111
248
|
this.scheduler.start?.();
|
|
112
249
|
await this.scheduler.reconcile?.();
|
|
113
250
|
await this.drainPendingBundleMessages();
|
|
251
|
+
await this.drainPendingSenseMessages();
|
|
114
252
|
if (fs.existsSync(this.socketPath)) {
|
|
115
253
|
fs.unlinkSync(this.socketPath);
|
|
116
254
|
}
|
|
@@ -186,6 +324,93 @@ class OuroDaemon {
|
|
|
186
324
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
187
325
|
}
|
|
188
326
|
}
|
|
327
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
328
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
329
|
+
async drainPendingSenseMessages() {
|
|
330
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
331
|
+
return;
|
|
332
|
+
let bundleDirs;
|
|
333
|
+
try {
|
|
334
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
for (const bundleDir of bundleDirs) {
|
|
340
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
341
|
+
continue;
|
|
342
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
343
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
344
|
+
if (!fs.existsSync(pendingRoot))
|
|
345
|
+
continue;
|
|
346
|
+
let friendDirs;
|
|
347
|
+
try {
|
|
348
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
for (const friendDir of friendDirs) {
|
|
354
|
+
if (!friendDir.isDirectory())
|
|
355
|
+
continue;
|
|
356
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
357
|
+
let channelDirs;
|
|
358
|
+
try {
|
|
359
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
for (const channelDir of channelDirs) {
|
|
365
|
+
if (!channelDir.isDirectory())
|
|
366
|
+
continue;
|
|
367
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
368
|
+
continue;
|
|
369
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
370
|
+
let keyDirs;
|
|
371
|
+
try {
|
|
372
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
373
|
+
}
|
|
374
|
+
catch {
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
for (const keyDir of keyDirs) {
|
|
378
|
+
if (!keyDir.isDirectory())
|
|
379
|
+
continue;
|
|
380
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
381
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
382
|
+
for (const msg of messages) {
|
|
383
|
+
try {
|
|
384
|
+
await this.router.send({
|
|
385
|
+
from: msg.from,
|
|
386
|
+
to: agentName,
|
|
387
|
+
content: msg.content,
|
|
388
|
+
priority: "normal",
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
// Best-effort delivery — log and continue
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (messages.length > 0) {
|
|
396
|
+
(0, runtime_1.emitNervesEvent)({
|
|
397
|
+
component: "daemon",
|
|
398
|
+
event: "daemon.startup_sense_drain",
|
|
399
|
+
message: "drained pending sense messages on startup",
|
|
400
|
+
meta: {
|
|
401
|
+
agent: agentName,
|
|
402
|
+
channel: channelDir.name,
|
|
403
|
+
friendId: friendDir.name,
|
|
404
|
+
key: keyDir.name,
|
|
405
|
+
count: messages.length,
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
189
414
|
async stop() {
|
|
190
415
|
(0, runtime_1.emitNervesEvent)({
|
|
191
416
|
component: "daemon",
|
|
@@ -193,6 +418,8 @@ class OuroDaemon {
|
|
|
193
418
|
message: "stopping daemon server",
|
|
194
419
|
meta: { socketPath: this.socketPath },
|
|
195
420
|
});
|
|
421
|
+
(0, update_checker_1.stopUpdateChecker)();
|
|
422
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
196
423
|
this.scheduler.stop?.();
|
|
197
424
|
await this.processManager.stopAll();
|
|
198
425
|
await this.senseManager?.stopAll();
|
|
@@ -237,13 +464,17 @@ class OuroDaemon {
|
|
|
237
464
|
const snapshots = this.processManager.listAgentSnapshots();
|
|
238
465
|
const workers = buildWorkerRows(snapshots);
|
|
239
466
|
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
467
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
240
468
|
const data = {
|
|
241
469
|
overview: {
|
|
242
470
|
daemon: "running",
|
|
243
471
|
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
244
472
|
socketPath: this.socketPath,
|
|
473
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
245
474
|
workerCount: workers.length,
|
|
246
475
|
senseCount: senses.length,
|
|
476
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
477
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
247
478
|
},
|
|
248
479
|
workers,
|
|
249
480
|
senses,
|
|
@@ -264,7 +495,7 @@ class OuroDaemon {
|
|
|
264
495
|
ok: true,
|
|
265
496
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
266
497
|
message: "log streaming available via ouro logs",
|
|
267
|
-
data: { logDir: "
|
|
498
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
268
499
|
};
|
|
269
500
|
case "agent.start":
|
|
270
501
|
await this.processManager.startAgent(command.agent);
|
|
@@ -306,6 +537,13 @@ class OuroDaemon {
|
|
|
306
537
|
data: messages,
|
|
307
538
|
};
|
|
308
539
|
}
|
|
540
|
+
case "inner.wake":
|
|
541
|
+
await this.processManager.startAgent(command.agent);
|
|
542
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
543
|
+
return {
|
|
544
|
+
ok: true,
|
|
545
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
546
|
+
};
|
|
309
547
|
case "chat.connect":
|
|
310
548
|
await this.processManager.startAgent(command.agent);
|
|
311
549
|
return {
|
|
@@ -328,6 +566,28 @@ class OuroDaemon {
|
|
|
328
566
|
data: receipt,
|
|
329
567
|
};
|
|
330
568
|
}
|
|
569
|
+
case "mcp.list": {
|
|
570
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
571
|
+
if (!mcpManager) {
|
|
572
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
573
|
+
}
|
|
574
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
575
|
+
}
|
|
576
|
+
case "mcp.call": {
|
|
577
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
578
|
+
if (!mcpCallManager) {
|
|
579
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
580
|
+
}
|
|
581
|
+
try {
|
|
582
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
583
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
584
|
+
return { ok: true, data: result };
|
|
585
|
+
}
|
|
586
|
+
catch (error) {
|
|
587
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
588
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
589
|
+
}
|
|
590
|
+
}
|
|
331
591
|
case "hatch.start":
|
|
332
592
|
return {
|
|
333
593
|
ok: true,
|
|
@@ -20,9 +20,16 @@ async function playHatchAnimation(hatchlingName, writer) {
|
|
|
20
20
|
meta: { hatchlingName },
|
|
21
21
|
});
|
|
22
22
|
const write = writer ?? ((text) => process.stderr.write(text));
|
|
23
|
+
// Total animation time randomized between 3–5 seconds
|
|
24
|
+
const totalMs = 3000 + Math.floor(Math.random() * 2000);
|
|
25
|
+
const eggPhase = Math.floor(totalMs * 0.4);
|
|
26
|
+
const dotsPhase = Math.floor(totalMs * 0.4);
|
|
27
|
+
const revealPause = totalMs - eggPhase - dotsPhase;
|
|
23
28
|
write(`\n ${EGG}`);
|
|
24
|
-
await wait(
|
|
29
|
+
await wait(eggPhase);
|
|
25
30
|
write(DOTS);
|
|
26
|
-
await wait(
|
|
27
|
-
write(`${SNAKE} \x1b[1m${hatchlingName}\x1b[0m
|
|
31
|
+
await wait(dotsPhase);
|
|
32
|
+
write(`${SNAKE} \x1b[1m${hatchlingName}\x1b[0m`);
|
|
33
|
+
await wait(revealPause);
|
|
34
|
+
write("\n\n");
|
|
28
35
|
}
|