@pellux/goodvibes-tui 1.27.1 → 2.0.1

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 (405) hide show
  1. package/CHANGELOG.md +116 -2
  2. package/README.md +7 -9
  3. package/bin/goodvibes +2 -2
  4. package/bin/launcher-support.js +8 -4
  5. package/docs/README.md +11 -2
  6. package/docs/foundation-artifacts/operator-contract.json +6403 -2347
  7. package/package.json +14 -25
  8. package/scripts/postinstall.js +35 -35
  9. package/src/audio/spoken-turn-model-routing.ts +1 -1
  10. package/src/cli/bundle-command.ts +5 -5
  11. package/src/cli/completions/generate.ts +1 -1
  12. package/src/cli/doctor.ts +3 -3
  13. package/src/cli/entrypoint.ts +12 -7
  14. package/src/cli/help.ts +4 -5
  15. package/src/cli/hooks-command.ts +1 -1
  16. package/src/cli/index.ts +1 -4
  17. package/src/cli/launch-auto-update.ts +59 -7
  18. package/src/cli/management-commands.ts +6 -6
  19. package/src/cli/management-utils.ts +5 -5
  20. package/src/cli/management.ts +7 -7
  21. package/src/cli/network-posture.ts +1 -1
  22. package/src/cli/package-verification.ts +7 -6
  23. package/src/cli/plugin-bundles-command.ts +1 -1
  24. package/src/cli/plugin-command.ts +2 -2
  25. package/src/cli/service-command.ts +2 -2
  26. package/src/cli/service-posture.ts +4 -4
  27. package/src/cli/status.ts +9 -8
  28. package/src/cli/surface-command.ts +4 -4
  29. package/src/cli/tui-startup.ts +3 -3
  30. package/src/cli-flags.ts +3 -3
  31. package/src/config/goodvibes-home-audit.ts +0 -2
  32. package/src/config/secret-config.ts +37 -5
  33. package/src/config/tui-extension-settings.ts +1 -1
  34. package/src/core/approval-alert.ts +2 -2
  35. package/src/core/budget-breach-notifier.ts +3 -3
  36. package/src/core/conversation-compaction-render.ts +1 -1
  37. package/src/core/conversation-line-cache.ts +1 -1
  38. package/src/core/conversation-render-context.ts +1 -1
  39. package/src/core/conversation-rendering.ts +2 -2
  40. package/src/core/conversation.ts +10 -10
  41. package/src/core/long-task-notifier.ts +2 -2
  42. package/src/core/memory-diagnostics-gateway.ts +1 -1
  43. package/src/core/scriptable-statusline.ts +1 -1
  44. package/src/core/session-auto-titler.ts +1 -1
  45. package/src/core/session-resume-core.ts +2 -2
  46. package/src/core/stream-event-wiring.ts +24 -44
  47. package/src/core/terminal-notifier.ts +3 -3
  48. package/src/core/turn-cancellation.ts +1 -1
  49. package/src/core/turn-event-wiring.ts +5 -5
  50. package/src/input/command-registry.ts +6 -6
  51. package/src/input/commands/channel-pairing.ts +1 -1
  52. package/src/input/commands/cluster-runtime.ts +1 -1
  53. package/src/input/commands/codebase-runtime.ts +1 -1
  54. package/src/input/commands/devices-runtime.ts +1 -1
  55. package/src/input/commands/hosted-runtime.ts +330 -0
  56. package/src/input/commands/local-setup-review.ts +1 -1
  57. package/src/input/commands/local-setup-transfer.ts +2 -2
  58. package/src/input/commands/local-setup.ts +3 -3
  59. package/src/input/commands/managed-runtime.ts +2 -2
  60. package/src/input/commands/operator-rpc.ts +24 -110
  61. package/src/input/commands/payment-card-intake.ts +1 -1
  62. package/src/input/commands/permissions-provenance.ts +2 -2
  63. package/src/input/commands/plugin-runtime.ts +1 -1
  64. package/src/input/commands/provider.ts +1 -1
  65. package/src/input/commands/relay-runtime.ts +18 -9
  66. package/src/input/commands/rewind-runtime.ts +1 -1
  67. package/src/input/commands/runtime-services.ts +1 -1
  68. package/src/input/commands/services-runtime.ts +1 -1
  69. package/src/input/commands/session-workflow.ts +1 -1
  70. package/src/input/commands/settings-sync-runtime.ts +2 -2
  71. package/src/input/commands/share-runtime.ts +1 -1
  72. package/src/input/commands/tasks-runtime.ts +145 -55
  73. package/src/input/commands/update-runtime.ts +31 -28
  74. package/src/input/commands/work-plan-runtime.ts +2 -2
  75. package/src/input/commands/workstream-attempts.ts +1 -1
  76. package/src/input/commands/workstream-runtime.ts +2 -2
  77. package/src/input/commands.ts +2 -0
  78. package/src/input/feature-unit-layout.ts +1 -1
  79. package/src/input/feed-context-factory.ts +3 -3
  80. package/src/input/handler-content-actions.ts +2 -2
  81. package/src/input/handler-feed-routes.ts +1 -1
  82. package/src/input/handler-feed.ts +3 -3
  83. package/src/input/handler-modal-token-routes.ts +1 -1
  84. package/src/input/handler-onboarding-daemon-adopt.ts +3 -2
  85. package/src/input/handler-onboarding.ts +1 -1
  86. package/src/input/handler-types.ts +2 -2
  87. package/src/input/handler-ui-state.ts +1 -1
  88. package/src/input/handler.ts +4 -4
  89. package/src/input/input-history.ts +1 -1
  90. package/src/input/onboarding/onboarding-feature-units.ts +2 -2
  91. package/src/input/onboarding/onboarding-runtime-status.ts +15 -1
  92. package/src/input/onboarding/onboarding-wizard-apply.ts +17 -8
  93. package/src/input/onboarding/onboarding-wizard-cloudflare-step.ts +5 -3
  94. package/src/input/onboarding/onboarding-wizard-external-surfaces.ts +1 -1
  95. package/src/input/onboarding/onboarding-wizard-types.ts +1 -1
  96. package/src/input/payments-config.ts +6 -6
  97. package/src/input/search.ts +1 -1
  98. package/src/input/session-picker-modal.ts +46 -0
  99. package/src/input/settings-modal-activation.ts +1 -1
  100. package/src/input/settings-modal-behavior.ts +4 -4
  101. package/src/input/settings-modal-commit.ts +11 -0
  102. package/src/input/settings-modal-data.ts +13 -80
  103. package/src/input/settings-modal-mutations.ts +33 -0
  104. package/src/input/settings-modal-secrets.ts +34 -0
  105. package/src/input/settings-modal-subscriptions.ts +1 -1
  106. package/src/input/settings-modal-types.ts +15 -1
  107. package/src/input/settings-modal.ts +28 -3
  108. package/src/input/worktree-setup-config.ts +1 -1
  109. package/src/main.ts +11 -9
  110. package/src/panels/agent-inspector-shared.ts +2 -2
  111. package/src/panels/base-panel.ts +2 -2
  112. package/src/panels/builtin/operations.ts +6 -8
  113. package/src/panels/builtin/session.ts +17 -0
  114. package/src/panels/builtin/shared.ts +5 -5
  115. package/src/panels/builtin-modals.ts +3 -3
  116. package/src/panels/confirm-state.ts +1 -1
  117. package/src/panels/cost-tracker-panel.ts +4 -4
  118. package/src/panels/diff-panel.ts +2 -2
  119. package/src/panels/diff-review-panel.ts +2 -2
  120. package/src/panels/expandable-list-panel.ts +2 -2
  121. package/src/panels/fleet-acts.ts +1 -1
  122. package/src/panels/fleet-observed-render.ts +1 -1
  123. package/src/panels/fleet-panel-format.ts +1 -1
  124. package/src/panels/fleet-panel.ts +1 -1
  125. package/src/panels/fleet-spawn.ts +1 -1
  126. package/src/panels/fleet-steer.ts +1 -1
  127. package/src/panels/fleet-transcript.ts +1 -1
  128. package/src/panels/git-panel.ts +1 -1
  129. package/src/panels/hosted-session-feed.ts +352 -0
  130. package/src/panels/hosted-session-panel.ts +221 -0
  131. package/src/panels/local-auth-panel.ts +3 -3
  132. package/src/panels/modals/devices-modal.ts +1 -1
  133. package/src/panels/modals/local-auth-modal.ts +1 -1
  134. package/src/panels/modals/pairing-modal.ts +1 -1
  135. package/src/panels/modals/services-modal.ts +1 -1
  136. package/src/panels/modals/settings-sync-modal.ts +1 -1
  137. package/src/panels/modals/subscription-modal.ts +1 -1
  138. package/src/panels/modals/work-plan-modal.ts +1 -1
  139. package/src/panels/notifications-panel.ts +1 -1
  140. package/src/panels/panel-confirm-overlay.ts +1 -1
  141. package/src/panels/plugins-panel.ts +2 -2
  142. package/src/panels/polish-core.ts +2 -2
  143. package/src/panels/polish-tables.ts +1 -1
  144. package/src/panels/polish.ts +2 -2
  145. package/src/panels/scrollable-list-panel.ts +3 -3
  146. package/src/panels/skills-panel.ts +3 -3
  147. package/src/panels/token-budget-panel.ts +5 -5
  148. package/src/panels/types.ts +1 -2
  149. package/src/permissions/prompt.ts +1 -1
  150. package/src/renderer/autocomplete-overlay.ts +1 -1
  151. package/src/renderer/block-actions-overlay.ts +1 -1
  152. package/src/renderer/bookmark-modal.ts +1 -1
  153. package/src/renderer/buffer.ts +1 -1
  154. package/src/renderer/code-block.ts +1 -1
  155. package/src/renderer/composer-fragments.ts +1 -1
  156. package/src/renderer/compositor.ts +2 -2
  157. package/src/renderer/config-modal.ts +1 -1
  158. package/src/renderer/context-inspector.ts +1 -1
  159. package/src/renderer/conversation-layout.ts +2 -2
  160. package/src/renderer/conversation-overlays.ts +1 -1
  161. package/src/renderer/conversation-surface.ts +2 -2
  162. package/src/renderer/diff-view.ts +1 -1
  163. package/src/renderer/diff.ts +1 -1
  164. package/src/renderer/file-picker-overlay.ts +1 -1
  165. package/src/renderer/fleet-tab-strip.ts +1 -1
  166. package/src/renderer/fullscreen-primitives.ts +2 -2
  167. package/src/renderer/fullscreen-workspace.ts +1 -1
  168. package/src/renderer/header-line.ts +1 -1
  169. package/src/renderer/help-overlay.ts +1 -1
  170. package/src/renderer/history-search-overlay.ts +2 -2
  171. package/src/renderer/layout.ts +5 -8
  172. package/src/renderer/markdown-inline.ts +1 -1
  173. package/src/renderer/markdown-table.ts +1 -1
  174. package/src/renderer/markdown.ts +1 -1
  175. package/src/renderer/mcp-workspace.ts +1 -1
  176. package/src/renderer/modal-factory.ts +2 -2
  177. package/src/renderer/model-workspace.ts +2 -2
  178. package/src/renderer/onboarding/onboarding-wizard.ts +1 -1
  179. package/src/renderer/overlay-box.ts +1 -1
  180. package/src/renderer/panel-composite.ts +1 -1
  181. package/src/renderer/panel-workspace-bar.ts +1 -1
  182. package/src/renderer/process-indicator.ts +1 -1
  183. package/src/renderer/profile-picker-modal.ts +1 -1
  184. package/src/renderer/search-overlay.ts +2 -2
  185. package/src/renderer/selection-modal-overlay.ts +1 -1
  186. package/src/renderer/session-picker-modal.ts +124 -3
  187. package/src/renderer/settings-modal-helpers.ts +2 -0
  188. package/src/renderer/settings-modal.ts +2 -2
  189. package/src/renderer/shell-surface.ts +2 -2
  190. package/src/renderer/system-message.ts +1 -1
  191. package/src/renderer/tab-strip.ts +1 -1
  192. package/src/renderer/theme-mode-config.ts +1 -1
  193. package/src/renderer/theme.ts +11 -12
  194. package/src/renderer/thinking.ts +1 -1
  195. package/src/renderer/tool-call.ts +2 -2
  196. package/src/renderer/tool-result-expanded-lines.ts +1 -1
  197. package/src/renderer/turn-injection.ts +7 -8
  198. package/src/renderer/ui-factory.ts +3 -3
  199. package/src/runtime/bootstrap-command-context.ts +4 -4
  200. package/src/runtime/bootstrap-command-parts.ts +5 -5
  201. package/src/runtime/bootstrap-core.ts +30 -30
  202. package/src/runtime/bootstrap-shell.ts +4 -4
  203. package/src/runtime/bootstrap.ts +128 -157
  204. package/src/runtime/client/approval-updates.ts +82 -0
  205. package/src/runtime/client/build-floors.ts +167 -0
  206. package/src/runtime/client/daemon-attach-handshake.ts +115 -0
  207. package/src/runtime/client/fleet-union.ts +147 -0
  208. package/src/runtime/client/host-service-status.ts +71 -0
  209. package/src/runtime/client/hosted-exit.ts +86 -0
  210. package/src/runtime/client/hosted-roster.ts +110 -0
  211. package/src/runtime/client/hosted-session-stream.ts +178 -0
  212. package/src/runtime/client/hosted-sessions.ts +187 -0
  213. package/src/runtime/client/operator-endpoint.ts +213 -0
  214. package/src/runtime/client/spine-adoption.ts +99 -0
  215. package/src/runtime/cloudflare-control-plane.ts +1 -1
  216. package/src/runtime/context-accounting-source.ts +1 -1
  217. package/src/runtime/context.ts +2 -2
  218. package/src/runtime/conversation-rewind-port.ts +42 -14
  219. package/src/runtime/daemon-attach-notices.ts +55 -19
  220. package/src/runtime/diagnostics/panels/ops.ts +1 -1
  221. package/src/runtime/disposal-wiring.ts +4 -24
  222. package/src/runtime/index.ts +119 -105
  223. package/src/runtime/install-self-check-startup.ts +2 -2
  224. package/src/runtime/interaction-seams.ts +1 -1
  225. package/src/runtime/knowledge-services.ts +8 -2
  226. package/src/runtime/legacy-daemon-migration.ts +4 -3
  227. package/src/runtime/legacy-daemon-reconcile.ts +3 -2
  228. package/src/runtime/memory-spine-transport.ts +37 -267
  229. package/src/runtime/notification-dispatch.ts +2 -2
  230. package/src/runtime/onboarding/apply.ts +2 -2
  231. package/src/runtime/onboarding/derivation.ts +2 -2
  232. package/src/runtime/onboarding/markers.ts +2 -2
  233. package/src/runtime/onboarding/progress.ts +2 -2
  234. package/src/runtime/onboarding/snapshot.ts +1 -1
  235. package/src/runtime/onboarding/state.ts +2 -2
  236. package/src/runtime/onboarding/types.ts +2 -2
  237. package/src/runtime/orchestrator-core-services.ts +1 -1
  238. package/src/runtime/path-shadow-startup.ts +28 -221
  239. package/src/runtime/power-keepawake-remote.ts +3 -2
  240. package/src/runtime/process-lifecycle.ts +2 -2
  241. package/src/runtime/provider-fallback.ts +10 -66
  242. package/src/runtime/recovery-autosave.ts +1 -1
  243. package/src/runtime/recovery-offer-wiring.ts +39 -23
  244. package/src/runtime/recovery-prompt.ts +31 -17
  245. package/src/runtime/relay-reachability-bridge.ts +53 -42
  246. package/src/runtime/release-artifacts.ts +2 -1
  247. package/src/runtime/runtime-services-types.ts +82 -35
  248. package/src/runtime/services.ts +305 -300
  249. package/src/runtime/session-resume-liveness-confirm.ts +1 -1
  250. package/src/runtime/ui-services.ts +7 -6
  251. package/src/runtime/update-check.ts +23 -43
  252. package/src/runtime/workspace-checkpointing.ts +1 -1
  253. package/src/runtime/wrfc-persistence.ts +2 -2
  254. package/src/shell/ui-openers.ts +30 -7
  255. package/src/utils/clipboard.ts +1 -1
  256. package/src/verification/verification-ledger.ts +10 -8
  257. package/src/version.ts +1 -1
  258. package/bin/goodvibes-daemon +0 -90
  259. package/src/cli/config-overrides.ts +0 -267
  260. package/src/cli/endpoints.ts +0 -109
  261. package/src/cli/parser.ts +0 -395
  262. package/src/cli/redaction.ts +0 -170
  263. package/src/cli/types.ts +0 -84
  264. package/src/cluster/commands.ts +0 -382
  265. package/src/cluster/remote-daemon-target.ts +0 -225
  266. package/src/cluster/render.ts +0 -268
  267. package/src/config/atomic-write.ts +0 -70
  268. package/src/config/credential-availability.ts +0 -122
  269. package/src/config/goodvibes-home.ts +0 -149
  270. package/src/config/index.ts +0 -88
  271. package/src/config/provider-model.ts +0 -23
  272. package/src/config/read-versioned.ts +0 -228
  273. package/src/core/alert-gating.ts +0 -67
  274. package/src/core/consolidation-receipt.ts +0 -41
  275. package/src/core/focus-tracker.ts +0 -41
  276. package/src/core/history.ts +0 -45
  277. package/src/core/memory-status.ts +0 -118
  278. package/src/core/orchestrator.ts +0 -7
  279. package/src/core/pairing-devices.ts +0 -49
  280. package/src/core/pairing-handoff.ts +0 -101
  281. package/src/core/pairing-offers.ts +0 -83
  282. package/src/core/pairing-origin.ts +0 -78
  283. package/src/core/rewind-turn-anchors.ts +0 -311
  284. package/src/core/session-recovery.ts +0 -210
  285. package/src/core/stable-host.ts +0 -171
  286. package/src/core/transcript-journal.ts +0 -503
  287. package/src/daemon/cli.ts +0 -693
  288. package/src/daemon/fatal-boot-report.ts +0 -111
  289. package/src/daemon/handlers/context.ts +0 -29
  290. package/src/daemon/handlers/contracts.ts +0 -77
  291. package/src/daemon/handlers/credentials.ts +0 -139
  292. package/src/daemon/handlers/drafts/draft-store.ts +0 -427
  293. package/src/daemon/handlers/drafts/index.ts +0 -17
  294. package/src/daemon/handlers/drafts/register.ts +0 -331
  295. package/src/daemon/handlers/errors.ts +0 -18
  296. package/src/daemon/handlers/inbox/cursor-store.ts +0 -457
  297. package/src/daemon/handlers/inbox/index.ts +0 -284
  298. package/src/daemon/handlers/inbox/mapping.ts +0 -192
  299. package/src/daemon/handlers/inbox/poller.ts +0 -212
  300. package/src/daemon/handlers/inbox/provider-adapter.ts +0 -156
  301. package/src/daemon/handlers/inbox/providers/discord.ts +0 -252
  302. package/src/daemon/handlers/inbox/providers/email.ts +0 -152
  303. package/src/daemon/handlers/inbox/providers/imap-client.ts +0 -300
  304. package/src/daemon/handlers/inbox/providers/route-util.ts +0 -24
  305. package/src/daemon/handlers/inbox/providers/slack.ts +0 -263
  306. package/src/daemon/handlers/index.ts +0 -117
  307. package/src/daemon/handlers/register.ts +0 -168
  308. package/src/daemon/handlers/remote/backends/cloud-terminal.ts +0 -142
  309. package/src/daemon/handlers/remote/backends/docker.ts +0 -79
  310. package/src/daemon/handlers/remote/backends/index.ts +0 -40
  311. package/src/daemon/handlers/remote/backends/local-process.ts +0 -113
  312. package/src/daemon/handlers/remote/backends/process-runner.ts +0 -127
  313. package/src/daemon/handlers/remote/backends/ssh.ts +0 -125
  314. package/src/daemon/handlers/remote/backends/types.ts +0 -97
  315. package/src/daemon/handlers/remote/dispatcher.ts +0 -181
  316. package/src/daemon/handlers/remote/index.ts +0 -119
  317. package/src/daemon/handlers/remote/peer-registry.ts +0 -357
  318. package/src/daemon/handlers/remote/service.ts +0 -191
  319. package/src/daemon/handlers/routing/inbox-bridge.ts +0 -71
  320. package/src/daemon/handlers/routing/index.ts +0 -261
  321. package/src/daemon/handlers/routing/route-store.ts +0 -319
  322. package/src/daemon/handlers/routing/routing-resolver.ts +0 -75
  323. package/src/daemon/handlers/sqlite-store.ts +0 -278
  324. package/src/daemon/handlers/triage/index.ts +0 -57
  325. package/src/daemon/handlers/triage/integration.ts +0 -213
  326. package/src/daemon/handlers/triage/pipeline.ts +0 -274
  327. package/src/daemon/handlers/triage/scorer.ts +0 -287
  328. package/src/daemon/handlers/triage/tagger/discord.ts +0 -187
  329. package/src/daemon/handlers/triage/tagger/imap.ts +0 -384
  330. package/src/daemon/handlers/triage/tagger/index.ts +0 -184
  331. package/src/daemon/handlers/triage/tagger/shared.ts +0 -70
  332. package/src/daemon/handlers/triage/tagger/slack.ts +0 -69
  333. package/src/daemon/handlers/triage/types.ts +0 -50
  334. package/src/daemon/lifecycle.ts +0 -41
  335. package/src/daemon/provision-wake-model.ts +0 -81
  336. package/src/daemon/safe-serve.ts +0 -61
  337. package/src/daemon/send/channels.ts +0 -200
  338. package/src/daemon/send/command.ts +0 -332
  339. package/src/daemon/send/composition.ts +0 -99
  340. package/src/daemon/send/failure-text.ts +0 -93
  341. package/src/daemon/send/inert-text.ts +0 -225
  342. package/src/daemon/send/stdin.ts +0 -24
  343. package/src/daemon/service-commands.ts +0 -329
  344. package/src/export/cost-utils.ts +0 -319
  345. package/src/input/selection.ts +0 -135
  346. package/src/plugins/loader.ts +0 -15
  347. package/src/renderer/bottom-bar.ts +0 -58
  348. package/src/renderer/conversation-tree.ts +0 -228
  349. package/src/runtime/agent-graph-composition.ts +0 -78
  350. package/src/runtime/channel-composition.ts +0 -46
  351. package/src/runtime/cluster-composition.ts +0 -124
  352. package/src/runtime/cluster-group-composition.ts +0 -284
  353. package/src/runtime/code-index-services.ts +0 -167
  354. package/src/runtime/daemon-handler-composition.ts +0 -76
  355. package/src/runtime/device-posture-composition.ts +0 -110
  356. package/src/runtime/durability-housekeeping.ts +0 -183
  357. package/src/runtime/durability-services.ts +0 -155
  358. package/src/runtime/embedded-service-factories.ts +0 -74
  359. package/src/runtime/feature-settings.ts +0 -154
  360. package/src/runtime/fleet-needs-input-push.ts +0 -70
  361. package/src/runtime/fleet-services.ts +0 -41
  362. package/src/runtime/idle-power-services.ts +0 -85
  363. package/src/runtime/mail-composition.ts +0 -65
  364. package/src/runtime/memory-fold.ts +0 -55
  365. package/src/runtime/operator-token-cleanup.ts +0 -109
  366. package/src/runtime/path-shadow.ts +0 -418
  367. package/src/runtime/perf/panel-health-monitor.ts +0 -18
  368. package/src/runtime/provider-optimizer-wiring.ts +0 -55
  369. package/src/runtime/reachability-notice.ts +0 -100
  370. package/src/runtime/remote-execution-composition.ts +0 -62
  371. package/src/runtime/session-liveness-marker.ts +0 -257
  372. package/src/runtime/session-pointer-surface.ts +0 -22
  373. package/src/runtime/session-storage-services.ts +0 -41
  374. package/src/runtime/surface-feature-flags.ts +0 -96
  375. package/src/runtime/terminal-output-guard.ts +0 -235
  376. package/src/runtime/trust/workspace-registration.ts +0 -192
  377. package/src/runtime/trust/workspace-trust.ts +0 -229
  378. package/src/runtime/ui/index.ts +0 -39
  379. package/src/runtime/ui/model-picker/data-provider.ts +0 -182
  380. package/src/runtime/ui/model-picker/health-enrichment.ts +0 -231
  381. package/src/runtime/ui/model-picker/index.ts +0 -59
  382. package/src/runtime/ui/model-picker/types.ts +0 -153
  383. package/src/runtime/ui/provider-health/data-provider.ts +0 -244
  384. package/src/runtime/ui/provider-health/fallback-visualizer.ts +0 -71
  385. package/src/runtime/ui/provider-health/index.ts +0 -46
  386. package/src/runtime/ui/provider-health/types.ts +0 -146
  387. package/src/runtime/ui-events.ts +0 -1
  388. package/src/runtime/ui-read-model-helpers.ts +0 -1
  389. package/src/runtime/ui-read-models-observability-maintenance.ts +0 -1
  390. package/src/runtime/ui-read-models-observability-options.ts +0 -1
  391. package/src/runtime/ui-read-models-observability-remote.ts +0 -1
  392. package/src/runtime/ui-read-models-observability-security.ts +0 -1
  393. package/src/runtime/ui-read-models-observability-system.ts +0 -1
  394. package/src/runtime/ui-read-models-observability.ts +0 -1
  395. package/src/runtime/ui-service-queries.ts +0 -1
  396. package/src/runtime/voice-setup-services.ts +0 -98
  397. package/src/runtime/workstream-attempts-validation.ts +0 -77
  398. package/src/runtime/workstream-draft-edits.ts +0 -95
  399. package/src/runtime/workstream-draft-store.ts +0 -274
  400. package/src/runtime/workstream-draft-types.ts +0 -42
  401. package/src/runtime/workstream-services.ts +0 -373
  402. package/src/tools/index.ts +0 -1
  403. package/src/types/grid.ts +0 -48
  404. package/src/types/sql-js.d.ts +0 -15
  405. package/src/work-plans/work-plan-store.ts +0 -702
