@pellux/goodvibes-tui 0.18.4 → 0.18.9

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 (571) hide show
  1. package/CHANGELOG.md +190 -0
  2. package/README.md +2 -2
  3. package/bin/goodvibes +1 -1
  4. package/bin/goodvibes-daemon +66 -0
  5. package/docs/foundation-artifacts/operator-contract.json +1 -1
  6. package/package.json +14 -7
  7. package/scripts/postinstall.js +220 -0
  8. package/src/acp/connection.ts +5 -5
  9. package/src/acp/index.ts +1 -1
  10. package/src/acp/manager.ts +1 -133
  11. package/src/adapters/bluebubbles/index.ts +1 -1
  12. package/src/adapters/discord/index.ts +2 -2
  13. package/src/adapters/github/index.ts +1 -1
  14. package/src/adapters/google-chat/index.ts +1 -1
  15. package/src/adapters/imessage/index.ts +1 -1
  16. package/src/adapters/index.ts +15 -15
  17. package/src/adapters/matrix/index.ts +1 -1
  18. package/src/adapters/mattermost/index.ts +1 -1
  19. package/src/adapters/msteams/index.ts +2 -2
  20. package/src/adapters/ntfy/index.ts +1 -1
  21. package/src/adapters/signal/index.ts +1 -1
  22. package/src/adapters/slack/index.ts +2 -2
  23. package/src/adapters/telegram/index.ts +1 -1
  24. package/src/adapters/types.ts +4 -4
  25. package/src/adapters/webhook/index.ts +1 -1
  26. package/src/adapters/whatsapp/index.ts +1 -1
  27. package/src/agents/message-bus-core.ts +2 -2
  28. package/src/agents/message-bus.ts +2 -2
  29. package/src/agents/orchestrator-prompts.ts +4 -4
  30. package/src/agents/orchestrator-runner.ts +11 -11
  31. package/src/agents/orchestrator.ts +15 -14
  32. package/src/agents/session.ts +1 -1
  33. package/src/agents/worktree.ts +1 -1
  34. package/src/agents/wrfc-config.ts +2 -2
  35. package/src/agents/wrfc-controller.ts +12 -12
  36. package/src/agents/wrfc-gate-runtime.ts +5 -5
  37. package/src/agents/wrfc-reporting.ts +1 -1
  38. package/src/agents/wrfc-runtime-events.ts +3 -3
  39. package/src/agents/wrfc-types.ts +1 -1
  40. package/src/automation/delivery-manager.ts +4 -4
  41. package/src/automation/index.ts +4 -4
  42. package/src/automation/manager-runtime-delivery.ts +1 -1
  43. package/src/automation/manager-runtime-events.ts +3 -3
  44. package/src/automation/manager-runtime-execution.ts +5 -5
  45. package/src/automation/manager-runtime-helpers.ts +2 -2
  46. package/src/automation/manager-runtime-job-mutations.ts +3 -3
  47. package/src/automation/manager-runtime-reconcile.ts +4 -4
  48. package/src/automation/manager-runtime-scheduling.ts +2 -2
  49. package/src/automation/manager-runtime.ts +18 -18
  50. package/src/automation/manager.ts +2 -2
  51. package/src/automation/service.ts +2 -2
  52. package/src/channels/builtin/account-actions.ts +5 -5
  53. package/src/channels/builtin/accounts.ts +2 -2
  54. package/src/channels/builtin/contracts.ts +3 -3
  55. package/src/channels/builtin/plugins.ts +5 -5
  56. package/src/channels/builtin/rendering.ts +4 -4
  57. package/src/channels/builtin/setup-schema.ts +1 -1
  58. package/src/channels/builtin/shared.ts +7 -7
  59. package/src/channels/builtin/surfaces.ts +2 -2
  60. package/src/channels/builtin/targets.ts +3 -3
  61. package/src/channels/builtin-runtime.ts +11 -11
  62. package/src/channels/delivery/shared.ts +2 -2
  63. package/src/channels/delivery/strategies-bridge.ts +3 -3
  64. package/src/channels/delivery/strategies-core.ts +5 -5
  65. package/src/channels/delivery/strategies-enterprise.ts +3 -3
  66. package/src/channels/delivery/types.ts +2 -2
  67. package/src/channels/delivery-router.ts +9 -9
  68. package/src/channels/index.ts +12 -12
  69. package/src/channels/plugin-registry.ts +1 -1
  70. package/src/channels/provider-runtime.ts +3 -3
  71. package/src/channels/reply-pipeline.ts +3 -3
  72. package/src/channels/route-manager.ts +2 -2
  73. package/src/channels/surface-registry.ts +2 -2
  74. package/src/config/helper-model.ts +1 -233
  75. package/src/config/index.ts +3 -3
  76. package/src/config/manager.ts +8 -404
  77. package/src/config/secrets.ts +21 -542
  78. package/src/config/service-registry.ts +1 -329
  79. package/src/config/tool-llm.ts +3 -3
  80. package/src/control-plane/approval-broker.ts +1 -1
  81. package/src/control-plane/gateway.ts +1 -713
  82. package/src/control-plane/index.ts +7 -7
  83. package/src/control-plane/media-contract-schemas.ts +1 -208
  84. package/src/control-plane/method-catalog-admin.ts +1 -136
  85. package/src/control-plane/method-catalog-channels.ts +1 -591
  86. package/src/control-plane/method-catalog-control-automation.ts +1 -475
  87. package/src/control-plane/method-catalog-control-core.ts +1 -594
  88. package/src/control-plane/method-catalog-control.ts +1 -8
  89. package/src/control-plane/method-catalog-events.ts +1 -74
  90. package/src/control-plane/method-catalog-knowledge.ts +1 -531
  91. package/src/control-plane/method-catalog-media.ts +1 -279
  92. package/src/control-plane/method-catalog-runtime.ts +1 -304
  93. package/src/control-plane/method-catalog-shared.ts +1 -223
  94. package/src/control-plane/method-catalog.ts +1 -242
  95. package/src/control-plane/operator-contract-schemas-admin.ts +1 -639
  96. package/src/control-plane/operator-contract-schemas-channels.ts +1 -375
  97. package/src/control-plane/operator-contract-schemas-control.ts +1 -226
  98. package/src/control-plane/operator-contract-schemas-domains.ts +1 -4
  99. package/src/control-plane/operator-contract-schemas-knowledge.ts +1 -582
  100. package/src/control-plane/operator-contract-schemas-media.ts +1 -297
  101. package/src/control-plane/operator-contract-schemas-permissions.ts +1 -100
  102. package/src/control-plane/operator-contract-schemas-remote.ts +1 -38
  103. package/src/control-plane/operator-contract-schemas-runtime.ts +1 -563
  104. package/src/control-plane/operator-contract-schemas-shared.ts +1 -85
  105. package/src/control-plane/operator-contract-schemas-telemetry.ts +1 -349
  106. package/src/control-plane/operator-contract-schemas.ts +1 -6
  107. package/src/control-plane/operator-contract.ts +5 -3
  108. package/src/control-plane/session-broker.ts +1 -1
  109. package/src/core/compaction-sections.ts +5 -5
  110. package/src/core/compaction-types.ts +3 -3
  111. package/src/core/composer-state.ts +1 -1
  112. package/src/core/context-compaction.ts +7 -7
  113. package/src/core/conversation-compaction.ts +4 -4
  114. package/src/core/conversation-diff.ts +1 -1
  115. package/src/core/conversation-rendering.ts +5 -5
  116. package/src/core/conversation-utils.ts +2 -2
  117. package/src/core/conversation.ts +10 -10
  118. package/src/core/event-replay.ts +1 -1
  119. package/src/core/orchestrator-context-runtime.ts +8 -8
  120. package/src/core/orchestrator-follow-up-runtime.ts +2 -2
  121. package/src/core/orchestrator-runtime.ts +4 -4
  122. package/src/core/orchestrator-tool-runtime.ts +7 -7
  123. package/src/core/orchestrator-turn-helpers.ts +7 -7
  124. package/src/core/orchestrator-turn-loop.ts +10 -10
  125. package/src/core/orchestrator.ts +17 -17
  126. package/src/core/plan-command-handler.ts +2 -2
  127. package/src/core/system-message-router.ts +2 -2
  128. package/src/core/transcript-events/classify.ts +1 -1
  129. package/src/core/transcript-events/index.ts +3 -3
  130. package/src/daemon/cli.ts +6 -6
  131. package/src/daemon/control-plane.ts +7 -7
  132. package/src/daemon/facade-composition.ts +16 -15
  133. package/src/daemon/facade.ts +17 -17
  134. package/src/daemon/helpers.ts +2 -2
  135. package/src/daemon/http/router-route-contexts.ts +11 -11
  136. package/src/daemon/http/router.ts +25 -25
  137. package/src/daemon/http-listener.ts +3 -3
  138. package/src/daemon/index.ts +1 -3
  139. package/src/daemon/service-manager.ts +1 -1
  140. package/src/daemon/surface-actions.ts +8 -8
  141. package/src/daemon/surface-delivery.ts +7 -7
  142. package/src/daemon/surface-policy.ts +1 -1
  143. package/src/daemon/transport-events.ts +4 -4
  144. package/src/daemon/types.ts +24 -24
  145. package/src/export/markdown.ts +1 -1
  146. package/src/export/session-export.ts +1 -633
  147. package/src/git/index.ts +1 -1
  148. package/src/git/service.ts +1 -1
  149. package/src/hooks/chain-engine.ts +1 -1
  150. package/src/hooks/dispatcher.ts +4 -4
  151. package/src/hooks/hook-api.ts +1 -1
  152. package/src/hooks/index.ts +8 -8
  153. package/src/hooks/runners/agent.ts +1 -1
  154. package/src/hooks/runners/prompt.ts +1 -1
  155. package/src/hooks/workbench.ts +2 -2
  156. package/src/input/command-registry.ts +24 -17
  157. package/src/input/commands/config.ts +1 -1
  158. package/src/input/commands/control-room-runtime.ts +2 -2
  159. package/src/input/commands/conversation-runtime.ts +1 -1
  160. package/src/input/commands/discovery-runtime.ts +7 -1
  161. package/src/input/commands/eval.ts +2 -2
  162. package/src/input/commands/git-runtime.ts +1 -1
  163. package/src/input/commands/guidance-runtime.ts +3 -3
  164. package/src/input/commands/health-runtime.ts +7 -7
  165. package/src/input/commands/incident-runtime.ts +1 -1
  166. package/src/input/commands/integration-runtime.ts +3 -3
  167. package/src/input/commands/local-provider-runtime.ts +1 -1
  168. package/src/input/commands/local-runtime.ts +1 -1
  169. package/src/input/commands/local-setup-review.ts +2 -2
  170. package/src/input/commands/local-setup.ts +2 -2
  171. package/src/input/commands/managed-runtime.ts +2 -2
  172. package/src/input/commands/marketplace-runtime.ts +1 -1
  173. package/src/input/commands/platform-access-runtime.ts +1 -1
  174. package/src/input/commands/platform-sandbox-qemu.ts +3 -3
  175. package/src/input/commands/platform-sandbox-runtime.ts +5 -5
  176. package/src/input/commands/platform-sandbox-session.ts +1 -1
  177. package/src/input/commands/policy-dispatch.ts +2 -2
  178. package/src/input/commands/product-runtime.ts +2 -2
  179. package/src/input/commands/profile-sync-runtime.ts +1 -1
  180. package/src/input/commands/provider-accounts-runtime.ts +1 -1
  181. package/src/input/commands/provider.ts +3 -3
  182. package/src/input/commands/quit-shared.ts +1 -1
  183. package/src/input/commands/recall-bundle.ts +1 -1
  184. package/src/input/commands/recall-capture.ts +2 -2
  185. package/src/input/commands/recall-query.ts +2 -2
  186. package/src/input/commands/recall-shared.ts +1 -1
  187. package/src/input/commands/remote-runtime-setup.ts +1 -1
  188. package/src/input/commands/remote-runtime.ts +1 -1
  189. package/src/input/commands/runtime-services.ts +13 -11
  190. package/src/input/commands/schedule-runtime.ts +2 -2
  191. package/src/input/commands/session-content.ts +1 -1
  192. package/src/input/commands/session-workflow.ts +4 -4
  193. package/src/input/commands/settings-sync-runtime.ts +1 -1
  194. package/src/input/commands/share-runtime.ts +9 -4
  195. package/src/input/commands/shell-core.ts +1 -1
  196. package/src/input/commands/skills-runtime.ts +1 -1
  197. package/src/input/commands/subscription-runtime.ts +1 -1
  198. package/src/input/commands/tasks-runtime.ts +1 -1
  199. package/src/input/commands/teamwork-runtime.ts +1 -1
  200. package/src/input/commands/worktree-runtime.ts +1 -1
  201. package/src/input/handler-command-route.ts +1 -1
  202. package/src/input/handler-content-actions.ts +3 -3
  203. package/src/input/handler-feed-routes.ts +2 -2
  204. package/src/input/handler-feed.ts +1 -1
  205. package/src/input/handler-shortcuts.ts +1 -1
  206. package/src/input/handler.ts +1 -1
  207. package/src/input/keybindings.ts +5 -0
  208. package/src/input/model-picker.ts +2 -2
  209. package/src/input/profile-picker-modal.ts +1 -1
  210. package/src/input/session-picker-modal.ts +1 -1
  211. package/src/input/settings-modal.ts +4 -4
  212. package/src/integrations/index.ts +1 -1
  213. package/src/integrations/notifier.ts +1 -1
  214. package/src/integrations/webhooks.ts +1 -177
  215. package/src/knowledge/consolidation.ts +2 -2
  216. package/src/knowledge/graphql.ts +1 -1
  217. package/src/knowledge/index.ts +5 -5
  218. package/src/knowledge/ingest-compile.ts +3 -3
  219. package/src/knowledge/ingest-context.ts +1 -1
  220. package/src/knowledge/ingest-inputs.ts +4 -4
  221. package/src/knowledge/ingest.ts +1 -20
  222. package/src/knowledge/internal.ts +1 -1
  223. package/src/knowledge/knowledge-api.ts +7 -7
  224. package/src/knowledge/lint.ts +3 -3
  225. package/src/knowledge/memory-sync.ts +2 -2
  226. package/src/knowledge/packet.ts +3 -3
  227. package/src/knowledge/scheduling.ts +2 -2
  228. package/src/knowledge/service.ts +10 -10
  229. package/src/main.ts +11 -10
  230. package/src/mcp/index.ts +4 -4
  231. package/src/mcp/mcp-api.ts +1 -1
  232. package/src/mcp/registry.ts +1 -508
  233. package/src/media/builtin-image-understanding.ts +2 -2
  234. package/src/media/builtin-providers.ts +2 -2
  235. package/src/media/index.ts +1 -1
  236. package/src/multimodal/index.ts +1 -1
  237. package/src/multimodal/service.ts +2 -2
  238. package/src/panels/agent-inspector-panel.ts +2 -2
  239. package/src/panels/agent-logs-panel.ts +3 -3
  240. package/src/panels/approval-panel.ts +2 -2
  241. package/src/panels/builtin/operations.ts +3 -1
  242. package/src/panels/builtin/shared.ts +14 -14
  243. package/src/panels/context-visualizer-panel.ts +2 -2
  244. package/src/panels/cost-tracker-panel.ts +2 -2
  245. package/src/panels/debug-panel.ts +3 -3
  246. package/src/panels/git-panel.ts +1 -1
  247. package/src/panels/hooks-panel.ts +4 -4
  248. package/src/panels/knowledge-panel.ts +1 -1
  249. package/src/panels/marketplace-panel.ts +1 -1
  250. package/src/panels/mcp-panel.ts +1 -1
  251. package/src/panels/memory-panel.ts +2 -2
  252. package/src/panels/ops-control-panel.ts +2 -2
  253. package/src/panels/ops-strategy-panel.ts +2 -2
  254. package/src/panels/plugins-panel.ts +1 -1
  255. package/src/panels/policy-panel.ts +1 -1
  256. package/src/panels/provider-health-panel.ts +3 -3
  257. package/src/panels/provider-stats-panel.ts +2 -2
  258. package/src/panels/sandbox-panel.ts +3 -3
  259. package/src/panels/schedule-panel.ts +1 -1
  260. package/src/panels/settings-sync-panel.ts +1 -1
  261. package/src/panels/skills-panel.ts +28 -1
  262. package/src/panels/system-messages-panel.ts +1 -1
  263. package/src/panels/tasks-panel.ts +1 -1
  264. package/src/panels/thinking-panel.ts +2 -2
  265. package/src/panels/token-budget-panel.ts +1 -1
  266. package/src/panels/tool-inspector-panel.ts +2 -2
  267. package/src/panels/worktree-panel.ts +1 -1
  268. package/src/panels/wrfc-panel.ts +4 -4
  269. package/src/permissions/briefs/build.ts +1 -1
  270. package/src/permissions/manager.ts +1 -356
  271. package/src/permissions/prompt.ts +1 -1
  272. package/src/plugins/api.ts +9 -9
  273. package/src/plugins/loader.ts +8 -8
  274. package/src/plugins/manager.ts +5 -5
  275. package/src/providers/amazon-bedrock-mantle.ts +1 -1
  276. package/src/providers/amazon-bedrock.ts +1 -1
  277. package/src/providers/anthropic-compat.ts +4 -4
  278. package/src/providers/anthropic-sdk-provider.ts +5 -5
  279. package/src/providers/anthropic-vertex.ts +1 -1
  280. package/src/providers/anthropic.ts +4 -4
  281. package/src/providers/auto-register.ts +6 -6
  282. package/src/providers/builtin-catalog.ts +2 -2
  283. package/src/providers/builtin-registry.ts +15 -15
  284. package/src/providers/cache-planner.ts +2 -2
  285. package/src/providers/capabilities.ts +1 -601
  286. package/src/providers/custom-loader.ts +6 -6
  287. package/src/providers/discovered-compat.ts +7 -18
  288. package/src/providers/discovered-factory.ts +7 -7
  289. package/src/providers/discovered-traits.ts +1 -1
  290. package/src/providers/gemini.ts +4 -4
  291. package/src/providers/github-copilot.ts +4 -4
  292. package/src/providers/index.ts +1 -47
  293. package/src/providers/interface.ts +1 -1
  294. package/src/providers/llama-cpp.ts +4 -4
  295. package/src/providers/lm-studio-helpers.ts +1 -1
  296. package/src/providers/lm-studio.ts +4 -4
  297. package/src/providers/model-catalog-cache.ts +1 -1
  298. package/src/providers/model-catalog-notifications.ts +1 -1
  299. package/src/providers/model-catalog-synthetic.ts +2 -2
  300. package/src/providers/model-catalog.ts +7 -7
  301. package/src/providers/model-limits.ts +1 -280
  302. package/src/providers/ollama.ts +4 -4
  303. package/src/providers/openai-codex.ts +2 -2
  304. package/src/providers/openai-compat.ts +4 -4
  305. package/src/providers/openai.ts +3 -3
  306. package/src/providers/optimizer.ts +1 -381
  307. package/src/providers/provider-api.ts +1 -553
  308. package/src/providers/registry-helpers.ts +1 -1
  309. package/src/providers/registry-models.ts +2 -2
  310. package/src/providers/registry-types.ts +5 -5
  311. package/src/providers/registry.ts +1 -729
  312. package/src/providers/runtime-metadata.ts +1 -1
  313. package/src/providers/runtime-snapshot.ts +3 -3
  314. package/src/providers/synthetic.ts +3 -3
  315. package/src/providers/tier-prompts.ts +1 -1
  316. package/src/providers/tool-formats.ts +1 -1
  317. package/src/renderer/agent-detail-modal.ts +2 -2
  318. package/src/renderer/block-actions.ts +1 -1
  319. package/src/renderer/context-inspector.ts +1 -1
  320. package/src/renderer/conversation-layout.ts +1 -1
  321. package/src/renderer/conversation-overlays.ts +1 -1
  322. package/src/renderer/git-status.ts +1 -1
  323. package/src/renderer/live-tail-modal.ts +1 -1
  324. package/src/renderer/process-modal.ts +2 -2
  325. package/src/runtime/bootstrap-background.ts +18 -8
  326. package/src/runtime/bootstrap-command-context.ts +24 -24
  327. package/src/runtime/bootstrap-command-parts.ts +24 -24
  328. package/src/runtime/bootstrap-core.ts +12 -10
  329. package/src/runtime/bootstrap-helpers.ts +2 -2
  330. package/src/runtime/bootstrap-hook-bridge.ts +9 -9
  331. package/src/runtime/bootstrap-runtime-events.ts +4 -4
  332. package/src/runtime/bootstrap-services.ts +4 -4
  333. package/src/runtime/bootstrap-shell.ts +11 -11
  334. package/src/runtime/bootstrap.ts +28 -10
  335. package/src/runtime/compaction/index.ts +1 -90
  336. package/src/runtime/compaction/lifecycle.ts +1 -167
  337. package/src/runtime/compaction/manager.ts +11 -11
  338. package/src/runtime/compaction/quality-score.ts +1 -279
  339. package/src/runtime/compaction/resume-repair.ts +1 -183
  340. package/src/runtime/compaction/strategies/autocompact.ts +1 -65
  341. package/src/runtime/compaction/strategies/boundary-commit.ts +1 -106
  342. package/src/runtime/compaction/strategies/collapse.ts +1 -90
  343. package/src/runtime/compaction/strategies/index.ts +1 -23
  344. package/src/runtime/compaction/strategies/microcompact.ts +1 -74
  345. package/src/runtime/compaction/strategies/reactive.ts +1 -89
  346. package/src/runtime/compaction/types.ts +1 -221
  347. package/src/runtime/context.ts +10 -10
  348. package/src/runtime/diagnostics/actions.ts +1 -1
  349. package/src/runtime/diagnostics/index.ts +5 -5
  350. package/src/runtime/diagnostics/panels/agents.ts +2 -2
  351. package/src/runtime/diagnostics/panels/events.ts +2 -2
  352. package/src/runtime/diagnostics/panels/health.ts +2 -2
  353. package/src/runtime/diagnostics/panels/ops.ts +2 -2
  354. package/src/runtime/diagnostics/panels/policy.ts +2 -2
  355. package/src/runtime/diagnostics/panels/tasks.ts +2 -2
  356. package/src/runtime/diagnostics/panels/tool-calls.ts +2 -2
  357. package/src/runtime/diagnostics/provider.ts +1 -1
  358. package/src/runtime/ecosystem/recommendations.ts +1 -1
  359. package/src/runtime/emitters/agents.ts +2 -2
  360. package/src/runtime/emitters/automation.ts +2 -2
  361. package/src/runtime/emitters/communication.ts +2 -2
  362. package/src/runtime/emitters/compaction.ts +2 -2
  363. package/src/runtime/emitters/control-plane.ts +2 -2
  364. package/src/runtime/emitters/deliveries.ts +2 -2
  365. package/src/runtime/emitters/forensics.ts +2 -2
  366. package/src/runtime/emitters/index.ts +27 -27
  367. package/src/runtime/emitters/knowledge.ts +2 -2
  368. package/src/runtime/emitters/mcp.ts +2 -2
  369. package/src/runtime/emitters/ops.ts +2 -2
  370. package/src/runtime/emitters/orchestration.ts +2 -2
  371. package/src/runtime/emitters/permissions.ts +2 -2
  372. package/src/runtime/emitters/planner.ts +2 -2
  373. package/src/runtime/emitters/plugins.ts +2 -2
  374. package/src/runtime/emitters/providers.ts +2 -2
  375. package/src/runtime/emitters/routes.ts +2 -2
  376. package/src/runtime/emitters/security.ts +2 -2
  377. package/src/runtime/emitters/session.ts +2 -2
  378. package/src/runtime/emitters/surfaces.ts +2 -2
  379. package/src/runtime/emitters/tasks.ts +2 -2
  380. package/src/runtime/emitters/tools.ts +2 -2
  381. package/src/runtime/emitters/transport.ts +2 -2
  382. package/src/runtime/emitters/turn.ts +3 -3
  383. package/src/runtime/emitters/ui.ts +2 -2
  384. package/src/runtime/emitters/watchers.ts +2 -2
  385. package/src/runtime/emitters/workflows.ts +3 -3
  386. package/src/runtime/eval/index.ts +3 -3
  387. package/src/runtime/eval/runner.ts +1 -1
  388. package/src/runtime/eval/suites.ts +1 -1
  389. package/src/runtime/events/domain-map.ts +2 -2
  390. package/src/runtime/events/index.ts +1 -194
  391. package/src/runtime/events/turn.ts +1 -60
  392. package/src/runtime/events/workflows.ts +1 -17
  393. package/src/runtime/forensics/collector.ts +4 -4
  394. package/src/runtime/forensics/index.ts +1 -1
  395. package/src/runtime/foundation-clients.ts +14 -14
  396. package/src/runtime/foundation-services.ts +8 -8
  397. package/src/runtime/guidance.ts +3 -3
  398. package/src/runtime/health/effect-handlers.ts +3 -3
  399. package/src/runtime/health/index.ts +4 -4
  400. package/src/runtime/health/wiring.ts +2 -2
  401. package/src/runtime/index.ts +29 -29
  402. package/src/runtime/integration/helpers.ts +12 -12
  403. package/src/runtime/lifecycle.ts +4 -4
  404. package/src/runtime/mcp/index.ts +3 -3
  405. package/src/runtime/mcp/manager.ts +1 -1
  406. package/src/runtime/network/inbound.ts +2 -2
  407. package/src/runtime/network/index.ts +5 -5
  408. package/src/runtime/network/outbound.ts +2 -2
  409. package/src/runtime/network/shared.ts +1 -1
  410. package/src/runtime/operator-client.ts +9 -9
  411. package/src/runtime/ops/control-plane.ts +2 -2
  412. package/src/runtime/ops/index.ts +3 -3
  413. package/src/runtime/ops/playbooks/index.ts +2 -2
  414. package/src/runtime/ops/playbooks/session-unrecoverable.ts +2 -2
  415. package/src/runtime/ops/playbooks/stuck-turn.ts +1 -1
  416. package/src/runtime/ops/runtime-context.ts +1 -1
  417. package/src/runtime/orchestration/spawn-policy.ts +1 -1
  418. package/src/runtime/peer-client.ts +3 -3
  419. package/src/runtime/perf/index.ts +1 -1
  420. package/src/runtime/perf/slo-collector.ts +1 -1
  421. package/src/runtime/permissions/index.ts +5 -5
  422. package/src/runtime/permissions/policy-runtime.ts +1 -175
  423. package/src/runtime/permissions/rule-suggestions.ts +1 -1
  424. package/src/runtime/plugins/hot-reload.ts +4 -4
  425. package/src/runtime/plugins/index.ts +13 -13
  426. package/src/runtime/plugins/lifecycle.ts +1 -1
  427. package/src/runtime/plugins/manager.ts +10 -10
  428. package/src/runtime/plugins/manifest.ts +2 -2
  429. package/src/runtime/plugins/quarantine.ts +2 -2
  430. package/src/runtime/plugins/trust.ts +2 -2
  431. package/src/runtime/plugins/types.ts +1 -1
  432. package/src/runtime/provider-accounts/registry.ts +2 -2
  433. package/src/runtime/remote/distributed-runtime-contract-schemas.ts +3 -3
  434. package/src/runtime/remote/index.ts +3 -3
  435. package/src/runtime/remote/runner-registry.ts +2 -2
  436. package/src/runtime/remote/supervisor.ts +1 -1
  437. package/src/runtime/runtime-hook-api.ts +1 -1
  438. package/src/runtime/runtime-knowledge-api.ts +1 -1
  439. package/src/runtime/runtime-mcp-api.ts +1 -1
  440. package/src/runtime/runtime-ops-api.ts +2 -2
  441. package/src/runtime/runtime-provider-api.ts +1 -1
  442. package/src/runtime/services.ts +42 -35
  443. package/src/runtime/session-maintenance.ts +1 -1
  444. package/src/runtime/session-persistence.ts +2 -2
  445. package/src/runtime/session-return-context.ts +3 -3
  446. package/src/runtime/settings/control-plane-store.ts +1 -1
  447. package/src/runtime/settings/control-plane.ts +2 -2
  448. package/src/runtime/shell-command-extensions.ts +7 -7
  449. package/src/runtime/shell-command-ops.ts +6 -6
  450. package/src/runtime/shell-command-platform.ts +1 -1
  451. package/src/runtime/shell-command-services.ts +18 -18
  452. package/src/runtime/shell-command-workspace.ts +2 -2
  453. package/src/runtime/store/domains/conversation.ts +1 -1
  454. package/src/runtime/store/domains/index.ts +4 -4
  455. package/src/runtime/store/domains/permissions.ts +1 -1
  456. package/src/runtime/store/helpers/reducers/conversation.ts +3 -3
  457. package/src/runtime/store/helpers/reducers/lifecycle.ts +3 -3
  458. package/src/runtime/store/helpers/reducers/shared.ts +2 -2
  459. package/src/runtime/store/helpers/reducers/sync.ts +1 -1
  460. package/src/runtime/store/helpers/reducers.ts +4 -4
  461. package/src/runtime/store/index.ts +4 -4
  462. package/src/runtime/store/selectors/index.ts +2 -2
  463. package/src/runtime/store/state.ts +4 -4
  464. package/src/runtime/tasks/adapters/acp-adapter.ts +1 -1
  465. package/src/runtime/tasks/adapters/index.ts +6 -6
  466. package/src/runtime/tasks/index.ts +3 -3
  467. package/src/runtime/tasks/manager.ts +3 -3
  468. package/src/runtime/telemetry/api-helpers.ts +2 -2
  469. package/src/runtime/telemetry/api.ts +2 -2
  470. package/src/runtime/telemetry/index.ts +5 -5
  471. package/src/runtime/telemetry/instrumentation/domain-bridge-agent-session.ts +1 -1
  472. package/src/runtime/telemetry/instrumentation/domain-bridge-plugin-mcp.ts +1 -1
  473. package/src/runtime/telemetry/instrumentation/domain-bridge-shared.ts +1 -1
  474. package/src/runtime/telemetry/instrumentation/domain-bridge-transport-task.ts +1 -1
  475. package/src/runtime/telemetry/instrumentation/domain-bridge.ts +5 -5
  476. package/src/runtime/telemetry/instrumentation/index.ts +3 -3
  477. package/src/runtime/tools/context.ts +3 -3
  478. package/src/runtime/tools/index.ts +4 -4
  479. package/src/runtime/tools/phased-executor.ts +3 -3
  480. package/src/runtime/tools/phases/budget.ts +1 -1
  481. package/src/runtime/tools/phases/execute.ts +1 -1
  482. package/src/runtime/tools/phases/index.ts +7 -7
  483. package/src/runtime/tools/phases/map-output.ts +1 -1
  484. package/src/runtime/tools/phases/permission.ts +2 -2
  485. package/src/runtime/tools/phases/posthook.ts +1 -1
  486. package/src/runtime/tools/phases/prehook.ts +1 -1
  487. package/src/runtime/tools/phases/validate.ts +1 -1
  488. package/src/runtime/transports/direct.ts +4 -4
  489. package/src/runtime/transports/http-helpers.ts +3 -3
  490. package/src/runtime/transports/http-types.ts +6 -6
  491. package/src/runtime/transports/http.ts +8 -8
  492. package/src/runtime/transports/realtime.ts +4 -4
  493. package/src/runtime/transports/remote-events.ts +1 -1
  494. package/src/runtime/transports/shared.ts +2 -2
  495. package/src/runtime/transports/ui-runtime-events.ts +2 -2
  496. package/src/runtime/ui/index.ts +7 -7
  497. package/src/runtime/ui/model-picker/data-provider.ts +4 -4
  498. package/src/runtime/ui/model-picker/health-enrichment.ts +3 -3
  499. package/src/runtime/ui/model-picker/index.ts +8 -8
  500. package/src/runtime/ui/provider-health/data-provider.ts +2 -2
  501. package/src/runtime/ui/provider-health/fallback-visualizer.ts +1 -1
  502. package/src/runtime/ui/provider-health/index.ts +5 -5
  503. package/src/runtime/ui-events.ts +1 -1
  504. package/src/runtime/ui-read-models-core.ts +2 -2
  505. package/src/runtime/ui-read-models-observability-maintenance.ts +4 -4
  506. package/src/runtime/ui-read-models-observability-options.ts +1 -1
  507. package/src/runtime/ui-read-models-observability-remote.ts +2 -2
  508. package/src/runtime/ui-read-models-observability-security.ts +3 -3
  509. package/src/runtime/ui-read-models-observability-system.ts +6 -6
  510. package/src/runtime/ui-read-models-observability.ts +10 -10
  511. package/src/runtime/ui-read-models-operations.ts +2 -2
  512. package/src/runtime/ui-read-models.ts +7 -7
  513. package/src/runtime/ui-service-queries.ts +2 -2
  514. package/src/runtime/ui-services.ts +7 -7
  515. package/src/runtime/worktree/registry.ts +1 -1
  516. package/src/scripts/process-messages.ts +1 -1
  517. package/src/sessions/manager.ts +9 -383
  518. package/src/shell/blocking-input.ts +3 -3
  519. package/src/shell/ui-openers.ts +3 -3
  520. package/src/state/file-watcher.ts +1 -1
  521. package/src/state/index.ts +10 -10
  522. package/src/state/knowledge-injection.ts +2 -2
  523. package/src/state/memory-embedding-http.ts +2 -2
  524. package/src/state/memory-embeddings.ts +1 -1
  525. package/src/state/memory-ingest.ts +3 -3
  526. package/src/state/memory-registry.ts +3 -3
  527. package/src/state/memory-store-helpers.ts +1 -1
  528. package/src/state/memory-store.ts +4 -4
  529. package/src/state/memory-vector-store.ts +3 -3
  530. package/src/tools/agent/index.ts +7 -7
  531. package/src/tools/agent/manager.ts +8 -8
  532. package/src/tools/analyze/git-modes.ts +2 -2
  533. package/src/tools/analyze/index.ts +2 -2
  534. package/src/tools/channel/agent-tools.ts +1 -1
  535. package/src/tools/channel/index.ts +2 -2
  536. package/src/tools/control/index.ts +1 -1
  537. package/src/tools/edit/core.ts +3 -3
  538. package/src/tools/edit/index.ts +2 -2
  539. package/src/tools/edit/phased.ts +2 -2
  540. package/src/tools/fetch/index.ts +2 -2
  541. package/src/tools/fetch/phased.ts +1 -1
  542. package/src/tools/index.ts +28 -28
  543. package/src/tools/mcp/index.ts +1 -1
  544. package/src/tools/remote-trigger/index.ts +1 -1
  545. package/src/tools/shared/auto-heal.ts +2 -2
  546. package/src/tools/state/index.ts +1 -1
  547. package/src/tools/web-search/index.ts +1 -1
  548. package/src/tools/write/index.ts +3 -3
  549. package/src/tools/write/phased.ts +1 -1
  550. package/src/version.ts +1 -1
  551. package/src/watchers/index.ts +2 -2
  552. package/src/watchers/registry.ts +2 -2
  553. package/src/web-search/index.ts +10 -10
  554. package/src/web-search/provider-registry.ts +8 -8
  555. package/src/web-search/providers/brave.ts +1 -1
  556. package/src/web-search/providers/duckduckgo.ts +1 -1
  557. package/src/web-search/providers/exa.ts +1 -1
  558. package/src/web-search/providers/firecrawl.ts +1 -1
  559. package/src/web-search/providers/perplexity.ts +1 -1
  560. package/src/web-search/providers/searxng.ts +1 -1
  561. package/src/web-search/providers/shared.ts +1 -1
  562. package/src/web-search/providers/tavily.ts +1 -1
  563. package/src/web-search/service.ts +2 -2
  564. package/docs/README.md +0 -32
  565. package/scripts/postinstall.mjs +0 -203
  566. package/src/runtime/ecosystem/catalog.ts +0 -606
  567. package/src/runtime/sandbox/backend.ts +0 -291
  568. package/src/runtime/sandbox/manager.ts +0 -364
  569. package/src/runtime/sandbox/provisioning.ts +0 -422
  570. package/src/runtime/sandbox/session-registry.ts +0 -289
  571. package/src/tools/repl/index.ts +0 -318
