@ouro.bot/cli 0.1.0-alpha.6 → 0.1.0-alpha.61
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 +334 -0
- package/dist/heart/active-work.js +178 -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/config.js +57 -23
- package/dist/heart/core.js +236 -90
- 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 +351 -0
- package/dist/heart/daemon/daemon-cli.js +1175 -232
- 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 +189 -10
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +4 -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 +178 -0
- package/dist/heart/daemon/ouro-uti.js +11 -2
- 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 +73 -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 +64 -5
- package/dist/heart/daemon/specialist-tools.js +213 -58
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +379 -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 +122 -19
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +40 -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/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 +72 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +299 -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/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/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 +629 -251
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +92 -48
- 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 +890 -45
- package/dist/senses/cli-layout.js +87 -0
- package/dist/senses/cli.js +345 -144
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +148 -0
- package/dist/senses/inner-dialog-worker.js +47 -18
- package/dist/senses/inner-dialog.js +330 -84
- package/dist/senses/pipeline.js +278 -0
- package/dist/senses/teams.js +570 -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,38 @@ 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
|
+
function buildWorkerRows(snapshots) {
|
|
53
|
+
return snapshots.map((snapshot) => ({
|
|
54
|
+
agent: snapshot.name,
|
|
55
|
+
worker: snapshot.channel,
|
|
56
|
+
status: snapshot.status,
|
|
57
|
+
pid: snapshot.pid,
|
|
58
|
+
restartCount: snapshot.restartCount,
|
|
59
|
+
startedAt: snapshot.startedAt,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
function formatStatusSummary(payload) {
|
|
63
|
+
if (payload.overview.workerCount === 0 && payload.overview.senseCount === 0) {
|
|
44
64
|
return "no managed agents";
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
}
|
|
66
|
+
const rows = [
|
|
67
|
+
...payload.workers.map((row) => `${row.agent}/${row.worker}:${row.status}`),
|
|
68
|
+
...payload.senses
|
|
69
|
+
.filter((row) => row.enabled)
|
|
70
|
+
.map((row) => `${row.agent}/${row.sense}:${row.status}`),
|
|
71
|
+
];
|
|
72
|
+
const detail = rows.length > 0 ? `\titems=${rows.join(",")}` : "";
|
|
73
|
+
return `daemon=${payload.overview.daemon}\tworkers=${payload.overview.workerCount}\tsenses=${payload.overview.senseCount}\thealth=${payload.overview.health}${detail}`;
|
|
50
74
|
}
|
|
51
75
|
function parseIncomingCommand(raw) {
|
|
52
76
|
let parsed;
|
|
@@ -71,6 +95,7 @@ class OuroDaemon {
|
|
|
71
95
|
scheduler;
|
|
72
96
|
healthMonitor;
|
|
73
97
|
router;
|
|
98
|
+
senseManager;
|
|
74
99
|
bundlesRoot;
|
|
75
100
|
server = null;
|
|
76
101
|
constructor(options) {
|
|
@@ -79,6 +104,7 @@ class OuroDaemon {
|
|
|
79
104
|
this.scheduler = options.scheduler;
|
|
80
105
|
this.healthMonitor = options.healthMonitor;
|
|
81
106
|
this.router = options.router;
|
|
107
|
+
this.senseManager = options.senseManager ?? null;
|
|
82
108
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
83
109
|
}
|
|
84
110
|
async start() {
|
|
@@ -90,10 +116,50 @@ class OuroDaemon {
|
|
|
90
116
|
message: "starting daemon server",
|
|
91
117
|
meta: { socketPath: this.socketPath },
|
|
92
118
|
});
|
|
119
|
+
// Register update hooks and apply pending updates before starting agents
|
|
120
|
+
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
121
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
122
|
+
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
123
|
+
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
124
|
+
const bundlesRoot = this.bundlesRoot;
|
|
125
|
+
const daemon = this;
|
|
126
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
127
|
+
currentVersion,
|
|
128
|
+
deps: {
|
|
129
|
+
distTag: "alpha",
|
|
130
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
131
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
132
|
+
return res.json();
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
136
|
+
if (!result.latestVersion)
|
|
137
|
+
return;
|
|
138
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
139
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
140
|
+
spawnSync: child_process_1.spawnSync,
|
|
141
|
+
resolveNewCodePath: (_version) => {
|
|
142
|
+
try {
|
|
143
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
144
|
+
return resolved ? path.dirname(resolved) : null;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
gracefulShutdown: () => daemon.stop(),
|
|
151
|
+
nodePath: process.execPath,
|
|
152
|
+
bundlesRoot,
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
/* v8 ignore stop */
|
|
156
|
+
});
|
|
93
157
|
await this.processManager.startAutoStartAgents();
|
|
158
|
+
await this.senseManager?.startAutoStartSenses();
|
|
94
159
|
this.scheduler.start?.();
|
|
95
160
|
await this.scheduler.reconcile?.();
|
|
96
161
|
await this.drainPendingBundleMessages();
|
|
162
|
+
await this.drainPendingSenseMessages();
|
|
97
163
|
if (fs.existsSync(this.socketPath)) {
|
|
98
164
|
fs.unlinkSync(this.socketPath);
|
|
99
165
|
}
|
|
@@ -169,6 +235,93 @@ class OuroDaemon {
|
|
|
169
235
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
170
236
|
}
|
|
171
237
|
}
|
|
238
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
239
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
240
|
+
async drainPendingSenseMessages() {
|
|
241
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
242
|
+
return;
|
|
243
|
+
let bundleDirs;
|
|
244
|
+
try {
|
|
245
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
for (const bundleDir of bundleDirs) {
|
|
251
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
252
|
+
continue;
|
|
253
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
254
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
255
|
+
if (!fs.existsSync(pendingRoot))
|
|
256
|
+
continue;
|
|
257
|
+
let friendDirs;
|
|
258
|
+
try {
|
|
259
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
for (const friendDir of friendDirs) {
|
|
265
|
+
if (!friendDir.isDirectory())
|
|
266
|
+
continue;
|
|
267
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
268
|
+
let channelDirs;
|
|
269
|
+
try {
|
|
270
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
for (const channelDir of channelDirs) {
|
|
276
|
+
if (!channelDir.isDirectory())
|
|
277
|
+
continue;
|
|
278
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
279
|
+
continue;
|
|
280
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
281
|
+
let keyDirs;
|
|
282
|
+
try {
|
|
283
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
for (const keyDir of keyDirs) {
|
|
289
|
+
if (!keyDir.isDirectory())
|
|
290
|
+
continue;
|
|
291
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
292
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
293
|
+
for (const msg of messages) {
|
|
294
|
+
try {
|
|
295
|
+
await this.router.send({
|
|
296
|
+
from: msg.from,
|
|
297
|
+
to: agentName,
|
|
298
|
+
content: msg.content,
|
|
299
|
+
priority: "normal",
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
// Best-effort delivery — log and continue
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (messages.length > 0) {
|
|
307
|
+
(0, runtime_1.emitNervesEvent)({
|
|
308
|
+
component: "daemon",
|
|
309
|
+
event: "daemon.startup_sense_drain",
|
|
310
|
+
message: "drained pending sense messages on startup",
|
|
311
|
+
meta: {
|
|
312
|
+
agent: agentName,
|
|
313
|
+
channel: channelDir.name,
|
|
314
|
+
friendId: friendDir.name,
|
|
315
|
+
key: keyDir.name,
|
|
316
|
+
count: messages.length,
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
172
325
|
async stop() {
|
|
173
326
|
(0, runtime_1.emitNervesEvent)({
|
|
174
327
|
component: "daemon",
|
|
@@ -176,8 +329,10 @@ class OuroDaemon {
|
|
|
176
329
|
message: "stopping daemon server",
|
|
177
330
|
meta: { socketPath: this.socketPath },
|
|
178
331
|
});
|
|
332
|
+
(0, update_checker_1.stopUpdateChecker)();
|
|
179
333
|
this.scheduler.stop?.();
|
|
180
334
|
await this.processManager.stopAll();
|
|
335
|
+
await this.senseManager?.stopAll();
|
|
181
336
|
if (this.server) {
|
|
182
337
|
await new Promise((resolve) => {
|
|
183
338
|
this.server?.close(() => resolve());
|
|
@@ -217,10 +372,27 @@ class OuroDaemon {
|
|
|
217
372
|
return { ok: true, message: "daemon stopped" };
|
|
218
373
|
case "daemon.status": {
|
|
219
374
|
const snapshots = this.processManager.listAgentSnapshots();
|
|
375
|
+
const workers = buildWorkerRows(snapshots);
|
|
376
|
+
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
377
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
378
|
+
const data = {
|
|
379
|
+
overview: {
|
|
380
|
+
daemon: "running",
|
|
381
|
+
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
382
|
+
socketPath: this.socketPath,
|
|
383
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
384
|
+
workerCount: workers.length,
|
|
385
|
+
senseCount: senses.length,
|
|
386
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
387
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
388
|
+
},
|
|
389
|
+
workers,
|
|
390
|
+
senses,
|
|
391
|
+
};
|
|
220
392
|
return {
|
|
221
393
|
ok: true,
|
|
222
|
-
summary: formatStatusSummary(
|
|
223
|
-
data
|
|
394
|
+
summary: formatStatusSummary(data),
|
|
395
|
+
data,
|
|
224
396
|
};
|
|
225
397
|
}
|
|
226
398
|
case "daemon.health": {
|
|
@@ -233,7 +405,7 @@ class OuroDaemon {
|
|
|
233
405
|
ok: true,
|
|
234
406
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
235
407
|
message: "log streaming available via ouro logs",
|
|
236
|
-
data: { logDir: "
|
|
408
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
237
409
|
};
|
|
238
410
|
case "agent.start":
|
|
239
411
|
await this.processManager.startAgent(command.agent);
|
|
@@ -275,6 +447,13 @@ class OuroDaemon {
|
|
|
275
447
|
data: messages,
|
|
276
448
|
};
|
|
277
449
|
}
|
|
450
|
+
case "inner.wake":
|
|
451
|
+
await this.processManager.startAgent(command.agent);
|
|
452
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
453
|
+
return {
|
|
454
|
+
ok: true,
|
|
455
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
456
|
+
};
|
|
278
457
|
case "chat.connect":
|
|
279
458
|
await this.processManager.startAgent(command.agent);
|
|
280
459
|
return {
|
|
@@ -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
|
}
|