@ouro.bot/cli 0.1.0-alpha.83 → 0.1.0-alpha.831

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.
Files changed (647) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -23
  3. package/RepairGuide.ouro/agent.json +5 -0
  4. package/RepairGuide.ouro/psyche/IDENTITY.md +19 -0
  5. package/RepairGuide.ouro/psyche/SOUL.md +55 -0
  6. package/RepairGuide.ouro/skills/diagnose-broken-remote.md +63 -0
  7. package/RepairGuide.ouro/skills/diagnose-stacked-typed-issues.md +35 -0
  8. package/RepairGuide.ouro/skills/diagnose-sync-blocked.md +54 -0
  9. package/RepairGuide.ouro/skills/diagnose-vault-expired.md +60 -0
  10. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +4 -2
  11. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +2 -2
  12. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
  13. package/assets/bluebubbles-host +264 -0
  14. package/assets/sanctuary-host-launcher.sh +16 -0
  15. package/changelog.json +5308 -16
  16. package/deploy/unraid/Dockerfile +54 -0
  17. package/deploy/unraid/README.txt +2983 -0
  18. package/deploy/unraid/audit-container-spec.sh +4 -0
  19. package/deploy/unraid/container-runtime.json +1 -0
  20. package/deploy/unraid/docker-man-template-transaction.mjs +711 -0
  21. package/deploy/unraid/docker-man-template-xml.cjs +105 -0
  22. package/deploy/unraid/migrate-sanctuary-bundle.mjs +60 -0
  23. package/deploy/unraid/ouro-events/bootstrap-spool.sh +92 -0
  24. package/deploy/unraid/ouro-events/emit-event.mjs +310 -0
  25. package/deploy/unraid/ouro-events/emit-usenet-event.sh +54 -0
  26. package/deploy/unraid/ouro-events/install-usenet-guard.sh +435 -0
  27. package/deploy/unraid/ouro-events/usenet-health.sh +176 -0
  28. package/deploy/unraid/sanctuary-acceptance-adapter.sh +43 -0
  29. package/deploy/unraid/sanctuary-acceptance-contract.json +198 -0
  30. package/deploy/unraid/sanctuary-acceptance-harness.sh +23 -0
  31. package/deploy/unraid/sanctuary-authority-installation.json +36 -0
  32. package/deploy/unraid/sanctuary-authority-service.sh +30 -0
  33. package/deploy/unraid/sanctuary-deployment-target.mjs +710 -0
  34. package/deploy/unraid/sanctuary-safe-rename.py +24 -0
  35. package/deploy/unraid/sanctuary-unit16-host-broker.mjs +2084 -0
  36. package/deploy/unraid/sanctuary-unit16-run.sh +560 -0
  37. package/deploy/unraid/sanctuary-unit18-target-audit.sh +27 -0
  38. package/deploy/unraid/sanctuary.ouro/agent.json +66 -0
  39. package/deploy/unraid/sanctuary.ouro/arc/README.md +3 -0
  40. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +5 -0
  41. package/deploy/unraid/sanctuary.ouro/habits/sanctuary-health.md +8 -0
  42. package/deploy/unraid/sanctuary.ouro/mcp/media-mcp.mjs +795 -0
  43. package/deploy/unraid/sanctuary.ouro/provider-readiness.json +11 -0
  44. package/deploy/unraid/sanctuary.ouro/psyche/ASPIRATIONS.md +5 -0
  45. package/deploy/unraid/sanctuary.ouro/psyche/IDENTITY.md +5 -0
  46. package/deploy/unraid/sanctuary.ouro/psyche/LORE.md +15 -0
  47. package/deploy/unraid/sanctuary.ouro/psyche/SOUL.md +25 -0
  48. package/deploy/unraid/sanctuary.ouro/psyche/TACIT.md +15 -0
  49. package/deploy/unraid/sanctuary.ouro/state/policy/steward.json +7 -0
  50. package/deploy/unraid/sanctuary.ouro/tool-profiles.json +135 -0
  51. package/deploy/unraid/sanctuary.xml +28 -0
  52. package/dist/a2a/card.js +57 -0
  53. package/dist/a2a/client.js +180 -0
  54. package/dist/a2a/config.js +50 -0
  55. package/dist/a2a/delegation-stores.js +56 -0
  56. package/dist/a2a/did-resolution.js +93 -0
  57. package/dist/a2a/identity.js +170 -0
  58. package/dist/a2a/inbound-share.js +107 -0
  59. package/dist/a2a/mission-result-wire.js +196 -0
  60. package/dist/a2a/onboarding.js +115 -0
  61. package/dist/a2a/pin-store.js +132 -0
  62. package/dist/a2a/seen-ledger.js +120 -0
  63. package/dist/a2a/server.js +604 -0
  64. package/dist/a2a/task-store.js +69 -0
  65. package/dist/a2a/transport.js +45 -0
  66. package/dist/a2a/types.js +3 -0
  67. package/dist/arc/attention-types.js +8 -0
  68. package/dist/arc/cares.js +360 -0
  69. package/dist/arc/episodes.js +118 -0
  70. package/dist/arc/evolution.js +490 -0
  71. package/dist/arc/flight-recorder.js +1034 -0
  72. package/dist/arc/intentions.js +134 -0
  73. package/dist/arc/json-store.js +117 -0
  74. package/dist/arc/obligations.js +386 -0
  75. package/dist/arc/packets.js +336 -0
  76. package/dist/arc/presence.js +185 -0
  77. package/dist/arc/task-lifecycle.js +57 -0
  78. package/dist/commerce/store.js +755 -0
  79. package/dist/commerce/types.js +3 -0
  80. package/dist/heart/active-work.js +798 -40
  81. package/dist/heart/agent-entry.js +252 -3
  82. package/dist/heart/approval-files.js +113 -0
  83. package/dist/heart/approval-store.js +960 -0
  84. package/dist/heart/attachments/image-normalize.js +194 -0
  85. package/dist/heart/attachments/materialize.js +97 -0
  86. package/dist/heart/attachments/originals.js +88 -0
  87. package/dist/heart/attachments/render.js +29 -0
  88. package/dist/heart/attachments/sources/bluebubbles.js +156 -0
  89. package/dist/heart/attachments/sources/cli-local-file.js +78 -0
  90. package/dist/heart/attachments/sources/index.js +18 -0
  91. package/dist/heart/attachments/sources/telegram.js +71 -0
  92. package/dist/heart/attachments/store.js +132 -0
  93. package/dist/heart/attachments/types.js +93 -0
  94. package/dist/heart/auth/auth-flow.js +495 -0
  95. package/dist/heart/autonomy-budget.js +478 -0
  96. package/dist/heart/awaiting/await-alert.js +148 -0
  97. package/dist/heart/awaiting/await-expiry.js +143 -0
  98. package/dist/heart/awaiting/await-loader.js +91 -0
  99. package/dist/heart/awaiting/await-parser.js +149 -0
  100. package/dist/heart/awaiting/await-runtime-state.js +111 -0
  101. package/dist/heart/awaiting/await-scheduler.js +382 -0
  102. package/dist/heart/background-operations.js +281 -0
  103. package/dist/heart/bridges/manager.js +137 -17
  104. package/dist/heart/bridges/store.js +14 -2
  105. package/dist/heart/bundle-state.js +168 -0
  106. package/dist/heart/commitments.js +44 -18
  107. package/dist/heart/config-registry.js +331 -0
  108. package/dist/heart/config.js +174 -131
  109. package/dist/heart/context-loss-gauntlet.js +387 -0
  110. package/dist/heart/context-loss-sentinel.js +1157 -0
  111. package/dist/heart/core.js +2169 -581
  112. package/dist/heart/cross-chat-delivery.js +9 -22
  113. package/dist/heart/daemon/agent-config-check.js +451 -0
  114. package/dist/heart/daemon/agent-discovery.js +185 -3
  115. package/dist/heart/daemon/agent-service.js +542 -0
  116. package/dist/heart/daemon/agentic-repair.js +547 -0
  117. package/dist/heart/daemon/await-private-wake.js +59 -0
  118. package/dist/heart/daemon/bluebubbles-cli-integration.js +71 -0
  119. package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
  120. package/dist/heart/daemon/bluebubbles-host-protocol.js +433 -0
  121. package/dist/heart/daemon/bluebubbles-host.js +273 -0
  122. package/dist/heart/daemon/boot-sync-probe.js +197 -0
  123. package/dist/heart/daemon/cadence.js +180 -0
  124. package/dist/heart/daemon/cli-defaults.js +854 -0
  125. package/dist/heart/daemon/cli-desk.js +322 -0
  126. package/dist/heart/daemon/cli-exec.js +8822 -0
  127. package/dist/heart/daemon/cli-help.js +716 -0
  128. package/dist/heart/daemon/cli-parse.js +2771 -0
  129. package/dist/heart/daemon/cli-render-doctor.js +57 -0
  130. package/dist/heart/daemon/cli-render.js +777 -0
  131. package/dist/heart/daemon/cli-types.js +8 -0
  132. package/dist/heart/daemon/connect-bay.js +323 -0
  133. package/dist/heart/daemon/container-credential-bootstrap.js +273 -0
  134. package/dist/heart/daemon/container-healthcheck.js +112 -0
  135. package/dist/heart/daemon/container-runtime.js +97 -0
  136. package/dist/heart/daemon/container-spec-auditor-main.js +171 -0
  137. package/dist/heart/daemon/container-spec-auditor.js +229 -0
  138. package/dist/heart/daemon/daemon-bootstrap-startup.js +115 -0
  139. package/dist/heart/daemon/daemon-cli.js +29 -2349
  140. package/dist/heart/daemon/daemon-entry.js +930 -11
  141. package/dist/heart/daemon/daemon-health.js +186 -0
  142. package/dist/heart/daemon/daemon-rollup.js +57 -0
  143. package/dist/heart/daemon/daemon-runtime-sync.js +88 -13
  144. package/dist/heart/daemon/daemon-tombstone.js +236 -0
  145. package/dist/heart/daemon/daemon.js +2084 -105
  146. package/dist/heart/daemon/dns-workflow.js +394 -0
  147. package/dist/heart/daemon/doctor-types.js +8 -0
  148. package/dist/heart/daemon/doctor.js +1755 -0
  149. package/dist/heart/daemon/freshness.js +345 -0
  150. package/dist/heart/daemon/habit-private-wake.js +61 -0
  151. package/dist/heart/daemon/health-monitor.js +142 -11
  152. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  153. package/dist/heart/daemon/hooks/bundle-meta.js +135 -1
  154. package/dist/heart/daemon/http-health-probe.js +80 -0
  155. package/dist/heart/daemon/human-command-screens.js +234 -0
  156. package/dist/heart/daemon/human-readiness.js +114 -0
  157. package/dist/heart/daemon/inner-status.js +78 -0
  158. package/dist/heart/daemon/interactive-repair.js +394 -0
  159. package/dist/heart/daemon/launchd.js +37 -8
  160. package/dist/heart/daemon/log-tailer.js +79 -10
  161. package/dist/heart/daemon/logs-prune.js +132 -0
  162. package/dist/heart/daemon/mcp-canary.js +524 -0
  163. package/dist/heart/daemon/message-router.js +65 -5
  164. package/dist/heart/daemon/migrate-to-desk.js +848 -0
  165. package/dist/heart/daemon/os-cron-deps.js +135 -0
  166. package/dist/heart/daemon/os-cron.js +22 -14
  167. package/dist/heart/daemon/ouro-bot-entry.js +4 -2
  168. package/dist/heart/daemon/ouro-entry.js +3 -1
  169. package/dist/heart/daemon/plugin-cli.js +432 -0
  170. package/dist/heart/daemon/process-manager.js +733 -61
  171. package/dist/heart/daemon/provider-discovery.js +137 -0
  172. package/dist/heart/daemon/provider-ping-progress.js +83 -0
  173. package/dist/heart/daemon/prunable-bundle.js +144 -0
  174. package/dist/heart/daemon/pulse.js +511 -0
  175. package/dist/heart/daemon/readiness-repair.js +365 -0
  176. package/dist/heart/daemon/run-hooks.js +2 -0
  177. package/dist/heart/daemon/runtime-logging.js +47 -14
  178. package/dist/heart/daemon/runtime-metadata.js +2 -30
  179. package/dist/heart/daemon/runtime-mode.js +13 -2
  180. package/dist/heart/daemon/safe-mode.js +161 -0
  181. package/dist/heart/daemon/sanctuary-acceptance-adapter.js +2654 -0
  182. package/dist/heart/daemon/sanctuary-acceptance-harness.js +1830 -0
  183. package/dist/heart/daemon/sanctuary-acceptance-marker.js +267 -0
  184. package/dist/heart/daemon/sanctuary-acceptance-scenarios.js +955 -0
  185. package/dist/heart/daemon/sanctuary-authority-codec.js +86 -0
  186. package/dist/heart/daemon/sanctuary-authority-epoch.js +256 -0
  187. package/dist/heart/daemon/sanctuary-authority-installation.js +140 -0
  188. package/dist/heart/daemon/sanctuary-authority-ledger.js +241 -0
  189. package/dist/heart/daemon/sanctuary-authority-root-lifecycle.js +819 -0
  190. package/dist/heart/daemon/sanctuary-authority-vault-migration.js +79 -0
  191. package/dist/heart/daemon/sanctuary-bundle-migration.js +729 -0
  192. package/dist/heart/daemon/sanctuary-host-authority.js +1008 -0
  193. package/dist/heart/daemon/sanctuary-host-detached-supervisor.js +494 -0
  194. package/dist/heart/daemon/sanctuary-host-executor.js +670 -0
  195. package/dist/heart/daemon/sanctuary-host-linux-kernel.js +334 -0
  196. package/dist/heart/daemon/sanctuary-host-supervisor-entry.js +207 -0
  197. package/dist/heart/daemon/sanctuary-host-supervisor.js +95 -0
  198. package/dist/heart/daemon/sanctuary-package-management.js +103 -0
  199. package/dist/heart/daemon/sanctuary-scheduler-liveness.js +227 -0
  200. package/dist/heart/daemon/sanctuary-scheduler-origin.js +132 -0
  201. package/dist/heart/daemon/sanctuary-telegram-authority-entry.js +445 -0
  202. package/dist/heart/daemon/sanctuary-telegram-authority-gateway.js +585 -0
  203. package/dist/heart/daemon/sanctuary-telegram-authority-service.js +630 -0
  204. package/dist/heart/daemon/sense-manager.js +699 -48
  205. package/dist/heart/daemon/session-id-resolver.js +131 -0
  206. package/dist/heart/daemon/skill-management-installer.js +1 -1
  207. package/dist/heart/daemon/socket-client.js +180 -12
  208. package/dist/heart/daemon/stale-bundle-prune.js +113 -0
  209. package/dist/heart/daemon/startup-tui.js +339 -0
  210. package/dist/heart/daemon/supercronic-supervisor.js +282 -0
  211. package/dist/heart/daemon/task-scheduler.js +117 -39
  212. package/dist/heart/daemon/terminal-ui.js +499 -0
  213. package/dist/heart/daemon/thoughts.js +138 -54
  214. package/dist/heart/daemon/up-progress.js +366 -0
  215. package/dist/heart/daemon/vault-items.js +56 -0
  216. package/dist/heart/delegation.js +1 -4
  217. package/dist/heart/external-events/router.js +1430 -0
  218. package/dist/heart/frontend-approval-runtime.js +506 -0
  219. package/dist/heart/frontend-journal.js +215 -0
  220. package/dist/heart/frontend-session-service.js +237 -0
  221. package/dist/heart/frontend-socket-client.js +164 -0
  222. package/dist/heart/frontend-socket.js +400 -0
  223. package/dist/heart/habits/habit-cancel.js +810 -0
  224. package/dist/heart/habits/habit-lifecycle.js +1327 -0
  225. package/dist/heart/habits/habit-migration.js +194 -0
  226. package/dist/heart/habits/habit-parser.js +278 -0
  227. package/dist/heart/habits/habit-runtime-state.js +93 -0
  228. package/dist/heart/habits/habit-scheduler.js +653 -0
  229. package/dist/heart/habits/habit-session-summary.js +318 -0
  230. package/dist/heart/habits/habit-session.js +636 -0
  231. package/dist/heart/{daemon → hatch}/hatch-flow.js +55 -62
  232. package/dist/heart/{daemon → hatch}/hatch-specialist.js +6 -8
  233. package/dist/heart/{daemon → hatch}/specialist-prompt.js +12 -9
  234. package/dist/heart/{daemon → hatch}/specialist-tools.js +53 -18
  235. package/dist/heart/identity.js +196 -59
  236. package/dist/heart/kept-notes.js +289 -0
  237. package/dist/heart/kicks.js +1 -1
  238. package/dist/heart/machine-identity.js +161 -0
  239. package/dist/heart/mail-import-discovery.js +356 -0
  240. package/dist/heart/mailbox/mailbox-http-hooks.js +98 -0
  241. package/dist/heart/mailbox/mailbox-http-response.js +7 -0
  242. package/dist/heart/mailbox/mailbox-http-routes.js +398 -0
  243. package/dist/heart/mailbox/mailbox-http-static.js +103 -0
  244. package/dist/heart/mailbox/mailbox-http-transport.js +129 -0
  245. package/dist/heart/mailbox/mailbox-http.js +99 -0
  246. package/dist/heart/mailbox/mailbox-read.js +39 -0
  247. package/dist/heart/mailbox/mailbox-types.js +27 -0
  248. package/dist/heart/mailbox/mailbox-view.js +197 -0
  249. package/dist/heart/mailbox/readers/agent-machine.js +428 -0
  250. package/dist/heart/mailbox/readers/continuity-readers.js +329 -0
  251. package/dist/heart/mailbox/readers/mail.js +375 -0
  252. package/dist/heart/mailbox/readers/runtime-readers.js +823 -0
  253. package/dist/heart/mailbox/readers/sessions.js +231 -0
  254. package/dist/heart/mailbox/readers/shared.js +111 -0
  255. package/dist/heart/mcp/mcp-server.js +696 -0
  256. package/dist/heart/migrate-config.js +100 -0
  257. package/dist/heart/model-capabilities.js +11 -0
  258. package/dist/heart/orientation-frame.js +345 -0
  259. package/dist/heart/platform.js +81 -0
  260. package/dist/heart/primitives.js +1 -1
  261. package/dist/heart/private-runtime/decision-renderer.js +158 -0
  262. package/dist/heart/private-runtime/index.js +18 -0
  263. package/dist/heart/private-runtime/ledger.js +221 -0
  264. package/dist/heart/private-runtime/policy.js +252 -0
  265. package/dist/heart/private-runtime/types.js +2 -0
  266. package/dist/heart/progress-story.js +1 -1
  267. package/dist/heart/provider-attempt.js +137 -0
  268. package/dist/heart/provider-binding-resolver.js +273 -0
  269. package/dist/heart/provider-credentials.js +449 -0
  270. package/dist/heart/provider-failover.js +311 -0
  271. package/dist/heart/provider-models.js +96 -0
  272. package/dist/heart/provider-ping.js +265 -0
  273. package/dist/heart/provider-readiness-cache.js +119 -0
  274. package/dist/heart/provider-visibility.js +188 -0
  275. package/dist/heart/providers/anthropic-token.js +131 -0
  276. package/dist/heart/providers/anthropic.js +173 -60
  277. package/dist/heart/providers/azure.js +23 -11
  278. package/dist/heart/providers/error-classification.js +127 -0
  279. package/dist/heart/providers/github-copilot.js +34 -38
  280. package/dist/heart/providers/minimax-vlm.js +189 -0
  281. package/dist/heart/providers/minimax.js +26 -8
  282. package/dist/heart/providers/openai-codex-token.js +349 -0
  283. package/dist/heart/providers/openai-codex.js +55 -40
  284. package/dist/heart/providers/openai-compatible.js +177 -0
  285. package/dist/heart/run-ledger.js +247 -0
  286. package/dist/heart/runtime-capability-check.js +170 -0
  287. package/dist/heart/runtime-credentials.js +607 -0
  288. package/dist/heart/runtime-cwd.js +87 -0
  289. package/dist/heart/sense-truth.js +22 -4
  290. package/dist/heart/session-activity.js +92 -24
  291. package/dist/heart/session-events.js +1504 -0
  292. package/dist/heart/session-playback-cli-main.js +5 -0
  293. package/dist/heart/session-playback-cli.js +36 -0
  294. package/dist/heart/session-playback.js +231 -0
  295. package/dist/heart/session-redaction-repair-cli-main.js +31 -0
  296. package/dist/heart/session-redaction-repair.js +552 -0
  297. package/dist/heart/session-stats-cli-main.js +5 -0
  298. package/dist/heart/session-stats.js +183 -0
  299. package/dist/heart/session-transcript.js +133 -0
  300. package/dist/heart/start-of-turn-packet.js +372 -0
  301. package/dist/heart/steward-policy.js +618 -0
  302. package/dist/heart/streaming.js +604 -207
  303. package/dist/heart/structured-output.js +196 -0
  304. package/dist/heart/sync-classification.js +176 -0
  305. package/dist/heart/sync.js +449 -0
  306. package/dist/heart/target-resolution.js +11 -7
  307. package/dist/heart/tempo.js +93 -0
  308. package/dist/heart/temporal-view.js +41 -0
  309. package/dist/heart/timeouts.js +101 -0
  310. package/dist/heart/tool-activity-callbacks.js +59 -0
  311. package/dist/heart/tool-approval.js +382 -0
  312. package/dist/heart/tool-description.js +155 -0
  313. package/dist/heart/tool-friction.js +55 -0
  314. package/dist/heart/tool-loop.js +200 -0
  315. package/dist/heart/turn-context.js +482 -0
  316. package/dist/heart/turn-execution-lease.js +30 -0
  317. package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +6 -5
  318. package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
  319. package/dist/heart/versioning/ouro-path-installer.js +432 -0
  320. package/dist/heart/versioning/ouro-recovery-launcher.js +76 -0
  321. package/dist/heart/versioning/ouro-version-manager.js +409 -0
  322. package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
  323. package/dist/heart/{daemon → versioning}/update-checker.js +6 -1
  324. package/dist/heart/versioning/update-hooks.js +154 -0
  325. package/dist/heart/versioning/version-intent.js +114 -0
  326. package/dist/heart/work-card.js +380 -0
  327. package/dist/mailbox-ui/assets/index-Cyv4mw3Y.js +1 -0
  328. package/dist/mailbox-ui/assets/index-Du_9G9WO.css +1 -0
  329. package/dist/mailbox-ui/assets/vendor-CcN1XpQ9.js +61 -0
  330. package/dist/mailbox-ui/index.html +16 -0
  331. package/dist/mailroom/attention.js +167 -0
  332. package/dist/mailroom/autonomy.js +209 -0
  333. package/dist/mailroom/blob-store.js +889 -0
  334. package/dist/mailroom/body-cache.js +61 -0
  335. package/dist/mailroom/cache-sync-cli.js +58 -0
  336. package/dist/mailroom/core.js +803 -0
  337. package/dist/mailroom/entry.js +160 -0
  338. package/dist/mailroom/file-store.js +568 -0
  339. package/dist/mailroom/hosted-cache-sync.js +384 -0
  340. package/dist/mailroom/mbox-import.js +393 -0
  341. package/dist/mailroom/migration.js +164 -0
  342. package/dist/mailroom/outbound.js +380 -0
  343. package/dist/mailroom/policy.js +263 -0
  344. package/dist/mailroom/reader.js +292 -0
  345. package/dist/mailroom/search-cache.js +513 -0
  346. package/dist/mailroom/search-relevance.js +319 -0
  347. package/dist/mailroom/smtp-ingress.js +176 -0
  348. package/dist/mailroom/source-state.js +176 -0
  349. package/dist/mailroom/thread.js +109 -0
  350. package/dist/mailroom/travel-extract.js +89 -0
  351. package/dist/mind/bundle-manifest.js +24 -2
  352. package/dist/mind/context.js +309 -111
  353. package/dist/mind/desk-section.js +362 -0
  354. package/dist/mind/diary-integrity.js +60 -0
  355. package/dist/mind/{memory.js → diary.js} +68 -77
  356. package/dist/mind/embedding-provider.js +60 -0
  357. package/dist/mind/file-state.js +179 -0
  358. package/dist/mind/{associative-recall.js → note-search.js} +47 -58
  359. package/dist/mind/obligation-steering.js +199 -3
  360. package/dist/mind/pending.js +36 -10
  361. package/dist/mind/prompt-budget.js +479 -0
  362. package/dist/mind/prompt-refresh.js +3 -2
  363. package/dist/mind/prompt.js +1050 -189
  364. package/dist/mind/provenance-trust.js +26 -0
  365. package/dist/mind/record-paths.js +312 -0
  366. package/dist/mind/scrutiny.js +173 -0
  367. package/dist/mind/session-transaction.js +564 -0
  368. package/dist/nerves/cli-logging.js +7 -1
  369. package/dist/nerves/coverage/audit-rules.js +15 -6
  370. package/dist/nerves/coverage/audit.js +28 -2
  371. package/dist/nerves/coverage/cli.js +1 -1
  372. package/dist/nerves/coverage/contract.js +5 -5
  373. package/dist/nerves/coverage/file-completeness.js +139 -5
  374. package/dist/nerves/coverage/run-artifacts.js +55 -35
  375. package/dist/nerves/coverage/source-scanner.js +4 -4
  376. package/dist/nerves/event-buffer.js +111 -0
  377. package/dist/nerves/index.js +293 -9
  378. package/dist/nerves/observation.js +20 -0
  379. package/dist/nerves/redact.js +79 -0
  380. package/dist/nerves/review/cli-main.js +5 -0
  381. package/dist/nerves/review/cli.js +156 -0
  382. package/dist/nerves/review/core.js +159 -0
  383. package/dist/nerves/runtime.js +17 -1
  384. package/dist/repertoire/ado-client.js +15 -56
  385. package/dist/repertoire/ado-semantic.js +16 -10
  386. package/dist/repertoire/api-client.js +97 -0
  387. package/dist/repertoire/bitwarden-store.js +1045 -0
  388. package/dist/repertoire/bundle-templates.js +71 -0
  389. package/dist/repertoire/bw-installer.js +180 -0
  390. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  391. package/dist/repertoire/coding/context-pack.js +331 -0
  392. package/dist/repertoire/coding/feedback.js +174 -32
  393. package/dist/repertoire/coding/index.js +15 -3
  394. package/dist/repertoire/coding/manager.js +159 -10
  395. package/dist/repertoire/coding/spawner.js +58 -11
  396. package/dist/repertoire/coding/tools.js +221 -15
  397. package/dist/repertoire/coding/workbench-client.js +272 -0
  398. package/dist/repertoire/coding/workbench-manager.js +346 -0
  399. package/dist/repertoire/commerce-errors.js +109 -0
  400. package/dist/repertoire/commerce-self-test.js +156 -0
  401. package/dist/repertoire/credential-access.js +178 -0
  402. package/dist/repertoire/desk/classifier.js +362 -0
  403. package/dist/repertoire/duffel-client.js +185 -0
  404. package/dist/repertoire/github-client.js +14 -55
  405. package/dist/repertoire/graph-client.js +11 -52
  406. package/dist/repertoire/guardrails.js +811 -18
  407. package/dist/repertoire/mcp-client.js +44 -3
  408. package/dist/repertoire/mcp-manager.js +427 -139
  409. package/dist/repertoire/mcp-tools.js +124 -0
  410. package/dist/repertoire/plugin-mcp.js +175 -0
  411. package/dist/repertoire/plugins.js +253 -0
  412. package/dist/repertoire/relationship-authorization.js +322 -0
  413. package/dist/repertoire/shell-sessions.js +134 -0
  414. package/dist/repertoire/skills.js +48 -4
  415. package/dist/repertoire/stripe-client.js +131 -0
  416. package/dist/repertoire/tool-arguments.js +170 -0
  417. package/dist/repertoire/tool-results.js +29 -0
  418. package/dist/repertoire/tools-a2a.js +699 -0
  419. package/dist/repertoire/tools-attachments.js +322 -0
  420. package/dist/repertoire/tools-awaiting.js +575 -0
  421. package/dist/repertoire/tools-base.js +77 -1138
  422. package/dist/repertoire/tools-bluebubbles.js +2 -0
  423. package/dist/repertoire/tools-bridge.js +144 -0
  424. package/dist/repertoire/tools-bundle.js +993 -0
  425. package/dist/repertoire/tools-commerce.js +253 -0
  426. package/dist/repertoire/tools-config.js +186 -0
  427. package/dist/repertoire/tools-continuity.js +575 -0
  428. package/dist/repertoire/tools-credential.js +383 -0
  429. package/dist/repertoire/tools-evolution.js +527 -0
  430. package/dist/repertoire/tools-files.js +344 -0
  431. package/dist/repertoire/tools-flight.js +290 -0
  432. package/dist/repertoire/tools-flow.js +119 -0
  433. package/dist/repertoire/tools-github.js +3 -8
  434. package/dist/repertoire/tools-habits.js +103 -0
  435. package/dist/repertoire/tools-mail.js +1828 -0
  436. package/dist/repertoire/tools-notes.js +485 -0
  437. package/dist/repertoire/tools-obligations.js +182 -0
  438. package/dist/repertoire/tools-orientation.js +31 -0
  439. package/dist/repertoire/tools-record.js +482 -0
  440. package/dist/repertoire/tools-rsvp.js +139 -0
  441. package/dist/repertoire/tools-runtime.js +150 -0
  442. package/dist/repertoire/tools-sanctuary-host.js +202 -0
  443. package/dist/repertoire/tools-session.js +1133 -0
  444. package/dist/repertoire/tools-shell.js +149 -0
  445. package/dist/repertoire/tools-steward-policy.js +119 -0
  446. package/dist/repertoire/tools-stripe.js +224 -0
  447. package/dist/repertoire/tools-surface.js +369 -0
  448. package/dist/repertoire/tools-teams.js +12 -39
  449. package/dist/repertoire/tools-telegram-contacts.js +37 -0
  450. package/dist/repertoire/tools-travel.js +125 -0
  451. package/dist/repertoire/tools-trip.js +982 -0
  452. package/dist/repertoire/tools-unraid.js +531 -0
  453. package/dist/repertoire/tools-user-profile.js +146 -0
  454. package/dist/repertoire/tools-vault.js +40 -0
  455. package/dist/repertoire/tools-voice.js +145 -0
  456. package/dist/repertoire/tools.js +494 -148
  457. package/dist/repertoire/travel-api-client.js +360 -0
  458. package/dist/repertoire/unraid-client.js +155 -0
  459. package/dist/repertoire/unraid-restart.js +339 -0
  460. package/dist/repertoire/user-profile.js +131 -0
  461. package/dist/repertoire/vault-setup.js +246 -0
  462. package/dist/repertoire/vault-unlock.js +628 -0
  463. package/dist/rsvp/aisleplanner-client.js +354 -0
  464. package/dist/rsvp/cli.js +926 -0
  465. package/dist/rsvp/config.js +327 -0
  466. package/dist/rsvp/cutover.js +433 -0
  467. package/dist/rsvp/diagnostics.js +232 -0
  468. package/dist/rsvp/diff-renderer.js +176 -0
  469. package/dist/rsvp/habit-policy.js +110 -0
  470. package/dist/rsvp/habit-stage.js +123 -0
  471. package/dist/rsvp/incident-bundle.js +97 -0
  472. package/dist/rsvp/migration.js +204 -0
  473. package/dist/rsvp/native-habit-runner.js +630 -0
  474. package/dist/rsvp/outbound-state.js +628 -0
  475. package/dist/rsvp/query.js +118 -0
  476. package/dist/rsvp/replay.js +233 -0
  477. package/dist/rsvp/snapshot.js +232 -0
  478. package/dist/rsvp/spend-ledger.js +175 -0
  479. package/dist/scripts/claude-code-hook.js +41 -0
  480. package/dist/scripts/claude-code-stop-hook.js +47 -0
  481. package/dist/senses/a2a-entry.js +115 -0
  482. package/dist/senses/acp-server.js +386 -0
  483. package/dist/senses/attention-queue.js +186 -0
  484. package/dist/senses/await-turn-message.js +58 -0
  485. package/dist/senses/bluebubbles/active-turns.js +216 -0
  486. package/dist/senses/bluebubbles/attachment-cache.js +53 -0
  487. package/dist/senses/bluebubbles/attachment-download.js +137 -0
  488. package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +355 -40
  489. package/dist/senses/bluebubbles/context-packet.js +207 -0
  490. package/dist/senses/bluebubbles/context-smoke.js +144 -0
  491. package/dist/senses/bluebubbles/entry.js +90 -0
  492. package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +21 -3
  493. package/dist/senses/bluebubbles/index.js +3841 -0
  494. package/dist/senses/bluebubbles/latest-turn.js +311 -0
  495. package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -71
  496. package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +159 -28
  497. package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +24 -13
  498. package/dist/senses/bluebubbles/outbound-state.js +308 -0
  499. package/dist/senses/bluebubbles/processed-log.js +133 -0
  500. package/dist/senses/bluebubbles/reaction-policy.js +47 -0
  501. package/dist/senses/bluebubbles/replay.js +284 -0
  502. package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +30 -2
  503. package/dist/senses/bluebubbles/semantic-receipts.js +1986 -0
  504. package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
  505. package/dist/senses/bluebubbles/webhook-registration.js +228 -0
  506. package/dist/senses/bluebubbles-meta-guard.js +39 -0
  507. package/dist/senses/cli/bracketed-paste.js +82 -0
  508. package/dist/senses/cli/image-paste.js +287 -0
  509. package/dist/senses/cli/image-ref-navigation.js +75 -0
  510. package/dist/senses/cli/ink-app.js +156 -0
  511. package/dist/senses/cli/inline-diff.js +64 -0
  512. package/dist/senses/cli/input-keys.js +174 -0
  513. package/dist/senses/cli/kill-ring.js +86 -0
  514. package/dist/senses/cli/message-list.js +51 -0
  515. package/dist/senses/cli/ouro-tui.js +607 -0
  516. package/dist/senses/cli/spinner-imperative.js +135 -0
  517. package/dist/senses/cli/spinner.js +101 -0
  518. package/dist/senses/cli/status-line.js +60 -0
  519. package/dist/senses/cli/streaming-markdown.js +526 -0
  520. package/dist/senses/cli/tool-display.js +85 -0
  521. package/dist/senses/cli/tool-render.js +85 -0
  522. package/dist/senses/cli/tui-store.js +241 -0
  523. package/dist/senses/cli/virtual-list.js +35 -0
  524. package/dist/senses/cli-entry.js +60 -8
  525. package/dist/senses/cli.js +604 -320
  526. package/dist/senses/commands.js +66 -3
  527. package/dist/senses/context-packet-ledger.js +371 -0
  528. package/dist/senses/context-packets.js +154 -0
  529. package/dist/senses/habit-lifecycle-guard.js +24 -0
  530. package/dist/senses/habit-turn-message.js +160 -0
  531. package/dist/senses/ingress-evidence.js +2 -0
  532. package/dist/senses/mail-entry.js +66 -0
  533. package/dist/senses/mail.js +524 -0
  534. package/dist/senses/pipeline.js +1115 -204
  535. package/dist/senses/private-runtime-worker.js +859 -0
  536. package/dist/senses/private-runtime.js +1517 -0
  537. package/dist/senses/proactive-content-guard.js +51 -0
  538. package/dist/senses/root-host-approval-port.js +345 -0
  539. package/dist/senses/root-host-approval-runtime.js +393 -0
  540. package/dist/senses/sanctuary-authority-resident.js +102 -0
  541. package/dist/senses/sanctuary-download-credit-presentation.js +31 -0
  542. package/dist/senses/sanctuary-full-visibility-contract.js +302 -0
  543. package/dist/senses/sanctuary-grounding.js +118 -0
  544. package/dist/senses/sanctuary-health-acceptance-probe-entry.js +12 -0
  545. package/dist/senses/sanctuary-health-acceptance-probe.js +774 -0
  546. package/dist/senses/sanctuary-health-runner.js +100 -0
  547. package/dist/senses/sanctuary-health.js +408 -0
  548. package/dist/senses/sanctuary-install-state-contract.js +126 -0
  549. package/dist/senses/sanctuary-interactive-control.js +410 -0
  550. package/dist/senses/sanctuary-media-catalog-contract.js +297 -0
  551. package/dist/senses/sanctuary-media-optimization.js +514 -0
  552. package/dist/senses/sanctuary-runtime.js +340 -0
  553. package/dist/senses/sanctuary-sab.js +85 -0
  554. package/dist/senses/sanctuary-storage-optimization-contract.js +32 -0
  555. package/dist/senses/shared-turn.js +772 -0
  556. package/dist/senses/surface-tool.js +109 -0
  557. package/dist/senses/teams-entry.js +60 -8
  558. package/dist/senses/teams.js +519 -218
  559. package/dist/senses/telegram-admission.js +718 -0
  560. package/dist/senses/telegram-approval-runtime.js +793 -0
  561. package/dist/senses/telegram-attachments.js +186 -0
  562. package/dist/senses/telegram-audit-ledger.js +220 -0
  563. package/dist/senses/telegram-authority-transport.js +231 -0
  564. package/dist/senses/telegram-client.js +1749 -0
  565. package/dist/senses/telegram-effect-adapter.js +896 -0
  566. package/dist/senses/telegram-entry.js +83 -0
  567. package/dist/senses/telegram.js +2324 -0
  568. package/dist/senses/trust-gate.js +104 -9
  569. package/dist/senses/voice/audio-playback.js +237 -0
  570. package/dist/senses/voice/audio-routing.js +119 -0
  571. package/dist/senses/voice/elevenlabs.js +202 -0
  572. package/dist/senses/voice/floor-control.js +431 -0
  573. package/dist/senses/voice/floor-controller.js +115 -0
  574. package/dist/senses/voice/golden-path.js +116 -0
  575. package/dist/senses/voice/index.js +29 -0
  576. package/dist/senses/voice/meeting.js +113 -0
  577. package/dist/senses/voice/outbound.js +190 -0
  578. package/dist/senses/voice/phone.js +33 -0
  579. package/dist/senses/voice/playback.js +139 -0
  580. package/dist/senses/voice/realtime-eval.js +496 -0
  581. package/dist/senses/voice/realtime-trace.js +531 -0
  582. package/dist/senses/voice/transcript.js +70 -0
  583. package/dist/senses/voice/turn.js +191 -0
  584. package/dist/senses/voice/twilio-phone-runtime.js +807 -0
  585. package/dist/senses/voice/twilio-phone.js +5031 -0
  586. package/dist/senses/voice/types.js +2 -0
  587. package/dist/senses/voice/whisper.js +161 -0
  588. package/dist/senses/voice-entry.js +81 -0
  589. package/dist/senses/voice-realtime-eval-command.js +99 -0
  590. package/dist/senses/voice-realtime-eval-entry.js +21 -0
  591. package/dist/senses/voice-twilio-entry.js +87 -0
  592. package/dist/trips/core.js +138 -0
  593. package/dist/trips/store.js +265 -0
  594. package/dist/util/frontmatter.js +69 -0
  595. package/npm-shrinkwrap.json +8138 -0
  596. package/package.json +72 -13
  597. package/skills/agent-commerce.md +113 -0
  598. package/skills/browser-navigation.md +117 -0
  599. package/skills/commerce-setup-guide.md +116 -0
  600. package/skills/commerce-setup.md +84 -0
  601. package/skills/configure-dev-tools.md +99 -0
  602. package/skills/travel-planning.md +138 -0
  603. package/dist/heart/daemon/auth-flow.js +0 -430
  604. package/dist/heart/daemon/ouro-path-installer.js +0 -260
  605. package/dist/heart/daemon/ouro-version-manager.js +0 -171
  606. package/dist/heart/daemon/update-hooks.js +0 -138
  607. package/dist/heart/obligations.js +0 -191
  608. package/dist/heart/safe-workspace.js +0 -228
  609. package/dist/heart/session-recall.js +0 -116
  610. package/dist/mind/friends/channel.js +0 -84
  611. package/dist/mind/friends/group-context.js +0 -144
  612. package/dist/mind/friends/resolver.js +0 -84
  613. package/dist/mind/friends/store-file.js +0 -190
  614. package/dist/mind/friends/store.js +0 -4
  615. package/dist/mind/friends/tokens.js +0 -26
  616. package/dist/mind/friends/trust-explanation.js +0 -74
  617. package/dist/mind/friends/types.js +0 -29
  618. package/dist/repertoire/tasks/board.js +0 -134
  619. package/dist/repertoire/tasks/index.js +0 -224
  620. package/dist/repertoire/tasks/lifecycle.js +0 -80
  621. package/dist/repertoire/tasks/middleware.js +0 -65
  622. package/dist/repertoire/tasks/parser.js +0 -173
  623. package/dist/repertoire/tasks/scanner.js +0 -132
  624. package/dist/repertoire/tasks/transitions.js +0 -144
  625. package/dist/senses/bluebubbles-entry.js +0 -13
  626. package/dist/senses/bluebubbles.js +0 -1181
  627. package/dist/senses/debug-activity.js +0 -154
  628. package/dist/senses/inner-dialog-worker.js +0 -90
  629. package/dist/senses/inner-dialog.js +0 -525
  630. package/subagents/README.md +0 -7
  631. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  632. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  633. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  634. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  635. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  636. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
  637. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  638. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  639. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
  640. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  641. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  642. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
  643. /package/dist/{repertoire/tasks/types.js → heart/attachments/sources/adapter.js} +0 -0
  644. /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
  645. /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
  646. /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
  647. /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