@@ -1,90 +1 @@
1
- /**
2
- * src/runtime/compaction/index.ts
3
- *
4
- * Barrel re-export for the session compaction lifecycle engine.
5
- *
6
- * Main entry point: `createCompactionManager()`
7
- *
8
- * Usage:
9
- * ```ts
10
- * import { createCompactionManager } from '../runtime/compaction/index.ts';
11
- *
12
- * const manager = createCompactionManager({ sessionId, bus, flags, contextWindow });
13
- * const result = await manager.compact({ messages, tokenCount, trigger: 'auto' });
14
- * ```
15
- */
16
-
17
- import { CompactionManager } from './manager.ts';
18
- import type { CompactionManagerOptions } from './manager.ts';
19
-
20
- export { CompactionManager };
21
- export type { CompactionManagerOptions };
22
-
23
- export type {
24
- CompactionLifecycleState,
25
- CompactionStrategy,
26
- CompactionTrigger,
27
- StrategyInput,
28
- StrategyOutput,
29
- BoundaryCommit,
30
- CompactionLifecycleResult,
31
- RepairAction,
32
- RepairSeverity,
33
- ResumeRepairResult,
34
- } from './types.ts';
35
-
36
- export type { BoundaryCommitOptions } from './strategies/boundary-commit.ts';
37
-
38
- export {
39
- canTransition,
40
- reachableFrom,
41
- applyTransition,
42
- isTerminal,
43
- isCompacting,
44
- selectStrategy,
45
- strategyToState,
46
- } from './lifecycle.ts';
47
-
48
- export type { TransitionResult, StrategySelectionParams } from './lifecycle.ts';
49
-
50
- export { runResumeRepair } from './resume-repair.ts';
51
- export type { ResumeRepairOptions } from './resume-repair.ts';
52
-
53
- export {
54
- runMicrocompact,
55
- runCollapse,
56
- runAutocompact,
57
- runReactive,
58
- createBoundaryCommit,
59
- validateBoundaryCommit,
60
- computeQualityScore,
61
- describeScore,
62
- escalateStrategy,
63
- LOW_QUALITY_THRESHOLD,
64
- } from './strategies/index.ts';
65
-
66
- export type {
67
- CompactionQualityScore,
68
- CompactionQualityGrade,
69
- SemanticRetentionSignals,
70
- } from './strategies/index.ts';
71
-
72
- /**
73
- * Factory function for creating a CompactionManager instance.
74
- *
75
- * Convenience wrapper over `new CompactionManager(opts)` for symmetry
76
- * with other runtime subsystem factories.
77
- *
78
- * NOTE: This factory is not yet wired to a consumer in the bootstrap layer.
79
- * Integration with the session bootstrap pipeline is the next step — the
80
- * CompactionManager will be instantiated per-session during session init
81
- * and attached to the session context for lifecycle event routing.
82
- *
83
- * @param opts - Manager options (see CompactionManagerOptions).
84
- * @returns A new CompactionManager instance.
85
- */
86
- export function createCompactionManager(
87
- opts: CompactionManagerOptions,
88
- ): CompactionManager {
89
- return new CompactionManager(opts);
90
- }
1
+ export * from '@pellux/goodvibes-sdk/platform/runtime/compaction/index';
@@ -1,167 +1 @@
1
- /**
2
- * lifecycle.ts
3
- *
4
- * Compaction lifecycle state machine for the compaction engine.
5
- *
6
- * Provides:
7
- * - Valid transition map for the 9-state machine
8
- * - Pure transition helpers (no side-effects)
9
- * - Strategy selection logic based on trigger and token pressure
10
- */
11
-
12
- import type { CompactionLifecycleState, CompactionStrategy, CompactionTrigger } from './types.ts';
13
-
14
- // ---------------------------------------------------------------------------
15
- // Transition map
16
- // ---------------------------------------------------------------------------
17
-
18
- /**
19
- * Valid state transitions for the compaction lifecycle machine.
20
- *
21
- * Key = current state
22
- * Value = set of states reachable from current
23
- */
24
- const VALID_TRANSITIONS: ReadonlyMap<
25
- CompactionLifecycleState,
26
- ReadonlySet<CompactionLifecycleState>
27
- > = new Map([
28
- ['idle', new Set<CompactionLifecycleState>(['checking_threshold'])],
29
- ['checking_threshold', new Set<CompactionLifecycleState>(['microcompact', 'collapse', 'autocompact', 'reactive_compact', 'done', 'failed'])],
30
- ['microcompact', new Set<CompactionLifecycleState>(['boundary_commit', 'failed'])],
31
- ['collapse', new Set<CompactionLifecycleState>(['boundary_commit', 'failed'])],
32
- ['autocompact', new Set<CompactionLifecycleState>(['boundary_commit', 'failed'])],
33
- ['reactive_compact', new Set<CompactionLifecycleState>(['boundary_commit', 'failed'])],
34
- ['boundary_commit', new Set<CompactionLifecycleState>(['done', 'failed'])],
35
- ['done', new Set<CompactionLifecycleState>(['idle'])],
36
- ['failed', new Set<CompactionLifecycleState>(['idle'])],
37
- ]);
38
-
39
- // ---------------------------------------------------------------------------
40
- // Transition helpers
41
- // ---------------------------------------------------------------------------
42
-
43
- /**
44
- * Returns whether a transition from `from` to `to` is valid.
45
- */
46
- export function canTransition(
47
- from: CompactionLifecycleState,
48
- to: CompactionLifecycleState,
49
- ): boolean {
50
- return VALID_TRANSITIONS.get(from)?.has(to) ?? false;
51
- }
52
-
53
- /**
54
- * Returns all states reachable from `from`.
55
- */
56
- export function reachableFrom(
57
- from: CompactionLifecycleState,
58
- ): ReadonlySet<CompactionLifecycleState> {
59
- return VALID_TRANSITIONS.get(from) ?? new Set();
60
- }
61
-
62
- /** Discriminated result of `applyTransition`. */
63
- export type TransitionResult =
64
- | { ok: true; state: CompactionLifecycleState }
65
- | { ok: false; reason: string };
66
-
67
- /**
68
- * Validates and applies a state transition.
69
- *
70
- * @returns `{ ok: true, state }` on success, `{ ok: false, reason }` on rejection.
71
- */
72
- export function applyTransition(
73
- current: CompactionLifecycleState,
74
- target: CompactionLifecycleState,
75
- ): TransitionResult {
76
- if (canTransition(current, target)) {
77
- return { ok: true, state: target };
78
- }
79
- return {
80
- ok: false,
81
- reason: `Invalid compaction transition: ${current} → ${target}`,
82
- };
83
- }
84
-
85
- // ---------------------------------------------------------------------------
86
- // Terminal / operational helpers
87
- // ---------------------------------------------------------------------------
88
-
89
- /** Returns true if the state is a terminal completion state (done | failed). */
90
- export function isTerminal(state: CompactionLifecycleState): boolean {
91
- return state === 'done' || state === 'failed';
92
- }
93
-
94
- /** Returns true if the state represents active compaction work in progress. */
95
- export function isCompacting(state: CompactionLifecycleState): boolean {
96
- return (
97
- state === 'microcompact' ||
98
- state === 'collapse' ||
99
- state === 'autocompact' ||
100
- state === 'reactive_compact' ||
101
- state === 'boundary_commit'
102
- );
103
- }
104
-
105
- // ---------------------------------------------------------------------------
106
- // Strategy selection
107
- // ---------------------------------------------------------------------------
108
-
109
- /** Parameters for selecting a compaction strategy. */
110
- export interface StrategySelectionParams {
111
- /** What triggered compaction. */
112
- trigger: CompactionTrigger;
113
- /** Estimated tokens currently in context. */
114
- currentTokens: number;
115
- /** Model context window size. */
116
- contextWindow: number;
117
- /** Whether a prompt-too-long error was the immediate cause. */
118
- isPromptTooLong?: boolean;
119
- }
120
-
121
- /**
122
- * Selects the appropriate compaction strategy based on trigger and token pressure.
123
- *
124
- * Selection priority:
125
- * 1. `reactive` — any prompt-too-long error (emergency, must shrink now)
126
- * 2. `microcompact` — token pressure < 50% of context window (light touch)
127
- * 3. `autocompact` — token pressure 50–85% (standard auto-compaction)
128
- * 4. `collapse` — token pressure > 85% or manual trigger (aggressive shrink)
129
- */
130
- export function selectStrategy(
131
- params: StrategySelectionParams,
132
- ): CompactionStrategy {
133
- const { trigger, currentTokens, contextWindow, isPromptTooLong } = params;
134
-
135
- if (isPromptTooLong === true || trigger === 'prompt_too_long') {
136
- return 'reactive';
137
- }
138
-
139
- const pressure = currentTokens / contextWindow;
140
-
141
- if (pressure < 0.5) {
142
- return 'microcompact';
143
- }
144
- if (pressure < 0.85) {
145
- return 'autocompact';
146
- }
147
- // High pressure or manual trigger — aggressive collapse
148
- return 'collapse';
149
- }
150
-
151
- /**
152
- * Maps a chosen CompactionStrategy to its corresponding lifecycle state.
153
- */
154
- export function strategyToState(
155
- strategy: CompactionStrategy,
156
- ): CompactionLifecycleState {
157
- switch (strategy) {
158
- case 'microcompact': return 'microcompact';
159
- case 'collapse': return 'collapse';
160
- case 'autocompact': return 'autocompact';
161
- case 'reactive': return 'reactive_compact';
162
- default: {
163
- const _exhaustive: never = strategy;
164
- throw new Error(`Unknown compaction strategy: ${_exhaustive}`);
165
- }
166
- }
167
- }
1
+ export * from '@pellux/goodvibes-sdk/platform/runtime/compaction/lifecycle';
@@ -13,14 +13,14 @@
13
13
  */