@@ -1,200 +0,0 @@
1
- /**
2
- * channels.ts — which channels `goodvibes-daemon send` can reach, and which one
3
- * it uses when the operator names none.
4
- *
5
- * The surface list, labels and required-setup keys are IMPORTED from
6
- * `src/cli/surface-command.ts` rather than restated, so `goodvibes surfaces
7
- * list` and `goodvibes-daemon send --list` can never disagree about what a
8
- * channel is called or what it needs. What this module adds on top is the two
9
- * facts that command needs and `SURFACE_CONFIGS` does not carry: the routable
10
- * `ChannelDeliverySurfaceKind` for each surface id (they differ in case —
11
- * `googleChat` vs `google-chat`), and the settings key holding each surface's
12
- * default destination.
13
- */
14
-
15
- import type { ConfigKey, ConfigManager } from '../../config/index.ts';
16
- import type { ChannelDeliverySurfaceKind } from '@pellux/goodvibes-sdk/platform/channels';
17
- import { SURFACE_CONFIGS } from '../../cli/surface-command.ts';
18
- import { canRenderInert } from './inert-text.ts';
19
-
20
- /**
21
- * The settings key holding each supported surface's default destination — the
22
- * chat, channel, topic or URL a message goes to when `--to` is not given.
23
- *
24
- * These are the SAME keys the delivery strategies in the SDK's
25
- * `strategies-core.ts` fall back to (`surfaces.telegram.defaultChatId`,
26
- * `surfaces.discord.defaultChannelId`, …). Only surfaces with a verified inert
27
- * transform appear; see inert-text.ts for why the rest are refused rather than
28
- * sent to.
29
- */
30
- const DESTINATION_KEY_BY_SURFACE_ID = {
31
- telegram: 'surfaces.telegram.defaultChatId',
32
- ntfy: 'surfaces.ntfy.topic',
33
- discord: 'surfaces.discord.defaultChannelId',
34
- slack: 'surfaces.slack.defaultChannel',
35
- googleChat: 'surfaces.googleChat.webhookUrl',
36
- webhook: 'surfaces.webhook.defaultTarget',
37
- signal: 'surfaces.signal.defaultRecipient',
38
- whatsapp: 'surfaces.whatsapp.defaultRecipient',
39
- imessage: 'surfaces.imessage.defaultChatId',
40
- msteams: 'surfaces.msteams.defaultConversationId',
41
- bluebubbles: 'surfaces.bluebubbles.defaultChatGuid',
42
- mattermost: 'surfaces.mattermost.defaultChannelId',
43
- matrix: 'surfaces.matrix.defaultRoomId',
44
- // Not cast: every value is checked against the real ConfigKey union, so a
45
- // key that is renamed or misspelled in the schema fails the build here
46
- // instead of reading `undefined` at send time and reporting the channel as
47
- // unconfigured.
48
- } as const satisfies Readonly<Record<string, ConfigKey>>;
49
-
50
- /** Surface ids whose routable kind is not simply the id itself. */
51
- const SURFACE_KIND_BY_ID: Readonly<Record<string, ChannelDeliverySurfaceKind>> = {
52
- googleChat: 'google-chat',
53
- };
54
-
55
- /**
56
- * What `--to` addresses on each channel, in that channel's own vocabulary.
57
- *
58
- * This is naming, not a scheme: `--to` becomes `ChannelDeliveryTarget.address`,
59
- * which is the first thing every strategy in `strategies-core.ts`,
60
- * `strategies-bridge.ts` and `strategies-enterprise.ts` already checks before
61
- * falling back to its configured default. Nothing new is invented — the label
62
- * exists so `--list` and the help can say "topic" where the channel says topic
63
- * and "chat id" where it says chat id, rather than making the operator work out
64
- * what an "address" is for ntfy.
65
- */
66
- const ADDRESS_LABEL_BY_SURFACE_ID: Readonly<Record<string, string>> = {
67
- telegram: 'chat id',
68
- ntfy: 'topic',
69
- discord: 'channel id',
70
- slack: 'channel id',
71
- googleChat: 'webhook URL',
72
- webhook: 'URL',
73
- signal: 'recipient',
74
- whatsapp: 'recipient',
75
- imessage: 'chat id',
76
- msteams: 'conversation id',
77
- bluebubbles: 'chat GUID',
78
- mattermost: 'channel id',
79
- matrix: 'room id',
80
- };
81
-
82
- export interface SendChannel {
83
- /** The id an operator types after `--channel`, e.g. `telegram`. */
84
- readonly id: string;
85
- /** Human label, shared with `goodvibes surfaces list`. */
86
- readonly label: string;
87
- /** The kind the channel delivery router routes on. */
88
- readonly surfaceKind: ChannelDeliverySurfaceKind;
89
- /** `surfaces.<id>.enabled`. */
90
- readonly enabledKey: ConfigKey;
91
- /** The settings key holding this channel's default destination. */
92
- readonly destinationKey: ConfigKey;
93
- /** What `--to` names on this channel, in the channel's own words ("topic"). */
94
- readonly addressLabel: string;
95
- }
96
-
97
- /**
98
- * Every channel this command can deliver to. Derived, not restated: a surface
99
- * that gains a delivery strategy and an inert transform appears here by adding
100
- * its destination key above, and a surface that loses its entry in
101
- * `SURFACE_CONFIGS` disappears from both commands at once.
102
- */
103
- const destinationKeys: Readonly<Record<string, ConfigKey>> = DESTINATION_KEY_BY_SURFACE_ID;
104
-
105
- export const SEND_CHANNELS: readonly SendChannel[] = SURFACE_CONFIGS
106
- .flatMap(([id, label]): SendChannel[] => {
107
- const destinationKey = destinationKeys[id];
108
- if (!destinationKey) return [];
109
- const surfaceKind = SURFACE_KIND_BY_ID[id] ?? (id as ChannelDeliverySurfaceKind);
110
- if (!canRenderInert(surfaceKind)) return [];
111
- return [{
112
- id,
113
- label,
114
- surfaceKind,
115
- enabledKey: `surfaces.${id}.enabled` as ConfigKey,
116
- destinationKey,
117
- addressLabel: ADDRESS_LABEL_BY_SURFACE_ID[id] ?? 'address',
118
- }];
119
- });
120
-
121
- /**
122
- * Look a channel up by the id an operator typed, accepting either the settings
123
- * id (`googleChat`) or the routable kind (`google-chat`) — the two spellings
124
- * are both visible in this product's own output, and making the operator
125
- * remember which one this command wants would be a trap.
126
- */
127
- export function findSendChannel(name: string): SendChannel | undefined {
128
- const wanted = name.trim().toLowerCase();
129
- return SEND_CHANNELS.find((channel) =>
130
- channel.id.toLowerCase() === wanted || channel.surfaceKind.toLowerCase() === wanted);
131
- }
132
-
133
- export interface ChannelReadiness {
134
- readonly channel: SendChannel;
135
- /** `surfaces.<id>.enabled` is true. */
136
- readonly enabled: boolean;
137
- /** The configured default destination, or null when the key is blank. */
138
- readonly destination: string | null;
139
- }
140
-
141
- function readSetting(config: Pick<ConfigManager, 'get'>, key: ConfigKey): string {
142
- const value = config.get(key);
143
- return typeof value === 'string' ? value.trim() : value === undefined || value === null ? '' : String(value).trim();
144
- }
145
-
146
- /**
147
- * Read every channel's live state from config.
148
- *
149
- * The `ConfigManager` handed in must be one built with a `homeDir`, because
150
- * every `surfaces.*` key is daemon-owned: the manager overlays
151
- * `<home>/.goodvibes/daemon/settings.json` LAST, which is the only reason a
152
- * client process can see a bot token the daemon owns. A manager built without
153
- * that overlay reads a surface silo holding nothing but `setupVersion` and
154
- * reports every channel as unconfigured.
155
- */
156
- export function readChannelReadiness(config: Pick<ConfigManager, 'get'>): readonly ChannelReadiness[] {
157
- return SEND_CHANNELS.map((channel) => {
158
- const destination = readSetting(config, channel.destinationKey);
159
- return {
160
- channel,
161
- enabled: config.get(channel.enabledKey) === true,
162
- destination: destination.length > 0 ? destination : null,
163
- };
164
- });
165
- }
166
-
167
- export type DefaultChannelResolution =
168
- | { readonly kind: 'resolved'; readonly channel: SendChannel; readonly destination: string; readonly reason: string }
169
- | { readonly kind: 'none'; readonly candidates: readonly ChannelReadiness[] }
170
- | { readonly kind: 'ambiguous'; readonly candidates: readonly ChannelReadiness[] };
171
-
172
- /**
173
- * Which channel a `send` with no `--channel` goes to.
174
- *
175
- * A channel qualifies when it is switched on AND has a destination configured —
176
- * "enabled" alone is not enough, because an enabled surface with a blank
177
- * destination is a channel that would throw at the provider rather than deliver.
178
- *
179
- * **Ambiguity refuses; it never picks.** With two qualifying channels there is
180
- * no non-arbitrary winner, and this command has an outward effect: sending the
181
- * owner's message to the wrong one of his channels is worse than printing the
182
- * list and exiting non-zero. There is deliberately no priority order here to
183
- * silently break that tie — a preference ordering baked into this file would be
184
- * an invisible decision about where his messages go.
185
- */
186
- export function resolveDefaultChannel(config: Pick<ConfigManager, 'get'>): DefaultChannelResolution {
187
- const readiness = readChannelReadiness(config);
188
- const qualifying = readiness.filter((entry) => entry.enabled && entry.destination !== null);
189
- if (qualifying.length === 1) {
190
- const only = qualifying[0]!;
191
- return {
192
- kind: 'resolved',
193
- channel: only.channel,
194
- destination: only.destination!,
195
- reason: 'the only channel that is switched on and has a destination configured',
196
- };
197
- }
198
- if (qualifying.length === 0) return { kind: 'none', candidates: readiness };
199
- return { kind: 'ambiguous', candidates: qualifying };
200
- }
@@ -1,332 +0,0 @@
1
- /**
2
- * command.ts — `goodvibes-daemon send`, the shell's way to put a message on one
3
- * of the owner's channels.
4
- *
5
- * ## Why this exists
6
- *
7
- * Nothing on this machine could send the owner a message from a script. The
8
- * three binaries exposed no send verb, the daemon's HTTP API answers
9
- * `401 AUTH_REQUIRED` to the operator token as stored, and driving the agent to
10
- * do it failed with `Missing Telegram bot token` — because the credential lives
11
- * in the DAEMON tier (`~/.goodvibes/daemon/settings.json`) and the agent was
12
- * reading its own surface silo. So the one process that could always send was
13
- * the daemon, and only while it was running.
14
- *
15
- * ## Three properties this command is built around
16
- *
17
- * 1. **It uses the delivery path, it is not a second sender.** Everything below
18
- * ends in `ChannelDeliveryRouter.deliver()` — the same call
19
- * `AutomationDeliveryManager.sendTarget` makes, reaching the same
20
- * per-surface strategies in `strategies-core.ts`. Nothing here talks to a
21
- * provider API directly.
22
- *
23
- * 2. **It never exits 0 on a send that did not happen.** The router throws with
24
- * the provider's own error text and that error is printed and exits non-zero.
25
- * `AutomationDeliveryManager.deliverText` was the alternative entry point and
26
- * was NOT used, deliberately: it returns an empty array when a feature gate
27
- * is off and returns failed attempts rather than throwing, so a caller that
28
- * did not inspect its result would report success for a message that never
29
- * left the machine — the exact false-green this command exists to avoid. The
30
- * gate check it would have done is done here instead, explicitly, and a gate
31
- * that is off produces a refusal naming the settings key rather than silence.
32
- *
33
- * 3. **Every message it sends arrives as literal text.** The body is passed
34
- * through `inertBodyFor` for the target surface before it reaches the router,
35
- * and there is no flag, env var or code path that skips that. The message
36
- * normally comes from the operator's own shell, but the command must not
37
- * become the way something else's text — a log line, a captured error, a
38
- * remote agent's output piped in — arrives on the owner's phone rendered as
39
- * live markup with a clickable link in it. See inert-text.ts.
40
- */
41
-
42
- import type { ConfigManager } from '../../config/index.ts';
43
- import type { ChannelDeliveryRequest } from '@pellux/goodvibes-sdk/platform/channels';
44
- import { getMissingSurfaceFeatureFlags, surfaceFeatureGateSettingsKeys } from '../../runtime/surface-feature-flags.ts';
45
- import { findSendChannel, readChannelReadiness, resolveDefaultChannel, SEND_CHANNELS, type SendChannel } from './channels.ts';
46
- import { describeSendFailure } from './failure-text.ts';
47
- import { inertBodyFor } from './inert-text.ts';
48
-
49
- /** What the router needs to actually send; injected so tests never reach the network. */
50
- export type SendDeliver = (request: ChannelDeliveryRequest) => Promise<string | undefined>;
51
-
52
- export interface SendCommandDeps {
53
- /** Built with a `homeDir` so the daemon tier overlays — see channels.ts. */
54
- readonly configManager: Pick<ConfigManager, 'get'>;
55
- readonly deliver: SendDeliver;
56
- /** Reads the whole of stdin; only called when no message argument was given. */
57
- readonly readStdin: () => Promise<string>;
58
- /** Whether stdin is a terminal. A TTY means there is no piped message to wait for. */
59
- readonly stdinIsTty: boolean;
60
- /** Injected so the run id in the delivery request is deterministic under test. */
61
- readonly newRunId?: (() => string) | undefined;
62
- }
63
-
64
- export interface SendCommandResult {
65
- readonly lines: readonly string[];
66
- readonly exitCode: number;
67
- }
68
-
69
- interface ParsedSendArgs {
70
- readonly channel: string | null;
71
- readonly to: string | null;
72
- readonly title: string | null;
73
- readonly list: boolean;
74
- readonly help: boolean;
75
- readonly words: readonly string[];
76
- readonly errors: readonly string[];
77
- }
78
-
79
- const USAGE = [
80
- 'Usage: goodvibes-daemon send [OPTIONS] [MESSAGE...]',
81
- '',
82
- 'Send a message to one of your configured channels. With no MESSAGE, the',
83
- 'message is read from stdin, so this composes with other tooling.',
84
- '',
85
- 'Options:',
86
- ' --channel <id> Channel to send to. With none named, your configured',
87
- ' channel is used and the output says which one.',
88
- ' --to <address> Where within that channel: an ntfy topic, a Telegram chat',
89
- ' id, a Slack or Mattermost channel id, a Matrix room id.',
90
- ' Without it the channel\'s configured destination is used.',
91
- ' --title <text> Title for channels that show one (ntfy).',
92
- ' --list Show every channel, whether it is on, and where it sends.',
93
- ' -h, --help Print this help',
94
- '',
95
- 'A channel that is switched off is refused by name and NOTHING is sent — the',
96
- 'command never quietly falls back to the default, so a message meant for a',
97
- 'quiet channel cannot end up on a noisy one.',
98
- '',
99
- 'The message is always delivered as literal text: markup a channel would',
100
- 'otherwise render — a Discord masked link, a Slack mention — arrives inert.',
101
- ].join('\n');
102
-
103
- function parseSendArgs(argv: readonly string[]): ParsedSendArgs {
104
- let channel: string | null = null;
105
- let to: string | null = null;
106
- let title: string | null = null;
107
- let list = false;
108
- let help = false;
109
- const words: string[] = [];
110
- const errors: string[] = [];
111
- let optionsEnded = false;
112
-
113
- const takeValue = (flag: string, value: string | undefined): string | null => {
114
- if (value === undefined || value.length === 0) {
115
- errors.push(`${flag} needs a value.`);
116
- return null;
117
- }
118
- return value;
119
- };
120
-
121
- for (let index = 0; index < argv.length; index += 1) {
122
- const arg = argv[index]!;
123
- if (optionsEnded) { words.push(arg); continue; }
124
- // Everything after `--` is message text, so a message that starts with a
125
- // dash is still sendable.
126
- if (arg === '--') { optionsEnded = true; continue; }
127
- if (arg === '-h' || arg === '--help') { help = true; continue; }
128
- if (arg === '--list') { list = true; continue; }
129
- if (arg === '--channel' || arg === '-c') { channel = takeValue(arg, argv[++index]); continue; }
130
- if (arg.startsWith('--channel=')) { channel = takeValue('--channel', arg.slice('--channel='.length)); continue; }
131
- if (arg === '--to') { to = takeValue(arg, argv[++index]); continue; }
132
- if (arg.startsWith('--to=')) { to = takeValue('--to', arg.slice('--to='.length)); continue; }
133
- if (arg === '--title') { title = takeValue(arg, argv[++index]); continue; }
134
- if (arg.startsWith('--title=')) { title = takeValue('--title', arg.slice('--title='.length)); continue; }
135
- if (arg.startsWith('-') && arg.length > 1) {
136
- errors.push(`Unknown option: ${arg}`);
137
- continue;
138
- }
139
- words.push(arg);
140
- }
141
- return { channel, to, title, list, help, words, errors };
142
- }
143
-
144
- /**
145
- * The channels that are actually usable right now, named. Every refusal ends
146
- * with this: telling someone their channel is not configured without telling
147
- * them which ones are just moves the guessing to them.
148
- */
149
- function describeConfiguredChannels(config: Pick<ConfigManager, 'get'>): string {
150
- const usable = readChannelReadiness(config)
151
- .filter((entry) => entry.enabled && entry.destination !== null)
152
- .map((entry) => entry.channel.id);
153
- return usable.length > 0
154
- ? `Configured and ready: ${usable.join(', ')}.`
155
- : 'No channel is currently both switched on and given a destination — run: goodvibes-daemon send --list';
156
- }
157
-
158
- function renderChannelList(config: Pick<ConfigManager, 'get'>): string[] {
159
- const readiness = readChannelReadiness(config);
160
- const idWidth = Math.max(...SEND_CHANNELS.map((channel) => channel.id.length), 7);
161
- const lines = ['Channels goodvibes-daemon send can reach:', ''];
162
- for (const entry of readiness) {
163
- const state = entry.enabled ? 'on ' : 'off';
164
- const destination = entry.destination ?? `not set (${entry.channel.destinationKey})`;
165
- lines.push(` ${entry.channel.id.padEnd(idWidth)} ${state} ${entry.channel.addressLabel}: ${destination}`);
166
- }
167
- lines.push('');
168
- lines.push('Override any channel\'s destination for one message with --to <address>.');
169
- lines.push('');
170
- const resolution = resolveDefaultChannel(config);
171
- if (resolution.kind === 'resolved') {
172
- lines.push(`Default with no --channel: ${resolution.channel.id} (${resolution.reason}).`);
173
- } else if (resolution.kind === 'none') {
174
- lines.push('There is no default: no channel is both switched on and given a destination.');
175
- } else {
176
- const names = resolution.candidates.map((entry) => entry.channel.id).join(', ');
177
- lines.push(`There is no default: ${names} all qualify, so --channel is required.`);
178
- }
179
- return lines;
180
- }
181
-
182
- /** Refusals that must happen before anything is sent, in the order they matter. */
183
- function checkChannelUsable(
184
- config: Pick<ConfigManager, 'get'>,
185
- channel: SendChannel,
186
- ): readonly string[] {
187
- if (config.get(channel.enabledKey) !== true) {
188
- // No fallback to the default channel, deliberately. Falling back is how a
189
- // message meant for a quiet channel lands on a noisy one, and how a caller
190
- // that named a channel because it mattered never finds out it was ignored.
191
- return [
192
- `${channel.label} is switched off, so nothing was sent.`,
193
- `Switch it on with: goodvibes surfaces enable ${channel.id} (settings key ${channel.enabledKey})`,
194
- describeConfiguredChannels(config),
195
- ];
196
- }
197
- // The same capability gates the daemon's own delivery honours. Checked here
198
- // rather than left to AutomationDeliveryManager, which answers a disabled
199
- // gate with an empty result and no reason.
200
- const missing = getMissingSurfaceFeatureFlags(config, channel.id);
201
- if (missing.length > 0) {
202
- return [
203
- `${channel.label} is switched on but the capabilities delivery needs are off, so nothing was sent.`,
204
- `Turn these settings on: ${surfaceFeatureGateSettingsKeys(missing).join(', ')}`,
205
- describeConfiguredChannels(config),
206
- ];
207
- }
208
- return [];
209
- }
210
-
211
- export async function runSendCommand(
212
- argv: readonly string[],
213
- deps: SendCommandDeps,
214
- ): Promise<SendCommandResult> {
215
- const parsed = parseSendArgs(argv);
216
- if (parsed.errors.length > 0) {
217
- return { lines: [...parsed.errors, '', USAGE], exitCode: 2 };
218
- }
219
- if (parsed.help) return { lines: [USAGE], exitCode: 0 };
220
- if (parsed.list) return { lines: renderChannelList(deps.configManager), exitCode: 0 };
221
-
222
- // --- which channel -------------------------------------------------------
223
- let channel: SendChannel;
224
- let usedDefault = false;
225
- let defaultReason = '';
226
- if (parsed.channel !== null) {
227
- const named = findSendChannel(parsed.channel);
228
- if (!named) {
229
- return {
230
- lines: [
231
- `Unknown channel: ${parsed.channel}`,
232
- `Known channels: ${SEND_CHANNELS.map((entry) => entry.id).join(', ')}`,
233
- describeConfiguredChannels(deps.configManager),
234
- ],
235
- exitCode: 2,
236
- };
237
- }
238
- channel = named;
239
- } else {
240
- const resolution = resolveDefaultChannel(deps.configManager);
241
- if (resolution.kind === 'none') {
242
- return {
243
- lines: [
244
- 'No channel was named and none is configured to be the default, so nothing was sent.',
245
- 'A channel qualifies when it is switched on AND has a destination set.',
246
- '',
247
- ...renderChannelList(deps.configManager),
248
- ],
249
- exitCode: 2,
250
- };
251
- }
252
- if (resolution.kind === 'ambiguous') {
253
- return {
254
- lines: [
255
- `No channel was named and more than one qualifies (${resolution.candidates.map((entry) => entry.channel.id).join(', ')}), so nothing was sent.`,
256
- 'Name one with --channel <id> rather than have this command guess which of your channels to message.',
257
- ],
258
- exitCode: 2,
259
- };
260
- }
261
- channel = resolution.channel;
262
- usedDefault = true;
263
- defaultReason = resolution.reason;
264
- }
265
-
266
- // --- what to send --------------------------------------------------------
267
- let message = parsed.words.join(' ');
268
- if (message.trim().length === 0) {
269
- if (deps.stdinIsTty) {
270
- return {
271
- lines: ['No message given. Pass it as an argument or pipe it on stdin.', '', USAGE],
272
- exitCode: 2,
273
- };
274
- }
275
- message = (await deps.readStdin()).replace(/\n+$/, '');
276
- }
277
- if (message.trim().length === 0) {
278
- return { lines: ['The message was empty, so nothing was sent.'], exitCode: 2 };
279
- }
280
-
281
- const refusal = checkChannelUsable(deps.configManager, channel);
282
- if (refusal.length > 0) return { lines: refusal, exitCode: 1 };
283
-
284
- // --- send ----------------------------------------------------------------
285
- const runId = deps.newRunId?.() ?? `cli-send-${Date.now().toString(36)}`;
286
- const title = parsed.title ?? 'GoodVibes';
287
- const body = inertBodyFor(channel.surfaceKind, message);
288
- const request: ChannelDeliveryRequest = {
289
- target: {
290
- kind: 'surface',
291
- surfaceKind: channel.surfaceKind,
292
- ...(parsed.to === null ? {} : { address: parsed.to }),
293
- label: title,
294
- },
295
- body,
296
- title,
297
- jobId: 'goodvibes-daemon-send',
298
- runId,
299
- // A message typed at a shell has no artifacts and no control-plane session
300
- // to link back to; a link appended here would point at a page the reader
301
- // did not ask for.
302
- includeLinks: false,
303
- };
304
-
305
- const preamble = usedDefault
306
- ? [`No channel named — using ${channel.id}: ${defaultReason}.`]
307
- : [];
308
- try {
309
- const responseId = await deps.deliver(request);
310
- return {
311
- lines: [
312
- ...preamble,
313
- `Sent to ${channel.label}${responseId ? ` (${responseId})` : ''}.`,
314
- ],
315
- exitCode: 0,
316
- };
317
- } catch (error) {
318
- // The provider's own words, not a paraphrase: "Missing Telegram chat id"
319
- // and "HTTP 401: Unauthorized" are different problems with different fixes,
320
- // and flattening them into "delivery failed" is what makes a failed send
321
- // take an hour to diagnose. See failure-text.ts for what is stripped
322
- // (credentials) and what is deliberately kept (everything else).
323
- return {
324
- lines: [
325
- ...preamble,
326
- `Sending to ${channel.label} failed, so the message did NOT go out.`,
327
- describeSendFailure(error),
328
- ],
329
- exitCode: 1,
330
- };
331
- }
332
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * composition.ts — the smallest set of services that can put a message on a
3
- * channel, built from the daemon's own tier.
4
- *
5
- * ## Why not `createRuntimeServices`
6
- *
7
- * The daemon's full runtime graph starts a LAN scan, a cluster coordinator, an
8
- * inbox poller, a fleet tick, a memory governor and a config watch. Composing
9
- * it to send one message would build a second, competing set of that state on a
10
- * machine that is already running a daemon — the same reason `cluster …` is
11
- * intercepted before any runtime is constructed (see src/daemon/cli.ts). This
12
- * builds only the five objects `ChannelDeliveryRouter` needs and starts no
13
- * timers, binds no sockets and joins no election, so it is safe to run beside a
14
- * live daemon.
15
- *
16
- * ## Why it does not talk to the running daemon over HTTP either
17
- *
18
- * That was tried before this command existed: the control-plane API answers
19
- * `401 AUTH_REQUIRED` to the operator token as stored on disk. More importantly
20
- * an HTTP-backed send would only work while a daemon is up, and the case this
21
- * command is for — telling the owner that something has stopped — is exactly
22
- * when it may not be.
23
- *
24
- * ## Where the credentials come from
25
- *
26
- * `surfaces.*` is a daemon-owned config prefix, so `ConfigManager` overlays
27
- * `<home>/.goodvibes/daemon/settings.json` LAST and a bot token stored there is
28
- * visible here. `SecretsManager` gets the same `daemonHome` the daemon itself
29
- * resolves, so a `goodvibes://secrets/...` reference in one of those keys
30
- * resolves against the daemon's store rather than a client silo. Getting that
31
- * second half wrong is what produced `Missing Telegram bot token` from a
32
- * machine whose token was present and correct.
33
- */
34
-
35
- import { ChannelDeliveryRouter } from '@pellux/goodvibes-sdk/platform/channels';
36
- import { ArtifactStore } from '@pellux/goodvibes-sdk/platform/artifacts';
37
- import { ConfigManager, ServiceRegistry, SubscriptionManager } from '@pellux/goodvibes-sdk/platform/config';
38
- import { createShellPathService } from '@/runtime/index.ts';
39
- import { SecretsManager } from '../../config/secrets.ts';
40
- import type { SendDeliver } from './command.ts';
41
-
42
- export interface SendStackRoots {
43
- readonly workingDirectory: string;
44
- /** The GoodVibes tree root — the directory `.goodvibes/` sits under. */
45
- readonly homeDirectory: string;
46
- /** The daemon's own state root, holding the daemon-scoped secret stores. */
47
- readonly daemonHomeDirectory: string;
48
- }
49
-
50
- export interface SendStack {
51
- readonly configManager: ConfigManager;
52
- readonly deliver: SendDeliver;
53
- }
54
-
55
- /**
56
- * Build the delivery stack for one CLI send.
57
- *
58
- * `secretsManager` is passed to `ChannelDeliveryRouter` because the router
59
- * REQUIRES it and refuses to construct without it. That requirement is the fix
60
- * for a real defect: while the parameter was optional, two shipped composition
61
- * roots (goodvibes-tui and goodvibes-agent) omitted it, still type-checked,
62
- * still delivered on every surface whose credential happens to sit in config or
63
- * the environment, and failed only on the surfaces that use a secret reference
64
- * — at send time, as `Missing Telegram bot token`. This composition root does
65
- * not repeat that.
66
- */
67
- export function createSendStack(roots: SendStackRoots): SendStack {
68
- const configManager = new ConfigManager({
69
- workingDir: roots.workingDirectory,
70
- homeDir: roots.homeDirectory,
71
- surfaceRoot: 'tui',
72
- });
73
- const shellPaths = createShellPathService({
74
- workingDirectory: roots.workingDirectory,
75
- homeDirectory: roots.homeDirectory,
76
- });
77
- const secretsManager = new SecretsManager({
78
- projectRoot: roots.workingDirectory,
79
- globalHome: roots.homeDirectory,
80
- // Threaded, never defaulted: a daemon told to run out of an isolated tree
81
- // must not read the real home's credential store, and neither must this.
82
- daemonHome: roots.daemonHomeDirectory,
83
- configManager,
84
- });
85
- const serviceRegistry = new ServiceRegistry(shellPaths.resolveProjectPath('tui', 'services.json'), {
86
- secretsManager,
87
- subscriptionManager: new SubscriptionManager(shellPaths.resolveUserPath('tui', 'subscriptions.json')),
88
- });
89
- const router = new ChannelDeliveryRouter({
90
- configManager,
91
- secretsManager,
92
- serviceRegistry,
93
- artifactStore: new ArtifactStore({ configManager }),
94
- });
95
- return {
96
- configManager,
97
- deliver: (request) => router.deliver(request),
98
- };
99
- }