@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,199 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * WHERE each harness keeps its providers — the facts the settings page writes by.
8
+ *
9
+ * The first version of this table GUESSED, and was wrong three times over. These
10
+ * cases exist so the corrections cannot be undone:
11
+ *
12
+ * - **`opencode2` was never a second registry** — it read the same
13
+ * `opencode.json` as 1.x, verified by writing a provider and watching both
14
+ * binaries list it. The entry is now RETIRED outright: the preview became a shim
15
+ * for `opencode`, so there is one binary and one tab.
16
+ * - **codex HAS a registry.** Its own reference documents
17
+ * `[model_providers.<id>]` with `base_url`, `env_key` and `wire_api`; calling it
18
+ * "no registry" sent the reader to the wrong page.
19
+ * - **pi, kimi and qwen have one each**, in three different formats — which is
20
+ * the work, not a detail to smooth over.
21
+ *
22
+ * The credential rule is the other half: two formats (`codex`, `qwen`) store the
23
+ * NAME of an environment variable, never the secret. A form that wrote a key there
24
+ * would put a credential in a file the vendor's docs keep it out of.
25
+ */
26
+
27
+ import { describe, expect, test } from 'bun:test';
28
+ import {
29
+ credentialFieldLabel,
30
+ credentialIsEnvName,
31
+ dialectChoices,
32
+ providerEnv,
33
+ providerLevel,
34
+ registryLabel,
35
+ supportsProviderEditor,
36
+ } from '@/shared/lib/harness/providers';
37
+ import { HARNESS_PROVIDER_FACTS, managesProviders, providerFacts } from '@/shared/lib/harness/provider-facts';
38
+ import { HARNESS_IDS } from '@/shared/lib/harness/catalog';
39
+
40
+ /** Harnesses whose registry Kabmo may WRITE, with the format it writes. */
41
+ const WRITABLE: Record<string, string> = {
42
+ 'omp-rpc': 'yaml-providers',
43
+ 'omp-acp': 'yaml-providers',
44
+ opencode: 'json-provider',
45
+ codex: 'toml-model-providers',
46
+ pi: 'json-providers',
47
+ kimi: 'toml-providers',
48
+ qwen: 'json-model-providers',
49
+ zcode: 'zcode-provider-rules',
50
+ };
51
+
52
+ describe('the measured registry table', () => {
53
+ test('every harness this build lists has facts', () => {
54
+ for (const id of HARNESS_IDS) {
55
+ expect(HARNESS_PROVIDER_FACTS[id], `no provider facts for ${id}`).toBeDefined();
56
+ }
57
+ });
58
+
59
+ test('a retired harness has no facts at all', () => {
60
+ // `opencode2` was a second catalog entry while the 2.x preview was its own
61
+ // binary. It is now a shim that execs `opencode`, so the entry is gone — and a
62
+ // lookup must say "unknown" rather than borrow the neighbour's registry.
63
+ expect(providerFacts('opencode2').registry.kind).toBe('none');
64
+ expect(providerFacts('opencode').registry.kind).toBe('json-provider');
65
+ });
66
+
67
+ test('omp and its ACP transport name the same models.yml', () => {
68
+ expect(providerFacts('omp-acp').registry.file).toBe(providerFacts('omp-rpc').registry.file);
69
+ expect(providerFacts('omp-rpc').registry.kind).toBe('yaml-providers');
70
+ });
71
+
72
+ test('the writable harnesses are exactly the ones with a format writer', () => {
73
+ for (const [id, kind] of Object.entries(WRITABLE)) {
74
+ expect(providerFacts(id).registry.kind).toBe(kind as never);
75
+ expect(providerFacts(id).registry.writable).toBe(true);
76
+ expect(managesProviders(id)).toBe(true);
77
+ expect(supportsProviderEditor(id)).toBe(true);
78
+ }
79
+ });
80
+
81
+ test('minimax has a registry that belongs to the AGENT', () => {
82
+ // A registry exists — `mcode` writes it — so "nothing to edit" would be
83
+ // false, and writing it from outside is how a working install stops signing in.
84
+ const registry = providerFacts('minimax').registry;
85
+ expect(registry.kind).toBe('agent-managed');
86
+ expect(registry.writable).toBe(false);
87
+ expect(managesProviders('minimax')).toBe(false);
88
+ });
89
+
90
+ test('zcode writes personal providers beside the app, never the app config', () => {
91
+ // 3.12+ stores user-added providers in `provider_config.json`; the legacy
92
+ // `config.json` map is the desktop app's and keeps its credentials. Writing
93
+ // THAT file is how a signed-in install stops signing in.
94
+ const registry = providerFacts('zcode').registry;
95
+ expect(registry.kind).toBe('zcode-provider-rules');
96
+ expect(registry.file).toBe('.zcode/v2/provider_config.json');
97
+ expect(registry.file).not.toBe('.zcode/v2/config.json');
98
+ expect(registry.pointer).toBe('config.providerConfigRules.providerRules');
99
+ expect(registry.baseUrlField).toBe('config.api.baseUrl');
100
+ expect(registry.apiKeyField).toBe('config.access.apiKey');
101
+ expect(registry.dialectField).toBe('config.api.type');
102
+ expect(registry.writable).toBe(true);
103
+ expect(managesProviders('zcode')).toBe(true);
104
+ });
105
+
106
+ test('the env-only harnesses keep their vendor variable names', () => {
107
+ // The alias table is asserted in `providerEnv` below; this is the endpoint
108
+ // and key each vendor documents.
109
+ expect(providerFacts('claude').env).toMatchObject({
110
+ baseUrl: 'ANTHROPIC_BASE_URL', apiKey: 'ANTHROPIC_AUTH_TOKEN', model: 'ANTHROPIC_MODEL',
111
+ });
112
+ expect(providerFacts('antigravity').env).toEqual({
113
+ baseUrl: 'GOOGLE_GEMINI_BASE_URL', apiKey: 'GEMINI_API_KEY',
114
+ });
115
+ // Both REPLACE the vendor rather than adding beside it.
116
+ expect(providerFacts('claude').createsChoice).toBe(false);
117
+ expect(providerFacts('antigravity').createsChoice).toBe(false);
118
+ expect(providerLevel('claude')).toBe('environment');
119
+ });
120
+
121
+ test('every writable registry states the field names a writer must use', () => {
122
+ for (const id of Object.keys(WRITABLE)) {
123
+ const registry = providerFacts(id).registry;
124
+ expect(registry.pointer, `${id} has no pointer`).toBeTruthy();
125
+ expect(registry.baseUrlField, `${id} has no base-URL field`).toBeTruthy();
126
+ expect(registry.apiKeyField, `${id} has no credential field`).toBeTruthy();
127
+ }
128
+ });
129
+
130
+ test('an unknown harness degrades to "nothing to offer"', () => {
131
+ expect(providerLevel('some-future-agent')).toBe('none');
132
+ expect(supportsProviderEditor('some-future-agent')).toBe(false);
133
+ expect(managesProviders(null)).toBe(false);
134
+ });
135
+ });
136
+
137
+ describe('credential fields that hold a NAME', () => {
138
+ test('codex and qwen are told apart from the ones that hold the secret', () => {
139
+ expect(credentialIsEnvName('codex')).toBe(true);
140
+ expect(credentialIsEnvName('qwen')).toBe(true);
141
+ expect(credentialFieldLabel('codex')).toContain('variable NAME');
142
+ // The others store the value itself.
143
+ expect(credentialIsEnvName('opencode')).toBe(false);
144
+ expect(credentialIsEnvName('omp-rpc')).toBe(false);
145
+ });
146
+ });
147
+
148
+ describe('labels a reader can check against the vendor docs', () => {
149
+ test('each format is named the way its file is named', () => {
150
+ expect(registryLabel('omp-rpc')).toBe('models.yml (omp)');
151
+ expect(registryLabel('opencode')).toBe('opencode.json');
152
+ expect(registryLabel('codex')).toBe('config.toml (codex)');
153
+ expect(registryLabel('pi')).toBe('models.json (pi)');
154
+ expect(registryLabel('kimi')).toBe('config.toml (kimi)');
155
+ expect(registryLabel('qwen')).toBe('settings.json (qwen)');
156
+ expect(registryLabel('claude')).toBe('environment variables');
157
+ });
158
+
159
+ test('the dialect vocabulary is the one that format documents', () => {
160
+ // A writer must not invent a value the agent rejects.
161
+ expect(dialectChoices('json-provider').map((d) => d.value)).toContain('@ai-sdk/anthropic');
162
+ expect(dialectChoices('toml-model-providers').map((d) => d.value)).toEqual(['chat', 'responses']);
163
+ expect(dialectChoices('toml-providers').map((d) => d.value)).toContain('openai_legacy');
164
+ // qwen routes by protocol id, so it has no dialect field of its own.
165
+ expect(dialectChoices('json-model-providers')).toEqual([]);
166
+ // ZCode documents exactly these three wire types; Gemini has no route there.
167
+ expect(dialectChoices('zcode-provider-rules').map((d) => d.value)).toEqual([
168
+ 'anthropic-messages', 'openai-chat-completions', 'openai-responses',
169
+ ]);
170
+ });
171
+ });
172
+
173
+ describe('providerEnv', () => {
174
+ test('a provider becomes the vendor’s own variables', () => {
175
+ expect(providerEnv('claude', { baseUrl: 'https://gw', apiKey: 'sk-1', model: 'claude-sonnet-5' }))
176
+ .toEqual({ ANTHROPIC_BASE_URL: 'https://gw', ANTHROPIC_AUTH_TOKEN: 'sk-1', ANTHROPIC_MODEL: 'claude-sonnet-5' });
177
+ });
178
+
179
+ test('claude pins every picker alias, so a gateway id can replace the vendor’s', () => {
180
+ // Measured: `--model sonnet` against a gateway listing `claude-sonnet-5-5`
181
+ // answered `400 model not found: sonnet` until the alias variable existed.
182
+ expect(providerFacts('claude').env?.modelAliases).toEqual([
183
+ { family: 'opus', env: 'ANTHROPIC_DEFAULT_OPUS_MODEL' },
184
+ { family: 'sonnet', env: 'ANTHROPIC_DEFAULT_SONNET_MODEL' },
185
+ { family: 'haiku', env: 'ANTHROPIC_DEFAULT_HAIKU_MODEL' },
186
+ { family: 'fable', env: 'ANTHROPIC_DEFAULT_FABLE_MODEL' },
187
+ ]);
188
+ });
189
+
190
+ test('a blank field writes no variable at all', () => {
191
+ // An empty env var is a real thing to set, so the form must not do it by
192
+ // accident.
193
+ expect(providerEnv('claude', { baseUrl: ' ', apiKey: 'sk-1' })).toEqual({ ANTHROPIC_AUTH_TOKEN: 'sk-1' });
194
+ });
195
+
196
+ test('a registry harness has no env contract', () => {
197
+ expect(providerEnv('opencode', { baseUrl: 'x', apiKey: 'y' })).toEqual({});
198
+ });
199
+ });
@@ -0,0 +1,349 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Where each harness keeps its providers, MEASURED — not assumed.
8
+ *
9
+ * Every entry below names a file (or an env contract) that was checked on a real
10
+ * install or taken from the vendor's own configuration reference. The first
11
+ * version of this table guessed, and guessed wrong in three places:
12
+ *
13
+ * - `opencode2` was given its own `opencode2.json`. Measured: the 2.x binary
14
+ * reads `$XDG_CONFIG_HOME/opencode/opencode.json` — the SAME file 1.x reads.
15
+ * A provider added to one appears in both, so the "two registries" idea was a
16
+ * fiction that would have split one real file into two imaginary ones.
17
+ * - `codex` was called `configurable` (no registry). Its own reference documents
18
+ * `[model_providers.<id>]` in `~/.codex/config.toml`, with `name`, `base_url`,
19
+ * `env_key`, `wire_api` and `http_headers`. It is a full registry.
20
+ * - `pi`, `kimi`, `qwen`, `minimax` and `dsh` were lumped in as "no registry".
21
+ * Each has one: `models.json`, `~/.kimi-code/config.toml` `[providers.<id>]`,
22
+ * `settings.json` `modelProviders`, BYOK providers, and a Cordis profile patch.
23
+ *
24
+ * Formats differ, and that difference is the work — not a detail to smooth over:
25
+ *
26
+ * | Harness | File | Shape |
27
+ * |---|---|---|
28
+ * | omp | `~/.omp/agent/models.yml` | `providers.<slug>` → `{baseUrl, apiKey, api, models: [{id, name, contextWindow, cost}]}` |
29
+ * | opencode | `$XDG_CONFIG_HOME/opencode/opencode.json` | `provider.<id>` → `{npm, name, options:{baseURL, apiKey}, models: {<id>: {name}}}` |
30
+ * | codex | `~/.codex/config.toml` | `[model_providers.<id>]` → `{name, base_url, env_key, wire_api, http_headers}` |
31
+ * | pi | `~/.pi/agent/models.json` | `providers.<id>` → `{name, baseUrl, api, apiKey, models: [{id, name, contextWindow, cost}]}` |
32
+ * | kimi | `~/.kimi-code/config.toml` | `[providers.<id>]` → `{type, base_url, api_key, custom_headers}` |
33
+ * | qwen | `~/.qwen/settings.json` | `modelProviders.<protocol>` → array of `{id, baseUrl, envKey}` |
34
+ * | minimax | its own BYOK store, written by `mcode` | not a file Kabmo may edit |
35
+ * | claude | env only | `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` |
36
+ * | antigravity | env only | `GOOGLE_GEMINI_BASE_URL`, `GEMINI_API_KEY` |
37
+ * | zcode | `~/.zcode/v2/provider_config.json` | `config.providerConfigRules.providerRules` (3.12+ personal providers) |
38
+ * | cursor, dsh | none Kabmo can write | the launch line and its env |
39
+ *
40
+ * A file Kabmo may READ but must not WRITE is marked `readOnly`: minimax keeps its
41
+ * BYOK entries behind `mcode`'s own writer, and rewriting that store from outside
42
+ * is how a working agent stops signing in.
43
+ */
44
+
45
+ import type { HarnessId } from '@/shared/lib/harness/catalog';
46
+ import type { CanonicalProtocol } from '@/shared/lib/harness/dialects';
47
+
48
+ /** How a harness stores providers. */
49
+ export type ProviderRegistryKind =
50
+ /** A YAML document with a `providers` map (omp). */
51
+ | 'yaml-providers'
52
+ /** A JSON document with a `provider` map (opencode). */
53
+ | 'json-provider'
54
+ /** A TOML document with a `model_providers` table (codex). */
55
+ | 'toml-model-providers'
56
+ /** A JSON document with a `providers` map (pi). */
57
+ | 'json-providers'
58
+ /** A TOML document with a `providers` table (kimi). */
59
+ | 'toml-providers'
60
+ /** A JSON settings document with `modelProviders` (qwen). */
61
+ | 'json-model-providers'
62
+ /** ZCode's personal-provider rules: arrays under `config.providerConfigRules`
63
+ * and `config.modelConfigRules` (3.12+). */
64
+ | 'zcode-provider-rules'
65
+ /** No provider registry this build writes; an env contract instead. */
66
+ | 'env'
67
+ /** A registry that exists but belongs to the agent's own writer. */
68
+ | 'agent-managed'
69
+ /** Nothing to offer. */
70
+ | 'none';
71
+
72
+ export interface ProviderRegistry {
73
+ kind: ProviderRegistryKind;
74
+ /** Path relative to the user's home, or null when there is no file. */
75
+ file: string | null;
76
+ /** Dot-path the providers live under, for the editors and the reader. */
77
+ pointer: string;
78
+ /** False when Kabmo may read the entries but must not write them. */
79
+ writable: boolean;
80
+ /** The base-URL field's name in THIS format, so a writer does not guess. */
81
+ baseUrlField: string | null;
82
+ /** The API-key field's name in this format. */
83
+ apiKeyField: string | null;
84
+ /** The dialect/SDK field's name, when the format has one. */
85
+ dialectField?: string;
86
+ /** How this format spells a model entry, for the model list. */
87
+ modelsField: string | null;
88
+ /**
89
+ * Provider ids this registry ships itself. An entry under one of these is the
90
+ * VENDOR's provider with an endpoint override — not a custom provider — and an
91
+ * import must never offer or write one: copying `anthropic` out of omp into
92
+ * codex would replace the vendor entry instead of adding a gateway.
93
+ */
94
+ bundledIds?: readonly string[];
95
+ /**
96
+ * False when this registry writes a MODEL TABLE beside the provider (kimi's
97
+ * `[models.<alias>]`, codex's `model`), so a provider alone serves nothing.
98
+ * The writer then emits the model rows too instead of leaving a husk.
99
+ */
100
+ modelsAreRows?: boolean;
101
+ }
102
+
103
+ /**
104
+ * One picker alias a vendor SDK resolves from the environment. Claude Code's
105
+ * `opus`/`sonnet`/`haiku`/`fable` aliases resolve to ids the VENDOR ships
106
+ * unless `ANTHROPIC_DEFAULT_<FAMILY>_MODEL` pins them; a gateway that lists
107
+ * only its own ids answers the vendor ids with `400 model not found`.
108
+ */
109
+ export interface EnvModelAlias {
110
+ family: string;
111
+ env: string;
112
+ }
113
+
114
+ /** The env names an `environment` harness reads, in the order its docs list. */
115
+ export interface EnvProviderContract {
116
+ baseUrl: string;
117
+ apiKey: string;
118
+ model?: string;
119
+ modelAliases?: readonly EnvModelAlias[];
120
+ }
121
+
122
+ export interface HarnessProviderFacts {
123
+ registry: ProviderRegistry;
124
+ /** Present only for an `env` harness. */
125
+ env?: EnvProviderContract;
126
+ /**
127
+ * The single wire protocol an `environment` harness's SDK speaks. Claude Code
128
+ * is Anthropic Messages and Antigravity is Google GenAI — an endpoint that
129
+ * speaks neither cannot be carried there, and an import has to say so instead
130
+ * of writing a URL the agent will fail every request against.
131
+ */
132
+ envProtocol?: CanonicalProtocol;
133
+ /** True when adding a provider ADDS a choice; false when it replaces the
134
+ * agent's own endpoint (Claude Code, Antigravity). */
135
+ createsChoice: boolean;
136
+ /** Harnesses whose entries this one can import, because the fields line up. */
137
+ importFrom: readonly HarnessId[];
138
+ /** One sentence for the settings card, in the vendor's own vocabulary. */
139
+ summary: string;
140
+ }
141
+
142
+ /**
143
+ * The table. A harness missing here is `none` — and `providerFacts` says so
144
+ * rather than defaulting to something that would offer an editor.
145
+ */
146
+ export const HARNESS_PROVIDER_FACTS: Readonly<Partial<Record<HarnessId, HarnessProviderFacts>>> = {
147
+ 'omp-rpc': {
148
+ registry: {
149
+ kind: 'yaml-providers', file: '.omp/agent/models.yml', pointer: 'providers',
150
+ writable: true, baseUrlField: 'baseUrl', apiKeyField: 'apiKey',
151
+ dialectField: 'api', modelsField: 'models',
152
+ },
153
+ createsChoice: true,
154
+ importFrom: ['opencode', 'codex', 'pi', 'kimi', 'qwen'],
155
+ summary: 'omp keeps providers in models.yml. Providers added here are added, not substituted.',
156
+ },
157
+ 'omp-acp': {
158
+ registry: {
159
+ kind: 'yaml-providers', file: '.omp/agent/models.yml', pointer: 'providers',
160
+ writable: true, baseUrlField: 'baseUrl', apiKeyField: 'apiKey',
161
+ dialectField: 'api', modelsField: 'models',
162
+ },
163
+ createsChoice: true,
164
+ importFrom: ['opencode', 'codex', 'pi', 'kimi', 'qwen'],
165
+ summary: 'The same models.yml omp over RPC uses — one registry, whichever transport runs the chat.',
166
+ },
167
+ opencode: {
168
+ registry: {
169
+ kind: 'json-provider', file: '.config/opencode/opencode.json', pointer: 'provider',
170
+ writable: true, baseUrlField: 'options.baseURL', apiKeyField: 'options.apiKey',
171
+ dialectField: 'npm', modelsField: 'models',
172
+ },
173
+ createsChoice: true,
174
+ importFrom: ['omp-rpc', 'codex', 'pi', 'kimi', 'qwen'],
175
+ summary: 'opencode reads providers from opencode.json, with an npm SDK per provider and a model map. Added beside the vendored ones.',
176
+ },
177
+ codex: {
178
+ registry: {
179
+ kind: 'toml-model-providers', file: '.codex/config.toml', pointer: 'model_providers',
180
+ writable: true, baseUrlField: 'base_url', apiKeyField: 'env_key',
181
+ dialectField: 'wire_api', modelsField: null,
182
+ // Built-ins codex reserves: its own reference says they cannot be
183
+ // overridden, so an import under one of these ids is refused by codex.
184
+ bundledIds: ['openai', 'ollama', 'lmstudio', 'amazon-bedrock', 'amazon-bedrock-runtime', 'gcp'],
185
+ },
186
+ createsChoice: true,
187
+ importFrom: ['omp-rpc', 'opencode', 'pi', 'kimi'],
188
+ summary: 'codex defines providers in config.toml under [model_providers.<id>]; model_provider selects the active one.',
189
+ },
190
+ pi: {
191
+ registry: {
192
+ kind: 'json-providers', file: '.pi/agent/models.json', pointer: 'providers',
193
+ writable: true, baseUrlField: 'baseUrl', apiKeyField: 'apiKey',
194
+ dialectField: 'api', modelsField: 'models',
195
+ },
196
+ createsChoice: true,
197
+ importFrom: ['omp-rpc', 'opencode', 'codex'],
198
+ summary: 'pi reads providers from models.json; each needs a baseUrl and an api.',
199
+ },
200
+ kimi: {
201
+ registry: {
202
+ // MEASURED: the binary this build updates is `@moonshot-ai/kimi-code`,
203
+ // which reads `~/.kimi-code/config.toml` (overridable with
204
+ // `KIMI_CODE_HOME`). `~/.kimi/` is the retired Python CLI's directory:
205
+ // `kimi migrate` copies out of it and deliberately leaves it in place, so
206
+ // reading it would show providers the running agent never sees.
207
+ kind: 'toml-providers', file: '.kimi-code/config.toml', pointer: 'providers',
208
+ writable: true, baseUrlField: 'base_url', apiKeyField: 'api_key',
209
+ dialectField: 'type', modelsField: 'models',
210
+ // A kimi provider serves nothing until `[models.<alias>]` names it, and
211
+ // that alias needs `provider`, `model` and `max_context_size`.
212
+ modelsAreRows: true,
213
+ },
214
+ createsChoice: true,
215
+ importFrom: ['omp-rpc', 'opencode', 'pi', 'qwen'],
216
+ summary: 'kimi-code reads [providers.<id>] and [models.<alias>] from config.toml; `type` names the wire protocol and nothing serves until a model alias exists.',
217
+ },
218
+ qwen: {
219
+ registry: {
220
+ kind: 'json-model-providers', file: '.qwen/settings.json', pointer: 'modelProviders',
221
+ writable: true, baseUrlField: 'baseUrl', apiKeyField: 'envKey',
222
+ modelsField: null,
223
+ // `qwen` reports its own OAuth models and cannot be overridden.
224
+ bundledIds: ['qwen-oauth'],
225
+ },
226
+ createsChoice: true,
227
+ importFrom: ['omp-rpc', 'opencode'],
228
+ summary: 'qwen lists model routes under modelProviders, grouped by protocol; credentials stay in the environment.',
229
+ },
230
+ 'command-code': {
231
+ registry: {
232
+ // `~/.commandcode/providers.json` exists, but its shape is written by
233
+ // `cmd /connect` and is not documented — so it is read for display and
234
+ // never used as an import source. Copying a shape Kabmo cannot vouch for is
235
+ // how an import writes something the agent then refuses.
236
+ kind: 'agent-managed', file: '.commandcode/providers.json', pointer: 'providers',
237
+ writable: false, baseUrlField: null, apiKeyField: null, modelsField: null,
238
+ },
239
+ createsChoice: true,
240
+ importFrom: [],
241
+ summary: 'Command Code adds providers with `cmd /connect`, which writes its own providers.json. The models it publishes then appear in Kabmo.',
242
+ },
243
+ minimax: {
244
+ registry: {
245
+ kind: 'agent-managed', file: null, pointer: 'mcode BYOK',
246
+ writable: false, baseUrlField: null, apiKeyField: null, modelsField: null,
247
+ },
248
+ createsChoice: true,
249
+ importFrom: [],
250
+ summary: 'MiniMax stores BYOK providers itself; add one with `mcode`, and Kabmo will see the models it publishes.',
251
+ },
252
+ claude: {
253
+ registry: {
254
+ kind: 'env', file: null, pointer: 'environment',
255
+ writable: true, baseUrlField: null, apiKeyField: null, modelsField: null,
256
+ },
257
+ env: {
258
+ baseUrl: 'ANTHROPIC_BASE_URL',
259
+ apiKey: 'ANTHROPIC_AUTH_TOKEN',
260
+ model: 'ANTHROPIC_MODEL',
261
+ // The picker's aliases resolve through these variables. Set only the ones
262
+ // the gateway serves: an unmapped alias keeps resolving to the vendor's
263
+ // id, which a custom endpoint answers with `400 model not found`.
264
+ modelAliases: [
265
+ { family: 'opus', env: 'ANTHROPIC_DEFAULT_OPUS_MODEL' },
266
+ { family: 'sonnet', env: 'ANTHROPIC_DEFAULT_SONNET_MODEL' },
267
+ { family: 'haiku', env: 'ANTHROPIC_DEFAULT_HAIKU_MODEL' },
268
+ { family: 'fable', env: 'ANTHROPIC_DEFAULT_FABLE_MODEL' },
269
+ ],
270
+ },
271
+ // Claude Code speaks Anthropic Messages only, and appends `/v1/messages`
272
+ // itself — measured: BASE_URL with `/v1` still on it requested
273
+ // `/v1/v1/messages` and answered with an empty turn.
274
+ envProtocol: 'anthropic-messages',
275
+ createsChoice: false,
276
+ importFrom: ['omp-rpc', 'opencode', 'codex', 'pi', 'kimi', 'qwen'],
277
+ summary: 'Claude Code has no provider registry: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN point every request at one endpoint. Setting them REPLACES Anthropic.',
278
+ },
279
+ antigravity: {
280
+ registry: {
281
+ kind: 'env', file: null, pointer: 'environment',
282
+ writable: true, baseUrlField: null, apiKeyField: null, modelsField: null,
283
+ },
284
+ env: { baseUrl: 'GOOGLE_GEMINI_BASE_URL', apiKey: 'GEMINI_API_KEY' },
285
+ envProtocol: 'google-genai',
286
+ createsChoice: false,
287
+ importFrom: ['omp-rpc', 'opencode', 'codex', 'pi', 'kimi', 'qwen'],
288
+ summary: 'Antigravity reads GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL, and only when modelProvider is `gemini`. It REPLACES the signed-in account.',
289
+ },
290
+ dsh: {
291
+ registry: {
292
+ kind: 'none', file: null, pointer: '—',
293
+ writable: false, baseUrlField: null, apiKeyField: null, modelsField: null,
294
+ },
295
+ createsChoice: false,
296
+ importFrom: [],
297
+ summary: 'No provider registry Kabmo can write; the launch command and env are the whole surface.',
298
+ },
299
+ cursor: {
300
+ registry: {
301
+ kind: 'none', file: null, pointer: '—',
302
+ writable: false, baseUrlField: null, apiKeyField: null, modelsField: null,
303
+ },
304
+ createsChoice: false,
305
+ importFrom: [],
306
+ summary: 'Signed in with its own auth flow; no provider registry to edit.',
307
+ },
308
+ zcode: {
309
+ registry: {
310
+ // MEASURED against the bridge's own reference and the installed 0.82.3
311
+ // bundle: `~/.zcode/v2/config.json` is the LEGACY provider map, and the
312
+ // personal providers a user adds in the 3.12+ desktop app (or the CLI's
313
+ // setup wizard) live in `provider_config.json`. The bridge reads both: the
314
+ // rule arrays are authoritative for custom providers, while `config.json`
315
+ // keeps builtin credentials. Writing `provider_config.json` is supported by
316
+ // the runtime (`provider-config.ts` writes it through a file lock and the
317
+ // backend absorbs external edits on a ~1s poll), so this registry is
318
+ // writable — unlike `config.json`, which the app owns.
319
+ kind: 'zcode-provider-rules', file: '.zcode/v2/provider_config.json',
320
+ pointer: 'config.providerConfigRules.providerRules',
321
+ writable: true, baseUrlField: 'config.api.baseUrl',
322
+ apiKeyField: 'config.access.apiKey', dialectField: 'config.api.type',
323
+ modelsField: 'config.personalModelIds', modelsAreRows: true,
324
+ },
325
+ createsChoice: true,
326
+ importFrom: ['omp-rpc', 'opencode', 'codex', 'pi', 'kimi', 'qwen'],
327
+ summary: 'ZCode keeps user-added providers in ~/.zcode/v2/provider_config.json (3.12+), as provider rules plus one model rule per id. Kabmo merges one provider into that file and leaves the app’s legacy config.json untouched. Chats still need a ZCode runtime: the desktop app, or `zcode-app-cli` on PATH (`ZCODE_BIN` for a custom install).',
328
+ },
329
+ };
330
+
331
+ /** The facts for a harness, or the honest "nothing to offer" record. */
332
+ export function providerFacts(id: string | null | undefined): HarnessProviderFacts {
333
+ const entry = id ? (HARNESS_PROVIDER_FACTS as Record<string, HarnessProviderFacts | undefined>)[id] : undefined;
334
+ return entry ?? {
335
+ registry: {
336
+ kind: 'none', file: null, pointer: '—',
337
+ writable: false, baseUrlField: null, apiKeyField: null, modelsField: null,
338
+ },
339
+ createsChoice: false,
340
+ importFrom: [],
341
+ summary: 'This build knows nothing about providers for that harness.',
342
+ };
343
+ }
344
+
345
+ /** True when the settings page should draw a registry editor. */
346
+ export function managesProviders(id: string | null | undefined): boolean {
347
+ const registry = providerFacts(id).registry;
348
+ return registry.writable && registry.kind !== 'env' && registry.kind !== 'none';
349
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The provider id a name becomes, and the shape every registry accepts.
8
+ *
9
+ * Each agent keys its provider table differently — omp's YAML map, opencode's
10
+ * JSON object, codex's `[model_providers.<id>]`, kimi's `[providers.<id>]` with
11
+ * dots and colons in its own managed names — so the id Kabmo writes is the
12
+ * INTERSECTION every format accepts. Deriving it in the browser alone would let
13
+ * a form store an id the server then refuses; the same function runs on both
14
+ * sides, and this module is the one definition.
15
+ *
16
+ * Pure and dependency-free: the form previews with it, the route validates with
17
+ * it, and the two cannot disagree about what "My Gateway" becomes.
18
+ */
19
+
20
+ /** The shape every registry in `provider-facts.ts` accepts as a key. */
21
+ export const PROVIDER_ID_PATTERN = /^[a-z0-9][a-z0-9._:-]{0,63}$/;
22
+
23
+ /**
24
+ * `My Gateway (EU)` → `my-gateway-eu`; `kenari.id` → `kenari-id`.
25
+ *
26
+ * Dashes for every run of other characters, and no leading/trailing dash — the
27
+ * same rule the Add Provider dialog uses for omp's own models.yml, so a provider
28
+ * named once reads the same in every agent it is added to.
29
+ */
30
+ export function providerSlugFrom(name: string): string {
31
+ return name
32
+ .trim()
33
+ .toLowerCase()
34
+ .replace(/[^a-z0-9]+/g, '-')
35
+ .replace(/^-+|-+$/g, '')
36
+ .slice(0, 64);
37
+ }
38
+
39
+ /** Why an id cannot be written, or null when it can. */
40
+ export function providerIdProblem(id: string): string | null {
41
+ if (!id.trim()) return 'Enter a provider name to derive an id.';
42
+ if (!PROVIDER_ID_PATTERN.test(id)) {
43
+ return 'The id must start with a letter or digit, and hold only a-z, 0-9, dot, underscore, colon or dash.';
44
+ }
45
+ return null;
46
+ }