14
14
 
15
15
  import { logger } from '@pellux/goodvibes-sdk/platform/utils/logger';
16
- import type { RuntimeEventBus } from '../events/index.ts';
16
+ import type { RuntimeEventBus } from '@pellux/goodvibes-sdk/platform/runtime/events/index';
17
17
  import type { FeatureFlagManager } from '@pellux/goodvibes-sdk/platform/runtime/feature-flags/manager';
18
- import type { EmitterContext } from '../emitters/index.ts';
18
+ import type { EmitterContext } from '@pellux/goodvibes-sdk/platform/runtime/emitters/index';
19
19
  import {
20
20
  applyTransition,
21
21
  selectStrategy,
22
22
  strategyToState,
23
- } from './lifecycle.ts';
23
+ } from '@pellux/goodvibes-sdk/platform/runtime/compaction/lifecycle';
24
24
  import {
25
25
  runMicrocompact,
26
26
  runCollapse,
@@ -28,8 +28,8 @@ import {
28
28
  runReactive,
29
29
  createBoundaryCommit,
30
30
  validateBoundaryCommit,
31
- } from './strategies/index.ts';
32
- import { runResumeRepair } from './resume-repair.ts';
31
+ } from '@pellux/goodvibes-sdk/platform/runtime/compaction/strategies/index';
32
+ import { runResumeRepair } from '@pellux/goodvibes-sdk/platform/runtime/compaction/resume-repair';
33
33
  import type {
34
34
  BoundaryCommit,
35
35
  CompactionLifecycleResult,
@@ -38,8 +38,8 @@ import type {
38
38
  CompactionTrigger,
39
39
  StrategyInput,
40
40
  StrategyOutput,
41
- } from './types.ts';
42
- import type { ResumeRepairResult } from './types.ts';
41
+ } from '@pellux/goodvibes-sdk/platform/runtime/compaction/types';
42
+ import type { ResumeRepairResult } from '@pellux/goodvibes-sdk/platform/runtime/compaction/types';
43
43
  import {
44
44
  emitCompactionCheck,
45
45
  emitCompactionDone,
@@ -51,10 +51,10 @@ import {
51
51
  emitCompactionReactive,
52
52
  emitCompactionQualityScore,
53
53
  emitCompactionStrategySwitch,
54
- } from '../emitters/compaction.ts';
55
- import { computeQualityScore, escalateStrategy, LOW_QUALITY_THRESHOLD } from './quality-score.ts';
56
- import type { CompactionQualityScore } from './quality-score.ts';
57
- import type { ProviderMessage } from '../../providers/interface.ts';
54
+ } from '@pellux/goodvibes-sdk/platform/runtime/emitters/compaction';
55
+ import { computeQualityScore, escalateStrategy, LOW_QUALITY_THRESHOLD } from '@pellux/goodvibes-sdk/platform/runtime/compaction/quality-score';
56
+ import type { CompactionQualityScore } from '@pellux/goodvibes-sdk/platform/runtime/compaction/quality-score';
57
+ import type { ProviderMessage } from '@pellux/goodvibes-sdk/platform/providers/interface';
58
58
  import { summarizeError } from '@pellux/goodvibes-sdk/platform/utils/error-display';
