@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,146 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The env-style provider form: one endpoint, its key, and an optional model pin.
8
+ *
9
+ * This is the entire "add a provider" action for an `environment` harness (Claude
10
+ * Code, Antigravity). Every field is labelled with the VARIABLE it becomes,
11
+ * because that is the only thing the user's choice produces — there is no
12
+ * registry to add to.
13
+ *
14
+ * A blank field writes NO variable: an empty env var is a real thing to set, so
15
+ * the form must not do it by accident. And the answer of `onSave` — not a state
16
+ * read after `setProblem` — decides whether the fields clear: the previous
17
+ * version read the stale state, so a successful save reported failure and kept
18
+ * its values.
19
+ */
20
+
21
+ import { useState } from 'preact/hooks';
22
+ import { AlertCircle, Check, Loader2 } from 'lucide-preact';
23
+ import type { HarnessProviderSupport } from '@/shared/types/harness';
24
+
25
+ const INPUT_CLASS =
26
+ 'w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 font-mono text-[11px] text-ink outline-none transition-colors placeholder:text-ink/30 focus:border-ink/50';
27
+
28
+ export function EnvProviderForm({ support, onSave }: { support: HarnessProviderSupport; onSave: (env: string) => Promise<string | null> }) {
29
+ const [baseUrl, setBaseUrl] = useState('');
30
+ const [apiKey, setApiKey] = useState('');
31
+ const [model, setModel] = useState('');
32
+ /** One value per `ANTHROPIC_DEFAULT_*_MODEL`-style variable, keyed by name. */
33
+ const [aliases, setAliases] = useState<Record<string, string>>({});
34
+ const [saving, setSaving] = useState(false);
35
+ const [problem, setProblem] = useState<string | null>(null);
36
+ const env = support.env;
37
+
38
+ if (!env) return null;
39
+
40
+ const modelAliases = env.modelAliases ?? [];
41
+
42
+ const save = async () => {
43
+ setSaving(true);
44
+ try {
45
+ const written = [
46
+ baseUrl.trim() ? `${env.baseUrl}=${baseUrl.trim()}` : '',
47
+ apiKey.trim() ? `${env.apiKey}=${apiKey.trim()}` : '',
48
+ env.model && model.trim() ? `${env.model}=${model.trim()}` : '',
49
+ ...modelAliases.map((alias) => {
50
+ const value = aliases[alias.env]?.trim();
51
+ return value ? `${alias.env}=${value}` : '';
52
+ }),
53
+ ].filter(Boolean).join('\n');
54
+ // The ANSWER is what decides success. Reading the `problem` state here held
55
+ // the PREVIOUS save's value, so a successful save reported failure.
56
+ const refusal = await onSave(written);
57
+ setProblem(refusal);
58
+ if (!refusal) {
59
+ setBaseUrl('');
60
+ setApiKey('');
61
+ setModel('');
62
+ setAliases({});
63
+ }
64
+ } finally {
65
+ setSaving(false);
66
+ }
67
+ };
68
+
69
+ return (
70
+ <div className="space-y-2">
71
+ <div className="flex items-start gap-1.5 rounded-md border border-ink/15 bg-ink/[0.03] p-2 text-[10px] leading-relaxed text-ink/65">
72
+ <AlertCircle size={11} className="mt-0.5 shrink-0" />
73
+ <span>
74
+ These point <strong className="font-semibold text-ink">every</strong> request at one endpoint — they
75
+ replace this agent's own provider, they do not add beside it.
76
+ </span>
77
+ </div>
78
+
79
+ <label className="flex flex-col gap-1">
80
+ <span className="font-mono text-[10px] text-ink/50">{env.baseUrl}</span>
81
+ <input
82
+ type="text"
83
+ value={baseUrl}
84
+ placeholder="https://api.example.com"
85
+ onInput={(e) => setBaseUrl(e.currentTarget.value)}
86
+ className={INPUT_CLASS}
87
+ />
88
+ </label>
89
+ <label className="flex flex-col gap-1">
90
+ <span className="font-mono text-[10px] text-ink/50">{env.apiKey}</span>
91
+ <input
92
+ type="password"
93
+ value={apiKey}
94
+ autoComplete="off"
95
+ placeholder="sk-…"
96
+ onInput={(e) => setApiKey(e.currentTarget.value)}
97
+ className={INPUT_CLASS}
98
+ />
99
+ </label>
100
+ {env.model && (
101
+ <label className="flex flex-col gap-1">
102
+ <span className="font-mono text-[10px] text-ink/50">{env.model}</span>
103
+ <input
104
+ type="text"
105
+ value={model}
106
+ placeholder="claude-sonnet-5"
107
+ onInput={(e) => setModel(e.currentTarget.value)}
108
+ className={INPUT_CLASS}
109
+ />
110
+ </label>
111
+ )}
112
+ {modelAliases.length > 0 && (
113
+ <div className="space-y-1.5 rounded-md border border-ink/15 bg-ink/[0.03] p-2">
114
+ <div className="text-[10px] leading-relaxed text-ink/60">
115
+ Each picker alias resolves to a model id the vendor ships unless it is pinned here.
116
+ Leave an alias blank when the endpoint serves that family's vendor id; fill it when
117
+ the endpoint has its own ids — otherwise that pick sends
118
+ {' '}<span className="font-mono">400 model not found</span>.
119
+ </div>
120
+ {modelAliases.map((alias) => (
121
+ <label key={alias.env} className="flex flex-col gap-1">
122
+ <span className="font-mono text-[10px] text-ink/50">{alias.env}</span>
123
+ <input
124
+ type="text"
125
+ value={aliases[alias.env] ?? ''}
126
+ placeholder={`the endpoint's ${alias.family} model id`}
127
+ onInput={(e) => setAliases((prev) => ({ ...prev, [alias.env]: e.currentTarget.value }))}
128
+ className={INPUT_CLASS}
129
+ />
130
+ </label>
131
+ ))}
132
+ </div>
133
+ )}
134
+
135
+ <button
136
+ type="button"
137
+ onClick={() => void save()}
138
+ disabled={saving || (!baseUrl.trim() && !apiKey.trim())}
139
+ className="inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/75 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50"
140
+ >
141
+ {saving ? <Loader2 size={11} className="animate-spin" /> : <Check size={11} />} Save to environment
142
+ </button>
143
+ {problem && <div className="rounded-md border border-ink/15 bg-ink/[0.04] p-2 text-[11px] text-ink/75">{problem}</div>}
144
+ </div>
145
+ );
146
+ }
@@ -0,0 +1,278 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * One harness's card: its mark, its live status, and the capabilities it
8
+ * actually advertised.
9
+ *
10
+ * The capability rows are rendered FROM the probe, never from a hardcoded
11
+ * table: the matrix in the design doc is the expected output of this card, so a
12
+ * version bump that adds `fork` shows up here with no code change, and a harness
13
+ * that has never been probed says so instead of borrowing omp's answers.
14
+ *
15
+ * "Check status" spawns the agent ONCE (measured: 0.08 s for omp, 2.3 s for
16
+ * opencode) and caches the result, which is why it is a button rather than
17
+ * something this page does on open.
18
+ */
19
+
20
+ import { useState } from 'preact/hooks';
21
+ import { AlertCircle, Check, CircleDashed, Loader2, PackageX, X } from 'lucide-preact';
22
+ import { HarnessGlyph } from '@/client/components/common/harness-glyph';
23
+ import { harnessStatus, type HarnessState } from '@/shared/lib/harness/status';
24
+ import { HarnessConfigForm } from '@/client/components/settings/categories/harness-settings/ConfigForm';
25
+ import { EMPTY_HARNESS_CONFIG, type HarnessConfig } from '@/shared/lib/harness/config';
26
+ import { HarnessProviderPanel } from '@/client/components/settings/categories/harness-settings/ProviderPanel';
27
+ import type { HarnessImportOutcome, HarnessProviderSupport, HarnessSummary } from '@/shared/types/harness';
28
+ import type { AddProviderInput } from '@/client/components/settings/categories/harness-settings/AddProviderForm';
29
+
30
+ interface HarnessCardProps {
31
+ summary: HarnessSummary;
32
+ onProbe: (id: string) => Promise<string | null>;
33
+ install?: string;
34
+ /** The stored per-harness config, or empty when the user never saved one. */
35
+ config?: HarnessConfig;
36
+ /** Save this harness's config; resolves to the server's refusal, or null. */
37
+ onSaveConfig?: (id: string, config: HarnessConfig) => Promise<string | null>;
38
+ /** Switch this harness on or off. Omitted by a surface that must not change
39
+ * the roster. */
40
+ onSetEnabled?: (enabled: boolean) => void;
41
+ /** True while this card's switch or Check is in flight. */
42
+ busy?: boolean;
43
+ /** Providers for this harness, at the level it actually supports. */
44
+ providerSupport?: HarnessProviderSupport;
45
+ /** Copy one provider from a source registry into this harness. */
46
+ onImportProvider?: (
47
+ id: string,
48
+ sourceId: string,
49
+ entry: HarnessProviderSupport['importable'][number],
50
+ ) => Promise<HarnessImportOutcome>;
51
+ /** Add a provider by typing its endpoint and key into this harness's card. */
52
+ onAddProvider?: (id: string, input: AddProviderInput) => Promise<HarnessImportOutcome>;
53
+ }
54
+
55
+ /** One capability row: a label and a yes/no/never-probed answer. */
56
+ function Capability({ label, value, detail }: { label: string; value: boolean | null; detail?: string }) {
57
+ return (
58
+ <div className="flex items-start justify-between gap-3 border-b border-ink/5 py-1.5 last:border-0">
59
+ <div className="min-w-0">
60
+ <div className="text-ink/70">{label}</div>
61
+ {detail && <div className="truncate text-[10px] text-ink/40" title={detail}>{detail}</div>}
62
+ </div>
63
+ <span className="shrink-0 font-mono text-[11px]">
64
+ {value === null ? (
65
+ <span className="text-ink/35">—</span>
66
+ ) : value ? (
67
+ <span className="inline-flex items-center gap-1 text-ink/80"><Check size={11} /> yes</span>
68
+ ) : (
69
+ <span className="inline-flex items-center gap-1 text-ink/40"><X size={11} /> no</span>
70
+ )}
71
+ </span>
72
+ </div>
73
+ );
74
+ }
75
+
76
+ export function HarnessCard({
77
+ summary, onProbe, install, config, onSaveConfig, providerSupport, onImportProvider, onAddProvider,
78
+ onSetEnabled, busy = false,
79
+ }: HarnessCardProps) {
80
+ const [probing, setProbing] = useState(false);
81
+ const [problem, setProblem] = useState<string | null>(summary.probe?.capabilities.blocked ?? null);
82
+ const caps = summary.probe?.capabilities;
83
+ // ONE derivation, shared with the tests: the header chip, the sentence under it
84
+ // and the action that fixes it all read the same state. `problem` is folded in
85
+ // as the probe's live refusal, so pressing Check status updates the SAME path
86
+ // a shipped refusal travels — a second branch here is how one card came to say
87
+ // "ready" beside a banner quoting an error.
88
+ const status = harnessStatus(
89
+ problem ? { ...summary, probe: summary.probe && {
90
+ ...summary.probe,
91
+ capabilities: { ...summary.probe.capabilities, blocked: problem },
92
+ } } : summary,
93
+ );
94
+ const blocked = status.state !== 'ready' && status.state !== 'unprobed';
95
+
96
+ const check = async () => {
97
+ setProbing(true);
98
+ try {
99
+ const reason = await onProbe(summary.id);
100
+ setProblem(reason);
101
+ } finally {
102
+ setProbing(false);
103
+ }
104
+ };
105
+
106
+ return (
107
+ <section className="rounded-xl border border-ink/10 bg-paper">
108
+ <header className="flex items-center justify-between gap-3 border-b border-ink/10 px-4 py-3">
109
+ <div className="flex min-w-0 items-center gap-2">
110
+ <HarnessGlyph harness={summary.id} size={18} />
111
+ <div className="min-w-0">
112
+ <div className="truncate text-sm font-medium text-ink">{summary.label}</div>
113
+ <div className="text-[11px] text-ink/45">
114
+ {summary.transport === 'rpc' ? 'Native RPC (always available)' : 'ACP over stdio'}
115
+ {caps?.agentVersion ? ` · ${caps.agentVersion}` : ''}
116
+ </div>
117
+ </div>
118
+ </div>
119
+ <div className="flex shrink-0 items-center gap-2">
120
+ {/* The chip says WHICH state: `not installed`, `needs setup`, `ready`,
121
+ `not probed`, `built in`. A single word `blocked` covered four
122
+ different fixes, so it told the reader nothing to act on. */}
123
+ <span
124
+ className="inline-flex items-center gap-1 text-[11px] text-ink/60"
125
+ title={status.detail ?? undefined}
126
+ >
127
+ <StatusMark state={status.state} />
128
+ {status.label}
129
+ </span>
130
+ <button
131
+ type="button"
132
+ onClick={() => void check()}
133
+ // A built-in transport has no agent to ask, and a missing binary has
134
+ // nothing to answer: the button is disabled with the REASON in its
135
+ // title, never silently inert.
136
+ disabled={probing || busy || !summary.canLaunch || summary.builtIn}
137
+ title={
138
+ summary.builtIn
139
+ ? 'Nothing to probe: Kabmo runs this transport itself'
140
+ : !summary.canLaunch
141
+ ? status.detail ?? 'Not installed'
142
+ : 'Spawn this harness once and read what it reports'
143
+ }
144
+ className="cursor-pointer rounded-md border border-ink/20 px-2 py-1 text-[11px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50"
145
+ >
146
+ {probing ? <Loader2 size={12} className="animate-spin" /> : 'Check status'}
147
+ </button>
148
+ {/* The roster switch, on the page that describes this agent. The
149
+ built-in transport has none: a build with it off could run no chat. */}
150
+ {onSetEnabled && !summary.builtIn && (
151
+ <button
152
+ type="button"
153
+ role="switch"
154
+ aria-checked={summary.enabled}
155
+ aria-label={`${summary.enabled ? 'Disable' : 'Enable'} ${summary.label}`}
156
+ disabled={probing || busy}
157
+ onClick={() => onSetEnabled(!summary.enabled)}
158
+ title={
159
+ summary.enabled
160
+ ? 'Turn off — hides this page and removes the agent from the model picker'
161
+ : 'Turn on — probes it once and adds its settings page'
162
+ }
163
+ className={`relative h-4 w-8 shrink-0 rounded-full transition-colors disabled:opacity-40 ${
164
+ summary.enabled ? 'bg-ink/70' : 'bg-ink/20'
165
+ }`}
166
+ >
167
+ <span
168
+ className={`absolute top-0.5 h-3 w-3 rounded-full bg-canvas transition-all ${
169
+ summary.enabled ? 'left-[18px]' : 'left-0.5'
170
+ }`}
171
+ />
172
+ </button>
173
+ )}
174
+ </div>
175
+ </header>
176
+
177
+ <div className="px-4 py-3 text-xs">
178
+ {/* The concrete sentence, always — never a bare state word. */}
179
+ <div
180
+ className={`mb-3 rounded-lg border p-2.5 text-[11px] ${
181
+ blocked ? 'border-ink/15 bg-ink/[0.04] text-ink/75' : 'border-ink/10 bg-ink/[0.02] text-ink/55'
182
+ }`}
183
+ >
184
+ <div className={blocked ? 'font-medium text-ink' : ''}>{status.detail}</div>
185
+ {/* The install line belongs to a missing binary only: telling a signed-out
186
+ agent to install a package it already has is a wrong instruction. */}
187
+ {status.state === 'not-installed' && install && (
188
+ <div className="mt-1 font-mono text-[10px] text-ink/50">{install}</div>
189
+ )}
190
+ </div>
191
+ {summary.note && <p className="mb-3 text-[11px] leading-relaxed text-ink/45">{summary.note}</p>}
192
+
193
+ <div className="grid gap-x-6 sm:grid-cols-2">
194
+ <div>
195
+ <div className="mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40">Session</div>
196
+ <Capability label="Load / resume history" value={caps ? caps.loadSession : null} />
197
+ <Capability label="List sessions" value={caps ? caps.listSessions : null} />
198
+ <Capability label="Fork" value={caps ? caps.forkSession : null} />
199
+ <Capability label="Delete" value={caps ? caps.deleteSession : null} />
200
+ </div>
201
+ <div>
202
+ <div className="mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40">Composer</div>
203
+ <Capability
204
+ label="Models offered"
205
+ value={caps ? caps.configModel > 0 : null}
206
+ detail={caps && caps.configModel > 0 ? `${caps.configModel} entries` : undefined}
207
+ />
208
+ <Capability
209
+ label="Thinking levels"
210
+ value={caps ? caps.configThinking > 0 : null}
211
+ detail={caps && caps.configThinking > 0 ? `${caps.configThinking} levels` : undefined}
212
+ />
213
+ <Capability
214
+ label="Mode selector"
215
+ value={caps ? caps.configMode > 0 : null}
216
+ detail={caps && caps.modeValues.length > 0 ? caps.modeValues.join(' · ') : undefined}
217
+ />
218
+ <Capability
219
+ label="Mid-turn steering"
220
+ value={caps ? caps.steerMode !== null : null}
221
+ detail={caps?.steerMode === 'follow-up' ? 'queue only' : undefined}
222
+ />
223
+ </div>
224
+ </div>
225
+
226
+ {/* The config form is per-harness and only for a launchable one: a
227
+ built-in transport has nothing to launch, and an uninstalled harness
228
+ still benefits from a command override. */}
229
+ {onSaveConfig && !summary.builtIn && (
230
+ <HarnessConfigForm
231
+ summary={summary}
232
+ config={config ?? { ...EMPTY_HARNESS_CONFIG }}
233
+ onSave={(next) => onSaveConfig(summary.id, next)}
234
+ />
235
+ )}
236
+
237
+ {/* Providers, drawn at the level the harness supports. An env-style
238
+ harness saves into the SAME config form's env block, so the two
239
+ surfaces cannot disagree about what the spawn reads. */}
240
+ {providerSupport && !summary.builtIn && (
241
+ <HarnessProviderPanel
242
+ support={providerSupport}
243
+ {...(onSaveConfig
244
+ ? { onSaveEnv: (env: string) => onSaveConfig(summary.id, { ...(config ?? EMPTY_HARNESS_CONFIG), env }) }
245
+ : {})}
246
+ {...(onImportProvider
247
+ ? { onImport: (sourceId: string, entry: HarnessProviderSupport['importable'][number]) => onImportProvider(summary.id, sourceId, entry) }
248
+ : {})}
249
+ {...(onAddProvider
250
+ ? { onAddProvider: (input: AddProviderInput) => onAddProvider(summary.id, input) }
251
+ : {})}
252
+ />
253
+ )}
254
+
255
+ <div className="mt-1 grid gap-x-6 sm:grid-cols-2">
256
+ <Capability
257
+ label="Usage / cost reported"
258
+ value={caps ? caps.hasUsage : null}
259
+ detail={caps && !caps.hasUsage ? 'usage panel shows “not reported”' : undefined}
260
+ />
261
+ <Capability label="Plan updates" value={caps ? caps.hasPlan : null} />
262
+ </div>
263
+ </div>
264
+ </section>
265
+ );
266
+ }
267
+
268
+ /**
269
+ * The state's mark. Shape, not only colour: a reader who cannot separate two
270
+ * low-contrast tones still sees a filled dot, a package with a slash, a warning
271
+ * triangle or an empty ring.
272
+ */
273
+ function StatusMark({ state }: { state: HarnessState }) {
274
+ if (state === 'ready') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-success" />;
275
+ if (state === 'not-installed') return <PackageX size={12} className="text-ink/55" />;
276
+ if (state === 'needs-setup') return <AlertCircle size={12} className="text-ink/60" />;
277
+ return <CircleDashed size={12} className="text-ink/40" />;
278
+ }
@@ -0,0 +1,195 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The rows of "import a custom provider from another harness".
8
+ *
9
+ * Split from the panel so the registry card and the environment card draw the
10
+ * SAME list: one row shape, one refusal rendering, one evidence block. A second
11
+ * copy is how the two surfaces start disagreeing about what a provider is.
12
+ *
13
+ * A row states the source's declared protocol and what THIS agent accepts — and
14
+ * deliberately NOT a verdict, because whether an endpoint can land here is a fact
15
+ * about the HOST that only the import's probe has. Measured: `kenari` declares
16
+ * Chat Completions and works in Claude Code through Anthropic Messages.
17
+ */
18
+
19
+ import { useState } from 'preact/hooks';
20
+ import { Download, Loader2 } from 'lucide-preact';
21
+ import type { HarnessImportOutcome, HarnessProviderSupport } from '@/shared/types/harness';
22
+ import { PROTOCOL_LABELS } from '@/shared/lib/harness/dialects';
23
+
24
+ export type ImportRow = HarnessProviderSupport['importable'][number];
25
+
26
+ /** What the row's source declares, and what this agent can take. */
27
+ function targetLabel(entry: ImportRow, support: HarnessProviderSupport): string {
28
+ const source = entry.protocol ? PROTOCOL_LABELS[entry.protocol] : entry.dialect ?? 'unknown dialect';
29
+ if (support.protocols.length === 0) return `${source} — this agent takes no providers`;
30
+ return `${source} · this agent takes ${support.protocols.map((p) => PROTOCOL_LABELS[p]).join(' · ')}`;
31
+ }
32
+
33
+ /** One importable row: the source's own name, its models, and its credential state. */
34
+ function ImportRowView({
35
+ entry, support, onImport, busy,
36
+ }: {
37
+ entry: ImportRow;
38
+ support: HarnessProviderSupport;
39
+ onImport: () => void;
40
+ busy: boolean;
41
+ }) {
42
+ return (
43
+ <div className="flex items-center justify-between gap-2 border-b border-ink/5 py-1.5 last:border-0">
44
+ <div className="min-w-0">
45
+ <div className="truncate text-[11px] font-medium text-ink">
46
+ {entry.name}
47
+ <span className="ml-1.5 font-mono text-[9px] uppercase tracking-wider text-ink/35">{entry.source}</span>
48
+ </div>
49
+ <div className="truncate font-mono text-[10px] text-ink/45">
50
+ {entry.id}
51
+ {entry.models.length > 0 ? ` · ${entry.models.length} models` : ' · no models listed'}
52
+ {entry.baseUrl ? ` · ${entry.baseUrl}` : ''}
53
+ </div>
54
+ <div className="truncate text-[10px] text-ink/40">{targetLabel(entry, support)}</div>
55
+ </div>
56
+ <div className="flex shrink-0 items-center gap-1.5">
57
+ {/* State, not a key: `hasKey` is the source's boolean and the value never
58
+ reaches the browser. */}
59
+ <span className="text-[10px] text-ink/40">{entry.hasKey ? 'key stored' : 'no key'}</span>
60
+ <button
61
+ type="button"
62
+ onClick={onImport}
63
+ disabled={busy}
64
+ title="Probes the endpoint, picks a protocol this agent speaks, and copies the credential from the source"
65
+ className="inline-flex cursor-pointer items-center gap-1 rounded-md border border-ink/20 px-2 py-0.5 text-[10px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50"
66
+ >
67
+ {busy ? <Loader2 size={10} className="animate-spin" /> : <Download size={10} />} Import
68
+ </button>
69
+ </div>
70
+ </div>
71
+ );
72
+ }
73
+
74
+ export function ImportSection({
75
+ support, onImport,
76
+ }: {
77
+ support: HarnessProviderSupport;
78
+ onImport: (sourceId: string, entry: ImportRow) => Promise<HarnessImportOutcome>;
79
+ }) {
80
+ const [busyId, setBusyId] = useState<string | null>(null);
81
+ const [outcome, setOutcome] = useState<{ id: string; result: HarnessImportOutcome } | null>(null);
82
+ const importable = support.importable;
83
+
84
+ if (importable.length === 0) return null;
85
+
86
+ return (
87
+ <div className="mt-3 space-y-1 border-t border-ink/10 pt-3">
88
+ <div className="flex items-center justify-between">
89
+ <span className="text-[10px] font-medium text-ink/50">Import from another harness</span>
90
+ <span className="text-[10px] text-ink/35">{importable.length} custom</span>
91
+ </div>
92
+ {importable.map((entry) => (
93
+ <ImportRowView
94
+ key={`${entry.source}:${entry.id}`}
95
+ entry={entry}
96
+ support={support}
97
+ busy={busyId === entry.id}
98
+ onImport={() => {
99
+ setBusyId(entry.id);
100
+ void onImport(entry.id, entry)
101
+ .then((result) => setOutcome({ id: entry.id, result }))
102
+ .finally(() => setBusyId(null));
103
+ }}
104
+ />
105
+ ))}
106
+ {outcome && (
107
+ <div className="mt-1 space-y-0.5">
108
+ <p className={`text-[10px] ${outcome.result.problem ? 'text-ink/70' : 'text-ink/55'}`}>
109
+ {outcome.result.problem
110
+ ? outcome.result.problem
111
+ : `Copied ${outcome.id} into ${support.fileLabel} — restart the agent so it re-reads the file.`}
112
+ </p>
113
+ {/* The evidence, not a bare "copied": which protocol the probe chose and
114
+ which variables were set are the facts a reader can check. */}
115
+ {outcome.result.detail && (
116
+ <p className="font-mono text-[9px] leading-relaxed text-ink/40">{outcome.result.detail}</p>
117
+ )}
118
+ </div>
119
+ )}
120
+ <p className="text-[10px] text-ink/35">
121
+ Only providers you registered yourself can be copied; a provider the agent ships is its own.
122
+ </p>
123
+ </div>
124
+ );
125
+ }
126
+
127
+ /**
128
+ * What this harness ALREADY holds, from its own registry.
129
+ *
130
+ * Without it an Add that wrote correctly and an Add that silently wrote nothing
131
+ * render the same card — the reason the import list alone was not enough. Rows
132
+ * are the custom ones only, because a vendor entry with an endpoint override is
133
+ * the agent's own provider rather than something Kabmo added.
134
+ */
135
+ export function ConfiguredList({ support }: { support: HarnessProviderSupport }) {
136
+ const configured = support.configured;
137
+ return (
138
+ <div className="space-y-1">
139
+ <div className="flex items-center justify-between">
140
+ <span className="text-[10px] font-medium text-ink/50">In this agent's registry</span>
141
+ <span className="text-[10px] text-ink/35">{configured.length} custom</span>
142
+ </div>
143
+ {configured.length === 0 ? (
144
+ <p className="text-[10px] text-ink/40">
145
+ No provider of your own yet. Add one below, or copy one from another harness.
146
+ </p>
147
+ ) : (
148
+ configured.map((entry) => (
149
+ <div key={entry.id} className="flex items-center justify-between gap-2 border-b border-ink/5 py-1.5 last:border-0">
150
+ <div className="min-w-0">
151
+ <div className="truncate text-[11px] font-medium text-ink">{entry.name}</div>
152
+ <div className="truncate font-mono text-[10px] text-ink/45">
153
+ {entry.id}
154
+ {entry.models.length > 0 ? ` · ${entry.models.length} models` : ' · no models listed'}
155
+ {entry.baseUrl ? ` · ${entry.baseUrl}` : ''}
156
+ </div>
157
+ <div className="truncate text-[10px] text-ink/40">{targetLabel(entry, support)}</div>
158
+ </div>
159
+ <span className="shrink-0 text-[10px] text-ink/40">{entry.hasKey ? 'key stored' : 'no key'}</span>
160
+ </div>
161
+ ))
162
+ )}
163
+ </div>
164
+ );
165
+ }
166
+
167
+ /**
168
+ * The same rows with the action unavailable — a registry Kabmo may READ but has
169
+ * no writer for (`command-code` keeps its own `providers.json`).
170
+ */
171
+ export function ReadOnlyRows({ support }: { support: HarnessProviderSupport }) {
172
+ return (
173
+ <div className="space-y-1">
174
+ <div className="text-[10px] font-medium text-ink/50">Import from another harness</div>
175
+ {support.importable.map((entry) => (
176
+ <div key={`${entry.source}:${entry.id}`} className="border-b border-ink/5 py-1.5 last:border-0">
177
+ <div className="truncate text-[11px] font-medium text-ink">
178
+ {entry.name}
179
+ <span className="ml-1.5 font-mono text-[9px] uppercase tracking-wider text-ink/35">{entry.source}</span>
180
+ </div>
181
+ <div className="truncate font-mono text-[10px] text-ink/45">
182
+ {entry.id}
183
+ {entry.models.length > 0 ? ` · ${entry.models.length} models` : ' · no models listed'}
184
+ {entry.baseUrl ? ` · ${entry.baseUrl}` : ''}
185
+ </div>
186
+ <div className="truncate text-[10px] text-ink/40">{targetLabel(entry, support)}</div>
187
+ <div className="text-[10px] text-ink/35">{entry.hasKey ? 'key stored' : 'no key'}</div>
188
+ </div>
189
+ ))}
190
+ <p className="text-[10px] text-ink/40">
191
+ This file has no writer in this build; the rows show what the sources hold.
192
+ </p>
193
+ </div>
194
+ );
195
+ }