@kabmo-labs/kabmo 0.22.0 → 0.24.0

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 (446) hide show
  1. package/README.md +1 -1
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +873 -524
  4. package/dist/client/static/js/{index-297dck9a.js → index-jcr5twtp.js} +799 -795
  5. package/dist/client/static/js/index-z3w7n85q.css +1 -0
  6. package/marketplace/plugins/stats/package.json +2 -2
  7. package/marketplace/plugins/stats/src/groups.test.ts +14 -0
  8. package/marketplace/plugins/stats/src/groups.ts +20 -0
  9. package/marketplace/plugins/stats/src/labels.test.ts +9 -0
  10. package/marketplace/plugins/stats/src/labels.ts +7 -0
  11. package/marketplace/plugins/stats/src/server.ts +1 -1
  12. package/package.json +1 -1
  13. package/src/client/App.tsx +20 -19
  14. package/src/client/components/common/ComposerTextarea.tsx +10 -1
  15. package/src/client/components/common/Modal.tsx +2 -6
  16. package/src/client/components/common/PWAInstallButton.tsx +3 -2
  17. package/src/client/components/common/Toast.test.tsx +298 -0
  18. package/src/client/components/common/Toast.tsx +103 -37
  19. package/src/client/components/common/ToastStack.tsx +33 -12
  20. package/src/client/components/common/ViewportSelector.tsx +122 -114
  21. package/src/client/components/common/context-usage-button/Ring.tsx +38 -1
  22. package/src/client/components/common/context-usage-button/index.test.tsx +19 -3
  23. package/src/client/components/common/context-usage-button/index.tsx +5 -2
  24. package/src/client/components/common/harness-glyph/brands.ts +65 -0
  25. package/src/client/components/common/harness-glyph/harness-glyph.test.ts +185 -0
  26. package/src/client/components/common/harness-glyph/index.tsx +131 -0
  27. package/src/client/components/common/header-controls/MoreMenu.tsx +2 -1
  28. package/src/client/components/common/header-controls/index.tsx +16 -8
  29. package/src/client/components/common/header-panel-buttons/index.tsx +4 -3
  30. package/src/client/components/common/panel-mark/index.test.tsx +2 -2
  31. package/src/client/components/common/panel-mark/index.tsx +11 -2
  32. package/src/client/components/common/search-select/index.tsx +305 -0
  33. package/src/client/components/common/search-select/search-select.test.tsx +217 -0
  34. package/src/client/components/common/server-control/index.tsx +3 -2
  35. package/src/client/components/common/session-row/index.tsx +18 -1
  36. package/src/client/components/common/toolbar-row/index.tsx +57 -20
  37. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -3
  38. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +3 -2
  39. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
  40. package/src/client/components/layout/desktop-layout/index.tsx +1 -3
  41. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -0
  42. package/src/client/components/layout/session-sidebar/SessionItem.tsx +18 -1
  43. package/src/client/components/layout/session-sidebar/SessionsView.tsx +1 -3
  44. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +332 -0
  45. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +310 -0
  46. package/src/client/components/layout/session-sidebar/about-modal/SocialLinks.tsx +63 -51
  47. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +4 -2
  48. package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
  49. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +136 -35
  50. package/src/client/components/layout/session-sidebar/harness-mark.test.tsx +126 -0
  51. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +4 -3
  52. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -0
  53. package/src/client/components/mobile/LayoutWrapper.tsx +1 -7
  54. package/src/client/components/mobile/SessionSidebar.tsx +1 -3
  55. package/src/client/components/mobile/mobile-main-view/Header.tsx +3 -2
  56. package/src/client/components/mobile/mobile-session-sidebar/Dialogs.tsx +0 -8
  57. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -0
  58. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +17 -1
  59. package/src/client/components/settings/Modal.tsx +26 -22
  60. package/src/client/components/settings/Sidebar.tsx +45 -5
  61. package/src/client/components/settings/categories/HarnessSettings.tsx +207 -0
  62. package/src/client/components/settings/categories/ProjectSettings.tsx +1 -3
  63. package/src/client/components/settings/categories/ProviderSettings.tsx +0 -4
  64. package/src/client/components/settings/categories/SkillCatalogSettings.tsx +13 -23
  65. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +23 -30
  66. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +20 -11
  67. package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +16 -16
  68. package/src/client/components/settings/categories/harness-settings/AddProviderForm.tsx +219 -0
  69. package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +268 -0
  70. package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +146 -0
  71. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +278 -0
  72. package/src/client/components/settings/categories/harness-settings/ImportSection.tsx +195 -0
  73. package/src/client/components/settings/categories/harness-settings/ProviderPanel.tsx +152 -0
  74. package/src/client/components/settings/categories/harness-settings/ToggleList.tsx +147 -0
  75. package/src/client/components/settings/categories/harness-settings/parts.test.tsx +97 -0
  76. package/src/client/components/settings/categories/harness-settings/parts.tsx +84 -0
  77. package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +313 -0
  78. package/src/client/components/settings/categories/omp-settings/RoleEditor.test.ts +60 -39
  79. package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +32 -41
  80. package/src/client/components/settings/categories/omp-settings/role-picker.test-util.ts +45 -0
  81. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +1 -1
  82. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +11 -4
  83. package/src/client/components/settings/groups.test.tsx +160 -0
  84. package/src/client/components/settings/harness-icons.test.tsx +134 -0
  85. package/src/client/components/workspace/browser-panel/AddressBar.tsx +3 -13
  86. package/src/client/components/workspace/browser-toolbar/clusters.tsx +237 -0
  87. package/src/client/components/workspace/browser-toolbar/index.test.tsx +167 -0
  88. package/src/client/components/workspace/browser-toolbar/index.tsx +99 -100
  89. package/src/client/components/workspace/btw-panel/Messages.tsx +4 -1
  90. package/src/client/components/workspace/btw-panel/index.tsx +2 -0
  91. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +11 -7
  92. package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
  93. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +13 -0
  94. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +13 -0
  95. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.test.ts +41 -0
  96. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +19 -14
  97. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
  98. package/src/client/components/workspace/chat-timeline/MessageList.tsx +6 -0
  99. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +14 -0
  100. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +4 -0
  101. package/src/client/components/workspace/chat-timeline/RunMark.tsx +58 -0
  102. package/src/client/components/workspace/chat-timeline/SubagentView.tsx +4 -1
  103. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +4 -0
  104. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -0
  105. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +11 -0
  106. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +13 -0
  107. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +8 -1
  108. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +27 -1
  109. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +48 -23
  110. package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +1 -0
  111. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +21 -1
  112. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +7 -0
  113. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +13 -0
  114. package/src/client/components/workspace/chat-timeline/chat-input/selection.ts +11 -2
  115. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +1 -0
  116. package/src/client/components/workspace/chat-timeline/index.tsx +17 -15
  117. package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +157 -0
  118. package/src/client/components/workspace/chat-timeline/run-mark.test.ts +104 -0
  119. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
  120. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
  121. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
  122. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
  123. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +31 -3
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +5 -1
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +56 -45
  127. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +38 -94
  128. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-parts.tsx +76 -0
  129. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +2 -1
  130. package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
  131. package/src/client/components/workspace/file-explorer/index.tsx +10 -6
  132. package/src/client/components/workspace/git-panel/index.test.ts +13 -3
  133. package/src/client/components/workspace/git-panel/index.tsx +1 -3
  134. package/src/client/components/workspace/model-dropdown/Fullscreen.tsx +92 -0
  135. package/src/client/components/workspace/model-dropdown/HarnessTabs.tsx +290 -0
  136. package/src/client/components/workspace/model-dropdown/Item.tsx +11 -0
  137. package/src/client/components/workspace/model-dropdown/Panel.tsx +119 -8
  138. package/src/client/components/workspace/model-dropdown/Section.tsx +4 -0
  139. package/src/client/components/workspace/model-dropdown/fullscreen-picker.ts +51 -0
  140. package/src/client/components/workspace/model-dropdown/harness-models.test.ts +177 -0
  141. package/src/client/components/workspace/model-dropdown/harness-models.ts +148 -0
  142. package/src/client/components/workspace/model-dropdown/harness-tabs.test.tsx +336 -0
  143. package/src/client/components/workspace/model-dropdown/index.tsx +114 -85
  144. package/src/client/components/workspace/model-dropdown/placement.test.tsx +127 -0
  145. package/src/client/components/workspace/model-dropdown/popover-metrics.test.ts +107 -0
  146. package/src/client/components/workspace/model-dropdown/popover-metrics.ts +118 -0
  147. package/src/client/components/workspace/model-dropdown/row-mutations.ts +106 -0
  148. package/src/client/components/workspace/model-dropdown/trigger.test.ts +22 -2
  149. package/src/client/components/workspace/model-dropdown/use-popover-size.ts +89 -0
  150. package/src/client/data/settings/omp-schema.json +224 -17
  151. package/src/client/hooks/chat/composer/index.ts +11 -2
  152. package/src/client/hooks/chat/composer/items.test.ts +11 -0
  153. package/src/client/hooks/chat/composer/items.ts +4 -2
  154. package/src/client/hooks/chat/composer/model-selection.test.ts +110 -0
  155. package/src/client/hooks/chat/composer/model-selection.ts +45 -4
  156. package/src/client/hooks/chat/omp/prompt-send.ts +4 -2
  157. package/src/client/hooks/chat/timeline/actions.ts +10 -5
  158. package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
  159. package/src/client/hooks/chat/timeline/composer-local-actions.test.ts +19 -81
  160. package/src/client/hooks/chat/timeline/composer-modes.ts +11 -2
  161. package/src/client/hooks/chat/timeline/composer-refs.ts +16 -1
  162. package/src/client/hooks/chat/timeline/index.ts +27 -35
  163. package/src/client/hooks/chat/timeline/mode-availability.test.ts +51 -0
  164. package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
  165. package/src/client/hooks/chat/timeline/modes.ts +41 -2
  166. package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
  167. package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
  168. package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
  169. package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
  170. package/src/client/hooks/chat/timeline/prompt-text.test.ts +7 -0
  171. package/src/client/hooks/chat/timeline/prompt-text.ts +15 -6
  172. package/src/client/hooks/chat/timeline/rewind-actions.test.ts +51 -1
  173. package/src/client/hooks/chat/timeline/rewind-actions.ts +23 -1
  174. package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
  175. package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
  176. package/src/client/hooks/chat/timeline/send-execute.test.ts +55 -0
  177. package/src/client/hooks/chat/timeline/send-props.ts +11 -3
  178. package/src/client/hooks/chat/timeline/send-steer.test.ts +2 -3
  179. package/src/client/hooks/chat/timeline/send.test-util.ts +3 -2
  180. package/src/client/hooks/chat/timeline/send.test.ts +2 -3
  181. package/src/client/hooks/chat/timeline/send.ts +34 -8
  182. package/src/client/hooks/chat/timeline/session-harness.test.ts +163 -0
  183. package/src/client/hooks/chat/timeline/session-harness.ts +164 -0
  184. package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
  185. package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
  186. package/src/client/hooks/chat/timeline/session-load.ts +6 -14
  187. package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
  188. package/src/client/hooks/chat/timeline/spawn-harness.ts +41 -0
  189. package/src/client/hooks/chat/timeline/timeline-running.ts +55 -0
  190. package/src/client/hooks/chat/timeline/tui-only-guard.ts +9 -0
  191. package/src/client/hooks/chat/timeline/undo-confirmation.test.ts +131 -0
  192. package/src/client/hooks/models/harness-catalog.ts +114 -0
  193. package/src/client/hooks/models/provider-writes.test.ts +81 -0
  194. package/src/client/hooks/models/provider-writes.ts +144 -0
  195. package/src/client/hooks/models/use-harness-versions.test.ts +152 -0
  196. package/src/client/hooks/models/use-harness-versions.ts +136 -0
  197. package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
  198. package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
  199. package/src/client/hooks/models/use-harnesses.test.ts +187 -0
  200. package/src/client/hooks/models/use-harnesses.ts +215 -0
  201. package/src/client/hooks/settings/providers/index.ts +1 -3
  202. package/src/client/hooks/ui/editor-error-toast.ts +10 -3
  203. package/src/client/hooks/ui/icon-style.ts +28 -0
  204. package/src/client/hooks/ui/on-click-outside.test.ts +104 -0
  205. package/src/client/hooks/ui/on-click-outside.ts +14 -2
  206. package/src/client/hooks/ui/theme.ts +6 -0
  207. package/src/client/hooks/ui/toast-queue.test.ts +126 -0
  208. package/src/client/hooks/ui/toasts.ts +132 -27
  209. package/src/client/hooks/ui/ui-feedback.test.ts +4 -91
  210. package/src/client/lib/ui/control-plate.test.ts +76 -0
  211. package/src/client/lib/ui/control-plate.ts +65 -0
  212. package/src/client/tailwind.css +47 -1
  213. package/src/server/lib/assets/shell-attributes.server.ts +9 -2
  214. package/src/server/lib/assets/shell-attributes.test.ts +22 -6
  215. package/src/server/lib/db/schema.ts +4 -0
  216. package/src/server/lib/harness/acp/acp-audit.server.ts +107 -0
  217. package/src/server/lib/harness/acp/acp-goal-driver.server.ts +153 -0
  218. package/src/server/lib/harness/acp/acp-goal-state.server.ts +136 -0
  219. package/src/server/lib/harness/acp/acp-goal.server.ts +273 -0
  220. package/src/server/lib/harness/acp/acp-goal.test.ts +229 -0
  221. package/src/server/lib/harness/acp/acp-telemetry.server.ts +133 -0
  222. package/src/server/lib/harness/acp/acp-telemetry.test.ts +85 -0
  223. package/src/server/lib/harness/acp/acp-todos.server.ts +45 -0
  224. package/src/server/lib/harness/acp/acp-todos.test.ts +43 -0
  225. package/src/server/lib/harness/acp/activation.test.ts +81 -0
  226. package/src/server/lib/harness/acp/activation.ts +72 -0
  227. package/src/server/lib/harness/acp/calls.ts +97 -0
  228. package/src/server/lib/harness/acp/client.test.ts +73 -0
  229. package/src/server/lib/harness/acp/client.ts +339 -0
  230. package/src/server/lib/harness/acp/commands.test.ts +92 -0
  231. package/src/server/lib/harness/acp/commands.ts +165 -0
  232. package/src/server/lib/harness/acp/frames.test.ts +315 -0
  233. package/src/server/lib/harness/acp/frames.ts +349 -0
  234. package/src/server/lib/harness/acp/mapper.ts +204 -0
  235. package/src/server/lib/harness/acp/permissions.test.ts +66 -0
  236. package/src/server/lib/harness/acp/permissions.ts +155 -0
  237. package/src/server/lib/harness/acp/prompt.test.ts +130 -0
  238. package/src/server/lib/harness/acp/prompt.ts +134 -0
  239. package/src/server/lib/harness/acp/protocol.ts +162 -0
  240. package/src/server/lib/harness/acp/session-config.test.ts +73 -0
  241. package/src/server/lib/harness/acp/session-config.ts +148 -0
  242. package/src/server/lib/harness/acp/session-facts.ts +71 -0
  243. package/src/server/lib/harness/acp/session-handshake.ts +89 -0
  244. package/src/server/lib/harness/acp/session-idle.ts +51 -0
  245. package/src/server/lib/harness/acp/session-notifications.ts +95 -0
  246. package/src/server/lib/harness/acp/session-observers.test.ts +193 -0
  247. package/src/server/lib/harness/acp/session-options.ts +33 -0
  248. package/src/server/lib/harness/acp/session-permissions.test.ts +105 -0
  249. package/src/server/lib/harness/acp/session-permissions.ts +74 -0
  250. package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
  251. package/src/server/lib/harness/acp/session-turns.ts +95 -0
  252. package/src/server/lib/harness/acp/session-usage.ts +60 -0
  253. package/src/server/lib/harness/acp/session-web-state.ts +61 -0
  254. package/src/server/lib/harness/acp/session.test-util.ts +160 -0
  255. package/src/server/lib/harness/acp/session.test.ts +233 -0
  256. package/src/server/lib/harness/acp/session.ts +350 -0
  257. package/src/server/lib/harness/acp/turn.ts +199 -0
  258. package/src/server/lib/harness/acp/verbs.ts +87 -0
  259. package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
  260. package/src/server/lib/harness/auto-probe.server.ts +178 -0
  261. package/src/server/lib/harness/capabilities.ts +67 -0
  262. package/src/server/lib/harness/config-invalidation.test.ts +91 -0
  263. package/src/server/lib/harness/config.server.test.ts +105 -0
  264. package/src/server/lib/harness/config.server.ts +98 -0
  265. package/src/server/lib/harness/enabled.server.test.ts +87 -0
  266. package/src/server/lib/harness/enabled.server.ts +61 -0
  267. package/src/server/lib/harness/launch-table.ts +195 -0
  268. package/src/server/lib/harness/launch.test.ts +220 -0
  269. package/src/server/lib/harness/launch.ts +216 -0
  270. package/src/server/lib/harness/probe-cache.server.test.ts +154 -0
  271. package/src/server/lib/harness/probe-cache.server.ts +177 -0
  272. package/src/server/lib/harness/provider-entry.ts +212 -0
  273. package/src/server/lib/harness/provider-file.server.ts +67 -0
  274. package/src/server/lib/harness/provider-import.test.ts +191 -0
  275. package/src/server/lib/harness/provider-probe.server.ts +123 -0
  276. package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
  277. package/src/server/lib/harness/provider-sources.server.ts +308 -0
  278. package/src/server/lib/harness/provider-write-error.ts +19 -0
  279. package/src/server/lib/harness/provider-write.server.test.ts +308 -0
  280. package/src/server/lib/harness/provider-write.server.ts +339 -0
  281. package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
  282. package/src/server/lib/harness/provider-zcode.server.ts +324 -0
  283. package/src/server/lib/harness/register.server.ts +36 -0
  284. package/src/server/lib/harness/registry.ts +58 -0
  285. package/src/server/lib/harness/schema.server.ts +129 -0
  286. package/src/server/lib/harness/session-store.server.test.ts +175 -0
  287. package/src/server/lib/harness/session-store.server.ts +206 -0
  288. package/src/server/lib/harness/session-title.server.test.ts +109 -0
  289. package/src/server/lib/harness/session-title.server.ts +70 -0
  290. package/src/server/lib/harness/session.ts +74 -0
  291. package/src/server/lib/harness/spawn.server.ts +133 -0
  292. package/src/server/lib/harness/update-state.server.ts +185 -0
  293. package/src/server/lib/lifecycle/after-listen.ts +7 -0
  294. package/src/server/lib/models/provider-items.server.ts +1 -1
  295. package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
  296. package/src/server/lib/models/registry-refresh.server.ts +98 -0
  297. package/src/server/lib/omp/config/models-config.ts +4 -0
  298. package/src/server/lib/omp/core/cli.ts +13 -0
  299. package/src/server/lib/omp/core/host-resolution.test.ts +6 -3
  300. package/src/server/lib/omp/rpc/child-config.ts +5 -4
  301. package/src/server/lib/omp/rpc/constants.test.ts +2 -1
  302. package/src/server/lib/omp/rpc/event-fanout.ts +9 -0
  303. package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
  304. package/src/server/lib/omp/rpc/rpc-primitives.test.ts +11 -0
  305. package/src/server/lib/omp/rpc/session-registration.ts +7 -2
  306. package/src/server/lib/omp/rpc/session-registry.test.ts +2 -1
  307. package/src/server/lib/omp/rpc/session-registry.ts +74 -5
  308. package/src/server/lib/omp/session/acp-rows.server.ts +79 -0
  309. package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
  310. package/src/server/lib/omp/session/delete.server.ts +12 -0
  311. package/src/server/lib/omp/session/sidebar-data.harness.test.ts +247 -0
  312. package/src/server/lib/omp/session/sidebar-data.server.ts +56 -3
  313. package/src/server/lib/queue/delivery.server.test.ts +4 -2
  314. package/src/server/lib/queue/payload.test.ts +67 -0
  315. package/src/server/lib/queue/payload.ts +9 -3
  316. package/src/server/lib/realtime/signals.server.test.ts +99 -0
  317. package/src/server/lib/realtime/signals.server.ts +25 -5
  318. package/src/server/lib/realtime/topics/session-data.server.ts +29 -0
  319. package/src/server/lib/realtime/topics/session.server.ts +3 -3
  320. package/src/server/routes/agent/command-resume.test.ts +77 -0
  321. package/src/server/routes/agent/command.test.ts +243 -2
  322. package/src/server/routes/agent/command.ts +78 -15
  323. package/src/server/routes/agent/harness-command.ts +133 -0
  324. package/src/server/routes/agent/new.ts +63 -1
  325. package/src/server/routes/chat/rewind.test.ts +147 -0
  326. package/src/server/routes/chat/rewind.ts +29 -7
  327. package/src/server/routes/chat/session.test.ts +240 -0
  328. package/src/server/routes/chat/session.ts +96 -4
  329. package/src/server/routes/harness/add-provider.test.ts +233 -0
  330. package/src/server/routes/harness/import-action.ts +272 -0
  331. package/src/server/routes/harness/import.test.ts +196 -0
  332. package/src/server/routes/harness/index.ts +13 -0
  333. package/src/server/routes/harness/root.ts +280 -0
  334. package/src/server/routes/harness/toggle.test.ts +127 -0
  335. package/src/server/routes/harness/update.ts +259 -0
  336. package/src/server/routes/harness/versions.test.ts +148 -0
  337. package/src/server/routes/harness/versions.ts +105 -0
  338. package/src/server/routes/index.ts +2 -0
  339. package/src/server/routes/sessions/delete-acp.test.ts +227 -0
  340. package/src/server/routes/sessions/queue.ts +7 -2
  341. package/src/server/routes/sessions/routes-queue.test.ts +52 -0
  342. package/src/server/routes/sessions/routes.test.ts +47 -13
  343. package/src/server/routes/sessions/session.ts +35 -0
  344. package/src/server/routes/settings/commands-harness.test.ts +92 -0
  345. package/src/server/routes/settings/commands.ts +26 -0
  346. package/src/server/routes/settings/model-override.ts +5 -2
  347. package/src/server/routes/settings/provider-entry.ts +2 -2
  348. package/src/server/routes/settings/provider-model.ts +2 -2
  349. package/src/server/routes/settings/provider-models.ts +2 -2
  350. package/src/server/routes/settings/provider-refresh.ts +6 -4
  351. package/src/server/routes/settings/providers.ts +3 -1
  352. package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
  353. package/src/server/routes/settings/skills.ts +12 -0
  354. package/src/shared/lib/chat/ask-form/fields.ts +76 -0
  355. package/src/shared/lib/chat/ask-form/index.ts +323 -0
  356. package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
  357. package/src/shared/lib/chat/ask-form/types.ts +43 -0
  358. package/src/shared/lib/chat/ask-form.test.ts +137 -0
  359. package/src/shared/lib/chat/ask-questions.test.ts +65 -1
  360. package/src/shared/lib/chat/ask-questions.ts +51 -145
  361. package/src/shared/lib/chat/ask-results.ts +198 -0
  362. package/src/shared/lib/chat/composer/client.ts +20 -8
  363. package/src/shared/lib/chat/context/usage.test.ts +8 -4
  364. package/src/shared/lib/chat/context/usage.ts +17 -3
  365. package/src/shared/lib/chat/omp/abort.test.ts +61 -0
  366. package/src/shared/lib/chat/omp/abort.ts +8 -2
  367. package/src/shared/lib/chat/omp/tool-frames.test.ts +23 -0
  368. package/src/shared/lib/chat/omp/tool-frames.ts +12 -2
  369. package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
  370. package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
  371. package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
  372. package/src/shared/lib/chat/tool/summary-wait.test.ts +18 -8
  373. package/src/shared/lib/chat/tool/wait-facts.ts +14 -8
  374. package/src/shared/lib/harness/brand-color.test.ts +66 -0
  375. package/src/shared/lib/harness/brand-color.ts +96 -0
  376. package/src/shared/lib/harness/catalog.test.ts +88 -0
  377. package/src/shared/lib/harness/catalog.ts +169 -0
  378. package/src/shared/lib/harness/config-fields.test.ts +139 -0
  379. package/src/shared/lib/harness/config-fields.ts +168 -0
  380. package/src/shared/lib/harness/config.test.ts +153 -0
  381. package/src/shared/lib/harness/config.ts +206 -0
  382. package/src/shared/lib/harness/dialects.test.ts +140 -0
  383. package/src/shared/lib/harness/dialects.ts +249 -0
  384. package/src/shared/lib/harness/enabled.test.ts +79 -0
  385. package/src/shared/lib/harness/enabled.ts +72 -0
  386. package/src/shared/lib/harness/menu.test.ts +94 -0
  387. package/src/shared/lib/harness/menu.ts +88 -0
  388. package/src/shared/lib/harness/provider-facts.test.ts +199 -0
  389. package/src/shared/lib/harness/provider-facts.ts +349 -0
  390. package/src/shared/lib/harness/provider-slug.ts +46 -0
  391. package/src/shared/lib/harness/providers.ts +175 -0
  392. package/src/shared/lib/harness/rewind.ts +24 -0
  393. package/src/shared/lib/harness/status.test.ts +158 -0
  394. package/src/shared/lib/harness/status.ts +112 -0
  395. package/src/shared/lib/harness/update-plan.test.ts +163 -0
  396. package/src/shared/lib/harness/update-plan.ts +140 -0
  397. package/src/shared/lib/harness/updates.test.ts +106 -0
  398. package/src/shared/lib/harness/updates.ts +177 -0
  399. package/src/shared/lib/icons/icon-paint-authority.test.ts +16 -4
  400. package/src/shared/lib/icons/icon-paint-authority.ts +57 -12
  401. package/src/shared/lib/icons/icon-paint-bucket.test.ts +84 -0
  402. package/src/shared/lib/icons/icon-paint-css.test.ts +23 -25
  403. package/src/shared/lib/icons/icon-paint-css.ts +69 -55
  404. package/src/shared/lib/icons/icon-paint-harness.test.ts +73 -0
  405. package/src/shared/lib/icons/icon-paint-harness.ts +75 -0
  406. package/src/shared/lib/icons/icon-paint-ink.ts +108 -0
  407. package/src/shared/lib/icons/icon-paint-panel.ts +19 -4
  408. package/src/shared/lib/icons/icon-paint-weight.ts +21 -2
  409. package/src/shared/lib/icons/icon-tone.ts +118 -21
  410. package/src/shared/lib/icons/tint-hues.generated.ts +100 -284
  411. package/src/shared/lib/icons/tint-tones.test.ts +79 -25
  412. package/src/shared/lib/icons/tint.ts +66 -6
  413. package/src/shared/lib/models/client.ts +10 -1
  414. package/src/shared/lib/models/provider/vendors.ts +72 -0
  415. package/src/shared/lib/omp/config/schema.test.ts +36 -0
  416. package/src/shared/lib/omp/dialog-methods.ts +4 -3
  417. package/src/shared/lib/omp/session/messages-map-trace.test.ts +42 -0
  418. package/src/shared/lib/omp/session/messages-map.ts +6 -1
  419. package/src/shared/lib/omp/session/parse-message-blocks-toolcall.test.ts +8 -0
  420. package/src/shared/lib/omp/session/parse-message-blocks.ts +6 -1
  421. package/src/shared/lib/omp/session/shell-trace.test.ts +69 -0
  422. package/src/shared/lib/omp/session/shell-trace.ts +63 -0
  423. package/src/shared/lib/omp/session/sidebar.ts +37 -10
  424. package/src/shared/lib/omp/session/wait-idle.test.ts +47 -0
  425. package/src/shared/lib/omp/session/wait-idle.ts +93 -0
  426. package/src/shared/lib/omp/session/wait.test.ts +34 -33
  427. package/src/shared/lib/omp/session/wait.ts +25 -39
  428. package/src/shared/lib/settings/sections.ts +24 -0
  429. package/src/shared/lib/theme/css.ts +2 -0
  430. package/src/shared/lib/theme/ink-scale.ts +21 -1
  431. package/src/shared/lib/theme/theme.test.ts +25 -9
  432. package/src/shared/lib/ui/safe-area.test.ts +28 -0
  433. package/src/shared/lib/ui/safe-area.ts +42 -0
  434. package/src/shared/lib/ui/toast-duration.test.ts +74 -0
  435. package/src/shared/lib/ui/toast-duration.ts +70 -0
  436. package/src/shared/types/harness-version.ts +59 -0
  437. package/src/shared/types/harness.ts +201 -0
  438. package/src/shared/types/index.ts +2 -0
  439. package/src/shared/types/omp/agent.ts +13 -0
  440. package/src/shared/types/settings/state.ts +10 -1
  441. package/src/shared/types/workspace.ts +10 -0
  442. package/src/test-support/env.ts +38 -0
  443. package/src/test-support/file-explorer-render.test-util.ts +37 -0
  444. package/src/test-support/file-explorer.test-util.ts +20 -18
  445. package/src/test-support/harness-table.test-util.ts +108 -0
  446. package/dist/client/static/js/index-7ppta1pb.css +0 -1
