@ouro.bot/cli 0.1.0-alpha.55 → 0.1.0-alpha.551

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 (386) hide show
  1. package/README.md +133 -19
  2. package/RepairGuide.ouro/agent.json +5 -0
  3. package/RepairGuide.ouro/psyche/IDENTITY.md +19 -0
  4. package/RepairGuide.ouro/psyche/SOUL.md +55 -0
  5. package/RepairGuide.ouro/skills/diagnose-bootstrap-drift.md +54 -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/changelog.json +3561 -0
  14. package/dist/arc/attention-types.js +8 -0
  15. package/dist/arc/cares.js +140 -0
  16. package/dist/arc/episodes.js +117 -0
  17. package/dist/arc/intentions.js +133 -0
  18. package/dist/arc/json-store.js +117 -0
  19. package/dist/arc/obligations.js +237 -0
  20. package/dist/arc/packets.js +193 -0
  21. package/dist/arc/presence.js +185 -0
  22. package/dist/arc/task-lifecycle.js +65 -0
  23. package/dist/heart/active-work.js +837 -26
  24. package/dist/heart/agent-entry.js +58 -3
  25. package/dist/heart/attachments/image-normalize.js +194 -0
  26. package/dist/heart/attachments/materialize.js +97 -0
  27. package/dist/heart/attachments/originals.js +88 -0
  28. package/dist/heart/attachments/render.js +29 -0
  29. package/dist/heart/attachments/sources/adapter.js +2 -0
  30. package/dist/heart/attachments/sources/bluebubbles.js +156 -0
  31. package/dist/heart/attachments/sources/cli-local-file.js +78 -0
  32. package/dist/heart/attachments/sources/index.js +16 -0
  33. package/dist/heart/attachments/store.js +103 -0
  34. package/dist/heart/attachments/types.js +93 -0
  35. package/dist/heart/auth/auth-flow.js +479 -0
  36. package/dist/heart/background-operations.js +281 -0
  37. package/dist/heart/bundle-state.js +168 -0
  38. package/dist/heart/commitments.js +111 -0
  39. package/dist/heart/config-registry.js +304 -0
  40. package/dist/heart/config.js +114 -118
  41. package/dist/heart/core.js +925 -246
  42. package/dist/heart/cross-chat-delivery.js +3 -18
  43. package/dist/heart/daemon/agent-config-check.js +512 -0
  44. package/dist/heart/daemon/agent-discovery.js +102 -3
  45. package/dist/heart/daemon/agent-service.js +522 -0
  46. package/dist/heart/daemon/agentic-repair.js +554 -0
  47. package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
  48. package/dist/heart/daemon/boot-sync-probe.js +197 -0
  49. package/dist/heart/daemon/cadence.js +70 -0
  50. package/dist/heart/daemon/cli-defaults.js +665 -0
  51. package/dist/heart/daemon/cli-exec.js +7565 -0
  52. package/dist/heart/daemon/cli-help.js +498 -0
  53. package/dist/heart/daemon/cli-parse.js +1590 -0
  54. package/dist/heart/daemon/cli-render-doctor.js +57 -0
  55. package/dist/heart/daemon/cli-render.js +775 -0
  56. package/dist/heart/daemon/cli-types.js +8 -0
  57. package/dist/heart/daemon/connect-bay.js +323 -0
  58. package/dist/heart/daemon/daemon-cli.js +29 -1672
  59. package/dist/heart/daemon/daemon-entry.js +417 -2
  60. package/dist/heart/daemon/daemon-health.js +183 -0
  61. package/dist/heart/daemon/daemon-rollup.js +58 -0
  62. package/dist/heart/daemon/daemon-runtime-sync.js +87 -13
  63. package/dist/heart/daemon/daemon-tombstone.js +236 -0
  64. package/dist/heart/daemon/daemon.js +796 -71
  65. package/dist/heart/daemon/dns-workflow.js +394 -0
  66. package/dist/heart/daemon/doctor-types.js +8 -0
  67. package/dist/heart/daemon/doctor.js +844 -0
  68. package/dist/heart/daemon/drift-detection.js +146 -0
  69. package/dist/heart/daemon/health-monitor.js +122 -1
  70. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  71. package/dist/heart/daemon/hooks/bundle-meta.js +115 -1
  72. package/dist/heart/daemon/http-health-probe.js +80 -0
  73. package/dist/heart/daemon/human-command-screens.js +234 -0
  74. package/dist/heart/daemon/human-readiness.js +114 -0
  75. package/dist/heart/daemon/inner-status.js +102 -0
  76. package/dist/heart/daemon/interactive-repair.js +394 -0
  77. package/dist/heart/daemon/launchd.js +37 -8
  78. package/dist/heart/daemon/log-tailer.js +82 -12
  79. package/dist/heart/daemon/logs-prune.js +110 -0
  80. package/dist/heart/daemon/mcp-canary.js +297 -0
  81. package/dist/heart/daemon/message-router.js +2 -2
  82. package/dist/heart/daemon/os-cron-deps.js +135 -0
  83. package/dist/heart/daemon/os-cron.js +14 -12
  84. package/dist/heart/daemon/ouro-bot-entry.js +4 -2
  85. package/dist/heart/daemon/ouro-entry.js +3 -1
  86. package/dist/heart/daemon/process-manager.js +375 -33
  87. package/dist/heart/daemon/provider-discovery.js +137 -0
  88. package/dist/heart/daemon/provider-ping-progress.js +83 -0
  89. package/dist/heart/daemon/pulse.js +475 -0
  90. package/dist/heart/daemon/readiness-repair.js +365 -0
  91. package/dist/heart/daemon/run-hooks.js +2 -0
  92. package/dist/heart/daemon/runtime-logging.js +67 -16
  93. package/dist/heart/daemon/runtime-metadata.js +3 -31
  94. package/dist/heart/daemon/safe-mode.js +161 -0
  95. package/dist/heart/daemon/sense-manager.js +353 -38
  96. package/dist/heart/daemon/session-id-resolver.js +131 -0
  97. package/dist/heart/daemon/skill-management-installer.js +94 -0
  98. package/dist/heart/daemon/socket-client.js +158 -11
  99. package/dist/heart/daemon/stale-bundle-prune.js +96 -0
  100. package/dist/heart/daemon/startup-tui.js +330 -0
  101. package/dist/heart/daemon/task-scheduler.js +3 -25
  102. package/dist/heart/daemon/terminal-ui.js +499 -0
  103. package/dist/heart/daemon/thoughts.js +162 -17
  104. package/dist/heart/daemon/up-progress.js +366 -0
  105. package/dist/heart/daemon/vault-items.js +56 -0
  106. package/dist/heart/delegation.js +1 -1
  107. package/dist/heart/habits/habit-migration.js +189 -0
  108. package/dist/heart/habits/habit-parser.js +140 -0
  109. package/dist/heart/habits/habit-runtime-state.js +100 -0
  110. package/dist/heart/habits/habit-scheduler.js +372 -0
  111. package/dist/heart/{daemon → hatch}/hatch-flow.js +52 -117
  112. package/dist/heart/{daemon → hatch}/hatch-specialist.js +6 -8
  113. package/dist/heart/{daemon → hatch}/specialist-prompt.js +12 -9
  114. package/dist/heart/{daemon → hatch}/specialist-tools.js +35 -12
  115. package/dist/heart/identity.js +200 -51
  116. package/dist/heart/kept-notes.js +357 -0
  117. package/dist/heart/kicks.js +1 -1
  118. package/dist/heart/machine-identity.js +161 -0
  119. package/dist/heart/mail-import-discovery.js +353 -0
  120. package/dist/heart/mailbox/mailbox-http-hooks.js +66 -0
  121. package/dist/heart/mailbox/mailbox-http-response.js +7 -0
  122. package/dist/heart/mailbox/mailbox-http-routes.js +246 -0
  123. package/dist/heart/mailbox/mailbox-http-static.js +103 -0
  124. package/dist/heart/mailbox/mailbox-http-transport.js +116 -0
  125. package/dist/heart/mailbox/mailbox-http.js +99 -0
  126. package/dist/heart/mailbox/mailbox-read.js +31 -0
  127. package/dist/heart/mailbox/mailbox-types.js +27 -0
  128. package/dist/heart/mailbox/mailbox-view.js +195 -0
  129. package/dist/heart/mailbox/readers/agent-machine.js +382 -0
  130. package/dist/heart/mailbox/readers/continuity-readers.js +338 -0
  131. package/dist/heart/mailbox/readers/mail.js +362 -0
  132. package/dist/heart/mailbox/readers/runtime-readers.js +651 -0
  133. package/dist/heart/mailbox/readers/sessions.js +232 -0
  134. package/dist/heart/mailbox/readers/shared.js +111 -0
  135. package/dist/heart/mcp/mcp-server.js +683 -0
  136. package/dist/heart/migrate-config.js +100 -0
  137. package/dist/heart/model-capabilities.js +19 -0
  138. package/dist/heart/platform.js +81 -0
  139. package/dist/heart/provider-attempt.js +134 -0
  140. package/dist/heart/provider-binding-resolver.js +255 -0
  141. package/dist/heart/provider-credentials.js +425 -0
  142. package/dist/heart/provider-failover.js +301 -0
  143. package/dist/heart/provider-models.js +81 -0
  144. package/dist/heart/provider-ping.js +262 -0
  145. package/dist/heart/provider-state.js +216 -0
  146. package/dist/heart/provider-visibility.js +188 -0
  147. package/dist/heart/providers/anthropic-token.js +131 -0
  148. package/dist/heart/providers/anthropic.js +139 -52
  149. package/dist/heart/providers/azure.js +97 -13
  150. package/dist/heart/providers/error-classification.js +127 -0
  151. package/dist/heart/providers/github-copilot.js +145 -0
  152. package/dist/heart/providers/minimax-vlm.js +189 -0
  153. package/dist/heart/providers/minimax.js +26 -8
  154. package/dist/heart/providers/openai-codex.js +55 -40
  155. package/dist/heart/runtime-capability-check.js +170 -0
  156. package/dist/heart/runtime-credentials.js +367 -0
  157. package/dist/heart/runtime-cwd.js +87 -0
  158. package/dist/heart/sense-truth.js +11 -4
  159. package/dist/heart/session-activity.js +43 -22
  160. package/dist/heart/session-events.js +1149 -0
  161. package/dist/heart/session-playback-cli-main.js +5 -0
  162. package/dist/heart/session-playback-cli.js +36 -0
  163. package/dist/heart/session-playback.js +231 -0
  164. package/dist/heart/session-stats-cli-main.js +5 -0
  165. package/dist/heart/session-stats.js +182 -0
  166. package/dist/heart/session-transcript.js +243 -0
  167. package/dist/heart/start-of-turn-packet.js +345 -0
  168. package/dist/heart/streaming.js +44 -27
  169. package/dist/heart/sync-classification.js +176 -0
  170. package/dist/heart/sync.js +449 -0
  171. package/dist/heart/target-resolution.js +9 -5
  172. package/dist/heart/tempo.js +93 -0
  173. package/dist/heart/temporal-view.js +41 -0
  174. package/dist/heart/timeouts.js +101 -0
  175. package/dist/heart/tool-activity-callbacks.js +59 -0
  176. package/dist/heart/tool-description.js +139 -0
  177. package/dist/heart/tool-friction.js +55 -0
  178. package/dist/heart/tool-loop.js +200 -0
  179. package/dist/heart/turn-context.js +381 -0
  180. package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +6 -5
  181. package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
  182. package/dist/heart/versioning/ouro-path-installer.js +426 -0
  183. package/dist/heart/versioning/ouro-version-manager.js +295 -0
  184. package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
  185. package/dist/heart/{daemon → versioning}/update-checker.js +6 -1
  186. package/dist/heart/{daemon → versioning}/update-hooks.js +63 -59
  187. package/dist/mailbox-ui/assets/index-BPr5vNuM.css +1 -0
  188. package/dist/mailbox-ui/assets/index-Cm51CY9W.js +61 -0
  189. package/dist/mailbox-ui/index.html +15 -0
  190. package/dist/mailroom/attention.js +167 -0
  191. package/dist/mailroom/autonomy.js +209 -0
  192. package/dist/mailroom/blob-store.js +674 -0
  193. package/dist/mailroom/body-cache.js +61 -0
  194. package/dist/mailroom/core.js +720 -0
  195. package/dist/mailroom/entry.js +160 -0
  196. package/dist/mailroom/file-store.js +430 -0
  197. package/dist/mailroom/mbox-import.js +383 -0
  198. package/dist/mailroom/outbound.js +380 -0
  199. package/dist/mailroom/policy.js +263 -0
  200. package/dist/mailroom/reader.js +233 -0
  201. package/dist/mailroom/search-cache.js +256 -0
  202. package/dist/mailroom/search-relevance.js +319 -0
  203. package/dist/mailroom/smtp-ingress.js +176 -0
  204. package/dist/mailroom/source-state.js +176 -0
  205. package/dist/mailroom/thread.js +109 -0
  206. package/dist/mailroom/travel-extract.js +89 -0
  207. package/dist/mind/bundle-manifest.js +7 -1
  208. package/dist/mind/context.js +165 -101
  209. package/dist/mind/diary-integrity.js +60 -0
  210. package/dist/mind/{memory.js → diary.js} +62 -75
  211. package/dist/mind/embedding-provider.js +60 -0
  212. package/dist/mind/file-state.js +179 -0
  213. package/dist/mind/friends/channel.js +30 -0
  214. package/dist/mind/friends/resolver.js +54 -2
  215. package/dist/mind/friends/store-file.js +39 -3
  216. package/dist/mind/friends/types.js +2 -2
  217. package/dist/mind/journal-index.js +161 -0
  218. package/dist/mind/note-search.js +268 -0
  219. package/dist/mind/obligation-steering.js +221 -0
  220. package/dist/mind/pending.js +4 -0
  221. package/dist/mind/prompt-refresh.js +3 -2
  222. package/dist/mind/prompt.js +995 -123
  223. package/dist/mind/provenance-trust.js +26 -0
  224. package/dist/mind/scrutiny.js +173 -0
  225. package/dist/nerves/cli-logging.js +7 -1
  226. package/dist/nerves/coverage/audit-rules.js +15 -6
  227. package/dist/nerves/coverage/audit.js +28 -2
  228. package/dist/nerves/coverage/cli.js +1 -1
  229. package/dist/nerves/coverage/contract.js +5 -5
  230. package/dist/nerves/coverage/file-completeness.js +139 -5
  231. package/dist/nerves/coverage/run-artifacts.js +1 -1
  232. package/dist/nerves/event-buffer.js +111 -0
  233. package/dist/nerves/index.js +224 -4
  234. package/dist/nerves/observation.js +20 -0
  235. package/dist/nerves/redact.js +79 -0
  236. package/dist/nerves/review/cli-main.js +5 -0
  237. package/dist/nerves/review/cli.js +156 -0
  238. package/dist/nerves/review/core.js +152 -0
  239. package/dist/nerves/runtime.js +5 -1
  240. package/dist/repertoire/ado-client.js +15 -56
  241. package/dist/repertoire/ado-semantic.js +11 -10
  242. package/dist/repertoire/api-client.js +97 -0
  243. package/dist/repertoire/bitwarden-store.js +816 -0
  244. package/dist/repertoire/bundle-templates.js +72 -0
  245. package/dist/repertoire/bw-installer.js +180 -0
  246. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  247. package/dist/repertoire/coding/context-pack.js +330 -0
  248. package/dist/repertoire/coding/feedback.js +197 -30
  249. package/dist/repertoire/coding/manager.js +158 -9
  250. package/dist/repertoire/coding/spawner.js +55 -9
  251. package/dist/repertoire/coding/tools.js +170 -7
  252. package/dist/repertoire/commerce-errors.js +109 -0
  253. package/dist/repertoire/commerce-self-test.js +156 -0
  254. package/dist/repertoire/credential-access.js +111 -0
  255. package/dist/repertoire/duffel-client.js +185 -0
  256. package/dist/repertoire/github-client.js +14 -55
  257. package/dist/repertoire/graph-client.js +11 -52
  258. package/dist/repertoire/guardrails.js +396 -0
  259. package/dist/repertoire/mcp-client.js +295 -0
  260. package/dist/repertoire/mcp-manager.js +362 -0
  261. package/dist/repertoire/mcp-tools.js +63 -0
  262. package/dist/repertoire/shell-sessions.js +133 -0
  263. package/dist/repertoire/skills.js +15 -24
  264. package/dist/repertoire/stripe-client.js +131 -0
  265. package/dist/repertoire/tasks/board.js +31 -5
  266. package/dist/repertoire/tasks/fix.js +182 -0
  267. package/dist/repertoire/tasks/index.js +16 -4
  268. package/dist/repertoire/tasks/lifecycle.js +2 -2
  269. package/dist/repertoire/tasks/parser.js +3 -2
  270. package/dist/repertoire/tasks/scanner.js +194 -37
  271. package/dist/repertoire/tasks/transitions.js +16 -78
  272. package/dist/repertoire/tool-results.js +29 -0
  273. package/dist/repertoire/tools-attachments.js +317 -0
  274. package/dist/repertoire/tools-base.js +47 -1075
  275. package/dist/repertoire/tools-bluebubbles.js +1 -0
  276. package/dist/repertoire/tools-bridge.js +142 -0
  277. package/dist/repertoire/tools-bundle.js +984 -0
  278. package/dist/repertoire/tools-config.js +185 -0
  279. package/dist/repertoire/tools-continuity.js +248 -0
  280. package/dist/repertoire/tools-credential.js +381 -0
  281. package/dist/repertoire/tools-files.js +342 -0
  282. package/dist/repertoire/tools-flight.js +224 -0
  283. package/dist/repertoire/tools-flow.js +119 -0
  284. package/dist/repertoire/tools-github.js +1 -7
  285. package/dist/repertoire/tools-mail.js +1857 -0
  286. package/dist/repertoire/tools-notes.js +421 -0
  287. package/dist/repertoire/tools-session.js +750 -0
  288. package/dist/repertoire/tools-shell.js +120 -0
  289. package/dist/repertoire/tools-stripe.js +180 -0
  290. package/dist/repertoire/tools-surface.js +243 -0
  291. package/dist/repertoire/tools-teams.js +9 -39
  292. package/dist/repertoire/tools-travel.js +125 -0
  293. package/dist/repertoire/tools-trip.js +604 -0
  294. package/dist/repertoire/tools-user-profile.js +144 -0
  295. package/dist/repertoire/tools-vault.js +40 -0
  296. package/dist/repertoire/tools.js +108 -100
  297. package/dist/repertoire/travel-api-client.js +360 -0
  298. package/dist/repertoire/user-profile.js +131 -0
  299. package/dist/repertoire/vault-setup.js +246 -0
  300. package/dist/repertoire/vault-unlock.js +561 -0
  301. package/dist/scripts/claude-code-hook.js +41 -0
  302. package/dist/scripts/claude-code-stop-hook.js +47 -0
  303. package/dist/senses/attention-queue.js +116 -0
  304. package/dist/senses/bluebubbles/active-turns.js +216 -0
  305. package/dist/senses/bluebubbles/attachment-cache.js +53 -0
  306. package/dist/senses/bluebubbles/attachment-download.js +137 -0
  307. package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +219 -18
  308. package/dist/senses/bluebubbles/entry.js +77 -0
  309. package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +20 -3
  310. package/dist/senses/bluebubbles/index.js +2305 -0
  311. package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -70
  312. package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +33 -12
  313. package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +3 -3
  314. package/dist/senses/bluebubbles/processed-log.js +133 -0
  315. package/dist/senses/bluebubbles/replay.js +137 -0
  316. package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +30 -2
  317. package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
  318. package/dist/senses/cli/bracketed-paste.js +82 -0
  319. package/dist/senses/cli/image-paste.js +287 -0
  320. package/dist/senses/cli/image-ref-navigation.js +75 -0
  321. package/dist/senses/cli/ink-app.js +156 -0
  322. package/dist/senses/cli/inline-diff.js +64 -0
  323. package/dist/senses/cli/input-keys.js +174 -0
  324. package/dist/senses/cli/kill-ring.js +86 -0
  325. package/dist/senses/cli/message-list.js +51 -0
  326. package/dist/senses/cli/ouro-tui.js +607 -0
  327. package/dist/senses/cli/spinner-imperative.js +135 -0
  328. package/dist/senses/cli/spinner.js +101 -0
  329. package/dist/senses/cli/status-line.js +60 -0
  330. package/dist/senses/cli/streaming-markdown.js +526 -0
  331. package/dist/senses/cli/tool-display.js +85 -0
  332. package/dist/senses/cli/tool-render.js +85 -0
  333. package/dist/senses/cli/tui-store.js +240 -0
  334. package/dist/senses/cli/virtual-list.js +35 -0
  335. package/dist/senses/cli-entry.js +60 -8
  336. package/dist/senses/cli-layout.js +187 -0
  337. package/dist/senses/cli.js +520 -209
  338. package/dist/senses/commands.js +66 -3
  339. package/dist/senses/habit-turn-message.js +108 -0
  340. package/dist/senses/inner-dialog-worker.js +175 -21
  341. package/dist/senses/inner-dialog.js +330 -27
  342. package/dist/senses/mail-entry.js +66 -0
  343. package/dist/senses/mail.js +379 -0
  344. package/dist/senses/pipeline.js +569 -182
  345. package/dist/senses/proactive-content-guard.js +51 -0
  346. package/dist/senses/shared-turn.js +248 -0
  347. package/dist/senses/surface-tool.js +68 -0
  348. package/dist/senses/teams-entry.js +60 -8
  349. package/dist/senses/teams.js +387 -98
  350. package/dist/senses/trust-gate.js +100 -5
  351. package/dist/trips/core.js +138 -0
  352. package/dist/trips/store.js +146 -0
  353. package/package.json +38 -7
  354. package/skills/agent-commerce.md +106 -0
  355. package/skills/browser-navigation.md +117 -0
  356. package/skills/commerce-setup-guide.md +116 -0
  357. package/skills/commerce-setup.md +84 -0
  358. package/skills/configure-dev-tools.md +101 -0
  359. package/skills/travel-planning.md +138 -0
  360. package/dist/heart/daemon/ouro-path-installer.js +0 -178
  361. package/dist/heart/daemon/subagent-installer.js +0 -166
  362. package/dist/heart/session-recall.js +0 -116
  363. package/dist/mind/associative-recall.js +0 -209
  364. package/dist/senses/bluebubbles-entry.js +0 -13
  365. package/dist/senses/bluebubbles.js +0 -1177
  366. package/dist/senses/debug-activity.js +0 -148
  367. package/subagents/README.md +0 -86
  368. package/subagents/work-doer.md +0 -237
  369. package/subagents/work-merger.md +0 -618
  370. package/subagents/work-planner.md +0 -390
  371. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  372. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  373. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  374. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  375. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  376. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
  377. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  378. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  379. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
  380. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  381. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  382. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
  383. /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
  384. /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
  385. /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
  386. /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
