@ouro.bot/cli 0.1.0-alpha.22 → 0.1.0-alpha.221
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/README.md +187 -191
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +1 -1
- package/changelog.json +1360 -2
- package/dist/arc/attention-types.js +8 -0
- package/dist/arc/cares.js +140 -0
- package/dist/arc/episodes.js +119 -0
- package/dist/arc/intentions.js +133 -0
- package/dist/arc/json-store.js +120 -0
- package/dist/arc/obligations.js +237 -0
- package/dist/arc/presence.js +185 -0
- package/dist/heart/active-work.js +832 -0
- package/dist/heart/agent-entry.js +37 -2
- package/dist/heart/auth/auth-flow.js +444 -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 +111 -0
- package/dist/heart/config-registry.js +305 -0
- package/dist/heart/config.js +59 -30
- package/dist/heart/core.js +601 -145
- package/dist/heart/cross-chat-delivery.js +131 -0
- package/dist/heart/daemon/agent-config-check.js +149 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/agent-service.js +360 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/cli-defaults.js +557 -0
- package/dist/heart/daemon/cli-exec.js +1847 -0
- package/dist/heart/daemon/cli-parse.js +759 -0
- package/dist/heart/daemon/cli-render.js +316 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/daemon-cli.js +29 -1163
- package/dist/heart/daemon/daemon-entry.js +202 -4
- package/dist/heart/daemon/daemon-health.js +136 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +153 -12
- package/dist/heart/daemon/daemon-tombstone.js +123 -0
- package/dist/heart/daemon/daemon.js +487 -20
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +115 -1
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/launchd.js +39 -8
- package/dist/heart/daemon/log-tailer.js +4 -3
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/os-cron-deps.js +134 -0
- package/dist/heart/daemon/ouro-bot-entry.js +1 -1
- package/dist/heart/daemon/process-manager.js +123 -0
- package/dist/heart/daemon/run-hooks.js +2 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +101 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/safe-mode.js +161 -0
- package/dist/heart/daemon/sense-manager.js +72 -3
- package/dist/heart/daemon/session-id-resolver.js +131 -0
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/task-scheduler.js +3 -25
- package/dist/heart/daemon/thoughts.js +507 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/habits/habit-migration.js +181 -0
- package/dist/heart/habits/habit-parser.js +119 -0
- package/dist/heart/habits/habit-scheduler.js +369 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +29 -119
- package/dist/heart/{daemon → hatch}/hatch-specialist.js +3 -3
- package/dist/heart/{daemon → hatch}/specialist-prompt.js +10 -7
- package/dist/heart/{daemon → hatch}/specialist-tools.js +49 -3
- package/dist/heart/identity.js +144 -55
- package/dist/heart/kicks.js +2 -20
- package/dist/heart/mcp/mcp-server.js +608 -0
- package/dist/heart/migrate-config.js +127 -0
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/outlook/outlook-http.js +439 -0
- package/dist/heart/outlook/outlook-read.js +1618 -0
- package/dist/heart/outlook/outlook-render.js +1032 -0
- package/dist/heart/outlook/outlook-types.js +7 -0
- package/dist/heart/outlook/outlook-view.js +194 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-failover.js +88 -0
- package/dist/heart/provider-ping.js +162 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +187 -41
- package/dist/heart/providers/azure.js +116 -10
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +51 -16
- package/dist/heart/session-activity.js +172 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/start-of-turn-packet.js +330 -0
- package/dist/heart/streaming.js +36 -27
- package/dist/heart/sync.js +217 -0
- package/dist/heart/target-resolution.js +127 -0
- package/dist/heart/tempo.js +93 -0
- package/dist/heart/temporal-view.js +41 -0
- package/dist/heart/tool-activity-callbacks.js +36 -0
- package/dist/heart/tool-description.js +135 -0
- package/dist/heart/tool-loop.js +200 -0
- package/dist/heart/turn-context.js +358 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/heart/versioning/ouro-bot-global-installer.js +128 -0
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
- package/dist/heart/{daemon → versioning}/ouro-path-installer.js +78 -35
- package/dist/heart/versioning/ouro-version-manager.js +171 -0
- package/dist/heart/{daemon → versioning}/staged-restart.js +30 -6
- package/dist/heart/{daemon → versioning}/update-checker.js +9 -1
- package/dist/heart/{daemon → versioning}/update-hooks.js +20 -2
- package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +41 -3
- package/dist/mind/associative-recall.js +126 -66
- package/dist/mind/bundle-manifest.js +8 -1
- package/dist/mind/context.js +125 -14
- package/dist/mind/{memory.js → diary.js} +73 -96
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +56 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/store-file.js +36 -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/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +779 -109
- package/dist/mind/scrutiny.js +173 -0
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/coverage/audit.js +1 -1
- package/dist/nerves/coverage/file-completeness.js +47 -5
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/nerves/event-buffer.js +111 -0
- package/dist/nerves/index.js +64 -4
- package/dist/nerves/observation.js +20 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/outlook-ui/assets/index-Ck8agNeO.js +61 -0
- package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
- package/dist/outlook-ui/index.html +15 -0
- package/dist/repertoire/ado-client.js +15 -56
- package/dist/repertoire/ado-semantic.js +11 -5
- package/dist/repertoire/api-client.js +100 -0
- package/dist/repertoire/bitwarden-client.js +290 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +330 -0
- package/dist/repertoire/coding/feedback.js +197 -30
- package/dist/repertoire/coding/manager.js +149 -2
- package/dist/repertoire/coding/spawner.js +55 -9
- package/dist/repertoire/coding/tools.js +170 -7
- package/dist/repertoire/github-client.js +14 -55
- package/dist/repertoire/graph-client.js +11 -52
- package/dist/repertoire/guardrails.js +342 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +251 -0
- package/dist/repertoire/shell-sessions.js +133 -0
- package/dist/repertoire/skills.js +14 -23
- package/dist/repertoire/tasks/board.js +43 -5
- package/dist/repertoire/tasks/fix.js +182 -0
- package/dist/repertoire/tasks/index.js +28 -10
- package/dist/repertoire/tasks/lifecycle.js +2 -2
- package/dist/repertoire/tasks/parser.js +3 -2
- package/dist/repertoire/tasks/scanner.js +194 -37
- package/dist/repertoire/tasks/transitions.js +11 -28
- package/dist/repertoire/tools-base.js +35 -771
- package/dist/repertoire/tools-bluebubbles.js +94 -0
- package/dist/repertoire/tools-bridge.js +141 -0
- package/dist/repertoire/tools-config.js +266 -0
- package/dist/repertoire/tools-continuity.js +248 -0
- package/dist/repertoire/tools-files.js +342 -0
- package/dist/repertoire/tools-flow.js +62 -0
- package/dist/repertoire/tools-github.js +1 -6
- package/dist/repertoire/tools-memory.js +347 -0
- package/dist/repertoire/tools-session.js +721 -0
- package/dist/repertoire/tools-shell.js +120 -0
- package/dist/repertoire/tools-surface.js +242 -0
- package/dist/repertoire/tools-teams.js +12 -59
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools-vault.js +185 -0
- package/dist/repertoire/tools.js +132 -124
- package/dist/repertoire/travel-api-client.js +224 -0
- package/dist/scripts/claude-code-hook.js +41 -0
- package/dist/scripts/claude-code-stop-hook.js +47 -0
- package/dist/senses/attention-queue.js +97 -0
- package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +109 -10
- package/dist/senses/bluebubbles/entry.js +13 -0
- package/dist/senses/bluebubbles/inbound-log.js +109 -0
- package/dist/senses/bluebubbles/index.js +1339 -0
- package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +119 -24
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +13 -5
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +46 -6
- package/dist/senses/bluebubbles/runtime-state.js +109 -0
- package/dist/senses/bluebubbles/session-cleanup.js +72 -0
- package/dist/senses/cli/adapter.js +274 -0
- package/dist/senses/cli/ink-app.js +156 -0
- package/dist/senses/cli/inline-diff.js +64 -0
- package/dist/senses/cli/message-list.js +51 -0
- package/dist/senses/cli/ouro-tui.js +358 -0
- package/dist/senses/cli/spinner-imperative.js +135 -0
- package/dist/senses/cli/spinner.js +101 -0
- package/dist/senses/cli/status-line.js +60 -0
- package/dist/senses/cli/streaming-markdown.js +526 -0
- package/dist/senses/cli/tool-display.js +83 -0
- package/dist/senses/cli/tool-render.js +85 -0
- package/dist/senses/cli/tui-store.js +198 -0
- package/dist/senses/cli/virtual-list.js +35 -0
- package/dist/senses/cli-entry.js +1 -1
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +503 -244
- package/dist/senses/commands.js +65 -1
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/habit-turn-message.js +108 -0
- package/dist/senses/inner-dialog-worker.js +112 -19
- package/dist/senses/inner-dialog.js +591 -84
- package/dist/senses/pipeline.js +559 -0
- package/dist/senses/shared-turn.js +196 -0
- package/dist/senses/surface-tool.js +68 -0
- package/dist/senses/teams.js +667 -120
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +12 -6
- package/skills/browser-navigation.md +110 -0
- package/skills/configure-dev-tools.md +81 -0
- package/skills/travel-planning.md +143 -0
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/dist/senses/bluebubbles-entry.js +0 -11
- package/dist/senses/bluebubbles.js +0 -421
- package/dist/senses/debug-activity.js +0 -107
- package/subagents/README.md +0 -73
- package/subagents/work-doer.md +0 -235
- package/subagents/work-merger.md +0 -618
- package/subagents/work-planner.md +0 -382
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
- /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
- /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
- /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
|
@@ -34,15 +34,108 @@ 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;
|
|
39
|
+
exports.handleAgentSenseTurn = handleAgentSenseTurn;
|
|
37
40
|
const fs = __importStar(require("fs"));
|
|
38
41
|
const net = __importStar(require("net"));
|
|
42
|
+
const os = __importStar(require("os"));
|
|
39
43
|
const path = __importStar(require("path"));
|
|
40
44
|
const identity_1 = require("../identity");
|
|
41
45
|
const runtime_1 = require("../../nerves/runtime");
|
|
42
46
|
const runtime_metadata_1 = require("./runtime-metadata");
|
|
43
|
-
const
|
|
47
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
48
|
+
const update_hooks_1 = require("../versioning/update-hooks");
|
|
44
49
|
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
50
|
+
const agent_config_v2_1 = require("./hooks/agent-config-v2");
|
|
45
51
|
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
52
|
+
const update_checker_1 = require("../versioning/update-checker");
|
|
53
|
+
const staged_restart_1 = require("../versioning/staged-restart");
|
|
54
|
+
const child_process_1 = require("child_process");
|
|
55
|
+
const pending_1 = require("../../mind/pending");
|
|
56
|
+
const agent_service_1 = require("./agent-service");
|
|
57
|
+
const channel_1 = require("../../mind/friends/channel");
|
|
58
|
+
const mcp_manager_1 = require("../../repertoire/mcp-manager");
|
|
59
|
+
const outlook_http_1 = require("../outlook/outlook-http");
|
|
60
|
+
const outlook_types_1 = require("../outlook/outlook-types");
|
|
61
|
+
const outlook_read_1 = require("../outlook/outlook-read");
|
|
62
|
+
const outlook_view_1 = require("../outlook/outlook-view");
|
|
63
|
+
const PIDFILE_PATH = path.join(os.homedir(), ".ouro-cli", "daemon.pids");
|
|
64
|
+
/**
|
|
65
|
+
* Kill all ouro processes from the previous daemon instance using the pidfile.
|
|
66
|
+
* On startup, reads PIDs from ~/.ouro-cli/daemon.pids, kills them all, then
|
|
67
|
+
* deletes the file. The new daemon writes its own PIDs after spawning.
|
|
68
|
+
*
|
|
69
|
+
* Falls back to ps-based scanning if the pidfile doesn't exist (first run
|
|
70
|
+
* or manual cleanup).
|
|
71
|
+
*/
|
|
72
|
+
/* v8 ignore start -- process lifecycle: uses kill/ps, tested via deployment @preserve */
|
|
73
|
+
function killOrphanProcesses() {
|
|
74
|
+
try {
|
|
75
|
+
let pidsToKill = [];
|
|
76
|
+
// Primary: read pidfile from previous daemon
|
|
77
|
+
try {
|
|
78
|
+
const raw = fs.readFileSync(PIDFILE_PATH, "utf-8");
|
|
79
|
+
pidsToKill = raw.split("\n").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n) && n !== process.pid);
|
|
80
|
+
fs.unlinkSync(PIDFILE_PATH);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// No pidfile — fall back to ps scan
|
|
84
|
+
}
|
|
85
|
+
// Fallback: scan ps for daemon-owned processes only (not MCP servers or external tools)
|
|
86
|
+
if (pidsToKill.length === 0) {
|
|
87
|
+
try {
|
|
88
|
+
const result = (0, child_process_1.execSync)("ps -eo pid,command", { encoding: "utf-8", timeout: 5000 });
|
|
89
|
+
for (const line of result.split("\n")) {
|
|
90
|
+
// Only match daemon-owned entry points, NOT mcp-serve or other external processes
|
|
91
|
+
if (line.includes("mcp-serve") || line.includes("mcp serve"))
|
|
92
|
+
continue;
|
|
93
|
+
if (!line.includes("agent-entry.js") && !line.includes("daemon-entry.js") && !line.includes("bluebubbles/entry.js") && !line.includes("teams-entry.js"))
|
|
94
|
+
continue;
|
|
95
|
+
const pid = parseInt(line.trim(), 10);
|
|
96
|
+
if (!isNaN(pid) && pid !== process.pid)
|
|
97
|
+
pidsToKill.push(pid);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch { /* ps failed — best effort */ }
|
|
101
|
+
}
|
|
102
|
+
if (pidsToKill.length > 0) {
|
|
103
|
+
for (const pid of pidsToKill) {
|
|
104
|
+
try {
|
|
105
|
+
process.kill(pid, "SIGTERM");
|
|
106
|
+
}
|
|
107
|
+
catch { /* already exited */ }
|
|
108
|
+
}
|
|
109
|
+
(0, runtime_1.emitNervesEvent)({
|
|
110
|
+
component: "daemon",
|
|
111
|
+
event: "daemon.orphan_cleanup",
|
|
112
|
+
message: `killed ${pidsToKill.length} orphaned ouro processes`,
|
|
113
|
+
meta: { pids: pidsToKill },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
(0, runtime_1.emitNervesEvent)({
|
|
119
|
+
level: "warn",
|
|
120
|
+
component: "daemon",
|
|
121
|
+
event: "daemon.orphan_cleanup_error",
|
|
122
|
+
message: "failed to clean up orphaned ouro processes",
|
|
123
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Write all managed PIDs (daemon + children) to the pidfile.
|
|
129
|
+
* Called after all agents and senses are spawned.
|
|
130
|
+
*/
|
|
131
|
+
function writePidfile(extraPids = []) {
|
|
132
|
+
try {
|
|
133
|
+
const pids = [process.pid, ...extraPids].filter(Boolean);
|
|
134
|
+
fs.mkdirSync(path.dirname(PIDFILE_PATH), { recursive: true });
|
|
135
|
+
fs.writeFileSync(PIDFILE_PATH, pids.join("\n") + "\n", "utf-8");
|
|
136
|
+
}
|
|
137
|
+
catch { /* best effort */ }
|
|
138
|
+
}
|
|
46
139
|
function buildWorkerRows(snapshots) {
|
|
47
140
|
return snapshots.map((snapshot) => ({
|
|
48
141
|
agent: snapshot.name,
|
|
@@ -51,6 +144,8 @@ function buildWorkerRows(snapshots) {
|
|
|
51
144
|
pid: snapshot.pid,
|
|
52
145
|
restartCount: snapshot.restartCount,
|
|
53
146
|
startedAt: snapshot.startedAt,
|
|
147
|
+
lastExitCode: snapshot.lastExitCode ?? null,
|
|
148
|
+
lastSignal: snapshot.lastSignal ?? null,
|
|
54
149
|
}));
|
|
55
150
|
}
|
|
56
151
|
function formatStatusSummary(payload) {
|
|
@@ -83,6 +178,33 @@ function parseIncomingCommand(raw) {
|
|
|
83
178
|
}
|
|
84
179
|
return parsed;
|
|
85
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Handle agent.senseTurn command: runs a full agent turn via the daemon process.
|
|
183
|
+
* Dynamic import lazy-loads shared-turn. Hot-reload works because ouro dev
|
|
184
|
+
* restarts the daemon process (fresh module cache).
|
|
185
|
+
*/
|
|
186
|
+
async function handleAgentSenseTurn(command) {
|
|
187
|
+
try {
|
|
188
|
+
const { runSenseTurn } = await Promise.resolve().then(() => __importStar(require("../../senses/shared-turn")));
|
|
189
|
+
const result = await runSenseTurn({
|
|
190
|
+
agentName: command.agent,
|
|
191
|
+
channel: command.channel,
|
|
192
|
+
sessionKey: command.sessionKey,
|
|
193
|
+
friendId: command.friendId,
|
|
194
|
+
userMessage: command.message,
|
|
195
|
+
});
|
|
196
|
+
return {
|
|
197
|
+
ok: true,
|
|
198
|
+
message: result.response,
|
|
199
|
+
data: { ponderDeferred: result.ponderDeferred },
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
/* v8 ignore next -- branch: String(error) fallback only for non-Error throws @preserve */
|
|
204
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
205
|
+
return { ok: false, error: `sense turn failed: ${errorMessage}` };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
86
208
|
class OuroDaemon {
|
|
87
209
|
socketPath;
|
|
88
210
|
processManager;
|
|
@@ -91,7 +213,9 @@ class OuroDaemon {
|
|
|
91
213
|
router;
|
|
92
214
|
senseManager;
|
|
93
215
|
bundlesRoot;
|
|
216
|
+
mode;
|
|
94
217
|
server = null;
|
|
218
|
+
outlookServer = null;
|
|
95
219
|
constructor(options) {
|
|
96
220
|
this.socketPath = options.socketPath;
|
|
97
221
|
this.processManager = options.processManager;
|
|
@@ -100,6 +224,28 @@ class OuroDaemon {
|
|
|
100
224
|
this.router = options.router;
|
|
101
225
|
this.senseManager = options.senseManager ?? null;
|
|
102
226
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
227
|
+
this.mode = options.mode ?? "production";
|
|
228
|
+
}
|
|
229
|
+
buildStatusPayload() {
|
|
230
|
+
const snapshots = this.processManager.listAgentSnapshots();
|
|
231
|
+
const workers = buildWorkerRows(snapshots);
|
|
232
|
+
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
233
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
234
|
+
return {
|
|
235
|
+
overview: {
|
|
236
|
+
daemon: "running",
|
|
237
|
+
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
238
|
+
socketPath: this.socketPath,
|
|
239
|
+
outlookUrl: this.outlookServer?.origin ?? "http://127.0.0.1:0",
|
|
240
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
241
|
+
workerCount: workers.length,
|
|
242
|
+
senseCount: senses.length,
|
|
243
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
244
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
245
|
+
},
|
|
246
|
+
workers,
|
|
247
|
+
senses,
|
|
248
|
+
};
|
|
103
249
|
}
|
|
104
250
|
async start() {
|
|
105
251
|
if (this.server)
|
|
@@ -112,24 +258,165 @@ class OuroDaemon {
|
|
|
112
258
|
});
|
|
113
259
|
// Register update hooks and apply pending updates before starting agents
|
|
114
260
|
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
115
|
-
|
|
261
|
+
(0, update_hooks_1.registerUpdateHook)(agent_config_v2_1.agentConfigV2Hook);
|
|
262
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
263
|
+
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
264
|
+
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
265
|
+
// Skip in dev mode — dev builds should not auto-update from npm
|
|
266
|
+
const bundlesRoot = this.bundlesRoot;
|
|
267
|
+
const daemonSocketPath = this.socketPath;
|
|
268
|
+
if (this.mode === "dev") {
|
|
269
|
+
(0, runtime_1.emitNervesEvent)({
|
|
270
|
+
component: "daemon",
|
|
271
|
+
event: "daemon.update_checker_skip",
|
|
272
|
+
message: "skipping update checker in dev mode",
|
|
273
|
+
meta: { reason: "dev mode" },
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
const daemon = this;
|
|
278
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
279
|
+
currentVersion,
|
|
280
|
+
deps: {
|
|
281
|
+
distTag: "alpha",
|
|
282
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
283
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
284
|
+
return res.json();
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
288
|
+
if (!result.latestVersion)
|
|
289
|
+
return;
|
|
290
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
291
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
292
|
+
spawnSync: child_process_1.spawnSync,
|
|
293
|
+
resolveNewCodePath: (_version) => {
|
|
294
|
+
try {
|
|
295
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
296
|
+
return resolved ? path.dirname(resolved) : null;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
gracefulShutdown: () => daemon.stop(),
|
|
303
|
+
spawnNewDaemon: (entryPath, sock) => {
|
|
304
|
+
const outFd = fs.openSync(os.devNull, "w");
|
|
305
|
+
const errFd = fs.openSync(os.devNull, "w");
|
|
306
|
+
const child = (0, child_process_1.spawn)(process.execPath, [entryPath, "--socket", sock], {
|
|
307
|
+
detached: true,
|
|
308
|
+
stdio: ["ignore", outFd, errFd],
|
|
309
|
+
});
|
|
310
|
+
child.unref();
|
|
311
|
+
return { pid: child.pid ?? null };
|
|
312
|
+
},
|
|
313
|
+
nodePath: process.execPath,
|
|
314
|
+
bundlesRoot,
|
|
315
|
+
socketPath: daemonSocketPath,
|
|
316
|
+
});
|
|
317
|
+
},
|
|
318
|
+
/* v8 ignore stop */
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
// Pre-initialize MCP connections so they're ready for the first command (non-blocking)
|
|
322
|
+
/* v8 ignore next -- catch callback: getSharedMcpManager logs errors internally @preserve */
|
|
323
|
+
(0, mcp_manager_1.getSharedMcpManager)().catch(() => { });
|
|
324
|
+
/* v8 ignore start -- orphan cleanup + pidfile: calls process management functions @preserve */
|
|
325
|
+
killOrphanProcesses();
|
|
326
|
+
/* v8 ignore stop */
|
|
116
327
|
await this.processManager.startAutoStartAgents();
|
|
117
328
|
await this.senseManager?.startAutoStartSenses();
|
|
329
|
+
// Write all managed PIDs to disk so the next daemon can clean up
|
|
330
|
+
/* v8 ignore start -- pidfile write: collects PIDs from process managers @preserve */
|
|
331
|
+
const agentPids = this.processManager.listAgentSnapshots().map((s) => s.pid).filter((p) => p !== null);
|
|
332
|
+
const sensePids = this.senseManager?.listManagedPids?.() ?? [];
|
|
333
|
+
writePidfile([...agentPids, ...sensePids]);
|
|
334
|
+
/* v8 ignore stop */
|
|
118
335
|
this.scheduler.start?.();
|
|
119
336
|
await this.scheduler.reconcile?.();
|
|
120
337
|
await this.drainPendingBundleMessages();
|
|
338
|
+
await this.drainPendingSenseMessages();
|
|
339
|
+
/* v8 ignore start — Outlook server startup, tested via outlook-http.test.ts */
|
|
340
|
+
if (!this.outlookServer) {
|
|
341
|
+
try {
|
|
342
|
+
this.outlookServer = await (0, outlook_http_1.startOutlookHttpServer)({
|
|
343
|
+
host: "127.0.0.1",
|
|
344
|
+
port: outlook_types_1.OUTLOOK_DEFAULT_PORT,
|
|
345
|
+
bundlesRoot: this.bundlesRoot,
|
|
346
|
+
readMachineState: () => (0, outlook_read_1.readOutlookMachineState)({ bundlesRoot: this.bundlesRoot }),
|
|
347
|
+
readMachineView: ({ machine }) => {
|
|
348
|
+
const overview = this.buildStatusPayload().overview;
|
|
349
|
+
return (0, outlook_view_1.buildOutlookMachineView)({
|
|
350
|
+
machine,
|
|
351
|
+
daemon: {
|
|
352
|
+
status: overview.daemon,
|
|
353
|
+
health: overview.health,
|
|
354
|
+
mode: overview.mode,
|
|
355
|
+
socketPath: overview.socketPath,
|
|
356
|
+
outlookUrl: overview.outlookUrl,
|
|
357
|
+
entryPath: overview.entryPath,
|
|
358
|
+
workerCount: overview.workerCount,
|
|
359
|
+
senseCount: overview.senseCount,
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
readAgentState: (agentName) => (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot }),
|
|
364
|
+
readAgentView: (agentName) => {
|
|
365
|
+
const agent = (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot });
|
|
366
|
+
return (0, outlook_view_1.buildOutlookAgentView)({
|
|
367
|
+
agent,
|
|
368
|
+
viewer: { kind: "human" },
|
|
369
|
+
});
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
(0, runtime_1.emitNervesEvent)({
|
|
375
|
+
level: "warn",
|
|
376
|
+
component: "daemon",
|
|
377
|
+
event: "daemon.outlook_start_failed",
|
|
378
|
+
message: `Outlook server failed to start: ${String(error)}`,
|
|
379
|
+
meta: { port: outlook_types_1.OUTLOOK_DEFAULT_PORT },
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/* v8 ignore stop */
|
|
121
384
|
if (fs.existsSync(this.socketPath)) {
|
|
122
385
|
fs.unlinkSync(this.socketPath);
|
|
123
386
|
}
|
|
124
387
|
this.server = net.createServer((connection) => {
|
|
125
388
|
let raw = "";
|
|
126
389
|
let responded = false;
|
|
390
|
+
/* v8 ignore start — connection error handler requires real socket error @preserve */
|
|
391
|
+
connection.on("error", (err) => {
|
|
392
|
+
(0, runtime_1.emitNervesEvent)({
|
|
393
|
+
level: "warn",
|
|
394
|
+
component: "daemon",
|
|
395
|
+
event: "daemon.connection_error",
|
|
396
|
+
message: "socket connection error",
|
|
397
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
/* v8 ignore stop */
|
|
127
401
|
const flushResponse = async () => {
|
|
128
402
|
if (responded)
|
|
129
403
|
return;
|
|
130
404
|
responded = true;
|
|
131
405
|
const response = await this.handleRawPayload(raw);
|
|
132
|
-
|
|
406
|
+
try {
|
|
407
|
+
connection.end(response);
|
|
408
|
+
/* v8 ignore start — EPIPE catch requires real socket disconnect @preserve */
|
|
409
|
+
}
|
|
410
|
+
catch (err) {
|
|
411
|
+
(0, runtime_1.emitNervesEvent)({
|
|
412
|
+
level: "warn",
|
|
413
|
+
component: "daemon",
|
|
414
|
+
event: "daemon.connection_end_error",
|
|
415
|
+
message: "failed to send response to client (EPIPE)",
|
|
416
|
+
meta: { error: err instanceof Error ? err.message : String(err) },
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/* v8 ignore stop */
|
|
133
420
|
};
|
|
134
421
|
connection.on("data", (chunk) => {
|
|
135
422
|
raw += chunk.toString("utf-8");
|
|
@@ -142,7 +429,22 @@ class OuroDaemon {
|
|
|
142
429
|
const server = this.server;
|
|
143
430
|
await new Promise((resolve, reject) => {
|
|
144
431
|
server.once("error", reject);
|
|
145
|
-
server.listen(this.socketPath, () =>
|
|
432
|
+
server.listen(this.socketPath, () => {
|
|
433
|
+
// Replace the one-time error listener with a persistent one after successful listen
|
|
434
|
+
server.removeAllListeners("error");
|
|
435
|
+
/* v8 ignore start — server error after listen requires real socket race condition @preserve */
|
|
436
|
+
server.on("error", (err) => {
|
|
437
|
+
(0, runtime_1.emitNervesEvent)({
|
|
438
|
+
level: "error",
|
|
439
|
+
component: "daemon",
|
|
440
|
+
event: "daemon.server_error",
|
|
441
|
+
message: "daemon server error after listen",
|
|
442
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
/* v8 ignore stop */
|
|
446
|
+
resolve();
|
|
447
|
+
});
|
|
146
448
|
});
|
|
147
449
|
}
|
|
148
450
|
async drainPendingBundleMessages() {
|
|
@@ -193,6 +495,93 @@ class OuroDaemon {
|
|
|
193
495
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
194
496
|
}
|
|
195
497
|
}
|
|
498
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
499
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
500
|
+
async drainPendingSenseMessages() {
|
|
501
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
502
|
+
return;
|
|
503
|
+
let bundleDirs;
|
|
504
|
+
try {
|
|
505
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
506
|
+
}
|
|
507
|
+
catch {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
for (const bundleDir of bundleDirs) {
|
|
511
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
512
|
+
continue;
|
|
513
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
514
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
515
|
+
if (!fs.existsSync(pendingRoot))
|
|
516
|
+
continue;
|
|
517
|
+
let friendDirs;
|
|
518
|
+
try {
|
|
519
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
for (const friendDir of friendDirs) {
|
|
525
|
+
if (!friendDir.isDirectory())
|
|
526
|
+
continue;
|
|
527
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
528
|
+
let channelDirs;
|
|
529
|
+
try {
|
|
530
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
531
|
+
}
|
|
532
|
+
catch {
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
for (const channelDir of channelDirs) {
|
|
536
|
+
if (!channelDir.isDirectory())
|
|
537
|
+
continue;
|
|
538
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
539
|
+
continue;
|
|
540
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
541
|
+
let keyDirs;
|
|
542
|
+
try {
|
|
543
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
for (const keyDir of keyDirs) {
|
|
549
|
+
if (!keyDir.isDirectory())
|
|
550
|
+
continue;
|
|
551
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
552
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
553
|
+
for (const msg of messages) {
|
|
554
|
+
try {
|
|
555
|
+
await this.router.send({
|
|
556
|
+
from: msg.from,
|
|
557
|
+
to: agentName,
|
|
558
|
+
content: msg.content,
|
|
559
|
+
priority: "normal",
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
// Best-effort delivery — log and continue
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (messages.length > 0) {
|
|
567
|
+
(0, runtime_1.emitNervesEvent)({
|
|
568
|
+
component: "daemon",
|
|
569
|
+
event: "daemon.startup_sense_drain",
|
|
570
|
+
message: "drained pending sense messages on startup",
|
|
571
|
+
meta: {
|
|
572
|
+
agent: agentName,
|
|
573
|
+
channel: channelDir.name,
|
|
574
|
+
friendId: friendDir.name,
|
|
575
|
+
key: keyDir.name,
|
|
576
|
+
count: messages.length,
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
196
585
|
async stop() {
|
|
197
586
|
(0, runtime_1.emitNervesEvent)({
|
|
198
587
|
component: "daemon",
|
|
@@ -200,6 +589,8 @@ class OuroDaemon {
|
|
|
200
589
|
message: "stopping daemon server",
|
|
201
590
|
meta: { socketPath: this.socketPath },
|
|
202
591
|
});
|
|
592
|
+
(0, update_checker_1.stopUpdateChecker)();
|
|
593
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
203
594
|
this.scheduler.stop?.();
|
|
204
595
|
await this.processManager.stopAll();
|
|
205
596
|
await this.senseManager?.stopAll();
|
|
@@ -209,6 +600,10 @@ class OuroDaemon {
|
|
|
209
600
|
});
|
|
210
601
|
this.server = null;
|
|
211
602
|
}
|
|
603
|
+
if (this.outlookServer) {
|
|
604
|
+
await this.outlookServer.stop();
|
|
605
|
+
this.outlookServer = null;
|
|
606
|
+
}
|
|
212
607
|
if (fs.existsSync(this.socketPath)) {
|
|
213
608
|
fs.unlinkSync(this.socketPath);
|
|
214
609
|
}
|
|
@@ -233,6 +628,27 @@ class OuroDaemon {
|
|
|
233
628
|
message: "handling daemon command",
|
|
234
629
|
meta: { kind: command.kind },
|
|
235
630
|
});
|
|
631
|
+
try {
|
|
632
|
+
return await this.handleCommandInner(command);
|
|
633
|
+
/* v8 ignore start — command error catch tested in daemon-command-error.test; instanceof branches defensive @preserve */
|
|
634
|
+
}
|
|
635
|
+
catch (error) {
|
|
636
|
+
(0, runtime_1.emitNervesEvent)({
|
|
637
|
+
level: "error",
|
|
638
|
+
component: "daemon",
|
|
639
|
+
event: "daemon.command_error",
|
|
640
|
+
message: "unexpected error handling daemon command",
|
|
641
|
+
meta: {
|
|
642
|
+
kind: command.kind,
|
|
643
|
+
error: error instanceof Error ? error.message : String(error),
|
|
644
|
+
stack: error instanceof Error ? error.stack ?? null : null,
|
|
645
|
+
},
|
|
646
|
+
});
|
|
647
|
+
throw error;
|
|
648
|
+
}
|
|
649
|
+
/* v8 ignore stop */
|
|
650
|
+
}
|
|
651
|
+
async handleCommandInner(command) {
|
|
236
652
|
switch (command.kind) {
|
|
237
653
|
case "daemon.start":
|
|
238
654
|
await this.start();
|
|
@@ -241,21 +657,7 @@ class OuroDaemon {
|
|
|
241
657
|
await this.stop();
|
|
242
658
|
return { ok: true, message: "daemon stopped" };
|
|
243
659
|
case "daemon.status": {
|
|
244
|
-
const
|
|
245
|
-
const workers = buildWorkerRows(snapshots);
|
|
246
|
-
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
247
|
-
const data = {
|
|
248
|
-
overview: {
|
|
249
|
-
daemon: "running",
|
|
250
|
-
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
251
|
-
socketPath: this.socketPath,
|
|
252
|
-
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
253
|
-
workerCount: workers.length,
|
|
254
|
-
senseCount: senses.length,
|
|
255
|
-
},
|
|
256
|
-
workers,
|
|
257
|
-
senses,
|
|
258
|
-
};
|
|
660
|
+
const data = this.buildStatusPayload();
|
|
259
661
|
return {
|
|
260
662
|
ok: true,
|
|
261
663
|
summary: formatStatusSummary(data),
|
|
@@ -272,7 +674,7 @@ class OuroDaemon {
|
|
|
272
674
|
ok: true,
|
|
273
675
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
274
676
|
message: "log streaming available via ouro logs",
|
|
275
|
-
data: { logDir: "
|
|
677
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
276
678
|
};
|
|
277
679
|
case "agent.start":
|
|
278
680
|
await this.processManager.startAgent(command.agent);
|
|
@@ -283,6 +685,35 @@ class OuroDaemon {
|
|
|
283
685
|
case "agent.restart":
|
|
284
686
|
await this.processManager.restartAgent?.(command.agent);
|
|
285
687
|
return { ok: true, message: `restarted ${command.agent}` };
|
|
688
|
+
case "agent.ask":
|
|
689
|
+
return (0, agent_service_1.handleAgentAsk)(command);
|
|
690
|
+
case "agent.status":
|
|
691
|
+
return (0, agent_service_1.handleAgentStatus)(command);
|
|
692
|
+
case "agent.catchup":
|
|
693
|
+
return (0, agent_service_1.handleAgentCatchup)(command);
|
|
694
|
+
case "agent.delegate":
|
|
695
|
+
return (0, agent_service_1.handleAgentDelegate)(command);
|
|
696
|
+
case "agent.getContext":
|
|
697
|
+
return (0, agent_service_1.handleAgentGetContext)(command);
|
|
698
|
+
case "agent.searchMemory":
|
|
699
|
+
return (0, agent_service_1.handleAgentSearchMemory)(command);
|
|
700
|
+
case "agent.getTask":
|
|
701
|
+
return (0, agent_service_1.handleAgentGetTask)(command);
|
|
702
|
+
case "agent.checkScope":
|
|
703
|
+
return (0, agent_service_1.handleAgentCheckScope)(command);
|
|
704
|
+
case "agent.requestDecision":
|
|
705
|
+
return (0, agent_service_1.handleAgentRequestDecision)(command);
|
|
706
|
+
case "agent.checkGuidance":
|
|
707
|
+
return (0, agent_service_1.handleAgentCheckGuidance)(command);
|
|
708
|
+
case "agent.reportProgress":
|
|
709
|
+
return (0, agent_service_1.handleAgentReportProgress)(command);
|
|
710
|
+
case "agent.reportBlocker":
|
|
711
|
+
return (0, agent_service_1.handleAgentReportBlocker)(command);
|
|
712
|
+
case "agent.reportComplete":
|
|
713
|
+
return (0, agent_service_1.handleAgentReportComplete)(command);
|
|
714
|
+
case "agent.senseTurn":
|
|
715
|
+
return handleAgentSenseTurn(command);
|
|
716
|
+
/* v8 ignore stop */
|
|
286
717
|
case "cron.list": {
|
|
287
718
|
const jobs = this.scheduler.listJobs();
|
|
288
719
|
const summary = jobs.length === 0
|
|
@@ -314,6 +745,13 @@ class OuroDaemon {
|
|
|
314
745
|
data: messages,
|
|
315
746
|
};
|
|
316
747
|
}
|
|
748
|
+
case "inner.wake":
|
|
749
|
+
await this.processManager.startAgent(command.agent);
|
|
750
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
751
|
+
return {
|
|
752
|
+
ok: true,
|
|
753
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
754
|
+
};
|
|
317
755
|
case "chat.connect":
|
|
318
756
|
await this.processManager.startAgent(command.agent);
|
|
319
757
|
return {
|
|
@@ -336,6 +774,35 @@ class OuroDaemon {
|
|
|
336
774
|
data: receipt,
|
|
337
775
|
};
|
|
338
776
|
}
|
|
777
|
+
case "habit.poke": {
|
|
778
|
+
this.processManager.sendToAgent?.(command.agent, { type: "habit", habitName: command.habitName });
|
|
779
|
+
return {
|
|
780
|
+
ok: true,
|
|
781
|
+
message: `poked habit ${command.habitName} for ${command.agent}`,
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
case "mcp.list": {
|
|
785
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
786
|
+
if (!mcpManager) {
|
|
787
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
788
|
+
}
|
|
789
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
790
|
+
}
|
|
791
|
+
case "mcp.call": {
|
|
792
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
793
|
+
if (!mcpCallManager) {
|
|
794
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
795
|
+
}
|
|
796
|
+
try {
|
|
797
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
798
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
799
|
+
return { ok: true, data: result };
|
|
800
|
+
}
|
|
801
|
+
catch (error) {
|
|
802
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
803
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
804
|
+
}
|
|
805
|
+
}
|
|
339
806
|
case "hatch.start":
|
|
340
807
|
return {
|
|
341
808
|
ok: true,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentConfigV2Hook = agentConfigV2Hook;
|
|
4
|
+
const runtime_1 = require("../../../nerves/runtime");
|
|
5
|
+
const migrate_config_1 = require("../../migrate-config");
|
|
6
|
+
async function agentConfigV2Hook(ctx) {
|
|
7
|
+
(0, runtime_1.emitNervesEvent)({
|
|
8
|
+
component: "daemon",
|
|
9
|
+
event: "daemon.agent_config_v2_hook_start",
|
|
10
|
+
message: "running agent-config-v2 update hook",
|
|
11
|
+
meta: { agentRoot: ctx.agentRoot, currentVersion: ctx.currentVersion },
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
(0, migrate_config_1.migrateAgentConfigV1ToV2)(ctx.agentRoot);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
const errorMessage = err instanceof Error ? err.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(err);
|
|
18
|
+
(0, runtime_1.emitNervesEvent)({
|
|
19
|
+
component: "daemon",
|
|
20
|
+
event: "daemon.agent_config_v2_hook_error",
|
|
21
|
+
message: "agent-config-v2 hook migration failed",
|
|
22
|
+
meta: { agentRoot: ctx.agentRoot, error: errorMessage },
|
|
23
|
+
});
|
|
24
|
+
return { ok: false, error: errorMessage };
|
|
25
|
+
}
|
|
26
|
+
(0, runtime_1.emitNervesEvent)({
|
|
27
|
+
component: "daemon",
|
|
28
|
+
event: "daemon.agent_config_v2_hook_end",
|
|
29
|
+
message: "agent-config-v2 hook completed",
|
|
30
|
+
meta: { agentRoot: ctx.agentRoot },
|
|
31
|
+
});
|
|
32
|
+
return { ok: true };
|
|
33
|
+
}
|