@ouro.bot/cli 0.1.0-alpha.12 → 0.1.0-alpha.121
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/assets/ouroboros.png +0 -0
- package/changelog.json +737 -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 +68 -23
- package/dist/heart/core.js +528 -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 +430 -0
- package/dist/heart/daemon/daemon-cli.js +1601 -207
- 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 +226 -1
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +7 -82
- 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-entry.js +0 -0
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-entry.js +0 -0
- package/dist/heart/daemon/ouro-path-installer.js +59 -15
- package/dist/heart/daemon/ouro-uti.js +11 -2
- 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 +43 -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 +37 -94
- package/dist/heart/daemon/specialist-prompt.js +50 -12
- package/dist/heart/daemon/specialist-tools.js +211 -60
- 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 +151 -0
- package/dist/heart/providers/anthropic.js +107 -20
- 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 +169 -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 +70 -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 +459 -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/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 +195 -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 +912 -45
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +477 -170
- 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 +14 -3
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/specialist-session.js +0 -177
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/dist/inner-worker-entry.js +0 -4
- 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,71 @@ 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;
|
|
37
38
|
const fs = __importStar(require("fs"));
|
|
38
39
|
const net = __importStar(require("net"));
|
|
39
40
|
const path = __importStar(require("path"));
|
|
40
41
|
const identity_1 = require("../identity");
|
|
41
42
|
const runtime_1 = require("../../nerves/runtime");
|
|
43
|
+
const runtime_metadata_1 = require("./runtime-metadata");
|
|
44
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
45
|
+
const update_hooks_1 = require("./update-hooks");
|
|
46
|
+
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
47
|
+
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
48
|
+
const update_checker_1 = require("./update-checker");
|
|
49
|
+
const staged_restart_1 = require("./staged-restart");
|
|
50
|
+
const child_process_1 = require("child_process");
|
|
51
|
+
const pending_1 = require("../../mind/pending");
|
|
52
|
+
const channel_1 = require("../../mind/friends/channel");
|
|
53
|
+
const mcp_manager_1 = require("../../repertoire/mcp-manager");
|
|
54
|
+
/**
|
|
55
|
+
* Kill ALL orphaned ouro processes from previous daemon instances.
|
|
56
|
+
* On each `ouro up`, old daemon AND agent processes persist because:
|
|
57
|
+
* - Daemons are spawned detached and never killed on restart
|
|
58
|
+
* - Each old daemon keeps respawning agents from its own (stale) code
|
|
59
|
+
* This scans for both daemon-entry.js and agent-entry.js processes
|
|
60
|
+
* and kills everything except the current process.
|
|
61
|
+
*/
|
|
62
|
+
/* v8 ignore start -- orphan cleanup: uses ps/kill, tested via deployment @preserve */
|
|
63
|
+
function killOrphanProcesses() {
|
|
64
|
+
try {
|
|
65
|
+
const myPid = process.pid;
|
|
66
|
+
const result = (0, child_process_1.execSync)("ps -eo pid,command", { encoding: "utf-8", timeout: 5000 });
|
|
67
|
+
const pidsToKill = [];
|
|
68
|
+
for (const line of result.split("\n")) {
|
|
69
|
+
if (!line.includes("agent-entry.js") && !line.includes("daemon-entry.js") && !line.includes("-entry.js --agent"))
|
|
70
|
+
continue;
|
|
71
|
+
const trimmed = line.trim();
|
|
72
|
+
const pid = parseInt(trimmed, 10);
|
|
73
|
+
if (isNaN(pid) || pid === myPid)
|
|
74
|
+
continue;
|
|
75
|
+
pidsToKill.push(pid);
|
|
76
|
+
}
|
|
77
|
+
if (pidsToKill.length > 0) {
|
|
78
|
+
for (const pid of pidsToKill) {
|
|
79
|
+
try {
|
|
80
|
+
process.kill(pid, "SIGTERM");
|
|
81
|
+
}
|
|
82
|
+
catch { /* already exited */ }
|
|
83
|
+
}
|
|
84
|
+
(0, runtime_1.emitNervesEvent)({
|
|
85
|
+
component: "daemon",
|
|
86
|
+
event: "daemon.orphan_cleanup",
|
|
87
|
+
message: `killed ${pidsToKill.length} orphaned ouro processes`,
|
|
88
|
+
meta: { pids: pidsToKill },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
(0, runtime_1.emitNervesEvent)({
|
|
94
|
+
level: "warn",
|
|
95
|
+
component: "daemon",
|
|
96
|
+
event: "daemon.orphan_cleanup_error",
|
|
97
|
+
message: "failed to clean up orphaned ouro processes",
|
|
98
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
42
102
|
function buildWorkerRows(snapshots) {
|
|
43
103
|
return snapshots.map((snapshot) => ({
|
|
44
104
|
agent: snapshot.name,
|
|
@@ -106,11 +166,54 @@ class OuroDaemon {
|
|
|
106
166
|
message: "starting daemon server",
|
|
107
167
|
meta: { socketPath: this.socketPath },
|
|
108
168
|
});
|
|
169
|
+
// Register update hooks and apply pending updates before starting agents
|
|
170
|
+
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
171
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
172
|
+
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
173
|
+
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
174
|
+
const bundlesRoot = this.bundlesRoot;
|
|
175
|
+
const daemon = this;
|
|
176
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
177
|
+
currentVersion,
|
|
178
|
+
deps: {
|
|
179
|
+
distTag: "alpha",
|
|
180
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
181
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
182
|
+
return res.json();
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
186
|
+
if (!result.latestVersion)
|
|
187
|
+
return;
|
|
188
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
189
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
190
|
+
spawnSync: child_process_1.spawnSync,
|
|
191
|
+
resolveNewCodePath: (_version) => {
|
|
192
|
+
try {
|
|
193
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
194
|
+
return resolved ? path.dirname(resolved) : null;
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
gracefulShutdown: () => daemon.stop(),
|
|
201
|
+
nodePath: process.execPath,
|
|
202
|
+
bundlesRoot,
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
/* v8 ignore stop */
|
|
206
|
+
});
|
|
207
|
+
// Pre-initialize MCP connections so they're ready for the first command (non-blocking)
|
|
208
|
+
/* v8 ignore next -- catch callback: getSharedMcpManager logs errors internally @preserve */
|
|
209
|
+
(0, mcp_manager_1.getSharedMcpManager)().catch(() => { });
|
|
210
|
+
killOrphanProcesses();
|
|
109
211
|
await this.processManager.startAutoStartAgents();
|
|
110
212
|
await this.senseManager?.startAutoStartSenses();
|
|
111
213
|
this.scheduler.start?.();
|
|
112
214
|
await this.scheduler.reconcile?.();
|
|
113
215
|
await this.drainPendingBundleMessages();
|
|
216
|
+
await this.drainPendingSenseMessages();
|
|
114
217
|
if (fs.existsSync(this.socketPath)) {
|
|
115
218
|
fs.unlinkSync(this.socketPath);
|
|
116
219
|
}
|
|
@@ -186,6 +289,93 @@ class OuroDaemon {
|
|
|
186
289
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
187
290
|
}
|
|
188
291
|
}
|
|
292
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
293
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
294
|
+
async drainPendingSenseMessages() {
|
|
295
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
296
|
+
return;
|
|
297
|
+
let bundleDirs;
|
|
298
|
+
try {
|
|
299
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
for (const bundleDir of bundleDirs) {
|
|
305
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
306
|
+
continue;
|
|
307
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
308
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
309
|
+
if (!fs.existsSync(pendingRoot))
|
|
310
|
+
continue;
|
|
311
|
+
let friendDirs;
|
|
312
|
+
try {
|
|
313
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
for (const friendDir of friendDirs) {
|
|
319
|
+
if (!friendDir.isDirectory())
|
|
320
|
+
continue;
|
|
321
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
322
|
+
let channelDirs;
|
|
323
|
+
try {
|
|
324
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
for (const channelDir of channelDirs) {
|
|
330
|
+
if (!channelDir.isDirectory())
|
|
331
|
+
continue;
|
|
332
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
333
|
+
continue;
|
|
334
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
335
|
+
let keyDirs;
|
|
336
|
+
try {
|
|
337
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
for (const keyDir of keyDirs) {
|
|
343
|
+
if (!keyDir.isDirectory())
|
|
344
|
+
continue;
|
|
345
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
346
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
347
|
+
for (const msg of messages) {
|
|
348
|
+
try {
|
|
349
|
+
await this.router.send({
|
|
350
|
+
from: msg.from,
|
|
351
|
+
to: agentName,
|
|
352
|
+
content: msg.content,
|
|
353
|
+
priority: "normal",
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
// Best-effort delivery — log and continue
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (messages.length > 0) {
|
|
361
|
+
(0, runtime_1.emitNervesEvent)({
|
|
362
|
+
component: "daemon",
|
|
363
|
+
event: "daemon.startup_sense_drain",
|
|
364
|
+
message: "drained pending sense messages on startup",
|
|
365
|
+
meta: {
|
|
366
|
+
agent: agentName,
|
|
367
|
+
channel: channelDir.name,
|
|
368
|
+
friendId: friendDir.name,
|
|
369
|
+
key: keyDir.name,
|
|
370
|
+
count: messages.length,
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
189
379
|
async stop() {
|
|
190
380
|
(0, runtime_1.emitNervesEvent)({
|
|
191
381
|
component: "daemon",
|
|
@@ -193,6 +383,8 @@ class OuroDaemon {
|
|
|
193
383
|
message: "stopping daemon server",
|
|
194
384
|
meta: { socketPath: this.socketPath },
|
|
195
385
|
});
|
|
386
|
+
(0, update_checker_1.stopUpdateChecker)();
|
|
387
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
196
388
|
this.scheduler.stop?.();
|
|
197
389
|
await this.processManager.stopAll();
|
|
198
390
|
await this.senseManager?.stopAll();
|
|
@@ -237,13 +429,17 @@ class OuroDaemon {
|
|
|
237
429
|
const snapshots = this.processManager.listAgentSnapshots();
|
|
238
430
|
const workers = buildWorkerRows(snapshots);
|
|
239
431
|
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
432
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
240
433
|
const data = {
|
|
241
434
|
overview: {
|
|
242
435
|
daemon: "running",
|
|
243
436
|
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
244
437
|
socketPath: this.socketPath,
|
|
438
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
245
439
|
workerCount: workers.length,
|
|
246
440
|
senseCount: senses.length,
|
|
441
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
442
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
247
443
|
},
|
|
248
444
|
workers,
|
|
249
445
|
senses,
|
|
@@ -264,7 +460,7 @@ class OuroDaemon {
|
|
|
264
460
|
ok: true,
|
|
265
461
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
266
462
|
message: "log streaming available via ouro logs",
|
|
267
|
-
data: { logDir: "
|
|
463
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
268
464
|
};
|
|
269
465
|
case "agent.start":
|
|
270
466
|
await this.processManager.startAgent(command.agent);
|
|
@@ -306,6 +502,13 @@ class OuroDaemon {
|
|
|
306
502
|
data: messages,
|
|
307
503
|
};
|
|
308
504
|
}
|
|
505
|
+
case "inner.wake":
|
|
506
|
+
await this.processManager.startAgent(command.agent);
|
|
507
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
508
|
+
return {
|
|
509
|
+
ok: true,
|
|
510
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
511
|
+
};
|
|
309
512
|
case "chat.connect":
|
|
310
513
|
await this.processManager.startAgent(command.agent);
|
|
311
514
|
return {
|
|
@@ -328,6 +531,28 @@ class OuroDaemon {
|
|
|
328
531
|
data: receipt,
|
|
329
532
|
};
|
|
330
533
|
}
|
|
534
|
+
case "mcp.list": {
|
|
535
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
536
|
+
if (!mcpManager) {
|
|
537
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
538
|
+
}
|
|
539
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
540
|
+
}
|
|
541
|
+
case "mcp.call": {
|
|
542
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
543
|
+
if (!mcpCallManager) {
|
|
544
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
545
|
+
}
|
|
546
|
+
try {
|
|
547
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
548
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
549
|
+
return { ok: true, data: result };
|
|
550
|
+
}
|
|
551
|
+
catch (error) {
|
|
552
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
553
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
554
|
+
}
|
|
555
|
+
}
|
|
331
556
|
case "hatch.start":
|
|
332
557
|
return {
|
|
333
558
|
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
|
}
|