@pellux/goodvibes-tui 1.27.0 → 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 (404) hide show
  1. package/CHANGELOG.md +125 -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 +12 -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 +15 -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 -641
  288. package/src/daemon/handlers/context.ts +0 -29
  289. package/src/daemon/handlers/contracts.ts +0 -77
  290. package/src/daemon/handlers/credentials.ts +0 -139
  291. package/src/daemon/handlers/drafts/draft-store.ts +0 -427
  292. package/src/daemon/handlers/drafts/index.ts +0 -17
  293. package/src/daemon/handlers/drafts/register.ts +0 -331
  294. package/src/daemon/handlers/errors.ts +0 -18
  295. package/src/daemon/handlers/inbox/cursor-store.ts +0 -457
  296. package/src/daemon/handlers/inbox/index.ts +0 -284
  297. package/src/daemon/handlers/inbox/mapping.ts +0 -192
  298. package/src/daemon/handlers/inbox/poller.ts +0 -212
  299. package/src/daemon/handlers/inbox/provider-adapter.ts +0 -156
  300. package/src/daemon/handlers/inbox/providers/discord.ts +0 -252
  301. package/src/daemon/handlers/inbox/providers/email.ts +0 -152
  302. package/src/daemon/handlers/inbox/providers/imap-client.ts +0 -300
  303. package/src/daemon/handlers/inbox/providers/route-util.ts +0 -24
  304. package/src/daemon/handlers/inbox/providers/slack.ts +0 -263
  305. package/src/daemon/handlers/index.ts +0 -117
  306. package/src/daemon/handlers/register.ts +0 -168
  307. package/src/daemon/handlers/remote/backends/cloud-terminal.ts +0 -142
  308. package/src/daemon/handlers/remote/backends/docker.ts +0 -79
  309. package/src/daemon/handlers/remote/backends/index.ts +0 -40
  310. package/src/daemon/handlers/remote/backends/local-process.ts +0 -113
  311. package/src/daemon/handlers/remote/backends/process-runner.ts +0 -127
  312. package/src/daemon/handlers/remote/backends/ssh.ts +0 -125
  313. package/src/daemon/handlers/remote/backends/types.ts +0 -97
  314. package/src/daemon/handlers/remote/dispatcher.ts +0 -181
  315. package/src/daemon/handlers/remote/index.ts +0 -119
  316. package/src/daemon/handlers/remote/peer-registry.ts +0 -357
  317. package/src/daemon/handlers/remote/service.ts +0 -191
  318. package/src/daemon/handlers/routing/inbox-bridge.ts +0 -71
  319. package/src/daemon/handlers/routing/index.ts +0 -261
  320. package/src/daemon/handlers/routing/route-store.ts +0 -319
  321. package/src/daemon/handlers/routing/routing-resolver.ts +0 -75
  322. package/src/daemon/handlers/sqlite-store.ts +0 -278
  323. package/src/daemon/handlers/triage/index.ts +0 -57
  324. package/src/daemon/handlers/triage/integration.ts +0 -213
  325. package/src/daemon/handlers/triage/pipeline.ts +0 -274
  326. package/src/daemon/handlers/triage/scorer.ts +0 -287
  327. package/src/daemon/handlers/triage/tagger/discord.ts +0 -187
  328. package/src/daemon/handlers/triage/tagger/imap.ts +0 -384
  329. package/src/daemon/handlers/triage/tagger/index.ts +0 -184
  330. package/src/daemon/handlers/triage/tagger/shared.ts +0 -70
  331. package/src/daemon/handlers/triage/tagger/slack.ts +0 -69
  332. package/src/daemon/handlers/triage/types.ts +0 -50
  333. package/src/daemon/lifecycle.ts +0 -41
  334. package/src/daemon/provision-wake-model.ts +0 -81
  335. package/src/daemon/safe-serve.ts +0 -61
  336. package/src/daemon/send/channels.ts +0 -200
  337. package/src/daemon/send/command.ts +0 -332
  338. package/src/daemon/send/composition.ts +0 -99
  339. package/src/daemon/send/failure-text.ts +0 -93
  340. package/src/daemon/send/inert-text.ts +0 -225
  341. package/src/daemon/send/stdin.ts +0 -24
  342. package/src/daemon/service-commands.ts +0 -329
  343. package/src/export/cost-utils.ts +0 -319
  344. package/src/input/selection.ts +0 -135
  345. package/src/plugins/loader.ts +0 -15
  346. package/src/renderer/bottom-bar.ts +0 -58
  347. package/src/renderer/conversation-tree.ts +0 -228
  348. package/src/runtime/agent-graph-composition.ts +0 -78
  349. package/src/runtime/channel-composition.ts +0 -46
  350. package/src/runtime/cluster-composition.ts +0 -124
  351. package/src/runtime/cluster-group-composition.ts +0 -284
  352. package/src/runtime/code-index-services.ts +0 -167
  353. package/src/runtime/daemon-handler-composition.ts +0 -76
  354. package/src/runtime/device-posture-composition.ts +0 -110
  355. package/src/runtime/durability-housekeeping.ts +0 -183
  356. package/src/runtime/durability-services.ts +0 -155
  357. package/src/runtime/embedded-service-factories.ts +0 -58
  358. package/src/runtime/feature-settings.ts +0 -154
  359. package/src/runtime/fleet-needs-input-push.ts +0 -70
  360. package/src/runtime/fleet-services.ts +0 -41
  361. package/src/runtime/idle-power-services.ts +0 -85
  362. package/src/runtime/mail-composition.ts +0 -65
  363. package/src/runtime/memory-fold.ts +0 -55
  364. package/src/runtime/operator-token-cleanup.ts +0 -109
  365. package/src/runtime/path-shadow.ts +0 -418
  366. package/src/runtime/perf/panel-health-monitor.ts +0 -18
  367. package/src/runtime/provider-optimizer-wiring.ts +0 -55
  368. package/src/runtime/reachability-notice.ts +0 -100
  369. package/src/runtime/remote-execution-composition.ts +0 -62
  370. package/src/runtime/session-liveness-marker.ts +0 -257
  371. package/src/runtime/session-pointer-surface.ts +0 -22
  372. package/src/runtime/session-storage-services.ts +0 -41
  373. package/src/runtime/surface-feature-flags.ts +0 -96
  374. package/src/runtime/terminal-output-guard.ts +0 -235
  375. package/src/runtime/trust/workspace-registration.ts +0 -192
  376. package/src/runtime/trust/workspace-trust.ts +0 -229
  377. package/src/runtime/ui/index.ts +0 -39
  378. package/src/runtime/ui/model-picker/data-provider.ts +0 -182
  379. package/src/runtime/ui/model-picker/health-enrichment.ts +0 -231
  380. package/src/runtime/ui/model-picker/index.ts +0 -59
  381. package/src/runtime/ui/model-picker/types.ts +0 -153
  382. package/src/runtime/ui/provider-health/data-provider.ts +0 -244
  383. package/src/runtime/ui/provider-health/fallback-visualizer.ts +0 -71
  384. package/src/runtime/ui/provider-health/index.ts +0 -46
  385. package/src/runtime/ui/provider-health/types.ts +0 -146
  386. package/src/runtime/ui-events.ts +0 -1
  387. package/src/runtime/ui-read-model-helpers.ts +0 -1
  388. package/src/runtime/ui-read-models-observability-maintenance.ts +0 -1
  389. package/src/runtime/ui-read-models-observability-options.ts +0 -1
  390. package/src/runtime/ui-read-models-observability-remote.ts +0 -1
  391. package/src/runtime/ui-read-models-observability-security.ts +0 -1
  392. package/src/runtime/ui-read-models-observability-system.ts +0 -1
  393. package/src/runtime/ui-read-models-observability.ts +0 -1
  394. package/src/runtime/ui-service-queries.ts +0 -1
  395. package/src/runtime/voice-setup-services.ts +0 -98
  396. package/src/runtime/workstream-attempts-validation.ts +0 -77
  397. package/src/runtime/workstream-draft-edits.ts +0 -95
  398. package/src/runtime/workstream-draft-store.ts +0 -274
  399. package/src/runtime/workstream-draft-types.ts +0 -42
  400. package/src/runtime/workstream-services.ts +0 -373
  401. package/src/tools/index.ts +0 -1
  402. package/src/types/grid.ts +0 -48
  403. package/src/types/sql-js.d.ts +0 -15
  404. package/src/work-plans/work-plan-store.ts +0 -702
