@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
@@ -25,14 +25,18 @@
25
25
  */
26
26
 
27
27
  import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
28
- import type { AIModelOption, ModelEntry } from '@/shared/types';
28
+ import type { AIModelOption } from '@/shared/types';
29
29
  import { fetchModelsData, subscribeModelsUpdated } from '@/shared/lib/models/client';
30
30
  import { selectableThinkingLevels } from '@/shared/lib/models/thinking-levels';
31
31
  import { resolveThinkingLevel, selectionFor } from '@/client/components/workspace/chat-timeline/chat-input/selection';
32
32
 
33
33
 
34
34
  /** Pick the catalog entry that matches `modelId` + `provider`, or undefined. */
35
- function matchModel(list: readonly ModelEntry[], provider: string, id: string): ModelEntry | undefined {
35
+ function matchModel<T extends { id: string; provider: string }>(
36
+ list: readonly T[],
37
+ provider: string,
38
+ id: string,
39
+ ): T | undefined {
36
40
  return list.find((entry) => entry.id === id && entry.provider === provider);
37
41
  }
38
42
 
@@ -53,6 +57,17 @@ export interface ModelSelectionOptions {
53
57
  sessionThinkingLevel: string | null | undefined;
54
58
  /** A selection the user made for the NEXT prompt; it outranks every default. */
55
59
  deferredComposerPickRef: { current: { provider?: string; modelId?: string; thinkingLevel?: string } | null };
60
+ /**
61
+ * The ACTIVE HARNESS's own catalog (ACP), or null for omp's registry.
62
+ *
63
+ * Every resolution below reads this instead of `/api/models` when it is
64
+ * present. The two catalogs share no ids — `claude` publishes `default`,
65
+ * `opus`, … and omp's registry has never heard of them — so matching a
66
+ * session's model against omp's list left the composer showing an omp model
67
+ * while the chat ran a different agent. The list also carries the agent's
68
+ * `thought_level` ladder, which is what enables the thinking picker.
69
+ */
70
+ scopedModels?: AIModelOption[] | null;
56
71
  onThinkingLevelChange?: (level: string) => void;
57
72
  }
58
73
 
@@ -74,6 +89,7 @@ export function useModelSelection({
74
89
  sessionModel,
75
90
  sessionThinkingLevel,
76
91
  deferredComposerPickRef,
92
+ scopedModels,
77
93
  onThinkingLevelChange,
78
94
  }: ModelSelectionOptions): ModelSelection {
79
95
  // Starts null and is filled from `/api/models`. Seeding a demo catalog entry
@@ -102,6 +118,13 @@ export function useModelSelection({
102
118
  useEffect(() => {
103
119
  if (!sessionModel?.provider || !sessionModel.modelId) return;
104
120
  if (deferredComposerPickRef.current) return;
121
+ // An ACP harness's catalog is the session's own; asking omp's registry
122
+ // would never find `claude/opus`.
123
+ if (scopedModels) {
124
+ const match = matchModel(scopedModels, sessionModel.provider, sessionModel.modelId);
125
+ if (match) setSelectedModel((prev) => selectionFor(match, sessionThinkingLevelRef.current, prev));
126
+ return;
127
+ }
105
128
  let active = true;
106
129
  fetchModelsData()
107
130
  .then((data) => {
@@ -114,7 +137,7 @@ export function useModelSelection({
114
137
  return () => {
115
138
  active = false;
116
139
  };
117
- }, [sessionModel?.provider, sessionModel?.modelId, deferredComposerPickRef]);
140
+ }, [sessionModel?.provider, sessionModel?.modelId, deferredComposerPickRef, scopedModels]);
118
141
 
119
142
  // Adopt the session's thinking level; a pending pick wins.
120
143
  useEffect(() => {
@@ -131,6 +154,20 @@ export function useModelSelection({
131
154
  useEffect(() => {
132
155
  let active = true;
133
156
  const syncModel = async () => {
157
+ // An ACP harness owns this selection: its list is the whole catalog, and
158
+ // omp's persisted/default model is a model the agent cannot run.
159
+ if (scopedModels) {
160
+ if (deferredComposerPickRef.current) return;
161
+ const fromSession = sessionModelRef.current;
162
+ const match = fromSession
163
+ ? matchModel(scopedModels, fromSession.provider, fromSession.modelId)
164
+ : undefined;
165
+ const fallback = match ?? scopedModels[0];
166
+ if (fallback) {
167
+ setSelectedModel((prev) => selectionFor(fallback, sessionThinkingLevelRef.current, prev));
168
+ }
169
+ return;
170
+ }
134
171
  try {
135
172
  const data = await fetchModelsData();
136
173
  if (!active) return;
@@ -173,12 +210,16 @@ export function useModelSelection({
173
210
  };
174
211
 
175
212
  syncModel();
213
+ // The harness catalog is refreshed through its own store; the models topic
214
+ // describes omp's registry only, so subscribing here would open a realtime
215
+ // channel for a catalog this selection never reads.
216
+ if (scopedModels) return;
176
217
  const unsubscribe = subscribeModelsUpdated(syncModel);
177
218
  return () => {
178
219
  active = false;
179
220
  unsubscribe();
180
221
  };
181
- }, [deferredComposerPickRef]);
222
+ }, [deferredComposerPickRef, scopedModels]);
182
223
 
183
224
  const thinkingLevels = useMemo(() => selectableThinkingLevels(selectedModel?.thinkingLevels), [selectedModel]);
184
225
 
@@ -142,12 +142,14 @@ export function useOmpPromptSender(deps: OmpPromptSenderDeps): OmpPromptSender {
142
142
  // Plan/goal picks from the pending view. Omitted when the user made
143
143
  // none, so a spawn with no selection behaves exactly as before.
144
144
  ...(composerOptions?.modes ? { modes: composerOptions.modes } : {}),
145
+ ...(composerOptions?.harness ? { harness: composerOptions.harness } : {}),
145
146
  }),
146
147
  });
147
148
  const createdBody = (await created.json().catch(() => ({}))) as {
148
149
  success?: boolean;
149
150
  sessionId?: string;
150
151
  model?: { provider: string; modelId: string } | null;
152
+ harness?: string;
151
153
  error?: string;
152
154
  };
153
155
  if (!created.ok || !createdBody.sessionId) {
@@ -166,7 +168,7 @@ export function useOmpPromptSender(deps: OmpPromptSenderDeps): OmpPromptSender {
166
168
  // is what makes the order a fact rather than a race. An armed interview
167
169
  // answers true: it already opened the turn, so this prompt is not sent.
168
170
  if (beforePrompt && await beforePrompt(sid)) {
169
- return { sessionId: sid, model: createdBody.model ?? null };
171
+ return { sessionId: sid, model: createdBody.model ?? null, ...(createdBody.harness ? { harness: createdBody.harness } : {}) };
170
172
  }
171
173
  const res = await fetch(`/api/agent/${encodeURIComponent(sid)}`, {
172
174
  method: 'POST',
@@ -182,7 +184,7 @@ export function useOmpPromptSender(deps: OmpPromptSenderDeps): OmpPromptSender {
182
184
  setState((prev) => ({ ...prev, isGenerating: false, error: body.error ?? `HTTP ${res.status}` }));
183
185
  return null;
184
186
  }
185
- return { sessionId: sid, model: createdBody.model ?? null };
187
+ return { sessionId: sid, model: createdBody.model ?? null, ...(createdBody.harness ? { harness: createdBody.harness } : {}) };
186
188
  } catch (e) {
187
189
  setState((prev) => ({ ...prev, isGenerating: false, error: e instanceof Error ? e.message : String(e) }));
188
190
  return null;
@@ -41,6 +41,9 @@ export interface ChatTimelineActionsDeps {
41
41
  * still refuses a plain prompt mid-turn, and omp drops it. */
42
42
  chatRunning: boolean;
43
43
  isOmpSession: boolean;
44
+ /** The harness that owns this chat; scopes the TUI-only slash guard so an
45
+ * ACP agent's own `/clear` is delivered instead of refused. */
46
+ harness?: string | null;
44
47
  /** Active session id (null on pending "new-…"); the omp undo path posts the
45
48
  * rewind against it. */
46
49
  sessionId: string | null;
@@ -55,7 +58,7 @@ export interface ChatTimelineActionsDeps {
55
58
  /** Server-backed per-item queue ops (append/remove/reorder). */
56
59
  enqueueMessage: (item: Omit<QueuedMessage, 'id'>) => void;
57
60
  removeMessage: (id: string) => void;
58
- executeSend: (text: string, attachments: Attachment[], options?: { model?: QueuedMessageModel | null }) => Promise<PromptDispatchResult>;
61
+ executeSend: (text: string, attachments: Attachment[], options?: { model?: QueuedMessageModel | null; harness?: string | null }) => Promise<PromptDispatchResult>;
59
62
  steerOmpAgent: (text: string, attachments: Attachment[]) => Promise<PromptDispatchResult>;
60
63
  ompAgent: OmpAgentHandle;
61
64
  abortControllerRef: { current: AbortController | null };
@@ -110,7 +113,7 @@ export interface ChatTimelineActionsResult {
110
113
  handleSendNowQueueItem: (item: QueuedMessage) => Promise<void>;
111
114
  handleUndo: (msgId: string, content?: string) => Promise<boolean>;
112
115
  handleRetry: (msgId: string) => void;
113
- submitNewChat: (text: string, attachments: Attachment[]) => void;
116
+ submitNewChat: (text: string, attachments: Attachment[], harness?: string) => void;
114
117
  /** Stop the active run; returns the number of queue items held back. */
115
118
  stopGenerating: () => number;
116
119
  handleThinkingLevelChange: (level: string) => void;
@@ -124,6 +127,7 @@ export function useChatTimelineActions(deps: ChatTimelineActionsDeps): ChatTimel
124
127
  isGenerating,
125
128
  chatRunning,
126
129
  isOmpSession,
130
+ harness,
127
131
  sessionId,
128
132
  folders,
129
133
  selectedFolderId,
@@ -179,7 +183,7 @@ export function useChatTimelineActions(deps: ChatTimelineActionsDeps): ChatTimel
179
183
  // would reach the model as literal text over RPC and burn a whole turn on
180
184
  // an improvisation. Answer it here, before it is queued or steered, and
181
185
  // keep the draft so the user can edit or retype it.
182
- if (blockTuiOnlySend(textToSend, setLocalMessages)) return;
186
+ if (blockTuiOnlySend(textToSend, setLocalMessages, harness)) return;
183
187
 
184
188
  // A NEW chat whose prompt is held for another session: nothing is sent now,
185
189
  // and the pending row stays on screen saying what it waits for. Checked
@@ -233,7 +237,7 @@ export function useChatTimelineActions(deps: ChatTimelineActionsDeps): ChatTimel
233
237
  // branch would rather than losing the message. Every other failure may
234
238
  // already have been accepted, and is reported by the send path instead.
235
239
  if (result.busy) enqueueFollowUp(textToSend, attachments);
236
- }, [deps, inputValue, isGenerating, chatRunning, executeSend, enqueueMessage, enqueueFollowUp, isOmpSession, appSettings, steerOmpAgent, setInputValue, abortControllerRef, setGenerating, stopHoldRef, composerModelRef, accessModeRef, setLocalMessages]);
240
+ }, [deps, inputValue, isGenerating, chatRunning, executeSend, enqueueMessage, enqueueFollowUp, isOmpSession, harness, appSettings, steerOmpAgent, setInputValue, abortControllerRef, setGenerating, stopHoldRef, composerModelRef, accessModeRef, setLocalMessages]);
237
241
 
238
242
  const handleEditQueueItem = useCallback((item: QueuedMessage) => {
239
243
  queueActions.handleEditQueueItem(item);
@@ -249,6 +253,7 @@ export function useChatTimelineActions(deps: ChatTimelineActionsDeps): ChatTimel
249
253
  () => createRewindActions({
250
254
  isGenerating,
251
255
  isOmpSession,
256
+ harness,
252
257
  sessionId,
253
258
  ompAgent,
254
259
  abortControllerRef,
@@ -260,7 +265,7 @@ export function useChatTimelineActions(deps: ChatTimelineActionsDeps): ChatTimel
260
265
  executeSend,
261
266
  reportActionError,
262
267
  }),
263
- [isGenerating, isOmpSession, sessionId, ompAgent, abortControllerRef, setGenerating, setInputValue, setLocalMessages, localMessagesRef, persistMessages, executeSend, reportActionError],
268
+ [isGenerating, isOmpSession, harness, sessionId, ompAgent, abortControllerRef, setGenerating, setInputValue, setLocalMessages, localMessagesRef, persistMessages, executeSend, reportActionError],
264
269
  );
265
270
 
266
271
  const submitNewChat = useNewChatSubmit({
@@ -42,7 +42,9 @@
42
42
  import { createContext, useContext } from 'preact/compat';
43
43
  import type { ChatMessageData } from '@/shared/types';
44
44
  import type { ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
45
- import { groupAskFrames, isAskSettled, isAskToolCall, normalizeAskText, parseAskQuestions, parseAskResult, type AskQuestion } from '@/shared/lib/chat/ask-questions';
45
+ import { askQuestionForTitle, groupAskFrames, isAskSettled, isAskToolCall, normalizeAskText, parseAskQuestions } from '@/shared/lib/chat/ask-questions';
46
+ import { parseAskResult } from '@/shared/lib/chat/ask-results';
47
+ import type { AskQuestion } from '@/shared/lib/chat/ask-form/types';
46
48
  import { isApprovalGateFrame } from '@/shared/lib/chat/omp/approval-gate';
47
49
  import type { ExtensionDialogResponse } from '@/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Lazy';
48
50
 
@@ -165,15 +167,14 @@ export function splitAskFrames(
165
167
  continue;
166
168
  }
167
169
 
168
- const title = typeof request.title === 'string' ? normalizeAskText(request.title) : '';
169
170
  let owner: string | null = null;
170
- if (title) {
171
+ if (typeof request.title === 'string' && request.title) {
171
172
  // Newest first: omp asks one question at a time and blocks on it, so when
172
173
  // two live calls name the same question the later one is the one in
173
174
  // flight.
174
175
  for (let index = openAsks.length - 1; index >= 0; index -= 1) {
175
176
  const candidate = openAsks[index];
176
- if (candidate.questions.some((question) => normalizeAskText(question.question) === title)) {
177
+ if (askQuestionForTitle(candidate.questions, request.title) !== -1) {
177
178
  owner = candidate.toolId;
178
179
  break;
179
180
  }
@@ -27,11 +27,9 @@
27
27
 
28
28
  import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
29
29
  import { Window } from 'happy-dom';
30
- import { h, render } from 'preact';
31
- import { act } from 'preact/test-utils';
30
+ import { render } from 'preact';
32
31
  import type { Dispatch, SetStateAction } from 'preact/compat';
33
32
  import { appendTuiOnlyNotice, blockTuiOnlySend } from '@/client/hooks/chat/timeline/tui-only-guard';
34
- import { useUndoConfirmation } from '@/client/hooks/chat/timeline/undo-confirmation';
35
33
  import { createQueueActions, type QueueActions, type QueueActionsDeps } from '@/client/hooks/chat/timeline/queue-actions';
36
34
  import type { Attachment, ChatMessageData, QueuedMessage } from '@/shared/types';
37
35
 
@@ -39,16 +37,6 @@ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTML
39
37
  /** The runner's own globals, restored on teardown so later files still have them. */
40
38
  const native: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
41
39
 
42
- /** The undo gate's surface. `undo-confirmation.ts` exports only the hook, so
43
- * the shape a caller sees is restated here rather than read off the function. */
44
- interface UndoGate {
45
- pendingUndo: { id: string; content: string } | null;
46
- undoing: boolean;
47
- error: string | null;
48
- requestUndo: (id: string, content?: string) => void;
49
- closeUndoConfirm: () => void;
50
- confirmUndo: () => Promise<void>;
51
- }
52
40
 
53
41
  const originalSetTimeout = globalThis.setTimeout;
54
42
  let container: HTMLElement | undefined;
@@ -119,6 +107,24 @@ describe('blockTuiOnlySend', () => {
119
107
  expect(store.messages).toHaveLength(0);
120
108
  });
121
109
 
110
+ test("another ACP agent's own command is delivered, not refused", () => {
111
+ // The table is omp's registry. claude publishes `/clear` and `/status`
112
+ // itself, so refusing them here meant the command never reached the agent
113
+ // that implements it.
114
+ const store = makeStore();
115
+ expect(blockTuiOnlySend('/clear', store.set, 'claude')).toBe(false);
116
+ expect(blockTuiOnlySend('/status', store.set, 'opencode')).toBe(false);
117
+ expect(store.messages).toHaveLength(0);
118
+ });
119
+
120
+ test('omp’s own transports keep the guard', () => {
121
+ for (const harness of ['omp-rpc', 'omp-acp', undefined]) {
122
+ const store = makeStore();
123
+ expect(blockTuiOnlySend('/hotkeys', store.set, harness)).toBe(true);
124
+ expect(store.messages).toHaveLength(1);
125
+ }
126
+ });
127
+
122
128
  test('plain prose is not a command and passes through', () => {
123
129
  const store = makeStore();
124
130
  expect(blockTuiOnlySend('what does /clear do?', store.set)).toBe(false);
@@ -166,74 +172,6 @@ describe('appendTuiOnlyNotice', () => {
166
172
  });
167
173
  });
168
174
 
169
- describe('useUndoConfirmation', () => {
170
- let undo: UndoGate | undefined;
171
-
172
- function UndoProbe({ onUndo }: { onUndo: (id: string, content: string) => Promise<boolean> }) {
173
- undo = useUndoConfirmation(onUndo);
174
- return null;
175
- }
176
-
177
- async function open(onUndo: (id: string, content: string) => Promise<boolean>): Promise<void> {
178
- container ??= document.body.appendChild(document.createElement('div'));
179
- await act(async () => { render(h(UndoProbe, { onUndo }), container as HTMLElement); });
180
- }
181
-
182
- test('a request opens the gate with the row it was given', async () => {
183
- await open(async () => true);
184
- await act(async () => { undo?.requestUndo('m1', 'the prompt'); });
185
- expect(undo?.pendingUndo).toEqual({ id: 'm1', content: 'the prompt' });
186
- });
187
-
188
- test('a request without content opens with an empty one', async () => {
189
- await open(async () => true);
190
- await act(async () => { undo?.requestUndo('m1'); });
191
- expect(undo?.pendingUndo).toEqual({ id: 'm1', content: '' });
192
- });
193
-
194
- test('a successful undo closes the gate', async () => {
195
- const calls: string[] = [];
196
- await open(async (id, content) => { calls.push(`${id}|${content}`); return true; });
197
- await act(async () => { undo?.requestUndo('m1', 'p'); });
198
- await act(async () => { await undo?.confirmUndo(); });
199
- expect(calls).toEqual(['m1|p']);
200
- expect(undo?.pendingUndo).toBeNull();
201
- expect(undo?.error).toBeNull();
202
- });
203
-
204
- test('a refused undo keeps the gate open WITH the reason', async () => {
205
- await open(async () => false);
206
- await act(async () => { undo?.requestUndo('m1'); });
207
- await act(async () => { await undo?.confirmUndo(); });
208
- expect(undo?.pendingUndo).toEqual({ id: 'm1', content: '' });
209
- expect(undo?.undoing).toBe(false);
210
- expect(undo?.error).toContain('Undo failed');
211
- });
212
-
213
- test('a second confirm while one is in flight is ignored', async () => {
214
- const pending = Promise.withResolvers<boolean>();
215
- const calls: string[] = [];
216
- await open((id) => { calls.push(id); return pending.promise; });
217
- await act(async () => { undo?.requestUndo('m1'); });
218
- await act(async () => { void undo?.confirmUndo(); });
219
- expect(undo?.undoing).toBe(true);
220
- await act(async () => { void undo?.confirmUndo(); });
221
- expect(calls).toEqual(['m1']);
222
- pending.resolve(true);
223
- await act(async () => {});
224
- expect(undo?.pendingUndo).toBeNull();
225
- });
226
-
227
- test('cancelling clears the gate and its reason', async () => {
228
- await open(async () => false);
229
- await act(async () => { undo?.requestUndo('m1'); });
230
- await act(async () => { await undo?.confirmUndo(); });
231
- await act(async () => { undo?.closeUndoConfirm(); });
232
- expect(undo?.pendingUndo).toBeNull();
233
- expect(undo?.error).toBeNull();
234
- });
235
- });
236
-
237
175
  describe('createQueueActions', () => {
238
176
  function queuedRow(id: string, text: string, attachments: Attachment[] = []): QueuedMessage {
239
177
  return {
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  import type { ChatTimelineModes } from '@/client/hooks/chat/timeline/modes';
21
+ import { useHarnesses } from '@/client/hooks/models/use-harnesses';
21
22
  import type { PlanReviewState } from '@/client/hooks/chat/timeline/plan-review';
22
23
  import { useChatTimelineModes } from '@/client/hooks/chat/timeline/modes';
23
24
  import { usePlanReview } from '@/client/hooks/chat/timeline/plan-review';
@@ -27,6 +28,14 @@ export interface ComposerModesHandle {
27
28
  planReview: PlanReviewState;
28
29
  }
29
30
 
30
- export function useComposerModes(sessionId: string | null): ComposerModesHandle {
31
- return { modes: useChatTimelineModes(sessionId), planReview: usePlanReview(sessionId) };
31
+ export function useComposerModes(sessionId: string | null, harness?: string | null): ComposerModesHandle {
32
+ // The harness's PROBE is what says whether it has a `plan` mode at all: the
33
+ // mode list is the agent's own, and a non-omp agent has no `/kabmo-mode`
34
+ // extension to fall back on.
35
+ const { harnesses } = useHarnesses();
36
+ const modeValues = harnesses.find((entry) => entry.id === harness)?.probe?.capabilities.modeValues;
37
+ return {
38
+ modes: useChatTimelineModes(sessionId, { harness, ...(modeValues ? { modeValues } : {}) }),
39
+ planReview: usePlanReview(sessionId),
40
+ };
32
41
  }
@@ -29,6 +29,14 @@ export interface ComposerRefs {
29
29
  composerModelRef: { current: { provider: string; modelId: string; thinkingLevel: string } | null };
30
30
  /** A pick made mid-run, pushed right before the next prompt this composer starts. */
31
31
  deferredComposerPickRef: { current: ComposerModelPick | null };
32
+ /**
33
+ * Harness picked on a pending `new-…` chat.
34
+ *
35
+ * A ref for the same reason the model pick is one: the send path is built once
36
+ * per deps record, so a value read from render state there would dispatch with
37
+ * whatever it was when that closure was created.
38
+ */
39
+ pendingHarnessRef: { current: string | null };
32
40
  }
33
41
 
34
42
  export function useComposerRefs(sessionId: string | null): ComposerRefs {
@@ -36,6 +44,7 @@ export function useComposerRefs(sessionId: string | null): ComposerRefs {
36
44
  const pendingThinkingLevelRef = useRef<string | null>(null);
37
45
  const composerModelRef = useRef<{ provider: string; modelId: string; thinkingLevel: string } | null>(null);
38
46
  const deferredComposerPickRef = useRef<ComposerModelPick | null>(null);
47
+ const pendingHarnessRef = useRef<string | null>(null);
39
48
 
40
49
  // A stashed pick belongs to ONE session's next prompt: carrying it across a
41
50
  // switch would silently re-target the session the user just opened.
@@ -43,5 +52,11 @@ export function useComposerRefs(sessionId: string | null): ComposerRefs {
43
52
  deferredComposerPickRef.current = null;
44
53
  }, [sessionId]);
45
54
 
46
- return { pendingComposerModelRef, pendingThinkingLevelRef, composerModelRef, deferredComposerPickRef };
55
+ // A harness pick belongs to the chat being started: opening another session
56
+ // must not carry `claude` onto an omp conversation.
57
+ useEffect(() => {
58
+ pendingHarnessRef.current = null;
59
+ }, [sessionId]);
60
+
61
+ return { pendingComposerModelRef, pendingThinkingLevelRef, composerModelRef, deferredComposerPickRef, pendingHarnessRef };
47
62
  }
@@ -1,4 +1,4 @@
1
- import { useCallback, useRef, useState } from 'preact/hooks';
1
+ import { useCallback, useMemo, useRef, useState } from 'preact/hooks';
2
2
  import { useTimelineScope } from '@/client/hooks/chat/timeline/scope';
3
3
  import { useSpawnTarget } from '@/client/hooks/chat/timeline/spawn-target';
4
4
  import type { ChatMessageData } from '@/shared/types';
@@ -17,7 +17,8 @@ import { cancelStreamingCoalescer } from '@/shared/lib/chat/timeline/stream-coal
17
17
  import { useChatTimelineAccessMode } from '@/client/hooks/chat/timeline/access-mode';
18
18
  import { useComposerModes } from '@/client/hooks/chat/timeline/composer-modes';
19
19
  import { useComposerDraft } from '@/client/hooks/chat/composer/use-draft';
20
- import { isChatRunning, isSessionStreaming } from '@/client/hooks/chat/omp/session-statuses';
20
+ import { useTimelineRunning } from '@/client/hooks/chat/timeline/timeline-running';
21
+ import { resolveSessionHarness, useHarnessPick } from '@/client/hooks/chat/timeline/session-harness';
21
22
  import { useWaitingDependencyChoice } from '@/client/hooks/chat/waiting/choice';
22
23
  import { useComposerRefs } from '@/client/hooks/chat/timeline/composer-refs';
23
24
 
@@ -96,32 +97,9 @@ export function useChatTimeline({
96
97
  // only a UUID routes through the live agent bridge.
97
98
  const isOmpSession = Boolean(sessionId) && !String(sessionId).startsWith('new-') && Number.isNaN(Number(sessionId));
98
99
 
99
- // One "a run is in flight" state for the whole chat, and its base is the
100
- // SERVER: the `stream` row written at prompt dispatch, published on the
101
- // `sidebar:status` topic the sidebar's spinner is drawn from — so no consumer
102
- // of this flag (indicator, streaming row, withheld run footer, queue-vs-send,
103
- // Stop) can disagree with the sidebar.
104
- //
105
- // Two windows the row cannot cover, and BOTH must be reported or a run reads
106
- // as already settled while it is still starting: (1) a pending `new-…` chat
107
- // has no omp id until the spawn answers, so no row can ever carry it; (2) a
108
- // run THIS PAGE dispatched, in the beat between the send arming the optimistic
109
- // rows and the row reaching this client over the topic — measured ~120-250 ms,
110
- // and the reason the run footer "appeared for an instant" on every prompt:
111
- // handed `isGenerating: false` for that window, `resolveRunFooters` settled the
112
- // run and painted a model/duration footer over the EMPTY placeholder row, then
113
- // withdrew it when the row arrived.
114
- //
115
- // The second term is `ownRun` — armed by the SEND path alone, released by the
116
- // same settle paths as the run — NOT the raw local flag: an ADOPTED run (the
117
- // mount probe resuming a live run's UI) leaves it alone, so a run this page did
118
- // not start is still reported by the server row and never by client state.
119
- const timelineRunning = isChatRunning(streamStatusMap, sessionId, ownRun);
120
-
121
- // SERVER evidence a prompt was dispatched (the `stream` row), mirrored for
122
- // the reconnect guard: a run whose FIRST frame was lost has no `agent_start`.
123
- const serverRunRef = useRef(isSessionStreaming(streamStatusMap, sessionId));
124
- serverRunRef.current = isSessionStreaming(streamStatusMap, sessionId);
100
+ // One "a run is in flight" state for the whole chat; the derivation and the
101
+ // two windows it covers live in `timeline-running.ts`.
102
+ const { running: timelineRunning, serverRunRef } = useTimelineRunning(streamStatusMap, sessionId, ownRun);
125
103
 
126
104
  const aiPlaceholderIdRef = useRef<string | null>(null);
127
105
 
@@ -156,16 +134,14 @@ export function useChatTimeline({
156
134
  scroll,
157
135
  });
158
136
 
159
- // The composer's model/thinking mirrors and the mid-run stash (see the hook).
160
- const { pendingComposerModelRef, pendingThinkingLevelRef, composerModelRef, deferredComposerPickRef } =
137
+ // Composer model/thinking mirrors and the mid-run stash (see the hook).
138
+ const { pendingComposerModelRef, pendingThinkingLevelRef, composerModelRef, deferredComposerPickRef, pendingHarnessRef } =
161
139
  useComposerRefs(sessionId);
162
140
 
163
- // Access control is a GLOBAL, persisted user preference (unlike the
164
- // per-session model/thinking picks).
141
+ // Access control is a GLOBAL persisted preference, unlike per-session picks.
165
142
  const { accessMode, accessModeRef, setAccessMode: handleAccessModeChange } = useChatTimelineAccessMode(appSettings);
166
143
 
167
- // "Wait for session" on a NEW chat: the pick, and the ref the send handler
168
- // reads (see `choice.ts` for why both).
144
+ // "Wait for session" on a NEW chat: the pick and the ref the send reads.
169
145
  const waitingDependency = useWaitingDependencyChoice(sessionId);
170
146
 
171
147
  const persistMessages = useCallback((messagesToSave: any[]) => {
@@ -216,13 +192,26 @@ export function useChatTimeline({
216
192
  // Plan/goal toggles plus the plan-review surface. PER SESSION, unlike the
217
193
  // access mode: they describe what this conversation is doing, and a mode
218
194
  // command can produce a proposal.
219
- const { modes, planReview } = useComposerModes(sessionId);
195
+ //
196
+ // The chat's HARNESS decides what those toggles may offer: a non-omp ACP agent
197
+ // has no `/kabmo-mode` extension, and `plan` is a real mode only where that
198
+ // agent publishes one. Resolved by the SAME rule the picker renders from
199
+ // (`resolveSessionHarness`) — row, spawn record, then the pick — because a
200
+ // second resolution here saw only the first two, so a pending `claude` chat
201
+ // still offered Goal and arming it did nothing.
202
+ const harnessPick = useHarnessPick(sessionId);
203
+ const chatHarness = useMemo(
204
+ () => resolveSessionHarness(folders, sessionId, harnessPick).harness,
205
+ [folders, sessionId, harnessPick],
206
+ );
207
+ const { modes, planReview } = useComposerModes(sessionId, chatHarness);
220
208
 
221
209
  const { steerOmpAgent, executeSend } = useChatTimelineSend({
222
210
  folders,
223
211
  selectedFolderId,
224
212
  sessionId,
225
213
  isOmpSession,
214
+ harness: chatHarness,
226
215
  appSettings,
227
216
  ompAgent,
228
217
  setLocalMessages,
@@ -239,6 +228,7 @@ export function useChatTimeline({
239
228
  pendingComposerModelRef,
240
229
  pendingThinkingLevelRef,
241
230
  deferredComposerPickRef,
231
+ pendingHarnessRef,
242
232
  accessModeRef,
243
233
  spawnSelectionRef: modes.spawnSelectionRef,
244
234
  goalArmRef: modes.goalArmRef,
@@ -262,6 +252,7 @@ export function useChatTimeline({
262
252
  isGenerating,
263
253
  chatRunning: timelineRunning,
264
254
  isOmpSession,
255
+ harness: chatHarness,
265
256
  sessionId,
266
257
  folders,
267
258
  selectedFolderId,
@@ -343,6 +334,7 @@ export function useChatTimeline({
343
334
  waitingDependency,
344
335
  spawnTarget: spawn.target,
345
336
  setSpawnTarget: spawn.setTarget,
337
+ pendingHarnessRef,
346
338
  extensionDialogs,
347
339
  resolveExtensionDialog,
348
340
  respondToExtensionUi: ompAgent.respondToExtensionUi,
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Which mode toggles a harness may offer.
8
+ *
9
+ * The composer used to show Plan and Goal on every chat. For a non-omp ACP agent
10
+ * that is a button whose only outcome is a refusal: there is no `/kabmo-mode`
11
+ * extension to carry either mode, and its own mode selector is the only place
12
+ * `plan` can live (measured: claude publishes `plan`, opencode's modes are its
13
+ * own three agents).
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+ import { modeAvailability } from '@/client/hooks/chat/timeline/modes';
18
+
19
+ describe('modeAvailability', () => {
20
+ test('omp RPC carries both modes', () => {
21
+ expect(modeAvailability({ harness: 'omp-rpc', modeValues: [] })).toEqual({ plan: true, goal: true });
22
+ });
23
+
24
+ test('omp over ACP carries both modes', () => {
25
+ expect(modeAvailability({ harness: 'omp-acp', modeValues: [] })).toEqual({ plan: true, goal: true });
26
+ });
27
+
28
+ test('an unknown harness keeps the old surface', () => {
29
+ expect(modeAvailability({})).toEqual({ plan: true, goal: true });
30
+ });
31
+
32
+ test('an ACP agent with a plan mode offers Plan and Goal', () => {
33
+ expect(modeAvailability({ harness: 'claude', modeValues: ['default', 'acceptEdits', 'plan'] })).toEqual({
34
+ plan: true,
35
+ goal: true,
36
+ });
37
+ });
38
+
39
+ test('an ACP agent without a plan mode still offers Goal', () => {
40
+ // The goal record and its loop are Kabmo-owned; the agent needs no mode
41
+ // value for them.
42
+ expect(modeAvailability({ harness: 'opencode', modeValues: ['Sisyphus', 'Prometheus'] })).toEqual({
43
+ plan: false,
44
+ goal: true,
45
+ });
46
+ });
47
+
48
+ test('a probe that has not arrived yet hides Plan for a non-omp harness', () => {
49
+ expect(modeAvailability({ harness: 'opencode', modeValues: undefined })).toEqual({ plan: false, goal: true });
50
+ });
51
+ });
@@ -52,6 +52,12 @@ export interface ChatTimelineModes {
52
52
  * flag only hides a button: a stale client or a typed `/plan` used to reach
53
53
  * the child and turn both modes on. */
54
54
  planAvailable: boolean;
55
+ /**
56
+ * Whether Goal is offered at all. An ACP agent that is not omp has no
57
+ * `/kabmo-mode` extension, so the toggle could only ever produce a refusal —
58
+ * the same rule `planAvailable` already follows for the plan/goal exclusion.
59
+ */
60
+ goalAvailable: boolean;
55
61
  /**
56
62
  * The last refusal, from either side of the wire: the route's own error, or a
57
63
  * `KABMO_MODE_ERROR` the extension emitted (an unknown action, a missing