@ouro.bot/cli 0.1.0-alpha.51 → 0.1.0-alpha.511
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 +133 -19
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +2 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
- package/changelog.json +3253 -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 +867 -35
- package/dist/heart/agent-entry.js +58 -3
- 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 +426 -0
- package/dist/heart/background-operations.js +281 -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 +119 -129
- package/dist/heart/core.js +878 -244
- package/dist/heart/cross-chat-delivery.js +131 -0
- package/dist/heart/daemon/agent-config-check.js +490 -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 +216 -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 +640 -0
- package/dist/heart/daemon/cli-exec.js +7241 -0
- package/dist/heart/daemon/cli-help.js +493 -0
- package/dist/heart/daemon/cli-parse.js +1536 -0
- package/dist/heart/daemon/cli-render-doctor.js +57 -0
- package/dist/heart/daemon/cli-render.js +561 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/connect-bay.js +323 -0
- package/dist/heart/daemon/daemon-cli.js +29 -1631
- package/dist/heart/daemon/daemon-entry.js +345 -3
- package/dist/heart/daemon/daemon-health.js +141 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +190 -12
- package/dist/heart/daemon/daemon-tombstone.js +236 -0
- package/dist/heart/daemon/daemon.js +677 -58
- package/dist/heart/daemon/dns-workflow.js +394 -0
- package/dist/heart/daemon/doctor-types.js +8 -0
- package/dist/heart/daemon/doctor.js +750 -0
- package/dist/heart/daemon/health-monitor.js +92 -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/human-command-screens.js +234 -0
- package/dist/heart/daemon/human-readiness.js +114 -0
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/interactive-repair.js +394 -0
- package/dist/heart/daemon/launchd.js +25 -5
- package/dist/heart/daemon/log-tailer.js +82 -12
- package/dist/heart/daemon/logs-prune.js +110 -0
- package/dist/heart/daemon/message-router.js +2 -2
- package/dist/heart/daemon/os-cron-deps.js +134 -0
- package/dist/heart/daemon/ouro-bot-entry.js +4 -2
- package/dist/heart/daemon/ouro-entry.js +3 -1
- package/dist/heart/daemon/process-manager.js +214 -0
- package/dist/heart/daemon/provider-discovery.js +137 -0
- package/dist/heart/daemon/provider-ping-progress.js +83 -0
- package/dist/heart/daemon/pulse.js +475 -0
- package/dist/heart/daemon/readiness-repair.js +365 -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 +73 -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 +178 -37
- 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 +109 -4
- package/dist/heart/daemon/stale-bundle-prune.js +96 -0
- package/dist/heart/daemon/startup-tui.js +264 -0
- package/dist/heart/daemon/task-scheduler.js +3 -25
- package/dist/heart/daemon/terminal-ui.js +499 -0
- package/dist/heart/daemon/thoughts.js +162 -17
- package/dist/heart/daemon/up-progress.js +366 -0
- package/dist/heart/daemon/vault-items.js +56 -0
- package/dist/heart/delegation.js +1 -1
- package/dist/heart/habits/habit-migration.js +189 -0
- package/dist/heart/habits/habit-parser.js +140 -0
- package/dist/heart/habits/habit-runtime-state.js +100 -0
- package/dist/heart/habits/habit-scheduler.js +372 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +52 -117
- package/dist/heart/{daemon → hatch}/hatch-specialist.js +3 -3
- package/dist/heart/{daemon → hatch}/specialist-prompt.js +12 -9
- package/dist/heart/{daemon → hatch}/specialist-tools.js +35 -12
- package/dist/heart/identity.js +205 -66
- package/dist/heart/kept-notes.js +357 -0
- package/dist/heart/kicks.js +1 -1
- package/dist/heart/machine-identity.js +161 -0
- package/dist/heart/mail-import-discovery.js +353 -0
- package/dist/heart/mcp/mcp-server.js +653 -0
- package/dist/heart/migrate-config.js +100 -0
- package/dist/heart/model-capabilities.js +19 -0
- package/dist/heart/outlook/outlook-http-hooks.js +66 -0
- package/dist/heart/outlook/outlook-http-response.js +7 -0
- package/dist/heart/outlook/outlook-http-routes.js +244 -0
- package/dist/heart/outlook/outlook-http-static.js +103 -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 +31 -0
- package/dist/heart/outlook/outlook-types.js +27 -0
- package/dist/heart/outlook/outlook-view.js +195 -0
- package/dist/heart/outlook/readers/agent-machine.js +382 -0
- package/dist/heart/outlook/readers/continuity-readers.js +336 -0
- package/dist/heart/outlook/readers/mail.js +362 -0
- package/dist/heart/outlook/readers/runtime-readers.js +644 -0
- package/dist/heart/outlook/readers/sessions.js +232 -0
- package/dist/heart/outlook/readers/shared.js +111 -0
- package/dist/heart/platform.js +81 -0
- package/dist/heart/provider-attempt.js +134 -0
- package/dist/heart/provider-binding-resolver.js +255 -0
- package/dist/heart/provider-credentials.js +424 -0
- package/dist/heart/provider-failover.js +301 -0
- package/dist/heart/provider-models.js +81 -0
- package/dist/heart/provider-ping.js +262 -0
- package/dist/heart/provider-state.js +216 -0
- package/dist/heart/provider-visibility.js +188 -0
- package/dist/heart/providers/anthropic-token.js +131 -0
- package/dist/heart/providers/anthropic.js +139 -52
- package/dist/heart/providers/azure.js +97 -13
- package/dist/heart/providers/error-classification.js +127 -0
- package/dist/heart/providers/github-copilot.js +145 -0
- package/dist/heart/providers/minimax-vlm.js +189 -0
- package/dist/heart/providers/minimax.js +26 -8
- package/dist/heart/providers/openai-codex.js +55 -40
- package/dist/heart/runtime-capability-check.js +170 -0
- package/dist/heart/runtime-credentials.js +260 -0
- package/dist/heart/sense-truth.js +11 -4
- package/dist/heart/session-activity.js +43 -22
- package/dist/heart/session-events.js +1150 -0
- package/dist/heart/session-playback-cli-main.js +5 -0
- package/dist/heart/session-playback-cli.js +36 -0
- package/dist/heart/session-playback.js +231 -0
- package/dist/heart/session-stats-cli-main.js +5 -0
- package/dist/heart/session-stats.js +182 -0
- package/dist/heart/session-transcript.js +167 -0
- package/dist/heart/start-of-turn-packet.js +345 -0
- package/dist/heart/streaming.js +44 -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 +372 -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 +425 -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 +5 -1
- package/dist/heart/{daemon → versioning}/update-hooks.js +63 -59
- package/dist/mailroom/attention.js +167 -0
- package/dist/mailroom/autonomy.js +209 -0
- package/dist/mailroom/blob-store.js +606 -0
- package/dist/mailroom/body-cache.js +61 -0
- package/dist/mailroom/core.js +672 -0
- package/dist/mailroom/entry.js +160 -0
- package/dist/mailroom/file-store.js +426 -0
- package/dist/mailroom/mbox-import.js +382 -0
- package/dist/mailroom/outbound.js +380 -0
- package/dist/mailroom/policy.js +263 -0
- package/dist/mailroom/reader.js +219 -0
- package/dist/mailroom/search-cache.js +182 -0
- package/dist/mailroom/search-relevance.js +319 -0
- package/dist/mailroom/smtp-ingress.js +176 -0
- package/dist/mailroom/source-state.js +176 -0
- package/dist/mailroom/thread.js +109 -0
- package/dist/mailroom/travel-extract.js +89 -0
- package/dist/mind/bundle-manifest.js +7 -1
- package/dist/mind/context.js +165 -101
- package/dist/mind/diary-integrity.js +60 -0
- package/dist/mind/{memory.js → diary.js} +74 -93
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/friends/channel.js +30 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/resolver.js +54 -2
- package/dist/mind/friends/store-file.js +39 -3
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +2 -2
- 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 +4 -0
- package/dist/mind/prompt-refresh.js +3 -2
- package/dist/mind/prompt.js +940 -111
- package/dist/mind/provenance-trust.js +26 -0
- package/dist/mind/scrutiny.js +173 -0
- 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/contract.js +5 -5
- package/dist/nerves/coverage/file-completeness.js +114 -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/review/cli-main.js +5 -0
- package/dist/nerves/review/cli.js +156 -0
- package/dist/nerves/review/core.js +152 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/outlook-ui/assets/index-BPr5vNuM.css +1 -0
- package/dist/outlook-ui/assets/index-Cm51CY9W.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 +774 -0
- package/dist/repertoire/bundle-templates.js +72 -0
- package/dist/repertoire/bw-installer.js +180 -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 +111 -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 +396 -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 +31 -5
- package/dist/repertoire/tasks/fix.js +182 -0
- package/dist/repertoire/tasks/index.js +16 -4
- 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 -78
- package/dist/repertoire/tool-results.js +29 -0
- package/dist/repertoire/tools-attachments.js +317 -0
- package/dist/repertoire/tools-base.js +46 -955
- 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 +381 -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-mail.js +1477 -0
- package/dist/repertoire/tools-notes.js +376 -0
- package/dist/repertoire/tools-session.js +749 -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 +9 -39
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools-trip.js +422 -0
- package/dist/repertoire/tools-user-profile.js +144 -0
- package/dist/repertoire/tools-vault.js +40 -0
- package/dist/repertoire/tools.js +107 -100
- package/dist/repertoire/travel-api-client.js +360 -0
- package/dist/repertoire/user-profile.js +131 -0
- package/dist/repertoire/vault-setup.js +246 -0
- package/dist/repertoire/vault-unlock.js +561 -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} +219 -18
- package/dist/senses/bluebubbles/entry.js +73 -0
- package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +20 -3
- package/dist/senses/bluebubbles/index.js +1881 -0
- package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -70
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +33 -12
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +3 -3
- package/dist/senses/bluebubbles/processed-log.js +111 -0
- package/dist/senses/bluebubbles/replay.js +129 -0
- package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +2 -2
- 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 +60 -8
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +511 -209
- package/dist/senses/commands.js +66 -3
- package/dist/senses/habit-turn-message.js +108 -0
- package/dist/senses/inner-dialog-worker.js +175 -21
- package/dist/senses/inner-dialog.js +330 -27
- package/dist/senses/mail-entry.js +66 -0
- package/dist/senses/mail.js +379 -0
- package/dist/senses/pipeline.js +573 -164
- package/dist/senses/proactive-content-guard.js +51 -0
- package/dist/senses/shared-turn.js +248 -0
- package/dist/senses/surface-tool.js +68 -0
- package/dist/senses/teams-entry.js +60 -8
- package/dist/senses/teams.js +405 -170
- package/dist/senses/trust-gate.js +100 -5
- package/dist/trips/core.js +138 -0
- package/dist/trips/store.js +146 -0
- package/package.json +37 -7
- package/skills/agent-commerce.md +106 -0
- package/skills/browser-navigation.md +117 -0
- package/skills/commerce-setup-guide.md +116 -0
- package/skills/commerce-setup.md +84 -0
- package/skills/configure-dev-tools.md +101 -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 -166
- package/dist/heart/session-recall.js +0 -116
- package/dist/mind/associative-recall.js +0 -209
- package/dist/senses/bluebubbles-entry.js +0 -13
- package/dist/senses/bluebubbles.js +0 -1142
- package/dist/senses/debug-activity.js +0 -148
- package/subagents/README.md +0 -86
- package/subagents/work-doer.md +0 -237
- package/subagents/work-merger.md +0 -618
- package/subagents/work-planner.md +0 -390
- /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,20 +34,279 @@ 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.mergeUniqueOrphanPids = mergeUniqueOrphanPids;
|
|
40
|
+
exports.killOrphanProcesses = killOrphanProcesses;
|
|
41
|
+
exports.writePidfile = writePidfile;
|
|
42
|
+
exports.handleAgentSenseTurn = handleAgentSenseTurn;
|
|
37
43
|
const fs = __importStar(require("fs"));
|
|
38
44
|
const net = __importStar(require("net"));
|
|
45
|
+
const os = __importStar(require("os"));
|
|
39
46
|
const path = __importStar(require("path"));
|
|
40
47
|
const identity_1 = require("../identity");
|
|
48
|
+
const agent_discovery_1 = require("./agent-discovery");
|
|
41
49
|
const runtime_1 = require("../../nerves/runtime");
|
|
42
50
|
const runtime_metadata_1 = require("./runtime-metadata");
|
|
43
|
-
const
|
|
51
|
+
const runtime_mode_1 = require("./runtime-mode");
|
|
52
|
+
const update_hooks_1 = require("../versioning/update-hooks");
|
|
44
53
|
const bundle_meta_1 = require("./hooks/bundle-meta");
|
|
54
|
+
const agent_config_v2_1 = require("./hooks/agent-config-v2");
|
|
45
55
|
const bundle_manifest_1 = require("../../mind/bundle-manifest");
|
|
46
|
-
const update_checker_1 = require("
|
|
47
|
-
const staged_restart_1 = require("
|
|
56
|
+
const update_checker_1 = require("../versioning/update-checker");
|
|
57
|
+
const staged_restart_1 = require("../versioning/staged-restart");
|
|
58
|
+
const ouro_version_manager_1 = require("../versioning/ouro-version-manager");
|
|
48
59
|
const child_process_1 = require("child_process");
|
|
49
60
|
const pending_1 = require("../../mind/pending");
|
|
61
|
+
const agent_service_1 = require("./agent-service");
|
|
50
62
|
const channel_1 = require("../../mind/friends/channel");
|
|
63
|
+
const mcp_manager_1 = require("../../repertoire/mcp-manager");
|
|
64
|
+
const outlook_http_1 = require("../outlook/outlook-http");
|
|
65
|
+
const outlook_types_1 = require("../outlook/outlook-types");
|
|
66
|
+
const outlook_read_1 = require("../outlook/outlook-read");
|
|
67
|
+
const outlook_view_1 = require("../outlook/outlook-view");
|
|
68
|
+
const provider_visibility_1 = require("../provider-visibility");
|
|
69
|
+
const PIDFILE_PATH = path.join(os.homedir(), ".ouro-cli", "daemon.pids");
|
|
70
|
+
/**
|
|
71
|
+
* Defense-in-depth: detect if we're running under vitest. The pidfile lives
|
|
72
|
+
* at a hardcoded path under the user's real ~/.ouro-cli/ — there's no DI
|
|
73
|
+
* seam to redirect it. So when a test creates a real OuroDaemon and calls
|
|
74
|
+
* start(), the daemon's killOrphanProcesses() reads the REAL pidfile,
|
|
75
|
+
* ps-verifies the PIDs, and SIGTERMs the production daemon. We saw this
|
|
76
|
+
* cause an outage on 2026-04-08 (alpha.265 daemon killed 93s after startup
|
|
77
|
+
* by a vitest test that called daemon.start()).
|
|
78
|
+
*
|
|
79
|
+
* Both killOrphanProcesses() and writePidfile() short-circuit under vitest
|
|
80
|
+
* to make the production pidfile sacred. Tests that need to verify these
|
|
81
|
+
* functions' behavior should use the extracted pure helpers
|
|
82
|
+
* (parseOrphanPidsFromPs, filterPidfilePidsToActualOrphans).
|
|
83
|
+
*/
|
|
84
|
+
function isVitestProcess() {
|
|
85
|
+
/* v8 ignore next -- defensive: process and process.argv always exist in node @preserve */
|
|
86
|
+
if (typeof process === "undefined" || !Array.isArray(process.argv))
|
|
87
|
+
return false;
|
|
88
|
+
return process.argv.some((arg) => typeof arg === "string" && arg.includes("vitest"));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Scan `ps -eo pid,ppid,command` output for daemon-owned entry points whose
|
|
92
|
+
* parent has died (PPID reparented to init/PID 1). Returns the list of PIDs
|
|
93
|
+
* that are safe to SIGTERM — true orphans, not children of live sibling
|
|
94
|
+
* daemons running from worktrees, test suites, or other users of the harness.
|
|
95
|
+
*
|
|
96
|
+
* Exported so unit tests can exercise the filter without shelling out.
|
|
97
|
+
*/
|
|
98
|
+
function parseOrphanPidsFromPs(psOutput, selfPid) {
|
|
99
|
+
const orphans = [];
|
|
100
|
+
for (const line of psOutput.split("\n")) {
|
|
101
|
+
// Explicitly exclude MCP server processes — they share a harness entry
|
|
102
|
+
// point but are not daemon children and must never be killed.
|
|
103
|
+
if (line.includes("mcp-serve") || line.includes("mcp serve"))
|
|
104
|
+
continue;
|
|
105
|
+
// Match only daemon-owned JS entry points.
|
|
106
|
+
if (!line.includes("agent-entry.js")
|
|
107
|
+
&& !line.includes("daemon-entry.js")
|
|
108
|
+
&& !line.includes("bluebubbles/entry.js")
|
|
109
|
+
&& !line.includes("teams-entry.js"))
|
|
110
|
+
continue;
|
|
111
|
+
// Parse `<pid> <ppid> <command...>`. ps pads these with leading spaces.
|
|
112
|
+
// Regex guarantees both groups are \d+ so parseInt can't produce NaN.
|
|
113
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)\s/);
|
|
114
|
+
if (!match)
|
|
115
|
+
continue;
|
|
116
|
+
const pid = parseInt(match[1], 10);
|
|
117
|
+
const ppid = parseInt(match[2], 10);
|
|
118
|
+
if (pid === selfPid)
|
|
119
|
+
continue;
|
|
120
|
+
// CRITICAL: only kill processes whose parent is init (PID 1). A live
|
|
121
|
+
// PPID means the process belongs to another daemon instance (parallel
|
|
122
|
+
// test run, sibling worktree, another user of /tmp/ouroboros-daemon.sock).
|
|
123
|
+
// Killing those will crash unrelated harnesses — we saw this in B6
|
|
124
|
+
// when a vitest worker's daemon killed slugger's production children.
|
|
125
|
+
if (ppid !== 1)
|
|
126
|
+
continue;
|
|
127
|
+
orphans.push(pid);
|
|
128
|
+
}
|
|
129
|
+
return orphans;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Given a list of PIDs from the pidfile, return only those that are actual
|
|
133
|
+
* orphans (PPID reparented to init/PID 1). Protects against a polluted
|
|
134
|
+
* pidfile killing a PID that the OS has reassigned to an unrelated process.
|
|
135
|
+
*
|
|
136
|
+
* Implementation: shells out to `ps -p <csv> -o pid,ppid` for a batch lookup.
|
|
137
|
+
* Returns the empty list if ps fails — safer to skip cleanup than to
|
|
138
|
+
* wildcard-kill on a bad read.
|
|
139
|
+
*
|
|
140
|
+
* Exported for direct unit coverage.
|
|
141
|
+
*/
|
|
142
|
+
function filterPidfilePidsToActualOrphans(candidatePids, psRunner = runPsCheck) {
|
|
143
|
+
if (candidatePids.length === 0)
|
|
144
|
+
return [];
|
|
145
|
+
const psOutput = psRunner(candidatePids);
|
|
146
|
+
if (psOutput === null)
|
|
147
|
+
return [];
|
|
148
|
+
const survivingOrphans = [];
|
|
149
|
+
// `ps -p x,y,z -o pid,ppid` emits a header line then one row per found PID.
|
|
150
|
+
// PIDs not found (already exited) are silently omitted — which is the
|
|
151
|
+
// correct behavior for us: we only want to kill live orphans.
|
|
152
|
+
for (const line of psOutput.split("\n")) {
|
|
153
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)$/);
|
|
154
|
+
if (!match)
|
|
155
|
+
continue;
|
|
156
|
+
const pid = parseInt(match[1], 10);
|
|
157
|
+
const ppid = parseInt(match[2], 10);
|
|
158
|
+
if (ppid !== 1)
|
|
159
|
+
continue;
|
|
160
|
+
if (!candidatePids.includes(pid))
|
|
161
|
+
continue;
|
|
162
|
+
survivingOrphans.push(pid);
|
|
163
|
+
}
|
|
164
|
+
return survivingOrphans;
|
|
165
|
+
}
|
|
166
|
+
function mergeUniqueOrphanPids(...sources) {
|
|
167
|
+
const merged = [];
|
|
168
|
+
const seen = new Set();
|
|
169
|
+
for (const source of sources) {
|
|
170
|
+
for (const pid of source) {
|
|
171
|
+
if (seen.has(pid))
|
|
172
|
+
continue;
|
|
173
|
+
seen.add(pid);
|
|
174
|
+
merged.push(pid);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return merged;
|
|
178
|
+
}
|
|
179
|
+
/* v8 ignore start -- shells out to ps; covered by filterPidfilePidsToActualOrphans unit tests via injected runner @preserve */
|
|
180
|
+
function runPsCheck(pids) {
|
|
181
|
+
try {
|
|
182
|
+
const csv = pids.join(",");
|
|
183
|
+
return (0, child_process_1.execSync)(`ps -p ${csv} -o pid=,ppid=`, { encoding: "utf-8", timeout: 5000 });
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// ps returns non-zero when none of the requested PIDs exist. Treat as
|
|
187
|
+
// "no survivors" rather than an error.
|
|
188
|
+
return "";
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/* v8 ignore stop */
|
|
192
|
+
/**
|
|
193
|
+
* Kill all ouro processes from the previous daemon instance using the pidfile.
|
|
194
|
+
* On startup, reads PIDs from ~/.ouro-cli/daemon.pids, kills them all, then
|
|
195
|
+
* deletes the file. The new daemon writes its own PIDs after spawning.
|
|
196
|
+
*
|
|
197
|
+
* Safety: pidfile contents are verified before being killed — each PID must
|
|
198
|
+
* be an actual orphan (PPID reparented to init/PID 1) via
|
|
199
|
+
* `filterPidfilePidsToActualOrphans`. Otherwise a polluted pidfile (written
|
|
200
|
+
* by a test, or a crashed daemon whose PIDs have since been reused by the
|
|
201
|
+
* OS) could SIGTERM unrelated processes.
|
|
202
|
+
*
|
|
203
|
+
* Falls back to ps-based scanning scoped to true orphans (PPID=1) if the
|
|
204
|
+
* pidfile doesn't exist (first run, previous daemon crashed before writing,
|
|
205
|
+
* manual cleanup). The scope is narrow on purpose — see parseOrphanPidsFromPs.
|
|
206
|
+
*/
|
|
207
|
+
/* v8 ignore start -- process lifecycle: uses kill/ps, tested via deployment @preserve */
|
|
208
|
+
function killOrphanProcesses() {
|
|
209
|
+
if (isVitestProcess()) {
|
|
210
|
+
(0, runtime_1.emitNervesEvent)({
|
|
211
|
+
level: "warn",
|
|
212
|
+
component: "daemon",
|
|
213
|
+
event: "daemon.orphan_cleanup_test_blocked",
|
|
214
|
+
message: "blocked killOrphanProcesses from touching real pidfile under vitest",
|
|
215
|
+
meta: { pidfilePath: PIDFILE_PATH },
|
|
216
|
+
});
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
let pidfileOrphans = [];
|
|
221
|
+
let scanOrphans = [];
|
|
222
|
+
// Primary: read pidfile from previous daemon
|
|
223
|
+
try {
|
|
224
|
+
const raw = fs.readFileSync(PIDFILE_PATH, "utf-8");
|
|
225
|
+
const candidates = raw.split("\n")
|
|
226
|
+
.map((s) => parseInt(s.trim(), 10))
|
|
227
|
+
.filter((n) => !isNaN(n) && n !== process.pid);
|
|
228
|
+
// Verify each candidate is an actual live orphan before killing. See
|
|
229
|
+
// docstring above for why this matters.
|
|
230
|
+
pidfileOrphans = filterPidfilePidsToActualOrphans(candidates);
|
|
231
|
+
fs.unlinkSync(PIDFILE_PATH);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
// No pidfile — the ps scan below still covers true orphans.
|
|
235
|
+
}
|
|
236
|
+
// Always supplement the pidfile with the scoped ps scan. A stale or
|
|
237
|
+
// partial pidfile can otherwise kill one old daemon while leaving a
|
|
238
|
+
// sibling PPID=1 daemon alive without a socket.
|
|
239
|
+
try {
|
|
240
|
+
const result = (0, child_process_1.execSync)("ps -eo pid,ppid,command", { encoding: "utf-8", timeout: 5000 });
|
|
241
|
+
scanOrphans = parseOrphanPidsFromPs(result, process.pid);
|
|
242
|
+
}
|
|
243
|
+
catch { /* ps failed — best effort */ }
|
|
244
|
+
const pidsToKill = mergeUniqueOrphanPids(pidfileOrphans, scanOrphans);
|
|
245
|
+
if (pidsToKill.length > 0) {
|
|
246
|
+
for (const pid of pidsToKill) {
|
|
247
|
+
try {
|
|
248
|
+
process.kill(pid, "SIGTERM");
|
|
249
|
+
}
|
|
250
|
+
catch { /* already exited */ }
|
|
251
|
+
}
|
|
252
|
+
(0, runtime_1.emitNervesEvent)({
|
|
253
|
+
component: "daemon",
|
|
254
|
+
event: "daemon.orphan_cleanup",
|
|
255
|
+
message: `killed ${pidsToKill.length} orphaned ouro processes`,
|
|
256
|
+
meta: { pids: pidsToKill },
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
(0, runtime_1.emitNervesEvent)({
|
|
262
|
+
level: "warn",
|
|
263
|
+
component: "daemon",
|
|
264
|
+
event: "daemon.orphan_cleanup_error",
|
|
265
|
+
message: "failed to clean up orphaned ouro processes",
|
|
266
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Write all managed PIDs (daemon + children) to the pidfile.
|
|
272
|
+
* Called after all agents and senses are spawned.
|
|
273
|
+
*/
|
|
274
|
+
function writePidfile(extraPids = []) {
|
|
275
|
+
if (isVitestProcess()) {
|
|
276
|
+
(0, runtime_1.emitNervesEvent)({
|
|
277
|
+
level: "warn",
|
|
278
|
+
component: "daemon",
|
|
279
|
+
event: "daemon.write_pidfile_test_blocked",
|
|
280
|
+
message: "blocked writePidfile from clobbering real pidfile under vitest",
|
|
281
|
+
meta: { pidfilePath: PIDFILE_PATH, attemptedPids: extraPids.length },
|
|
282
|
+
});
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
const pids = [process.pid, ...extraPids].filter(Boolean);
|
|
287
|
+
fs.mkdirSync(path.dirname(PIDFILE_PATH), { recursive: true });
|
|
288
|
+
fs.writeFileSync(PIDFILE_PATH, pids.join("\n") + "\n", "utf-8");
|
|
289
|
+
}
|
|
290
|
+
catch { /* best effort */ }
|
|
291
|
+
}
|
|
292
|
+
function readSocketIdentity(socketPath) {
|
|
293
|
+
try {
|
|
294
|
+
const stats = fs.lstatSync(socketPath);
|
|
295
|
+
return {
|
|
296
|
+
dev: stats.dev,
|
|
297
|
+
ino: stats.ino,
|
|
298
|
+
ctimeMs: stats.ctimeMs,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function sameSocketIdentity(left, right) {
|
|
306
|
+
if (!left || !right)
|
|
307
|
+
return false;
|
|
308
|
+
return left.dev === right.dev && left.ino === right.ino && left.ctimeMs === right.ctimeMs;
|
|
309
|
+
}
|
|
51
310
|
function buildWorkerRows(snapshots) {
|
|
52
311
|
return snapshots.map((snapshot) => ({
|
|
53
312
|
agent: snapshot.name,
|
|
@@ -56,6 +315,10 @@ function buildWorkerRows(snapshots) {
|
|
|
56
315
|
pid: snapshot.pid,
|
|
57
316
|
restartCount: snapshot.restartCount,
|
|
58
317
|
startedAt: snapshot.startedAt,
|
|
318
|
+
lastExitCode: snapshot.lastExitCode ?? null,
|
|
319
|
+
lastSignal: snapshot.lastSignal ?? null,
|
|
320
|
+
errorReason: snapshot.errorReason ?? null,
|
|
321
|
+
fixHint: snapshot.fixHint ?? null,
|
|
59
322
|
}));
|
|
60
323
|
}
|
|
61
324
|
function formatStatusSummary(payload) {
|
|
@@ -88,6 +351,35 @@ function parseIncomingCommand(raw) {
|
|
|
88
351
|
}
|
|
89
352
|
return parsed;
|
|
90
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Handle agent.senseTurn command: runs a full agent turn via the daemon process.
|
|
356
|
+
* Dynamic import lazy-loads shared-turn. Hot-reload works because ouro dev
|
|
357
|
+
* restarts the daemon process (fresh module cache).
|
|
358
|
+
*/
|
|
359
|
+
async function handleAgentSenseTurn(command) {
|
|
360
|
+
try {
|
|
361
|
+
const { setAgentName } = await Promise.resolve().then(() => __importStar(require("../identity")));
|
|
362
|
+
setAgentName(command.agent);
|
|
363
|
+
const { runSenseTurn } = await Promise.resolve().then(() => __importStar(require("../../senses/shared-turn")));
|
|
364
|
+
const result = await runSenseTurn({
|
|
365
|
+
agentName: command.agent,
|
|
366
|
+
channel: command.channel,
|
|
367
|
+
sessionKey: command.sessionKey,
|
|
368
|
+
friendId: command.friendId,
|
|
369
|
+
userMessage: command.message,
|
|
370
|
+
});
|
|
371
|
+
return {
|
|
372
|
+
ok: true,
|
|
373
|
+
message: result.response,
|
|
374
|
+
data: { ponderDeferred: result.ponderDeferred },
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
/* v8 ignore next -- branch: String(error) fallback only for non-Error throws @preserve */
|
|
379
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
380
|
+
return { ok: false, error: `sense turn failed: ${errorMessage}` };
|
|
381
|
+
}
|
|
382
|
+
}
|
|
91
383
|
class OuroDaemon {
|
|
92
384
|
socketPath;
|
|
93
385
|
processManager;
|
|
@@ -96,7 +388,11 @@ class OuroDaemon {
|
|
|
96
388
|
router;
|
|
97
389
|
senseManager;
|
|
98
390
|
bundlesRoot;
|
|
391
|
+
mode;
|
|
99
392
|
server = null;
|
|
393
|
+
outlookServer = null;
|
|
394
|
+
socketIdentity = null;
|
|
395
|
+
outlookServerFactory;
|
|
100
396
|
constructor(options) {
|
|
101
397
|
this.socketPath = options.socketPath;
|
|
102
398
|
this.processManager = options.processManager;
|
|
@@ -105,6 +401,72 @@ class OuroDaemon {
|
|
|
105
401
|
this.router = options.router;
|
|
106
402
|
this.senseManager = options.senseManager ?? null;
|
|
107
403
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
404
|
+
this.mode = options.mode ?? "production";
|
|
405
|
+
this.outlookServerFactory = options.outlookServerFactory ?? this.createDefaultOutlookServer.bind(this);
|
|
406
|
+
}
|
|
407
|
+
/* 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 */
|
|
408
|
+
createDefaultOutlookServer() {
|
|
409
|
+
return (0, outlook_http_1.startOutlookHttpServer)({
|
|
410
|
+
host: "127.0.0.1",
|
|
411
|
+
port: outlook_types_1.OUTLOOK_DEFAULT_PORT,
|
|
412
|
+
bundlesRoot: this.bundlesRoot,
|
|
413
|
+
readMachineState: () => (0, outlook_read_1.readOutlookMachineState)({ bundlesRoot: this.bundlesRoot }),
|
|
414
|
+
readMachineView: ({ machine }) => {
|
|
415
|
+
const overview = this.buildStatusPayload().overview;
|
|
416
|
+
return (0, outlook_view_1.buildOutlookMachineView)({
|
|
417
|
+
machine,
|
|
418
|
+
daemon: {
|
|
419
|
+
status: overview.daemon,
|
|
420
|
+
health: overview.health,
|
|
421
|
+
mode: overview.mode,
|
|
422
|
+
socketPath: overview.socketPath,
|
|
423
|
+
outlookUrl: overview.outlookUrl,
|
|
424
|
+
entryPath: overview.entryPath,
|
|
425
|
+
workerCount: overview.workerCount,
|
|
426
|
+
senseCount: overview.senseCount,
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
},
|
|
430
|
+
readAgentState: (agentName) => (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot }),
|
|
431
|
+
readAgentView: (agentName) => {
|
|
432
|
+
const agent = (0, outlook_read_1.readOutlookAgentState)(agentName, { bundlesRoot: this.bundlesRoot });
|
|
433
|
+
return (0, outlook_view_1.buildOutlookAgentView)({
|
|
434
|
+
agent,
|
|
435
|
+
viewer: { kind: "human" },
|
|
436
|
+
});
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
/* v8 ignore stop */
|
|
441
|
+
buildStatusPayload() {
|
|
442
|
+
const snapshots = this.processManager.listAgentSnapshots();
|
|
443
|
+
const workers = buildWorkerRows(snapshots);
|
|
444
|
+
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
445
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
446
|
+
const sync = (0, agent_discovery_1.listBundleSyncRows)({ bundlesRoot: this.bundlesRoot });
|
|
447
|
+
const agents = (0, agent_discovery_1.listAllBundleAgents)({ bundlesRoot: this.bundlesRoot });
|
|
448
|
+
const providers = agents.flatMap((agent) => (0, provider_visibility_1.providerVisibilityStatusRows)((0, provider_visibility_1.buildAgentProviderVisibility)({
|
|
449
|
+
agentName: agent.name,
|
|
450
|
+
agentRoot: path.join(this.bundlesRoot, `${agent.name}.ouro`),
|
|
451
|
+
})));
|
|
452
|
+
return {
|
|
453
|
+
overview: {
|
|
454
|
+
daemon: "running",
|
|
455
|
+
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
456
|
+
socketPath: this.socketPath,
|
|
457
|
+
outlookUrl: this.outlookServer?.origin ?? "http://127.0.0.1:0",
|
|
458
|
+
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
459
|
+
workerCount: workers.length,
|
|
460
|
+
senseCount: senses.length,
|
|
461
|
+
entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
|
|
462
|
+
mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
|
|
463
|
+
},
|
|
464
|
+
workers,
|
|
465
|
+
senses,
|
|
466
|
+
sync,
|
|
467
|
+
agents,
|
|
468
|
+
...(providers.length > 0 ? { providers } : {}),
|
|
469
|
+
};
|
|
108
470
|
}
|
|
109
471
|
async start() {
|
|
110
472
|
if (this.server)
|
|
@@ -115,62 +477,181 @@ class OuroDaemon {
|
|
|
115
477
|
message: "starting daemon server",
|
|
116
478
|
meta: { socketPath: this.socketPath },
|
|
117
479
|
});
|
|
480
|
+
try {
|
|
481
|
+
await this.startInner();
|
|
482
|
+
}
|
|
483
|
+
catch (err) {
|
|
484
|
+
// Emit a paired terminating event (`_error`) so the nerves audit's
|
|
485
|
+
// start_end_pairing rule is satisfied when startup throws mid-sequence
|
|
486
|
+
// and `stop()` (which emits `server_end`) is never called.
|
|
487
|
+
(0, runtime_1.emitNervesEvent)({
|
|
488
|
+
level: "error",
|
|
489
|
+
component: "daemon",
|
|
490
|
+
event: "daemon.server_error",
|
|
491
|
+
message: "daemon start failed",
|
|
492
|
+
meta: {
|
|
493
|
+
error: err instanceof Error ? err.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(err),
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
throw err;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
async startInner() {
|
|
118
500
|
// Register update hooks and apply pending updates before starting agents
|
|
119
501
|
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
502
|
+
(0, update_hooks_1.registerUpdateHook)(agent_config_v2_1.agentConfigV2Hook);
|
|
120
503
|
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
121
504
|
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
122
505
|
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
506
|
+
// Skip in dev mode — dev builds should not auto-update from npm
|
|
123
507
|
const bundlesRoot = this.bundlesRoot;
|
|
124
|
-
const
|
|
125
|
-
(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
143
|
-
return resolved ? path.dirname(resolved) : null;
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
508
|
+
const daemonSocketPath = this.socketPath;
|
|
509
|
+
if (this.mode === "dev") {
|
|
510
|
+
(0, runtime_1.emitNervesEvent)({
|
|
511
|
+
component: "daemon",
|
|
512
|
+
event: "daemon.update_checker_skip",
|
|
513
|
+
message: "skipping update checker in dev mode",
|
|
514
|
+
meta: { reason: "dev mode" },
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
const daemon = this;
|
|
519
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
520
|
+
currentVersion,
|
|
521
|
+
deps: {
|
|
522
|
+
distTag: "latest",
|
|
523
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
524
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
525
|
+
return res.json();
|
|
148
526
|
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
527
|
+
},
|
|
528
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
529
|
+
if (!result.latestVersion)
|
|
530
|
+
return;
|
|
531
|
+
// Install via the version manager (NOT `npm install -g`). The
|
|
532
|
+
// global install path doesn't end up on the daemon process's
|
|
533
|
+
// NODE_PATH, so the previous `require.resolve('@ouro.bot/cli')`
|
|
534
|
+
// -based path lookup always returned null and the staged restart
|
|
535
|
+
// never actually completed. Verified live on 2026-04-08:
|
|
536
|
+
// alpha.268 daemon detected alpha.270 was available, ran the
|
|
537
|
+
// staged restart, and bailed at `staged_restart_path_failed` —
|
|
538
|
+
// meaning the daemon could never auto-update itself and required
|
|
539
|
+
// manual `ouro up` to pick up new versions.
|
|
540
|
+
//
|
|
541
|
+
// Switch to the version-managed layout the CLI itself uses:
|
|
542
|
+
// installVersion(version) puts files at
|
|
543
|
+
// ~/.ouro-cli/versions/{version}/node_modules/@ouro.bot/cli
|
|
544
|
+
// which is a known path we can compute deterministically.
|
|
545
|
+
// Then activateVersion(version) flips the CurrentVersion symlink
|
|
546
|
+
// so the next `ouro up` from the user sees the same version
|
|
547
|
+
// the daemon is running.
|
|
548
|
+
const cliHome = (0, ouro_version_manager_1.getOuroCliHome)();
|
|
549
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
550
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
551
|
+
spawnSync: child_process_1.spawnSync,
|
|
552
|
+
installNewVersion: (version) => {
|
|
553
|
+
(0, ouro_version_manager_1.installVersion)(version, {});
|
|
554
|
+
(0, ouro_version_manager_1.activateVersion)(version, {});
|
|
555
|
+
},
|
|
556
|
+
resolveNewCodePath: (version) => {
|
|
557
|
+
const versionPath = path.join(cliHome, "versions", version, "node_modules", "@ouro.bot", "cli");
|
|
558
|
+
return fs.existsSync(versionPath) ? versionPath : null;
|
|
559
|
+
},
|
|
560
|
+
gracefulShutdown: () => daemon.stop(),
|
|
561
|
+
spawnNewDaemon: (entryPath, sock) => {
|
|
562
|
+
const outFd = fs.openSync(os.devNull, "w");
|
|
563
|
+
const errFd = fs.openSync(os.devNull, "w");
|
|
564
|
+
const child = (0, child_process_1.spawn)(process.execPath, [entryPath, "--socket", sock], {
|
|
565
|
+
detached: true,
|
|
566
|
+
stdio: ["ignore", outFd, errFd],
|
|
567
|
+
});
|
|
568
|
+
child.unref();
|
|
569
|
+
return { pid: child.pid ?? null };
|
|
570
|
+
},
|
|
571
|
+
nodePath: process.execPath,
|
|
572
|
+
bundlesRoot,
|
|
573
|
+
socketPath: daemonSocketPath,
|
|
574
|
+
});
|
|
575
|
+
},
|
|
576
|
+
/* v8 ignore stop */
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
// MCP connections are lazily initialized per-agent during senseTurn
|
|
580
|
+
// (daemon manages multiple agents; agent identity must be set before loading MCP config)
|
|
581
|
+
/* v8 ignore start -- orphan cleanup + pidfile: calls process management functions @preserve */
|
|
582
|
+
killOrphanProcesses();
|
|
583
|
+
/* v8 ignore stop */
|
|
156
584
|
await this.processManager.startAutoStartAgents();
|
|
157
585
|
await this.senseManager?.startAutoStartSenses();
|
|
586
|
+
// Write all managed PIDs to disk so the next daemon can clean up
|
|
587
|
+
/* v8 ignore start -- pidfile write: collects PIDs from process managers @preserve */
|
|
588
|
+
const agentPids = this.processManager.listAgentSnapshots().map((s) => s.pid).filter((p) => p !== null);
|
|
589
|
+
const sensePids = this.senseManager?.listManagedPids?.() ?? [];
|
|
590
|
+
writePidfile([...agentPids, ...sensePids]);
|
|
591
|
+
/* v8 ignore stop */
|
|
158
592
|
this.scheduler.start?.();
|
|
159
593
|
await this.scheduler.reconcile?.();
|
|
160
594
|
await this.drainPendingBundleMessages();
|
|
161
595
|
await this.drainPendingSenseMessages();
|
|
596
|
+
// startInner is only reachable when this.server is null (guarded in
|
|
597
|
+
// start()), and stop() nulls out this.outlookServer alongside this.server,
|
|
598
|
+
// so outlookServer is guaranteed unset here — no need for a guard.
|
|
599
|
+
try {
|
|
600
|
+
this.outlookServer = await this.outlookServerFactory();
|
|
601
|
+
}
|
|
602
|
+
catch (error) {
|
|
603
|
+
(0, runtime_1.emitNervesEvent)({
|
|
604
|
+
level: "warn",
|
|
605
|
+
component: "daemon",
|
|
606
|
+
event: "daemon.outlook_start_failed",
|
|
607
|
+
message: `Outlook server failed to start: ${String(error)}`,
|
|
608
|
+
meta: { port: outlook_types_1.OUTLOOK_DEFAULT_PORT },
|
|
609
|
+
});
|
|
610
|
+
}
|
|
162
611
|
if (fs.existsSync(this.socketPath)) {
|
|
163
612
|
fs.unlinkSync(this.socketPath);
|
|
164
613
|
}
|
|
165
|
-
|
|
614
|
+
// allowHalfOpen: true lets the server keep its writable side open after
|
|
615
|
+
// the client sends FIN. Without this, when a client calls `client.end()`
|
|
616
|
+
// after writing a command, node closes the server's writable side
|
|
617
|
+
// automatically — so a long-running response (like an agent.senseTurn
|
|
618
|
+
// LLM turn that takes 5+ seconds) never reaches the client. The
|
|
619
|
+
// socket-client fix in #303/#334 also removed client.end() on the
|
|
620
|
+
// sending side, but this option is defense in depth: even if a future
|
|
621
|
+
// caller half-closes, the server still writes its response correctly.
|
|
622
|
+
this.server = net.createServer({ allowHalfOpen: true }, (connection) => {
|
|
166
623
|
let raw = "";
|
|
167
624
|
let responded = false;
|
|
625
|
+
/* v8 ignore start — connection error handler requires real socket error @preserve */
|
|
626
|
+
connection.on("error", (err) => {
|
|
627
|
+
(0, runtime_1.emitNervesEvent)({
|
|
628
|
+
level: "warn",
|
|
629
|
+
component: "daemon",
|
|
630
|
+
event: "daemon.connection_error",
|
|
631
|
+
message: "socket connection error",
|
|
632
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
/* v8 ignore stop */
|
|
168
636
|
const flushResponse = async () => {
|
|
169
637
|
if (responded)
|
|
170
638
|
return;
|
|
171
639
|
responded = true;
|
|
172
640
|
const response = await this.handleRawPayload(raw);
|
|
173
|
-
|
|
641
|
+
try {
|
|
642
|
+
connection.end(response);
|
|
643
|
+
/* v8 ignore start — EPIPE catch requires real socket disconnect @preserve */
|
|
644
|
+
}
|
|
645
|
+
catch (err) {
|
|
646
|
+
(0, runtime_1.emitNervesEvent)({
|
|
647
|
+
level: "warn",
|
|
648
|
+
component: "daemon",
|
|
649
|
+
event: "daemon.connection_end_error",
|
|
650
|
+
message: "failed to send response to client (EPIPE)",
|
|
651
|
+
meta: { error: err instanceof Error ? err.message : String(err) },
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
/* v8 ignore stop */
|
|
174
655
|
};
|
|
175
656
|
connection.on("data", (chunk) => {
|
|
176
657
|
raw += chunk.toString("utf-8");
|
|
@@ -183,7 +664,23 @@ class OuroDaemon {
|
|
|
183
664
|
const server = this.server;
|
|
184
665
|
await new Promise((resolve, reject) => {
|
|
185
666
|
server.once("error", reject);
|
|
186
|
-
server.listen(this.socketPath, () =>
|
|
667
|
+
server.listen(this.socketPath, () => {
|
|
668
|
+
// Replace the one-time error listener with a persistent one after successful listen
|
|
669
|
+
server.removeAllListeners("error");
|
|
670
|
+
this.socketIdentity = readSocketIdentity(this.socketPath);
|
|
671
|
+
/* v8 ignore start — server error after listen requires real socket race condition @preserve */
|
|
672
|
+
server.on("error", (err) => {
|
|
673
|
+
(0, runtime_1.emitNervesEvent)({
|
|
674
|
+
level: "error",
|
|
675
|
+
component: "daemon",
|
|
676
|
+
event: "daemon.server_error",
|
|
677
|
+
message: "daemon server error after listen",
|
|
678
|
+
meta: { error: err.message, code: err.code ?? null },
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
/* v8 ignore stop */
|
|
682
|
+
resolve();
|
|
683
|
+
});
|
|
187
684
|
});
|
|
188
685
|
}
|
|
189
686
|
async drainPendingBundleMessages() {
|
|
@@ -322,25 +819,82 @@ class OuroDaemon {
|
|
|
322
819
|
}
|
|
323
820
|
}
|
|
324
821
|
async stop() {
|
|
822
|
+
// Must be named `_end` (not `_stop`) to satisfy the nerves audit's
|
|
823
|
+
// start/end pairing rule — see src/nerves/coverage/audit-rules.ts.
|
|
824
|
+
// This is the counterpart to `daemon.server_start` emitted at line 480.
|
|
325
825
|
(0, runtime_1.emitNervesEvent)({
|
|
326
826
|
component: "daemon",
|
|
327
|
-
event: "daemon.
|
|
827
|
+
event: "daemon.server_end",
|
|
328
828
|
message: "stopping daemon server",
|
|
329
829
|
meta: { socketPath: this.socketPath },
|
|
330
830
|
});
|
|
331
831
|
(0, update_checker_1.stopUpdateChecker)();
|
|
832
|
+
(0, mcp_manager_1.shutdownSharedMcpManager)();
|
|
332
833
|
this.scheduler.stop?.();
|
|
333
834
|
await this.processManager.stopAll();
|
|
334
835
|
await this.senseManager?.stopAll();
|
|
335
836
|
if (this.server) {
|
|
336
|
-
await
|
|
337
|
-
|
|
338
|
-
|
|
837
|
+
// DO NOT `await` server.close() here. server.close() resolves only
|
|
838
|
+
// after every open connection has closed. When stop() is invoked
|
|
839
|
+
// from the daemon.stop command handler, the calling client's
|
|
840
|
+
// connection is STILL open — its flushResponse() is currently
|
|
841
|
+
// awaiting THIS function. Awaiting close() creates a deadlock:
|
|
842
|
+
//
|
|
843
|
+
// client → flushResponse → handleRawPayload → daemon.stop case
|
|
844
|
+
// → stop() → await server.close() (waits for client's connection)
|
|
845
|
+
// → client's connection waits for flushResponse to call
|
|
846
|
+
// connection.end() → DEADLOCK
|
|
847
|
+
//
|
|
848
|
+
// Both processes sit in kevent forever. Verified live on
|
|
849
|
+
// 2026-04-08: alpha.268 daemon hung at `daemon.server_end` log
|
|
850
|
+
// line for 5+ minutes after a client sent daemon.stop, while the
|
|
851
|
+
// client (alpha.270 ouro up) hung waiting for the response.
|
|
852
|
+
//
|
|
853
|
+
// This regressed when #303/#334/#339 stopped half-closing the
|
|
854
|
+
// client socket and switched the server to allowHalfOpen: true.
|
|
855
|
+
// Previously, the client called .end() after writing its command,
|
|
856
|
+
// which (with allowHalfOpen: false) caused node to auto-tear-down
|
|
857
|
+
// the server's writable side — incidentally unblocking
|
|
858
|
+
// server.close() before the response was sent. The half-close
|
|
859
|
+
// breakage masked this deadlock; the fix exposed it.
|
|
860
|
+
//
|
|
861
|
+
// Solution: fire close() and let it complete asynchronously. Once
|
|
862
|
+
// stop() returns, the daemon.stop case returns its response,
|
|
863
|
+
// flushResponse() calls connection.end(response), the connection
|
|
864
|
+
// closes, and server.close()'s pending callback fires. The event
|
|
865
|
+
// loop drains and the daemon exits cleanly.
|
|
866
|
+
this.server.close();
|
|
339
867
|
this.server = null;
|
|
340
868
|
}
|
|
341
|
-
if (
|
|
869
|
+
if (this.outlookServer) {
|
|
870
|
+
await this.outlookServer.stop();
|
|
871
|
+
this.outlookServer = null;
|
|
872
|
+
}
|
|
873
|
+
const socketPathExists = fs.existsSync(this.socketPath);
|
|
874
|
+
const currentSocketIdentity = socketPathExists ? readSocketIdentity(this.socketPath) : null;
|
|
875
|
+
if (sameSocketIdentity(this.socketIdentity, currentSocketIdentity)) {
|
|
342
876
|
fs.unlinkSync(this.socketPath);
|
|
343
877
|
}
|
|
878
|
+
else if (socketPathExists) {
|
|
879
|
+
const expectedSocketIdentity = { dev: null, ino: null, ctimeMs: null, ...this.socketIdentity };
|
|
880
|
+
const actualSocketIdentity = { dev: null, ino: null, ctimeMs: null, ...currentSocketIdentity };
|
|
881
|
+
(0, runtime_1.emitNervesEvent)({
|
|
882
|
+
level: "warn",
|
|
883
|
+
component: "daemon",
|
|
884
|
+
event: "daemon.socket_cleanup_skipped",
|
|
885
|
+
message: "skipped daemon socket cleanup because the socket path no longer belongs to this daemon",
|
|
886
|
+
meta: {
|
|
887
|
+
socketPath: this.socketPath,
|
|
888
|
+
expectedDev: expectedSocketIdentity.dev,
|
|
889
|
+
expectedIno: expectedSocketIdentity.ino,
|
|
890
|
+
expectedCtimeMs: expectedSocketIdentity.ctimeMs,
|
|
891
|
+
actualDev: actualSocketIdentity.dev,
|
|
892
|
+
actualIno: actualSocketIdentity.ino,
|
|
893
|
+
actualCtimeMs: actualSocketIdentity.ctimeMs,
|
|
894
|
+
},
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
this.socketIdentity = null;
|
|
344
898
|
}
|
|
345
899
|
async handleRawPayload(raw) {
|
|
346
900
|
try {
|
|
@@ -362,6 +916,27 @@ class OuroDaemon {
|
|
|
362
916
|
message: "handling daemon command",
|
|
363
917
|
meta: { kind: command.kind },
|
|
364
918
|
});
|
|
919
|
+
try {
|
|
920
|
+
return await this.handleCommandInner(command);
|
|
921
|
+
/* v8 ignore start — command error catch tested in daemon-command-error.test; instanceof branches defensive @preserve */
|
|
922
|
+
}
|
|
923
|
+
catch (error) {
|
|
924
|
+
(0, runtime_1.emitNervesEvent)({
|
|
925
|
+
level: "error",
|
|
926
|
+
component: "daemon",
|
|
927
|
+
event: "daemon.command_error",
|
|
928
|
+
message: "unexpected error handling daemon command",
|
|
929
|
+
meta: {
|
|
930
|
+
kind: command.kind,
|
|
931
|
+
error: error instanceof Error ? error.message : String(error),
|
|
932
|
+
stack: error instanceof Error ? error.stack ?? null : null,
|
|
933
|
+
},
|
|
934
|
+
});
|
|
935
|
+
throw error;
|
|
936
|
+
}
|
|
937
|
+
/* v8 ignore stop */
|
|
938
|
+
}
|
|
939
|
+
async handleCommandInner(command) {
|
|
365
940
|
switch (command.kind) {
|
|
366
941
|
case "daemon.start":
|
|
367
942
|
await this.start();
|
|
@@ -370,21 +945,7 @@ class OuroDaemon {
|
|
|
370
945
|
await this.stop();
|
|
371
946
|
return { ok: true, message: "daemon stopped" };
|
|
372
947
|
case "daemon.status": {
|
|
373
|
-
const
|
|
374
|
-
const workers = buildWorkerRows(snapshots);
|
|
375
|
-
const senses = this.senseManager?.listSenseRows() ?? [];
|
|
376
|
-
const data = {
|
|
377
|
-
overview: {
|
|
378
|
-
daemon: "running",
|
|
379
|
-
health: workers.every((worker) => worker.status === "running") ? "ok" : "warn",
|
|
380
|
-
socketPath: this.socketPath,
|
|
381
|
-
...(0, runtime_metadata_1.getRuntimeMetadata)(),
|
|
382
|
-
workerCount: workers.length,
|
|
383
|
-
senseCount: senses.length,
|
|
384
|
-
},
|
|
385
|
-
workers,
|
|
386
|
-
senses,
|
|
387
|
-
};
|
|
948
|
+
const data = this.buildStatusPayload();
|
|
388
949
|
return {
|
|
389
950
|
ok: true,
|
|
390
951
|
summary: formatStatusSummary(data),
|
|
@@ -401,7 +962,7 @@ class OuroDaemon {
|
|
|
401
962
|
ok: true,
|
|
402
963
|
summary: "logs: use `ouro logs` to tail daemon and agent output",
|
|
403
964
|
message: "log streaming available via ouro logs",
|
|
404
|
-
data: { logDir: "
|
|
965
|
+
data: { logDir: "~/AgentBundles/<agent>.ouro/state/daemon/logs" },
|
|
405
966
|
};
|
|
406
967
|
case "agent.start":
|
|
407
968
|
await this.processManager.startAgent(command.agent);
|
|
@@ -412,6 +973,35 @@ class OuroDaemon {
|
|
|
412
973
|
case "agent.restart":
|
|
413
974
|
await this.processManager.restartAgent?.(command.agent);
|
|
414
975
|
return { ok: true, message: `restarted ${command.agent}` };
|
|
976
|
+
case "agent.ask":
|
|
977
|
+
return (0, agent_service_1.handleAgentAsk)(command);
|
|
978
|
+
case "agent.status":
|
|
979
|
+
return (0, agent_service_1.handleAgentStatus)(command);
|
|
980
|
+
case "agent.catchup":
|
|
981
|
+
return (0, agent_service_1.handleAgentCatchup)(command);
|
|
982
|
+
case "agent.delegate":
|
|
983
|
+
return (0, agent_service_1.handleAgentDelegate)(command);
|
|
984
|
+
case "agent.getContext":
|
|
985
|
+
return (0, agent_service_1.handleAgentGetContext)(command);
|
|
986
|
+
case "agent.searchNotes":
|
|
987
|
+
return (0, agent_service_1.handleAgentSearchNotes)(command);
|
|
988
|
+
case "agent.getTask":
|
|
989
|
+
return (0, agent_service_1.handleAgentGetTask)(command);
|
|
990
|
+
case "agent.checkScope":
|
|
991
|
+
return (0, agent_service_1.handleAgentCheckScope)(command);
|
|
992
|
+
case "agent.requestDecision":
|
|
993
|
+
return (0, agent_service_1.handleAgentRequestDecision)(command);
|
|
994
|
+
case "agent.checkGuidance":
|
|
995
|
+
return (0, agent_service_1.handleAgentCheckGuidance)(command);
|
|
996
|
+
case "agent.reportProgress":
|
|
997
|
+
return (0, agent_service_1.handleAgentReportProgress)(command);
|
|
998
|
+
case "agent.reportBlocker":
|
|
999
|
+
return (0, agent_service_1.handleAgentReportBlocker)(command);
|
|
1000
|
+
case "agent.reportComplete":
|
|
1001
|
+
return (0, agent_service_1.handleAgentReportComplete)(command);
|
|
1002
|
+
case "agent.senseTurn":
|
|
1003
|
+
return handleAgentSenseTurn(command);
|
|
1004
|
+
/* v8 ignore stop */
|
|
415
1005
|
case "cron.list": {
|
|
416
1006
|
const jobs = this.scheduler.listJobs();
|
|
417
1007
|
const summary = jobs.length === 0
|
|
@@ -472,6 +1062,35 @@ class OuroDaemon {
|
|
|
472
1062
|
data: receipt,
|
|
473
1063
|
};
|
|
474
1064
|
}
|
|
1065
|
+
case "habit.poke": {
|
|
1066
|
+
this.processManager.sendToAgent?.(command.agent, { type: "habit", habitName: command.habitName });
|
|
1067
|
+
return {
|
|
1068
|
+
ok: true,
|
|
1069
|
+
message: `poked habit ${command.habitName} for ${command.agent}`,
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
case "mcp.list": {
|
|
1073
|
+
const mcpManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
1074
|
+
if (!mcpManager) {
|
|
1075
|
+
return { ok: true, data: [], message: "no MCP servers configured" };
|
|
1076
|
+
}
|
|
1077
|
+
return { ok: true, data: mcpManager.listAllTools() };
|
|
1078
|
+
}
|
|
1079
|
+
case "mcp.call": {
|
|
1080
|
+
const mcpCallManager = await (0, mcp_manager_1.getSharedMcpManager)();
|
|
1081
|
+
if (!mcpCallManager) {
|
|
1082
|
+
return { ok: false, error: "no MCP servers configured" };
|
|
1083
|
+
}
|
|
1084
|
+
try {
|
|
1085
|
+
const parsedArgs = command.args ? JSON.parse(command.args) : {};
|
|
1086
|
+
const result = await mcpCallManager.callTool(command.server, command.tool, parsedArgs);
|
|
1087
|
+
return { ok: true, data: result };
|
|
1088
|
+
}
|
|
1089
|
+
catch (error) {
|
|
1090
|
+
/* v8 ignore next -- defensive: callTool errors are always Error instances @preserve */
|
|
1091
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
475
1094
|
case "hatch.start":
|
|
476
1095
|
return {
|
|
477
1096
|
ok: true,
|