@@ -0,0 +1,259 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Updating ONE harness — and refusing where Kabmo must not act.
8
+ *
9
+ * Three mechanisms, and the refusal is as much of the feature as the button:
10
+ *
11
+ * - **`npm`** — install that package at the version the registry reported. This is
12
+ * the only case where Kabmo touches an install, and it is the case the vendor
13
+ * published for exactly this.
14
+ * - **`self`** — the CLI updates itself (`opencode upgrade`, `cmd update`). Kabmo
15
+ * runs THAT command: it must not install a package behind launcher logic it
16
+ * does not own.
17
+ * - **`own`** — a vendor installer (curl script, app bundle). Refused with the
18
+ * reason, because replacing it would be Kabmo guessing at an install it did not
19
+ * make.
20
+ *
21
+ * **An adapter is TWO installs.** `claude` is `@agentclientprotocol/claude-agent-acp`
22
+ * (the number the probe reports) on top of the `claude` CLI, and they move
23
+ * independently — measured here: adapter 0.100.0 under CLI 2.1.318. So one press
24
+ * moves EVERY part that is behind and none that is current:
25
+ *
26
+ * - both behind → `npm i -g <adapter>@<latest>` then `claude update`;
27
+ * - only the CLI → `claude update`, with no adapter install at all;
28
+ * - only the adapter → the npm install alone.
29
+ *
30
+ * Running both unconditionally was the first shape, and it reinstalled an adapter
31
+ * that was already current while reporting "updated to 0.101.0" about a version
32
+ * that never moved.
33
+ *
34
+ * Every run is a POST that answers plain JSON, not an SSE stream: an npm install
35
+ * of one package, or one `upgrade` subcommand, is seconds rather than the minutes
36
+ * `omp update` and the Kabmo self-update take. If one of these grows long enough
37
+ * to need streaming, it should reuse `updates/apply.ts` rather than grow a second
38
+ * progress protocol here.
39
+ */
40
+
41
+ import { json } from '@/server/lib/remix-compat';
42
+ import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
43
+ import { methodNotAllowed } from '@/server/lib/route-adapter';
44
+ import { HARNESS_IDS, harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
45
+ import { harnessUpdateFacts, latestSourceFor, type HarnessUpdateFacts } from '@/shared/lib/harness/updates';
46
+ import { forgetProbe, loadProbes } from '@/server/lib/harness/probe-cache.server';
47
+ import { forgetCliVersion, harnessVersionState } from '@/server/lib/harness/update-state.server';
48
+ import { planHarnessUpdate, repointAdapterLaunch, type HarnessUpdateStep } from '@/shared/lib/harness/update-plan';
49
+ import { loadHarnessConfig, saveHarnessConfig } from '@/server/lib/harness/config.server';
50
+ import { resolveOmpBin } from '@/server/lib/omp/core/cli';
51
+ import { harnessVersionRows } from '@/server/routes/harness/versions';
52
+
53
+ /** Longest one update may run before it is killed and reported as a timeout. */
54
+ const UPDATE_TIMEOUT_MS = 5 * 60_000;
55
+
56
+ /** The result the UI reports, in the agent's own terms. */
57
+ interface HarnessUpdateOutcome {
58
+ success: boolean;
59
+ id: string;
60
+ message: string;
61
+ /** The commands that ran, so the reader can repeat them themselves. */
62
+ command?: string;
63
+ /** The tail of their output — what actually failed, when it failed. */
64
+ output?: string;
65
+ }
66
+
67
+ /** Run a command, capturing its combined output for the report. */
68
+ async function run(command: string[], cwd?: string): Promise<{ code: number | null; output: string }> {
69
+ const proc = Bun.spawn({
70
+ cmd: command,
71
+ stdin: 'ignore',
72
+ stdout: 'pipe',
73
+ stderr: 'pipe',
74
+ timeout: UPDATE_TIMEOUT_MS,
75
+ env: { ...Bun.env, PAGER: 'cat', FORCE_COLOR: '0' },
76
+ ...(cwd ? { cwd } : {}),
77
+ });
78
+ const [stdout, stderr] = await Promise.all([
79
+ new Response(proc.stdout).text(),
80
+ new Response(proc.stderr).text(),
81
+ ]);
82
+ const code = await proc.exited;
83
+ return { code, output: [stdout, stderr].filter(Boolean).join('\n').trim() };
84
+ }
85
+
86
+ /** The last few lines of a run, which is where a failure explains itself. */
87
+ function tail(output: string, lines = 12): string {
88
+ const all = output.split('\n');
89
+ return all.slice(Math.max(0, all.length - lines)).join('\n').trim();
90
+ }
91
+
92
+ /**
93
+ * Make an adapter install the one the next spawn runs.
94
+ *
95
+ * The launch table starts an npm adapter through a PINNED `npx -y pkg@x.y.z`
96
+ * (measured versions), while the update installs the package GLOBALLY. Those are
97
+ * two different resolvers: `npm i -g` writes a binary onto PATH that `npx` never
98
+ * consults, so the press reported success while every new session still started
99
+ * the old pinned build — measured on `claude` (global 0.101.0, launch requested
100
+ * 0.100.0) and reproduced for codex/pi/zcode by construction.
101
+ *
102
+ * Once the install succeeded AND the binary is on PATH, the harness's launch
103
+ * line is pointed at it. A user's own configured command is never replaced: it
104
+ * is an explicit choice about how this machine launches the harness.
105
+ */
106
+ async function pointAtInstalledAdapter(
107
+ harness: HarnessId,
108
+ facts: HarnessUpdateFacts,
109
+ steps: HarnessUpdateStep[],
110
+ ): Promise<string | null> {
111
+ const config = await loadHarnessConfig(harness);
112
+ const bin = repointAdapterLaunch(
113
+ facts,
114
+ steps,
115
+ config.command,
116
+ facts.agentBin ? Boolean(Bun.which(facts.agentBin)) : false,
117
+ );
118
+ if (!bin) return null;
119
+ await saveHarnessConfig(harness, { ...config, command: bin });
120
+ return bin;
121
+ }
122
+
123
+ export async function action({ request, params }: ActionFunctionArgs) {
124
+ if (request.method !== 'POST') return methodNotAllowed({ request, params });
125
+
126
+ let body: unknown;
127
+ try {
128
+ body = await request.json();
129
+ } catch {
130
+ return json({ error: 'Request body is not valid JSON' }, { status: 400 });
131
+ }
132
+ const id = body && typeof body === 'object' && 'harness' in body ? body.harness : undefined;
133
+ if (typeof id !== 'string' || !HARNESS_IDS.includes(id as HarnessId)) {
134
+ return json({ error: 'Unknown harness' }, { status: 400 });
135
+ }
136
+
137
+ const harness = id as HarnessId;
138
+ const facts = harnessUpdateFacts(harness);
139
+ const label = harnessDescriptor(harness)?.label ?? harness;
140
+ if (!facts) {
141
+ return json({ error: `Kabmo knows nothing about updating ${label}` }, { status: 400 });
142
+ }
143
+
144
+ if (facts.kind === 'own') {
145
+ // Refused, with the reason: a vendor installer owns this binary, and Kabmo
146
+ // replacing it would be an install it did not make.
147
+ return json({
148
+ error: `${label} is installed by its vendor` + (facts.command ? `. Update it with: ${facts.command}` : ''),
149
+ code: 'vendor_managed',
150
+ }, { status: 400 });
151
+ }
152
+
153
+ if (facts.kind === 'self') {
154
+ const command = facts.command?.split(' ') ?? [];
155
+ const binary = command[0];
156
+ // `omp` has its own resolver (`KABMO_OMP_BIN`, then PATH): a custom install
157
+ // is launchable and already reported as installed by `commandAvailable`, so
158
+ // checking PATH alone refused the one updater the harness actually has.
159
+ const resolved = harness === 'omp-acp' ? resolveOmpBin() : binary ? Bun.which(binary) : null;
160
+ if (!binary || !resolved) {
161
+ return json({ error: `${label}: \`${binary ?? 'the updater'}\` is not on PATH` }, { status: 400 });
162
+ }
163
+ const result = await run([resolved, ...command.slice(1)]);
164
+ const ok = result.code === 0;
165
+ const outcome: HarnessUpdateOutcome = {
166
+ success: ok,
167
+ id: harness,
168
+ message: ok ? `${label} updated` : `${label} update failed (exit ${result.code ?? 'killed'})`,
169
+ command: facts.command,
170
+ ...(result.output ? { output: tail(result.output) } : {}),
171
+ };
172
+ return json(outcome);
173
+ }
174
+
175
+ // `npm`: install the package at the version the registry reports NOW, so the
176
+ // number on screen and the install cannot disagree. A harness can have no
177
+ // AGENT package while its CLI has one (`dsh`): the CLI step is then the whole
178
+ // update, so the missing agent package is not a refusal.
179
+ const pkg = latestSourceFor(harness);
180
+ if (!pkg && !facts.cli?.pkg) return json({ error: `${label} has no package to install` }, { status: 400 });
181
+
182
+ const probe = (await loadProbes()).get(harness);
183
+ const agentVersion = probe?.capabilities.agentVersion ?? null;
184
+ // A forced read: this press must install the newest published version, not one
185
+ // remembered from ten minutes ago.
186
+ const state = await harnessVersionState(harness, agentVersion, true);
187
+ if (!state.installed) {
188
+ // A partial install (the CLI present, the adapter absent) reaches here, and an
189
+ // update that cannot see the binary must say so rather than run an install
190
+ // whose result the row could never report.
191
+ return json({ error: `${label} is not installed on this machine` }, { status: 400 });
192
+ }
193
+
194
+ // `harnessVersionState` was read with `force`, so both latest numbers are what
195
+ // the registry serves NOW rather than what the dialog remembered.
196
+
197
+ const steps = planHarnessUpdate(label, facts, state, agentVersion);
198
+
199
+ if (steps.length === 0) {
200
+ // Nothing to install. Reported as a success the UI can state plainly, rather
201
+ // than running an install that would change nothing.
202
+ const current = [state.agent.version && `adapter ${state.agent.version}`, state.cli?.version && `${facts.cli?.name} ${state.cli.version}`]
203
+ .filter(Boolean)
204
+ .join(', ');
205
+ return json({
206
+ success: true,
207
+ id: harness,
208
+ // Without a probe there was no number to compare, so the honest answer is
209
+ // that nothing was compared — not "up to date".
210
+ message: agentVersion
211
+ ? `${label} is already up to date${current ? ` (${current})` : ''}`
212
+ : `${label} has never been probed — nothing could be compared`,
213
+ } satisfies HarnessUpdateOutcome);
214
+ }
215
+
216
+ /** Did every step that ran succeed, and what did each print? */
217
+ const outputs: string[] = [];
218
+ let ok = true;
219
+ for (const step of steps) {
220
+ const result = await run(step.argv);
221
+ if (result.output) outputs.push(result.output);
222
+ if (result.code !== 0) {
223
+ ok = false;
224
+ // The first failure ends the run: installing the CLI on top of a failed
225
+ // adapter install would report two outcomes for one broken state.
226
+ break;
227
+ }
228
+ }
229
+
230
+ if (ok) {
231
+ // The cached probe describes the binary that WAS installed. Keeping it would
232
+ // report the old version until the TTL (30 min) or a manual re-probe — and
233
+ // measured after a real `npm install`: the row still read 0.100.0 while npm
234
+ // had 0.101.0 on disk, because the running adapter was the previous process.
235
+ await forgetProbe(harness);
236
+ // The CLI's `--version` read has the same problem: it is cached for ten
237
+ // minutes, so the row would keep claiming the old number after it moved.
238
+ if (facts.cli) forgetCliVersion(facts.cli.bin);
239
+ }
240
+ // Only after the install succeeded: the launch line is repointed at the binary
241
+ // that install wrote, or the next session would start the pinned one forever.
242
+ const repointed = ok ? await pointAtInstalledAdapter(harness, facts, steps) : null;
243
+
244
+ const moved = steps.map((step) => step.part);
245
+ return json({
246
+ success: ok,
247
+ id: harness,
248
+ message: ok
249
+ ? `${label} updated (${moved.join(' + ')})${repointed ? ` — launches now run \`${repointed}\`` : ''} — check its status to read the new version`
250
+ : `${label} update failed`,
251
+ command: steps.map((step) => step.command).join(' && '),
252
+ ...(outputs.length > 0 ? { output: tail(outputs.join('\n')) } : {}),
253
+ } satisfies HarnessUpdateOutcome);
254
+ }
255
+
256
+ /** GET answers the same rows the versions route does, so a mistake reads plainly. */
257
+ export async function loader() {
258
+ return json({ harnesses: await harnessVersionRows() });
259
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The version table, as facts rather than a screenshot.
8
+ *
9
+ * The bug this pins was measured in a running card: `claude` read
10
+ * "0.100.0 → 2.1.318" with an Update button, because the registry package was a
11
+ * DIFFERENT product from the one the probe reported. A comparison across two
12
+ * number lines is worse than no comparison — it invites an install that cannot
13
+ * land where the number claims.
14
+ *
15
+ * The other half is what each kind of harness may be TOLD. A row with no probe
16
+ * has no running version, and saying "up to date" about it would be fabricating a
17
+ * fact; a self-updating CLI has no registry number at all, so the row states the
18
+ * command instead.
19
+ */
20
+
21
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
22
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
23
+ import { probes } from '@/server/lib/harness/probe-cache.server';
24
+ import { harnessVersionRows } from '@/server/routes/harness/versions';
25
+ import { isNewer } from '@/shared/lib/updates/semver';
26
+
27
+ beforeEach(async () => {
28
+ await isolateDb();
29
+ probes().clear();
30
+ });
31
+
32
+ afterEach(async () => {
33
+ await releaseDb();
34
+ probes().clear();
35
+ });
36
+
37
+ afterAll(async () => {
38
+ await releaseDb();
39
+ });
40
+
41
+ /** The row for one harness. */
42
+ async function row(id: string) {
43
+ const rows = await harnessVersionRows();
44
+ const found = rows.find((entry) => entry.id === id);
45
+ if (!found) throw new Error(`no row for ${id}`);
46
+ return found;
47
+ }
48
+
49
+ describe('harness version rows', () => {
50
+ test('an unprobed harness reports NO version and says so', async () => {
51
+ const claude = await row('claude');
52
+ // `false` here would claim "up to date" about an unknown version.
53
+ expect(claude.agent.updateAvailable).toBe(false);
54
+ expect(claude.note).toContain('Not probed');
55
+ });
56
+
57
+ test('a harness that is NOT installed offers no version and no action', async () => {
58
+ // Measured on a real card: rows for agents that were never installed showed
59
+ // an Update or a copyable command. An absent agent has nothing to update.
60
+ const cursor = await row('cursor');
61
+ if (!cursor.installed) {
62
+ expect(cursor.kind).toBeNull();
63
+ expect(cursor.agent.latest).toBeNull();
64
+ expect(cursor.updateAvailable).toBe(false);
65
+ expect(cursor.command).toBeNull();
66
+ expect(cursor.note).toContain('Not installed');
67
+ }
68
+ });
69
+
70
+ test('a self-updating harness has no registry number, only its command', async () => {
71
+ const opencode = await row('opencode');
72
+ // `kind` is reported only for a harness this machine can launch (`toRow`
73
+ // nulls it otherwise), and `opencode` is not installed on a clean runner —
74
+ // measured on both CI gates, where this case alone failed with
75
+ // `Expected: "self", Received: null` while the same file passed locally.
76
+ // The other cases here guard the same way; this one did not.
77
+ if (!opencode.installed) return;
78
+ expect(opencode.kind).toBe('self');
79
+ expect(opencode.agent.latest).toBeNull();
80
+ expect(opencode.command).toBe('opencode upgrade');
81
+ });
82
+
83
+ test('a vendor-managed harness carries its command ONLY when installed', async () => {
84
+ // The command is what WOULD update it, so it is useful on an install and
85
+ // misleading on an absent agent — a reader would copy a line that cannot run.
86
+ const antigravity = await row('antigravity');
87
+ if (antigravity.installed) {
88
+ expect(antigravity.kind).toBe('own');
89
+ expect(antigravity.command).toContain('antigravity.google');
90
+ } else {
91
+ expect(antigravity.kind).toBeNull();
92
+ expect(antigravity.command).toBeNull();
93
+ expect(antigravity.note).toContain('Not installed');
94
+ }
95
+ // Nothing for Kabmo to install either way.
96
+ expect(antigravity.updateAvailable).toBe(false);
97
+ });
98
+
99
+ test('an installed npm harness reads a real registry version', async () => {
100
+ // A network read, so it asserts only what it can: an INSTALLED npm harness
101
+ // either has a version or says why the registry could not be read.
102
+ const rows = await harnessVersionRows();
103
+ const target = rows.find((entry) => entry.installed && entry.kind === 'npm');
104
+ if (!target) return;
105
+ if (target.agent.latest === null) {
106
+ expect(target.note).toContain('Could not read');
107
+ return;
108
+ }
109
+ expect(target.agent.latest).toMatch(/^\d+\.\d+\.\d+/);
110
+ });
111
+
112
+ test('an adapter row reports BOTH parts, each with its own latest', async () => {
113
+ // `claude` is an npm adapter over a `claude update` CLI. The row must carry
114
+ // both numbers so the table can say which half is behind — a single flattened
115
+ // pair is what made "the adapter is current" read as "everything is current".
116
+ const claude = await row('claude');
117
+ if (!claude.installed) return;
118
+ expect(claude.cli?.name).toBe('Claude Code');
119
+ // The registry answers are cached for ten minutes; a miss is stated as a null
120
+ // rather than invented, so this asserts the shape and the comparison rule.
121
+ for (const part of [claude.agent, claude.cli]) {
122
+ if (!part) continue;
123
+ expect(part.updateAvailable).toBe(
124
+ Boolean(part.version && part.latest) && isNewer(part.latest as string, part.version as string),
125
+ );
126
+ }
127
+ // `updateAvailable` is the union of the parts: one press moves every part that
128
+ // is behind, so the button appears when either half can move.
129
+ expect(claude.updateAvailable).toBe(claude.agent.updateAvailable || Boolean(claude.cli?.updateAvailable));
130
+ });
131
+
132
+ test('the built-in transport has no kind and no version', async () => {
133
+ const builtin = await row('omp-rpc');
134
+ expect(builtin.kind).toBeNull();
135
+ expect(builtin.agent.version).toBeNull();
136
+ expect(builtin.agent.latest).toBeNull();
137
+ expect(builtin.cli).toBeNull();
138
+ expect(builtin.updateAvailable).toBe(false);
139
+ });
140
+
141
+ test('every listed harness has a row, so a reader counts them all', async () => {
142
+ const rows = await harnessVersionRows();
143
+ expect(rows.length).toBeGreaterThan(10);
144
+ for (const entry of rows) {
145
+ expect(entry.label).toBeTruthy();
146
+ }
147
+ });
148
+ });
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Version and update state for EVERY harness, in one read.
8
+ *
9
+ * The About modal answers "what am I running, and what could move?". That used to
10
+ * be two products — Kabmo and omp — and now it is a dozen agents, each installed a
11
+ * different way. So this route reports, per harness:
12
+ *
13
+ * - `agent` — the ADAPTER: the version the probe reported, and what its own
14
+ * package on npm now offers.
15
+ * - `cli` — the CLI underneath an adapter, from its own `--version`, with its
16
+ * own package's latest version. Two parts, two number lines: `claude` measured
17
+ * 2.1.318 while its ACP adapter was 0.100.0, and moving one does not move the
18
+ * other.
19
+ * - `updateAvailable` — true when ANY part is behind, because the update action
20
+ * moves every part that is behind in one run. Only when the numbers are known
21
+ * and comparable: `—` is a real answer here, and a fabricated `false` would
22
+ * claim "up to date" about a harness Kabmo knows nothing about.
23
+ * - `kind` — how it updates, so the UI says "Updated by `opencode upgrade`"
24
+ * instead of offering a button that would install a package behind the vendor's
25
+ * launcher.
26
+ *
27
+ * `force` re-reads npm instead of answering from the process cache; the About
28
+ * modal's "Check again" sets it, and the automatic path does not.
29
+ */
30
+
31
+ import { json, NO_STORE_HEADERS } from '@/server/lib/remix-compat';
32
+ import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
33
+ import { HARNESS_IDS, harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
34
+ import { harnessUpdateFacts, type HarnessUpdateFacts } from '@/shared/lib/harness/updates';
35
+ import type { HarnessPartRow, HarnessVersionRow } from '@/shared/types/harness-version';
36
+ import { loadProbes } from '@/server/lib/harness/probe-cache.server';
37
+ import { harnessVersionState, type HarnessVersionState } from '@/server/lib/harness/update-state.server';
38
+ import { isNewer } from '@/shared/lib/updates/semver';
39
+
40
+ /** One part's row, with the comparison the UI is not allowed to guess at. */
41
+ function partRow(part: { version: string | null; latest: string | null }): HarnessPartRow {
42
+ return {
43
+ version: part.version,
44
+ latest: part.latest,
45
+ updateAvailable: Boolean(part.version && part.latest) && isNewer(part.latest as string, part.version as string),
46
+ };
47
+ }
48
+
49
+ /** Assemble the wire row from the version state. */
50
+ function toRow(
51
+ id: HarnessId,
52
+ label: string,
53
+ kind: HarnessVersionRow['kind'],
54
+ facts: HarnessUpdateFacts | null,
55
+ state: HarnessVersionState,
56
+ ): HarnessVersionRow {
57
+ const agent = partRow(state.agent);
58
+ const cli = state.cli ? { name: state.cli.name, ...partRow(state.cli) } : null;
59
+
60
+ // `—` is a real answer. A comparison needs BOTH numbers, and claiming
61
+ // "up to date" about a harness with no probe would be a fabricated fact.
62
+ const updateAvailable = state.installed && (agent.updateAvailable || Boolean(cli?.updateAvailable));
63
+
64
+ let note: string | null = facts?.note ?? null;
65
+ if (!state.installed) note = 'Not installed on this machine — nothing to update.';
66
+ else if (!facts) note = 'Kabmo knows nothing about updating this harness.';
67
+ else if (!state.agent.version) note = 'Not probed yet — check its status to learn the version it runs.';
68
+ else if (facts.kind !== 'npm') note = facts.command ? `Updated by \`${facts.command}\`.` : note;
69
+ // An npm harness can have no AGENT package (`dsh`: the probe reports the ACP
70
+ // surface, the package is the CLI). The note names whichever package was
71
+ // actually read, instead of "Could not read undefined".
72
+ else if (facts.pkg && !state.agent.latest) note = `Could not read ${facts.pkg} from the registry.`;
73
+ else if (facts.cli?.pkg && state.cli?.version && !state.cli.latest) note = `Could not read ${facts.cli.pkg} from the registry.`;
74
+
75
+ return {
76
+ id,
77
+ label,
78
+ kind: state.installed ? kind : null,
79
+ installed: state.installed,
80
+ agent,
81
+ cli,
82
+ updateAvailable,
83
+ note,
84
+ // An absent harness has no command to offer: the reader would copy a line
85
+ // that cannot run until the agent exists.
86
+ command: state.installed ? facts?.command ?? null : null,
87
+ };
88
+ }
89
+
90
+ /** Every harness's row, in catalog order. */
91
+ export async function harnessVersionRows(force = false): Promise<HarnessVersionRow[]> {
92
+ const probes = await loadProbes();
93
+
94
+ return Promise.all(HARNESS_IDS.map(async (id) => {
95
+ const facts = harnessUpdateFacts(id);
96
+ const state = await harnessVersionState(id, probes.get(id)?.capabilities.agentVersion ?? null, force);
97
+ return toRow(id, harnessDescriptor(id)?.label ?? id, facts?.kind ?? null, facts, state);
98
+ }));
99
+ }
100
+
101
+ /** GET /api/harness/versions?force=1 */
102
+ export async function loader({ request }: LoaderFunctionArgs) {
103
+ const force = new URL(request.url).searchParams.get('force') === '1';
104
+ return json({ harnesses: await harnessVersionRows(force) }, { headers: NO_STORE_HEADERS });
105
+ }
@@ -27,6 +27,7 @@ import { reviewBindings } from '@/server/routes/review/bindings';
27
27
  import { panelsBindings } from '@/server/routes/panels/bindings';
28
28
  import { pluginsBindings } from '@/server/routes/plugins/bindings';
29
29
  import { realtimeWsRoutes } from '@/server/routes/realtime/ws';
30
+ import { harnessBindings } from '@/server/routes/harness';
30
31
  import { healthBindings } from '@/server/routes/health';
31
32
  import { wellKnownBindings } from '@/server/routes/well-known';
32
33
 
@@ -36,6 +37,7 @@ const allBindings: HandlerBinding[] = [
36
37
  // @deprecated pre-rename path; same handlers, kept for an old page.
37
38
  ...chamberBindings,
38
39
  ...agentBindings,
40
+ ...harnessBindings,
39
41
  ...btwBindings,
40
42
  ...chatBindings,
41
43
  ...sessionsBindings,