@@ -1,1675 +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.parseOuroCommand = parseOuroCommand;
38
- exports.discoverExistingCredentials = discoverExistingCredentials;
39
- exports.createDefaultOuroCliDeps = createDefaultOuroCliDeps;
40
- exports.runOuroCli = runOuroCli;
41
- const child_process_1 = require("child_process");
42
- const crypto_1 = require("crypto");
43
- const fs = __importStar(require("fs"));
44
- const os = __importStar(require("os"));
45
- const path = __importStar(require("path"));
46
- const identity_1 = require("../identity");
47
- const runtime_1 = require("../../nerves/runtime");
48
- const store_file_1 = require("../../mind/friends/store-file");
49
- const types_1 = require("../../mind/friends/types");
50
- const ouro_uti_1 = require("./ouro-uti");
51
- const ouro_path_installer_1 = require("./ouro-path-installer");
52
- const subagent_installer_1 = require("./subagent-installer");
53
- const hatch_flow_1 = require("./hatch-flow");
54
- const specialist_orchestrator_1 = require("./specialist-orchestrator");
55
- const specialist_prompt_1 = require("./specialist-prompt");
56
- const specialist_tools_1 = require("./specialist-tools");
57
- const runtime_metadata_1 = require("./runtime-metadata");
58
- const runtime_mode_1 = require("./runtime-mode");
59
- const daemon_runtime_sync_1 = require("./daemon-runtime-sync");
60
- const agent_discovery_1 = require("./agent-discovery");
61
- const update_hooks_1 = require("./update-hooks");
62
- const bundle_meta_1 = require("./hooks/bundle-meta");
63
- const bundle_manifest_1 = require("../../mind/bundle-manifest");
64
- const tasks_1 = require("../../repertoire/tasks");
65
- const thoughts_1 = require("./thoughts");
66
- const ouro_bot_global_installer_1 = require("./ouro-bot-global-installer");
67
- const launchd_1 = require("./launchd");
68
- const socket_client_1 = require("./socket-client");
69
- const session_activity_1 = require("../session-activity");
70
- function stringField(value) {
71
- return typeof value === "string" ? value : null;
72
- }
73
- function numberField(value) {
74
- return typeof value === "number" && Number.isFinite(value) ? value : null;
75
- }
76
- function booleanField(value) {
77
- return typeof value === "boolean" ? value : null;
78
- }
79
- function parseStatusPayload(data) {
80
- if (!data || typeof data !== "object" || Array.isArray(data))
81
- return null;
82
- const raw = data;
83
- const overview = raw.overview;
84
- const senses = raw.senses;
85
- const workers = raw.workers;
86
- if (!overview || typeof overview !== "object" || Array.isArray(overview))
87
- return null;
88
- if (!Array.isArray(senses) || !Array.isArray(workers))
89
- return null;
90
- const parsedOverview = {
91
- daemon: stringField(overview.daemon) ?? "unknown",
92
- health: stringField(overview.health) ?? "unknown",
93
- socketPath: stringField(overview.socketPath) ?? "unknown",
94
- version: stringField(overview.version) ?? "unknown",
95
- lastUpdated: stringField(overview.lastUpdated) ?? "unknown",
96
- repoRoot: stringField(overview.repoRoot) ?? "unknown",
97
- configFingerprint: stringField(overview.configFingerprint) ?? "unknown",
98
- workerCount: numberField(overview.workerCount) ?? 0,
99
- senseCount: numberField(overview.senseCount) ?? 0,
100
- entryPath: stringField(overview.entryPath) ?? "unknown",
101
- mode: stringField(overview.mode) ?? "unknown",
102
- };
103
- const parsedSenses = senses.map((entry) => {
104
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
105
- return null;
106
- const row = entry;
107
- const agent = stringField(row.agent);
108
- const sense = stringField(row.sense);
109
- const status = stringField(row.status);
110
- const detail = stringField(row.detail);
111
- const enabled = booleanField(row.enabled);
112
- if (!agent || !sense || !status || detail === null || enabled === null)
113
- return null;
114
- return {
115
- agent,
116
- sense,
117
- label: stringField(row.label) ?? undefined,
118
- enabled,
119
- status,
120
- detail,
121
- };
122
- });
123
- const parsedWorkers = workers.map((entry) => {
124
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
125
- return null;
126
- const row = entry;
127
- const agent = stringField(row.agent);
128
- const worker = stringField(row.worker);
129
- const status = stringField(row.status);
130
- const restartCount = numberField(row.restartCount);
131
- const hasPid = Object.prototype.hasOwnProperty.call(row, "pid");
132
- const pid = row.pid === null ? null : numberField(row.pid);
133
- const pidInvalid = !hasPid || (row.pid !== null && pid === null);
134
- if (!agent || !worker || !status || restartCount === null || pidInvalid)
135
- return null;
136
- return {
137
- agent,
138
- worker,
139
- status,
140
- pid,
141
- restartCount,
142
- };
143
- });
144
- if (parsedSenses.some((row) => row === null) || parsedWorkers.some((row) => row === null))
145
- return null;
146
- return {
147
- overview: parsedOverview,
148
- senses: parsedSenses,
149
- workers: parsedWorkers,
150
- };
151
- }
152
- function humanizeSenseName(sense, label) {
153
- if (label)
154
- return label;
155
- if (sense === "cli")
156
- return "CLI";
157
- if (sense === "bluebubbles")
158
- return "BlueBubbles";
159
- if (sense === "teams")
160
- return "Teams";
161
- return sense;
162
- }
163
- function formatTable(headers, rows) {
164
- const widths = headers.map((header, index) => Math.max(header.length, ...rows.map((row) => row[index].length)));
165
- const renderRow = (row) => `| ${row.map((cell, index) => cell.padEnd(widths[index])).join(" | ")} |`;
166
- const divider = `|-${widths.map((width) => "-".repeat(width)).join("-|-")}-|`;
167
- return [
168
- renderRow(headers),
169
- divider,
170
- ...rows.map(renderRow),
171
- ].join("\n");
172
- }
173
- function formatDaemonStatusOutput(response, fallback) {
174
- const payload = parseStatusPayload(response.data);
175
- if (!payload)
176
- return fallback;
177
- const overviewRows = [
178
- ["Daemon", payload.overview.daemon],
179
- ["Socket", payload.overview.socketPath],
180
- ["Version", payload.overview.version],
181
- ["Last Updated", payload.overview.lastUpdated],
182
- ["Entry Path", payload.overview.entryPath],
183
- ["Mode", payload.overview.mode],
184
- ["Workers", String(payload.overview.workerCount)],
185
- ["Senses", String(payload.overview.senseCount)],
186
- ["Health", payload.overview.health],
187
- ];
188
- const senseRows = payload.senses.map((row) => [
189
- row.agent,
190
- humanizeSenseName(row.sense, row.label),
191
- row.enabled ? "ON" : "OFF",
192
- row.status,
193
- row.detail,
194
- ]);
195
- const workerRows = payload.workers.map((row) => [
196
- row.agent,
197
- row.worker,
198
- row.status,
199
- row.pid === null ? "n/a" : String(row.pid),
200
- String(row.restartCount),
201
- ]);
202
- return [
203
- "Overview",
204
- formatTable(["Item", "Value"], overviewRows),
205
- "",
206
- "Senses",
207
- formatTable(["Agent", "Sense", "Enabled", "State", "Detail"], senseRows),
208
- "",
209
- "Workers",
210
- formatTable(["Agent", "Worker", "State", "PID", "Restarts"], workerRows),
211
- ].join("\n");
212
- }
213
- async function ensureDaemonRunning(deps) {
214
- const alive = await deps.checkSocketAlive(deps.socketPath);
215
- if (alive) {
216
- const localRuntime = (0, runtime_metadata_1.getRuntimeMetadata)();
217
- let runningRuntimePromise = null;
218
- const fetchRunningRuntimeMetadata = async () => {
219
- runningRuntimePromise ??= (async () => {
220
- const status = await deps.sendCommand(deps.socketPath, { kind: "daemon.status" });
221
- const payload = parseStatusPayload(status.data);
222
- return {
223
- version: payload?.overview.version ?? "unknown",
224
- lastUpdated: payload?.overview.lastUpdated ?? "unknown",
225
- repoRoot: payload?.overview.repoRoot ?? "unknown",
226
- configFingerprint: payload?.overview.configFingerprint ?? "unknown",
227
- };
228
- })();
229
- return runningRuntimePromise;
230
- };
231
- return (0, daemon_runtime_sync_1.ensureCurrentDaemonRuntime)({
232
- socketPath: deps.socketPath,
233
- localVersion: localRuntime.version,
234
- localLastUpdated: localRuntime.lastUpdated,
235
- localRepoRoot: localRuntime.repoRoot,
236
- localConfigFingerprint: localRuntime.configFingerprint,
237
- fetchRunningVersion: async () => (await fetchRunningRuntimeMetadata()).version,
238
- fetchRunningRuntimeMetadata,
239
- stopDaemon: async () => {
240
- await deps.sendCommand(deps.socketPath, { kind: "daemon.stop" });
241
- },
242
- cleanupStaleSocket: deps.cleanupStaleSocket,
243
- startDaemonProcess: deps.startDaemonProcess,
244
- });
245
- }
246
- deps.cleanupStaleSocket(deps.socketPath);
247
- const started = await deps.startDaemonProcess(deps.socketPath);
248
- return {
249
- alreadyRunning: false,
250
- message: `daemon started (pid ${started.pid ?? "unknown"})`,
251
- };
252
- }
253
2
  /**
254
- * Extract `--agent <name>` from an args array, returning the agent name and
255
- * the remaining args with the flag pair removed.
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.
256
15
  */