59
59
 
60
60
  // ---------------------------------------------------------------------------
@@ -1,279 +1 @@
1
- /**
2
- * quality-score.ts
3
- *
4
- * Compaction quality scoring — evaluates the output of a compaction strategy
5
- * by combining compression ratio and semantic retention signals.
6
- *
7
- * Score range: 0.0 (worst) → 1.0 (best)
8
- * Auto-switch threshold: scores below LOW_QUALITY_THRESHOLD trigger a strategy
9
- * escalation to the next more-aggressive strategy.
10
- */
11
-
12
- import type { StrategyInput, StrategyOutput, CompactionStrategy } from './types.ts';
13
-
14
- // ---------------------------------------------------------------------------
15
- // Constants
16
- // ---------------------------------------------------------------------------
17
-
18
- /**
19
- * Compaction runs scoring below this value are considered low-quality and
20
- * trigger an automatic strategy switch.
21
- */
22
- export const LOW_QUALITY_THRESHOLD = 0.4;
23
-
24
- /**
25
- * Keywords that indicate a message is a compaction handoff/summary note.
26
- */
27
- const HANDOFF_MARKERS = ['[Session', 'compaction', 'collapsed', 'summarized', 'condensed', 'context window'] as const;
28
-
29
- /**
30
- * Weight given to compression ratio in the composite score (0–1).
31
- * The remainder is allocated to semantic retention.
32
- */
33
- const COMPRESSION_WEIGHT = 0.55;
34
-
35
- /**
36
- * Weight given to semantic retention signals in the composite score (0–1).
37
- */
38
- const RETENTION_WEIGHT = 0.45;
39
-
40
- /**
41
- * Minimum meaningful compression ratio. A run with zero or negative compression
42
- * scores 0 on the compression axis.
43
- */
44
- const MIN_COMPRESSION_RATIO = 0;
45
-
46
- /**
47
- * Compression ratio above which the compression dimension is fully saturated.
48
- * Anything at or above this (e.g. 80% reduction) receives a perfect compression score.
49
- */
50
- const MAX_COMPRESSION_RATIO = 0.8;
51
-
52
- // ---------------------------------------------------------------------------
53
- // Types
54
- // ---------------------------------------------------------------------------
55
-
56
- /** Letter grade derived from the composite quality score. */
57
- export type CompactionQualityGrade = 'A' | 'B' | 'C' | 'D' | 'F';
58
-
59
- /** Semantic retention signals evaluated during scoring. */
60
- export interface SemanticRetentionSignals {
61
- /** At least one handoff/summary message is present in the output. */
62
- hasHandoff: boolean;
63
- /** Output contains non-trivial content (not just a blank handoff note). */
64
- hasNonTrivialContent: boolean;
65
- /** The output message count is a reasonable fraction of the input. */
66
- messageCountSane: boolean;
67
- /** The output token count is positive. */
68
- positiveTokenCount: boolean;
69
- }
70
-
71
- /** Full quality score breakdown for a compaction run. */
72
- export interface CompactionQualityScore {
73
- /** Fraction of tokens removed: (tokensBefore - tokensAfter) / tokensBefore. */
74
- compressionRatio: number;
75
- /** Normalised compression dimension score (0–1). */
76
- compressionScore: number;
77
- /** Semantic retention dimension score (0–1). */
78
- retentionScore: number;
79
- /** Composite quality score: weighted sum of compression + retention (0–1). */
80
- score: number;
81
- /** Letter grade derived from score. */
82
- grade: CompactionQualityGrade;
83
- /** Individual semantic retention signals. */
84
- signals: SemanticRetentionSignals;
85
- /** True when score < LOW_QUALITY_THRESHOLD and strategy escalation should occur. */
86
- isLowQuality: boolean;
87
- /** Human-readable description of the score for diagnostics. */
88
- description: string;
89
- }
90
-
91
- // ---------------------------------------------------------------------------
92
- // Scoring
93
- // ---------------------------------------------------------------------------
94
-
95
- /**
96
- * Extracts plain text content from a provider message.
97
- */
98
- function extractTextContent(msg: StrategyOutput['messages'][number]): string {
99
- if (typeof msg.content === 'string') return msg.content;
100
- if (Array.isArray(msg.content)) {
101
- return msg.content
102
- .filter((b): b is { type: 'text'; text: string } => b.type === 'text')
103
- .map((b) => b.text)
104
- .join(' ');
105
- }
106
- return '';
107
- }
108
-
109
- /**
110
- * Evaluates the semantic retention signals from a strategy output.
111
- *
112
- * These are lightweight structural checks — no LLM call required.
113
- */
114
- function evaluateSemanticRetention(
115
- input: StrategyInput,
116
- output: StrategyOutput,
117
- ): SemanticRetentionSignals {
118
- const hasHandoff = output.messages.some((m) => {
119
- const content = extractTextContent(m);
120
- return HANDOFF_MARKERS.some((marker) => content.includes(marker));
121
- });
122
-
123
- const hasNonTrivialContent = output.messages.some((m) => {
124
- const text = extractTextContent(m);
125
- // Non-trivial means more than just whitespace, and longer than a minimal fragment
126
- return text.trim().length > 20;
127
- });
128
-
129
- // Sane if output has at least 1 message and doesn't exceed input count
130
- const messageCountSane =
131
- output.messages.length >= 1 &&
132
- output.messages.length <= input.messages.length;
133
-
134
- const positiveTokenCount = output.tokensAfter > 0;
135
-
136
- return {
137
- hasHandoff,
138
- hasNonTrivialContent,
139
- messageCountSane,
140
- positiveTokenCount,
141
- };
142
- }
143
-
144
- /**
145
- * Scores the semantic retention dimension as a 0–1 value.
146
- *
147
- * Each signal contributes equally. Missing signals reduce the score.
148
- */
149
- function scoreRetention(signals: SemanticRetentionSignals): number {
150
- const checks = [
151
- signals.hasHandoff,
152
- signals.hasNonTrivialContent,
153
- signals.messageCountSane,
154
- signals.positiveTokenCount,
155
- ];
156
- return checks.filter(Boolean).length / checks.length;
157
- }
158
-
159
- /**
160
- * Normalises a raw compression ratio to a 0–1 score.
161
- *
162
- * A ratio of 0 (no reduction) → score 0.
163
- * A ratio at MAX_COMPRESSION_RATIO (e.g. 80%) → score 1.
164
- * Values above MAX_COMPRESSION_RATIO are clamped at 1.
165
- * Negative ratios (output larger than input) are clamped at 0.
166
- */
167
- function scoreCompression(ratio: number): number {
168
- if (ratio <= MIN_COMPRESSION_RATIO) return 0;
169
- const normalised = (ratio - MIN_COMPRESSION_RATIO) / (MAX_COMPRESSION_RATIO - MIN_COMPRESSION_RATIO);
170
- return Math.min(1, Math.max(0, normalised));
171
- }
172
-
173
- /**
174
- * Maps a composite score to a letter grade.
175
- */
176
- function gradeScore(score: number): CompactionQualityGrade {
177
- if (score >= 0.85) return 'A';
178
- if (score >= 0.70) return 'B';
179
- if (score >= 0.55) return 'C';
180
- if (score >= LOW_QUALITY_THRESHOLD) return 'D';
181
- return 'F';
182
- }
183
-
184
- /**
185
- * Produces a human-readable diagnostic description for a quality score.
186
- */
187
- export function describeScore(score: CompactionQualityScore): string {
188
- const parts: string[] = [
189
- `score=${score.score.toFixed(2)} (${score.grade})`,
190
- `compression=${(score.compressionRatio * 100).toFixed(1)}%`,
191
- `retention=${(score.retentionScore * 100).toFixed(0)}%`,
192
- ];
193
- if (score.isLowQuality) {
194
- parts.push('LOW_QUALITY — strategy switch triggered');
195
- }
196
- return parts.join(', ');
197
- }
198
-
199
- /**
200
- * Computes the quality score for a completed compaction strategy run.
201
- *
202
- * @param input - The strategy input (pre-compaction state).
203
- * @param output - The strategy output (post-compaction state).
204
- * @returns A full CompactionQualityScore breakdown.
205
- */
206
- function scoreCompactionOutput(
207
- input: StrategyInput,
208
- output: StrategyOutput,
209
- ): CompactionQualityScore {
210
- // Compression ratio: fraction of tokens removed
211
- const compressionRatio =
212
- input.tokensBefore > 0
213
- ? Math.max(0, (input.tokensBefore - output.tokensAfter) / input.tokensBefore)
214
- : 0;
215
-
216
- const compressionScore = scoreCompression(compressionRatio);
217
-
218
- const signals = evaluateSemanticRetention(input, output);
219
- const retentionScore = scoreRetention(signals);
220
-
221
- const score =
222
- COMPRESSION_WEIGHT * compressionScore + RETENTION_WEIGHT * retentionScore;
223
-
224
- const grade = gradeScore(score);
225
- const isLowQuality = score < LOW_QUALITY_THRESHOLD;
226
-
227
- return {
228
- compressionRatio,
229
- compressionScore,
230
- retentionScore,
231
- score,
232
- grade,
233
- signals,
234
- isLowQuality,
235
- description: '', // filled below to avoid circular call
236
- };
237
- }
238
-
239
- /**
240
- * Computes the quality score with description filled in.
241
- *
242
- * Prefer this over `scoreCompactionOutput` for all public use.
243
- */
244
- export function computeQualityScore(
245
- input: StrategyInput,
246
- output: StrategyOutput,
247
- ): CompactionQualityScore {
248
- const partial = scoreCompactionOutput(input, output);
249
- const full: CompactionQualityScore = { ...partial, description: '' };
250
- full.description = describeScore(full);
251
- return full;
252
- }
253
-
254
- // ---------------------------------------------------------------------------
255
- // Strategy escalation
256
- // ---------------------------------------------------------------------------
257
-
258
- /**
259
- * Returns the next more-aggressive strategy for escalation when quality is low.
260
- *
261
- * Escalation path:
262
- * microcompact → autocompact → collapse → collapse (ceiling)
263
- * reactive → reactive (already maximum)
264
- *
265
- * @param current - The strategy that produced the low-quality result.
266
- * @returns The escalated strategy to re-run with.
267
- */
268
- export function escalateStrategy(current: CompactionStrategy): CompactionStrategy {
269
- switch (current) {
270
- case 'microcompact': return 'autocompact';
271
- case 'autocompact': return 'collapse';
272
- case 'collapse': return 'collapse'; // already most aggressive
273
- case 'reactive': return 'reactive'; // emergency — cannot escalate further
274
- default: {
275
- const _exhaustive: never = current;
276
- throw new Error(`Unknown compaction strategy: ${_exhaustive}`);
277
- }
278
- }
279
- }
1
+ export * from '@pellux/goodvibes-sdk/platform/runtime/compaction/quality-score';