@ouro.bot/cli 0.1.0-alpha.14 → 0.1.0-alpha.141
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 +151 -205
- package/changelog.json +913 -0
- package/dist/heart/active-work.js +633 -0
- package/dist/heart/bridges/manager.js +358 -0
- package/dist/heart/bridges/state-machine.js +135 -0
- package/dist/heart/bridges/store.js +123 -0
- package/dist/heart/commitments.js +105 -0
- package/dist/heart/config.js +66 -21
- package/dist/heart/core.js +645 -112
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/agent-service.js +467 -0
- package/dist/heart/daemon/auth-flow.js +457 -0
- package/dist/heart/daemon/daemon-cli.js +1840 -196
- package/dist/heart/daemon/daemon-entry.js +80 -3
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon.js +301 -1
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +15 -80
- package/dist/heart/daemon/heartbeat-timer.js +131 -0
- 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/mcp-server.js +464 -0
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-path-installer.js +67 -34
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- package/dist/heart/daemon/process-manager.js +13 -0
- package/dist/heart/daemon/run-hooks.js +37 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +219 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/sense-manager.js +50 -2
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/specialist-orchestrator.js +2 -2
- package/dist/heart/daemon/specialist-prompt.js +10 -7
- package/dist/heart/daemon/specialist-tools.js +52 -3
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +507 -0
- package/dist/heart/daemon/update-checker.js +111 -0
- package/dist/heart/daemon/update-hooks.js +138 -0
- package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/identity.js +64 -21
- package/dist/heart/kicks.js +2 -20
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/obligations.js +197 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-failover.js +88 -0
- package/dist/heart/provider-ping.js +159 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +195 -34
- package/dist/heart/providers/azure.js +115 -9
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +49 -14
- package/dist/heart/session-activity.js +173 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/streaming.js +117 -33
- package/dist/heart/target-resolution.js +123 -0
- package/dist/heart/tool-loop.js +200 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/mind/associative-recall.js +122 -32
- package/dist/mind/bundle-manifest.js +14 -0
- package/dist/mind/context.js +125 -14
- package/dist/mind/{memory.js → diary.js} +70 -56
- 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/journal-index.js +161 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/obligations.js +134 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +554 -88
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +15 -2
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/nerves/index.js +12 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/repertoire/ado-client.js +4 -2
- package/dist/repertoire/ado-semantic.js +6 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- 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 +59 -12
- package/dist/repertoire/coding/tools.js +176 -4
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +290 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +198 -0
- package/dist/repertoire/skills.js +14 -23
- 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 +980 -271
- package/dist/repertoire/tools-bluebubbles.js +94 -0
- package/dist/repertoire/tools-github.js +1 -6
- package/dist/repertoire/tools-teams.js +65 -59
- package/dist/repertoire/tools.js +266 -91
- package/dist/senses/attention-queue.js +97 -0
- 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 +944 -45
- package/dist/senses/cli-entry.js +1 -1
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +374 -131
- package/dist/senses/contextual-heartbeat.js +102 -0
- 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 +500 -84
- package/dist/senses/pipeline.js +454 -0
- package/dist/senses/surface-tool.js +82 -0
- package/dist/senses/teams.js +607 -129
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +12 -4
- package/skills/configure-dev-tools.md +109 -0
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- package/subagents/work-planner.md +0 -373
|
@@ -34,11 +34,99 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.OuroDaemon = void 0;
|
|
37
|
+
exports.killOrphanProcesses = killOrphanProcesses;
|
|
38
|
+
exports.writePidfile = writePidfile;
|
|
37
39
|
const fs = __importStar(require("fs"));
|
|
38
40
|
const net = __importStar(require("net"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
39
42
|
const path = __importStar(require("path"));
|
|
40
43
|
const identity_1 = require("../identity");
|
|
41
44
|
const runtime_1 = require("../../nerves/runtime");
|
|
45
|
+
const runtime_metadata_1 = require("./runtime-metadata");
|
|
46
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
47
|
+
const update_hooks_1 = require("./update-hooks");
|
|
48
|
+
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
49
|
+
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
50
|
+
const update_checker_1 = require("./update-checker");
|
|
51
|
+
const staged_restart_1 = require("./staged-restart");
|
|
52
|
+
const child_process_1 = require("child_process");
|
|
53
|
+
const pending_1 = require("../../mind/pending");
|
|
54
|
+
const agent_service_1 = require("./agent-service");
|
|
55
|
+
const channel_1 = require("../../mind/friends/channel");
|
|
56
|
+
const mcp_manager_1 = require("../../repertoire/mcp-manager");
|
|
57
|
+
const PIDFILE_PATH = path.join(os.homedir(), ".ouro-cli", "daemon.pids");
|
|
58
|
+
/**
|
|
59
|
+
* Kill all ouro processes from the previous daemon instance using the pidfile.
|
|
60
|
+
* On startup, reads PIDs from ~/.ouro-cli/daemon.pids, kills them all, then
|
|
61
|
+
* deletes the file. The new daemon writes its own PIDs after spawning.
|
|
62
|
+
*
|
|
63
|
+
* Falls back to ps-based scanning if the pidfile doesn't exist (first run
|
|
64
|
+
* or manual cleanup).
|
|
65
|
+
*/
|
|
66
|
+
/* v8 ignore start -- process lifecycle: uses kill/ps, tested via deployment @preserve */
|
|
67
|
+
function killOrphanProcesses() {
|
|
68
|
+
try {
|
|
69
|
+
let pidsToKill = [];
|
|
70
|
+
// Primary: read pidfile from previous daemon
|
|
71
|
+
try {
|
|
72
|
+
const raw = fs.readFileSync(PIDFILE_PATH, "utf-8");
|
|
73
|
+
pidsToKill = raw.split("\n").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n !== process.pid);
|
|
74
|
+
fs.unlinkSync(PIDFILE_PATH);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// No pidfile — fall back to ps scan
|
|
78
|
+
}
|
|
79
|
+
// Fallback: scan ps for any ouro entry processes we missed
|
|
80
|
+
if (pidsToKill.length === 0) {
|
|
81
|
+
try {
|
|
82
|
+
const result = (0, child_process_1.execSync)("ps -eo pid,command", { encoding: "utf-8", timeout: 5000 });
|
|
83
|
+
for (const line of result.split("\n")) {
|
|
84
|
+
if (!line.includes("agent-entry.js") && !line.includes("daemon-entry.js") && !line.includes("-entry.js --agent"))
|
|
85
|
+
continue;
|
|
86
|
+
const pid = parseInt(line.trim(), 10);
|
|
87
|
+
if (!isNaN(pid) && pid !== process.pid)
|
|
88
|
+
pidsToKill.push(pid);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch { /* ps failed — best effort */ }
|
|
92
|
+
}
|
|
93
|
+
if (pidsToKill.length > 0) {
|
|
94
|
+
for (const pid of pidsToKill) {
|
|
95
|
+
try {
|
|
96
|
+
process.kill(pid, "SIGTERM");
|
|
97
|
+
}
|
|
98
|
+
catch { /* already exited */ }
|
|
99
|
+
}
|
|
100
|
+
(0, runtime_1.emitNervesEvent)({
|
|
101
|
+
component: "daemon",
|
|
102
|
+
event: "daemon.orphan_cleanup",
|
|
103
|
+
message: `killed ${pidsToKill.length} orphaned ouro processes`,
|
|
104
|
+
meta: { pids: pidsToKill },
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
(0, runtime_1.emitNervesEvent)({
|
|
110
|
+
level: "warn",
|
|
111
|
+
component: "daemon",
|
|
112
|
+
event: "daemon.orphan_cleanup_error",
|
|
113
|
+
message: "failed to clean up orphaned ouro processes",
|
|
114
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Write all managed PIDs (daemon + children) to the pidfile.
|
|
120
|
+
* Called after all agents and senses are spawned.
|
|
121
|
+
*/
|
|
122
|
+
function writePidfile(extraPids = []) {
|
|
123
|
+
try {
|
|
124
|
+
const pids = [process.pid, ...extraPids].filter(Boolean);
|
|
125
|
+
fs.mkdirSync(path.dirname(PIDFILE_PATH), { recursive: true });
|
|
126
|
+
fs.writeFileSync(PIDFILE_PATH, pids.join("\n") + "\n", "utf-8");
|
|
127
|
+
}
|
|
128
|
+
catch { /* best effort */ }
|
|
129
|
+
}
|
|
42
130
|
function buildWorkerRows(snapshots) {
|
|
43
131
|
return snapshots.map((snapshot) => ({
|
|
44
132
|
agent: snapshot.name,
|
|
@@ -87,6 +175,7 @@ class OuroDaemon {
|
|
|
87
175
|
router;
|
|
88
176
|
senseManager;
|
|
89
177
|
bundlesRoot;
|
|
178
|
+
mode;
|
|
90
179
|
server = null;
|
|
91
180
|
constructor(options) {
|
|
92
181
|
this.socketPath = options.socketPath;
|
|
@@ -96,6 +185,7 @@ class OuroDaemon {
|
|
|
96
185
|
this.router = options.router;
|
|
97
186
|
this.senseManager = options.senseManager ?? null;
|
|
98
187
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
188
|
+
this.mode = options.mode ?? "production";
|
|
99
189
|
}
|
|
100
190
|
async start() {
|
|
101
191
|
if (this.server)
|
|
@@ -106,11 +196,73 @@ class OuroDaemon {
|
|
|
106
196
|
message: "starting daemon server",
|
|
107
197
|
meta: { socketPath: this.socketPath },
|
|
108
198
|
});
|
|
199
|
+
// Register update hooks and apply pending updates before starting agents
|
|
200
|
+
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
201
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
202
|
+
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
203
|
+
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
204
|
+
// Skip in dev mode — dev builds should not auto-update from npm
|
|
205
|
+
const bundlesRoot = this.bundlesRoot;
|
|
206
|
+
if (this.mode === "dev") {
|
|
207
|
+
(0, runtime_1.emitNervesEvent)({
|
|
208
|
+
component: "daemon",
|
|
209
|
+
event: "daemon.update_checker_skip",
|
|
210
|
+
message: "skipping update checker in dev mode",
|
|
211
|
+
meta: { reason: "dev mode" },
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
const daemon = this;
|
|
216
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
217
|
+
currentVersion,
|
|
218
|
+
deps: {
|
|
219
|
+
distTag: "alpha",
|
|
220
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
221
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
222
|
+
return res.json();
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
226
|
+
if (!result.latestVersion)
|
|
227
|
+
return;
|
|
228
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
229
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
230
|
+
spawnSync: child_process_1.spawnSync,
|
|
231
|
+
resolveNewCodePath: (_version) => {
|
|
232
|
+
try {
|
|
233
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
234
|
+
return resolved ? path.dirname(resolved) : null;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
gracefulShutdown: () => daemon.stop(),
|
|
241
|
+
nodePath: process.execPath,
|
|
242
|
+
bundlesRoot,
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
/* v8 ignore stop */
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
// Pre-initialize MCP connections so they're ready for the first command (non-blocking)
|
|
249
|
+
/* v8 ignore next -- catch callback: getSharedMcpManager logs errors internally @preserve */
|
|
250
|
+
(0, mcp_manager_1.getSharedMcpManager)().catch(() => { });
|
|
251
|
+
/* v8 ignore start -- orphan cleanup + pidfile: calls process management functions @preserve */
|
|
252
|
+
killOrphanProcesses();
|
|
253
|
+
/* v8 ignore stop */
|
|
109
254
|
await this.processManager.startAutoStartAgents();
|
|
110
255
|
await this.senseManager?.startAutoStartSenses();
|
|
256
|
+
// Write all managed PIDs to disk so the next daemon can clean up
|
|
257
|
+
/* v8 ignore start -- pidfile write: collects PIDs from process managers @preserve */
|
|
258
|
+
const agentPids = this.processManager.listAgentSnapshots().map((s) => s.pid).filter((p) => p !== null);
|
|
259
|
+
const sensePids = this.senseManager?.listManagedPids?.() ?? [];
|
|
260
|
+
writePidfile([...agentPids, ...sensePids]);
|
|
261
|
+
/* v8 ignore stop */
|
|
111
262
|
this.scheduler.start?.();
|
|
112
263
|
await this.scheduler.reconcile?.();
|
|
113
264
|
await this.drainPendingBundleMessages();
|
|
265
|
+
await this.drainPendingSenseMessages();
|
|
114
266
|
if (fs.existsSync(this.socketPath)) {
|
|
115
267
|
fs.unlinkSync(this.socketPath);
|
|
116
268
|
}
|
|
@@ -186,6 +338,93 @@ class OuroDaemon {
|
|
|
186
338
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
187
339
|
}
|
|
188
340
|
}
|
|
341
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
342
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
343
|
+
async drainPendingSenseMessages() {
|
|
344
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
345
|
+
return;
|
|
346
|
+
let bundleDirs;
|
|
347
|
+
try {
|
|
348
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
for (const bundleDir of bundleDirs) {
|
|
354
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
355
|
+
continue;
|
|
356
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
357
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
358
|
+
if (!fs.existsSync(pendingRoot))
|
|
359
|
+
continue;
|
|
360
|
+
let friendDirs;
|
|
361
|
+
try {
|
|
362
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
for (const friendDir of friendDirs) {
|
|
368
|
+
if (!friendDir.isDirectory())
|
|
369
|
+
continue;
|
|
370
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
371
|
+
let channelDirs;
|
|
372
|
+
try {
|
|
373
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
for (const channelDir of channelDirs) {
|
|
379
|
+
if (!channelDir.isDirectory())
|
|
380
|
+
continue;
|
|
381
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
382
|
+
continue;
|
|
383
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
384
|
+
let keyDirs;
|
|
385
|
+
try {
|
|
386
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
for (const keyDir of keyDirs) {
|
|
392
|
+
if (!keyDir.isDirectory())
|
|
393
|
+
continue;
|
|
394
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
395
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
396
|
+
for (const msg of messages) {
|
|
397
|
+
try {
|
|
398
|
+
await this.router.send({
|
|
399
|
+
from: msg.from,
|
|
400
|
+
to: agentName,
|
|
401
|
+
content: msg.content,
|
|
402
|
+
priority: "normal",
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
catch {
|
|
406
|
+
// Best-effort delivery — log and continue
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (messages.length > 0) {
|
|
410
|
+
(0, runtime_1.emitNervesEvent)({
|
|
411
|
+
component: "daemon",
|
|
412
|
+
event: "daemon.startup_sense_drain",
|
|
413
|
+
message: "drained pending sense messages on startup",
|
|
414
|
+
meta: {
|
|
415
|
+
agent: agentName,
|
|
416
|
+
channel: channelDir.name,
|
|
417
|
+
friendId: friendDir.name,
|
|
418
|
+
key: keyDir.name,
|
|
419
|
+
count: messages.length,
|
|
420
|
+
},
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
189
428
|
async stop() {
|
|
190
429
|
(0, runtime_1.emitNervesEvent)({
|
|
191
430
|
component: "daemon",
|
|
@@ -193,6 +432,8 @@ class OuroDaemon {
|
|
|
193
432
|
message: "stopping daemon server",
|
|
194
433
|
meta: { socketPath: this.socketPath },
|
|
195
434
|
});
|
|
435
|
+
(0, update_checker_1.stopUpdateChecker)();
|
|
436
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
196
437
|
this.scheduler.stop?.();
|
|
197
438
|
await this.processManager.stopAll();
|
|
198
439
|
await this.senseManager?.stopAll();
|
|
@@ -237,13 +478,17 @@ class OuroDaemon {
|
|
|
237
478
|
const snapshots = this.processManager.listAgentSnapshots();
|
|
238
479
|
const workers = buildWorkerRows(snapshots);
|
|
239
480
|
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
481
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
240
482
|
const data = {
|
|
241
483
|
overview: {
|
|
242
484
|
daemon: "running",
|
|
243
485
|
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
244
486
|
socketPath: this.socketPath,
|
|
487
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
245
488
|
workerCount: workers.length,
|
|
246
489
|
senseCount: senses.length,
|
|
490
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
491
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
247
492
|
},
|
|
248
493
|
workers,
|
|
249
494
|
senses,
|
|
@@ -264,7 +509,7 @@ class OuroDaemon {
|
|
|
264
509
|
ok: true,
|
|
265
510
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
266
511
|
message: "log streaming available via ouro logs",
|
|
267
|
-
data: { logDir: "
|
|
512
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
268
513
|
};
|
|
269
514
|
case "agent.start":
|
|
270
515
|
await this.processManager.startAgent(command.agent);
|
|
@@ -275,6 +520,32 @@ class OuroDaemon {
|
|
|
275
520
|
case "agent.restart":
|
|
276
521
|
await this.processManager.restartAgent?.(command.agent);
|
|
277
522
|
return { ok: true, message: `restarted ${command.agent}` };
|
|
523
|
+
case "agent.ask":
|
|
524
|
+
return (0, agent_service_1.handleAgentAsk)(command);
|
|
525
|
+
case "agent.status":
|
|
526
|
+
return (0, agent_service_1.handleAgentStatus)(command);
|
|
527
|
+
case "agent.catchup":
|
|
528
|
+
return (0, agent_service_1.handleAgentCatchup)(command);
|
|
529
|
+
case "agent.delegate":
|
|
530
|
+
return (0, agent_service_1.handleAgentDelegate)(command);
|
|
531
|
+
case "agent.getContext":
|
|
532
|
+
return (0, agent_service_1.handleAgentGetContext)(command);
|
|
533
|
+
case "agent.searchMemory":
|
|
534
|
+
return (0, agent_service_1.handleAgentSearchMemory)(command);
|
|
535
|
+
case "agent.getTask":
|
|
536
|
+
return (0, agent_service_1.handleAgentGetTask)(command);
|
|
537
|
+
case "agent.checkScope":
|
|
538
|
+
return (0, agent_service_1.handleAgentCheckScope)(command);
|
|
539
|
+
case "agent.requestDecision":
|
|
540
|
+
return (0, agent_service_1.handleAgentRequestDecision)(command);
|
|
541
|
+
case "agent.checkGuidance":
|
|
542
|
+
return (0, agent_service_1.handleAgentCheckGuidance)(command);
|
|
543
|
+
case "agent.reportProgress":
|
|
544
|
+
return (0, agent_service_1.handleAgentReportProgress)(command);
|
|
545
|
+
case "agent.reportBlocker":
|
|
546
|
+
return (0, agent_service_1.handleAgentReportBlocker)(command);
|
|
547
|
+
case "agent.reportComplete":
|
|
548
|
+
return (0, agent_service_1.handleAgentReportComplete)(command);
|
|
278
549
|
case "cron.list": {
|
|
279
550
|
const jobs = this.scheduler.listJobs();
|
|
280
551
|
const summary = jobs.length === 0
|
|
@@ -306,6 +577,13 @@ class OuroDaemon {
|
|
|
306
577
|
data: messages,
|
|
307
578
|
};
|
|
308
579
|
}
|
|
580
|
+
case "inner.wake":
|
|
581
|
+
await this.processManager.startAgent(command.agent);
|
|
582
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
583
|
+
return {
|
|
584
|
+
ok: true,
|
|
585
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
586
|
+
};
|
|
309
587
|
case "chat.connect":
|
|
310
588
|
await this.processManager.startAgent(command.agent);
|
|
311
589
|
return {
|
|
@@ -328,6 +606,28 @@ class OuroDaemon {
|
|
|
328
606
|
data: receipt,
|
|
329
607
|
};
|
|
330
608
|
}
|
|
609
|
+
case "mcp.list": {
|
|
610
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
611
|
+
if (!mcpManager) {
|
|
612
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
613
|
+
}
|
|
614
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
615
|
+
}
|
|
616
|
+
case "mcp.call": {
|
|
617
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
618
|
+
if (!mcpCallManager) {
|
|
619
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
620
|
+
}
|
|
621
|
+
try {
|
|
622
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
623
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
624
|
+
return { ok: true, data: result };
|
|
625
|
+
}
|
|
626
|
+
catch (error) {
|
|
627
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
628
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
629
|
+
}
|
|
630
|
+
}
|
|
331
631
|
case "hatch.start":
|
|
332
632
|
return {
|
|
333
633
|
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
|
}
|
|
@@ -39,13 +39,18 @@ const fs = __importStar(require("fs"));
|
|
|
39
39
|
const os = __importStar(require("os"));
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
41
|
const identity_1 = require("../identity");
|
|
42
|
+
const config_1 = require("../config");
|
|
42
43
|
const runtime_1 = require("../../nerves/runtime");
|
|
44
|
+
const auth_flow_1 = require("./auth-flow");
|
|
43
45
|
const hatch_specialist_1 = require("./hatch-specialist");
|
|
44
46
|
function requiredCredentialKeys(provider) {
|
|
45
47
|
if (provider === "anthropic")
|
|
46
48
|
return ["setupToken"];
|
|
47
49
|
if (provider === "openai-codex")
|
|
48
50
|
return ["oauthAccessToken"];
|
|
51
|
+
/* v8 ignore next -- branch tested via requiredCredentialKeys unit test @preserve */
|
|
52
|
+
if (provider === "github-copilot")
|
|
53
|
+
return ["githubToken"];
|
|
49
54
|
if (provider === "minimax")
|
|
50
55
|
return ["apiKey"];
|
|
51
56
|
return ["apiKey", "endpoint", "deployment"];
|
|
@@ -66,70 +71,8 @@ function validateCredentials(provider, credentials) {
|
|
|
66
71
|
throw new Error(`Missing required credentials for ${provider}: ${missing.join(", ")}`);
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
|
-
function buildSecretsTemplate() {
|
|
70
|
-
return {
|
|
71
|
-
providers: {
|
|
72
|
-
azure: {
|
|
73
|
-
modelName: "gpt-4o-mini",
|
|
74
|
-
apiKey: "",
|
|
75
|
-
endpoint: "",
|
|
76
|
-
deployment: "",
|
|
77
|
-
apiVersion: "2025-04-01-preview",
|
|
78
|
-
},
|
|
79
|
-
minimax: {
|
|
80
|
-
model: "minimax-text-01",
|
|
81
|
-
apiKey: "",
|
|
82
|
-
},
|
|
83
|
-
anthropic: {
|
|
84
|
-
model: "claude-opus-4-6",
|
|
85
|
-
setupToken: "",
|
|
86
|
-
},
|
|
87
|
-
"openai-codex": {
|
|
88
|
-
model: "gpt-5.2",
|
|
89
|
-
oauthAccessToken: "",
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
teams: {
|
|
93
|
-
clientId: "",
|
|
94
|
-
clientSecret: "",
|
|
95
|
-
tenantId: "",
|
|
96
|
-
},
|
|
97
|
-
oauth: {
|
|
98
|
-
graphConnectionName: "graph",
|
|
99
|
-
adoConnectionName: "ado",
|
|
100
|
-
githubConnectionName: "",
|
|
101
|
-
},
|
|
102
|
-
teamsChannel: {
|
|
103
|
-
skipConfirmation: true,
|
|
104
|
-
port: 3978,
|
|
105
|
-
},
|
|
106
|
-
integrations: {
|
|
107
|
-
perplexityApiKey: "",
|
|
108
|
-
openaiEmbeddingsApiKey: "",
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
74
|
function writeSecretsFile(agentName, provider, credentials, secretsRoot) {
|
|
113
|
-
|
|
114
|
-
if (provider === "anthropic") {
|
|
115
|
-
secrets.providers.anthropic.setupToken = credentials.setupToken.trim();
|
|
116
|
-
}
|
|
117
|
-
else if (provider === "openai-codex") {
|
|
118
|
-
secrets.providers["openai-codex"].oauthAccessToken = credentials.oauthAccessToken.trim();
|
|
119
|
-
}
|
|
120
|
-
else if (provider === "minimax") {
|
|
121
|
-
secrets.providers.minimax.apiKey = credentials.apiKey.trim();
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
secrets.providers.azure.apiKey = credentials.apiKey.trim();
|
|
125
|
-
secrets.providers.azure.endpoint = credentials.endpoint.trim();
|
|
126
|
-
secrets.providers.azure.deployment = credentials.deployment.trim();
|
|
127
|
-
}
|
|
128
|
-
const secretsDir = path.join(secretsRoot, agentName);
|
|
129
|
-
fs.mkdirSync(secretsDir, { recursive: true });
|
|
130
|
-
const secretsPath = path.join(secretsDir, "secrets.json");
|
|
131
|
-
fs.writeFileSync(secretsPath, `${JSON.stringify(secrets, null, 2)}\n`, "utf-8");
|
|
132
|
-
return secretsPath;
|
|
75
|
+
return (0, auth_flow_1.writeProviderCredentials)(agentName, provider, credentials, { secretsRoot }).secretsPath;
|
|
133
76
|
}
|
|
134
77
|
function writeReadme(dir, purpose) {
|
|
135
78
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -138,14 +81,6 @@ function writeReadme(dir, purpose) {
|
|
|
138
81
|
fs.writeFileSync(readmePath, `# ${path.basename(dir)}\n\n${purpose}\n`, "utf-8");
|
|
139
82
|
}
|
|
140
83
|
}
|
|
141
|
-
function slugify(value) {
|
|
142
|
-
const trimmed = value.trim().toLowerCase();
|
|
143
|
-
const slug = trimmed
|
|
144
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
145
|
-
.replace(/^-+/, "")
|
|
146
|
-
.replace(/-+$/, "");
|
|
147
|
-
return slug || "friend";
|
|
148
|
-
}
|
|
149
84
|
function pad(value) {
|
|
150
85
|
return String(value).padStart(2, "0");
|
|
151
86
|
}
|
|
@@ -182,7 +117,7 @@ function writeFriendImprint(bundleRoot, humanName, now) {
|
|
|
182
117
|
const friendsDir = path.join(bundleRoot, "friends");
|
|
183
118
|
fs.mkdirSync(friendsDir, { recursive: true });
|
|
184
119
|
const nowIso = now.toISOString();
|
|
185
|
-
const id = `friend-${slugify(humanName)}`;
|
|
120
|
+
const id = `friend-${(0, config_1.slugify)(humanName) || "friend"}`;
|
|
186
121
|
const localExternalId = `${os.userInfo().username}@${os.hostname()}`;
|
|
187
122
|
const record = {
|
|
188
123
|
id,
|
|
@@ -207,12 +142,12 @@ function writeFriendImprint(bundleRoot, humanName, now) {
|
|
|
207
142
|
};
|
|
208
143
|
fs.writeFileSync(path.join(friendsDir, `${id}.json`), `${JSON.stringify(record, null, 2)}\n`, "utf-8");
|
|
209
144
|
}
|
|
210
|
-
function
|
|
211
|
-
const
|
|
212
|
-
fs.mkdirSync(path.join(
|
|
213
|
-
fs.mkdirSync(path.join(
|
|
214
|
-
fs.writeFileSync(path.join(
|
|
215
|
-
fs.writeFileSync(path.join(
|
|
145
|
+
function writeDiaryScaffold(bundleRoot) {
|
|
146
|
+
const diaryRoot = path.join(bundleRoot, "diary");
|
|
147
|
+
fs.mkdirSync(path.join(diaryRoot, "daily"), { recursive: true });
|
|
148
|
+
fs.mkdirSync(path.join(diaryRoot, "archive"), { recursive: true });
|
|
149
|
+
fs.writeFileSync(path.join(diaryRoot, "facts.jsonl"), "", "utf-8");
|
|
150
|
+
fs.writeFileSync(path.join(diaryRoot, "entities.json"), "{}\n", "utf-8");
|
|
216
151
|
}
|
|
217
152
|
function writeHatchlingAgentConfig(bundleRoot, input) {
|
|
218
153
|
const template = (0, identity_1.buildDefaultAgentTemplate)(input.agentName);
|
|
@@ -248,7 +183,7 @@ async function runHatchFlow(input, deps = {}) {
|
|
|
248
183
|
fs.mkdirSync(bundleRoot, { recursive: true });
|
|
249
184
|
writeReadme(bundleRoot, "Root of this agent bundle.");
|
|
250
185
|
writeReadme(path.join(bundleRoot, "psyche"), "Identity and behavior files.");
|
|
251
|
-
writeReadme(path.join(bundleRoot, "
|
|
186
|
+
writeReadme(path.join(bundleRoot, "diary"), "Persistent diary — things I've learned and remember.");
|
|
252
187
|
writeReadme(path.join(bundleRoot, "friends"), "Known friend records.");
|
|
253
188
|
writeReadme(path.join(bundleRoot, "tasks"), "Task files.");
|
|
254
189
|
writeReadme(path.join(bundleRoot, "tasks", "habits"), "Recurring tasks.");
|
|
@@ -258,7 +193,7 @@ async function runHatchFlow(input, deps = {}) {
|
|
|
258
193
|
writeReadme(path.join(bundleRoot, "senses"), "Sense-specific config.");
|
|
259
194
|
writeReadme(path.join(bundleRoot, "senses", "teams"), "Teams sense config.");
|
|
260
195
|
writeHatchlingAgentConfig(bundleRoot, input);
|
|
261
|
-
|
|
196
|
+
writeDiaryScaffold(bundleRoot);
|
|
262
197
|
writeFriendImprint(bundleRoot, input.humanName, now);
|
|
263
198
|
writeHeartbeatTask(bundleRoot, now);
|
|
264
199
|
(0, runtime_1.emitNervesEvent)({
|