257
- function extractAgentFlag(args) {
258
- const idx = args.indexOf("--agent");
259
- if (idx === -1 || idx + 1 >= args.length)
260
- return { rest: args };
261
- const agent = args[idx + 1];
262
- const rest = [...args.slice(0, idx), ...args.slice(idx + 2)];
263
- return { agent, rest };
264
- }
265
- function usage() {
266
- return [
267
- "Usage:",
268
- " ouro [up]",
269
- " ouro stop|down|status|logs|hatch",
270
- " ouro -v|--version",
271
- " ouro chat <agent>",
272
- " ouro msg --to <agent> [--session <id>] [--task <ref>] <message>",
273
- " ouro poke <agent> --task <task-id>",
274
- " ouro link <agent> --friend <id> --provider <provider> --external-id <external-id>",
275
- " ouro task board [<status>] [--agent <name>]",
276
- " ouro task create <title> [--type <type>] [--agent <name>]",
277
- " ouro task update <id> <status> [--agent <name>]",
278
- " ouro task show <id> [--agent <name>]",
279
- " ouro task actionable|deps|sessions [--agent <name>]",
280
- " ouro reminder create <title> --body <body> [--at <iso>] [--cadence <interval>] [--category <category>] [--agent <name>]",
281
- " ouro friend list [--agent <name>]",
282
- " ouro friend show <id> [--agent <name>]",
283
- " ouro friend create --name <name> [--trust <level>] [--agent <name>]",
284
- " ouro thoughts [--last <n>] [--json] [--follow] [--agent <name>]",
285
- " ouro friend link <agent> --friend <id> --provider <p> --external-id <eid>",
286
- " ouro friend unlink <agent> --friend <id> --provider <p> --external-id <eid>",
287
- " ouro whoami [--agent <name>]",
288
- " ouro session list [--agent <name>]",
289
- ].join("\n");
290
- }
291
- function formatVersionOutput() {
292
- return (0, runtime_metadata_1.getRuntimeMetadata)().version;
293
- }
294
- function buildStoppedStatusPayload(socketPath) {
295
- const metadata = (0, runtime_metadata_1.getRuntimeMetadata)();
296
- const repoRoot = (0, identity_1.getRepoRoot)();
297
- return {
298
- overview: {
299
- daemon: "stopped",
300
- health: "warn",
301
- socketPath,
302
- version: metadata.version,
303
- lastUpdated: metadata.lastUpdated,
304
- repoRoot: metadata.repoRoot,
305
- configFingerprint: metadata.configFingerprint,
306
- workerCount: 0,
307
- senseCount: 0,
308
- entryPath: path.join(repoRoot, "dist", "heart", "daemon", "daemon-entry.js"),
309
- mode: (0, runtime_mode_1.detectRuntimeMode)(repoRoot),
310
- },
311
- senses: [],
312
- workers: [],
313
- };
314
- }
315
- function daemonUnavailableStatusOutput(socketPath) {
316
- return [
317
- formatDaemonStatusOutput({
318
- ok: true,
319
- summary: "daemon not running",
320
- data: buildStoppedStatusPayload(socketPath),
321
- }, "daemon not running"),
322
- "",
323
- "daemon not running; run `ouro up`",
324
- ].join("\n");
325
- }
326
- function isDaemonUnavailableError(error) {
327
- const code = typeof error === "object" && error !== null && "code" in error
328
- ? String(error.code ?? "")
329
- : "";
330
- return code === "ENOENT" || code === "ECONNREFUSED";
331
- }
332
- function parseMessageCommand(args) {
333
- let to;
334
- let sessionId;
335
- let taskRef;
336
- const messageParts = [];
337
- for (let i = 0; i < args.length; i += 1) {
338
- const token = args[i];
339
- if (token === "--to") {
340
- to = args[i + 1];
341
- i += 1;
342
- continue;
343
- }
344
- if (token === "--session") {
345
- sessionId = args[i + 1];
346
- i += 1;
347
- continue;
348
- }
349
- if (token === "--task") {
350
- taskRef = args[i + 1];
351
- i += 1;
352
- continue;
353
- }
354
- messageParts.push(token);
355
- }
356
- const content = messageParts.join(" ").trim();
357
- if (!to || !content)
358
- throw new Error(`Usage\n${usage()}`);
359
- return {
360
- kind: "message.send",
361
- from: "ouro-cli",
362
- to,
363
- content,
364
- sessionId,
365
- taskRef,
366
- };
367
- }
368
- function parsePokeCommand(args) {
369
- const agent = args[0];
370
- if (!agent)
371
- throw new Error(`Usage\n${usage()}`);
372
- let taskId;
373
- for (let i = 1; i < args.length; i += 1) {
374
- if (args[i] === "--task") {
375
- taskId = args[i + 1];
376
- i += 1;
377
- }
378
- }
379
- if (!taskId)
380
- throw new Error(`Usage\n${usage()}`);
381
- return { kind: "task.poke", agent, taskId };
382
- }
383
- function parseLinkCommand(args, kind = "friend.link") {
384
- const agent = args[0];
385
- if (!agent)
386
- throw new Error(`Usage\n${usage()}`);
387
- let friendId;
388
- let providerRaw;
389
- let externalId;
390
- for (let i = 1; i < args.length; i += 1) {
391
- const token = args[i];
392
- if (token === "--friend") {
393
- friendId = args[i + 1];
394
- i += 1;
395
- continue;
396
- }
397
- if (token === "--provider") {
398
- providerRaw = args[i + 1];
399
- i += 1;
400
- continue;
401
- }
402
- if (token === "--external-id") {
403
- externalId = args[i + 1];
404
- i += 1;
405
- continue;
406
- }
407
- }
408
- if (!friendId || !providerRaw || !externalId) {
409
- throw new Error(`Usage\n${usage()}`);
410
- }
411
- if (!(0, types_1.isIdentityProvider)(providerRaw)) {
412
- throw new Error(`Unknown identity provider '${providerRaw}'. Use aad|local|teams-conversation.`);
413
- }
414
- return {
415
- kind,
416
- agent,
417
- friendId,
418
- provider: providerRaw,
419
- externalId,
420
- };
421
- }
422
- function isAgentProvider(value) {
423
- return value === "azure" || value === "anthropic" || value === "minimax" || value === "openai-codex";
424
- }
425
- function parseHatchCommand(args) {
426
- let agentName;
427
- let humanName;
428
- let providerRaw;
429
- let migrationPath;
430
- const credentials = {};
431
- for (let i = 0; i < args.length; i += 1) {
432
- const token = args[i];
433
- if (token === "--agent") {
434
- agentName = args[i + 1];
435
- i += 1;
436
- continue;
437
- }
438
- if (token === "--human") {
439
- humanName = args[i + 1];
440
- i += 1;
441
- continue;
442
- }
443
- if (token === "--provider") {
444
- providerRaw = args[i + 1];
445
- i += 1;
446
- continue;
447
- }
448
- if (token === "--setup-token") {
449
- credentials.setupToken = args[i + 1];
450
- i += 1;
451
- continue;
452
- }
453
- if (token === "--oauth-token") {
454
- credentials.oauthAccessToken = args[i + 1];
455
- i += 1;
456
- continue;
457
- }
458
- if (token === "--api-key") {
459
- credentials.apiKey = args[i + 1];
460
- i += 1;
461
- continue;
462
- }
463
- if (token === "--endpoint") {
464
- credentials.endpoint = args[i + 1];
465
- i += 1;
466
- continue;
467
- }
468
- if (token === "--deployment") {
469
- credentials.deployment = args[i + 1];
470
- i += 1;
471
- continue;
472
- }
473
- if (token === "--migration-path") {
474
- migrationPath = args[i + 1];
475
- i += 1;
476
- continue;
477
- }
478
- }
479
- if (providerRaw && !isAgentProvider(providerRaw)) {
480
- throw new Error("Unknown provider. Use azure|anthropic|minimax|openai-codex.");
481
- }
482
- const provider = providerRaw && isAgentProvider(providerRaw) ? providerRaw : undefined;
483
- return {
484
- kind: "hatch.start",
485
- agentName,
486
- humanName,
487
- provider,
488
- credentials: Object.keys(credentials).length > 0 ? credentials : undefined,
489
- migrationPath,
490
- };
491
- }
492
- function parseTaskCommand(args) {
493
- const { agent, rest: cleaned } = extractAgentFlag(args);
494
- const [sub, ...rest] = cleaned;
495
- if (!sub)
496
- throw new Error(`Usage\n${usage()}`);
497
- if (sub === "board") {
498
- const status = rest[0];
499
- return status
500
- ? { kind: "task.board", status, ...(agent ? { agent } : {}) }
501
- : { kind: "task.board", ...(agent ? { agent } : {}) };
502
- }
503
- if (sub === "create") {
504
- const title = rest[0];
505
- if (!title)
506
- throw new Error(`Usage\n${usage()}`);
507
- let type;
508
- for (let i = 1; i < rest.length; i++) {
509
- if (rest[i] === "--type" && rest[i + 1]) {
510
- type = rest[i + 1];
511
- i += 1;
512
- }
513
- }
514
- return type
515
- ? { kind: "task.create", title, type, ...(agent ? { agent } : {}) }
516
- : { kind: "task.create", title, ...(agent ? { agent } : {}) };
517
- }
518
- if (sub === "update") {
519
- const id = rest[0];
520
- const status = rest[1];
521
- if (!id || !status)
522
- throw new Error(`Usage\n${usage()}`);
523
- return { kind: "task.update", id, status, ...(agent ? { agent } : {}) };
524
- }
525
- if (sub === "show") {
526
- const id = rest[0];
527
- if (!id)
528
- throw new Error(`Usage\n${usage()}`);
529
- return { kind: "task.show", id, ...(agent ? { agent } : {}) };
530
- }
531
- if (sub === "actionable")
532
- return { kind: "task.actionable", ...(agent ? { agent } : {}) };
533
- if (sub === "deps")
534
- return { kind: "task.deps", ...(agent ? { agent } : {}) };
535
- if (sub === "sessions")
536
- return { kind: "task.sessions", ...(agent ? { agent } : {}) };
537
- throw new Error(`Usage\n${usage()}`);
538
- }
539
- function parseReminderCommand(args) {
540
- const { agent, rest: cleaned } = extractAgentFlag(args);
541
- const [sub, ...rest] = cleaned;
542
- if (!sub)
543
- throw new Error(`Usage\n${usage()}`);
544
- if (sub === "create") {
545
- const title = rest[0];
546
- if (!title)
547
- throw new Error(`Usage\n${usage()}`);
548
- let body;
549
- let scheduledAt;
550
- let cadence;
551
- let category;
552
- let requester;
553
- for (let i = 1; i < rest.length; i++) {
554
- if (rest[i] === "--body" && rest[i + 1]) {
555
- body = rest[i + 1];
556
- i += 1;
557
- }
558
- else if (rest[i] === "--at" && rest[i + 1]) {
559
- scheduledAt = rest[i + 1];
560
- i += 1;
561
- }
562
- else if (rest[i] === "--cadence" && rest[i + 1]) {
563
- cadence = rest[i + 1];
564
- i += 1;
565
- }
566
- else if (rest[i] === "--category" && rest[i + 1]) {
567
- category = rest[i + 1];
568
- i += 1;
569
- }
570
- else if (rest[i] === "--requester" && rest[i + 1]) {
571
- requester = rest[i + 1];
572
- i += 1;
573
- }
574
- }
575
- if (!body)
576
- throw new Error(`Usage\n${usage()}`);
577
- if (!scheduledAt && !cadence)
578
- throw new Error(`Usage\n${usage()}`);
579
- return {
580
- kind: "reminder.create",
581
- title,
582
- body,
583
- ...(scheduledAt ? { scheduledAt } : {}),
584
- ...(cadence ? { cadence } : {}),
585
- ...(category ? { category } : {}),
586
- ...(requester ? { requester } : {}),
587
- ...(agent ? { agent } : {}),
588
- };
589
- }
590
- throw new Error(`Usage\n${usage()}`);
591
- }
592
- function parseSessionCommand(args) {
593
- const { agent, rest: cleaned } = extractAgentFlag(args);
594
- const [sub] = cleaned;
595
- if (!sub)
596
- throw new Error(`Usage\n${usage()}`);
597
- if (sub === "list")
598
- return { kind: "session.list", ...(agent ? { agent } : {}) };
599
- throw new Error(`Usage\n${usage()}`);
600
- }
601
- function parseThoughtsCommand(args) {
602
- const { agent, rest: cleaned } = extractAgentFlag(args);
603
- let last;
604
- let json = false;
605
- let follow = false;
606
- for (let i = 0; i < cleaned.length; i++) {
607
- if (cleaned[i] === "--last" && i + 1 < cleaned.length) {
608
- last = Number.parseInt(cleaned[i + 1], 10);
609
- i++;
610
- }
611
- if (cleaned[i] === "--json")
612
- json = true;
613
- if (cleaned[i] === "--follow" || cleaned[i] === "-f")
614
- follow = true;
615
- }
616
- return { kind: "thoughts", ...(agent ? { agent } : {}), ...(last ? { last } : {}), ...(json ? { json } : {}), ...(follow ? { follow } : {}) };
617
- }
618
- function parseFriendCommand(args) {
619
- const { agent, rest: cleaned } = extractAgentFlag(args);
620
- const [sub, ...rest] = cleaned;
621
- if (!sub)
622
- throw new Error(`Usage\n${usage()}`);
623
- if (sub === "list")
624
- return { kind: "friend.list", ...(agent ? { agent } : {}) };
625
- if (sub === "show") {
626
- const friendId = rest[0];
627
- if (!friendId)
628
- throw new Error(`Usage\n${usage()}`);
629
- return { kind: "friend.show", friendId, ...(agent ? { agent } : {}) };
630
- }
631
- if (sub === "create") {
632
- let name;
633
- let trustLevel;
634
- for (let i = 0; i < rest.length; i++) {
635
- if (rest[i] === "--name" && rest[i + 1]) {
636
- name = rest[i + 1];
637
- i += 1;
638
- }
639
- else if (rest[i] === "--trust" && rest[i + 1]) {
640
- trustLevel = rest[i + 1];
641
- i += 1;
642
- }
643
- }
644
- if (!name)
645
- throw new Error(`Usage\n${usage()}`);
646
- return {
647
- kind: "friend.create",
648
- name,
649
- ...(trustLevel ? { trustLevel } : {}),
650
- ...(agent ? { agent } : {}),
651
- };
652
- }
653
- if (sub === "link")
654
- return parseLinkCommand(rest, "friend.link");
655
- if (sub === "unlink")
656
- return parseLinkCommand(rest, "friend.unlink");
657
- throw new Error(`Usage\n${usage()}`);
658
- }
659
- function parseOuroCommand(args) {
660
- const [head, second] = args;
661
- if (!head)
662
- return { kind: "daemon.up" };
663
- if (head === "up")
664
- return { kind: "daemon.up" };
665
- if (head === "stop" || head === "down")
666
- return { kind: "daemon.stop" };
667
- if (head === "status")
668
- return { kind: "daemon.status" };
669
- if (head === "logs")
670
- return { kind: "daemon.logs" };
671
- if (head === "hatch")
672
- return parseHatchCommand(args.slice(1));
673
- if (head === "task")
674
- return parseTaskCommand(args.slice(1));
675
- if (head === "reminder")
676
- return parseReminderCommand(args.slice(1));
677
- if (head === "friend")
678
- return parseFriendCommand(args.slice(1));
679
- if (head === "whoami") {
680
- const { agent } = extractAgentFlag(args.slice(1));
681
- return { kind: "whoami", ...(agent ? { agent } : {}) };
682
- }
683
- if (head === "session")
684
- return parseSessionCommand(args.slice(1));
685
- if (head === "thoughts")
686
- return parseThoughtsCommand(args.slice(1));
687
- if (head === "chat") {
688
- if (!second)
689
- throw new Error(`Usage\n${usage()}`);
690
- return { kind: "chat.connect", agent: second };
691
- }
692
- if (head === "msg")
693
- return parseMessageCommand(args.slice(1));
694
- if (head === "poke")
695
- return parsePokeCommand(args.slice(1));
696
- if (head === "link")
697
- return parseLinkCommand(args.slice(1));
698
- throw new Error(`Unknown command '${args.join(" ")}'.\n${usage()}`);
699
- }
700
- function defaultStartDaemonProcess(socketPath) {
701
- const entry = path.join((0, identity_1.getRepoRoot)(), "dist", "heart", "daemon", "daemon-entry.js");
702
- const child = (0, child_process_1.spawn)("node", [entry, "--socket", socketPath], {
703
- detached: true,
704
- stdio: "ignore",
705
- });
706
- child.unref();
707
- return Promise.resolve({ pid: child.pid ?? null });
708
- }
709
- function defaultWriteStdout(text) {
710
- // eslint-disable-next-line no-console -- terminal UX: CLI command output
711
- console.log(text);
712
- }
713
- function defaultCleanupStaleSocket(socketPath) {
714
- if (fs.existsSync(socketPath)) {
715
- fs.unlinkSync(socketPath);
716
- }
717
- }
718
- function defaultFallbackPendingMessage(command) {
719
- const inboxDir = path.join((0, identity_1.getAgentBundlesRoot)(), `${command.to}.ouro`, "inbox");
720
- const pendingPath = path.join(inboxDir, "pending.jsonl");
721
- const queuedAt = new Date().toISOString();
722
- const payload = {
723
- from: command.from,
724
- to: command.to,
725
- content: command.content,
726
- priority: command.priority ?? "normal",
727
- sessionId: command.sessionId,
728
- taskRef: command.taskRef,
729
- queuedAt,
730
- };
731
- fs.mkdirSync(inboxDir, { recursive: true });
732
- fs.appendFileSync(pendingPath, `${JSON.stringify(payload)}\n`, "utf-8");
733
- (0, runtime_1.emitNervesEvent)({
734
- level: "warn",
735
- component: "daemon",
736
- event: "daemon.message_fallback_queued",
737
- message: "queued message to pending fallback file",
738
- meta: {
739
- to: command.to,
740
- path: pendingPath,
741
- sessionId: command.sessionId ?? null,
742
- taskRef: command.taskRef ?? null,
743
- },
744
- });
745
- return pendingPath;
746
- }
747
- function defaultEnsureDaemonBootPersistence(socketPath) {
748
- if (process.platform !== "darwin") {
749
- return;
750
- }
751
- const homeDir = os.homedir();
752
- const launchdDeps = {
753
- exec: (cmd) => { (0, child_process_1.execSync)(cmd, { stdio: "ignore" }); },
754
- writeFile: (filePath, content) => fs.writeFileSync(filePath, content, "utf-8"),
755
- removeFile: (filePath) => fs.rmSync(filePath, { force: true }),
756
- existsFile: (filePath) => fs.existsSync(filePath),
757
- mkdirp: (dir) => fs.mkdirSync(dir, { recursive: true }),
758
- homeDir,
759
- userUid: process.getuid?.() ?? 0,
760
- };
761
- const entryPath = path.join((0, identity_1.getRepoRoot)(), "dist", "heart", "daemon", "daemon-entry.js");
762
- /* 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 */
763
- if (!fs.existsSync(entryPath)) {
764
- (0, runtime_1.emitNervesEvent)({
765
- level: "warn",
766
- component: "daemon",
767
- event: "daemon.entry_path_missing",
768
- message: "entryPath does not exist on disk — plist may point to a stale location. Run 'ouro daemon install' from the correct location.",
769
- meta: { entryPath },
770
- });
771
- }
772
- const logDir = path.join(homeDir, ".agentstate", "daemon", "logs");
773
- (0, launchd_1.installLaunchAgent)(launchdDeps, {
774
- nodePath: process.execPath,
775
- entryPath,
776
- socketPath,
777
- logDir,
778
- envPath: process.env.PATH,
779
- });
780
- }
781
- async function defaultInstallSubagents() {
782
- return (0, subagent_installer_1.installSubagentsForAvailableCli)({
783
- repoRoot: (0, identity_1.getRepoRoot)(),
784
- });
785
- }
786
- async function defaultPromptInput(question) {
787
- const readline = await Promise.resolve().then(() => __importStar(require("readline/promises")));
788
- const rl = readline.createInterface({
789
- input: process.stdin,
790
- output: process.stdout,
791
- });
792
- try {
793
- const response = await rl.question(question);
794
- return response.trim();
795
- }
796
- finally {
797
- rl.close();
798
- }
799
- }
800
- function defaultListDiscoveredAgents() {
801
- return (0, agent_discovery_1.listEnabledBundleAgents)({
802
- bundlesRoot: (0, identity_1.getAgentBundlesRoot)(),
803
- readdirSync: fs.readdirSync,
804
- readFileSync: fs.readFileSync,
805
- });
806
- }
807
- function discoverExistingCredentials(secretsRoot) {
808
- const found = [];
809
- let entries;
810
- try {
811
- entries = fs.readdirSync(secretsRoot, { withFileTypes: true });
812
- }
813
- catch {
814
- return found;
815
- }
816
- for (const entry of entries) {
817
- if (!entry.isDirectory())
818
- continue;
819
- const secretsPath = path.join(secretsRoot, entry.name, "secrets.json");
820
- let raw;
821
- try {
822
- raw = fs.readFileSync(secretsPath, "utf-8");
823
- }
824
- catch {
825
- continue;
826
- }
827
- let parsed;
828
- try {
829
- parsed = JSON.parse(raw);
830
- }
831
- catch {
832
- continue;
833
- }
834
- if (!parsed.providers)
835
- continue;
836
- for (const [provName, provConfig] of Object.entries(parsed.providers)) {
837
- if (provName === "anthropic" && provConfig.setupToken) {
838
- found.push({ agentName: entry.name, provider: "anthropic", credentials: { setupToken: provConfig.setupToken }, providerConfig: { ...provConfig } });
839
- }
840
- else if (provName === "openai-codex" && provConfig.oauthAccessToken) {
841
- found.push({ agentName: entry.name, provider: "openai-codex", credentials: { oauthAccessToken: provConfig.oauthAccessToken }, providerConfig: { ...provConfig } });
842
- }
843
- else if (provName === "minimax" && provConfig.apiKey) {
844
- found.push({ agentName: entry.name, provider: "minimax", credentials: { apiKey: provConfig.apiKey }, providerConfig: { ...provConfig } });
845
- }
846
- else if (provName === "azure" && provConfig.apiKey && provConfig.endpoint && provConfig.deployment) {
847
- found.push({ agentName: entry.name, provider: "azure", credentials: { apiKey: provConfig.apiKey, endpoint: provConfig.endpoint, deployment: provConfig.deployment }, providerConfig: { ...provConfig } });
848
- }
849
- }
850
- }
851
- // Deduplicate by provider+credential value (keep first seen)
852
- const seen = new Set();
853
- return found.filter((cred) => {
854
- const key = `${cred.provider}:${JSON.stringify(cred.credentials)}`;
855
- if (seen.has(key))
856
- return false;
857
- seen.add(key);
858
- return true;
859
- });
860
- }
861
- /* v8 ignore start -- integration: interactive terminal specialist session @preserve */
862
- async function defaultRunAdoptionSpecialist() {
863
- const { runCliSession } = await Promise.resolve().then(() => __importStar(require("../../senses/cli")));
864
- const { patchRuntimeConfig } = await Promise.resolve().then(() => __importStar(require("../config")));
865
- const { setAgentName, setAgentConfigOverride } = await Promise.resolve().then(() => __importStar(require("../identity")));
866
- const readlinePromises = await Promise.resolve().then(() => __importStar(require("readline/promises")));
867
- const crypto = await Promise.resolve().then(() => __importStar(require("crypto")));
868
- // Phase 1: cold CLI — collect provider/credentials with a simple readline
869
- const coldRl = readlinePromises.createInterface({ input: process.stdin, output: process.stdout });
870
- const coldPrompt = async (q) => {
871
- const answer = await coldRl.question(q);
872
- return answer.trim();
873
- };
874
- let providerRaw;
875
- let credentials = {};
876
- let providerConfig = {};
877
- const tempDir = path.join(os.tmpdir(), `ouro-hatch-${crypto.randomUUID()}`);
878
- try {
879
- const secretsRoot = path.join(os.homedir(), ".agentsecrets");
880
- const discovered = discoverExistingCredentials(secretsRoot);
881
- const existingBundleCount = (0, specialist_orchestrator_1.listExistingBundles)((0, identity_1.getAgentBundlesRoot)()).length;
882
- const hatchVerb = existingBundleCount > 0 ? "let's hatch a new agent." : "let's hatch your first agent.";
883
- // Default models per provider (used when entering new credentials)
884
- const defaultModels = {
885
- anthropic: "claude-opus-4-6",
886
- minimax: "MiniMax-Text-01",
887
- "openai-codex": "gpt-5.4",
888
- azure: "",
889
- };
890
- if (discovered.length > 0) {
891
- process.stdout.write(`\n\ud83d\udc0d welcome to ouroboros! ${hatchVerb}\n`);
892
- process.stdout.write("i found existing API credentials:\n\n");
893
- const unique = [...new Map(discovered.map((d) => [`${d.provider}`, d])).values()];
894
- for (let i = 0; i < unique.length; i++) {
895
- const model = unique[i].providerConfig.model || unique[i].providerConfig.deployment || "";
896
- const modelLabel = model ? `, ${model}` : "";
897
- process.stdout.write(` ${i + 1}. ${unique[i].provider}${modelLabel} (from ${unique[i].agentName})\n`);
898
- }
899
- process.stdout.write("\n");
900
- const choice = await coldPrompt("use one of these? enter number, or 'new' for a different key: ");
901
- const idx = parseInt(choice, 10) - 1;
902
- if (idx >= 0 && idx < unique.length) {
903
- providerRaw = unique[idx].provider;
904
- credentials = unique[idx].credentials;
905
- providerConfig = unique[idx].providerConfig;
906
- }
907
- else {
908
- const pRaw = await coldPrompt("provider (anthropic/azure/minimax/openai-codex): ");
909
- if (!isAgentProvider(pRaw)) {
910
- process.stdout.write("unknown provider. run `ouro hatch` to try again.\n");
911
- coldRl.close();
912
- return null;
913
- }
914
- providerRaw = pRaw;
915
- providerConfig = { model: defaultModels[providerRaw] };
916
- if (providerRaw === "anthropic")
917
- credentials.setupToken = await coldPrompt("API key: ");
918
- if (providerRaw === "openai-codex")
919
- credentials.oauthAccessToken = await coldPrompt("OAuth token: ");
920
- if (providerRaw === "minimax")
921
- credentials.apiKey = await coldPrompt("API key: ");
922
- if (providerRaw === "azure") {
923
- credentials.apiKey = await coldPrompt("API key: ");
924
- credentials.endpoint = await coldPrompt("endpoint: ");
925
- credentials.deployment = await coldPrompt("deployment: ");
926
- }
927
- }
928
- }
929
- else {
930
- process.stdout.write(`\n\ud83d\udc0d welcome to ouroboros! ${hatchVerb}\n`);
931
- process.stdout.write("i need an API key to power our conversation.\n\n");
932
- const pRaw = await coldPrompt("provider (anthropic/azure/minimax/openai-codex): ");
933
- if (!isAgentProvider(pRaw)) {
934
- process.stdout.write("unknown provider. run `ouro hatch` to try again.\n");
935
- coldRl.close();
936
- return null;
937
- }
938
- providerRaw = pRaw;
939
- providerConfig = { model: defaultModels[providerRaw] };
940
- if (providerRaw === "anthropic")
941
- credentials.setupToken = await coldPrompt("API key: ");
942
- if (providerRaw === "openai-codex")
943
- credentials.oauthAccessToken = await coldPrompt("OAuth token: ");
944
- if (providerRaw === "minimax")
945
- credentials.apiKey = await coldPrompt("API key: ");
946
- if (providerRaw === "azure") {
947
- credentials.apiKey = await coldPrompt("API key: ");
948
- credentials.endpoint = await coldPrompt("endpoint: ");
949
- credentials.deployment = await coldPrompt("deployment: ");
950
- }
951
- }
952
- coldRl.close();
953
- process.stdout.write("\n");
954
- // Phase 2: configure runtime for adoption specialist
955
- const bundleSourceDir = path.resolve(__dirname, "..", "..", "..", "AdoptionSpecialist.ouro");
956
- const bundlesRoot = (0, identity_1.getAgentBundlesRoot)();
957
- const secretsRoot2 = path.join(os.homedir(), ".agentsecrets");
958
- // Suppress non-critical log noise during adoption (no secrets.json, etc.)
959
- const { setRuntimeLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves/runtime")));
960
- const { createLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves")));
961
- setRuntimeLogger(createLogger({ level: "error" }));
962
- // Configure runtime: set agent identity + config override so runAgent
963
- // doesn't try to read from ~/AgentBundles/AdoptionSpecialist.ouro/
964
- setAgentName("AdoptionSpecialist");
965
- // Build specialist system prompt
966
- const soulText = (0, specialist_orchestrator_1.loadSoulText)(bundleSourceDir);
967
- const identitiesDir = path.join(bundleSourceDir, "psyche", "identities");
968
- const identity = (0, specialist_orchestrator_1.pickRandomIdentity)(identitiesDir);
969
- // Load identity-specific spinner phrases (falls back to DEFAULT_AGENT_PHRASES)
970
- const { loadIdentityPhrases } = await Promise.resolve().then(() => __importStar(require("./specialist-orchestrator")));
971
- const phrases = loadIdentityPhrases(bundleSourceDir, identity.fileName);
972
- setAgentConfigOverride({
973
- version: 1,
974
- enabled: true,
975
- provider: providerRaw,
976
- phrases,
977
- });
978
- patchRuntimeConfig({
979
- providers: {
980
- [providerRaw]: { ...providerConfig, ...credentials },
981
- },
982
- });
983
- const existingBundles = (0, specialist_orchestrator_1.listExistingBundles)(bundlesRoot);
984
- const systemPrompt = (0, specialist_prompt_1.buildSpecialistSystemPrompt)(soulText, identity.content, existingBundles, {
985
- tempDir,
986
- provider: providerRaw,
987
- });
988
- // Build specialist tools
989
- const specialistTools = (0, specialist_tools_1.getSpecialistTools)();
990
- const specialistExecTool = (0, specialist_tools_1.createSpecialistExecTool)({
991
- tempDir,
992
- credentials,
993
- provider: providerRaw,
994
- bundlesRoot,
995
- secretsRoot: secretsRoot2,
996
- animationWriter: (text) => process.stdout.write(text),
997
- });
998
- // Run the adoption specialist session via runCliSession
999
- const result = await runCliSession({
1000
- agentName: "AdoptionSpecialist",
1001
- tools: specialistTools,
1002
- execTool: specialistExecTool,
1003
- exitOnToolCall: "complete_adoption",
1004
- autoFirstTurn: true,
1005
- banner: false,
1006
- disableCommands: true,
1007
- skipSystemPromptRefresh: true,
1008
- messages: [
1009
- { role: "system", content: systemPrompt },
1010
- { role: "user", content: "hi" },
1011
- ],
1012
- });
1013
- if (result.exitReason === "tool_exit" && result.toolResult) {
1014
- const parsed = typeof result.toolResult === "string" ? JSON.parse(result.toolResult) : result.toolResult;
1015
- if (parsed.success && parsed.agentName) {
1016
- return parsed.agentName;
1017
- }
1018
- }
1019
- return null;
1020
- }
1021
- catch (err) {
1022
- process.stderr.write(`\nouro adoption error: ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`);
1023
- coldRl.close();
1024
- return null;
1025
- }
1026
- finally {
1027
- // Clear specialist config/identity so the hatched agent gets its own
1028
- setAgentConfigOverride(null);
1029
- const { resetProviderRuntime } = await Promise.resolve().then(() => __importStar(require("../core")));
1030
- resetProviderRuntime();
1031
- const { resetConfigCache } = await Promise.resolve().then(() => __importStar(require("../config")));
1032
- resetConfigCache();
1033
- // Restore default logging
1034
- const { setRuntimeLogger: restoreLogger } = await Promise.resolve().then(() => __importStar(require("../../nerves/runtime")));
1035
- restoreLogger(null);
1036
- // Clean up temp dir if it still exists
1037
- try {
1038
- if (fs.existsSync(tempDir)) {
1039
- fs.rmSync(tempDir, { recursive: true, force: true });
1040
- }
1041
- }
1042
- catch {
1043
- // Best effort cleanup
1044
- }
1045
- }
1046
- }
1047
- /* v8 ignore stop */
1048
- function createDefaultOuroCliDeps(socketPath = socket_client_1.DEFAULT_DAEMON_SOCKET_PATH) {
1049
- return {
1050
- socketPath,
1051
- sendCommand: socket_client_1.sendDaemonCommand,
1052
- startDaemonProcess: defaultStartDaemonProcess,
1053
- writeStdout: defaultWriteStdout,
1054
- checkSocketAlive: socket_client_1.checkDaemonSocketAlive,
1055
- cleanupStaleSocket: defaultCleanupStaleSocket,
1056
- fallbackPendingMessage: defaultFallbackPendingMessage,
1057
- installSubagents: defaultInstallSubagents,
1058
- listDiscoveredAgents: defaultListDiscoveredAgents,
1059
- runHatchFlow: hatch_flow_1.runHatchFlow,
1060
- promptInput: defaultPromptInput,
1061
- runAdoptionSpecialist: defaultRunAdoptionSpecialist,
1062
- registerOuroBundleType: ouro_uti_1.registerOuroBundleUti,
1063
- installOuroCommand: ouro_path_installer_1.installOuroCommand,
1064
- syncGlobalOuroBotWrapper: ouro_bot_global_installer_1.syncGlobalOuroBotWrapper,
1065
- ensureDaemonBootPersistence: defaultEnsureDaemonBootPersistence,
1066
- /* v8 ignore next 3 -- integration: launches interactive CLI session @preserve */
1067
- startChat: async (agentName) => {
1068
- const { main } = await Promise.resolve().then(() => __importStar(require("../../senses/cli")));
1069
- await main(agentName);
1070
- },
1071
- scanSessions: async () => {
1072
- const agentName = (0, identity_1.getAgentName)();
1073
- const agentRoot = (0, identity_1.getAgentRoot)(agentName);
1074
- return (0, session_activity_1.listSessionActivity)({
1075
- sessionsDir: path.join(agentRoot, "state", "sessions"),
1076
- friendsDir: path.join(agentRoot, "friends"),
1077
- agentName,
1078
- }).map((entry) => ({
1079
- friendId: entry.friendId,
1080
- friendName: entry.friendName,
1081
- channel: entry.channel,
1082
- lastActivity: entry.lastActivityAt,
1083
- }));
1084
- },
1085
- };
1086
- }
1087
- function toDaemonCommand(command) {
1088
- return command;
1089
- }
1090
- async function resolveHatchInput(command, deps) {
1091
- const prompt = deps.promptInput;
1092
- const agentName = command.agentName ?? (prompt ? await prompt("Hatchling name: ") : "");
1093
- const humanName = command.humanName ?? (prompt ? await prompt("Your name: ") : os.userInfo().username);
1094
- const providerRaw = command.provider ?? (prompt ? await prompt("Provider (azure|anthropic|minimax|openai-codex): ") : "");
1095
- if (!agentName || !humanName || !isAgentProvider(providerRaw)) {
1096
- throw new Error(`Usage\n${usage()}`);
1097
- }
1098
- const credentials = { ...(command.credentials ?? {}) };
1099
- if (providerRaw === "anthropic" && !credentials.setupToken && prompt) {
1100
- credentials.setupToken = await prompt("Anthropic setup-token: ");
1101
- }
1102
- if (providerRaw === "openai-codex" && !credentials.oauthAccessToken && prompt) {
1103
- credentials.oauthAccessToken = await prompt("OpenAI Codex OAuth token: ");
1104
- }
1105
- if (providerRaw === "minimax" && !credentials.apiKey && prompt) {
1106
- credentials.apiKey = await prompt("MiniMax API key: ");
1107
- }
1108
- if (providerRaw === "azure") {
1109
- if (!credentials.apiKey && prompt)
1110
- credentials.apiKey = await prompt("Azure API key: ");
1111
- if (!credentials.endpoint && prompt)
1112
- credentials.endpoint = await prompt("Azure endpoint: ");
1113
- if (!credentials.deployment && prompt)
1114
- credentials.deployment = await prompt("Azure deployment: ");
1115
- }
1116
- return {
1117
- agentName,
1118
- humanName,
1119
- provider: providerRaw,
1120
- credentials,
1121
- migrationPath: command.migrationPath,
1122
- };
1123
- }
1124
- async function registerOuroBundleTypeNonBlocking(deps) {
1125
- const registerOuroBundleType = deps.registerOuroBundleType;
1126
- if (!registerOuroBundleType)
1127
- return;
1128
- try {
1129
- await Promise.resolve(registerOuroBundleType());
1130
- }
1131
- catch (error) {
1132
- (0, runtime_1.emitNervesEvent)({
1133
- level: "warn",
1134
- component: "daemon",
1135
- event: "daemon.ouro_uti_register_error",
1136
- message: "failed .ouro UTI registration from CLI flow",
1137
- meta: { error: error instanceof Error ? error.message : String(error) },
1138
- });
1139
- }
1140
- }
1141
- async function performSystemSetup(deps) {
1142
- // Install ouro command to PATH (non-blocking)
1143
- if (deps.installOuroCommand) {
1144
- try {
1145
- deps.installOuroCommand();
1146
- }
1147
- catch (error) {
1148
- (0, runtime_1.emitNervesEvent)({
1149
- level: "warn",
1150
- component: "daemon",
1151
- event: "daemon.system_setup_ouro_cmd_error",
1152
- message: "failed to install ouro command to PATH",
1153
- meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
1154
- });
1155
- }
1156
- }
1157
- if (deps.syncGlobalOuroBotWrapper) {
1158
- try {
1159
- await Promise.resolve(deps.syncGlobalOuroBotWrapper());
1160
- }
1161
- catch (error) {
1162
- (0, runtime_1.emitNervesEvent)({
1163
- level: "warn",
1164
- component: "daemon",
1165
- event: "daemon.system_setup_ouro_bot_wrapper_error",
1166
- message: "failed to sync global ouro.bot wrapper",
1167
- meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
1168
- });
1169
- }
1170
- }
1171
- // Install subagents (claude/codex skills)
1172
- try {
1173
- await deps.installSubagents();
1174
- }
1175
- catch (error) {
1176
- (0, runtime_1.emitNervesEvent)({
1177
- level: "warn",
1178
- component: "daemon",
1179
- event: "daemon.subagent_install_error",
1180
- message: "subagent auto-install failed",
1181
- meta: { error: error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error) },
1182
- });
1183
- }
1184
- // Register .ouro bundle type (UTI on macOS)
1185
- await registerOuroBundleTypeNonBlocking(deps);
1186
- }
1187
- function executeTaskCommand(command, taskMod) {
1188
- if (command.kind === "task.board") {
1189
- if (command.status) {
1190
- const lines = taskMod.boardStatus(command.status);
1191
- return lines.length > 0 ? lines.join("\n") : "no tasks in that status";
1192
- }
1193
- const board = taskMod.getBoard();
1194
- return board.full || board.compact || "no tasks found";
1195
- }
1196
- if (command.kind === "task.create") {
1197
- try {
1198
- const created = taskMod.createTask({
1199
- title: command.title,
1200
- type: command.type ?? "one-shot",
1201
- category: "general",
1202
- body: "",
1203
- });
1204
- return `created: ${created}`;
1205
- }
1206
- catch (error) {
1207
- return `error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error)}`;
1208
- }
1209
- }
1210
- if (command.kind === "task.update") {
1211
- const result = taskMod.updateStatus(command.id, command.status);
1212
- if (!result.ok) {
1213
- return `error: ${result.reason ?? "status update failed"}`;
1214
- }
1215
- const archivedSuffix = result.archived && result.archived.length > 0
1216
- ? ` | archived: ${result.archived.join(", ")}`
1217
- : "";
1218
- return `updated: ${command.id} -> ${result.to}${archivedSuffix}`;
1219
- }
1220
- if (command.kind === "task.show") {
1221
- const task = taskMod.getTask(command.id);
1222
- if (!task)
1223
- return `task not found: ${command.id}`;
1224
- return [
1225
- `title: ${task.title}`,
1226
- `type: ${task.type}`,
1227
- `status: ${task.status}`,
1228
- `category: ${task.category}`,
1229
- `created: ${task.created}`,
1230
- `updated: ${task.updated}`,
1231
- `path: ${task.path}`,
1232
- task.body ? `\n${task.body}` : "",
1233
- ].filter(Boolean).join("\n");
1234
- }
1235
- if (command.kind === "task.actionable") {
1236
- const lines = taskMod.boardAction();
1237
- return lines.length > 0 ? lines.join("\n") : "no action required";
1238
- }
1239
- if (command.kind === "task.deps") {
1240
- const lines = taskMod.boardDeps();
1241
- return lines.length > 0 ? lines.join("\n") : "no unresolved dependencies";
1242
- }
1243
- // command.kind === "task.sessions"
1244
- const lines = taskMod.boardSessions();
1245
- return lines.length > 0 ? lines.join("\n") : "no active sessions";
1246
- }
1247
- const TRUST_RANK = { family: 4, friend: 3, acquaintance: 2, stranger: 1 };
1248
- /* v8 ignore start -- defensive: ?? fallbacks are unreachable when inputs are valid TrustLevel values @preserve */
1249
- function higherTrust(a, b) {
1250
- const rankA = TRUST_RANK[a ?? "stranger"] ?? 1;
1251
- const rankB = TRUST_RANK[b ?? "stranger"] ?? 1;
1252
- return rankA >= rankB ? (a ?? "stranger") : (b ?? "stranger");
1253
- }
1254
- /* v8 ignore stop */
1255
- async function executeFriendCommand(command, store) {
1256
- if (command.kind === "friend.list") {
1257
- const listAll = store.listAll;
1258
- if (!listAll)
1259
- return "friend store does not support listing";
1260
- const friends = await listAll.call(store);
1261
- if (friends.length === 0)
1262
- return "no friends found";
1263
- const lines = friends.map((f) => {
1264
- const trust = f.trustLevel ?? "unknown";
1265
- return `${f.id} ${f.name} ${trust}`;
1266
- });
1267
- return lines.join("\n");
1268
- }
1269
- if (command.kind === "friend.show") {
1270
- const record = await store.get(command.friendId);
1271
- if (!record)
1272
- return `friend not found: ${command.friendId}`;
1273
- return JSON.stringify(record, null, 2);
1274
- }
1275
- if (command.kind === "friend.create") {
1276
- const now = new Date().toISOString();
1277
- const id = (0, crypto_1.randomUUID)();
1278
- const trustLevel = (command.trustLevel ?? "acquaintance");
1279
- await store.put(id, {
1280
- id,
1281
- name: command.name,
1282
- trustLevel,
1283
- externalIds: [],
1284
- tenantMemberships: [],
1285
- toolPreferences: {},
1286
- notes: {},
1287
- totalTokens: 0,
1288
- createdAt: now,
1289
- updatedAt: now,
1290
- schemaVersion: 1,
1291
- });
1292
- return `created: ${id} (${command.name}, ${trustLevel})`;
1293
- }
1294
- if (command.kind === "friend.link") {
1295
- const current = await store.get(command.friendId);
1296
- if (!current)
1297
- return `friend not found: ${command.friendId}`;
1298
- const alreadyLinked = current.externalIds.some((ext) => ext.provider === command.provider && ext.externalId === command.externalId);
1299
- if (alreadyLinked)
1300
- return `identity already linked: ${command.provider}:${command.externalId}`;
1301
- const now = new Date().toISOString();
1302
- const newExternalIds = [
1303
- ...current.externalIds,
1304
- { provider: command.provider, externalId: command.externalId, linkedAt: now },
1305
- ];
1306
- // Orphan cleanup: check if another friend has this externalId
1307
- const orphan = await store.findByExternalId(command.provider, command.externalId);
1308
- let mergeMessage = "";
1309
- let mergedNotes = { ...current.notes };
1310
- let mergedTrust = current.trustLevel;
1311
- let orphanExternalIds = [];
1312
- if (orphan && orphan.id !== command.friendId) {
1313
- // Merge orphan's notes (target's notes take priority)
1314
- mergedNotes = { ...orphan.notes, ...current.notes };
1315
- // Keep higher trust level
1316
- mergedTrust = higherTrust(current.trustLevel, orphan.trustLevel);
1317
- // Collect orphan's other externalIds (excluding the one being linked)
1318
- orphanExternalIds = orphan.externalIds.filter((ext) => !(ext.provider === command.provider && ext.externalId === command.externalId));
1319
- await store.delete(orphan.id);
1320
- mergeMessage = ` (merged orphan ${orphan.id})`;
1321
- }
1322
- await store.put(command.friendId, {
1323
- ...current,
1324
- externalIds: [...newExternalIds, ...orphanExternalIds],
1325
- notes: mergedNotes,
1326
- trustLevel: mergedTrust,
1327
- updatedAt: now,
1328
- });
1329
- return `linked ${command.provider}:${command.externalId} to ${command.friendId}${mergeMessage}`;
1330
- }
1331
- // command.kind === "friend.unlink"
1332
- const current = await store.get(command.friendId);
1333
- if (!current)
1334
- return `friend not found: ${command.friendId}`;
1335
- const idx = current.externalIds.findIndex((ext) => ext.provider === command.provider && ext.externalId === command.externalId);
1336
- if (idx === -1)
1337
- return `identity not linked: ${command.provider}:${command.externalId}`;
1338
- const now = new Date().toISOString();
1339
- const filtered = current.externalIds.filter((_, i) => i !== idx);
1340
- await store.put(command.friendId, { ...current, externalIds: filtered, updatedAt: now });
1341
- return `unlinked ${command.provider}:${command.externalId} from ${command.friendId}`;
1342
- }
1343
- function executeReminderCommand(command, taskMod) {
1344
- try {
1345
- const created = taskMod.createTask({
1346
- title: command.title,
1347
- type: command.cadence ? "habit" : "one-shot",
1348
- category: command.category ?? "reminder",
1349
- body: command.body,
1350
- scheduledAt: command.scheduledAt,
1351
- cadence: command.cadence,
1352
- requester: command.requester,
1353
- });
1354
- return `created: ${created}`;
1355
- }
1356
- catch (error) {
1357
- return `error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error)}`;
1358
- }
1359
- }
1360
- async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
1361
- if (args.includes("--help") || args.includes("-h")) {
1362
- const text = usage();
1363
- deps.writeStdout(text);
1364
- return text;
1365
- }
1366
- if (args.length === 1 && (args[0] === "-v" || args[0] === "--version")) {
1367
- const text = formatVersionOutput();
1368
- deps.writeStdout(text);
1369
- return text;
1370
- }
1371
- let command;
1372
- try {
1373
- command = parseOuroCommand(args);
1374
- }
1375
- catch (parseError) {
1376
- if (deps.startChat && deps.listDiscoveredAgents && args.length === 1) {
1377
- const discovered = await Promise.resolve(deps.listDiscoveredAgents());
1378
- if (discovered.includes(args[0])) {
1379
- await ensureDaemonRunning(deps);
1380
- await deps.startChat(args[0]);
1381
- return "";
1382
- }
1383
- }
1384
- throw parseError;
1385
- }
1386
- if (args.length === 0) {
1387
- const discovered = await Promise.resolve(deps.listDiscoveredAgents ? deps.listDiscoveredAgents() : defaultListDiscoveredAgents());
1388
- if (discovered.length === 0 && deps.runAdoptionSpecialist) {
1389
- // System setup first — ouro command, subagents, UTI — before the interactive specialist
1390
- await performSystemSetup(deps);
1391
- const hatchlingName = await deps.runAdoptionSpecialist();
1392
- if (!hatchlingName) {
1393
- return "";
1394
- }
1395
- await ensureDaemonRunning(deps);
1396
- if (deps.startChat) {
1397
- await deps.startChat(hatchlingName);
1398
- }
1399
- return "";
1400
- }
1401
- else if (discovered.length === 0) {
1402
- command = { kind: "hatch.start" };
1403
- }
1404
- else if (discovered.length === 1) {
1405
- if (deps.startChat) {
1406
- await ensureDaemonRunning(deps);
1407
- await deps.startChat(discovered[0]);
1408
- return "";
1409
- }
1410
- command = { kind: "chat.connect", agent: discovered[0] };
1411
- }
1412
- else {
1413
- if (deps.startChat && deps.promptInput) {
1414
- const prompt = `who do you want to talk to?\n${discovered.map((a, i) => `${i + 1}. ${a}`).join("\n")}\n`;
1415
- const answer = await deps.promptInput(prompt);
1416
- const selected = discovered.includes(answer) ? answer : discovered[parseInt(answer, 10) - 1];
1417
- if (!selected)
1418
- throw new Error("Invalid selection");
1419
- await ensureDaemonRunning(deps);
1420
- await deps.startChat(selected);
1421
- return "";
1422
- }
1423
- const message = `who do you want to talk to? ${discovered.join(", ")} (use: ouro chat <agent>)`;
1424
- deps.writeStdout(message);
1425
- return message;
1426
- }
1427
- (0, runtime_1.emitNervesEvent)({
1428
- component: "daemon",
1429
- event: "daemon.cli_auto_route",
1430
- message: "routed bare ouro command from discovered agents",
1431
- meta: { target: command.kind, count: discovered.length },
1432
- });
1433
- }
1434
- (0, runtime_1.emitNervesEvent)({
1435
- component: "daemon",
1436
- event: "daemon.cli_command",
1437
- message: "ouro CLI command invoked",
1438
- meta: { kind: command.kind },
1439
- });
1440
- if (command.kind === "daemon.up") {
1441
- await performSystemSetup(deps);
1442
- if (deps.ensureDaemonBootPersistence) {
1443
- try {
1444
- await Promise.resolve(deps.ensureDaemonBootPersistence(deps.socketPath));
1445
- }
1446
- catch (error) {
1447
- (0, runtime_1.emitNervesEvent)({
1448
- level: "warn",
1449
- component: "daemon",
1450
- event: "daemon.system_setup_launchd_error",
1451
- message: "failed to persist daemon boot startup",
1452
- meta: { error: error instanceof Error ? error.message : String(error), socketPath: deps.socketPath },
1453
- });
1454
- }
1455
- }
1456
- // Run update hooks before starting daemon so user sees the output
1457
- (0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
1458
- const bundlesRoot = (0, identity_1.getAgentBundlesRoot)();
1459
- const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
1460
- const updateSummary = await (0, update_hooks_1.applyPendingUpdates)(bundlesRoot, currentVersion);
1461
- if (updateSummary.updated.length > 0) {
1462
- const agents = updateSummary.updated.map((e) => e.agent);
1463
- const from = updateSummary.updated[0].from;
1464
- const to = updateSummary.updated[0].to;
1465
- const fromStr = from ? ` (was ${from})` : "";
1466
- const count = agents.length;
1467
- deps.writeStdout(`updated ${count} agent${count === 1 ? "" : "s"} to runtime ${to}${fromStr}`);
1468
- }
1469
- const daemonResult = await ensureDaemonRunning(deps);
1470
- deps.writeStdout(daemonResult.message);
1471
- return daemonResult.message;
1472
- }
1473
- if (command.kind === "daemon.logs" && deps.tailLogs) {
1474
- deps.tailLogs();
1475
- return "";
1476
- }
1477
- // ── task subcommands (local, no daemon socket needed) ──
1478
- if (command.kind === "task.board" || command.kind === "task.create" || command.kind === "task.update" ||
1479
- command.kind === "task.show" || command.kind === "task.actionable" || command.kind === "task.deps" ||
1480
- command.kind === "task.sessions") {
1481
- /* v8 ignore start -- production default: requires full identity setup @preserve */
1482
- const taskMod = deps.taskModule ?? (0, tasks_1.getTaskModule)();
1483
- /* v8 ignore stop */
1484
- const message = executeTaskCommand(command, taskMod);
1485
- deps.writeStdout(message);
1486
- return message;
1487
- }
1488
- // ── reminder subcommands (local, no daemon socket needed) ──
1489
- if (command.kind === "reminder.create") {
1490
- /* v8 ignore start -- production default: requires full identity setup @preserve */
1491
- const taskMod = deps.taskModule ?? (0, tasks_1.getTaskModule)();
1492
- /* v8 ignore stop */
1493
- const message = executeReminderCommand(command, taskMod);
1494
- deps.writeStdout(message);
1495
- return message;
1496
- }
1497
- // ── friend subcommands (local, no daemon socket needed) ──
1498
- if (command.kind === "friend.list" || command.kind === "friend.show" || command.kind === "friend.create" ||
1499
- command.kind === "friend.link" || command.kind === "friend.unlink") {
1500
- /* v8 ignore start -- production default: requires full identity setup @preserve */
1501
- let store = deps.friendStore;
1502
- if (!store) {
1503
- // Derive agent-scoped friends dir from --agent flag or link/unlink's agent field
1504
- const agentName = ("agent" in command && command.agent) ? command.agent : undefined;
1505
- const friendsDir = agentName
1506
- ? path.join((0, identity_1.getAgentBundlesRoot)(), `${agentName}.ouro`, "friends")
1507
- : path.join((0, identity_1.getAgentBundlesRoot)(), "friends");
1508
- store = new store_file_1.FileFriendStore(friendsDir);
1509
- }
1510
- /* v8 ignore stop */
1511
- const message = await executeFriendCommand(command, store);
1512
- deps.writeStdout(message);
1513
- return message;
1514
- }
1515
- // ── whoami (local, no daemon socket needed) ──
1516
- if (command.kind === "whoami") {
1517
- if (command.agent) {
1518
- const agentRoot = path.join((0, identity_1.getAgentBundlesRoot)(), `${command.agent}.ouro`);
1519
- const message = [
1520
- `agent: ${command.agent}`,
1521
- `home: ${agentRoot}`,
1522
- `bones: ${(0, runtime_metadata_1.getRuntimeMetadata)().version}`,
1523
- ].join("\n");
1524
- deps.writeStdout(message);
1525
- return message;
1526
- }
1527
- /* v8 ignore start -- production default: requires full identity setup @preserve */
1528
- try {
1529
- const info = deps.whoamiInfo
1530
- ? deps.whoamiInfo()
1531
- : {
1532
- agentName: (0, identity_1.getAgentName)(),
1533
- homePath: path.join((0, identity_1.getAgentBundlesRoot)(), `${(0, identity_1.getAgentName)()}.ouro`),
1534
- bonesVersion: (0, runtime_metadata_1.getRuntimeMetadata)().version,
1535
- };
1536
- const message = [
1537
- `agent: ${info.agentName}`,
1538
- `home: ${info.homePath}`,
1539
- `bones: ${info.bonesVersion}`,
1540
- ].join("\n");
1541
- deps.writeStdout(message);
1542
- return message;
1543
- }
1544
- catch {
1545
- const message = "error: no agent context — use --agent <name> to specify";
1546
- deps.writeStdout(message);
1547
- return message;
1548
- }
1549
- /* v8 ignore stop */
1550
- }
1551
- // ── thoughts (local, no daemon socket needed) ──
1552
- if (command.kind === "thoughts") {
1553
- try {
1554
- const agentName = command.agent ?? (0, identity_1.getAgentName)();
1555
- const agentRoot = path.join((0, identity_1.getAgentBundlesRoot)(), `${agentName}.ouro`);
1556
- const sessionFilePath = (0, thoughts_1.getInnerDialogSessionPath)(agentRoot);
1557
- if (command.json) {
1558
- try {
1559
- const raw = fs.readFileSync(sessionFilePath, "utf-8");
1560
- deps.writeStdout(raw);
1561
- return raw;
1562
- }
1563
- catch {
1564
- const message = "no inner dialog session found";
1565
- deps.writeStdout(message);
1566
- return message;
1567
- }
1568
- }
1569
- const turns = (0, thoughts_1.parseInnerDialogSession)(sessionFilePath);
1570
- const message = (0, thoughts_1.formatThoughtTurns)(turns, command.last ?? 10);
1571
- deps.writeStdout(message);
1572
- if (command.follow) {
1573
- deps.writeStdout("\n\n--- following (ctrl+c to stop) ---\n");
1574
- /* v8 ignore start -- callback tested via followThoughts unit tests @preserve */
1575
- const stop = (0, thoughts_1.followThoughts)(sessionFilePath, (formatted) => {
1576
- deps.writeStdout("\n" + formatted);
1577
- });
1578
- /* v8 ignore stop */
1579
- // Block until process exit; cleanup watcher on SIGINT/SIGTERM
1580
- return new Promise((resolve) => {
1581
- const cleanup = () => { stop(); resolve(message); };
1582
- process.once("SIGINT", cleanup);
1583
- process.once("SIGTERM", cleanup);
1584
- });
1585
- }
1586
- return message;
1587
- }
1588
- catch {
1589
- const message = "error: no agent context — use --agent <name> to specify";
1590
- deps.writeStdout(message);
1591
- return message;
1592
- }
1593
- }
1594
- // ── session list (local, no daemon socket needed) ──
1595
- if (command.kind === "session.list") {
1596
- /* v8 ignore start -- production default: requires full identity setup @preserve */
1597
- const scanner = deps.scanSessions ?? (async () => []);
1598
- /* v8 ignore stop */
1599
- const sessions = await scanner();
1600
- if (sessions.length === 0) {
1601
- const message = "no active sessions";
1602
- deps.writeStdout(message);
1603
- return message;
1604
- }
1605
- const lines = sessions.map((s) => `${s.friendId} ${s.friendName} ${s.channel} ${s.lastActivity}`);
1606
- const message = lines.join("\n");
1607
- deps.writeStdout(message);
1608
- return message;
1609
- }
1610
- if (command.kind === "hatch.start") {
1611
- // Route through adoption specialist when no explicit hatch args were provided
1612
- const hasExplicitHatchArgs = !!(command.agentName || command.humanName || command.provider || command.credentials);
1613
- if (deps.runAdoptionSpecialist && !hasExplicitHatchArgs) {
1614
- // System setup first — ouro command, subagents, UTI — before the interactive specialist
1615
- await performSystemSetup(deps);
1616
- const hatchlingName = await deps.runAdoptionSpecialist();
1617
- if (!hatchlingName) {
1618
- return "";
1619
- }
1620
- await ensureDaemonRunning(deps);
1621
- if (deps.startChat) {
1622
- await deps.startChat(hatchlingName);
1623
- }
1624
- return "";
1625
- }
1626
- const hatchRunner = deps.runHatchFlow;
1627
- if (!hatchRunner) {
1628
- const response = await deps.sendCommand(deps.socketPath, { kind: "hatch.start" });
1629
- const message = response.summary ?? response.message ?? (response.ok ? "ok" : `error: ${response.error ?? "unknown error"}`);
1630
- deps.writeStdout(message);
1631
- return message;
1632
- }
1633
- const hatchInput = await resolveHatchInput(command, deps);
1634
- const result = await hatchRunner(hatchInput);
1635
- await performSystemSetup(deps);
1636
- const daemonResult = await ensureDaemonRunning(deps);
1637
- if (deps.startChat) {
1638
- await deps.startChat(hatchInput.agentName);
1639
- return "";
1640
- }
1641
- const message = `hatched ${hatchInput.agentName} at ${result.bundleRoot} using specialist identity ${result.selectedIdentity}; ${daemonResult.message}`;
1642
- deps.writeStdout(message);
1643
- return message;
1644
- }
1645
- const daemonCommand = toDaemonCommand(command);
1646
- let response;
1647
- try {
1648
- response = await deps.sendCommand(deps.socketPath, daemonCommand);
1649
- }
1650
- catch (error) {
1651
- if (command.kind === "message.send") {
1652
- const pendingPath = deps.fallbackPendingMessage(command);
1653
- const message = `daemon unavailable; queued message fallback at ${pendingPath}`;
1654
- deps.writeStdout(message);
1655
- return message;
1656
- }
1657
- if (command.kind === "daemon.status" && isDaemonUnavailableError(error)) {
1658
- const message = daemonUnavailableStatusOutput(deps.socketPath);
1659
- deps.writeStdout(message);
1660
- return message;
1661
- }
1662
- if (command.kind === "daemon.stop" && isDaemonUnavailableError(error)) {
1663
- const message = "daemon not running";
1664
- deps.writeStdout(message);
1665
- return message;
1666
- }
1667
- throw error;
1668
- }
1669
- const fallbackMessage = response.summary ?? response.message ?? (response.ok ? "ok" : `error: ${response.error ?? "unknown error"}`);
1670
- const message = command.kind === "daemon.status"
1671
- ? formatDaemonStatusOutput(response, fallbackMessage)
1672
- : fallbackMessage;
1673
- deps.writeStdout(message);
1674
- return message;
1675
- }
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; } });