@ouro.bot/cli 0.1.0-alpha.23 → 0.1.0-alpha.231
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 +1408 -1
- 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 +447 -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 +63 -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 +489 -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 +201 -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 +58 -3
- 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 +97 -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/credential-access.js +449 -0
- 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-credential.js +184 -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 +739 -0
- package/dist/repertoire/tools-shell.js +120 -0
- package/dist/repertoire/tools-surface.js +243 -0
- package/dist/repertoire/tools-teams.js +12 -59
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools.js +132 -124
- package/dist/repertoire/travel-api-client.js +214 -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 +1374 -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 +594 -85
- 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 +138 -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,35 @@ 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 { setAgentName } = await Promise.resolve().then(() => __importStar(require("../identity")));
|
|
189
|
+
setAgentName(command.agent);
|
|
190
|
+
const { runSenseTurn } = await Promise.resolve().then(() => __importStar(require("../../senses/shared-turn")));
|
|
191
|
+
const result = await runSenseTurn({
|
|
192
|
+
agentName: command.agent,
|
|
193
|
+
channel: command.channel,
|
|
194
|
+
sessionKey: command.sessionKey,
|
|
195
|
+
friendId: command.friendId,
|
|
196
|
+
userMessage: command.message,
|
|
197
|
+
});
|
|
198
|
+
return {
|
|
199
|
+
ok: true,
|
|
200
|
+
message: result.response,
|
|
201
|
+
data: { ponderDeferred: result.ponderDeferred },
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
/* v8 ignore next -- branch: String(error) fallback only for non-Error throws @preserve */
|
|
206
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
207
|
+
return { ok: false, error: `sense turn failed: ${errorMessage}` };
|
|
208
|
+
}
|
|
209
|
+
}
|
|
86
210
|
class OuroDaemon {
|
|
87
211
|
socketPath;
|
|
88
212
|
processManager;
|
|
@@ -91,7 +215,9 @@ class OuroDaemon {
|
|
|
91
215
|
router;
|
|
92
216
|
senseManager;
|
|
93
217
|
bundlesRoot;
|
|
218
|
+
mode;
|
|
94
219
|
server = null;
|
|
220
|
+
outlookServer = null;
|
|
95
221
|
constructor(options) {
|
|
96
222
|
this.socketPath = options.socketPath;
|
|
97
223
|
this.processManager = options.processManager;
|
|
@@ -100,6 +226,28 @@ class OuroDaemon {
|
|
|
100
226
|
this.router = options.router;
|
|
101
227
|
this.senseManager = options.senseManager ?? null;
|
|
102
228
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
229
|
+
this.mode = options.mode ?? "production";
|
|
230
|
+
}
|
|
231
|
+
buildStatusPayload() {
|
|
232
|
+
const snapshots = this.processManager.listAgentSnapshots();
|
|
233
|
+
const workers = buildWorkerRows(snapshots);
|
|
234
|
+
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
235
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
236
|
+
return {
|
|
237
|
+
overview: {
|
|
238
|
+
daemon: "running",
|
|
239
|
+
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
240
|
+
socketPath: this.socketPath,
|
|
241
|
+
outlookUrl: this.outlookServer?.origin ?? "http://127.0.0.1:0",
|
|
242
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
243
|
+
workerCount: workers.length,
|
|
244
|
+
senseCount: senses.length,
|
|
245
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
246
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
247
|
+
},
|
|
248
|
+
workers,
|
|
249
|
+
senses,
|
|
250
|
+
};
|
|
103
251
|
}
|
|
104
252
|
async start() {
|
|
105
253
|
if (this.server)
|
|
@@ -112,24 +260,165 @@ class OuroDaemon {
|
|
|
112
260
|
});
|
|
113
261
|
// Register update hooks and apply pending updates before starting agents
|
|
114
262
|
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
115
|
-
|
|
263
|
+
(0, update_hooks_1.registerUpdateHook)(agent_config_v2_1.agentConfigV2Hook);
|
|
264
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
265
|
+
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
266
|
+
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
267
|
+
// Skip in dev mode — dev builds should not auto-update from npm
|
|
268
|
+
const bundlesRoot = this.bundlesRoot;
|
|
269
|
+
const daemonSocketPath = this.socketPath;
|
|
270
|
+
if (this.mode === "dev") {
|
|
271
|
+
(0, runtime_1.emitNervesEvent)({
|
|
272
|
+
component: "daemon",
|
|
273
|
+
event: "daemon.update_checker_skip",
|
|
274
|
+
message: "skipping update checker in dev mode",
|
|
275
|
+
meta: { reason: "dev mode" },
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
const daemon = this;
|
|
280
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
281
|
+
currentVersion,
|
|
282
|
+
deps: {
|
|
283
|
+
distTag: "alpha",
|
|
284
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
285
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
286
|
+
return res.json();
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
290
|
+
if (!result.latestVersion)
|
|
291
|
+
return;
|
|
292
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
293
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
294
|
+
spawnSync: child_process_1.spawnSync,
|
|
295
|
+
resolveNewCodePath: (_version) => {
|
|
296
|
+
try {
|
|
297
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
298
|
+
return resolved ? path.dirname(resolved) : null;
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
gracefulShutdown: () => daemon.stop(),
|
|
305
|
+
spawnNewDaemon: (entryPath, sock) => {
|
|
306
|
+
const outFd = fs.openSync(os.devNull, "w");
|
|
307
|
+
const errFd = fs.openSync(os.devNull, "w");
|
|
308
|
+
const child = (0, child_process_1.spawn)(process.execPath, [entryPath, "--socket", sock], {
|
|
309
|
+
detached: true,
|
|
310
|
+
stdio: ["ignore", outFd, errFd],
|
|
311
|
+
});
|
|
312
|
+
child.unref();
|
|
313
|
+
return { pid: child.pid ?? null };
|
|
314
|
+
},
|
|
315
|
+
nodePath: process.execPath,
|
|
316
|
+
bundlesRoot,
|
|
317
|
+
socketPath: daemonSocketPath,
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
/* v8 ignore stop */
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
// Pre-initialize MCP connections so they're ready for the first command (non-blocking)
|
|
324
|
+
/* v8 ignore next -- catch callback: getSharedMcpManager logs errors internally @preserve */
|
|
325
|
+
(0, mcp_manager_1.getSharedMcpManager)().catch(() => { });
|
|
326
|
+
/* v8 ignore start -- orphan cleanup + pidfile: calls process management functions @preserve */
|
|
327
|
+
killOrphanProcesses();
|
|
328
|
+
/* v8 ignore stop */
|
|
116
329
|
await this.processManager.startAutoStartAgents();
|
|
117
330
|
await this.senseManager?.startAutoStartSenses();
|
|
331
|
+
// Write all managed PIDs to disk so the next daemon can clean up
|
|
332
|
+
/* v8 ignore start -- pidfile write: collects PIDs from process managers @preserve */
|
|
333
|
+
const agentPids = this.processManager.listAgentSnapshots().map((s) => s.pid).filter((p) => p !== null);
|
|
334
|
+
const sensePids = this.senseManager?.listManagedPids?.() ?? [];
|
|
335
|
+
writePidfile([...agentPids, ...sensePids]);
|
|
336
|
+
/* v8 ignore stop */
|
|
118
337
|
this.scheduler.start?.();
|
|
119
338
|
await this.scheduler.reconcile?.();
|
|
120
339
|
await this.drainPendingBundleMessages();
|
|
340
|
+
await this.drainPendingSenseMessages();
|
|
341
|
+
/* v8 ignore start — Outlook server startup, tested via outlook-http.test.ts */
|
|
342
|
+
if (!this.outlookServer) {
|
|
343
|
+
try {
|
|
344
|
+
this.outlookServer = await (0, outlook_http_1.startOutlookHttpServer)({
|
|
345
|
+
host: "127.0.0.1",
|
|
346
|
+
port: outlook_types_1.OUTLOOK_DEFAULT_PORT,
|
|
347
|
+
bundlesRoot: this.bundlesRoot,
|
|
348
|
+
readMachineState: () => (0, outlook_read_1.readOutlookMachineState)({ bundlesRoot: this.bundlesRoot }),
|
|
349
|
+
readMachineView: ({ machine }) => {
|
|
350
|
+
const overview = this.buildStatusPayload().overview;
|
|
351
|
+
return (0, outlook_view_1.buildOutlookMachineView)({
|
|
352
|
+
machine,
|
|
353
|
+
daemon: {
|
|
354
|
+
status: overview.daemon,
|
|
355
|
+
health: overview.health,
|
|
356
|
+
mode: overview.mode,
|
|
357
|
+
socketPath: overview.socketPath,
|
|
358
|
+
outlookUrl: overview.outlookUrl,
|
|
359
|
+
entryPath: overview.entryPath,
|
|
360
|
+
workerCount: overview.workerCount,
|
|
361
|
+
senseCount: overview.senseCount,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
},
|
|
365
|
+
readAgentState: (agentName) => (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot }),
|
|
366
|
+
readAgentView: (agentName) => {
|
|
367
|
+
const agent = (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot });
|
|
368
|
+
return (0, outlook_view_1.buildOutlookAgentView)({
|
|
369
|
+
agent,
|
|
370
|
+
viewer: { kind: "human" },
|
|
371
|
+
});
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
(0, runtime_1.emitNervesEvent)({
|
|
377
|
+
level: "warn",
|
|
378
|
+
component: "daemon",
|
|
379
|
+
event: "daemon.outlook_start_failed",
|
|
380
|
+
message: `Outlook server failed to start: ${String(error)}`,
|
|
381
|
+
meta: { port: outlook_types_1.OUTLOOK_DEFAULT_PORT },
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/* v8 ignore stop */
|
|
121
386
|
if (fs.existsSync(this.socketPath)) {
|
|
122
387
|
fs.unlinkSync(this.socketPath);
|
|
123
388
|
}
|
|
124
389
|
this.server = net.createServer((connection) => {
|
|
125
390
|
let raw = "";
|
|
126
391
|
let responded = false;
|
|
392
|
+
/* v8 ignore start — connection error handler requires real socket error @preserve */
|
|
393
|
+
connection.on("error", (err) => {
|
|
394
|
+
(0, runtime_1.emitNervesEvent)({
|
|
395
|
+
level: "warn",
|
|
396
|
+
component: "daemon",
|
|
397
|
+
event: "daemon.connection_error",
|
|
398
|
+
message: "socket connection error",
|
|
399
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
/* v8 ignore stop */
|
|
127
403
|
const flushResponse = async () => {
|
|
128
404
|
if (responded)
|
|
129
405
|
return;
|
|
130
406
|
responded = true;
|
|
131
407
|
const response = await this.handleRawPayload(raw);
|
|
132
|
-
|
|
408
|
+
try {
|
|
409
|
+
connection.end(response);
|
|
410
|
+
/* v8 ignore start — EPIPE catch requires real socket disconnect @preserve */
|
|
411
|
+
}
|
|
412
|
+
catch (err) {
|
|
413
|
+
(0, runtime_1.emitNervesEvent)({
|
|
414
|
+
level: "warn",
|
|
415
|
+
component: "daemon",
|
|
416
|
+
event: "daemon.connection_end_error",
|
|
417
|
+
message: "failed to send response to client (EPIPE)",
|
|
418
|
+
meta: { error: err instanceof Error ? err.message : String(err) },
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/* v8 ignore stop */
|
|
133
422
|
};
|
|
134
423
|
connection.on("data", (chunk) => {
|
|
135
424
|
raw += chunk.toString("utf-8");
|
|
@@ -142,7 +431,22 @@ class OuroDaemon {
|
|
|
142
431
|
const server = this.server;
|
|
143
432
|
await new Promise((resolve, reject) => {
|
|
144
433
|
server.once("error", reject);
|
|
145
|
-
server.listen(this.socketPath, () =>
|
|
434
|
+
server.listen(this.socketPath, () => {
|
|
435
|
+
// Replace the one-time error listener with a persistent one after successful listen
|
|
436
|
+
server.removeAllListeners("error");
|
|
437
|
+
/* v8 ignore start — server error after listen requires real socket race condition @preserve */
|
|
438
|
+
server.on("error", (err) => {
|
|
439
|
+
(0, runtime_1.emitNervesEvent)({
|
|
440
|
+
level: "error",
|
|
441
|
+
component: "daemon",
|
|
442
|
+
event: "daemon.server_error",
|
|
443
|
+
message: "daemon server error after listen",
|
|
444
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
/* v8 ignore stop */
|
|
448
|
+
resolve();
|
|
449
|
+
});
|
|
146
450
|
});
|
|
147
451
|
}
|
|
148
452
|
async drainPendingBundleMessages() {
|
|
@@ -193,6 +497,93 @@ class OuroDaemon {
|
|
|
193
497
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
194
498
|
}
|
|
195
499
|
}
|
|
500
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
501
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
502
|
+
async drainPendingSenseMessages() {
|
|
503
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
504
|
+
return;
|
|
505
|
+
let bundleDirs;
|
|
506
|
+
try {
|
|
507
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
508
|
+
}
|
|
509
|
+
catch {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
for (const bundleDir of bundleDirs) {
|
|
513
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
514
|
+
continue;
|
|
515
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
516
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
517
|
+
if (!fs.existsSync(pendingRoot))
|
|
518
|
+
continue;
|
|
519
|
+
let friendDirs;
|
|
520
|
+
try {
|
|
521
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
522
|
+
}
|
|
523
|
+
catch {
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
for (const friendDir of friendDirs) {
|
|
527
|
+
if (!friendDir.isDirectory())
|
|
528
|
+
continue;
|
|
529
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
530
|
+
let channelDirs;
|
|
531
|
+
try {
|
|
532
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
533
|
+
}
|
|
534
|
+
catch {
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
for (const channelDir of channelDirs) {
|
|
538
|
+
if (!channelDir.isDirectory())
|
|
539
|
+
continue;
|
|
540
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
541
|
+
continue;
|
|
542
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
543
|
+
let keyDirs;
|
|
544
|
+
try {
|
|
545
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
546
|
+
}
|
|
547
|
+
catch {
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
for (const keyDir of keyDirs) {
|
|
551
|
+
if (!keyDir.isDirectory())
|
|
552
|
+
continue;
|
|
553
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
554
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
555
|
+
for (const msg of messages) {
|
|
556
|
+
try {
|
|
557
|
+
await this.router.send({
|
|
558
|
+
from: msg.from,
|
|
559
|
+
to: agentName,
|
|
560
|
+
content: msg.content,
|
|
561
|
+
priority: "normal",
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
catch {
|
|
565
|
+
// Best-effort delivery — log and continue
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (messages.length > 0) {
|
|
569
|
+
(0, runtime_1.emitNervesEvent)({
|
|
570
|
+
component: "daemon",
|
|
571
|
+
event: "daemon.startup_sense_drain",
|
|
572
|
+
message: "drained pending sense messages on startup",
|
|
573
|
+
meta: {
|
|
574
|
+
agent: agentName,
|
|
575
|
+
channel: channelDir.name,
|
|
576
|
+
friendId: friendDir.name,
|
|
577
|
+
key: keyDir.name,
|
|
578
|
+
count: messages.length,
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
196
587
|
async stop() {
|
|
197
588
|
(0, runtime_1.emitNervesEvent)({
|
|
198
589
|
component: "daemon",
|
|
@@ -200,6 +591,8 @@ class OuroDaemon {
|
|
|
200
591
|
message: "stopping daemon server",
|
|
201
592
|
meta: { socketPath: this.socketPath },
|
|
202
593
|
});
|
|
594
|
+
(0, update_checker_1.stopUpdateChecker)();
|
|
595
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
203
596
|
this.scheduler.stop?.();
|
|
204
597
|
await this.processManager.stopAll();
|
|
205
598
|
await this.senseManager?.stopAll();
|
|
@@ -209,6 +602,10 @@ class OuroDaemon {
|
|
|
209
602
|
});
|
|
210
603
|
this.server = null;
|
|
211
604
|
}
|
|
605
|
+
if (this.outlookServer) {
|
|
606
|
+
await this.outlookServer.stop();
|
|
607
|
+
this.outlookServer = null;
|
|
608
|
+
}
|
|
212
609
|
if (fs.existsSync(this.socketPath)) {
|
|
213
610
|
fs.unlinkSync(this.socketPath);
|
|
214
611
|
}
|
|
@@ -233,6 +630,27 @@ class OuroDaemon {
|
|
|
233
630
|
message: "handling daemon command",
|
|
234
631
|
meta: { kind: command.kind },
|
|
235
632
|
});
|
|
633
|
+
try {
|
|
634
|
+
return await this.handleCommandInner(command);
|
|
635
|
+
/* v8 ignore start — command error catch tested in daemon-command-error.test; instanceof branches defensive @preserve */
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
(0, runtime_1.emitNervesEvent)({
|
|
639
|
+
level: "error",
|
|
640
|
+
component: "daemon",
|
|
641
|
+
event: "daemon.command_error",
|
|
642
|
+
message: "unexpected error handling daemon command",
|
|
643
|
+
meta: {
|
|
644
|
+
kind: command.kind,
|
|
645
|
+
error: error instanceof Error ? error.message : String(error),
|
|
646
|
+
stack: error instanceof Error ? error.stack ?? null : null,
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
throw error;
|
|
650
|
+
}
|
|
651
|
+
/* v8 ignore stop */
|
|
652
|
+
}
|
|
653
|
+
async handleCommandInner(command) {
|
|
236
654
|
switch (command.kind) {
|
|
237
655
|
case "daemon.start":
|
|
238
656
|
await this.start();
|
|
@@ -241,21 +659,7 @@ class OuroDaemon {
|
|
|
241
659
|
await this.stop();
|
|
242
660
|
return { ok: true, message: "daemon stopped" };
|
|
243
661
|
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
|
-
};
|
|
662
|
+
const data = this.buildStatusPayload();
|
|
259
663
|
return {
|
|
260
664
|
ok: true,
|
|
261
665
|
summary: formatStatusSummary(data),
|
|
@@ -272,7 +676,7 @@ class OuroDaemon {
|
|
|
272
676
|
ok: true,
|
|
273
677
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
274
678
|
message: "log streaming available via ouro logs",
|
|
275
|
-
data: { logDir: "
|
|
679
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
276
680
|
};
|
|
277
681
|
case "agent.start":
|
|
278
682
|
await this.processManager.startAgent(command.agent);
|
|
@@ -283,6 +687,35 @@ class OuroDaemon {
|
|
|
283
687
|
case "agent.restart":
|
|
284
688
|
await this.processManager.restartAgent?.(command.agent);
|
|
285
689
|
return { ok: true, message: `restarted ${command.agent}` };
|
|
690
|
+
case "agent.ask":
|
|
691
|
+
return (0, agent_service_1.handleAgentAsk)(command);
|
|
692
|
+
case "agent.status":
|
|
693
|
+
return (0, agent_service_1.handleAgentStatus)(command);
|
|
694
|
+
case "agent.catchup":
|
|
695
|
+
return (0, agent_service_1.handleAgentCatchup)(command);
|
|
696
|
+
case "agent.delegate":
|
|
697
|
+
return (0, agent_service_1.handleAgentDelegate)(command);
|
|
698
|
+
case "agent.getContext":
|
|
699
|
+
return (0, agent_service_1.handleAgentGetContext)(command);
|
|
700
|
+
case "agent.searchMemory":
|
|
701
|
+
return (0, agent_service_1.handleAgentSearchMemory)(command);
|
|
702
|
+
case "agent.getTask":
|
|
703
|
+
return (0, agent_service_1.handleAgentGetTask)(command);
|
|
704
|
+
case "agent.checkScope":
|
|
705
|
+
return (0, agent_service_1.handleAgentCheckScope)(command);
|
|
706
|
+
case "agent.requestDecision":
|
|
707
|
+
return (0, agent_service_1.handleAgentRequestDecision)(command);
|
|
708
|
+
case "agent.checkGuidance":
|
|
709
|
+
return (0, agent_service_1.handleAgentCheckGuidance)(command);
|
|
710
|
+
case "agent.reportProgress":
|
|
711
|
+
return (0, agent_service_1.handleAgentReportProgress)(command);
|
|
712
|
+
case "agent.reportBlocker":
|
|
713
|
+
return (0, agent_service_1.handleAgentReportBlocker)(command);
|
|
714
|
+
case "agent.reportComplete":
|
|
715
|
+
return (0, agent_service_1.handleAgentReportComplete)(command);
|
|
716
|
+
case "agent.senseTurn":
|
|
717
|
+
return handleAgentSenseTurn(command);
|
|
718
|
+
/* v8 ignore stop */
|
|
286
719
|
case "cron.list": {
|
|
287
720
|
const jobs = this.scheduler.listJobs();
|
|
288
721
|
const summary = jobs.length === 0
|
|
@@ -314,6 +747,13 @@ class OuroDaemon {
|
|
|
314
747
|
data: messages,
|
|
315
748
|
};
|
|
316
749
|
}
|
|
750
|
+
case "inner.wake":
|
|
751
|
+
await this.processManager.startAgent(command.agent);
|
|
752
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
753
|
+
return {
|
|
754
|
+
ok: true,
|
|
755
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
756
|
+
};
|
|
317
757
|
case "chat.connect":
|
|
318
758
|
await this.processManager.startAgent(command.agent);
|
|
319
759
|
return {
|
|
@@ -336,6 +776,35 @@ class OuroDaemon {
|
|
|
336
776
|
data: receipt,
|
|
337
777
|
};
|
|
338
778
|
}
|
|
779
|
+
case "habit.poke": {
|
|
780
|
+
this.processManager.sendToAgent?.(command.agent, { type: "habit", habitName: command.habitName });
|
|
781
|
+
return {
|
|
782
|
+
ok: true,
|
|
783
|
+
message: `poked habit ${command.habitName} for ${command.agent}`,
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
case "mcp.list": {
|
|
787
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
788
|
+
if (!mcpManager) {
|
|
789
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
790
|
+
}
|
|
791
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
792
|
+
}
|
|
793
|
+
case "mcp.call": {
|
|
794
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
795
|
+
if (!mcpCallManager) {
|
|
796
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
797
|
+
}
|
|
798
|
+
try {
|
|
799
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
800
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
801
|
+
return { ok: true, data: result };
|
|
802
|
+
}
|
|
803
|
+
catch (error) {
|
|
804
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
805
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
806
|
+
}
|
|
807
|
+
}
|
|
339
808
|
case "hatch.start":
|
|
340
809
|
return {
|
|
341
810
|
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
|
+
}
|