@@ -1,278 +0,0 @@
1
- import { mkdir, rename, writeFile } from 'node:fs/promises';
2
- import { readFileSync, readdirSync, renameSync, rmSync, statSync } from 'node:fs';
3
- import { existsSync } from 'node:fs';
4
- import { basename, dirname, join } from 'node:path';
5
- import { logger } from '@pellux/goodvibes-sdk/platform/utils';
6
- import initSqlJs from 'sql.js';
7
-
8
- type SqlJsStatic = Awaited<ReturnType<typeof initSqlJs>>;
9
- type SqlDatabase = InstanceType<SqlJsStatic['Database']>;
10
-
11
- export interface SqliteStoreOptions {
12
- workingDirectory: string;
13
- /** e.g. 'channel-routes.sqlite', 'drafts.sqlite', 'inbox-cursors.sqlite' */
14
- fileName: string;
15
- /** CREATE TABLE / INDEX statements run once on init (idempotent: IF NOT EXISTS). */
16
- schema: string[];
17
- }
18
-
19
- /**
20
- * The 16 bytes every SQLite file begins with ("SQLite format 3" + NUL). A file
21
- * that does not start with these is not a database, whatever its extension —
22
- * which is exactly what a crash mid-create, a zero-fill, or a partially
23
- * restored backup leaves behind.
24
- */
25
- const SQLITE_HEADER = Buffer.from('SQLite format 3\0', 'latin1');
26
-
27
- /**
28
- * How long a quarantined `.corrupt-<timestamp>` database is kept before it is
29
- * reclaimed. These files exist so an operator can try to salvage a damaged
30
- * store by hand; 14 days is long enough for someone to notice a broken daemon
31
- * and come looking, and short enough that a store that goes bad repeatedly
32
- * cannot fill the disk with copies of itself. Reaped on the next init.
33
- */
34
- const CORRUPT_QUARANTINE_TTL_MS = 14 * 24 * 60 * 60 * 1000;
35
-
36
- /** At most this many quarantined copies of one store are kept, newest first. */
37
- const MAX_CORRUPT_QUARANTINES = 3;
38
-
39
- let sqlJsStaticPromise: Promise<SqlJsStatic> | null = null;
40
-
41
- async function loadSqlJs(): Promise<SqlJsStatic> {
42
- if (!sqlJsStaticPromise) {
43
- sqlJsStaticPromise = initSqlJs();
44
- }
45
- return sqlJsStaticPromise;
46
- }
47
-
48
- /**
49
- * Daemon sqlite helper following the project MemoryStore lifecycle
50
- * (sql.js WASM: init → run/exec → save → close). One file per concern under
51
- * {workingDirectory}/.goodvibes/tui/operator/{fileName}.
52
- */
53
- export class HandlerSqliteStore {
54
- private readonly options: SqliteStoreOptions;
55
- private readonly resolvedPath: string;
56
- private db: SqlDatabase | null = null;
57
-
58
- constructor(options: SqliteStoreOptions) {
59
- this.options = options;
60
- this.resolvedPath = join(
61
- options.workingDirectory,
62
- '.goodvibes',
63
- 'tui',
64
- 'operator',
65
- options.fileName,
66
- );
67
- }
68
-
69
- get dbPath(): string {
70
- return this.resolvedPath;
71
- }
72
-
73
- private requireDb(): SqlDatabase {
74
- if (!this.db) {
75
- throw new Error(`HandlerSqliteStore not initialized: ${this.resolvedPath}`);
76
- }
77
- return this.db;
78
- }
79
-
80
- /**
81
- * Move a database file that cannot be opened aside instead of deleting it, so
82
- * an operator still has something to salvage, and return the quarantine path.
83
- * Returns null when the move itself failed — in which case the caller starts
84
- * fresh in memory and the bad file is left exactly where it was rather than
85
- * being overwritten on the next save.
86
- */
87
- private quarantineUnreadable(): string | null {
88
- const target = `${this.resolvedPath}.corrupt-${Date.now()}`;
89
- try {
90
- renameSync(this.resolvedPath, target);
91
- return target;
92
- } catch {
93
- return null;
94
- }
95
- }
96
-
97
- /**
98
- * Bound the quarantine directory: drop `.corrupt-*` copies of THIS store that
99
- * are past the TTL or beyond the keep-newest count. Best-effort and
100
- * idempotent — a file another process already removed is success, not an
101
- * error — so two daemons opening the same store at once cannot fight.
102
- * Returns how many were reclaimed.
103
- */
104
- private reapCorruptQuarantines(nowMs: number): number {
105
- const dir = dirname(this.resolvedPath);
106
- const prefix = `${basename(this.resolvedPath)}.corrupt-`;
107
- let candidates: Array<{ path: string; mtimeMs: number }>;
108
- try {
109
- candidates = readdirSync(dir)
110
- .filter((name) => name.startsWith(prefix))
111
- .map((name) => join(dir, name))
112
- .flatMap((path) => {
113
- try {
114
- return [{ path, mtimeMs: statSync(path).mtimeMs }];
115
- } catch {
116
- return [];
117
- }
118
- });
119
- } catch {
120
- return 0;
121
- }
122
- if (candidates.length === 0) return 0;
123
- // Newest first: the newest MAX_CORRUPT_QUARANTINES survive the count cap,
124
- // and everything past the TTL goes regardless of rank.
125
- candidates.sort((a, b) => b.mtimeMs - a.mtimeMs);
126
- let reclaimed = 0;
127
- for (const [index, candidate] of candidates.entries()) {
128
- const tooOld = nowMs - candidate.mtimeMs > CORRUPT_QUARANTINE_TTL_MS;
129
- const overCap = index >= MAX_CORRUPT_QUARANTINES;
130
- if (!tooOld && !overCap) continue;
131
- try {
132
- rmSync(candidate.path, { force: true });
133
- reclaimed += 1;
134
- } catch {
135
- // Another process may have taken it first; that is the outcome we wanted.
136
- }
137
- }
138
- return reclaimed;
139
- }
140
-
141
- async init(): Promise<void> {
142
- if (this.db) return;
143
- await mkdir(dirname(this.resolvedPath), { recursive: true });
144
- const SQL = await loadSqlJs();
145
-
146
- // Validate the file by its CONTENT, not by existsSync. `save()` writes
147
- // through a pid-and-timestamp temp file and an atomic rename, so it cannot
148
- // itself leave a half-written database — but a zero-filled file recovered
149
- // by a filesystem, a truncated restore, or a copy interrupted by something
150
- // outside this process all produce a path that exists and holds no usable
151
- // database. Handing those bytes to `new SQL.Database(...)` throws out of
152
- // init and takes the whole daemon store down with no way back.
153
- let existing: Buffer | undefined;
154
- let quarantined: string | null = null;
155
- let quarantineReason = '';
156
- if (existsSync(this.resolvedPath)) {
157
- let raw: Buffer | null = null;
158
- try {
159
- raw = readFileSync(this.resolvedPath);
160
- } catch {
161
- raw = null;
162
- }
163
- if (!raw || raw.length === 0) {
164
- quarantineReason = raw ? 'zero-byte file (interrupted write)' : 'unreadable file';
165
- quarantined = this.quarantineUnreadable();
166
- } else if (raw.length < SQLITE_HEADER.length || !raw.subarray(0, SQLITE_HEADER.length).equals(SQLITE_HEADER)) {
167
- quarantineReason = 'missing the SQLite file header (not a database)';
168
- quarantined = this.quarantineUnreadable();
169
- } else {
170
- existing = raw;
171
- }
172
- }
173
-
174
- if (existing) {
175
- // The constructor is NOT where a damaged image surfaces: sql.js accepts
176
- // the bytes and only reports "database disk image is malformed" when the
177
- // first statement touches a bad page. So the open is not proved until the
178
- // schema has actually run against it, and both steps share one catch.
179
- try {
180
- const candidate = new SQL.Database(existing);
181
- try {
182
- for (const statement of this.options.schema) candidate.run(statement);
183
- this.db = candidate;
184
- } catch (error) {
185
- candidate.close();
186
- throw error;
187
- }
188
- } catch (error) {
189
- // Header present but the body does not hold up: a truncated or damaged
190
- // database. Same treatment — set aside, disclose, start clean.
191
- quarantineReason = `database would not open: ${error instanceof Error ? error.message : String(error)}`;
192
- this.db = null;
193
- quarantined = this.quarantineUnreadable();
194
- }
195
- }
196
-
197
- if (!this.db) {
198
- this.db = new SQL.Database();
199
- for (const statement of this.options.schema) this.db.run(statement);
200
- }
201
-
202
- // Disclosure: starting a store from scratch is data loss from the user's
203
- // point of view, so it is never allowed to happen quietly.
204
- if (quarantineReason) {
205
- logger.warn('daemon store could not be opened — starting a fresh one', {
206
- store: this.options.fileName,
207
- path: this.resolvedPath,
208
- reason: quarantineReason,
209
- quarantinedTo: quarantined ?? '(could not be moved aside; left in place)',
210
- });
211
- }
212
-
213
- const reclaimed = this.reapCorruptQuarantines(Date.now());
214
- if (reclaimed > 0) {
215
- logger.info('daemon store reclaimed quarantined copies', {
216
- store: this.options.fileName,
217
- reclaimedFiles: reclaimed,
218
- ttlDays: Math.round(CORRUPT_QUARANTINE_TTL_MS / (24 * 60 * 60 * 1000)),
219
- keptNewest: MAX_CORRUPT_QUARANTINES,
220
- });
221
- }
222
- }
223
-
224
- /** Execute a write (INSERT/UPDATE/DELETE/CREATE). */
225
- run(sql: string, params?: (string | number | Uint8Array | null)[]): void {
226
- this.requireDb().run(sql, params);
227
- }
228
-
229
- /** SELECT → array of row objects (columns mapped to values). */
230
- all<T = Record<string, unknown>>(sql: string, params?: (string | number)[]): T[] {
231
- const result = this.requireDb().exec(sql, params);
232
- if (result.length === 0) return [];
233
- const { columns, values } = result[0]!;
234
- return values.map((row) => {
235
- const obj: Record<string, unknown> = {};
236
- for (let i = 0; i < columns.length; i += 1) {
237
- obj[columns[i]!] = row[i];
238
- }
239
- return obj as T;
240
- });
241
- }
242
-
243
- /** First row or null. */
244
- get<T = Record<string, unknown>>(sql: string, params?: (string | number)[]): T | null {
245
- const rows = this.all<T>(sql, params);
246
- return rows.length > 0 ? rows[0]! : null;
247
- }
248
-
249
- /** Serialize and atomically persist to dbPath (tmp + rename). */
250
- async save(): Promise<void> {
251
- const db = this.requireDb();
252
- await mkdir(dirname(this.resolvedPath), { recursive: true });
253
- const data = db.export();
254
- const tmpPath = `${this.resolvedPath}.${process.pid}.${Date.now()}.tmp`;
255
- await writeFile(tmpPath, data);
256
- await rename(tmpPath, this.resolvedPath);
257
- }
258
-
259
- close(): void {
260
- if (this.db) {
261
- this.db.close();
262
- this.db = null;
263
- }
264
- }
265
-
266
- /** BEGIN/COMMIT around fn; ROLLBACK on throw (synchronous sql.js). */
267
- transaction(fn: () => void): void {
268
- const db = this.requireDb();
269
- db.run('BEGIN');
270
- try {
271
- fn();
272
- db.run('COMMIT');
273
- } catch (error) {
274
- db.run('ROLLBACK');
275
- throw error;
276
- }
277
- }
278
- }
@@ -1,57 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Public surface for the daemon-internal Email Auto-Tag / Spam Triage handler.
3
- //
4
- // `registerTriagedInbox` (from ./integration.ts) is the single entry the
5
- // runtime composition root calls. It DECORATES the inbox surface's
6
- // `channels.inbox.list` handler (overlaying persisted triage metadata) and
7
- // returns the poller-facing pipeline + tagger. inbox.triage.* are NOT published
8
- // catalog methods — this surface registers no triage method id.
9
- // ---------------------------------------------------------------------------
10
-
11
- export {
12
- scoreInboundItem,
13
- labelToTag,
14
- type TriageScore,
15
- type TriageScorerOptions,
16
- } from './scorer.ts';
17
-
18
- export type {
19
- InboundChannelItem,
20
- TriageLabel,
21
- ConversationKind,
22
- } from './types.ts';
23
-
24
- export {
25
- runInboxTriage,
26
- createTriageStore,
27
- readTriageMetadata,
28
- readTriageMetadataBatch,
29
- enrichItemsWithTriage,
30
- TRIAGE_STORE_FILE,
31
- type TriageMetadata,
32
- type TriagedItem,
33
- type TriageOverlay,
34
- type TriageEnrichedItem,
35
- type RunInboxTriageOptions,
36
- type RunInboxTriageResult,
37
- } from './pipeline.ts';
38
-
39
- export {
40
- createTriageTagger,
41
- TRIAGE_AUTOTAG_FLAG,
42
- type TriageTagger,
43
- type TriageTaggerOptions,
44
- type TaggerProviderConfig,
45
- type ApplyTagsRequest,
46
- type ApplyTagsResult,
47
- type ImapStoreArgs,
48
- type ImapRetryOptions,
49
- } from './tagger/index.ts';
50
-
51
- export {
52
- registerTriagedInbox,
53
- INBOX_LIST_METHOD_ID,
54
- type RegisterInbox,
55
- type RegisterTriagedInboxOptions,
56
- type TriagedInboxRegistration,
57
- } from './integration.ts';
@@ -1,213 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Daemon-internal triage INTEGRATION (the single entry the runtime calls).
3
- //
4
- // `registerTriagedInbox(ctx, registerInbox, options)` closes the contract loop:
5
- //
6
- // 1. It DECORATES the inbox surface's `channels.inbox.list` handler. The
7
- // inbox surface (a separate handler module) attaches its handler to the
8
- // SDK-auto-registered descriptor via `ctx.catalog.register(descriptor,
9
- // handler, { replace: true })`. We pass the inbox `registerInbox` a
10
- // catalog PROXY whose `register` intercepts exactly the
11
- // `channels.inbox.list` id and wraps the handler so every returned item is
12
- // overlaid with the persisted triageScore/triageTags via
13
- // enrichItemsWithTriage(). Every other registration passes straight
14
- // through to the real catalog. The inbox descriptor/schema/id is never
15
- // re-authored — only its handler is wrapped.
16
- // 2. It exposes the triage pipeline + tagger (`runInboxTriage`, `tagger`) for
17
- // the daemon-internal poller, which scores items and persists them to the
18
- // co-located inbox-triage.sqlite store the decorator reads from.
19
- // 3. inbox.triage.* are intentionally NOT registered on the catalog (they are
20
- // a daemon-internal pipeline, not published methods) — so this module
21
- // makes ZERO catalog.register call for any triage id.
22
- //
23
- // Reads in the decorator are best-effort and degrade to the raw item when no
24
- // triage row exists yet, so the read-only inbox feed never breaks.
25
- // ---------------------------------------------------------------------------
26
-
27
- import type { HandlerContext } from '../context.ts';
28
- import type {
29
- GatewayMethodCatalog,
30
- GatewayMethodDescriptor,
31
- GatewayMethodHandler,
32
- } from '../contracts.ts';
33
- import type { Unregister } from '../register.ts';
34
- import { HandlerSqliteStore } from '../sqlite-store.ts';
35
- import {
36
- createTriageStore,
37
- enrichItemsWithTriage,
38
- runInboxTriage,
39
- type RunInboxTriageOptions,
40
- type RunInboxTriageResult,
41
- } from './pipeline.ts';
42
- import type { InboundChannelItem } from './types.ts';
43
- import {
44
- createTriageTagger,
45
- type ApplyTagsRequest,
46
- type ApplyTagsResult,
47
- type TriageTagger,
48
- type TriageTaggerOptions,
49
- } from './tagger/index.ts';
50
- import { summarizeError } from '@pellux/goodvibes-sdk/platform/utils';
51
-
52
- /**
53
- * Canonical id of the inbox list method whose handler we decorate. This is the
54
- * SDK's published id — referenced as a plain string for matching during
55
- * registration; no descriptor or schema is authored here.
56
- */
57
- export const INBOX_LIST_METHOD_ID = 'channels.inbox.list';
58
-
59
- /** Minimal shape of the inbox.list result the decorator overlays triage onto. */
60
- interface InboxListResult {
61
- items?: unknown;
62
- [key: string]: unknown;
63
- }
64
-
65
- export interface RegisterTriagedInboxOptions {
66
- pipeline?: RunInboxTriageOptions;
67
- tagger?: TriageTaggerOptions;
68
- }
69
-
70
- /**
71
- * The inbox surface provider. The runtime supplies the inbox module's register
72
- * function; we hand it a decorating catalog proxy so its `channels.inbox.list`
73
- * handler is wrapped with triage enrichment.
74
- */
75
- export type RegisterInbox = (ctx: HandlerContext) => Unregister;
76
-
77
- /** Handle returned to the runtime: teardown + the poller-facing pipeline/tagger. */
78
- export interface TriagedInboxRegistration {
79
- readonly unregister: Unregister;
80
- /** Score (+persist) a batch of polled items. Used by the inbox poller. */
81
- runInboxTriage(
82
- items: readonly InboundChannelItem[],
83
- options?: RunInboxTriageOptions,
84
- ): Promise<RunInboxTriageResult>;
85
- /** Provider-side tagger (IMAP flag / Slack or Discord reaction/tag). */
86
- readonly tagger: TriageTagger;
87
- }
88
-
89
- type StoredHandler = GatewayMethodHandler;
90
-
91
- interface EnrichmentProxy {
92
- readonly ctx: HandlerContext;
93
- /** Close the shared triage store handle (if one was ever opened). */
94
- dispose(): void;
95
- }
96
-
97
- /**
98
- * Build a HandlerContext whose catalog decorates `channels.inbox.list`
99
- * registration. The triage store is opened lazily ONCE on the first list
100
- * invocation and reused for every subsequent call (hot read path); the caller
101
- * disposes the handle on teardown.
102
- */
103
- function withInboxEnrichment(ctx: HandlerContext): EnrichmentProxy {
104
- const original = ctx.catalog;
105
-
106
- let store: HandlerSqliteStore | null = null;
107
- let initPromise: Promise<HandlerSqliteStore> | null = null;
108
- const getStore = async (): Promise<HandlerSqliteStore> => {
109
- if (store) return store;
110
- if (!initPromise) {
111
- const pending = createTriageStore(ctx.workingDirectory);
112
- initPromise = pending
113
- .init()
114
- .then(() => {
115
- store = pending;
116
- return pending;
117
- })
118
- .catch((error) => {
119
- initPromise = null; // allow a later call to retry opening the store
120
- throw error;
121
- });
122
- }
123
- return initPromise;
124
- };
125
- const dispose = (): void => {
126
- if (store) {
127
- store.close();
128
- store = null;
129
- }
130
- initPromise = null;
131
- };
132
-
133
- const decoratedRegister: GatewayMethodCatalog['register'] = (
134
- descriptor: GatewayMethodDescriptor,
135
- handler?: StoredHandler,
136
- options?: { replace?: boolean },
137
- ): Unregister => {
138
- if (descriptor.id !== INBOX_LIST_METHOD_ID || !handler) {
139
- return original.register(descriptor, handler, options);
140
- }
141
- const innerHandler = handler;
142
- const wrapped: StoredHandler = async (invocation) => {
143
- const result = (await innerHandler(invocation)) as InboxListResult;
144
- if (!result || !Array.isArray(result.items) || result.items.length === 0) {
145
- return result;
146
- }
147
- const items = result.items as Array<{ id: string }>;
148
- try {
149
- const handle = await getStore();
150
- return { ...result, items: enrichItemsWithTriage(handle, items) };
151
- } catch (error) {
152
- // Triage is best-effort: a missing/locked store must never break the
153
- // read-only inbox feed. Log and return the un-enriched result.
154
- ctx.logger.warn('triage: inbox enrichment skipped', {
155
- message: summarizeError(error),
156
- });
157
- return result;
158
- }
159
- };
160
- return original.register(descriptor, wrapped, options);
161
- };
162
-
163
- // Clone the context with only `catalog.register` swapped. Every other catalog
164
- // method (invoke/list/get/...) keeps pointing at the original instance.
165
- const proxiedCatalog = new Proxy(original, {
166
- get(target, prop, receiver) {
167
- if (prop === 'register') return decoratedRegister;
168
- return Reflect.get(target, prop, receiver);
169
- },
170
- }) as GatewayMethodCatalog;
171
-
172
- return { ctx: { ...ctx, catalog: proxiedCatalog }, dispose };
173
- }
174
-
175
- /**
176
- * Compose the triage pipeline with the inbox surface so channels.inbox.list
177
- * returns pre-scored items. Returns the teardown plus the poller-facing
178
- * pipeline/tagger handle. The inbox surface's registration is wrapped; inbox
179
- * teardown runs first, then the shared store handle is disposed.
180
- */
181
- export function registerTriagedInbox(
182
- ctx: HandlerContext,
183
- registerInbox: RegisterInbox,
184
- options: RegisterTriagedInboxOptions = {},
185
- ): TriagedInboxRegistration {
186
- const tagger = createTriageTagger(ctx, options.tagger);
187
- const enriched = withInboxEnrichment(ctx);
188
-
189
- let unregisterInbox: Unregister;
190
- try {
191
- unregisterInbox = registerInbox(enriched.ctx);
192
- } catch (error) {
193
- enriched.dispose();
194
- throw error;
195
- }
196
-
197
- const unregister: Unregister = () => {
198
- try {
199
- unregisterInbox();
200
- } finally {
201
- enriched.dispose();
202
- }
203
- };
204
-
205
- return {
206
- unregister,
207
- runInboxTriage: (items, runOptions) =>
208
- runInboxTriage(items, ctx, { ...options.pipeline, ...runOptions }),
209
- tagger,
210
- };
211
- }
212
-
213
- export type { ApplyTagsRequest, ApplyTagsResult };