@@ -1,2352 +1,32 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ensureDaemonRunning = ensureDaemonRunning;
37
- exports.listGithubCopilotModels = listGithubCopilotModels;
38
- exports.pingGithubCopilotModel = pingGithubCopilotModel;
39
- exports.parseOuroCommand = parseOuroCommand;
40
- exports.readFirstBundleMetaVersion = readFirstBundleMetaVersion;
41
- exports.discoverExistingCredentials = discoverExistingCredentials;
42
- exports.createDefaultOuroCliDeps = createDefaultOuroCliDeps;
43
- exports.runOuroCli = runOuroCli;
44
- const child_process_1 = require("child_process");
45
- const crypto_1 = require("crypto");
46
- const fs = __importStar(require("fs"));
47
- const os = __importStar(require("os"));
48
- const path = __importStar(require("path"));
49
- const identity_1 = require("../identity");
50
- const runtime_1 = require("../../nerves/runtime");
51
- const store_file_1 = require("../../mind/friends/store-file");
52
- const types_1 = require("../../mind/friends/types");
53
- const ouro_uti_1 = require("./ouro-uti");
54
- const ouro_path_installer_1 = require("./ouro-path-installer");
55
- const ouro_version_manager_1 = require("./ouro-version-manager");
56
- const skill_management_installer_1 = require("./skill-management-installer");
57
- const hatch_flow_1 = require("./hatch-flow");
58
- const specialist_orchestrator_1 = require("./specialist-orchestrator");
59
- const specialist_prompt_1 = require("./specialist-prompt");
60
- const specialist_tools_1 = require("./specialist-tools");
61
- const runtime_metadata_1 = require("./runtime-metadata");
62
- const runtime_mode_1 = require("./runtime-mode");
63
- const daemon_runtime_sync_1 = require("./daemon-runtime-sync");
64
- const agent_discovery_1 = require("./agent-discovery");
65
- const update_hooks_1 = require("./update-hooks");
66
- const bundle_meta_1 = require("./hooks/bundle-meta");
67
- const bundle_manifest_1 = require("../../mind/bundle-manifest");
68
- const tasks_1 = require("../../repertoire/tasks");
69
- const thoughts_1 = require("./thoughts");
70
- const ouro_bot_global_installer_1 = require("./ouro-bot-global-installer");
71
- const launchd_1 = require("./launchd");
72
- const socket_client_1 = require("./socket-client");
73
- const session_activity_1 = require("../session-activity");
74
- const auth_flow_1 = require("./auth-flow");
75
- function stringField(value) {
76
- return typeof value === "string" ? value : null;
77
- }
78
- function numberField(value) {
79
- return typeof value === "number" && Number.isFinite(value) ? value : null;
80
- }
81
- function booleanField(value) {
82
- return typeof value === "boolean" ? value : null;
83
- }
84
- function parseStatusPayload(data) {
85
- if (!data || typeof data !== "object" || Array.isArray(data))
86
- return null;
87
- const raw = data;
88
- const overview = raw.overview;
89
- const senses = raw.senses;
90
- const workers = raw.workers;
91
- if (!overview || typeof overview !== "object" || Array.isArray(overview))
92
- return null;
93
- if (!Array.isArray(senses) || !Array.isArray(workers))
94
- return null;
95
- const parsedOverview = {
96
- daemon: stringField(overview.daemon) ?? "unknown",
97
- health: stringField(overview.health) ?? "unknown",
98
- socketPath: stringField(overview.socketPath) ?? "unknown",
99
- version: stringField(overview.version) ?? "unknown",
100
- lastUpdated: stringField(overview.lastUpdated) ?? "unknown",
101
- repoRoot: stringField(overview.repoRoot) ?? "unknown",
102
- configFingerprint: stringField(overview.configFingerprint) ?? "unknown",
103
- workerCount: numberField(overview.workerCount) ?? 0,
104
- senseCount: numberField(overview.senseCount) ?? 0,
105
- entryPath: stringField(overview.entryPath) ?? "unknown",
106
- mode: stringField(overview.mode) ?? "unknown",
107
- };
108
- const parsedSenses = senses.map((entry) => {
109
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
110
- return null;
111
- const row = entry;
112
- const agent = stringField(row.agent);
113
- const sense = stringField(row.sense);
114
- const status = stringField(row.status);
115
- const detail = stringField(row.detail);
116
- const enabled = booleanField(row.enabled);
117
- if (!agent || !sense || !status || detail === null || enabled === null)
118
- return null;
119
- return {
120
- agent,
121
- sense,
122
- label: stringField(row.label) ?? undefined,
123
- enabled,
124
- status,
125
- detail,
126
- };
127
- });
128
- const parsedWorkers = workers.map((entry) => {
129
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
130
- return null;
131
- const row = entry;
132
- const agent = stringField(row.agent);
133
- const worker = stringField(row.worker);
134
- const status = stringField(row.status);
135
- const restartCount = numberField(row.restartCount);
136
- const hasPid = Object.prototype.hasOwnProperty.call(row, "pid");
137
- const pid = row.pid === null ? null : numberField(row.pid);
138
- const pidInvalid = !hasPid || (row.pid !== null && pid === null);
139
- if (!agent || !worker || !status || restartCount === null || pidInvalid)
140
- return null;
141
- return {
142
- agent,
143
- worker,
144
- status,
145
- pid,
146
- restartCount,
147
- };
148
- });
149
- if (parsedSenses.some((row) => row === null) || parsedWorkers.some((row) => row === null))
150
- return null;
151
- return {
152
- overview: parsedOverview,
153
- senses: parsedSenses,
154
- workers: parsedWorkers,
155
- };
156
- }
157
- function humanizeSenseName(sense, label) {
158
- if (label)
159
- return label;
160
- if (sense === "cli")
161
- return "CLI";
162
- if (sense === "bluebubbles")
163
- return "BlueBubbles";
164
- if (sense === "teams")
165
- return "Teams";
166
- return sense;
167
- }
168
- function formatTable(headers, rows) {
169
- const widths = headers.map((header, index) => Math.max(header.length, ...rows.map((row) => row[index].length)));
170
- const renderRow = (row) => `| ${row.map((cell, index) => cell.padEnd(widths[index])).join(" | ")} |`;
171
- const divider = `|-${widths.map((width) => "-".repeat(width)).join("-|-")}-|`;
172
- return [
173
- renderRow(headers),
174
- divider,
175
- ...rows.map(renderRow),
176
- ].join("\n");
177
- }
178
- function formatDaemonStatusOutput(response, fallback) {
179
- const payload = parseStatusPayload(response.data);
180
- if (!payload)
181
- return fallback;
182
- const overviewRows = [
183
- ["Daemon", payload.overview.daemon],
184
- ["Socket", payload.overview.socketPath],
185
- ["Version", payload.overview.version],
186
- ["Last Updated", payload.overview.lastUpdated],
187
- ["Entry Path", payload.overview.entryPath],
188
- ["Mode", payload.overview.mode],
189
- ["Workers", String(payload.overview.workerCount)],
190
- ["Senses", String(payload.overview.senseCount)],
191
- ["Health", payload.overview.health],
192
- ];
193
- const senseRows = payload.senses.map((row) => [
194
- row.agent,
195
- humanizeSenseName(row.sense, row.label),
196
- row.enabled ? "ON" : "OFF",
197
- row.status,
198
- row.detail,
199
- ]);
200
- const workerRows = payload.workers.map((row) => [
201
- row.agent,
202
- row.worker,
203
- row.status,
204
- row.pid === null ? "n/a" : String(row.pid),
205
- String(row.restartCount),
206
- ]);
207
- return [
208
- "Overview",
209
- formatTable(["Item", "Value"], overviewRows),
210
- "",
211
- "Senses",
212
- formatTable(["Agent", "Sense", "Enabled", "State", "Detail"], senseRows),
213
- "",
214
- "Workers",
215
- formatTable(["Agent", "Worker", "State", "PID", "Restarts"], workerRows),
216
- ].join("\n");
217
- }
218
- async function ensureDaemonRunning(deps) {
219
- const alive = await deps.checkSocketAlive(deps.socketPath);
220
- if (alive) {
221
- const localRuntime = (0, runtime_metadata_1.getRuntimeMetadata)();
222
- let runningRuntimePromise = null;
223
- const fetchRunningRuntimeMetadata = async () => {
224
- runningRuntimePromise ??= (async () => {
225
- const status = await deps.sendCommand(deps.socketPath, { kind: "daemon.status" });
226
- const payload = parseStatusPayload(status.data);
227
- return {
228
- version: payload?.overview.version ?? "unknown",
229
- lastUpdated: payload?.overview.lastUpdated ?? "unknown",
230
- repoRoot: payload?.overview.repoRoot ?? "unknown",
231
- configFingerprint: payload?.overview.configFingerprint ?? "unknown",
232
- };
233
- })();
234
- return runningRuntimePromise;
235
- };
236
- return (0, daemon_runtime_sync_1.ensureCurrentDaemonRuntime)({
237
- socketPath: deps.socketPath,
238
- localVersion: localRuntime.version,
239
- localLastUpdated: localRuntime.lastUpdated,
240
- localRepoRoot: localRuntime.repoRoot,
241
- localConfigFingerprint: localRuntime.configFingerprint,
242
- fetchRunningVersion: async () => (await fetchRunningRuntimeMetadata()).version,
243
- fetchRunningRuntimeMetadata,
244
- stopDaemon: async () => {
245
- await deps.sendCommand(deps.socketPath, { kind: "daemon.stop" });
246
- },
247
- cleanupStaleSocket: deps.cleanupStaleSocket,
248
- startDaemonProcess: deps.startDaemonProcess,
249
- });
250
- }
251
- deps.cleanupStaleSocket(deps.socketPath);
252
- const started = await deps.startDaemonProcess(deps.socketPath);
253
- return {
254
- alreadyRunning: false,
255
- message: `daemon started (pid ${started.pid ?? "unknown"})`,
256
- };
257
- }
258
- /**
259
- * Extract `--agent <name>` from an args array, returning the agent name and
260
- * the remaining args with the flag pair removed.
261
- */
262
- function extractAgentFlag(args) {
263
- const idx = args.indexOf("--agent");
264
- if (idx === -1 || idx + 1 >= args.length)
265
- return { rest: args };
266
- const agent = args[idx + 1];
267
- const rest = [...args.slice(0, idx), ...args.slice(idx + 2)];
268
- return { agent, rest };
269
- }
270
- function usage() {
271
- return [
272
- "Usage:",
273
- " ouro [up]",
274
- " ouro stop|down|status|logs|hatch",
275
- " ouro -v|--version",
276
- " ouro config model --agent <name> <model-name>",
277
- " ouro config models --agent <name>",
278
- " ouro auth --agent <name> [--provider <provider>]",
279
- " ouro auth verify --agent <name> [--provider <provider>]",
280
- " ouro auth switch --agent <name> --provider <provider>",
281
- " ouro chat <agent>",
282
- " ouro msg --to <agent> [--session <id>] [--task <ref>] <message>",
283
- " ouro poke <agent> --task <task-id>",
284
- " ouro link <agent> --friend <id> --provider <provider> --external-id <external-id>",
285
- " ouro task board [<status>] [--agent <name>]",
286
- " ouro task create <title> [--type <type>] [--agent <name>]",
287
- " ouro task update <id> <status> [--agent <name>]",
288
- " ouro task show <id> [--agent <name>]",
289
- " ouro task actionable|deps|sessions [--agent <name>]",
290
- " ouro reminder create <title> --body <body> [--at <iso>] [--cadence <interval>] [--category <category>] [--agent <name>]",
291
- " ouro friend list [--agent <name>]",
292
- " ouro friend show <id> [--agent <name>]",
293
- " ouro friend create --name <name> [--trust <level>] [--agent <name>]",
294
- " ouro friend update <id> --trust <level> [--agent <name>]",
295
- " ouro thoughts [--last <n>] [--json] [--follow] [--agent <name>]",
296
- " ouro friend link <agent> --friend <id> --provider <p> --external-id <eid>",
297
- " ouro friend unlink <agent> --friend <id> --provider <p> --external-id <eid>",
298
- " ouro whoami [--agent <name>]",
299
- " ouro session list [--agent <name>]",
300
- " ouro mcp list",
301
- " ouro mcp call <server> <tool> [--args '{...}']",
302
- " ouro rollback [<version>]",
303
- " ouro versions",
304
- ].join("\n");
305
- }
306
- function formatVersionOutput() {
307
- return (0, runtime_metadata_1.getRuntimeMetadata)().version;
308
- }
309
- function buildStoppedStatusPayload(socketPath) {
310
- const metadata = (0, runtime_metadata_1.getRuntimeMetadata)();
311
- const repoRoot = (0, identity_1.getRepoRoot)();
312
- return {
313
- overview: {
314
- daemon: "stopped",
315
- health: "warn",
316
- socketPath,
317
- version: metadata.version,
318
- lastUpdated: metadata.lastUpdated,
319
- repoRoot: metadata.repoRoot,
320
- configFingerprint: metadata.configFingerprint,
321
- workerCount: 0,
322
- senseCount: 0,
323
- entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
324
- mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
325
- },
326
- senses: [],
327
- workers: [],
328
- };
329
- }
330
- function daemonUnavailableStatusOutput(socketPath) {
331
- return [
332
- formatDaemonStatusOutput({
333
- ok: true,
334
- summary: "daemon not running",
335
- data: buildStoppedStatusPayload(socketPath),
336
- }, "daemon not running"),
337
- "",
338
- "daemon not running; run `ouro up`",
339
- ].join("\n");
340
- }
341
- function isDaemonUnavailableError(error) {
342
- const code = typeof error === "object" && error !== null && "code" in error
343
- ? String(error.code ?? "")
344
- : "";
345
- return code === "ENOENT" || code === "ECONNREFUSED";
346
- }
347
- function parseMessageCommand(args) {
348
- let to;
349
- let sessionId;
350
- let taskRef;
351
- const messageParts = [];
352
- for (let i = 0; i < args.length; i += 1) {
353
- const token = args[i];
354
- if (token === "--to") {
355
- to = args[i + 1];
356
- i += 1;
357
- continue;
358
- }
359
- if (token === "--session") {
360
- sessionId = args[i + 1];
361
- i += 1;
362
- continue;
363
- }
364
- if (token === "--task") {
365
- taskRef = args[i + 1];
366
- i += 1;
367
- continue;
368
- }
369
- messageParts.push(token);
370
- }
371
- const content = messageParts.join(" ").trim();
372
- if (!to || !content)
373
- throw new Error(`Usage\n${usage()}`);
374
- return {
375
- kind: "message.send",
376
- from: "ouro-cli",
377
- to,
378
- content,
379
- sessionId,
380
- taskRef,
381
- };
382
- }
383
- function parsePokeCommand(args) {
384
- const agent = args[0];
385
- if (!agent)
386
- throw new Error(`Usage\n${usage()}`);
387
- let taskId;
388
- for (let i = 1; i < args.length; i += 1) {
389
- if (args[i] === "--task") {
390
- taskId = args[i + 1];
391
- i += 1;
392
- }
393
- }
394
- if (!taskId)
395
- throw new Error(`Usage\n${usage()}`);
396
- return { kind: "task.poke", agent, taskId };
397
- }
398
- function parseLinkCommand(args, kind = "friend.link") {
399
- const agent = args[0];
400
- if (!agent)
401
- throw new Error(`Usage\n${usage()}`);
402
- let friendId;
403
- let providerRaw;
404
- let externalId;
405
- for (let i = 1; i < args.length; i += 1) {
406
- const token = args[i];
407
- if (token === "--friend") {
408
- friendId = args[i + 1];
409
- i += 1;
410
- continue;
411
- }
412
- if (token === "--provider") {
413
- providerRaw = args[i + 1];
414
- i += 1;
415
- continue;
416
- }
417
- if (token === "--external-id") {
418
- externalId = args[i + 1];
419
- i += 1;
420
- continue;
421
- }
422
- }
423
- if (!friendId || !providerRaw || !externalId) {
424
- throw new Error(`Usage\n${usage()}`);
425
- }
426
- if (!(0, types_1.isIdentityProvider)(providerRaw)) {
427
- throw new Error(`Unknown identity provider '${providerRaw}'. Use aad|local|teams-conversation.`);
428
- }
429
- return {
430
- kind,
431
- agent,
432
- friendId,
433
- provider: providerRaw,
434
- externalId,
435
- };
436
- }
437
- function isAgentProvider(value) {
438
- return value === "azure" || value === "anthropic" || value === "minimax" || value === "openai-codex" || value === "github-copilot";
439
- }
440
- /* v8 ignore start -- hasStoredCredentials: per-provider branches tested via auth switch tests @preserve */
441
- function hasStoredCredentials(provider, providerSecrets) {
442
- if (provider === "anthropic")
443
- return !!providerSecrets.setupToken;
444
- if (provider === "openai-codex")
445
- return !!providerSecrets.oauthAccessToken;
446
- if (provider === "github-copilot")
447
- return !!providerSecrets.githubToken;
448
- if (provider === "minimax")
449
- return !!providerSecrets.apiKey;
450
- // azure
451
- return !!providerSecrets.endpoint && !!providerSecrets.apiKey;
452
- }
453
- /* v8 ignore stop */
454
- /* v8 ignore start -- verifyProviderCredentials: per-provider branches tested via auth verify tests @preserve */
455
- async function verifyProviderCredentials(provider, providers, fetchImpl = fetch) {
456
- const p = providers[provider];
457
- if (!p)
458
- return "not configured";
459
- if (provider === "anthropic") {
460
- const token = p.setupToken || "";
461
- if (!token)
462
- return "failed (no token)";
463
- if (token.startsWith("sk-ant-"))
464
- return "ok";
465
- return "failed (invalid token format)";
466
- }
467
- if (provider === "openai-codex") {
468
- const token = p.oauthAccessToken || "";
469
- return token ? "ok" : "failed (no token)";
470
- }
471
- if (provider === "github-copilot") {
472
- const token = p.githubToken || "";
473
- if (!token)
474
- return "failed (no token)";
475
- try {
476
- const response = await fetchImpl("https://api.github.com/copilot_internal/user", {
477
- headers: { Authorization: `Bearer ${token}` },
478
- });
479
- return response.ok ? "ok" : `failed (HTTP ${response.status})`;
480
- }
481
- catch (error) {
482
- return `failed (${error.message})`;
483
- }
484
- }
485
- if (provider === "minimax") {
486
- const apiKey = p.apiKey || "";
487
- return apiKey ? "ok" : "failed (no api key)";
488
- }
489
- // azure
490
- const endpoint = p.endpoint || "";
491
- const apiKey = p.apiKey || "";
492
- if (!endpoint)
493
- return "failed (no endpoint)";
494
- if (!apiKey)
495
- return "failed (no api key)";
496
- return "ok";
497
- }
498
- async function listGithubCopilotModels(baseUrl, token, fetchImpl = fetch) {
499
- const url = `${baseUrl.replace(/\/+$/, "")}/models`;
500
- const response = await fetchImpl(url, {
501
- headers: { Authorization: `Bearer ${token}` },
502
- });
503
- if (!response.ok) {
504
- throw new Error(`model listing failed (HTTP ${response.status})`);
505
- }
506
- const body = await response.json();
507
- /* v8 ignore start -- response shape handling: tested via config-models.test.ts @preserve */
508
- const items = Array.isArray(body) ? body : (body?.data ?? []);
509
- return items.map((item) => {
510
- const rec = item;
511
- const capabilities = Array.isArray(rec.capabilities)
512
- ? rec.capabilities.filter((c) => typeof c === "string")
513
- : undefined;
514
- return {
515
- id: String(rec.id ?? rec.name ?? ""),
516
- name: String(rec.name ?? rec.id ?? ""),
517
- ...(capabilities ? { capabilities } : {}),
518
- };
519
- });
520
- /* v8 ignore stop */
521
- }
522
- async function pingGithubCopilotModel(baseUrl, token, model, fetchImpl = fetch) {
523
- const base = baseUrl.replace(/\/+$/, "");
524
- const isClaude = model.startsWith("claude");
525
- const url = isClaude ? `${base}/chat/completions` : `${base}/responses`;
526
- const body = isClaude
527
- ? JSON.stringify({ model, messages: [{ role: "user", content: "ping" }], max_tokens: 1 })
528
- : JSON.stringify({ model, input: "ping", max_output_tokens: 16 });
529
- try {
530
- const response = await fetchImpl(url, {
531
- method: "POST",
532
- headers: {
533
- Authorization: `Bearer ${token}`,
534
- "Content-Type": "application/json",
535
- },
536
- body,
537
- });
538
- if (response.ok)
539
- return { ok: true };
540
- let detail = `HTTP ${response.status}`;
541
- try {
542
- const json = await response.json();
543
- /* v8 ignore start -- error format parsing: all branches tested via config-models.test.ts @preserve */
544
- if (typeof json.error === "string")
545
- detail = json.error;
546
- else if (typeof json.error === "object" && json.error !== null) {
547
- const errObj = json.error;
548
- if (typeof errObj.message === "string")
549
- detail = errObj.message;
550
- }
551
- else if (typeof json.message === "string")
552
- detail = json.message;
553
- /* v8 ignore stop */
554
- }
555
- catch {
556
- // response body not JSON — keep HTTP status
557
- }
558
- return { ok: false, error: detail };
559
- }
560
- catch (err) {
561
- /* v8 ignore next -- defensive: fetch errors are always Error instances @preserve */
562
- return { ok: false, error: err instanceof Error ? err.message : String(err) };
563
- }
564
- }
565
- function parseHatchCommand(args) {
566
- let agentName;
567
- let humanName;
568
- let providerRaw;
569
- let migrationPath;
570
- const credentials = {};
571
- for (let i = 0; i < args.length; i += 1) {
572
- const token = args[i];
573
- if (token === "--agent") {
574
- agentName = args[i + 1];
575
- i += 1;
576
- continue;
577
- }
578
- if (token === "--human") {
579
- humanName = args[i + 1];
580
- i += 1;
581
- continue;
582
- }
583
- if (token === "--provider") {
584
- providerRaw = args[i + 1];
585
- i += 1;
586
- continue;
587
- }
588
- if (token === "--setup-token") {
589
- credentials.setupToken = args[i + 1];
590
- i += 1;
591
- continue;
592
- }
593
- if (token === "--oauth-token") {
594
- credentials.oauthAccessToken = args[i + 1];
595
- i += 1;
596
- continue;
597
- }
598
- if (token === "--api-key") {
599
- credentials.apiKey = args[i + 1];
600
- i += 1;
601
- continue;
602
- }
603
- if (token === "--endpoint") {
604
- credentials.endpoint = args[i + 1];
605
- i += 1;
606
- continue;
607
- }
608
- if (token === "--deployment") {
609
- credentials.deployment = args[i + 1];
610
- i += 1;
611
- continue;
612
- }
613
- if (token === "--migration-path") {
614
- migrationPath = args[i + 1];
615
- i += 1;
616
- continue;
617
- }
618
- }
619
- if (providerRaw && !isAgentProvider(providerRaw)) {
620
- throw new Error("Unknown provider. Use azure|anthropic|minimax|openai-codex|github-copilot.");
621
- }
622
- const provider = providerRaw && isAgentProvider(providerRaw) ? providerRaw : undefined;
623
- return {
624
- kind: "hatch.start",
625
- agentName,
626
- humanName,
627
- provider,
628
- credentials: Object.keys(credentials).length > 0 ? credentials : undefined,
629
- migrationPath,
630
- };
631
- }
632
- function parseTaskCommand(args) {
633
- const { agent, rest: cleaned } = extractAgentFlag(args);
634
- const [sub, ...rest] = cleaned;
635
- if (!sub)
636
- throw new Error(`Usage\n${usage()}`);
637
- if (sub === "board") {
638
- const status = rest[0];
639
- return status
640
- ? { kind: "task.board", status, ...(agent ? { agent } : {}) }
641
- : { kind: "task.board", ...(agent ? { agent } : {}) };
642
- }
643
- if (sub === "create") {
644
- const title = rest[0];
645
- if (!title)
646
- throw new Error(`Usage\n${usage()}`);
647
- let type;
648
- for (let i = 1; i < rest.length; i++) {
649
- if (rest[i] === "--type" && rest[i + 1]) {
650
- type = rest[i + 1];
651
- i += 1;
652
- }
653
- }
654
- return type
655
- ? { kind: "task.create", title, type, ...(agent ? { agent } : {}) }
656
- : { kind: "task.create", title, ...(agent ? { agent } : {}) };
657
- }
658
- if (sub === "update") {
659
- const id = rest[0];
660
- const status = rest[1];
661
- if (!id || !status)
662
- throw new Error(`Usage\n${usage()}`);
663
- return { kind: "task.update", id, status, ...(agent ? { agent } : {}) };
664
- }
665
- if (sub === "show") {
666
- const id = rest[0];
667
- if (!id)
668
- throw new Error(`Usage\n${usage()}`);
669
- return { kind: "task.show", id, ...(agent ? { agent } : {}) };
670
- }
671
- if (sub === "actionable")
672
- return { kind: "task.actionable", ...(agent ? { agent } : {}) };
673
- if (sub === "deps")
674
- return { kind: "task.deps", ...(agent ? { agent } : {}) };
675
- if (sub === "sessions")
676
- return { kind: "task.sessions", ...(agent ? { agent } : {}) };
677
- throw new Error(`Usage\n${usage()}`);
678
- }
679
- function parseAuthCommand(args) {
680
- const first = args[0];
681
- // Support both positional (`auth switch`) and flag (`auth --switch`) forms
682
- if (first === "verify" || first === "switch" || first === "--verify" || first === "--switch") {
683
- const subcommand = first.replace(/^--/, "");
684
- const { agent, rest } = extractAgentFlag(args.slice(1));
685
- let provider;
686
- /* v8 ignore start -- provider flag parsing: branches tested via CLI parsing tests @preserve */
687
- for (let i = 0; i < rest.length; i += 1) {
688
- if (rest[i] === "--provider") {
689
- const value = rest[i + 1];
690
- if (!isAgentProvider(value))
691
- throw new Error(`Usage\n${usage()}`);
692
- provider = value;
693
- i += 1;
694
- continue;
695
- }
696
- }
697
- /* v8 ignore stop */
698
- /* v8 ignore next -- defensive: agent always provided in tests @preserve */
699
- if (!agent)
700
- throw new Error(`Usage\n${usage()}`);
701
- if (subcommand === "switch") {
702
- if (!provider)
703
- throw new Error(`auth switch requires --provider.\n${usage()}`);
704
- return { kind: "auth.switch", agent, provider };
705
- }
706
- return provider ? { kind: "auth.verify", agent, provider } : { kind: "auth.verify", agent };
707
- }
708
- const { agent, rest } = extractAgentFlag(args);
709
- let provider;
710
- for (let i = 0; i < rest.length; i += 1) {
711
- if (rest[i] === "--provider") {
712
- const value = rest[i + 1];
713
- if (!isAgentProvider(value))
714
- throw new Error(`Usage\n${usage()}`);
715
- provider = value;
716
- i += 1;
717
- continue;
718
- }
719
- }
720
- if (!agent)
721
- throw new Error(`Usage\n${usage()}`);
722
- return provider ? { kind: "auth.run", agent, provider } : { kind: "auth.run", agent };
723
- }
724
- function parseReminderCommand(args) {
725
- const { agent, rest: cleaned } = extractAgentFlag(args);
726
- const [sub, ...rest] = cleaned;
727
- if (!sub)
728
- throw new Error(`Usage\n${usage()}`);
729
- if (sub === "create") {
730
- const title = rest[0];
731
- if (!title)
732
- throw new Error(`Usage\n${usage()}`);
733
- let body;
734
- let scheduledAt;
735
- let cadence;
736
- let category;
737
- let requester;
738
- for (let i = 1; i < rest.length; i++) {
739
- if (rest[i] === "--body" && rest[i + 1]) {
740
- body = rest[i + 1];
741
- i += 1;
742
- }
743
- else if (rest[i] === "--at" && rest[i + 1]) {
744
- scheduledAt = rest[i + 1];
745
- i += 1;
746
- }
747
- else if (rest[i] === "--cadence" && rest[i + 1]) {
748
- cadence = rest[i + 1];
749
- i += 1;
750
- }
751
- else if (rest[i] === "--category" && rest[i + 1]) {
752
- category = rest[i + 1];
753
- i += 1;
754
- }
755
- else if (rest[i] === "--requester" && rest[i + 1]) {
756
- requester = rest[i + 1];
757
- i += 1;
758
- }
759
- }
760
- if (!body)
761
- throw new Error(`Usage\n${usage()}`);
762
- if (!scheduledAt && !cadence)
763
- throw new Error(`Usage\n${usage()}`);
764
- return {
765
- kind: "reminder.create",
766
- title,
767
- body,
768
- ...(scheduledAt ? { scheduledAt } : {}),
769
- ...(cadence ? { cadence } : {}),
770
- ...(category ? { category } : {}),
771
- ...(requester ? { requester } : {}),
772
- ...(agent ? { agent } : {}),
773
- };
774
- }
775
- throw new Error(`Usage\n${usage()}`);
776
- }
777
- function parseSessionCommand(args) {
778
- const { agent, rest: cleaned } = extractAgentFlag(args);
779
- const [sub] = cleaned;
780
- if (!sub)
781
- throw new Error(`Usage\n${usage()}`);
782
- if (sub === "list")
783
- return { kind: "session.list", ...(agent ? { agent } : {}) };
784
- throw new Error(`Usage\n${usage()}`);
785
- }
786
- function parseThoughtsCommand(args) {
787
- const { agent, rest: cleaned } = extractAgentFlag(args);
788
- let last;
789
- let json = false;
790
- let follow = false;
791
- for (let i = 0; i < cleaned.length; i++) {
792
- if (cleaned[i] === "--last" && i + 1 < cleaned.length) {
793
- last = Number.parseInt(cleaned[i + 1], 10);
794
- i++;
795
- }
796
- if (cleaned[i] === "--json")
797
- json = true;
798
- if (cleaned[i] === "--follow" || cleaned[i] === "-f")
799
- follow = true;
800
- }
801
- return { kind: "thoughts", ...(agent ? { agent } : {}), ...(last ? { last } : {}), ...(json ? { json } : {}), ...(follow ? { follow } : {}) };
802
- }
803
- function parseFriendCommand(args) {
804
- const { agent, rest: cleaned } = extractAgentFlag(args);
805
- const [sub, ...rest] = cleaned;
806
- if (!sub)
807
- throw new Error(`Usage\n${usage()}`);
808
- if (sub === "list")
809
- return { kind: "friend.list", ...(agent ? { agent } : {}) };
810
- if (sub === "show") {
811
- const friendId = rest[0];
812
- if (!friendId)
813
- throw new Error(`Usage\n${usage()}`);
814
- return { kind: "friend.show", friendId, ...(agent ? { agent } : {}) };
815
- }
816
- if (sub === "create") {
817
- let name;
818
- let trustLevel;
819
- for (let i = 0; i < rest.length; i++) {
820
- if (rest[i] === "--name" && rest[i + 1]) {
821
- name = rest[i + 1];
822
- i += 1;
823
- }
824
- else if (rest[i] === "--trust" && rest[i + 1]) {
825
- trustLevel = rest[i + 1];
826
- i += 1;
827
- }
828
- }
829
- if (!name)
830
- throw new Error(`Usage\n${usage()}`);
831
- return {
832
- kind: "friend.create",
833
- name,
834
- ...(trustLevel ? { trustLevel } : {}),
835
- ...(agent ? { agent } : {}),
836
- };
837
- }
838
- if (sub === "update") {
839
- const friendId = rest[0];
840
- if (!friendId)
841
- throw new Error(`Usage: ouro friend update <id> --trust <level>`);
842
- let trustLevel;
843
- /* v8 ignore start -- flag parsing loop: tested via CLI parsing tests @preserve */
844
- for (let i = 1; i < rest.length; i++) {
845
- if (rest[i] === "--trust" && rest[i + 1]) {
846
- trustLevel = rest[i + 1];
847
- i += 1;
848
- }
849
- }
850
- /* v8 ignore stop */
851
- const VALID_TRUST_LEVELS = new Set(["stranger", "acquaintance", "friend", "family"]);
852
- if (!trustLevel || !VALID_TRUST_LEVELS.has(trustLevel)) {
853
- throw new Error(`Usage: ouro friend update <id> --trust <stranger|acquaintance|friend|family>`);
854
- }
855
- return {
856
- kind: "friend.update",
857
- friendId,
858
- trustLevel: trustLevel,
859
- ...(agent ? { agent } : {}),
860
- };
861
- }
862
- if (sub === "link")
863
- return parseLinkCommand(rest, "friend.link");
864
- if (sub === "unlink")
865
- return parseLinkCommand(rest, "friend.unlink");
866
- throw new Error(`Usage\n${usage()}`);
867
- }
868
- function parseConfigCommand(args) {
869
- const { agent, rest: cleaned } = extractAgentFlag(args);
870
- const [sub, ...rest] = cleaned;
871
- if (!sub)
872
- throw new Error(`Usage\n${usage()}`);
873
- if (sub === "model") {
874
- if (!agent)
875
- throw new Error("--agent is required for config model");
876
- const modelName = rest[0];
877
- if (!modelName)
878
- throw new Error(`Usage: ouro config model --agent <name> <model-name>`);
879
- return { kind: "config.model", agent, modelName };
880
- }
881
- if (sub === "models") {
882
- if (!agent)
883
- throw new Error("--agent is required for config models");
884
- return { kind: "config.models", agent };
885
- }
886
- throw new Error(`Usage\n${usage()}`);
887
- }
888
- function parseMcpCommand(args) {
889
- const [sub, ...rest] = args;
890
- if (!sub)
891
- throw new Error(`Usage\n${usage()}`);
892
- if (sub === "list")
893
- return { kind: "mcp.list" };
894
- if (sub === "call") {
895
- const server = rest[0];
896
- const tool = rest[1];
897
- if (!server || !tool)
898
- throw new Error(`Usage\n${usage()}`);
899
- const argsIdx = rest.indexOf("--args");
900
- const mcpArgs = argsIdx !== -1 && rest[argsIdx + 1] ? rest[argsIdx + 1] : undefined;
901
- return { kind: "mcp.call", server, tool, ...(mcpArgs ? { args: mcpArgs } : {}) };
902
- }
903
- throw new Error(`Usage\n${usage()}`);
904
- }
905
- function parseOuroCommand(args) {
906
- const [head, second] = args;
907
- if (!head)
908
- return { kind: "daemon.up" };
909
- if (head === "--agent" && second) {
910
- return parseOuroCommand(args.slice(2));
911
- }
912
- if (head === "up")
913
- return { kind: "daemon.up" };
914
- if (head === "rollback")
915
- return { kind: "rollback", ...(second ? { version: second } : {}) };
916
- if (head === "versions")
917
- return { kind: "versions" };
918
- if (head === "stop" || head === "down")
919
- return { kind: "daemon.stop" };
920
- if (head === "status")
921
- return { kind: "daemon.status" };
922
- if (head === "logs")
923
- return { kind: "daemon.logs" };
924
- if (head === "hatch")
925
- return parseHatchCommand(args.slice(1));
926
- if (head === "auth")
927
- return parseAuthCommand(args.slice(1));
928
- if (head === "task")
929
- return parseTaskCommand(args.slice(1));
930
- if (head === "reminder")
931
- return parseReminderCommand(args.slice(1));
932
- if (head === "friend")
933
- return parseFriendCommand(args.slice(1));
934
- if (head === "config")
935
- return parseConfigCommand(args.slice(1));
936
- if (head === "mcp")
937
- return parseMcpCommand(args.slice(1));
938
- if (head === "whoami") {
939
- const { agent } = extractAgentFlag(args.slice(1));
940
- return { kind: "whoami", ...(agent ? { agent } : {}) };
941
- }
942
- if (head === "session")
943
- return parseSessionCommand(args.slice(1));
944
- if (head === "changelog") {
945
- const sliced = args.slice(1);
946
- const { agent, rest: remaining } = extractAgentFlag(sliced);
947
- let from;
948
- const fromIdx = remaining.indexOf("--from");
949
- if (fromIdx !== -1 && remaining[fromIdx + 1]) {
950
- from = remaining[fromIdx + 1];
951
- }
952
- return { kind: "changelog", ...(from ? { from } : {}), ...(agent ? { agent } : {}) };
953
- }
954
- if (head === "thoughts")
955
- return parseThoughtsCommand(args.slice(1));
956
- if (head === "chat") {
957
- if (!second)
958
- throw new Error(`Usage\n${usage()}`);
959
- return { kind: "chat.connect", agent: second };
960
- }
961
- if (head === "msg")
962
- return parseMessageCommand(args.slice(1));
963
- if (head === "poke")
964
- return parsePokeCommand(args.slice(1));
965
- if (head === "link")
966
- return parseLinkCommand(args.slice(1));
967
- throw new Error(`Unknown command '${args.join(" ")}'.\n${usage()}`);
968
- }
969
- function defaultStartDaemonProcess(socketPath) {
970
- const entry = path.join((0, identity_1.getRepoRoot)(), "dist", "heart", "daemon", "daemon-entry.js");
971
- const child = (0, child_process_1.spawn)("node", [entry, "--socket", socketPath], {
972
- detached: true,
973
- stdio: "ignore",
974
- });
975
- child.unref();
976
- return Promise.resolve({ pid: child.pid ?? null });
977
- }
978
- function defaultWriteStdout(text) {
979
- // eslint-disable-next-line no-console -- terminal UX: CLI command output
980
- console.log(text);
981
- }
982
2
  /**
983
- * Read the runtimeVersion from the first .ouro bundle's bundle-meta.json.
984
- * Returns undefined if none found or unreadable.
3
+ * daemon-cli.ts — Re-export shim.
4
+ *
5
+ * The ouro CLI implementation is split across focused modules:
6
+ *
7
+ * cli-types.ts — OuroCliCommand union, OuroCliDeps interface, type aliases
8
+ * cli-parse.ts — parseOuroCommand() + per-group parsers
9
+ * cli-render.ts — formatTable, formatDaemonStatusOutput, etc.
10
+ * cli-exec.ts — runOuroCli(), ensureDaemonRunning(), command handlers
11
+ * cli-defaults.ts — createDefaultOuroCliDeps(), default implementations
12
+ *
13
+ * This file re-exports the public API so existing consumers (tests,
14
+ * ouro-entry.ts, ouro-bot-wrapper.ts) continue to work unchanged.
985
15
  */
