@ouro.bot/cli 0.1.0-alpha.8 → 0.1.0-alpha.81
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/agent.json +70 -9
- package/AdoptionSpecialist.ouro/psyche/SOUL.md +5 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +147 -205
- package/assets/ouroboros.png +0 -0
- package/changelog.json +468 -0
- package/dist/heart/active-work.js +218 -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 +89 -0
- package/dist/heart/config.js +68 -23
- package/dist/heart/core.js +452 -93
- 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 +1779 -247
- package/dist/heart/daemon/daemon-entry.js +55 -6
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon.js +216 -10
- 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 +260 -0
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/ouro-version-manager.js +164 -0
- package/dist/heart/daemon/process-manager.js +14 -1
- 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 +307 -0
- 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 +53 -84
- package/dist/heart/daemon/specialist-prompt.js +63 -11
- 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 +126 -21
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/obligations.js +141 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/providers/anthropic.js +74 -9
- package/dist/heart/providers/azure.js +86 -7
- package/dist/heart/providers/github-copilot.js +149 -0
- package/dist/heart/providers/minimax.js +4 -0
- package/dist/heart/providers/openai-codex.js +12 -3
- package/dist/heart/safe-workspace.js +228 -0
- package/dist/heart/sense-truth.js +61 -0
- package/dist/heart/session-activity.js +169 -0
- package/dist/heart/session-recall.js +116 -0
- package/dist/heart/streaming.js +100 -22
- package/dist/heart/target-resolution.js +123 -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 +27 -11
- 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/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +445 -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/feedback.js +134 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +62 -4
- package/dist/repertoire/coding/spawner.js +3 -3
- package/dist/repertoire/coding/tools.js +41 -2
- 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 +686 -251
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +95 -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 +894 -45
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +405 -156
- 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 +377 -83
- package/dist/senses/pipeline.js +307 -0
- package/dist/senses/teams.js +573 -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 -142
- package/dist/heart/daemon/subagent-installer.js +0 -125
- 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");
|
|
@@ -8,6 +43,10 @@ const message_router_1 = require("./message-router");
|
|
|
8
43
|
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");
|
|
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");
|
|
11
50
|
function parseSocketPath(argv) {
|
|
12
51
|
const socketIndex = argv.indexOf("--socket");
|
|
13
52
|
if (socketIndex >= 0) {
|
|
@@ -19,22 +58,31 @@ function parseSocketPath(argv) {
|
|
|
19
58
|
}
|
|
20
59
|
const socketPath = parseSocketPath(process.argv);
|
|
21
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)());
|
|
22
63
|
(0, runtime_1.emitNervesEvent)({
|
|
23
64
|
component: "daemon",
|
|
24
65
|
event: "daemon.entry_start",
|
|
25
66
|
message: "starting daemon entrypoint",
|
|
26
|
-
meta: { socketPath },
|
|
67
|
+
meta: { socketPath, entryPath, mode },
|
|
27
68
|
});
|
|
69
|
+
const managedAgents = (0, agent_discovery_1.listEnabledBundleAgents)();
|
|
28
70
|
const processManager = new process_manager_1.DaemonProcessManager({
|
|
29
|
-
agents:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
71
|
+
agents: managedAgents.map((agent) => ({
|
|
72
|
+
name: agent,
|
|
73
|
+
entry: "heart/agent-entry.js",
|
|
74
|
+
channel: "inner-dialog",
|
|
75
|
+
autoStart: true,
|
|
76
|
+
})),
|
|
77
|
+
existsSync: fs.existsSync,
|
|
33
78
|
});
|
|
34
79
|
const scheduler = new task_scheduler_1.TaskDrivenScheduler({
|
|
35
|
-
agents: [
|
|
80
|
+
agents: [...managedAgents],
|
|
36
81
|
});
|
|
37
82
|
const router = new message_router_1.FileMessageRouter();
|
|
83
|
+
const senseManager = new sense_manager_1.DaemonSenseManager({
|
|
84
|
+
agents: [...managedAgents],
|
|
85
|
+
});
|
|
38
86
|
const healthMonitor = new health_monitor_1.HealthMonitor({
|
|
39
87
|
processManager,
|
|
40
88
|
scheduler,
|
|
@@ -51,6 +99,7 @@ const healthMonitor = new health_monitor_1.HealthMonitor({
|
|
|
51
99
|
const daemon = new daemon_1.OuroDaemon({
|
|
52
100
|
socketPath,
|
|
53
101
|
processManager,
|
|
102
|
+
senseManager,
|
|
54
103
|
scheduler,
|
|
55
104
|
healthMonitor,
|
|
56
105
|
router,
|
|
@@ -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
|
+
}
|
|
@@ -39,14 +39,39 @@ const net = __importStar(require("net"));
|
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
const identity_1 = require("../identity");
|
|
41
41
|
const runtime_1 = require("../../nerves/runtime");
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const runtime_metadata_1 = require("./runtime-metadata");
|
|
43
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
44
|
+
const update_hooks_1 = require("./update-hooks");
|
|
45
|
+
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
46
|
+
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
47
|
+
const update_checker_1 = require("./update-checker");
|
|
48
|
+
const staged_restart_1 = require("./staged-restart");
|
|
49
|
+
const child_process_1 = require("child_process");
|
|
50
|
+
const pending_1 = require("../../mind/pending");
|
|
51
|
+
const channel_1 = require("../../mind/friends/channel");
|
|
52
|
+
const mcp_manager_1 = require("../../repertoire/mcp-manager");
|
|
53
|
+
function buildWorkerRows(snapshots) {
|
|
54
|
+
return snapshots.map((snapshot) => ({
|
|
55
|
+
agent: snapshot.name,
|
|
56
|
+
worker: snapshot.channel,
|
|
57
|
+
status: snapshot.status,
|
|
58
|
+
pid: snapshot.pid,
|
|
59
|
+
restartCount: snapshot.restartCount,
|
|
60
|
+
startedAt: snapshot.startedAt,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function formatStatusSummary(payload) {
|
|
64
|
+
if (payload.overview.workerCount === 0 && payload.overview.senseCount === 0) {
|
|
44
65
|
return "no managed agents";
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
66
|
+
}
|
|
67
|
+
const rows = [
|
|
68
|
+
...payload.workers.map((row) => `${row.agent}/${row.worker}:${row.status}`),
|
|
69
|
+
...payload.senses
|
|
70
|
+
.filter((row) => row.enabled)
|
|
71
|
+
.map((row) => `${row.agent}/${row.sense}:${row.status}`),
|
|
72
|
+
];
|
|
73
|
+
const detail = rows.length > 0 ? `\titems=${rows.join(",")}` : "";
|
|
74
|
+
return `daemon=${payload.overview.daemon}\tworkers=${payload.overview.workerCount}\tsenses=${payload.overview.senseCount}\thealth=${payload.overview.health}${detail}`;
|
|
50
75
|
}
|
|
51
76
|
function parseIncomingCommand(raw) {
|
|
52
77
|
let parsed;
|
|
@@ -71,6 +96,7 @@ class OuroDaemon {
|
|
|
71
96
|
scheduler;
|
|
72
97
|
healthMonitor;
|
|
73
98
|
router;
|
|
99
|
+
senseManager;
|
|
74
100
|
bundlesRoot;
|
|
75
101
|
server = null;
|
|
76
102
|
constructor(options) {
|
|
@@ -79,6 +105,7 @@ class OuroDaemon {
|
|
|
79
105
|
this.scheduler = options.scheduler;
|
|
80
106
|
this.healthMonitor = options.healthMonitor;
|
|
81
107
|
this.router = options.router;
|
|
108
|
+
this.senseManager = options.senseManager ?? null;
|
|
82
109
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
83
110
|
}
|
|
84
111
|
async start() {
|
|
@@ -90,10 +117,53 @@ class OuroDaemon {
|
|
|
90
117
|
message: "starting daemon server",
|
|
91
118
|
meta: { socketPath: this.socketPath },
|
|
92
119
|
});
|
|
120
|
+
// Register update hooks and apply pending updates before starting agents
|
|
121
|
+
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
122
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
123
|
+
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
124
|
+
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
125
|
+
const bundlesRoot = this.bundlesRoot;
|
|
126
|
+
const daemon = this;
|
|
127
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
128
|
+
currentVersion,
|
|
129
|
+
deps: {
|
|
130
|
+
distTag: "alpha",
|
|
131
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
132
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
133
|
+
return res.json();
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
137
|
+
if (!result.latestVersion)
|
|
138
|
+
return;
|
|
139
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
140
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
141
|
+
spawnSync: child_process_1.spawnSync,
|
|
142
|
+
resolveNewCodePath: (_version) => {
|
|
143
|
+
try {
|
|
144
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
145
|
+
return resolved ? path.dirname(resolved) : null;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
gracefulShutdown: () => daemon.stop(),
|
|
152
|
+
nodePath: process.execPath,
|
|
153
|
+
bundlesRoot,
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
/* v8 ignore stop */
|
|
157
|
+
});
|
|
158
|
+
// Pre-initialize MCP connections so they're ready for the first command (non-blocking)
|
|
159
|
+
/* v8 ignore next -- catch callback: getSharedMcpManager logs errors internally @preserve */
|
|
160
|
+
(0, mcp_manager_1.getSharedMcpManager)().catch(() => { });
|
|
93
161
|
await this.processManager.startAutoStartAgents();
|
|
162
|
+
await this.senseManager?.startAutoStartSenses();
|
|
94
163
|
this.scheduler.start?.();
|
|
95
164
|
await this.scheduler.reconcile?.();
|
|
96
165
|
await this.drainPendingBundleMessages();
|
|
166
|
+
await this.drainPendingSenseMessages();
|
|
97
167
|
if (fs.existsSync(this.socketPath)) {
|
|
98
168
|
fs.unlinkSync(this.socketPath);
|
|
99
169
|
}
|
|
@@ -169,6 +239,93 @@ class OuroDaemon {
|
|
|
169
239
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
170
240
|
}
|
|
171
241
|
}
|
|
242
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
243
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
244
|
+
async drainPendingSenseMessages() {
|
|
245
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
246
|
+
return;
|
|
247
|
+
let bundleDirs;
|
|
248
|
+
try {
|
|
249
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
for (const bundleDir of bundleDirs) {
|
|
255
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
256
|
+
continue;
|
|
257
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
258
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
259
|
+
if (!fs.existsSync(pendingRoot))
|
|
260
|
+
continue;
|
|
261
|
+
let friendDirs;
|
|
262
|
+
try {
|
|
263
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
for (const friendDir of friendDirs) {
|
|
269
|
+
if (!friendDir.isDirectory())
|
|
270
|
+
continue;
|
|
271
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
272
|
+
let channelDirs;
|
|
273
|
+
try {
|
|
274
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
for (const channelDir of channelDirs) {
|
|
280
|
+
if (!channelDir.isDirectory())
|
|
281
|
+
continue;
|
|
282
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
283
|
+
continue;
|
|
284
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
285
|
+
let keyDirs;
|
|
286
|
+
try {
|
|
287
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
for (const keyDir of keyDirs) {
|
|
293
|
+
if (!keyDir.isDirectory())
|
|
294
|
+
continue;
|
|
295
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
296
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
297
|
+
for (const msg of messages) {
|
|
298
|
+
try {
|
|
299
|
+
await this.router.send({
|
|
300
|
+
from: msg.from,
|
|
301
|
+
to: agentName,
|
|
302
|
+
content: msg.content,
|
|
303
|
+
priority: "normal",
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
// Best-effort delivery — log and continue
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (messages.length > 0) {
|
|
311
|
+
(0, runtime_1.emitNervesEvent)({
|
|
312
|
+
component: "daemon",
|
|
313
|
+
event: "daemon.startup_sense_drain",
|
|
314
|
+
message: "drained pending sense messages on startup",
|
|
315
|
+
meta: {
|
|
316
|
+
agent: agentName,
|
|
317
|
+
channel: channelDir.name,
|
|
318
|
+
friendId: friendDir.name,
|
|
319
|
+
key: keyDir.name,
|
|
320
|
+
count: messages.length,
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
172
329
|
async stop() {
|
|
173
330
|
(0, runtime_1.emitNervesEvent)({
|
|
174
331
|
component: "daemon",
|
|
@@ -176,8 +333,11 @@ class OuroDaemon {
|
|
|
176
333
|
message: "stopping daemon server",
|
|
177
334
|
meta: { socketPath: this.socketPath },
|
|
178
335
|
});
|
|
336
|
+
(0, update_checker_1.stopUpdateChecker)();
|
|
337
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
179
338
|
this.scheduler.stop?.();
|
|
180
339
|
await this.processManager.stopAll();
|
|
340
|
+
await this.senseManager?.stopAll();
|
|
181
341
|
if (this.server) {
|
|
182
342
|
await new Promise((resolve) => {
|
|
183
343
|
this.server?.close(() => resolve());
|
|
@@ -217,10 +377,27 @@ class OuroDaemon {
|
|
|
217
377
|
return { ok: true, message: "daemon stopped" };
|
|
218
378
|
case "daemon.status": {
|
|
219
379
|
const snapshots = this.processManager.listAgentSnapshots();
|
|
380
|
+
const workers = buildWorkerRows(snapshots);
|
|
381
|
+
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
382
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
383
|
+
const data = {
|
|
384
|
+
overview: {
|
|
385
|
+
daemon: "running",
|
|
386
|
+
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
387
|
+
socketPath: this.socketPath,
|
|
388
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
389
|
+
workerCount: workers.length,
|
|
390
|
+
senseCount: senses.length,
|
|
391
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
392
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
393
|
+
},
|
|
394
|
+
workers,
|
|
395
|
+
senses,
|
|
396
|
+
};
|
|
220
397
|
return {
|
|
221
398
|
ok: true,
|
|
222
|
-
summary: formatStatusSummary(
|
|
223
|
-
data
|
|
399
|
+
summary: formatStatusSummary(data),
|
|
400
|
+
data,
|
|
224
401
|
};
|
|
225
402
|
}
|
|
226
403
|
case "daemon.health": {
|
|
@@ -233,7 +410,7 @@ class OuroDaemon {
|
|
|
233
410
|
ok: true,
|
|
234
411
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
235
412
|
message: "log streaming available via ouro logs",
|
|
236
|
-
data: { logDir: "
|
|
413
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
237
414
|
};
|
|
238
415
|
case "agent.start":
|
|
239
416
|
await this.processManager.startAgent(command.agent);
|
|
@@ -275,6 +452,13 @@ class OuroDaemon {
|
|
|
275
452
|
data: messages,
|
|
276
453
|
};
|
|
277
454
|
}
|
|
455
|
+
case "inner.wake":
|
|
456
|
+
await this.processManager.startAgent(command.agent);
|
|
457
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
458
|
+
return {
|
|
459
|
+
ok: true,
|
|
460
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
461
|
+
};
|
|
278
462
|
case "chat.connect":
|
|
279
463
|
await this.processManager.startAgent(command.agent);
|
|
280
464
|
return {
|
|
@@ -297,6 +481,28 @@ class OuroDaemon {
|
|
|
297
481
|
data: receipt,
|
|
298
482
|
};
|
|
299
483
|
}
|
|
484
|
+
case "mcp.list": {
|
|
485
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
486
|
+
if (!mcpManager) {
|
|
487
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
488
|
+
}
|
|
489
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
490
|
+
}
|
|
491
|
+
case "mcp.call": {
|
|
492
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
493
|
+
if (!mcpCallManager) {
|
|
494
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
495
|
+
}
|
|
496
|
+
try {
|
|
497
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
498
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
499
|
+
return { ok: true, data: result };
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
503
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
504
|
+
}
|
|
505
|
+
}
|
|
300
506
|
case "hatch.start":
|
|
301
507
|
return {
|
|
302
508
|
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
|
}
|