@ouro.bot/cli 0.1.0-alpha.35 → 0.1.0-alpha.350
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 +188 -187
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +1 -1
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
- package/changelog.json +2088 -0
- package/dist/arc/attention-types.js +8 -0
- package/dist/arc/cares.js +140 -0
- package/dist/arc/episodes.js +117 -0
- package/dist/arc/intentions.js +133 -0
- package/dist/arc/json-store.js +117 -0
- package/dist/arc/obligations.js +237 -0
- package/dist/arc/packets.js +193 -0
- package/dist/arc/presence.js +185 -0
- package/dist/arc/task-lifecycle.js +65 -0
- package/dist/heart/active-work.js +832 -0
- package/dist/heart/agent-entry.js +37 -2
- package/dist/heart/attachments/image-normalize.js +194 -0
- package/dist/heart/attachments/materialize.js +97 -0
- package/dist/heart/attachments/originals.js +88 -0
- package/dist/heart/attachments/render.js +29 -0
- package/dist/heart/attachments/sources/adapter.js +2 -0
- package/dist/heart/attachments/sources/bluebubbles.js +156 -0
- package/dist/heart/attachments/sources/cli-local-file.js +78 -0
- package/dist/heart/attachments/sources/index.js +16 -0
- package/dist/heart/attachments/store.js +103 -0
- package/dist/heart/attachments/types.js +93 -0
- package/dist/heart/auth/auth-flow.js +463 -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/bundle-state.js +168 -0
- package/dist/heart/commitments.js +111 -0
- package/dist/heart/config-registry.js +304 -0
- package/dist/heart/config.js +53 -21
- package/dist/heart/core.js +744 -252
- package/dist/heart/cross-chat-delivery.js +131 -0
- package/dist/heart/daemon/agent-config-check.js +561 -0
- package/dist/heart/daemon/agent-discovery.js +79 -3
- package/dist/heart/daemon/agent-service.js +360 -0
- package/dist/heart/daemon/agentic-repair.js +170 -0
- package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/cli-defaults.js +591 -0
- package/dist/heart/daemon/cli-exec.js +2633 -0
- package/dist/heart/daemon/cli-help.js +306 -0
- package/dist/heart/daemon/cli-parse.js +913 -0
- package/dist/heart/daemon/cli-render-doctor.js +57 -0
- package/dist/heart/daemon/cli-render.js +512 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/daemon-cli.js +30 -1171
- package/dist/heart/daemon/daemon-entry.js +358 -3
- package/dist/heart/daemon/daemon-health.js +141 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +157 -12
- package/dist/heart/daemon/daemon-tombstone.js +236 -0
- package/dist/heart/daemon/daemon.js +751 -58
- package/dist/heart/daemon/doctor-types.js +8 -0
- package/dist/heart/daemon/doctor.js +465 -0
- package/dist/heart/daemon/health-monitor.js +79 -1
- 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/http-health-probe.js +80 -0
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/interactive-repair.js +91 -0
- package/dist/heart/daemon/launchd.js +46 -9
- package/dist/heart/daemon/log-tailer.js +82 -12
- package/dist/heart/daemon/logs-prune.js +105 -0
- 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 +201 -0
- package/dist/heart/daemon/provider-discovery.js +105 -0
- package/dist/heart/daemon/pulse.js +463 -0
- package/dist/heart/daemon/run-hooks.js +2 -0
- package/dist/heart/daemon/runtime-logging.js +67 -16
- 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 +307 -0
- package/dist/heart/daemon/stale-bundle-prune.js +96 -0
- package/dist/heart/daemon/startup-tui.js +237 -0
- package/dist/heart/daemon/task-scheduler.js +3 -25
- package/dist/heart/daemon/thoughts.js +510 -0
- package/dist/heart/daemon/up-progress.js +135 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/habits/habit-migration.js +181 -0
- package/dist/heart/habits/habit-parser.js +140 -0
- package/dist/heart/habits/habit-scheduler.js +371 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +52 -120
- 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 +56 -10
- package/dist/heart/identity.js +154 -59
- package/dist/heart/kept-notes.js +357 -0
- package/dist/heart/kicks.js +2 -20
- package/dist/heart/machine-identity.js +161 -0
- package/dist/heart/mcp/mcp-server.js +653 -0
- package/dist/heart/migrate-config.js +127 -0
- package/dist/heart/model-capabilities.js +59 -0
- package/dist/heart/outlook/outlook-http-hooks.js +64 -0
- package/dist/heart/outlook/outlook-http-response.js +7 -0
- package/dist/heart/outlook/outlook-http-routes.js +232 -0
- package/dist/heart/outlook/outlook-http-static.js +99 -0
- package/dist/heart/outlook/outlook-http-transport.js +116 -0
- package/dist/heart/outlook/outlook-http.js +99 -0
- package/dist/heart/outlook/outlook-read.js +28 -0
- package/dist/heart/outlook/outlook-types.js +27 -0
- package/dist/heart/outlook/outlook-view.js +194 -0
- package/dist/heart/outlook/readers/agent-machine.js +355 -0
- package/dist/heart/outlook/readers/continuity-readers.js +332 -0
- package/dist/heart/outlook/readers/runtime-readers.js +660 -0
- package/dist/heart/outlook/readers/sessions.js +231 -0
- package/dist/heart/outlook/readers/shared.js +111 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-attempt.js +133 -0
- package/dist/heart/provider-binding-resolver.js +240 -0
- package/dist/heart/provider-credential-pool.js +395 -0
- package/dist/heart/provider-failover.js +135 -0
- package/dist/heart/provider-models.js +81 -0
- package/dist/heart/provider-ping.js +258 -0
- package/dist/heart/provider-state.js +208 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +171 -50
- package/dist/heart/providers/azure.js +97 -11
- package/dist/heart/providers/error-classification.js +63 -0
- package/dist/heart/providers/github-copilot.js +135 -0
- package/dist/heart/providers/minimax-vlm.js +189 -0
- package/dist/heart/providers/minimax.js +23 -6
- package/dist/heart/providers/openai-codex.js +33 -23
- package/dist/heart/session-activity.js +190 -0
- package/dist/heart/session-events.js +727 -0
- package/dist/heart/session-transcript.js +162 -0
- package/dist/heart/start-of-turn-packet.js +341 -0
- package/dist/heart/streaming.js +36 -27
- package/dist/heart/sync.js +332 -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-friction.js +55 -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/{daemon → versioning}/ouro-bot-global-installer.js +1 -1
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
- package/dist/heart/versioning/ouro-path-installer.js +296 -0
- package/dist/heart/versioning/ouro-version-manager.js +295 -0
- package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
- package/dist/heart/{daemon → versioning}/update-checker.js +12 -2
- package/dist/heart/{daemon → versioning}/update-hooks.js +63 -59
- package/dist/mind/bundle-manifest.js +7 -1
- package/dist/mind/context.js +140 -94
- package/dist/mind/diary-integrity.js +60 -0
- package/dist/mind/{memory.js → diary.js} +84 -96
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/first-impressions.js +14 -1
- package/dist/mind/friends/channel.js +56 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/resolver.js +38 -1
- package/dist/mind/friends/store-file.js +58 -3
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +9 -1
- package/dist/mind/journal-index.js +161 -0
- package/dist/mind/note-search.js +268 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/pending.js +74 -7
- package/dist/mind/prompt.js +1000 -112
- package/dist/mind/provenance-trust.js +26 -0
- package/dist/mind/scrutiny.js +173 -0
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +7 -1
- package/dist/nerves/coverage/audit-rules.js +15 -6
- package/dist/nerves/coverage/audit.js +28 -2
- package/dist/nerves/coverage/cli.js +1 -1
- package/dist/nerves/coverage/file-completeness.js +83 -5
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/nerves/event-buffer.js +111 -0
- package/dist/nerves/index.js +224 -4
- package/dist/nerves/observation.js +20 -0
- package/dist/nerves/redact.js +79 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
- package/dist/outlook-ui/assets/index-xTdv64BV.js +61 -0
- package/dist/outlook-ui/index.html +15 -0
- package/dist/repertoire/ado-client.js +15 -56
- package/dist/repertoire/ado-semantic.js +11 -10
- package/dist/repertoire/api-client.js +97 -0
- package/dist/repertoire/bitwarden-store.js +319 -0
- package/dist/repertoire/bundle-templates.js +72 -0
- package/dist/repertoire/bw-installer.js +79 -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 +158 -9
- package/dist/repertoire/coding/spawner.js +55 -9
- package/dist/repertoire/coding/tools.js +170 -7
- package/dist/repertoire/commerce-errors.js +109 -0
- package/dist/repertoire/commerce-self-test.js +156 -0
- package/dist/repertoire/credential-access.js +527 -0
- package/dist/repertoire/duffel-client.js +185 -0
- package/dist/repertoire/github-client.js +14 -55
- package/dist/repertoire/graph-client.js +11 -52
- package/dist/repertoire/guardrails.js +375 -0
- package/dist/repertoire/mcp-client.js +255 -0
- package/dist/repertoire/mcp-manager.js +305 -0
- package/dist/repertoire/mcp-tools.js +63 -0
- package/dist/repertoire/shell-sessions.js +133 -0
- package/dist/repertoire/skills.js +15 -24
- package/dist/repertoire/stripe-client.js +131 -0
- 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 +16 -79
- package/dist/repertoire/tool-results.js +29 -0
- package/dist/repertoire/tools-attachments.js +316 -0
- package/dist/repertoire/tools-base.js +45 -771
- package/dist/repertoire/tools-bluebubbles.js +1 -0
- package/dist/repertoire/tools-bridge.js +141 -0
- package/dist/repertoire/tools-bundle.js +984 -0
- package/dist/repertoire/tools-config.js +185 -0
- package/dist/repertoire/tools-continuity.js +248 -0
- package/dist/repertoire/tools-credential.js +182 -0
- package/dist/repertoire/tools-files.js +342 -0
- package/dist/repertoire/tools-flight.js +224 -0
- package/dist/repertoire/tools-flow.js +105 -0
- package/dist/repertoire/tools-github.js +1 -7
- package/dist/repertoire/tools-notes.js +376 -0
- package/dist/repertoire/tools-session.js +739 -0
- package/dist/repertoire/tools-shell.js +120 -0
- package/dist/repertoire/tools-stripe.js +180 -0
- package/dist/repertoire/tools-surface.js +243 -0
- package/dist/repertoire/tools-teams.js +12 -62
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools-user-profile.js +144 -0
- package/dist/repertoire/tools-vault.js +110 -0
- package/dist/repertoire/tools.js +144 -138
- package/dist/repertoire/travel-api-client.js +360 -0
- package/dist/repertoire/user-profile.js +118 -0
- package/dist/repertoire/vault-setup.js +241 -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 +116 -0
- package/dist/senses/bluebubbles/attachment-cache.js +53 -0
- package/dist/senses/bluebubbles/attachment-download.js +137 -0
- package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +225 -9
- package/dist/senses/bluebubbles/entry.js +13 -0
- package/dist/senses/bluebubbles/inbound-log.js +113 -0
- package/dist/senses/bluebubbles/index.js +1590 -0
- package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -70
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +43 -12
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +46 -6
- package/dist/senses/bluebubbles/replay.js +129 -0
- package/dist/senses/bluebubbles/runtime-state.js +109 -0
- package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
- package/dist/senses/cli/bracketed-paste.js +82 -0
- package/dist/senses/cli/image-paste.js +287 -0
- package/dist/senses/cli/image-ref-navigation.js +75 -0
- package/dist/senses/cli/ink-app.js +156 -0
- package/dist/senses/cli/inline-diff.js +64 -0
- package/dist/senses/cli/input-keys.js +174 -0
- package/dist/senses/cli/kill-ring.js +86 -0
- package/dist/senses/cli/message-list.js +51 -0
- package/dist/senses/cli/ouro-tui.js +605 -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 +240 -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 +603 -246
- 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 +633 -86
- package/dist/senses/pipeline.js +567 -0
- package/dist/senses/shared-turn.js +199 -0
- package/dist/senses/surface-tool.js +68 -0
- package/dist/senses/teams.js +665 -160
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +29 -7
- package/skills/agent-commerce.md +106 -0
- package/skills/browser-navigation.md +110 -0
- package/skills/commerce-setup-guide.md +116 -0
- package/skills/commerce-setup.md +84 -0
- package/skills/configure-dev-tools.md +81 -0
- package/skills/travel-planning.md +138 -0
- package/dist/heart/daemon/ouro-path-installer.js +0 -178
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/dist/mind/associative-recall.js +0 -197
- package/dist/senses/bluebubbles-entry.js +0 -11
- package/dist/senses/bluebubbles.js +0 -548
- package/dist/senses/debug-activity.js +0 -127
- 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-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
- /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
|
@@ -34,18 +34,261 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.OuroDaemon = void 0;
|
|
37
|
+
exports.parseOrphanPidsFromPs = parseOrphanPidsFromPs;
|
|
38
|
+
exports.filterPidfilePidsToActualOrphans = filterPidfilePidsToActualOrphans;
|
|
39
|
+
exports.killOrphanProcesses = killOrphanProcesses;
|
|
40
|
+
exports.writePidfile = writePidfile;
|
|
41
|
+
exports.handleAgentSenseTurn = handleAgentSenseTurn;
|
|
37
42
|
const fs = __importStar(require("fs"));
|
|
38
43
|
const net = __importStar(require("net"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
39
45
|
const path = __importStar(require("path"));
|
|
40
46
|
const identity_1 = require("../identity");
|
|
47
|
+
const agent_discovery_1 = require("./agent-discovery");
|
|
41
48
|
const runtime_1 = require("../../nerves/runtime");
|
|
42
49
|
const runtime_metadata_1 = require("./runtime-metadata");
|
|
43
|
-
const
|
|
50
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
51
|
+
const update_hooks_1 = require("../versioning/update-hooks");
|
|
44
52
|
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
53
|
+
const agent_config_v2_1 = require("./hooks/agent-config-v2");
|
|
45
54
|
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
46
|
-
const update_checker_1 = require("
|
|
47
|
-
const staged_restart_1 = require("
|
|
55
|
+
const update_checker_1 = require("../versioning/update-checker");
|
|
56
|
+
const staged_restart_1 = require("../versioning/staged-restart");
|
|
57
|
+
const ouro_version_manager_1 = require("../versioning/ouro-version-manager");
|
|
48
58
|
const child_process_1 = require("child_process");
|
|
59
|
+
const pending_1 = require("../../mind/pending");
|
|
60
|
+
const agent_service_1 = require("./agent-service");
|
|
61
|
+
const channel_1 = require("../../mind/friends/channel");
|
|
62
|
+
const mcp_manager_1 = require("../../repertoire/mcp-manager");
|
|
63
|
+
const outlook_http_1 = require("../outlook/outlook-http");
|
|
64
|
+
const outlook_types_1 = require("../outlook/outlook-types");
|
|
65
|
+
const outlook_read_1 = require("../outlook/outlook-read");
|
|
66
|
+
const outlook_view_1 = require("../outlook/outlook-view");
|
|
67
|
+
const PIDFILE_PATH = path.join(os.homedir(), ".ouro-cli", "daemon.pids");
|
|
68
|
+
/**
|
|
69
|
+
* Defense-in-depth: detect if we're running under vitest. The pidfile lives
|
|
70
|
+
* at a hardcoded path under the user's real ~/.ouro-cli/ — there's no DI
|
|
71
|
+
* seam to redirect it. So when a test creates a real OuroDaemon and calls
|
|
72
|
+
* start(), the daemon's killOrphanProcesses() reads the REAL pidfile,
|
|
73
|
+
* ps-verifies the PIDs, and SIGTERMs the production daemon. We saw this
|
|
74
|
+
* cause an outage on 2026-04-08 (alpha.265 daemon killed 93s after startup
|
|
75
|
+
* by a vitest test that called daemon.start()).
|
|
76
|
+
*
|
|
77
|
+
* Both killOrphanProcesses() and writePidfile() short-circuit under vitest
|
|
78
|
+
* to make the production pidfile sacred. Tests that need to verify these
|
|
79
|
+
* functions' behavior should use the extracted pure helpers
|
|
80
|
+
* (parseOrphanPidsFromPs, filterPidfilePidsToActualOrphans).
|
|
81
|
+
*/
|
|
82
|
+
function isVitestProcess() {
|
|
83
|
+
/* v8 ignore next -- defensive: process and process.argv always exist in node @preserve */
|
|
84
|
+
if (typeof process === "undefined" || !Array.isArray(process.argv))
|
|
85
|
+
return false;
|
|
86
|
+
return process.argv.some((arg) => typeof arg === "string" && arg.includes("vitest"));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Scan `ps -eo pid,ppid,command` output for daemon-owned entry points whose
|
|
90
|
+
* parent has died (PPID reparented to init/PID 1). Returns the list of PIDs
|
|
91
|
+
* that are safe to SIGTERM — true orphans, not children of live sibling
|
|
92
|
+
* daemons running from worktrees, test suites, or other users of the harness.
|
|
93
|
+
*
|
|
94
|
+
* Exported so unit tests can exercise the filter without shelling out.
|
|
95
|
+
*/
|
|
96
|
+
function parseOrphanPidsFromPs(psOutput, selfPid) {
|
|
97
|
+
const orphans = [];
|
|
98
|
+
for (const line of psOutput.split("\n")) {
|
|
99
|
+
// Explicitly exclude MCP server processes — they share a harness entry
|
|
100
|
+
// point but are not daemon children and must never be killed.
|
|
101
|
+
if (line.includes("mcp-serve") || line.includes("mcp serve"))
|
|
102
|
+
continue;
|
|
103
|
+
// Match only daemon-owned JS entry points.
|
|
104
|
+
if (!line.includes("agent-entry.js")
|
|
105
|
+
&& !line.includes("daemon-entry.js")
|
|
106
|
+
&& !line.includes("bluebubbles/entry.js")
|
|
107
|
+
&& !line.includes("teams-entry.js"))
|
|
108
|
+
continue;
|
|
109
|
+
// Parse `<pid> <ppid> <command...>`. ps pads these with leading spaces.
|
|
110
|
+
// Regex guarantees both groups are \d+ so parseInt can't produce NaN.
|
|
111
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)\s/);
|
|
112
|
+
if (!match)
|
|
113
|
+
continue;
|
|
114
|
+
const pid = parseInt(match[1], 10);
|
|
115
|
+
const ppid = parseInt(match[2], 10);
|
|
116
|
+
if (pid === selfPid)
|
|
117
|
+
continue;
|
|
118
|
+
// CRITICAL: only kill processes whose parent is init (PID 1). A live
|
|
119
|
+
// PPID means the process belongs to another daemon instance (parallel
|
|
120
|
+
// test run, sibling worktree, another user of /tmp/ouroboros-daemon.sock).
|
|
121
|
+
// Killing those will crash unrelated harnesses — we saw this in B6
|
|
122
|
+
// when a vitest worker's daemon killed slugger's production children.
|
|
123
|
+
if (ppid !== 1)
|
|
124
|
+
continue;
|
|
125
|
+
orphans.push(pid);
|
|
126
|
+
}
|
|
127
|
+
return orphans;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Given a list of PIDs from the pidfile, return only those that are actual
|
|
131
|
+
* orphans (PPID reparented to init/PID 1). Protects against a polluted
|
|
132
|
+
* pidfile killing a PID that the OS has reassigned to an unrelated process.
|
|
133
|
+
*
|
|
134
|
+
* Implementation: shells out to `ps -p <csv> -o pid,ppid` for a batch lookup.
|
|
135
|
+
* Returns the empty list if ps fails — safer to skip cleanup than to
|
|
136
|
+
* wildcard-kill on a bad read.
|
|
137
|
+
*
|
|
138
|
+
* Exported for direct unit coverage.
|
|
139
|
+
*/
|
|
140
|
+
function filterPidfilePidsToActualOrphans(candidatePids, psRunner = runPsCheck) {
|
|
141
|
+
if (candidatePids.length === 0)
|
|
142
|
+
return [];
|
|
143
|
+
const psOutput = psRunner(candidatePids);
|
|
144
|
+
if (psOutput === null)
|
|
145
|
+
return [];
|
|
146
|
+
const survivingOrphans = [];
|
|
147
|
+
// `ps -p x,y,z -o pid,ppid` emits a header line then one row per found PID.
|
|
148
|
+
// PIDs not found (already exited) are silently omitted — which is the
|
|
149
|
+
// correct behavior for us: we only want to kill live orphans.
|
|
150
|
+
for (const line of psOutput.split("\n")) {
|
|
151
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)$/);
|
|
152
|
+
if (!match)
|
|
153
|
+
continue;
|
|
154
|
+
const pid = parseInt(match[1], 10);
|
|
155
|
+
const ppid = parseInt(match[2], 10);
|
|
156
|
+
if (ppid !== 1)
|
|
157
|
+
continue;
|
|
158
|
+
if (!candidatePids.includes(pid))
|
|
159
|
+
continue;
|
|
160
|
+
survivingOrphans.push(pid);
|
|
161
|
+
}
|
|
162
|
+
return survivingOrphans;
|
|
163
|
+
}
|
|
164
|
+
/* v8 ignore start -- shells out to ps; covered by filterPidfilePidsToActualOrphans unit tests via injected runner @preserve */
|
|
165
|
+
function runPsCheck(pids) {
|
|
166
|
+
try {
|
|
167
|
+
const csv = pids.join(",");
|
|
168
|
+
return (0, child_process_1.execSync)(`ps -p ${csv} -o pid=,ppid=`, { encoding: "utf-8", timeout: 5000 });
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// ps returns non-zero when none of the requested PIDs exist. Treat as
|
|
172
|
+
// "no survivors" rather than an error.
|
|
173
|
+
return "";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/* v8 ignore stop */
|
|
177
|
+
/**
|
|
178
|
+
* Kill all ouro processes from the previous daemon instance using the pidfile.
|
|
179
|
+
* On startup, reads PIDs from ~/.ouro-cli/daemon.pids, kills them all, then
|
|
180
|
+
* deletes the file. The new daemon writes its own PIDs after spawning.
|
|
181
|
+
*
|
|
182
|
+
* Safety: pidfile contents are verified before being killed — each PID must
|
|
183
|
+
* be an actual orphan (PPID reparented to init/PID 1) via
|
|
184
|
+
* `filterPidfilePidsToActualOrphans`. Otherwise a polluted pidfile (written
|
|
185
|
+
* by a test, or a crashed daemon whose PIDs have since been reused by the
|
|
186
|
+
* OS) could SIGTERM unrelated processes.
|
|
187
|
+
*
|
|
188
|
+
* Falls back to ps-based scanning scoped to true orphans (PPID=1) if the
|
|
189
|
+
* pidfile doesn't exist (first run, previous daemon crashed before writing,
|
|
190
|
+
* manual cleanup). The scope is narrow on purpose — see parseOrphanPidsFromPs.
|
|
191
|
+
*/
|
|
192
|
+
/* v8 ignore start -- process lifecycle: uses kill/ps, tested via deployment @preserve */
|
|
193
|
+
function killOrphanProcesses() {
|
|
194
|
+
if (isVitestProcess()) {
|
|
195
|
+
(0, runtime_1.emitNervesEvent)({
|
|
196
|
+
level: "warn",
|
|
197
|
+
component: "daemon",
|
|
198
|
+
event: "daemon.orphan_cleanup_test_blocked",
|
|
199
|
+
message: "blocked killOrphanProcesses from touching real pidfile under vitest",
|
|
200
|
+
meta: { pidfilePath: PIDFILE_PATH },
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
let pidsToKill = [];
|
|
206
|
+
// Primary: read pidfile from previous daemon
|
|
207
|
+
try {
|
|
208
|
+
const raw = fs.readFileSync(PIDFILE_PATH, "utf-8");
|
|
209
|
+
const candidates = raw.split("\n")
|
|
210
|
+
.map((s) => parseInt(s.trim(), 10))
|
|
211
|
+
.filter((n) => !isNaN(n) && n !== process.pid);
|
|
212
|
+
// Verify each candidate is an actual live orphan before killing. See
|
|
213
|
+
// docstring above for why this matters.
|
|
214
|
+
pidsToKill = filterPidfilePidsToActualOrphans(candidates);
|
|
215
|
+
fs.unlinkSync(PIDFILE_PATH);
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// No pidfile — fall back to ps scan (scoped to orphans with PPID=1).
|
|
219
|
+
}
|
|
220
|
+
if (pidsToKill.length === 0) {
|
|
221
|
+
try {
|
|
222
|
+
const result = (0, child_process_1.execSync)("ps -eo pid,ppid,command", { encoding: "utf-8", timeout: 5000 });
|
|
223
|
+
pidsToKill = parseOrphanPidsFromPs(result, process.pid);
|
|
224
|
+
}
|
|
225
|
+
catch { /* ps failed — best effort */ }
|
|
226
|
+
}
|
|
227
|
+
if (pidsToKill.length > 0) {
|
|
228
|
+
for (const pid of pidsToKill) {
|
|
229
|
+
try {
|
|
230
|
+
process.kill(pid, "SIGTERM");
|
|
231
|
+
}
|
|
232
|
+
catch { /* already exited */ }
|
|
233
|
+
}
|
|
234
|
+
(0, runtime_1.emitNervesEvent)({
|
|
235
|
+
component: "daemon",
|
|
236
|
+
event: "daemon.orphan_cleanup",
|
|
237
|
+
message: `killed ${pidsToKill.length} orphaned ouro processes`,
|
|
238
|
+
meta: { pids: pidsToKill },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
(0, runtime_1.emitNervesEvent)({
|
|
244
|
+
level: "warn",
|
|
245
|
+
component: "daemon",
|
|
246
|
+
event: "daemon.orphan_cleanup_error",
|
|
247
|
+
message: "failed to clean up orphaned ouro processes",
|
|
248
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Write all managed PIDs (daemon + children) to the pidfile.
|
|
254
|
+
* Called after all agents and senses are spawned.
|
|
255
|
+
*/
|
|
256
|
+
function writePidfile(extraPids = []) {
|
|
257
|
+
if (isVitestProcess()) {
|
|
258
|
+
(0, runtime_1.emitNervesEvent)({
|
|
259
|
+
level: "warn",
|
|
260
|
+
component: "daemon",
|
|
261
|
+
event: "daemon.write_pidfile_test_blocked",
|
|
262
|
+
message: "blocked writePidfile from clobbering real pidfile under vitest",
|
|
263
|
+
meta: { pidfilePath: PIDFILE_PATH, attemptedPids: extraPids.length },
|
|
264
|
+
});
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
const pids = [process.pid, ...extraPids].filter(Boolean);
|
|
269
|
+
fs.mkdirSync(path.dirname(PIDFILE_PATH), { recursive: true });
|
|
270
|
+
fs.writeFileSync(PIDFILE_PATH, pids.join("\n") + "\n", "utf-8");
|
|
271
|
+
}
|
|
272
|
+
catch { /* best effort */ }
|
|
273
|
+
}
|
|
274
|
+
function readSocketIdentity(socketPath) {
|
|
275
|
+
try {
|
|
276
|
+
const stats = fs.lstatSync(socketPath);
|
|
277
|
+
return {
|
|
278
|
+
dev: stats.dev,
|
|
279
|
+
ino: stats.ino,
|
|
280
|
+
ctimeMs: stats.ctimeMs,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function sameSocketIdentity(left, right) {
|
|
288
|
+
if (!left || !right)
|
|
289
|
+
return false;
|
|
290
|
+
return left.dev === right.dev && left.ino === right.ino && left.ctimeMs === right.ctimeMs;
|
|
291
|
+
}
|
|
49
292
|
function buildWorkerRows(snapshots) {
|
|
50
293
|
return snapshots.map((snapshot) => ({
|
|
51
294
|
agent: snapshot.name,
|
|
@@ -54,6 +297,10 @@ function buildWorkerRows(snapshots) {
|
|
|
54
297
|
pid: snapshot.pid,
|
|
55
298
|
restartCount: snapshot.restartCount,
|
|
56
299
|
startedAt: snapshot.startedAt,
|
|
300
|
+
lastExitCode: snapshot.lastExitCode ?? null,
|
|
301
|
+
lastSignal: snapshot.lastSignal ?? null,
|
|
302
|
+
errorReason: snapshot.errorReason ?? null,
|
|
303
|
+
fixHint: snapshot.fixHint ?? null,
|
|
57
304
|
}));
|
|
58
305
|
}
|
|
59
306
|
function formatStatusSummary(payload) {
|
|
@@ -86,6 +333,35 @@ function parseIncomingCommand(raw) {
|
|
|
86
333
|
}
|
|
87
334
|
return parsed;
|
|
88
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Handle agent.senseTurn command: runs a full agent turn via the daemon process.
|
|
338
|
+
* Dynamic import lazy-loads shared-turn. Hot-reload works because ouro dev
|
|
339
|
+
* restarts the daemon process (fresh module cache).
|
|
340
|
+
*/
|
|
341
|
+
async function handleAgentSenseTurn(command) {
|
|
342
|
+
try {
|
|
343
|
+
const { setAgentName } = await Promise.resolve().then(() => __importStar(require("../identity")));
|
|
344
|
+
setAgentName(command.agent);
|
|
345
|
+
const { runSenseTurn } = await Promise.resolve().then(() => __importStar(require("../../senses/shared-turn")));
|
|
346
|
+
const result = await runSenseTurn({
|
|
347
|
+
agentName: command.agent,
|
|
348
|
+
channel: command.channel,
|
|
349
|
+
sessionKey: command.sessionKey,
|
|
350
|
+
friendId: command.friendId,
|
|
351
|
+
userMessage: command.message,
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
ok: true,
|
|
355
|
+
message: result.response,
|
|
356
|
+
data: { ponderDeferred: result.ponderDeferred },
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
/* v8 ignore next -- branch: String(error) fallback only for non-Error throws @preserve */
|
|
361
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
362
|
+
return { ok: false, error: `sense turn failed: ${errorMessage}` };
|
|
363
|
+
}
|
|
364
|
+
}
|
|
89
365
|
class OuroDaemon {
|
|
90
366
|
socketPath;
|
|
91
367
|
processManager;
|
|
@@ -94,7 +370,11 @@ class OuroDaemon {
|
|
|
94
370
|
router;
|
|
95
371
|
senseManager;
|
|
96
372
|
bundlesRoot;
|
|
373
|
+
mode;
|
|
97
374
|
server = null;
|
|
375
|
+
outlookServer = null;
|
|
376
|
+
socketIdentity = null;
|
|
377
|
+
outlookServerFactory;
|
|
98
378
|
constructor(options) {
|
|
99
379
|
this.socketPath = options.socketPath;
|
|
100
380
|
this.processManager = options.processManager;
|
|
@@ -103,6 +383,67 @@ class OuroDaemon {
|
|
|
103
383
|
this.router = options.router;
|
|
104
384
|
this.senseManager = options.senseManager ?? null;
|
|
105
385
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
386
|
+
this.mode = options.mode ?? "production";
|
|
387
|
+
this.outlookServerFactory = options.outlookServerFactory ?? this.createDefaultOutlookServer.bind(this);
|
|
388
|
+
}
|
|
389
|
+
/* v8 ignore start -- default outlook server wiring: production-only path, tests inject outlookServerFactory stub instead. startOutlookHttpServer itself has full coverage in outlook-http.test.ts @preserve */
|
|
390
|
+
createDefaultOutlookServer() {
|
|
391
|
+
return (0, outlook_http_1.startOutlookHttpServer)({
|
|
392
|
+
host: "127.0.0.1",
|
|
393
|
+
port: outlook_types_1.OUTLOOK_DEFAULT_PORT,
|
|
394
|
+
bundlesRoot: this.bundlesRoot,
|
|
395
|
+
readMachineState: () => (0, outlook_read_1.readOutlookMachineState)({ bundlesRoot: this.bundlesRoot }),
|
|
396
|
+
readMachineView: ({ machine }) => {
|
|
397
|
+
const overview = this.buildStatusPayload().overview;
|
|
398
|
+
return (0, outlook_view_1.buildOutlookMachineView)({
|
|
399
|
+
machine,
|
|
400
|
+
daemon: {
|
|
401
|
+
status: overview.daemon,
|
|
402
|
+
health: overview.health,
|
|
403
|
+
mode: overview.mode,
|
|
404
|
+
socketPath: overview.socketPath,
|
|
405
|
+
outlookUrl: overview.outlookUrl,
|
|
406
|
+
entryPath: overview.entryPath,
|
|
407
|
+
workerCount: overview.workerCount,
|
|
408
|
+
senseCount: overview.senseCount,
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
readAgentState: (agentName) => (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot }),
|
|
413
|
+
readAgentView: (agentName) => {
|
|
414
|
+
const agent = (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot });
|
|
415
|
+
return (0, outlook_view_1.buildOutlookAgentView)({
|
|
416
|
+
agent,
|
|
417
|
+
viewer: { kind: "human" },
|
|
418
|
+
});
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
/* v8 ignore stop */
|
|
423
|
+
buildStatusPayload() {
|
|
424
|
+
const snapshots = this.processManager.listAgentSnapshots();
|
|
425
|
+
const workers = buildWorkerRows(snapshots);
|
|
426
|
+
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
427
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
428
|
+
const sync = (0, agent_discovery_1.listBundleSyncRows)({ bundlesRoot: this.bundlesRoot });
|
|
429
|
+
const agents = (0, agent_discovery_1.listAllBundleAgents)({ bundlesRoot: this.bundlesRoot });
|
|
430
|
+
return {
|
|
431
|
+
overview: {
|
|
432
|
+
daemon: "running",
|
|
433
|
+
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
434
|
+
socketPath: this.socketPath,
|
|
435
|
+
outlookUrl: this.outlookServer?.origin ?? "http://127.0.0.1:0",
|
|
436
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
437
|
+
workerCount: workers.length,
|
|
438
|
+
senseCount: senses.length,
|
|
439
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
440
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
441
|
+
},
|
|
442
|
+
workers,
|
|
443
|
+
senses,
|
|
444
|
+
sync,
|
|
445
|
+
agents,
|
|
446
|
+
};
|
|
106
447
|
}
|
|
107
448
|
async start() {
|
|
108
449
|
if (this.server)
|
|
@@ -113,61 +454,181 @@ class OuroDaemon {
|
|
|
113
454
|
message: "starting daemon server",
|
|
114
455
|
meta: { socketPath: this.socketPath },
|
|
115
456
|
});
|
|
457
|
+
try {
|
|
458
|
+
await this.startInner();
|
|
459
|
+
}
|
|
460
|
+
catch (err) {
|
|
461
|
+
// Emit a paired terminating event (`_error`) so the nerves audit's
|
|
462
|
+
// start_end_pairing rule is satisfied when startup throws mid-sequence
|
|
463
|
+
// and `stop()` (which emits `server_end`) is never called.
|
|
464
|
+
(0, runtime_1.emitNervesEvent)({
|
|
465
|
+
level: "error",
|
|
466
|
+
component: "daemon",
|
|
467
|
+
event: "daemon.server_error",
|
|
468
|
+
message: "daemon start failed",
|
|
469
|
+
meta: {
|
|
470
|
+
error: err instanceof Error ? err.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(err),
|
|
471
|
+
},
|
|
472
|
+
});
|
|
473
|
+
throw err;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
async startInner() {
|
|
116
477
|
// Register update hooks and apply pending updates before starting agents
|
|
117
478
|
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
479
|
+
(0, update_hooks_1.registerUpdateHook)(agent_config_v2_1.agentConfigV2Hook);
|
|
118
480
|
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
119
481
|
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
120
482
|
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
483
|
+
// Skip in dev mode — dev builds should not auto-update from npm
|
|
121
484
|
const bundlesRoot = this.bundlesRoot;
|
|
122
|
-
const
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
141
|
-
return resolved ? path.dirname(resolved) : null;
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
485
|
+
const daemonSocketPath = this.socketPath;
|
|
486
|
+
if (this.mode === "dev") {
|
|
487
|
+
(0, runtime_1.emitNervesEvent)({
|
|
488
|
+
component: "daemon",
|
|
489
|
+
event: "daemon.update_checker_skip",
|
|
490
|
+
message: "skipping update checker in dev mode",
|
|
491
|
+
meta: { reason: "dev mode" },
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
const daemon = this;
|
|
496
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
497
|
+
currentVersion,
|
|
498
|
+
deps: {
|
|
499
|
+
distTag: "alpha",
|
|
500
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
501
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
502
|
+
return res.json();
|
|
146
503
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
504
|
+
},
|
|
505
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
506
|
+
if (!result.latestVersion)
|
|
507
|
+
return;
|
|
508
|
+
// Install via the version manager (NOT `npm install -g`). The
|
|
509
|
+
// global install path doesn't end up on the daemon process's
|
|
510
|
+
// NODE_PATH, so the previous `require.resolve('@ouro.bot/cli')`
|
|
511
|
+
// -based path lookup always returned null and the staged restart
|
|
512
|
+
// never actually completed. Verified live on 2026-04-08:
|
|
513
|
+
// alpha.268 daemon detected alpha.270 was available, ran the
|
|
514
|
+
// staged restart, and bailed at `staged_restart_path_failed` —
|
|
515
|
+
// meaning the daemon could never auto-update itself and required
|
|
516
|
+
// manual `ouro up` to pick up new versions.
|
|
517
|
+
//
|
|
518
|
+
// Switch to the version-managed layout the CLI itself uses:
|
|
519
|
+
// installVersion(version) puts files at
|
|
520
|
+
// ~/.ouro-cli/versions/{version}/node_modules/@ouro.bot/cli
|
|
521
|
+
// which is a known path we can compute deterministically.
|
|
522
|
+
// Then activateVersion(version) flips the CurrentVersion symlink
|
|
523
|
+
// so the next `ouro up` from the user sees the same version
|
|
524
|
+
// the daemon is running.
|
|
525
|
+
const cliHome = (0, ouro_version_manager_1.getOuroCliHome)();
|
|
526
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
527
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
528
|
+
spawnSync: child_process_1.spawnSync,
|
|
529
|
+
installNewVersion: (version) => {
|
|
530
|
+
(0, ouro_version_manager_1.installVersion)(version, {});
|
|
531
|
+
(0, ouro_version_manager_1.activateVersion)(version, {});
|
|
532
|
+
},
|
|
533
|
+
resolveNewCodePath: (version) => {
|
|
534
|
+
const versionPath = path.join(cliHome, "versions", version, "node_modules", "@ouro.bot", "cli");
|
|
535
|
+
return fs.existsSync(versionPath) ? versionPath : null;
|
|
536
|
+
},
|
|
537
|
+
gracefulShutdown: () => daemon.stop(),
|
|
538
|
+
spawnNewDaemon: (entryPath, sock) => {
|
|
539
|
+
const outFd = fs.openSync(os.devNull, "w");
|
|
540
|
+
const errFd = fs.openSync(os.devNull, "w");
|
|
541
|
+
const child = (0, child_process_1.spawn)(process.execPath, [entryPath, "--socket", sock], {
|
|
542
|
+
detached: true,
|
|
543
|
+
stdio: ["ignore", outFd, errFd],
|
|
544
|
+
});
|
|
545
|
+
child.unref();
|
|
546
|
+
return { pid: child.pid ?? null };
|
|
547
|
+
},
|
|
548
|
+
nodePath: process.execPath,
|
|
549
|
+
bundlesRoot,
|
|
550
|
+
socketPath: daemonSocketPath,
|
|
551
|
+
});
|
|
552
|
+
},
|
|
553
|
+
/* v8 ignore stop */
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
// MCP connections are lazily initialized per-agent during senseTurn
|
|
557
|
+
// (daemon manages multiple agents; agent identity must be set before loading MCP config)
|
|
558
|
+
/* v8 ignore start -- orphan cleanup + pidfile: calls process management functions @preserve */
|
|
559
|
+
killOrphanProcesses();
|
|
560
|
+
/* v8 ignore stop */
|
|
154
561
|
await this.processManager.startAutoStartAgents();
|
|
155
562
|
await this.senseManager?.startAutoStartSenses();
|
|
563
|
+
// Write all managed PIDs to disk so the next daemon can clean up
|
|
564
|
+
/* v8 ignore start -- pidfile write: collects PIDs from process managers @preserve */
|
|
565
|
+
const agentPids = this.processManager.listAgentSnapshots().map((s) => s.pid).filter((p) => p !== null);
|
|
566
|
+
const sensePids = this.senseManager?.listManagedPids?.() ?? [];
|
|
567
|
+
writePidfile([...agentPids, ...sensePids]);
|
|
568
|
+
/* v8 ignore stop */
|
|
156
569
|
this.scheduler.start?.();
|
|
157
570
|
await this.scheduler.reconcile?.();
|
|
158
571
|
await this.drainPendingBundleMessages();
|
|
572
|
+
await this.drainPendingSenseMessages();
|
|
573
|
+
// startInner is only reachable when this.server is null (guarded in
|
|
574
|
+
// start()), and stop() nulls out this.outlookServer alongside this.server,
|
|
575
|
+
// so outlookServer is guaranteed unset here — no need for a guard.
|
|
576
|
+
try {
|
|
577
|
+
this.outlookServer = await this.outlookServerFactory();
|
|
578
|
+
}
|
|
579
|
+
catch (error) {
|
|
580
|
+
(0, runtime_1.emitNervesEvent)({
|
|
581
|
+
level: "warn",
|
|
582
|
+
component: "daemon",
|
|
583
|
+
event: "daemon.outlook_start_failed",
|
|
584
|
+
message: `Outlook server failed to start: ${String(error)}`,
|
|
585
|
+
meta: { port: outlook_types_1.OUTLOOK_DEFAULT_PORT },
|
|
586
|
+
});
|
|
587
|
+
}
|
|
159
588
|
if (fs.existsSync(this.socketPath)) {
|
|
160
589
|
fs.unlinkSync(this.socketPath);
|
|
161
590
|
}
|
|
162
|
-
|
|
591
|
+
// allowHalfOpen: true lets the server keep its writable side open after
|
|
592
|
+
// the client sends FIN. Without this, when a client calls `client.end()`
|
|
593
|
+
// after writing a command, node closes the server's writable side
|
|
594
|
+
// automatically — so a long-running response (like an agent.senseTurn
|
|
595
|
+
// LLM turn that takes 5+ seconds) never reaches the client. The
|
|
596
|
+
// socket-client fix in #303/#334 also removed client.end() on the
|
|
597
|
+
// sending side, but this option is defense in depth: even if a future
|
|
598
|
+
// caller half-closes, the server still writes its response correctly.
|
|
599
|
+
this.server = net.createServer({ allowHalfOpen: true }, (connection) => {
|
|
163
600
|
let raw = "";
|
|
164
601
|
let responded = false;
|
|
602
|
+
/* v8 ignore start — connection error handler requires real socket error @preserve */
|
|
603
|
+
connection.on("error", (err) => {
|
|
604
|
+
(0, runtime_1.emitNervesEvent)({
|
|
605
|
+
level: "warn",
|
|
606
|
+
component: "daemon",
|
|
607
|
+
event: "daemon.connection_error",
|
|
608
|
+
message: "socket connection error",
|
|
609
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
/* v8 ignore stop */
|
|
165
613
|
const flushResponse = async () => {
|
|
166
614
|
if (responded)
|
|
167
615
|
return;
|
|
168
616
|
responded = true;
|
|
169
617
|
const response = await this.handleRawPayload(raw);
|
|
170
|
-
|
|
618
|
+
try {
|
|
619
|
+
connection.end(response);
|
|
620
|
+
/* v8 ignore start — EPIPE catch requires real socket disconnect @preserve */
|
|
621
|
+
}
|
|
622
|
+
catch (err) {
|
|
623
|
+
(0, runtime_1.emitNervesEvent)({
|
|
624
|
+
level: "warn",
|
|
625
|
+
component: "daemon",
|
|
626
|
+
event: "daemon.connection_end_error",
|
|
627
|
+
message: "failed to send response to client (EPIPE)",
|
|
628
|
+
meta: { error: err instanceof Error ? err.message : String(err) },
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
/* v8 ignore stop */
|
|
171
632
|
};
|
|
172
633
|
connection.on("data", (chunk) => {
|
|
173
634
|
raw += chunk.toString("utf-8");
|
|
@@ -180,7 +641,23 @@ class OuroDaemon {
|
|
|
180
641
|
const server = this.server;
|
|
181
642
|
await new Promise((resolve, reject) => {
|
|
182
643
|
server.once("error", reject);
|
|
183
|
-
server.listen(this.socketPath, () =>
|
|
644
|
+
server.listen(this.socketPath, () => {
|
|
645
|
+
// Replace the one-time error listener with a persistent one after successful listen
|
|
646
|
+
server.removeAllListeners("error");
|
|
647
|
+
this.socketIdentity = readSocketIdentity(this.socketPath);
|
|
648
|
+
/* v8 ignore start — server error after listen requires real socket race condition @preserve */
|
|
649
|
+
server.on("error", (err) => {
|
|
650
|
+
(0, runtime_1.emitNervesEvent)({
|
|
651
|
+
level: "error",
|
|
652
|
+
component: "daemon",
|
|
653
|
+
event: "daemon.server_error",
|
|
654
|
+
message: "daemon server error after listen",
|
|
655
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
/* v8 ignore stop */
|
|
659
|
+
resolve();
|
|
660
|
+
});
|
|
184
661
|
});
|
|
185
662
|
}
|
|
186
663
|
async drainPendingBundleMessages() {
|
|
@@ -231,26 +708,170 @@ class OuroDaemon {
|
|
|
231
708
|
fs.writeFileSync(pendingPath, next, "utf-8");
|
|
232
709
|
}
|
|
233
710
|
}
|
|
711
|
+
/** Drains per-sense pending dirs for always-on senses across all agents. */
|
|
712
|
+
static ALWAYS_ON_SENSES = new Set((0, channel_1.getAlwaysOnSenseNames)());
|
|
713
|
+
async drainPendingSenseMessages() {
|
|
714
|
+
if (!fs.existsSync(this.bundlesRoot))
|
|
715
|
+
return;
|
|
716
|
+
let bundleDirs;
|
|
717
|
+
try {
|
|
718
|
+
bundleDirs = fs.readdirSync(this.bundlesRoot, { withFileTypes: true });
|
|
719
|
+
}
|
|
720
|
+
catch {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
for (const bundleDir of bundleDirs) {
|
|
724
|
+
if (!bundleDir.isDirectory() || !bundleDir.name.endsWith(".ouro"))
|
|
725
|
+
continue;
|
|
726
|
+
const agentName = bundleDir.name.replace(/\.ouro$/, "");
|
|
727
|
+
const pendingRoot = path.join(this.bundlesRoot, bundleDir.name, "state", "pending");
|
|
728
|
+
if (!fs.existsSync(pendingRoot))
|
|
729
|
+
continue;
|
|
730
|
+
let friendDirs;
|
|
731
|
+
try {
|
|
732
|
+
friendDirs = fs.readdirSync(pendingRoot, { withFileTypes: true });
|
|
733
|
+
}
|
|
734
|
+
catch {
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
for (const friendDir of friendDirs) {
|
|
738
|
+
if (!friendDir.isDirectory())
|
|
739
|
+
continue;
|
|
740
|
+
const friendPath = path.join(pendingRoot, friendDir.name);
|
|
741
|
+
let channelDirs;
|
|
742
|
+
try {
|
|
743
|
+
channelDirs = fs.readdirSync(friendPath, { withFileTypes: true });
|
|
744
|
+
}
|
|
745
|
+
catch {
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
for (const channelDir of channelDirs) {
|
|
749
|
+
if (!channelDir.isDirectory())
|
|
750
|
+
continue;
|
|
751
|
+
if (!OuroDaemon.ALWAYS_ON_SENSES.has(channelDir.name))
|
|
752
|
+
continue;
|
|
753
|
+
const channelPath = path.join(friendPath, channelDir.name);
|
|
754
|
+
let keyDirs;
|
|
755
|
+
try {
|
|
756
|
+
keyDirs = fs.readdirSync(channelPath, { withFileTypes: true });
|
|
757
|
+
}
|
|
758
|
+
catch {
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
for (const keyDir of keyDirs) {
|
|
762
|
+
if (!keyDir.isDirectory())
|
|
763
|
+
continue;
|
|
764
|
+
const leafDir = path.join(channelPath, keyDir.name);
|
|
765
|
+
const messages = (0, pending_1.drainPending)(leafDir);
|
|
766
|
+
for (const msg of messages) {
|
|
767
|
+
try {
|
|
768
|
+
await this.router.send({
|
|
769
|
+
from: msg.from,
|
|
770
|
+
to: agentName,
|
|
771
|
+
content: msg.content,
|
|
772
|
+
priority: "normal",
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
catch {
|
|
776
|
+
// Best-effort delivery — log and continue
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
if (messages.length > 0) {
|
|
780
|
+
(0, runtime_1.emitNervesEvent)({
|
|
781
|
+
component: "daemon",
|
|
782
|
+
event: "daemon.startup_sense_drain",
|
|
783
|
+
message: "drained pending sense messages on startup",
|
|
784
|
+
meta: {
|
|
785
|
+
agent: agentName,
|
|
786
|
+
channel: channelDir.name,
|
|
787
|
+
friendId: friendDir.name,
|
|
788
|
+
key: keyDir.name,
|
|
789
|
+
count: messages.length,
|
|
790
|
+
},
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
234
798
|
async stop() {
|
|
799
|
+
// Must be named `_end` (not `_stop`) to satisfy the nerves audit's
|
|
800
|
+
// start/end pairing rule — see src/nerves/coverage/audit-rules.ts.
|
|
801
|
+
// This is the counterpart to `daemon.server_start` emitted at line 480.
|
|
235
802
|
(0, runtime_1.emitNervesEvent)({
|
|
236
803
|
component: "daemon",
|
|
237
|
-
event: "daemon.
|
|
804
|
+
event: "daemon.server_end",
|
|
238
805
|
message: "stopping daemon server",
|
|
239
806
|
meta: { socketPath: this.socketPath },
|
|
240
807
|
});
|
|
241
808
|
(0, update_checker_1.stopUpdateChecker)();
|
|
809
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
242
810
|
this.scheduler.stop?.();
|
|
243
811
|
await this.processManager.stopAll();
|
|
244
812
|
await this.senseManager?.stopAll();
|
|
245
813
|
if (this.server) {
|
|
246
|
-
await
|
|
247
|
-
|
|
248
|
-
|
|
814
|
+
// DO NOT `await` server.close() here. server.close() resolves only
|
|
815
|
+
// after every open connection has closed. When stop() is invoked
|
|
816
|
+
// from the daemon.stop command handler, the calling client's
|
|
817
|
+
// connection is STILL open — its flushResponse() is currently
|
|
818
|
+
// awaiting THIS function. Awaiting close() creates a deadlock:
|
|
819
|
+
//
|
|
820
|
+
// client → flushResponse → handleRawPayload → daemon.stop case
|
|
821
|
+
// → stop() → await server.close() (waits for client's connection)
|
|
822
|
+
// → client's connection waits for flushResponse to call
|
|
823
|
+
// connection.end() → DEADLOCK
|
|
824
|
+
//
|
|
825
|
+
// Both processes sit in kevent forever. Verified live on
|
|
826
|
+
// 2026-04-08: alpha.268 daemon hung at `daemon.server_end` log
|
|
827
|
+
// line for 5+ minutes after a client sent daemon.stop, while the
|
|
828
|
+
// client (alpha.270 ouro up) hung waiting for the response.
|
|
829
|
+
//
|
|
830
|
+
// This regressed when #303/#334/#339 stopped half-closing the
|
|
831
|
+
// client socket and switched the server to allowHalfOpen: true.
|
|
832
|
+
// Previously, the client called .end() after writing its command,
|
|
833
|
+
// which (with allowHalfOpen: false) caused node to auto-tear-down
|
|
834
|
+
// the server's writable side — incidentally unblocking
|
|
835
|
+
// server.close() before the response was sent. The half-close
|
|
836
|
+
// breakage masked this deadlock; the fix exposed it.
|
|
837
|
+
//
|
|
838
|
+
// Solution: fire close() and let it complete asynchronously. Once
|
|
839
|
+
// stop() returns, the daemon.stop case returns its response,
|
|
840
|
+
// flushResponse() calls connection.end(response), the connection
|
|
841
|
+
// closes, and server.close()'s pending callback fires. The event
|
|
842
|
+
// loop drains and the daemon exits cleanly.
|
|
843
|
+
this.server.close();
|
|
249
844
|
this.server = null;
|
|
250
845
|
}
|
|
251
|
-
if (
|
|
846
|
+
if (this.outlookServer) {
|
|
847
|
+
await this.outlookServer.stop();
|
|
848
|
+
this.outlookServer = null;
|
|
849
|
+
}
|
|
850
|
+
const socketPathExists = fs.existsSync(this.socketPath);
|
|
851
|
+
const currentSocketIdentity = socketPathExists ? readSocketIdentity(this.socketPath) : null;
|
|
852
|
+
if (sameSocketIdentity(this.socketIdentity, currentSocketIdentity)) {
|
|
252
853
|
fs.unlinkSync(this.socketPath);
|
|
253
854
|
}
|
|
855
|
+
else if (socketPathExists) {
|
|
856
|
+
const expectedSocketIdentity = { dev: null, ino: null, ctimeMs: null, ...this.socketIdentity };
|
|
857
|
+
const actualSocketIdentity = { dev: null, ino: null, ctimeMs: null, ...currentSocketIdentity };
|
|
858
|
+
(0, runtime_1.emitNervesEvent)({
|
|
859
|
+
level: "warn",
|
|
860
|
+
component: "daemon",
|
|
861
|
+
event: "daemon.socket_cleanup_skipped",
|
|
862
|
+
message: "skipped daemon socket cleanup because the socket path no longer belongs to this daemon",
|
|
863
|
+
meta: {
|
|
864
|
+
socketPath: this.socketPath,
|
|
865
|
+
expectedDev: expectedSocketIdentity.dev,
|
|
866
|
+
expectedIno: expectedSocketIdentity.ino,
|
|
867
|
+
expectedCtimeMs: expectedSocketIdentity.ctimeMs,
|
|
868
|
+
actualDev: actualSocketIdentity.dev,
|
|
869
|
+
actualIno: actualSocketIdentity.ino,
|
|
870
|
+
actualCtimeMs: actualSocketIdentity.ctimeMs,
|
|
871
|
+
},
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
this.socketIdentity = null;
|
|
254
875
|
}
|
|
255
876
|
async handleRawPayload(raw) {
|
|
256
877
|
try {
|
|
@@ -272,6 +893,27 @@ class OuroDaemon {
|
|
|
272
893
|
message: "handling daemon command",
|
|
273
894
|
meta: { kind: command.kind },
|
|
274
895
|
});
|
|
896
|
+
try {
|
|
897
|
+
return await this.handleCommandInner(command);
|
|
898
|
+
/* v8 ignore start — command error catch tested in daemon-command-error.test; instanceof branches defensive @preserve */
|
|
899
|
+
}
|
|
900
|
+
catch (error) {
|
|
901
|
+
(0, runtime_1.emitNervesEvent)({
|
|
902
|
+
level: "error",
|
|
903
|
+
component: "daemon",
|
|
904
|
+
event: "daemon.command_error",
|
|
905
|
+
message: "unexpected error handling daemon command",
|
|
906
|
+
meta: {
|
|
907
|
+
kind: command.kind,
|
|
908
|
+
error: error instanceof Error ? error.message : String(error),
|
|
909
|
+
stack: error instanceof Error ? error.stack ?? null : null,
|
|
910
|
+
},
|
|
911
|
+
});
|
|
912
|
+
throw error;
|
|
913
|
+
}
|
|
914
|
+
/* v8 ignore stop */
|
|
915
|
+
}
|
|
916
|
+
async handleCommandInner(command) {
|
|
275
917
|
switch (command.kind) {
|
|
276
918
|
case "daemon.start":
|
|
277
919
|
await this.start();
|
|
@@ -280,21 +922,7 @@ class OuroDaemon {
|
|
|
280
922
|
await this.stop();
|
|
281
923
|
return { ok: true, message: "daemon stopped" };
|
|
282
924
|
case "daemon.status": {
|
|
283
|
-
const
|
|
284
|
-
const workers = buildWorkerRows(snapshots);
|
|
285
|
-
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
286
|
-
const data = {
|
|
287
|
-
overview: {
|
|
288
|
-
daemon: "running",
|
|
289
|
-
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
290
|
-
socketPath: this.socketPath,
|
|
291
|
-
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
292
|
-
workerCount: workers.length,
|
|
293
|
-
senseCount: senses.length,
|
|
294
|
-
},
|
|
295
|
-
workers,
|
|
296
|
-
senses,
|
|
297
|
-
};
|
|
925
|
+
const data = this.buildStatusPayload();
|
|
298
926
|
return {
|
|
299
927
|
ok: true,
|
|
300
928
|
summary: formatStatusSummary(data),
|
|
@@ -311,7 +939,7 @@ class OuroDaemon {
|
|
|
311
939
|
ok: true,
|
|
312
940
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
313
941
|
message: "log streaming available via ouro logs",
|
|
314
|
-
data: { logDir: "
|
|
942
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
315
943
|
};
|
|
316
944
|
case "agent.start":
|
|
317
945
|
await this.processManager.startAgent(command.agent);
|
|
@@ -322,6 +950,35 @@ class OuroDaemon {
|
|
|
322
950
|
case "agent.restart":
|
|
323
951
|
await this.processManager.restartAgent?.(command.agent);
|
|
324
952
|
return { ok: true, message: `restarted ${command.agent}` };
|
|
953
|
+
case "agent.ask":
|
|
954
|
+
return (0, agent_service_1.handleAgentAsk)(command);
|
|
955
|
+
case "agent.status":
|
|
956
|
+
return (0, agent_service_1.handleAgentStatus)(command);
|
|
957
|
+
case "agent.catchup":
|
|
958
|
+
return (0, agent_service_1.handleAgentCatchup)(command);
|
|
959
|
+
case "agent.delegate":
|
|
960
|
+
return (0, agent_service_1.handleAgentDelegate)(command);
|
|
961
|
+
case "agent.getContext":
|
|
962
|
+
return (0, agent_service_1.handleAgentGetContext)(command);
|
|
963
|
+
case "agent.searchNotes":
|
|
964
|
+
return (0, agent_service_1.handleAgentSearchNotes)(command);
|
|
965
|
+
case "agent.getTask":
|
|
966
|
+
return (0, agent_service_1.handleAgentGetTask)(command);
|
|
967
|
+
case "agent.checkScope":
|
|
968
|
+
return (0, agent_service_1.handleAgentCheckScope)(command);
|
|
969
|
+
case "agent.requestDecision":
|
|
970
|
+
return (0, agent_service_1.handleAgentRequestDecision)(command);
|
|
971
|
+
case "agent.checkGuidance":
|
|
972
|
+
return (0, agent_service_1.handleAgentCheckGuidance)(command);
|
|
973
|
+
case "agent.reportProgress":
|
|
974
|
+
return (0, agent_service_1.handleAgentReportProgress)(command);
|
|
975
|
+
case "agent.reportBlocker":
|
|
976
|
+
return (0, agent_service_1.handleAgentReportBlocker)(command);
|
|
977
|
+
case "agent.reportComplete":
|
|
978
|
+
return (0, agent_service_1.handleAgentReportComplete)(command);
|
|
979
|
+
case "agent.senseTurn":
|
|
980
|
+
return handleAgentSenseTurn(command);
|
|
981
|
+
/* v8 ignore stop */
|
|
325
982
|
case "cron.list": {
|
|
326
983
|
const jobs = this.scheduler.listJobs();
|
|
327
984
|
const summary = jobs.length === 0
|
|
@@ -353,6 +1010,13 @@ class OuroDaemon {
|
|
|
353
1010
|
data: messages,
|
|
354
1011
|
};
|
|
355
1012
|
}
|
|
1013
|
+
case "inner.wake":
|
|
1014
|
+
await this.processManager.startAgent(command.agent);
|
|
1015
|
+
this.processManager.sendToAgent?.(command.agent, { type: "message" });
|
|
1016
|
+
return {
|
|
1017
|
+
ok: true,
|
|
1018
|
+
message: `woke inner dialog for ${command.agent}`,
|
|
1019
|
+
};
|
|
356
1020
|
case "chat.connect":
|
|
357
1021
|
await this.processManager.startAgent(command.agent);
|
|
358
1022
|
return {
|
|
@@ -375,6 +1039,35 @@ class OuroDaemon {
|
|
|
375
1039
|
data: receipt,
|
|
376
1040
|
};
|
|
377
1041
|
}
|
|
1042
|
+
case "habit.poke": {
|
|
1043
|
+
this.processManager.sendToAgent?.(command.agent, { type: "habit", habitName: command.habitName });
|
|
1044
|
+
return {
|
|
1045
|
+
ok: true,
|
|
1046
|
+
message: `poked habit ${command.habitName} for ${command.agent}`,
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
case "mcp.list": {
|
|
1050
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
1051
|
+
if (!mcpManager) {
|
|
1052
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
1053
|
+
}
|
|
1054
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
1055
|
+
}
|
|
1056
|
+
case "mcp.call": {
|
|
1057
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
1058
|
+
if (!mcpCallManager) {
|
|
1059
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
1060
|
+
}
|
|
1061
|
+
try {
|
|
1062
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
1063
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
1064
|
+
return { ok: true, data: result };
|
|
1065
|
+
}
|
|
1066
|
+
catch (error) {
|
|
1067
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
1068
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
378
1071
|
case "hatch.start":
|
|
379
1072
|
return {
|
|
380
1073
|
ok: true,
|