986
- function readFirstBundleMetaVersion(bundlesRoot) {
987
- try {
988
- if (!fs.existsSync(bundlesRoot))
989
- return undefined;
990
- const entries = fs.readdirSync(bundlesRoot, { withFileTypes: true });
991
- for (const entry of entries) {
992
- /* v8 ignore next -- skip non-.ouro dirs: tested via version-detect tests @preserve */
993
- if (!entry.isDirectory() || !entry.name.endsWith(".ouro"))
994
- continue;
995
- const metaPath = path.join(bundlesRoot, entry.name, "bundle-meta.json");
996
- if (!fs.existsSync(metaPath))
997
- continue;
998
- const raw = fs.readFileSync(metaPath, "utf-8");
999
- const meta = JSON.parse(raw);
1000
- if (meta.runtimeVersion)
1001
- return meta.runtimeVersion;
1002
- }
1003
- }
1004
- catch {
1005
- // Best effort — return undefined on any error
1006
- }
1007
- return undefined;
1008
- }
1009
- function defaultCleanupStaleSocket(socketPath) {
1010
- if (fs.existsSync(socketPath)) {
1011
- fs.unlinkSync(socketPath);
1012
- }
1013
- }
1014
- function defaultFallbackPendingMessage(command) {
1015
- const inboxDir = path.join((0, identity_1.getAgentBundlesRoot)(), `${command.to}.ouro`, "inbox");
1016
- const pendingPath = path.join(inboxDir, "pending.jsonl");
1017
- const queuedAt = new Date().toISOString();
1018
- const payload = {
1019
- from: command.from,
1020
- to: command.to,
1021
- content: command.content,
1022
- priority: command.priority ?? "normal",
1023
- sessionId: command.sessionId,
1024
- taskRef: command.taskRef,
1025
- queuedAt,
1026
- };
1027
- fs.mkdirSync(inboxDir, { recursive: true });
1028
- fs.appendFileSync(pendingPath, `${JSON.stringify(payload)}\n`, "utf-8");
1029
- (0, runtime_1.emitNervesEvent)({
1030
- level: "warn",
1031
- component: "daemon",
1032
- event: "daemon.message_fallback_queued",
1033
- message: "queued message to pending fallback file",
1034
- meta: {
1035
- to: command.to,
1036
- path: pendingPath,
1037
- sessionId: command.sessionId ?? null,
1038
- taskRef: command.taskRef ?? null,
1039
- },
1040
- });
1041
- return pendingPath;
1042
- }
1043
- function defaultEnsureDaemonBootPersistence(socketPath) {
1044
- if (process.platform !== "darwin") {
1045
- return;
1046
- }
1047
- const homeDir = os.homedir();
1048
- const launchdDeps = {
1049
- exec: (cmd) => { (0, child_process_1.execSync)(cmd, { stdio: "ignore" }); },
1050
- writeFile: (filePath, content) => fs.writeFileSync(filePath, content, "utf-8"),
1051
- removeFile: (filePath) => fs.rmSync(filePath, { force: true }),
1052
- existsFile: (filePath) => fs.existsSync(filePath),
1053
- mkdirp: (dir) => fs.mkdirSync(dir, { recursive: true }),
1054
- homeDir,
1055
- userUid: process.getuid?.() ?? 0,
1056
- };
1057
- const entryPath = path.join((0, identity_1.getRepoRoot)(), "dist", "heart", "daemon", "daemon-entry.js");
1058
- /* v8 ignore next -- covered via mock in daemon-cli-defaults.test.ts; v8 on CI attributes the real fs.existsSync branch to the non-mock load @preserve */
1059
- if (!fs.existsSync(entryPath)) {
1060
- (0, runtime_1.emitNervesEvent)({
1061
- level: "warn",
1062
- component: "daemon",
1063
- event: "daemon.entry_path_missing",
1064
- message: "entryPath does not exist on disk — plist may point to a stale location. Run 'ouro daemon install' from the correct location.",
1065
- meta: { entryPath },
1066
- });
1067
- }
1068
- const logDir = (0, identity_1.getAgentDaemonLogsDir)();
1069
- (0, launchd_1.installLaunchAgent)(launchdDeps, {
1070
- nodePath: process.execPath,
1071
- entryPath,
1072
- socketPath,
1073
- logDir,
1074
- envPath: process.env.PATH,
1075
- });
1076
- }
1077
- async function defaultPromptInput(question) {
1078
- const readline = await Promise.resolve().then(() => __importStar(require("readline/promises")));
1079
- const rl = readline.createInterface({
1080
- input: process.stdin,
1081
- output: process.stdout,
1082
- });
1083
- try {
1084
- const response = await rl.question(question);
1085
- return response.trim();
1086
- }
1087
- finally {
1088
- rl.close();
1089
- }
1090
- }
1091
- function defaultListDiscoveredAgents() {
1092
- return (0, agent_discovery_1.listEnabledBundleAgents)({
1093
- bundlesRoot: (0, identity_1.getAgentBundlesRoot)(),
1094
- readdirSync: fs.readdirSync,
1095
- readFileSync: fs.readFileSync,
1096
- });
1097
- }
1098
- function discoverExistingCredentials(secretsRoot) {
1099
- const found = [];
1100
- let entries;
1101
- try {
1102
- entries = fs.readdirSync(secretsRoot, { withFileTypes: true });
1103
- }
1104
- catch {
1105
- return found;
1106
- }
1107
- for (const entry of entries) {
1108
- if (!entry.isDirectory())
1109
- continue;
1110
- const secretsPath = path.join(secretsRoot, entry.name, "secrets.json");
1111
- let raw;
1112
- try {
1113
- raw = fs.readFileSync(secretsPath, "utf-8");
1114
- }
1115
- catch {
1116
- continue;
1117
- }
1118
- let parsed;
1119
- try {
1120
- parsed = JSON.parse(raw);
1121
- }
1122
- catch {
1123
- continue;
1124
- }
1125
- if (!parsed.providers)
1126
- continue;
1127
- for (const [provName, provConfig] of Object.entries(parsed.providers)) {
1128
- if (provName === "anthropic" && provConfig.setupToken) {
1129
- found.push({ agentName: entry.name, provider: "anthropic", credentials: { setupToken: provConfig.setupToken }, providerConfig: { ...provConfig } });
1130
- }
1131
- else if (provName === "openai-codex" && provConfig.oauthAccessToken) {
1132
- found.push({ agentName: entry.name, provider: "openai-codex", credentials: { oauthAccessToken: provConfig.oauthAccessToken }, providerConfig: { ...provConfig } });
1133
- }
1134
- else if (provName === "minimax" && provConfig.apiKey) {
1135
- found.push({ agentName: entry.name, provider: "minimax", credentials: { apiKey: provConfig.apiKey }, providerConfig: { ...provConfig } });
1136
- }
1137
- else if (provName === "azure" && provConfig.apiKey && provConfig.endpoint && provConfig.deployment) {
1138
- found.push({ agentName: entry.name, provider: "azure", credentials: { apiKey: provConfig.apiKey, endpoint: provConfig.endpoint, deployment: provConfig.deployment }, providerConfig: { ...provConfig } });
1139
- }
1140
- }
1141
- }
1142
- // Deduplicate by provider+credential value (keep first seen)
1143
- const seen = new Set();
1144
- return found.filter((cred) => {
1145
- const key = `${cred.provider}:${JSON.stringify(cred.credentials)}`;
1146
- if (seen.has(key))
1147
- return false;
1148
- seen.add(key);
1149
- return true;
1150
- });
1151
- }
1152
- /* v8 ignore start -- integration: interactive terminal specialist session @preserve */
1153
- async function defaultRunAdoptionSpecialist() {
1154
- const { runCliSession } = await Promise.resolve().then(() => __importStar(require("../../senses/cli")));
1155
- const { patchRuntimeConfig } = await Promise.resolve().then(() => __importStar(require("../config")));
1156
- const { setAgentName, setAgentConfigOverride } = await Promise.resolve().then(() => __importStar(require("../identity")));
1157
- const readlinePromises = await Promise.resolve().then(() => __importStar(require("readline/promises")));
1158
- const crypto = await Promise.resolve().then(() => __importStar(require("crypto")));
1159
- // Phase 1: cold CLI — collect provider/credentials with a simple readline
1160
- const coldRl = readlinePromises.createInterface({ input: process.stdin, output: process.stdout });
1161
- const coldPrompt = async (q) => {
1162
- const answer = await coldRl.question(q);
1163
- return answer.trim();
1164
- };
1165
- let providerRaw;
1166
- let credentials = {};
1167
- let providerConfig = {};
1168
- const tempDir = path.join(os.tmpdir(), `ouro-hatch-${crypto.randomUUID()}`);
1169
- try {
1170
- const secretsRoot = path.join(os.homedir(), ".agentsecrets");
1171
- const discovered = discoverExistingCredentials(secretsRoot);
1172
- const existingBundleCount = (0, specialist_orchestrator_1.listExistingBundles)((0, identity_1.getAgentBundlesRoot)()).length;
1173
- const hatchVerb = existingBundleCount > 0 ? "let's hatch a new agent." : "let's hatch your first agent.";
1174
- // Default models per provider (used when entering new credentials)
1175
- const defaultModels = {
1176
- anthropic: "claude-opus-4-6",
1177
- minimax: "MiniMax-Text-01",
1178
- "openai-codex": "gpt-5.4",
1179
- "github-copilot": "claude-sonnet-4.6",
1180
- azure: "",
1181
- };
1182
- if (discovered.length > 0) {
1183
- process.stdout.write(`\n\ud83d\udc0d welcome to ouroboros! ${hatchVerb}\n`);
1184
- process.stdout.write("i found existing API credentials:\n\n");
1185
- const unique = [...new Map(discovered.map((d) => [`${d.provider}`, d])).values()];
1186
- for (let i = 0; i < unique.length; i++) {
1187
- const model = unique[i].providerConfig.model || unique[i].providerConfig.deployment || "";
1188
- const modelLabel = model ? `, ${model}` : "";
1189
- process.stdout.write(` ${i + 1}. ${unique[i].provider}${modelLabel} (from ${unique[i].agentName})\n`);
1190
- }
1191
- process.stdout.write("\n");
1192
- const choice = await coldPrompt("use one of these? enter number, or 'new' for a different key: ");
1193
- const idx = parseInt(choice, 10) - 1;
1194
- if (idx >= 0 && idx < unique.length) {
1195
- providerRaw = unique[idx].provider;
1196
- credentials = unique[idx].credentials;
1197
- providerConfig = unique[idx].providerConfig;
1198
- }
1199
- else {
1200
- const pRaw = await coldPrompt("provider (anthropic/azure/minimax/openai-codex/github-copilot): ");
1201
- if (!isAgentProvider(pRaw)) {
1202
- process.stdout.write("unknown provider. run `ouro hatch` to try again.\n");
1203
- coldRl.close();
1204
- return null;
1205
- }
1206
- providerRaw = pRaw;
1207
- providerConfig = { model: defaultModels[providerRaw] };
1208
- if (providerRaw === "anthropic")
1209
- credentials.setupToken = await coldPrompt("API key: ");
1210
- if (providerRaw === "openai-codex")
1211
- credentials.oauthAccessToken = await coldPrompt("OAuth token: ");
1212
- if (providerRaw === "minimax")
1213
- credentials.apiKey = await coldPrompt("API key: ");
1214
- if (providerRaw === "azure") {
1215
- credentials.apiKey = await coldPrompt("API key: ");
1216
- credentials.endpoint = await coldPrompt("endpoint: ");
1217
- credentials.deployment = await coldPrompt("deployment: ");
1218
- }
1219
- }
1220
- }
1221
- else {
1222
- process.stdout.write(`\n\ud83d\udc0d welcome to ouroboros! ${hatchVerb}\n`);
1223
- process.stdout.write("i need an API key to power our conversation.\n\n");
1224
- const pRaw = await coldPrompt("provider (anthropic/azure/minimax/openai-codex/github-copilot): ");
1225
- if (!isAgentProvider(pRaw)) {
1226
- process.stdout.write("unknown provider. run `ouro hatch` to try again.\n");
1227
- coldRl.close();
1228
- return null;
1229
- }
1230
- providerRaw = pRaw;
1231
- providerConfig = { model: defaultModels[providerRaw] };
1232
- if (providerRaw === "anthropic")
1233
- credentials.setupToken = await coldPrompt("API key: ");
1234
- if (providerRaw === "openai-codex")
1235
- credentials.oauthAccessToken = await coldPrompt("OAuth token: ");
1236
- if (providerRaw === "minimax")
1237
- credentials.apiKey = await coldPrompt("API key: ");
1238
- if (providerRaw === "azure") {
1239
- credentials.apiKey = await coldPrompt("API key: ");
1240
- credentials.endpoint = await coldPrompt("endpoint: ");
1241
- credentials.deployment = await coldPrompt("deployment: ");
1242
- }
1243
- }
1244
- coldRl.close();
1245
- process.stdout.write("\n");
1246
- // Phase 2: configure runtime for adoption specialist
1247
- const bundleSourceDir = path.resolve(__dirname, "..", "..", "..", "AdoptionSpecialist.ouro");
1248
- const bundlesRoot = (0, identity_1.getAgentBundlesRoot)();
1249
- const secretsRoot2 = path.join(os.homedir(), ".agentsecrets");
1250
- // Suppress non-critical log noise during adoption (no secrets.json, etc.)
1251
- const { setRuntimeLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves/runtime")));
1252
- const { createLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves")));
1253
- setRuntimeLogger(createLogger({ level: "error" }));
1254
- // Configure runtime: set agent identity + config override so runAgent
1255
- // doesn't try to read from ~/AgentBundles/AdoptionSpecialist.ouro/
1256
- setAgentName("AdoptionSpecialist");
1257
- // Build specialist system prompt
1258
- const soulText = (0, specialist_orchestrator_1.loadSoulText)(bundleSourceDir);
1259
- const identitiesDir = path.join(bundleSourceDir, "psyche", "identities");
1260
- const identity = (0, specialist_orchestrator_1.pickRandomIdentity)(identitiesDir);
1261
- // Load identity-specific spinner phrases (falls back to DEFAULT_AGENT_PHRASES)
1262
- const { loadIdentityPhrases } = await Promise.resolve().then(() => __importStar(require("./specialist-orchestrator")));
1263
- const phrases = loadIdentityPhrases(bundleSourceDir, identity.fileName);
1264
- setAgentConfigOverride({
1265
- version: 1,
1266
- enabled: true,
1267
- provider: providerRaw,
1268
- phrases,
1269
- });
1270
- patchRuntimeConfig({
1271
- providers: {
1272
- [providerRaw]: { ...providerConfig, ...credentials },
1273
- },
1274
- });
1275
- const existingBundles = (0, specialist_orchestrator_1.listExistingBundles)(bundlesRoot);
1276
- const systemPrompt = (0, specialist_prompt_1.buildSpecialistSystemPrompt)(soulText, identity.content, existingBundles, {
1277
- tempDir,
1278
- provider: providerRaw,
1279
- });
1280
- // Build specialist tools
1281
- const specialistTools = (0, specialist_tools_1.getSpecialistTools)();
1282
- const specialistExecTool = (0, specialist_tools_1.createSpecialistExecTool)({
1283
- tempDir,
1284
- credentials,
1285
- provider: providerRaw,
1286
- bundlesRoot,
1287
- secretsRoot: secretsRoot2,
1288
- animationWriter: (text) => process.stdout.write(text),
1289
- });
1290
- // Run the adoption specialist session via runCliSession
1291
- const result = await runCliSession({
1292
- agentName: "AdoptionSpecialist",
1293
- tools: specialistTools,
1294
- execTool: specialistExecTool,
1295
- exitOnToolCall: "complete_adoption",
1296
- autoFirstTurn: true,
1297
- banner: false,
1298
- disableCommands: true,
1299
- skipSystemPromptRefresh: true,
1300
- messages: [
1301
- { role: "system", content: systemPrompt },
1302
- { role: "user", content: "hi" },
1303
- ],
1304
- });
1305
- if (result.exitReason === "tool_exit" && result.toolResult) {
1306
- const parsed = typeof result.toolResult === "string" ? JSON.parse(result.toolResult) : result.toolResult;
1307
- if (parsed.success && parsed.agentName) {
1308
- return parsed.agentName;
1309
- }
1310
- }
1311
- return null;
1312
- }
1313
- catch (err) {
1314
- process.stderr.write(`\nouro adoption error: ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`);
1315
- coldRl.close();
1316
- return null;
1317
- }
1318
- finally {
1319
- // Clear specialist config/identity so the hatched agent gets its own
1320
- setAgentConfigOverride(null);
1321
- const { resetProviderRuntime } = await Promise.resolve().then(() => __importStar(require("../core")));
1322
- resetProviderRuntime();
1323
- const { resetConfigCache } = await Promise.resolve().then(() => __importStar(require("../config")));
1324
- resetConfigCache();
1325
- // Restore default logging
1326
- const { setRuntimeLogger: restoreLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves/runtime")));
1327
- restoreLogger(null);
1328
- // Clean up temp dir if it still exists
1329
- try {
1330
- if (fs.existsSync(tempDir)) {
1331
- fs.rmSync(tempDir, { recursive: true, force: true });
1332
- }
1333
- }
1334
- catch {
1335
- // Best effort cleanup
1336
- }
1337
- }
1338
- }
1339
- /* v8 ignore stop */
1340
- function createDefaultOuroCliDeps(socketPath = socket_client_1.DEFAULT_DAEMON_SOCKET_PATH) {
1341
- return {
1342
- socketPath,
1343
- sendCommand: socket_client_1.sendDaemonCommand,
1344
- startDaemonProcess: defaultStartDaemonProcess,
1345
- writeStdout: defaultWriteStdout,
1346
- checkSocketAlive: socket_client_1.checkDaemonSocketAlive,
1347
- cleanupStaleSocket: defaultCleanupStaleSocket,
1348
- fallbackPendingMessage: defaultFallbackPendingMessage,
1349
- listDiscoveredAgents: defaultListDiscoveredAgents,
1350
- runHatchFlow: hatch_flow_1.runHatchFlow,
1351
- promptInput: defaultPromptInput,
1352
- runAdoptionSpecialist: defaultRunAdoptionSpecialist,
1353
- runAuthFlow: auth_flow_1.runRuntimeAuthFlow,
1354
- registerOuroBundleType: ouro_uti_1.registerOuroBundleUti,
1355
- installOuroCommand: ouro_path_installer_1.installOuroCommand,
1356
- /* v8 ignore start -- self-healing: ensures versioned layout has current version installed @preserve */
1357
- ensureCurrentVersionInstalled: () => {
1358
- const currentVersion = (0, ouro_version_manager_1.getCurrentVersion)({});
1359
- if (currentVersion)
1360
- return; // Already installed and linked
1361
- const version = (0, bundle_manifest_1.getPackageVersion)();
1362
- (0, ouro_version_manager_1.ensureLayout)({});
1363
- const cliHome = (0, ouro_version_manager_1.getOuroCliHome)();
1364
- const versionEntry = path.join(cliHome, "versions", version, "node_modules", "@ouro.bot", "cli", "dist", "heart", "daemon", "ouro-entry.js");
1365
- if (!fs.existsSync(versionEntry)) {
1366
- (0, ouro_version_manager_1.installVersion)(version, {});
1367
- }
1368
- (0, ouro_version_manager_1.activateVersion)(version, {});
1369
- },
1370
- /* v8 ignore stop */
1371
- /* v8 ignore start -- CLI version management defaults: integration code @preserve */
1372
- checkForCliUpdate: async () => {
1373
- const { checkForUpdate } = await Promise.resolve().then(() => __importStar(require("./update-checker")));
1374
- return checkForUpdate((0, bundle_manifest_1.getPackageVersion)(), {
1375
- fetchRegistryJson: async () => {
1376
- const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
1377
- return res.json();
1378
- },
1379
- distTag: "alpha",
1380
- });
1381
- },
1382
- installCliVersion: async (version) => { (0, ouro_version_manager_1.installVersion)(version, {}); },
1383
- activateCliVersion: (version) => { (0, ouro_version_manager_1.activateVersion)(version, {}); },
1384
- getCurrentCliVersion: () => (0, ouro_version_manager_1.getCurrentVersion)({}),
1385
- getPreviousCliVersion: () => (0, ouro_version_manager_1.getPreviousVersion)({}),
1386
- listCliVersions: () => (0, ouro_version_manager_1.listInstalledVersions)({}),
1387
- reExecFromNewVersion: (reArgs) => {
1388
- const entry = path.join((0, ouro_version_manager_1.getOuroCliHome)(), "CurrentVersion", "node_modules", "@ouro.bot", "cli", "dist", "heart", "daemon", "ouro-entry.js");
1389
- require("child_process").execFileSync("node", [entry, ...reArgs], { stdio: "inherit" });
1390
- process.exit(0);
1391
- },
1392
- /* v8 ignore stop */
1393
- syncGlobalOuroBotWrapper: ouro_bot_global_installer_1.syncGlobalOuroBotWrapper,
1394
- ensureSkillManagement: skill_management_installer_1.ensureSkillManagement,
1395
- ensureDaemonBootPersistence: defaultEnsureDaemonBootPersistence,
1396
- /* v8 ignore next 3 -- integration: launches interactive CLI session @preserve */
1397
- startChat: async (agentName) => {
1398
- const { main } = await Promise.resolve().then(() => __importStar(require("../../senses/cli")));
1399
- await main(agentName);
1400
- },
1401
- scanSessions: async () => {
1402
- const agentName = (0, identity_1.getAgentName)();
1403
- const agentRoot = (0, identity_1.getAgentRoot)(agentName);
1404
- return (0, session_activity_1.listSessionActivity)({
1405
- sessionsDir: path.join(agentRoot, "state", "sessions"),
1406
- friendsDir: path.join(agentRoot, "friends"),
1407
- agentName,
1408
- }).map((entry) => ({
1409
- friendId: entry.friendId,
1410
- friendName: entry.friendName,
1411
- channel: entry.channel,
1412
- lastActivity: entry.lastActivityAt,
1413
- }));
1414
- },
1415
- };
1416
- }
1417
- function formatMcpResponse(command, response) {
1418
- if (command.kind === "mcp.list") {
1419
- const allTools = response.data;
1420
- if (!allTools || allTools.length === 0) {
1421
- return response.message ?? "no tools available from connected MCP servers";
1422
- }
1423
- const lines = [];
1424
- for (const entry of allTools) {
1425
- lines.push(`[${entry.server}]`);
1426
- for (const tool of entry.tools) {
1427
- lines.push(` ${tool.name}: ${tool.description}`);
1428
- }
1429
- }
1430
- return lines.join("\n");
1431
- }
1432
- // mcp.call
1433
- const result = response.data;
1434
- if (!result) {
1435
- return response.message ?? "no result";
1436
- }
1437
- return result.content.map((c) => c.text).join("\n");
1438
- }
1439
- function toDaemonCommand(command) {
1440
- return command;
1441
- }
1442
- async function resolveHatchInput(command, deps) {
1443
- const prompt = deps.promptInput;
1444
- const agentName = command.agentName ?? (prompt ? await prompt("Hatchling name: ") : "");
1445
- const humanName = command.humanName ?? (prompt ? await prompt("Your name: ") : os.userInfo().username);
1446
- const providerRaw = command.provider ?? (prompt ? await prompt("Provider (azure|anthropic|minimax|openai-codex|github-copilot): ") : "");
1447
- if (!agentName || !humanName || !isAgentProvider(providerRaw)) {
1448
- throw new Error(`Usage\n${usage()}`);
1449
- }
1450
- const credentials = await (0, auth_flow_1.resolveHatchCredentials)({
1451
- agentName,
1452
- provider: providerRaw,
1453
- credentials: command.credentials,
1454
- promptInput: prompt,
1455
- runAuthFlow: deps.runAuthFlow,
1456
- });
1457
- return {
1458
- agentName,
1459
- humanName,
1460
- provider: providerRaw,
1461
- credentials,
1462
- migrationPath: command.migrationPath,
1463
- };
1464
- }
1465
- async function registerOuroBundleTypeNonBlocking(deps) {
1466
- const registerOuroBundleType = deps.registerOuroBundleType;
1467
- if (!registerOuroBundleType)
1468
- return;
1469
- try {
1470
- await Promise.resolve(registerOuroBundleType());
1471
- }
1472
- catch (error) {
1473
- (0, runtime_1.emitNervesEvent)({
1474
- level: "warn",
1475
- component: "daemon",
1476
- event: "daemon.ouro_uti_register_error",
1477
- message: "failed .ouro UTI registration from CLI flow",
1478
- meta: { error: error instanceof Error ? error.message : String(error) },
1479
- });
1480
- }
1481
- }
1482
- async function performSystemSetup(deps) {
1483
- // Install ouro command to PATH (non-blocking)
1484
- if (deps.installOuroCommand) {
1485
- try {
1486
- const installResult = deps.installOuroCommand();
1487
- /* v8 ignore next -- migration hint: only fires once during old→new layout migration @preserve */
1488
- if (installResult.migratedFromOldPath) {
1489
- deps.writeStdout("migrated ouro to ~/.ouro-cli/ — open a new terminal or run: source ~/.zshrc");
1490
- }
1491
- }
1492
- catch (error) {
1493
- (0, runtime_1.emitNervesEvent)({
1494
- level: "warn",
1495
- component: "daemon",
1496
- event: "daemon.system_setup_ouro_cmd_error",
1497
- message: "failed to install ouro command to PATH",
1498
- meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
1499
- });
1500
- }
1501
- }
1502
- // Self-healing: ensure current version is installed in ~/.ouro-cli/ layout.
1503
- // Handles the case where the wrapper exists but CurrentVersion is missing
1504
- // (e.g., first run after migration from old npx wrapper).
1505
- if (deps.ensureCurrentVersionInstalled) {
1506
- try {
1507
- deps.ensureCurrentVersionInstalled();
1508
- }
1509
- catch (error) {
1510
- (0, runtime_1.emitNervesEvent)({
1511
- level: "warn",
1512
- component: "daemon",
1513
- event: "daemon.system_setup_version_install_error",
1514
- message: "failed to ensure current version installed",
1515
- meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive @preserve */ String(error) },
1516
- });
1517
- }
1518
- }
1519
- if (deps.syncGlobalOuroBotWrapper) {
1520
- try {
1521
- await Promise.resolve(deps.syncGlobalOuroBotWrapper());
1522
- }
1523
- catch (error) {
1524
- (0, runtime_1.emitNervesEvent)({
1525
- level: "warn",
1526
- component: "daemon",
1527
- event: "daemon.system_setup_ouro_bot_wrapper_error",
1528
- message: "failed to sync global ouro.bot wrapper",
1529
- meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
1530
- });
1531
- }
1532
- }
1533
- // Ensure skill-management skill is available
1534
- if (deps.ensureSkillManagement) {
1535
- try {
1536
- await deps.ensureSkillManagement();
1537
- /* v8 ignore start -- defensive: ensureSkillManagement handles its own errors internally @preserve */
1538
- }
1539
- catch (error) {
1540
- (0, runtime_1.emitNervesEvent)({
1541
- level: "warn",
1542
- component: "daemon",
1543
- event: "daemon.system_setup_skill_management_error",
1544
- message: "failed to ensure skill-management skill",
1545
- meta: { error: error instanceof Error ? error.message : String(error) },
1546
- });
1547
- }
1548
- /* v8 ignore stop */
1549
- }
1550
- // Register .ouro bundle type (UTI on macOS)
1551
- await registerOuroBundleTypeNonBlocking(deps);
1552
- }
1553
- function executeTaskCommand(command, taskMod) {
1554
- if (command.kind === "task.board") {
1555
- if (command.status) {
1556
- const lines = taskMod.boardStatus(command.status);
1557
- return lines.length > 0 ? lines.join("\n") : "no tasks in that status";
1558
- }
1559
- const board = taskMod.getBoard();
1560
- return board.full || board.compact || "no tasks found";
1561
- }
1562
- if (command.kind === "task.create") {
1563
- try {
1564
- const created = taskMod.createTask({
1565
- title: command.title,
1566
- type: command.type ?? "one-shot",
1567
- category: "general",
1568
- body: "",
1569
- });
1570
- return `created: ${created}`;
1571
- }
1572
- catch (error) {
1573
- return `error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error)}`;
1574
- }
1575
- }
1576
- if (command.kind === "task.update") {
1577
- const result = taskMod.updateStatus(command.id, command.status);
1578
- if (!result.ok) {
1579
- return `error: ${result.reason ?? "status update failed"}`;
1580
- }
1581
- const archivedSuffix = result.archived && result.archived.length > 0
1582
- ? ` | archived: ${result.archived.join(", ")}`
1583
- : "";
1584
- return `updated: ${command.id} -> ${result.to}${archivedSuffix}`;
1585
- }
1586
- if (command.kind === "task.show") {
1587
- const task = taskMod.getTask(command.id);
1588
- if (!task)
1589
- return `task not found: ${command.id}`;
1590
- return [
1591
- `title: ${task.title}`,
1592
- `type: ${task.type}`,
1593
- `status: ${task.status}`,
1594
- `category: ${task.category}`,
1595
- `created: ${task.created}`,
1596
- `updated: ${task.updated}`,
1597
- `path: ${task.path}`,
1598
- task.body ? `\n${task.body}` : "",
1599
- ].filter(Boolean).join("\n");
1600
- }
1601
- if (command.kind === "task.actionable") {
1602
- const lines = taskMod.boardAction();
1603
- return lines.length > 0 ? lines.join("\n") : "no action required";
1604
- }
1605
- if (command.kind === "task.deps") {
1606
- const lines = taskMod.boardDeps();
1607
- return lines.length > 0 ? lines.join("\n") : "no unresolved dependencies";
1608
- }
1609
- // command.kind === "task.sessions"
1610
- const lines = taskMod.boardSessions();
1611
- return lines.length > 0 ? lines.join("\n") : "no active sessions";
1612
- }
1613
- const TRUST_RANK = { family: 4, friend: 3, acquaintance: 2, stranger: 1 };
1614
- /* v8 ignore start -- defensive: ?? fallbacks are unreachable when inputs are valid TrustLevel values @preserve */
1615
- function higherTrust(a, b) {
1616
- const rankA = TRUST_RANK[a ?? "stranger"] ?? 1;
1617
- const rankB = TRUST_RANK[b ?? "stranger"] ?? 1;
1618
- return rankA >= rankB ? (a ?? "stranger") : (b ?? "stranger");
1619
- }
1620
- /* v8 ignore stop */
1621
- async function executeFriendCommand(command, store) {
1622
- if (command.kind === "friend.list") {
1623
- const listAll = store.listAll;
1624
- if (!listAll)
1625
- return "friend store does not support listing";
1626
- const friends = await listAll.call(store);
1627
- if (friends.length === 0)
1628
- return "no friends found";
1629
- const lines = friends.map((f) => {
1630
- const trust = f.trustLevel ?? "unknown";
1631
- return `${f.id} ${f.name} ${trust}`;
1632
- });
1633
- return lines.join("\n");
1634
- }
1635
- if (command.kind === "friend.show") {
1636
- const record = await store.get(command.friendId);
1637
- if (!record)
1638
- return `friend not found: ${command.friendId}`;
1639
- return JSON.stringify(record, null, 2);
1640
- }
1641
- if (command.kind === "friend.create") {
1642
- const now = new Date().toISOString();
1643
- const id = (0, crypto_1.randomUUID)();
1644
- const trustLevel = (command.trustLevel ?? "acquaintance");
1645
- await store.put(id, {
1646
- id,
1647
- name: command.name,
1648
- trustLevel,
1649
- externalIds: [],
1650
- tenantMemberships: [],
1651
- toolPreferences: {},
1652
- notes: {},
1653
- totalTokens: 0,
1654
- createdAt: now,
1655
- updatedAt: now,
1656
- schemaVersion: 1,
1657
- });
1658
- return `created: ${id} (${command.name}, ${trustLevel})`;
1659
- }
1660
- if (command.kind === "friend.update") {
1661
- const current = await store.get(command.friendId);
1662
- if (!current)
1663
- return `friend not found: ${command.friendId}`;
1664
- const now = new Date().toISOString();
1665
- await store.put(command.friendId, {
1666
- ...current,
1667
- trustLevel: command.trustLevel,
1668
- role: command.trustLevel,
1669
- updatedAt: now,
1670
- });
1671
- return `updated: ${command.friendId} → trust=${command.trustLevel}`;
1672
- }
1673
- if (command.kind === "friend.link") {
1674
- const current = await store.get(command.friendId);
1675
- if (!current)
1676
- return `friend not found: ${command.friendId}`;
1677
- const alreadyLinked = current.externalIds.some((ext) => ext.provider === command.provider && ext.externalId === command.externalId);
1678
- if (alreadyLinked)
1679
- return `identity already linked: ${command.provider}:${command.externalId}`;
1680
- const now = new Date().toISOString();
1681
- const newExternalIds = [
1682
- ...current.externalIds,
1683
- { provider: command.provider, externalId: command.externalId, linkedAt: now },
1684
- ];
1685
- // Orphan cleanup: check if another friend has this externalId
1686
- const orphan = await store.findByExternalId(command.provider, command.externalId);
1687
- let mergeMessage = "";
1688
- let mergedNotes = { ...current.notes };
1689
- let mergedTrust = current.trustLevel;
1690
- let orphanExternalIds = [];
1691
- if (orphan && orphan.id !== command.friendId) {
1692
- // Merge orphan's notes (target's notes take priority)
1693
- mergedNotes = { ...orphan.notes, ...current.notes };
1694
- // Keep higher trust level
1695
- mergedTrust = higherTrust(current.trustLevel, orphan.trustLevel);
1696
- // Collect orphan's other externalIds (excluding the one being linked)
1697
- orphanExternalIds = orphan.externalIds.filter((ext) => !(ext.provider === command.provider && ext.externalId === command.externalId));
1698
- await store.delete(orphan.id);
1699
- mergeMessage = ` (merged orphan ${orphan.id})`;
1700
- }
1701
- await store.put(command.friendId, {
1702
- ...current,
1703
- externalIds: [...newExternalIds, ...orphanExternalIds],
1704
- notes: mergedNotes,
1705
- trustLevel: mergedTrust,
1706
- updatedAt: now,
1707
- });
1708
- return `linked ${command.provider}:${command.externalId} to ${command.friendId}${mergeMessage}`;
1709
- }
1710
- // command.kind === "friend.unlink"
1711
- const current = await store.get(command.friendId);
1712
- if (!current)
1713
- return `friend not found: ${command.friendId}`;
1714
- const idx = current.externalIds.findIndex((ext) => ext.provider === command.provider && ext.externalId === command.externalId);
1715
- if (idx === -1)
1716
- return `identity not linked: ${command.provider}:${command.externalId}`;
1717
- const now = new Date().toISOString();
1718
- const filtered = current.externalIds.filter((_, i) => i !== idx);
1719
- await store.put(command.friendId, { ...current, externalIds: filtered, updatedAt: now });
1720
- return `unlinked ${command.provider}:${command.externalId} from ${command.friendId}`;
1721
- }
1722
- function executeReminderCommand(command, taskMod) {
1723
- try {
1724
- const created = taskMod.createTask({
1725
- title: command.title,
1726
- type: command.cadence ? "habit" : "one-shot",
1727
- category: command.category ?? "reminder",
1728
- body: command.body,
1729
- scheduledAt: command.scheduledAt,
1730
- cadence: command.cadence,
1731
- requester: command.requester,
1732
- });
1733
- return `created: ${created}`;
1734
- }
1735
- catch (error) {
1736
- return `error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error)}`;
1737
- }
1738
- }
1739
- async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
1740
- if (args.includes("--help") || args.includes("-h")) {
1741
- const text = usage();
1742
- deps.writeStdout(text);
1743
- return text;
1744
- }
1745
- if (args.length === 1 && (args[0] === "-v" || args[0] === "--version")) {
1746
- const text = formatVersionOutput();
1747
- deps.writeStdout(text);
1748
- return text;
1749
- }
1750
- let command;
1751
- try {
1752
- command = parseOuroCommand(args);
1753
- }
1754
- catch (parseError) {
1755
- if (deps.startChat && deps.listDiscoveredAgents && args.length === 1) {
1756
- const discovered = await Promise.resolve(deps.listDiscoveredAgents());
1757
- if (discovered.includes(args[0])) {
1758
- await ensureDaemonRunning(deps);
1759
- await deps.startChat(args[0]);
1760
- return "";
1761
- }
1762
- }
1763
- throw parseError;
1764
- }
1765
- if (args.length === 0) {
1766
- const discovered = await Promise.resolve(deps.listDiscoveredAgents ? deps.listDiscoveredAgents() : defaultListDiscoveredAgents());
1767
- if (discovered.length === 0 && deps.runAdoptionSpecialist) {
1768
- // System setup first — ouro command, subagents, UTI — before the interactive specialist
1769
- await performSystemSetup(deps);
1770
- const hatchlingName = await deps.runAdoptionSpecialist();
1771
- if (!hatchlingName) {
1772
- return "";
1773
- }
1774
- await ensureDaemonRunning(deps);
1775
- if (deps.startChat) {
1776
- await deps.startChat(hatchlingName);
1777
- }
1778
- return "";
1779
- }
1780
- else if (discovered.length === 0) {
1781
- command = { kind: "hatch.start" };
1782
- }
1783
- else if (discovered.length === 1) {
1784
- if (deps.startChat) {
1785
- await ensureDaemonRunning(deps);
1786
- await deps.startChat(discovered[0]);
1787
- return "";
1788
- }
1789
- command = { kind: "chat.connect", agent: discovered[0] };
1790
- }
1791
- else {
1792
- if (deps.startChat && deps.promptInput) {
1793
- const prompt = `who do you want to talk to?\n${discovered.map((a, i) => `${i + 1}. ${a}`).join("\n")}\n`;
1794
- const answer = await deps.promptInput(prompt);
1795
- const selected = discovered.includes(answer) ? answer : discovered[parseInt(answer, 10) - 1];
1796
- if (!selected)
1797
- throw new Error("Invalid selection");
1798
- await ensureDaemonRunning(deps);
1799
- await deps.startChat(selected);
1800
- return "";
1801
- }
1802
- const message = `who do you want to talk to? ${discovered.join(", ")} (use: ouro chat <agent>)`;
1803
- deps.writeStdout(message);
1804
- return message;
1805
- }
1806
- (0, runtime_1.emitNervesEvent)({
1807
- component: "daemon",
1808
- event: "daemon.cli_auto_route",
1809
- message: "routed bare ouro command from discovered agents",
1810
- meta: { target: command.kind, count: discovered.length },
1811
- });
1812
- }
1813
- (0, runtime_1.emitNervesEvent)({
1814
- component: "daemon",
1815
- event: "daemon.cli_command",
1816
- message: "ouro CLI command invoked",
1817
- meta: { kind: command.kind },
1818
- });
1819
- if (command.kind === "daemon.up") {
1820
- // ── versioned CLI update check ──
1821
- if (deps.checkForCliUpdate) {
1822
- let pendingReExec = false;
1823
- try {
1824
- const updateResult = await deps.checkForCliUpdate();
1825
- if (updateResult.available && updateResult.latestVersion) {
1826
- /* v8 ignore next -- fallback: getCurrentCliVersion always injected in tests @preserve */
1827
- const currentVersion = deps.getCurrentCliVersion?.() ?? "unknown";
1828
- await deps.installCliVersion(updateResult.latestVersion);
1829
- deps.activateCliVersion(updateResult.latestVersion);
1830
- deps.writeStdout(`ouro updated to ${updateResult.latestVersion} (was ${currentVersion})`);
1831
- const changelogCommand = (0, ouro_version_manager_1.buildChangelogCommand)(currentVersion, updateResult.latestVersion);
1832
- /* v8 ignore next -- buildChangelogCommand is non-null when an actual newer version is installed @preserve */
1833
- if (changelogCommand) {
1834
- deps.writeStdout(`review changes with: ${changelogCommand}`);
1835
- }
1836
- pendingReExec = true;
1837
- }
1838
- /* v8 ignore start -- update check error: tested via daemon-cli-update-flow.test.ts @preserve */
1839
- }
1840
- catch (error) {
1841
- (0, runtime_1.emitNervesEvent)({
1842
- level: "warn",
1843
- component: "daemon",
1844
- event: "daemon.cli_update_check_error",
1845
- message: "CLI update check failed",
1846
- meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
1847
- });
1848
- }
1849
- /* v8 ignore stop */
1850
- if (pendingReExec) {
1851
- deps.reExecFromNewVersion(args);
1852
- }
1853
- }
1854
- await performSystemSetup(deps);
1855
- if (deps.ensureDaemonBootPersistence) {
1856
- try {
1857
- await Promise.resolve(deps.ensureDaemonBootPersistence(deps.socketPath));
1858
- }
1859
- catch (error) {
1860
- (0, runtime_1.emitNervesEvent)({
1861
- level: "warn",
1862
- component: "daemon",
1863
- event: "daemon.system_setup_launchd_error",
1864
- message: "failed to persist daemon boot startup",
1865
- meta: { error: error instanceof Error ? error.message : String(error), socketPath: deps.socketPath },
1866
- });
1867
- }
1868
- }
1869
- // Run update hooks before starting daemon so user sees the output
1870
- (0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
1871
- const bundlesRoot = (0, identity_1.getAgentBundlesRoot)();
1872
- const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
1873
- // Snapshot the previous CLI version from the first bundle-meta before
1874
- // hooks overwrite it. This detects when npx downloaded a newer CLI.
1875
- const previousCliVersion = readFirstBundleMetaVersion(bundlesRoot);
1876
- const updateSummary = await (0, update_hooks_1.applyPendingUpdates)(bundlesRoot, currentVersion);
1877
- // Notify about CLI binary update (npx downloaded a new version)
1878
- /* v8 ignore start -- CLI update detection: tested via daemon-cli-version-detect.test.ts @preserve */
1879
- if (previousCliVersion && previousCliVersion !== currentVersion) {
1880
- deps.writeStdout(`ouro updated to ${currentVersion} (was ${previousCliVersion})`);
1881
- const changelogCommand = (0, ouro_version_manager_1.buildChangelogCommand)(previousCliVersion, currentVersion);
1882
- /* v8 ignore next -- buildChangelogCommand is non-null when previous/current runtime versions differ @preserve */
1883
- if (changelogCommand) {
1884
- deps.writeStdout(`review changes with: ${changelogCommand}`);
1885
- }
1886
- }
1887
- /* v8 ignore stop */
1888
- if (updateSummary.updated.length > 0) {
1889
- const agents = updateSummary.updated.map((e) => e.agent);
1890
- const from = updateSummary.updated[0].from;
1891
- const to = updateSummary.updated[0].to;
1892
- const fromStr = from ? ` (was ${from})` : "";
1893
- const count = agents.length;
1894
- deps.writeStdout(`updated ${count} agent${count === 1 ? "" : "s"} to runtime ${to}${fromStr}`);
1895
- }
1896
- const daemonResult = await ensureDaemonRunning(deps);
1897
- deps.writeStdout(daemonResult.message);
1898
- return daemonResult.message;
1899
- }
1900
- // ── rollback command (local, no daemon socket needed for symlinks) ──
1901
- /* v8 ignore start -- rollback/versions: tested via daemon-cli-rollback/versions tests @preserve */
1902
- if (command.kind === "rollback") {
1903
- const currentVersion = deps.getCurrentCliVersion?.() ?? "unknown";
1904
- if (command.version) {
1905
- // Rollback to a specific version
1906
- const installed = deps.listCliVersions?.() ?? [];
1907
- if (!installed.includes(command.version)) {
1908
- try {
1909
- await deps.installCliVersion(command.version);
1910
- }
1911
- catch (error) {
1912
- const message = `failed to install version ${command.version}: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error)}`;
1913
- deps.writeStdout(message);
1914
- return message;
1915
- }
1916
- }
1917
- deps.activateCliVersion(command.version);
1918
- }
1919
- else {
1920
- // Rollback to previous version
1921
- const previousVersion = deps.getPreviousCliVersion?.();
1922
- if (!previousVersion) {
1923
- const message = "no previous version to roll back to";
1924
- deps.writeStdout(message);
1925
- return message;
1926
- }
1927
- deps.activateCliVersion(previousVersion);
1928
- command = { ...command, version: previousVersion };
1929
- }
1930
- // Stop daemon (non-fatal if not running)
1931
- try {
1932
- await deps.sendCommand(deps.socketPath, { kind: "daemon.stop" });
1933
- }
1934
- catch {
1935
- // Daemon may not be running — that's fine
1936
- }
1937
- const message = `rolled back to ${command.version} (was ${currentVersion})`;
1938
- deps.writeStdout(message);
1939
- return message;
1940
- }
1941
- // ── versions command (local, no daemon socket needed) ──
1942
- if (command.kind === "versions") {
1943
- const versions = deps.listCliVersions?.() ?? [];
1944
- if (versions.length === 0) {
1945
- const message = "no versions installed";
1946
- deps.writeStdout(message);
1947
- return message;
1948
- }
1949
- const current = deps.getCurrentCliVersion?.();
1950
- const previous = deps.getPreviousCliVersion?.();
1951
- const lines = versions.map((v) => {
1952
- let line = v;
1953
- if (v === current)
1954
- line += " * current";
1955
- if (v === previous)
1956
- line += " (previous)";
1957
- return line;
1958
- });
1959
- const message = lines.join("\n");
1960
- deps.writeStdout(message);
1961
- return message;
1962
- }
1963
- /* v8 ignore stop */
1964
- if (command.kind === "daemon.logs" && deps.tailLogs) {
1965
- deps.tailLogs();
1966
- return "";
1967
- }
1968
- // ── mcp subcommands (routed through daemon socket) ──
1969
- if (command.kind === "mcp.list" || command.kind === "mcp.call") {
1970
- const daemonCommand = toDaemonCommand(command);
1971
- let response;
1972
- try {
1973
- response = await deps.sendCommand(deps.socketPath, daemonCommand);
1974
- }
1975
- catch {
1976
- const message = "daemon unavailable — start with `ouro up` first";
1977
- deps.writeStdout(message);
1978
- return message;
1979
- }
1980
- if (!response.ok) {
1981
- const message = response.error ?? "unknown error";
1982
- deps.writeStdout(message);
1983
- return message;
1984
- }
1985
- const message = formatMcpResponse(command, response);
1986
- deps.writeStdout(message);
1987
- return message;
1988
- }
1989
- // ── task subcommands (local, no daemon socket needed) ──
1990
- if (command.kind === "task.board" || command.kind === "task.create" || command.kind === "task.update" ||
1991
- command.kind === "task.show" || command.kind === "task.actionable" || command.kind === "task.deps" ||
1992
- command.kind === "task.sessions") {
1993
- /* v8 ignore start -- production default: requires full identity setup @preserve */
1994
- const taskMod = deps.taskModule ?? (0, tasks_1.getTaskModule)();
1995
- /* v8 ignore stop */
1996
- const message = executeTaskCommand(command, taskMod);
1997
- deps.writeStdout(message);
1998
- return message;
1999
- }
2000
- // ── reminder subcommands (local, no daemon socket needed) ──
2001
- if (command.kind === "reminder.create") {
2002
- /* v8 ignore start -- production default: requires full identity setup @preserve */
2003
- const taskMod = deps.taskModule ?? (0, tasks_1.getTaskModule)();
2004
- /* v8 ignore stop */
2005
- const message = executeReminderCommand(command, taskMod);
2006
- deps.writeStdout(message);
2007
- return message;
2008
- }
2009
- // ── friend subcommands (local, no daemon socket needed) ──
2010
- if (command.kind === "friend.list" || command.kind === "friend.show" || command.kind === "friend.create" ||
2011
- command.kind === "friend.update" || command.kind === "friend.link" || command.kind === "friend.unlink") {
2012
- /* v8 ignore start -- production default: requires full identity setup @preserve */
2013
- let store = deps.friendStore;
2014
- if (!store) {
2015
- // Derive agent-scoped friends dir from --agent flag or link/unlink's agent field
2016
- const agentName = ("agent" in command && command.agent) ? command.agent : undefined;
2017
- const friendsDir = agentName
2018
- ? path.join((0, identity_1.getAgentBundlesRoot)(), `${agentName}.ouro`, "friends")
2019
- : path.join((0, identity_1.getAgentBundlesRoot)(), "friends");
2020
- store = new store_file_1.FileFriendStore(friendsDir);
2021
- }
2022
- /* v8 ignore stop */
2023
- const message = await executeFriendCommand(command, store);
2024
- deps.writeStdout(message);
2025
- return message;
2026
- }
2027
- // ── auth (local, no daemon socket needed) ──
2028
- if (command.kind === "auth.run") {
2029
- const provider = command.provider ?? (0, auth_flow_1.readAgentConfigForAgent)(command.agent).config.provider;
2030
- /* v8 ignore next -- tests always inject runAuthFlow; default is for production @preserve */
2031
- const authRunner = deps.runAuthFlow ?? auth_flow_1.runRuntimeAuthFlow;
2032
- const result = await authRunner({
2033
- agentName: command.agent,
2034
- provider,
2035
- promptInput: deps.promptInput,
2036
- });
2037
- // Behavior: ouro auth stores credentials only — does NOT switch provider.
2038
- // Use `ouro auth switch` to change the active provider.
2039
- deps.writeStdout(result.message);
2040
- return result.message;
2041
- }
2042
- // ── auth verify (local, no daemon socket needed) ──
2043
- /* v8 ignore start -- auth verify/switch: tested in daemon-cli.test.ts but v8 traces differ in CI @preserve */
2044
- if (command.kind === "auth.verify") {
2045
- const { secrets } = (0, auth_flow_1.loadAgentSecrets)(command.agent);
2046
- const providers = secrets.providers;
2047
- const fetchFn = deps.fetchImpl ?? fetch;
2048
- if (command.provider) {
2049
- const status = await verifyProviderCredentials(command.provider, providers, fetchFn);
2050
- const message = `${command.provider}: ${status}`;
2051
- deps.writeStdout(message);
2052
- return message;
2053
- }
2054
- const lines = [];
2055
- for (const p of Object.keys(providers)) {
2056
- const status = await verifyProviderCredentials(p, providers, fetchFn);
2057
- lines.push(`${p}: ${status}`);
2058
- }
2059
- const message = lines.join("\n");
2060
- deps.writeStdout(message);
2061
- return message;
2062
- }
2063
- // ── auth switch (local, no daemon socket needed) ──
2064
- if (command.kind === "auth.switch") {
2065
- const { secrets } = (0, auth_flow_1.loadAgentSecrets)(command.agent);
2066
- const providerSecrets = secrets.providers[command.provider];
2067
- if (!providerSecrets || !hasStoredCredentials(command.provider, providerSecrets)) {
2068
- const message = `no credentials stored for ${command.provider}. Run \`ouro auth --agent ${command.agent} --provider ${command.provider}\` first.`;
2069
- deps.writeStdout(message);
2070
- return message;
2071
- }
2072
- (0, auth_flow_1.writeAgentProviderSelection)(command.agent, command.provider);
2073
- const message = `switched ${command.agent} to ${command.provider}`;
2074
- deps.writeStdout(message);
2075
- return message;
2076
- }
2077
- /* v8 ignore stop */
2078
- // ── config models (local, no daemon socket needed) ──
2079
- /* v8 ignore start -- config models: tested via daemon-cli.test.ts @preserve */
2080
- if (command.kind === "config.models") {
2081
- const { config } = (0, auth_flow_1.readAgentConfigForAgent)(command.agent);
2082
- const provider = config.provider;
2083
- if (provider !== "github-copilot") {
2084
- const message = `model listing not available for ${provider} — check provider documentation.`;
2085
- deps.writeStdout(message);
2086
- return message;
2087
- }
2088
- const { secrets } = (0, auth_flow_1.loadAgentSecrets)(command.agent);
2089
- const ghConfig = secrets.providers["github-copilot"];
2090
- if (!ghConfig.githubToken || !ghConfig.baseUrl) {
2091
- throw new Error(`github-copilot credentials not configured. Run \`ouro auth --agent ${command.agent} --provider github-copilot\` first.`);
2092
- }
2093
- const fetchFn = deps.fetchImpl ?? fetch;
2094
- const models = await listGithubCopilotModels(ghConfig.baseUrl, ghConfig.githubToken, fetchFn);
2095
- if (models.length === 0) {
2096
- const message = "no models found";
2097
- deps.writeStdout(message);
2098
- return message;
2099
- }
2100
- const lines = ["available models:"];
2101
- for (const m of models) {
2102
- const caps = m.capabilities?.length ? ` (${m.capabilities.join(", ")})` : "";
2103
- lines.push(` ${m.id}${caps}`);
2104
- }
2105
- const message = lines.join("\n");
2106
- deps.writeStdout(message);
2107
- return message;
2108
- }
2109
- /* v8 ignore stop */
2110
- // ── config model (local, no daemon socket needed) ──
2111
- /* v8 ignore start -- config model: tested via daemon-cli.test.ts @preserve */
2112
- if (command.kind === "config.model") {
2113
- // Validate model availability for github-copilot before writing
2114
- const { config } = (0, auth_flow_1.readAgentConfigForAgent)(command.agent);
2115
- if (config.provider === "github-copilot") {
2116
- const { secrets } = (0, auth_flow_1.loadAgentSecrets)(command.agent);
2117
- const ghConfig = secrets.providers["github-copilot"];
2118
- if (ghConfig.githubToken && ghConfig.baseUrl) {
2119
- const fetchFn = deps.fetchImpl ?? fetch;
2120
- try {
2121
- const models = await listGithubCopilotModels(ghConfig.baseUrl, ghConfig.githubToken, fetchFn);
2122
- const available = models.map((m) => m.id);
2123
- if (available.length > 0 && !available.includes(command.modelName)) {
2124
- const message = `model '${command.modelName}' not found. available models:\n${available.map((id) => ` ${id}`).join("\n")}`;
2125
- deps.writeStdout(message);
2126
- return message;
2127
- }
2128
- }
2129
- catch {
2130
- // Catalog validation failed — fall through to ping test
2131
- }
2132
- // Ping test: verify the model actually works before switching
2133
- const pingResult = await pingGithubCopilotModel(ghConfig.baseUrl, ghConfig.githubToken, command.modelName, fetchFn);
2134
- if (!pingResult.ok) {
2135
- const message = `model '${command.modelName}' ping failed: ${pingResult.error}\nrun \`ouro config models --agent ${command.agent}\` to see available models.`;
2136
- deps.writeStdout(message);
2137
- return message;
2138
- }
2139
- }
2140
- }
2141
- const { provider, previousModel } = (0, auth_flow_1.writeAgentModel)(command.agent, command.modelName);
2142
- const message = previousModel
2143
- ? `updated ${command.agent} model on ${provider}: ${previousModel} → ${command.modelName}`
2144
- : `set ${command.agent} model on ${provider}: ${command.modelName}`;
2145
- deps.writeStdout(message);
2146
- return message;
2147
- }
2148
- /* v8 ignore stop */
2149
- // ── whoami (local, no daemon socket needed) ──
2150
- if (command.kind === "whoami") {
2151
- if (command.agent) {
2152
- const agentRoot = path.join((0, identity_1.getAgentBundlesRoot)(), `${command.agent}.ouro`);
2153
- const message = [
2154
- `agent: ${command.agent}`,
2155
- `home: ${agentRoot}`,
2156
- `bones: ${(0, runtime_metadata_1.getRuntimeMetadata)().version}`,
2157
- ].join("\n");
2158
- deps.writeStdout(message);
2159
- return message;
2160
- }
2161
- /* v8 ignore start -- production default: requires full identity setup @preserve */
2162
- try {
2163
- const info = deps.whoamiInfo
2164
- ? deps.whoamiInfo()
2165
- : {
2166
- agentName: (0, identity_1.getAgentName)(),
2167
- homePath: path.join((0, identity_1.getAgentBundlesRoot)(), `${(0, identity_1.getAgentName)()}.ouro`),
2168
- bonesVersion: (0, runtime_metadata_1.getRuntimeMetadata)().version,
2169
- };
2170
- const message = [
2171
- `agent: ${info.agentName}`,
2172
- `home: ${info.homePath}`,
2173
- `bones: ${info.bonesVersion}`,
2174
- ].join("\n");
2175
- deps.writeStdout(message);
2176
- return message;
2177
- }
2178
- catch {
2179
- const message = "error: no agent context — use --agent <name> to specify";
2180
- deps.writeStdout(message);
2181
- return message;
2182
- }
2183
- /* v8 ignore stop */
2184
- }
2185
- // ── changelog (local, no daemon socket needed) ──
2186
- if (command.kind === "changelog") {
2187
- try {
2188
- const changelogPath = deps.getChangelogPath
2189
- ? deps.getChangelogPath()
2190
- : (0, bundle_manifest_1.getChangelogPath)();
2191
- const raw = fs.readFileSync(changelogPath, "utf-8");
2192
- const entries = JSON.parse(raw);
2193
- let filtered = entries;
2194
- if (command.from) {
2195
- const fromVersion = command.from;
2196
- filtered = entries.filter((e) => e.version > fromVersion);
2197
- }
2198
- if (filtered.length === 0) {
2199
- const message = "no changelog entries found.";
2200
- deps.writeStdout(message);
2201
- return message;
2202
- }
2203
- const lines = [];
2204
- for (const entry of filtered) {
2205
- lines.push(`## ${entry.version}${entry.date ? ` (${entry.date})` : ""}`);
2206
- if (entry.changes) {
2207
- for (const change of entry.changes) {
2208
- lines.push(`- ${change}`);
2209
- }
2210
- }
2211
- lines.push("");
2212
- }
2213
- const message = lines.join("\n").trim();
2214
- deps.writeStdout(message);
2215
- return message;
2216
- }
2217
- catch {
2218
- const message = "no changelog entries found.";
2219
- deps.writeStdout(message);
2220
- return message;
2221
- }
2222
- }
2223
- // ── thoughts (local, no daemon socket needed) ──
2224
- if (command.kind === "thoughts") {
2225
- try {
2226
- const agentName = command.agent ?? (0, identity_1.getAgentName)();
2227
- const agentRoot = path.join((0, identity_1.getAgentBundlesRoot)(), `${agentName}.ouro`);
2228
- const sessionFilePath = (0, thoughts_1.getInnerDialogSessionPath)(agentRoot);
2229
- if (command.json) {
2230
- try {
2231
- const raw = fs.readFileSync(sessionFilePath, "utf-8");
2232
- deps.writeStdout(raw);
2233
- return raw;
2234
- }
2235
- catch {
2236
- const message = "no inner dialog session found";
2237
- deps.writeStdout(message);
2238
- return message;
2239
- }
2240
- }
2241
- const turns = (0, thoughts_1.parseInnerDialogSession)(sessionFilePath);
2242
- const message = (0, thoughts_1.formatThoughtTurns)(turns, command.last ?? 10);
2243
- deps.writeStdout(message);
2244
- if (command.follow) {
2245
- deps.writeStdout("\n\n--- following (ctrl+c to stop) ---\n");
2246
- /* v8 ignore start -- callback tested via followThoughts unit tests @preserve */
2247
- const stop = (0, thoughts_1.followThoughts)(sessionFilePath, (formatted) => {
2248
- deps.writeStdout("\n" + formatted);
2249
- });
2250
- /* v8 ignore stop */
2251
- // Block until process exit; cleanup watcher on SIGINT/SIGTERM
2252
- return new Promise((resolve) => {
2253
- const cleanup = () => { stop(); resolve(message); };
2254
- process.once("SIGINT", cleanup);
2255
- process.once("SIGTERM", cleanup);
2256
- });
2257
- }
2258
- return message;
2259
- }
2260
- catch {
2261
- const message = "error: no agent context — use --agent <name> to specify";
2262
- deps.writeStdout(message);
2263
- return message;
2264
- }
2265
- }
2266
- // ── session list (local, no daemon socket needed) ──
2267
- if (command.kind === "session.list") {
2268
- /* v8 ignore start -- production default: requires full identity setup @preserve */
2269
- const scanner = deps.scanSessions ?? (async () => []);
2270
- /* v8 ignore stop */
2271
- const sessions = await scanner();
2272
- if (sessions.length === 0) {
2273
- const message = "no active sessions";
2274
- deps.writeStdout(message);
2275
- return message;
2276
- }
2277
- const lines = sessions.map((s) => `${s.friendId} ${s.friendName} ${s.channel} ${s.lastActivity}`);
2278
- const message = lines.join("\n");
2279
- deps.writeStdout(message);
2280
- return message;
2281
- }
2282
- if (command.kind === "chat.connect" && deps.startChat) {
2283
- await ensureDaemonRunning(deps);
2284
- await deps.startChat(command.agent);
2285
- return "";
2286
- }
2287
- if (command.kind === "hatch.start") {
2288
- // Route through adoption specialist when no explicit hatch args were provided
2289
- const hasExplicitHatchArgs = !!(command.agentName || command.humanName || command.provider || command.credentials);
2290
- if (deps.runAdoptionSpecialist && !hasExplicitHatchArgs) {
2291
- // System setup first — ouro command, subagents, UTI — before the interactive specialist
2292
- await performSystemSetup(deps);
2293
- const hatchlingName = await deps.runAdoptionSpecialist();
2294
- if (!hatchlingName) {
2295
- return "";
2296
- }
2297
- await ensureDaemonRunning(deps);
2298
- if (deps.startChat) {
2299
- await deps.startChat(hatchlingName);
2300
- }
2301
- return "";
2302
- }
2303
- const hatchRunner = deps.runHatchFlow;
2304
- if (!hatchRunner) {
2305
- const response = await deps.sendCommand(deps.socketPath, { kind: "hatch.start" });
2306
- const message = response.summary ?? response.message ?? (response.ok ? "ok" : `error: ${response.error ?? "unknown error"}`);
2307
- deps.writeStdout(message);
2308
- return message;
2309
- }
2310
- const hatchInput = await resolveHatchInput(command, deps);
2311
- const result = await hatchRunner(hatchInput);
2312
- await performSystemSetup(deps);
2313
- const daemonResult = await ensureDaemonRunning(deps);
2314
- if (deps.startChat) {
2315
- await deps.startChat(hatchInput.agentName);
2316
- return "";
2317
- }
2318
- const message = `hatched ${hatchInput.agentName} at ${result.bundleRoot} using specialist identity ${result.selectedIdentity}; ${daemonResult.message}`;
2319
- deps.writeStdout(message);
2320
- return message;
2321
- }
2322
- const daemonCommand = toDaemonCommand(command);
2323
- let response;
2324
- try {
2325
- response = await deps.sendCommand(deps.socketPath, daemonCommand);
2326
- }
2327
- catch (error) {
2328
- if (command.kind === "message.send") {
2329
- const pendingPath = deps.fallbackPendingMessage(command);
2330
- const message = `daemon unavailable; queued message fallback at ${pendingPath}`;
2331
- deps.writeStdout(message);
2332
- return message;
2333
- }
2334
- if (command.kind === "daemon.status" && isDaemonUnavailableError(error)) {
2335
- const message = daemonUnavailableStatusOutput(deps.socketPath);
2336
- deps.writeStdout(message);
2337
- return message;
2338
- }
2339
- if (command.kind === "daemon.stop" && isDaemonUnavailableError(error)) {
2340
- const message = "daemon not running";
2341
- deps.writeStdout(message);
2342
- return message;
2343
- }
2344
- throw error;
2345
- }
2346
- const fallbackMessage = response.summary ?? response.message ?? (response.ok ? "ok" : `error: ${response.error ?? "unknown error"}`);
2347
- const message = command.kind === "daemon.status"
2348
- ? formatDaemonStatusOutput(response, fallbackMessage)
2349
- : fallbackMessage;
2350
- deps.writeStdout(message);
2351
- return message;
2352
- }
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.readFirstBundleMetaVersion = exports.createDefaultOuroCliDeps = exports.pingGithubCopilotModel = exports.summarizeDaemonStartupFailure = exports.listGithubCopilotModels = exports.ensureDaemonRunning = exports.runOuroCli = exports.parseOuroCommand = void 0;
18
+ // ── Parsing ──
19
+ var cli_parse_1 = require("./cli-parse");
20
+ Object.defineProperty(exports, "parseOuroCommand", { enumerable: true, get: function () { return cli_parse_1.parseOuroCommand; } });
21
+ // ── Execution ──
22
+ var cli_exec_1 = require("./cli-exec");
23
+ Object.defineProperty(exports, "runOuroCli", { enumerable: true, get: function () { return cli_exec_1.runOuroCli; } });
24
+ Object.defineProperty(exports, "ensureDaemonRunning", { enumerable: true, get: function () { return cli_exec_1.ensureDaemonRunning; } });
25
+ Object.defineProperty(exports, "listGithubCopilotModels", { enumerable: true, get: function () { return cli_exec_1.listGithubCopilotModels; } });
26
+ Object.defineProperty(exports, "summarizeDaemonStartupFailure", { enumerable: true, get: function () { return cli_exec_1.summarizeDaemonStartupFailure; } });
27
+ var provider_ping_1 = require("../provider-ping");
28
+ Object.defineProperty(exports, "pingGithubCopilotModel", { enumerable: true, get: function () { return provider_ping_1.pingGithubCopilotModel; } });
29
+ // ── Defaults ──
30
+ var cli_defaults_1 = require("./cli-defaults");
31
+ Object.defineProperty(exports, "createDefaultOuroCliDeps", { enumerable: true, get: function () { return cli_defaults_1.createDefaultOuroCliDeps; } });
32
+ Object.defineProperty(exports, "readFirstBundleMetaVersion", { enumerable: true, get: function () { return cli_defaults_1.readFirstBundleMetaVersion; } });