@kabmo-labs/kabmo 0.11.1 → 0.12.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 (324) hide show
  1. package/README.md +67 -421
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +426 -413
  4. package/dist/client/static/js/{index-amss8pge.js → index-0smc9gm2.js} +1123 -747
  5. package/dist/client/static/js/index-shexbk5f.css +1 -0
  6. package/marketplace/marketplace.json +13 -3
  7. package/marketplace/plugins/command-runner/package.json +4 -2
  8. package/marketplace/plugins/git-forge/README.md +219 -0
  9. package/marketplace/plugins/git-forge/icon.svg +20 -0
  10. package/marketplace/plugins/git-forge/package.json +56 -0
  11. package/marketplace/plugins/git-forge/src/app.tsx +82 -0
  12. package/marketplace/plugins/git-forge/src/command.test.ts +181 -0
  13. package/marketplace/plugins/git-forge/src/command.ts +119 -0
  14. package/marketplace/plugins/git-forge/src/header.tsx +87 -0
  15. package/marketplace/plugins/git-forge/src/panel/Badge.tsx +76 -0
  16. package/marketplace/plugins/git-forge/src/panel/Change.tsx +150 -0
  17. package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +51 -0
  18. package/marketplace/plugins/git-forge/src/panel/Credential.tsx +107 -0
  19. package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +70 -0
  20. package/marketplace/plugins/git-forge/src/panel/Header.tsx +255 -0
  21. package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +198 -0
  22. package/marketplace/plugins/git-forge/src/panel/List.tsx +89 -0
  23. package/marketplace/plugins/git-forge/src/panel/Row.tsx +68 -0
  24. package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +94 -0
  25. package/marketplace/plugins/git-forge/src/panel/Write.tsx +236 -0
  26. package/marketplace/plugins/git-forge/src/panel/format.ts +78 -0
  27. package/marketplace/plugins/git-forge/src/panel/index.test.tsx +344 -0
  28. package/marketplace/plugins/git-forge/src/panel/index.tsx +193 -0
  29. package/marketplace/plugins/git-forge/src/panel/use-forge.ts +250 -0
  30. package/marketplace/plugins/git-forge/src/panel/write.test.tsx +269 -0
  31. package/marketplace/plugins/git-forge/src/protocol.ts +308 -0
  32. package/marketplace/plugins/git-forge/src/server/adapters.test.ts +274 -0
  33. package/marketplace/plugins/git-forge/src/server/bitbucket.ts +307 -0
  34. package/marketplace/plugins/git-forge/src/server/capabilities.test.ts +116 -0
  35. package/marketplace/plugins/git-forge/src/server/capabilities.ts +105 -0
  36. package/marketplace/plugins/git-forge/src/server/ci.test.ts +88 -0
  37. package/marketplace/plugins/git-forge/src/server/ci.ts +118 -0
  38. package/marketplace/plugins/git-forge/src/server/context.ts +76 -0
  39. package/marketplace/plugins/git-forge/src/server/diff.test.ts +127 -0
  40. package/marketplace/plugins/git-forge/src/server/diff.ts +120 -0
  41. package/marketplace/plugins/git-forge/src/server/filters.test.ts +138 -0
  42. package/marketplace/plugins/git-forge/src/server/filters.ts +138 -0
  43. package/marketplace/plugins/git-forge/src/server/forges.test.ts +235 -0
  44. package/marketplace/plugins/git-forge/src/server/gitea.ts +296 -0
  45. package/marketplace/plugins/git-forge/src/server/github-extras.ts +92 -0
  46. package/marketplace/plugins/git-forge/src/server/github.ts +320 -0
  47. package/marketplace/plugins/git-forge/src/server/gitlab-detail.ts +207 -0
  48. package/marketplace/plugins/git-forge/src/server/gitlab.test.ts +195 -0
  49. package/marketplace/plugins/git-forge/src/server/gitlab.ts +176 -0
  50. package/marketplace/plugins/git-forge/src/server/http.test.ts +270 -0
  51. package/marketplace/plugins/git-forge/src/server/http.ts +329 -0
  52. package/marketplace/plugins/git-forge/src/server/map.ts +120 -0
  53. package/marketplace/plugins/git-forge/src/server/registry.ts +47 -0
  54. package/marketplace/plugins/git-forge/src/server/remote.test.ts +146 -0
  55. package/marketplace/plugins/git-forge/src/server/remote.ts +188 -0
  56. package/marketplace/plugins/git-forge/src/server/scope-probe.test.ts +98 -0
  57. package/marketplace/plugins/git-forge/src/server/scope-probe.ts +128 -0
  58. package/marketplace/plugins/git-forge/src/server/scope.ts +66 -0
  59. package/marketplace/plugins/git-forge/src/server/test-context.ts +67 -0
  60. package/marketplace/plugins/git-forge/src/server/test-host.ts +51 -0
  61. package/marketplace/plugins/git-forge/src/server/token.test.ts +107 -0
  62. package/marketplace/plugins/git-forge/src/server/token.ts +139 -0
  63. package/marketplace/plugins/git-forge/src/server/write-http.test.ts +127 -0
  64. package/marketplace/plugins/git-forge/src/server/write-http.ts +110 -0
  65. package/marketplace/plugins/git-forge/src/server/writes.test.ts +218 -0
  66. package/marketplace/plugins/git-forge/src/server/writes.ts +313 -0
  67. package/marketplace/plugins/git-forge/src/server.ts +284 -0
  68. package/marketplace/plugins/git-forge/tsconfig.json +16 -0
  69. package/marketplace/plugins/session-info/package.json +4 -2
  70. package/marketplace/plugins/stats/package.json +4 -2
  71. package/package.json +6 -1
  72. package/src/client/components/common/code-surface/blame-hover.ts +188 -0
  73. package/src/client/components/common/code-surface/blame-panel.test.ts +304 -0
  74. package/src/client/components/common/code-surface/blame-panel.ts +306 -0
  75. package/src/client/components/common/code-surface/blame.test.ts +303 -0
  76. package/src/client/components/common/code-surface/blame.ts +227 -0
  77. package/src/client/components/common/code-surface/conflict-markers.test.ts +135 -0
  78. package/src/client/components/common/code-surface/conflict-markers.ts +144 -0
  79. package/src/client/components/common/code-surface/documents.ts +48 -1
  80. package/src/client/components/common/code-surface/extensions.test.ts +4 -0
  81. package/src/client/components/common/code-surface/extensions.ts +44 -0
  82. package/src/client/components/common/code-surface/fold-stack.test.ts +4 -0
  83. package/src/client/components/common/code-surface/indent.test.ts +5 -0
  84. package/src/client/components/common/code-surface/index.tsx +16 -2
  85. package/src/client/components/common/code-surface/lint-parsers.test.ts +109 -0
  86. package/src/client/components/common/code-surface/lint-parsers.ts +134 -0
  87. package/src/client/components/common/code-surface/lint.test.ts +101 -0
  88. package/src/client/components/common/code-surface/lint.ts +85 -0
  89. package/src/client/components/common/code-surface/props.ts +17 -0
  90. package/src/client/components/common/code-surface/surface-failures.test.ts +132 -0
  91. package/src/client/components/common/code-surface/theme.ts +71 -0
  92. package/src/client/components/common/header-controls/index.test.tsx +1 -1
  93. package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -1
  94. package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -1
  95. package/src/client/components/common/provider-icon/Plate.tsx +88 -0
  96. package/src/client/components/common/provider-icon/index.tsx +55 -11
  97. package/src/client/components/layout/session-sidebar/SessionsView.tsx +5 -2
  98. package/src/client/components/mobile/SessionSidebar.tsx +2 -10
  99. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +6 -0
  100. package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +8 -0
  101. package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
  102. package/src/client/components/settings/categories/ProviderSettings.tsx +43 -41
  103. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +97 -0
  104. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +106 -54
  105. package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +14 -1
  106. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +39 -150
  107. package/src/client/components/settings/categories/panel-plugins/Meta.test.tsx +143 -0
  108. package/src/client/components/settings/categories/panel-plugins/Meta.tsx +157 -0
  109. package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +149 -0
  110. package/src/client/components/settings/categories/panel-plugins/Placement.tsx +99 -0
  111. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +270 -0
  112. package/src/client/components/settings/categories/panel-plugins/Section.tsx +11 -3
  113. package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +25 -0
  114. package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +135 -80
  115. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +51 -21
  116. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +175 -0
  117. package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +275 -0
  118. package/src/client/components/settings/categories/provider-settings/Header.tsx +40 -9
  119. package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +142 -160
  120. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  121. package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +84 -46
  122. package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +217 -102
  123. package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +5 -2
  124. package/src/client/components/settings/categories/provider-settings/SidebarList.plugin.test.ts +3 -3
  125. package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +158 -102
  126. package/src/client/components/settings/categories/provider-settings/auth-section.test.tsx +135 -0
  127. package/src/client/components/settings/categories/provider-settings/groups.test.ts +98 -0
  128. package/src/client/components/settings/categories/provider-settings/groups.ts +108 -0
  129. package/src/client/components/settings/categories/provider-settings/layout.test.tsx +325 -0
  130. package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +135 -0
  131. package/src/client/components/settings/categories/provider-settings/preset-picker.test.tsx +73 -0
  132. package/src/client/components/settings/categories/usage-settings/ProviderCard.tsx +22 -2
  133. package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +2 -0
  134. package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +16 -6
  135. package/src/client/components/settings/categories/usage-settings/providers.ts +3 -0
  136. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +19 -0
  137. package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +143 -0
  138. package/src/client/components/workspace/chat-timeline/MinimapShortcuts.test.ts +2 -1
  139. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +23 -19
  140. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +23 -19
  141. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +20 -18
  142. package/src/client/components/workspace/chat-timeline/chat-input/compact.test.tsx +19 -6
  143. package/src/client/components/workspace/chat-timeline/index.tsx +7 -16
  144. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +100 -0
  145. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +3 -47
  146. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +8 -1
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util.ts +62 -0
  148. package/src/client/components/workspace/diff-panel/HunkStepper.tsx +62 -0
  149. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +29 -0
  150. package/src/client/components/workspace/diff-panel/Toolbar.tsx +32 -1
  151. package/src/client/components/workspace/diff-panel/changes.ts +69 -0
  152. package/src/client/components/workspace/diff-panel/chunks.ts +85 -0
  153. package/src/client/components/workspace/diff-panel/index.tsx +21 -1
  154. package/src/client/components/workspace/diff-panel/merge.test.ts +145 -0
  155. package/src/client/components/workspace/diff-panel/merge.ts +63 -68
  156. package/src/client/components/workspace/editor/EditorDropOverlay.tsx +6 -1
  157. package/src/client/components/workspace/editor/FileDocument.tsx +51 -1
  158. package/src/client/components/workspace/editor/FilePane.tsx +25 -1
  159. package/src/client/components/workspace/editor/StatusBar.tsx +19 -0
  160. package/src/client/components/workspace/editor/Toolbar.tsx +29 -5
  161. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +86 -0
  162. package/src/client/components/workspace/editor/toolbar-clusters.tsx +48 -16
  163. package/src/client/components/workspace/editor/viewers/bytes.ts +16 -0
  164. package/src/client/components/workspace/git-panel/index.test.ts +46 -1
  165. package/src/client/components/workspace/git-panel/index.tsx +11 -38
  166. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +66 -0
  167. package/src/client/components/workspace/model-dropdown/Item.tsx +71 -62
  168. package/src/client/components/workspace/model-dropdown/Section.tsx +31 -14
  169. package/src/client/components/workspace/model-dropdown/collapsed.ts +72 -0
  170. package/src/client/components/workspace/model-dropdown/index.tsx +42 -19
  171. package/src/client/components/workspace/model-dropdown/refresh.test.tsx +260 -0
  172. package/src/client/components/workspace/model-dropdown/trigger.test.ts +34 -0
  173. package/src/client/components/workspace/model-dropdown/use-catalog.ts +13 -2
  174. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +19 -3
  175. package/src/client/hooks/chat/omp/folder-auto-expand.ts +113 -0
  176. package/src/client/hooks/chat/omp/index.ts +20 -0
  177. package/src/client/hooks/chat/omp/pending-rows.ts +21 -0
  178. package/src/client/hooks/chat/omp/pending-sessions.test.ts +16 -1
  179. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +102 -0
  180. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +21 -1
  181. package/src/client/hooks/chat/omp/stream.ts +8 -1
  182. package/src/client/hooks/chat/timeline/index.ts +1 -1
  183. package/src/client/hooks/chat/timeline/new-chat-open.ts +60 -0
  184. package/src/client/hooks/editor/blame-settings.ts +67 -0
  185. package/src/client/hooks/editor/blame.test.ts +272 -0
  186. package/src/client/hooks/editor/blame.ts +232 -0
  187. package/src/client/hooks/editor/file-editor-types.ts +23 -0
  188. package/src/client/hooks/editor/save-file.test.ts +20 -0
  189. package/src/client/hooks/editor/use-editor-drop.test-util.ts +198 -0
  190. package/src/client/hooks/editor/use-editor-drop.test.ts +70 -175
  191. package/src/client/hooks/editor/use-editor-drop.ts +19 -36
  192. package/src/client/hooks/editor/use-file-editor.ts +7 -1
  193. package/src/client/hooks/settings/providers/actions.ts +90 -194
  194. package/src/client/hooks/settings/providers/api.ts +7 -1
  195. package/src/client/hooks/settings/providers/index.ts +171 -59
  196. package/src/client/hooks/settings/providers/login.test.ts +79 -0
  197. package/src/client/hooks/settings/providers/login.ts +276 -0
  198. package/src/client/hooks/settings/providers/messages.ts +28 -0
  199. package/src/client/hooks/settings/providers/model-actions.ts +178 -0
  200. package/src/client/hooks/ui/editor-error-toast.ts +47 -0
  201. package/src/client/hooks/ui/open-file.ts +7 -0
  202. package/src/client/hooks/ui/toasts.ts +7 -0
  203. package/src/client/hooks/workspace/file-tabs.ts +4 -1
  204. package/src/client/hooks/workspace/folder-expansion.test.ts +62 -0
  205. package/src/client/hooks/workspace/folder-expansion.ts +33 -0
  206. package/src/client/hooks/workspace/git-action-outcome.ts +86 -0
  207. package/src/client/hooks/workspace/git-actions.ts +29 -2
  208. package/src/client/hooks/workspace/plugin-contributions.test.ts +117 -0
  209. package/src/client/hooks/workspace/plugin-contributions.ts +146 -0
  210. package/src/client/lib/editor-errors.test.ts +85 -0
  211. package/src/client/lib/editor-errors.ts +71 -0
  212. package/src/client/lib/fs/resolve-open.test.ts +125 -0
  213. package/src/client/lib/fs/resolve-open.ts +90 -0
  214. package/src/client/lib/git/action-message.test.ts +82 -0
  215. package/src/client/lib/git/action-message.ts +160 -0
  216. package/src/client/lib/launch/device-files.test.ts +160 -0
  217. package/src/client/lib/launch/device-files.ts +197 -0
  218. package/src/client/lib/native/open-paths.test.ts +140 -0
  219. package/src/client/lib/native/open-paths.ts +157 -0
  220. package/src/client/lib/plugins/bootstrap.test.ts +1 -1
  221. package/src/client/main.tsx +20 -0
  222. package/src/server/db.server.test.ts +39 -0
  223. package/src/server/db.server.ts +21 -2
  224. package/src/server/lib/db/schema.ts +2 -0
  225. package/src/server/lib/fs/external-roots.test.ts +100 -0
  226. package/src/server/lib/fs/external-roots.ts +101 -0
  227. package/src/server/lib/fs/git-actions-branch.ts +15 -2
  228. package/src/server/lib/fs/git-actions-shared.ts +24 -0
  229. package/src/server/lib/fs/git-actions-sync.test.ts +18 -7
  230. package/src/server/lib/fs/git-actions-worktree.ts +5 -1
  231. package/src/server/lib/fs/git-blame.test.ts +206 -0
  232. package/src/server/lib/fs/git-blame.ts +189 -0
  233. package/src/server/lib/fs/root.ts +14 -0
  234. package/src/server/lib/http/same-origin.ts +28 -7
  235. package/src/server/lib/models/catalog.server.ts +230 -0
  236. package/src/server/lib/models/catalog.test.ts +83 -0
  237. package/src/server/lib/models/credential-origin.server.ts +108 -0
  238. package/src/server/lib/models/credential-origin.test.ts +132 -0
  239. package/src/server/lib/models/provider-icon-fetch.ts +115 -0
  240. package/src/server/lib/models/provider-icon-parse.test.ts +134 -0
  241. package/src/server/lib/models/provider-icon-parse.ts +139 -0
  242. package/src/server/lib/models/provider-icon-store.server.ts +118 -0
  243. package/src/server/lib/models/provider-icon-store.test.ts +107 -0
  244. package/src/server/lib/models/provider-icon.server.ts +209 -0
  245. package/src/server/lib/models/provider-items.server.ts +211 -37
  246. package/src/server/lib/models/provider-items.test.ts +201 -0
  247. package/src/server/lib/models/provider-registry.server.test.ts +27 -9
  248. package/src/server/lib/models/provider-registry.server.ts +160 -67
  249. package/src/server/lib/models/registry.server.test.ts +3 -3
  250. package/src/server/lib/models/registry.server.ts +8 -0
  251. package/src/server/lib/omp/config/definitions.test.ts +5 -4
  252. package/src/server/lib/omp/config/models-config.ts +42 -0
  253. package/src/server/lib/omp/config/provider-entry.test.ts +205 -0
  254. package/src/server/lib/omp/config/provider-entry.ts +197 -0
  255. package/src/server/lib/omp/config/provider-seeds.ts +10 -0
  256. package/src/server/lib/omp/core/models-json.ts +69 -0
  257. package/src/server/lib/omp/session/messages.ts +17 -3
  258. package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +13 -3
  259. package/src/server/lib/panels/bundled-catalog.server.ts +7 -0
  260. package/src/server/lib/panels/catalog-offers.server.ts +68 -0
  261. package/src/server/lib/panels/git-update.server.test.ts +14 -0
  262. package/src/server/lib/panels/git-update.server.ts +63 -1
  263. package/src/server/lib/panels/manifest.test.ts +65 -0
  264. package/src/server/lib/panels/manifest.ts +55 -1
  265. package/src/server/lib/panels/offers.server.test.ts +191 -0
  266. package/src/server/lib/panels/offers.server.ts +108 -0
  267. package/src/server/lib/panels/registry.server.test.ts +35 -1
  268. package/src/server/lib/panels/registry.server.ts +51 -142
  269. package/src/server/lib/panels/scan.server.ts +162 -0
  270. package/src/server/lib/route-adapter.ts +13 -2
  271. package/src/server/lib/tray/tray.test.ts +2 -1
  272. package/src/server/lib/usage/providers.server.ts +4 -1
  273. package/src/server/routes/chat/session.ts +7 -1
  274. package/src/server/routes/fs/git-blame-loader.test.ts +146 -0
  275. package/src/server/routes/fs/git.ts +17 -0
  276. package/src/server/routes/fs/grant.test.ts +135 -0
  277. package/src/server/routes/fs/grant.ts +79 -0
  278. package/src/server/routes/fs/index.ts +2 -0
  279. package/src/server/routes/fs/scope.ts +34 -17
  280. package/src/server/routes/omp/login.ts +41 -14
  281. package/src/server/routes/omp/routes.test.ts +23 -10
  282. package/src/server/routes/settings/index.ts +8 -0
  283. package/src/server/routes/settings/provider-entry.ts +108 -0
  284. package/src/server/routes/settings/provider-icon.ts +99 -0
  285. package/src/server/routes/settings/provider-model.ts +4 -1
  286. package/src/server/routes/settings/provider-refresh.ts +87 -0
  287. package/src/server/routes/settings/providers.ts +31 -2
  288. package/src/shared/lib/chat/omp/fold.test.ts +34 -0
  289. package/src/shared/lib/chat/omp/tool-frames.test.ts +20 -0
  290. package/src/shared/lib/chat/omp/tool-frames.ts +5 -1
  291. package/src/shared/lib/chat/omp/tool-results.ts +29 -3
  292. package/src/shared/lib/chat/tool/wait-facts.ts +4 -0
  293. package/src/shared/lib/fs/git-blame.test.ts +266 -0
  294. package/src/shared/lib/fs/git-blame.ts +246 -0
  295. package/src/shared/lib/git/url.ts +18 -0
  296. package/src/shared/lib/markdown/sanitize.test.ts +57 -0
  297. package/src/shared/lib/markdown/sanitize.ts +30 -7
  298. package/src/shared/lib/models/provider/connection.ts +135 -0
  299. package/src/shared/lib/models/provider/dialect.test.ts +4 -2
  300. package/src/shared/lib/models/provider/dialect.ts +76 -6
  301. package/src/shared/lib/models/provider/models.ts +2 -0
  302. package/src/shared/lib/models/provider/origin.ts +94 -0
  303. package/src/shared/lib/models/provider/provider-ui.test.ts +7 -0
  304. package/src/shared/lib/models/server-cache.ts +8 -3
  305. package/src/shared/lib/omp/session/messages-map-pending.test.ts +110 -0
  306. package/src/shared/lib/omp/session/messages-map.ts +34 -2
  307. package/src/shared/lib/omp/session/prewarm-misc.test.ts +7 -90
  308. package/src/shared/lib/omp/session/prewarm.test.ts +133 -0
  309. package/src/shared/lib/omp/session/prewarm.ts +23 -1
  310. package/src/shared/lib/omp/session/wait.test.ts +28 -0
  311. package/src/shared/lib/omp/session/wait.ts +38 -3
  312. package/src/shared/lib/panels/slot-labels.test.ts +61 -0
  313. package/src/shared/lib/panels/slot-labels.ts +133 -0
  314. package/src/shared/lib/workspace/panel-ids.ts +11 -0
  315. package/src/shared/types/fs.ts +6 -0
  316. package/src/shared/types/index.ts +1 -0
  317. package/src/shared/types/models.ts +12 -0
  318. package/src/shared/types/panels-registry.ts +277 -0
  319. package/src/shared/types/panels.ts +46 -213
  320. package/src/shared/types/settings/provider.ts +58 -0
  321. package/src/shared/types/settings/usage.ts +10 -0
  322. package/src/test-support/pristine-globals.ts +7 -0
  323. package/dist/client/static/js/index-bq6qeayr.css +0 -1
  324. package/src/client/components/settings/categories/provider-settings/ReconnectModal.tsx +0 -184
@@ -4,13 +4,13 @@
4
4
  */
5
5
 
6
6
  /**
7
- * The leftover edges of the omp bridge: the prewarm trigger that must never
8
- * block the UI, the telemetry content profiler whose badges the raw-messages
9
- * panel renders, the additive column migration, the generated UI password, the
10
- * synchronous transaction wrapper, and the persisted access-mode read. Each is
11
- * small but each fails user-visibly: a prewarm that throws on an offline
12
- * browser, a profiler that mislabels a tool, a migration that aborts startup,
13
- * a transaction that commits a failed write.
7
+ * The leftover edges of the omp bridge: the telemetry content profiler whose
8
+ * badges the raw-messages panel renders, the additive column migration, the
9
+ * generated UI password, the synchronous transaction wrapper, and the persisted
10
+ * access-mode read. Each is small but each fails user-visibly: a profiler that
11
+ * mislabels a tool, a migration that aborts startup, a transaction that commits
12
+ * a failed write. The prewarm trigger and its cwd resolution have their own
13
+ * file (`prewarm.test.ts`).
14
14
  */
15
15
 
16
16
  import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
@@ -24,94 +24,11 @@ import { withTransaction } from '@/shared/lib/db/transaction.server';
24
24
  import { loadPersistedAccessMode } from '@/shared/lib/omp/config/access-mode.server';
25
25
  import { ACCESS_MODE_SETTING_KEY, DEFAULT_APPROVAL_MODE } from '@/shared/lib/omp/config/access-mode';
26
26
  import { TYPE_ORDER, contentProfile } from '@/shared/lib/omp/session/telemetry-blocks';
27
- import { spawnCwdForNewSession, triggerSessionPrewarm } from '@/shared/lib/omp/session/prewarm';
28
27
  import { migrateSessionStreamStateColumns } from '@/shared/lib/omp/session/schema-migrations';
29
28
  import { createDb } from '@/server/lib/db/client';
30
29
  import { hashPassword, verifyPassword } from '@/server/lib/auth/config';
31
30
  import { getDb } from '@/server/db.server';
32
31
 
33
- describe('triggerSessionPrewarm', () => {
34
- /** The runner's own fetch, reached through `Bun` so a stub leaked onto the global cannot be mistaken for it. */
35
- const originalFetch = Bun.fetch;
36
- const calls: Array<{ url: string; method?: string; body: unknown }> = [];
37
- const post = (url: unknown, init?: { method?: string; body?: string }) => {
38
- calls.push({ url: String(url), method: init?.method, body: JSON.parse(String(init?.body)) });
39
- return Promise.resolve(new Response('{}', { status: 200 }));
40
- };
41
-
42
- beforeAll(() => { globalThis.fetch = post as unknown as typeof fetch; });
43
- afterAll(() => { globalThis.fetch = originalFetch; });
44
-
45
- test('posts the cwd, and the access mode only when one is given', () => {
46
- calls.length = 0;
47
- triggerSessionPrewarm('/tmp/project');
48
- triggerSessionPrewarm('/tmp/project', 'yolo');
49
- expect(calls).toEqual([
50
- { url: '/api/agent/prewarm', method: 'POST', body: { cwd: '/tmp/project' } },
51
- { url: '/api/agent/prewarm', method: 'POST', body: { cwd: '/tmp/project', accessMode: 'yolo' } },
52
- ]);
53
- });
54
-
55
- test('an empty cwd sends nothing', () => {
56
- calls.length = 0;
57
- triggerSessionPrewarm('');
58
- expect(calls).toEqual([]);
59
- });
60
-
61
- test('a rejected request is swallowed — prewarm must never reach the UI', () => {
62
- // Fire-and-forget: the function returns undefined synchronously and the
63
- // module attaches its own catch, so the rejection never becomes an
64
- // unhandled one that would surface as a test-run error.
65
- calls.length = 0;
66
- globalThis.fetch = (() => Promise.reject(new Error('offline'))) as unknown as typeof fetch;
67
- expect(triggerSessionPrewarm('/tmp/project')).toBeUndefined();
68
- expect(calls).toEqual([]);
69
- globalThis.fetch = post as unknown as typeof fetch;
70
- });
71
- });
72
-
73
- describe('spawnCwdForNewSession', () => {
74
- const folders = [
75
- { id: 1, name: 'alpha', project_path: '/work/alpha', sessions: [{ id: 's-1' }] },
76
- { id: 2, name: 'beta', project_path: null, sessions: [] },
77
- { id: 3, name: 'gamma', project_path: '/work/gamma' },
78
- ];
79
-
80
- test('an explicit folder id wins, resolved loosely by string form', () => {
81
- expect(spawnCwdForNewSession(folders, null, 3)).toBe('/work/gamma');
82
- expect(spawnCwdForNewSession(folders, null, '3')).toBe('/work/gamma');
83
- });
84
-
85
- test('an unknown folder id yields no cwd rather than the wrong one', () => {
86
- expect(spawnCwdForNewSession(folders, null, 99)).toBeNull();
87
- });
88
-
89
- test('otherwise the folder owning the active session is used', () => {
90
- expect(spawnCwdForNewSession(folders, 's-1')).toBe('/work/alpha');
91
- });
92
-
93
- test('without a session match the first folder WITH a project path is used', () => {
94
- // Neither the active session nor an id matched, so the first folder that
95
- // carries a project path (alpha) wins; folder 2 has none.
96
- expect(spawnCwdForNewSession(folders, 'unknown-session')).toBe('/work/alpha');
97
- });
98
-
99
- test('a matched folder with no project path falls back to its name', () => {
100
- const sessionFolder = [{ id: 2, name: 'beta', project_path: null, sessions: [{ id: 's-9' }] }];
101
- expect(spawnCwdForNewSession(sessionFolder, 's-9')).toBe('beta');
102
- expect(spawnCwdForNewSession(sessionFolder, null, 2)).toBe('beta');
103
- });
104
-
105
- test('no matching folder at all yields null', () => {
106
- expect(spawnCwdForNewSession([{ id: 2, name: 'beta', project_path: null }], null)).toBeNull();
107
- });
108
-
109
- test('no folders at all yields null', () => {
110
- expect(spawnCwdForNewSession([], null)).toBeNull();
111
- expect(spawnCwdForNewSession([], 's-1', 1)).toBeNull();
112
- });
113
- });
114
-
115
32
  describe('contentProfile', () => {
116
33
  test('the badge order is fixed', () => {
117
34
  expect(TYPE_ORDER).toEqual(['reasoning', 'text', 'bash', 'read', 'edit', 'search', 'web', 'tool']);
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The prewarm trigger and the cwd it resolves.
8
+ *
9
+ * Split from `prewarm-misc.test.ts` (which covers the other leftover edges of
10
+ * the omp bridge) because both halves of this feature live in `prewarm.ts` and
11
+ * they fail in the same way: a prewarm in the wrong cwd, or under a different
12
+ * access mode, is a process the send never claims — the claim KILLS it and
13
+ * cold-spawns, which is the 675-934 ms boot the feature exists to hide.
14
+ */
15
+
16
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
17
+
18
+ import { ACCESS_MODE_SETTING_KEY } from '@/shared/lib/omp/config/access-mode';
19
+ import { spawnCwdForNewSession, triggerSessionPrewarm } from '@/shared/lib/omp/session/prewarm';
20
+ import { primeKabmoSettings, writeSetting } from '@/shared/lib/settings/client';
21
+
22
+ describe('triggerSessionPrewarm', () => {
23
+ /** The runner's own fetch, reached through `Bun` so a stub leaked onto the global cannot be mistaken for it. */
24
+ const originalFetch = Bun.fetch;
25
+ const calls: Array<{ url: string; method?: string; body: unknown }> = [];
26
+ const post = (url: unknown, init?: { method?: string; body?: string }) => {
27
+ calls.push({ url: String(url), method: init?.method, body: JSON.parse(String(init?.body)) });
28
+ return Promise.resolve(new Response('{}', { status: 200 }));
29
+ };
30
+
31
+ beforeAll(() => { globalThis.fetch = post as unknown as typeof fetch; });
32
+ afterAll(() => { globalThis.fetch = originalFetch; });
33
+
34
+ /** The settings snapshot is module state: every case states what it boots with. */
35
+ const prime = (mode?: string) => {
36
+ primeKabmoSettings(mode ? { [ACCESS_MODE_SETTING_KEY]: mode } : {});
37
+ calls.length = 0;
38
+ };
39
+
40
+ test('carries the mode the settings snapshot holds', () => {
41
+ prime('yolo');
42
+ triggerSessionPrewarm('/tmp/project');
43
+ expect(calls).toEqual([
44
+ { url: '/api/agent/prewarm', method: 'POST', body: { cwd: '/tmp/project', accessMode: 'yolo' } },
45
+ ]);
46
+ });
47
+
48
+ test('a mode chosen AFTER boot is the one sent', () => {
49
+ // The regression: the sidebar used to hand over `appSettings.omp_access_mode`,
50
+ // a boot-time prop, so a mode picked in the composer left the prewarm on the
51
+ // previous one — and a mismatched prewarm is KILLED by the claim, which is
52
+ // the 762 ms cold spawn this feature exists to remove.
53
+ prime('always-ask');
54
+ writeSetting(ACCESS_MODE_SETTING_KEY, 'yolo');
55
+ calls.length = 0;
56
+ triggerSessionPrewarm('/tmp/project');
57
+ expect(calls).toEqual([
58
+ { url: '/api/agent/prewarm', method: 'POST', body: { cwd: '/tmp/project', accessMode: 'yolo' } },
59
+ ]);
60
+ });
61
+
62
+ test('an unset or unusable mode sends the cwd alone', () => {
63
+ prime();
64
+ triggerSessionPrewarm('/tmp/project');
65
+ // The server falls back to the persisted row, exactly as it would for a
66
+ // request that named nothing; sending garbage would only look like a choice.
67
+ primeKabmoSettings({ [ACCESS_MODE_SETTING_KEY]: 'turbo' });
68
+ triggerSessionPrewarm('/tmp/project');
69
+ expect(calls).toEqual([
70
+ { url: '/api/agent/prewarm', method: 'POST', body: { cwd: '/tmp/project' } },
71
+ { url: '/api/agent/prewarm', method: 'POST', body: { cwd: '/tmp/project' } },
72
+ ]);
73
+ });
74
+
75
+ test('an empty cwd sends nothing', () => {
76
+ prime('yolo');
77
+ triggerSessionPrewarm('');
78
+ expect(calls).toEqual([]);
79
+ });
80
+
81
+ test('a rejected request is swallowed — prewarm must never reach the UI', () => {
82
+ // Fire-and-forget: the function returns undefined synchronously and the
83
+ // module attaches its own catch, so the rejection never becomes an
84
+ // unhandled one that would surface as a test-run error.
85
+ prime('yolo');
86
+ globalThis.fetch = (() => Promise.reject(new Error('offline'))) as unknown as typeof fetch;
87
+ expect(triggerSessionPrewarm('/tmp/project')).toBeUndefined();
88
+ expect(calls).toEqual([]);
89
+ globalThis.fetch = post as unknown as typeof fetch;
90
+ });
91
+ });
92
+
93
+ describe('spawnCwdForNewSession', () => {
94
+ const folders = [
95
+ { id: 1, name: 'alpha', project_path: '/work/alpha', sessions: [{ id: 's-1' }] },
96
+ { id: 2, name: 'beta', project_path: null, sessions: [] },
97
+ { id: 3, name: 'gamma', project_path: '/work/gamma' },
98
+ ];
99
+
100
+ test('an explicit folder id wins, resolved loosely by string form', () => {
101
+ expect(spawnCwdForNewSession(folders, null, 3)).toBe('/work/gamma');
102
+ expect(spawnCwdForNewSession(folders, null, '3')).toBe('/work/gamma');
103
+ });
104
+
105
+ test('an unknown folder id yields no cwd rather than the wrong one', () => {
106
+ expect(spawnCwdForNewSession(folders, null, 99)).toBeNull();
107
+ });
108
+
109
+ test('otherwise the folder owning the active session is used', () => {
110
+ expect(spawnCwdForNewSession(folders, 's-1')).toBe('/work/alpha');
111
+ });
112
+
113
+ test('without a session match the first folder WITH a project path is used', () => {
114
+ // Neither the active session nor an id matched, so the first folder that
115
+ // carries a project path (alpha) wins; folder 2 has none.
116
+ expect(spawnCwdForNewSession(folders, 'unknown-session')).toBe('/work/alpha');
117
+ });
118
+
119
+ test('a matched folder with no project path falls back to its name', () => {
120
+ const sessionFolder = [{ id: 2, name: 'beta', project_path: null, sessions: [{ id: 's-9' }] }];
121
+ expect(spawnCwdForNewSession(sessionFolder, 's-9')).toBe('beta');
122
+ expect(spawnCwdForNewSession(sessionFolder, null, 2)).toBe('beta');
123
+ });
124
+
125
+ test('no matching folder at all yields null', () => {
126
+ expect(spawnCwdForNewSession([{ id: 2, name: 'beta', project_path: null }], null)).toBeNull();
127
+ });
128
+
129
+ test('no folders at all yields null', () => {
130
+ expect(spawnCwdForNewSession([], null)).toBeNull();
131
+ expect(spawnCwdForNewSession([], 's-1', 1)).toBeNull();
132
+ });
133
+ });
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
1
6
  /**
2
7
  * Client-side trigger for the server's prewarm pool: asking Kabmo server
3
8
  * to start an idle `omp --mode rpc-ui` process for a project cwd before the
@@ -6,10 +11,27 @@
6
11
  *
7
12
  * Fire-and-forget by contract: a failed or slow prewarm must never block or
8
13
  * error the UI. The next send spawns cold in that case, exactly as before.
14
+ *
15
+ * **The access mode is read here, from the live settings snapshot, and is
16
+ * deliberately NOT a parameter.** `claimPrewarmedSession` only hands out an
17
+ * entry spawned with the mode the send asks for; a mismatch KILLS the
18
+ * prewarmed child and cold-spawns (measured: 762 ms against 6 ms), so the
19
+ * prewarm exists only if both ends name the same mode. Callers cannot supply
20
+ * it reliably: the desktop sidebar reads `appSettings.omp_access_mode`, a
21
+ * boot-time prop, while the send path reads the composer's live ref — a mode
22
+ * picked in the composer then spent the next prewarm on the previous one, and
23
+ * the phone passed nothing at all, so every prewarm there was always-ask
24
+ * against a yolo install. `writeSetting` updates the snapshot synchronously,
25
+ * so this reads exactly what the composer last chose.
9
26
  */
10
27
 
11
- export function triggerSessionPrewarm(cwd: string, accessMode?: string): void {
28
+ import { ACCESS_MODE_SETTING_KEY, isApprovalMode } from '@/shared/lib/omp/config/access-mode';
29
+ import { readKabmoSetting } from '@/shared/lib/settings/client';
30
+
31
+ export function triggerSessionPrewarm(cwd: string): void {
12
32
  if (!cwd) return;
33
+ const stored = readKabmoSetting<unknown>(ACCESS_MODE_SETTING_KEY);
34
+ const accessMode = isApprovalMode(stored) ? stored : undefined;
13
35
  fetch('/api/agent/prewarm', {
14
36
  method: 'POST',
15
37
  headers: { 'Content-Type': 'application/json' },
@@ -103,6 +103,34 @@ describe('waitViewOf', () => {
103
103
  expect(waitViewOf({ details: { proc: { jobs: [{ id: 'bg_1' }] } } })).toBeUndefined();
104
104
  expect(waitViewOf({})).toBeUndefined();
105
105
  });
106
+
107
+ test('a wait with NO result is still a wait, and says its jobs are unknown', () => {
108
+ // The reload case: the transcript holds the `toolCall` block and no
109
+ // `toolResult` behind it. Requiring `details.op` degraded the card to a
110
+ // generic Output block — the reported "wait renders as general after a
111
+ // reload". The name is the only evidence left, and `reported: false` is
112
+ // what keeps a reader from claiming "no jobs".
113
+ const view = waitViewOf({ name: 'wait' });
114
+ expect(view).toMatchObject({ op: 'wait', jobs: [], reported: false });
115
+ });
116
+
117
+ test("omp's own `details: {}` answer is unreported, not an empty job list", () => {
118
+ // "Nothing to wait for: no background job or service you started is
119
+ // running." arrives with `details: {}` — a real result, but it carries no
120
+ // snapshot, so the job list is UNKNOWN rather than known-empty.
121
+ const view = waitViewOf({ name: 'wait', details: {} });
122
+ expect(view?.reported).toBe(false);
123
+ expect(view?.jobs).toEqual([]);
124
+ });
125
+
126
+ test('a reported snapshot is marked reported', () => {
127
+ expect(waitViewOf({ name: 'wait', details: { op: 'wait', jobs: [] } })?.reported).toBe(true);
128
+ });
129
+
130
+ test('another tool with no result is not claimed by its name', () => {
131
+ expect(waitViewOf({ name: 'bash' })).toBeUndefined();
132
+ expect(waitViewOf({ type: 'task' })).toBeUndefined();
133
+ });
106
134
  });
107
135
 
108
136
  describe('waitJobSpanMs', () => {
@@ -93,6 +93,16 @@ export interface WaitView {
93
93
  /** The message a `send` delivered to, for the `send` op. */
94
94
  from?: string;
95
95
  to?: string;
96
+ /**
97
+ * Whether `details` carried the `op` that identifies a coordination result.
98
+ *
99
+ * False for a wait the runtime has not reported a snapshot for yet — a call
100
+ * still blocking after a page reload, whose transcript carries only the
101
+ * `toolCall` block — and for omp's own `details: {}` on "Nothing to wait
102
+ * for". The view is still a wait (the tool's own name says so), but its job
103
+ * list is UNKNOWN rather than empty, so no reader may claim "no jobs".
104
+ */
105
+ reported: boolean;
96
106
  }
97
107
 
98
108
  function asString(value: unknown): string | undefined {
@@ -156,6 +166,15 @@ function messageOf(value: unknown): WaitMessage | undefined {
156
166
 
157
167
  const WAIT_OPS: Record<string, true> = { wait: true, send: true };
158
168
 
169
+ /** The tool names that ARE a coordination call, independent of their result. */
170
+ const WAIT_TOOL_NAMES: Record<string, true> = { wait: true };
171
+
172
+ /** The op a tool's own name implies, for a call whose result reports none. */
173
+ function opOfTool(tool: { name?: string; type?: string }): string | undefined {
174
+ const raw = (tool.name || tool.type || '').toLowerCase();
175
+ return WAIT_TOOL_NAMES[raw] ? raw : undefined;
176
+ }
177
+
159
178
  /**
160
179
  * Normalize a `wait` result into `WaitView`, or undefined when the call is not
161
180
  * one of the coordination operations.
@@ -170,12 +189,27 @@ const WAIT_OPS: Record<string, true> = { wait: true, send: true };
170
189
  * background work may still be running") and when a service rather than a job
171
190
  * woke the call. Rejecting it drew the most interesting wait of all as a
172
191
  * generic card.
192
+ *
193
+ * A wait with NO result at all is still a wait, and the tool's own name is the
194
+ * only evidence left — a page reloaded while the call blocks reads the JSONL's
195
+ * `toolCall` block with no `toolResult` behind it, and omp's own
196
+ * "Nothing to wait for" answers `details: {}`. Requiring `details.op` there
197
+ * degraded the card to a generic Output block, which is the reported "wait
198
+ * rendered as general after a reload". Such a view is marked `reported: false`
199
+ * so nothing claims a job count it does not have.
173
200
  */
174
- export function waitViewOf(tool: { details?: Record<string, unknown> }): WaitView | undefined {
201
+ export function waitViewOf(tool: {
202
+ details?: Record<string, unknown>;
203
+ name?: string;
204
+ type?: string;
205
+ }): WaitView | undefined {
175
206
  const details = isRecord(tool.details) ? tool.details : undefined;
176
- if (!details) return undefined;
177
- const op = asString(details.op);
207
+ const reportedOp = details ? asString(details.op) : undefined;
208
+ const op = reportedOp ?? opOfTool(tool);
178
209
  if (!op || !WAIT_OPS[op]) return undefined;
210
+ if (!details) {
211
+ return { op, jobs: [], agents: [], interrupted: false, cancelled: [], reported: false };
212
+ }
179
213
 
180
214
  return {
181
215
  op,
@@ -190,6 +224,7 @@ export function waitViewOf(tool: { details?: Record<string, unknown> }): WaitVie
190
224
  waited: messageOf(details.waited),
191
225
  from: asString(details.from),
192
226
  to: asString(details.to),
227
+ reported: reportedOp !== undefined,
193
228
  };
194
229
  }
195
230
 
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The slot vocabulary a card speaks.
8
+ *
9
+ * Two tables and one rule each, and the rule is the one that goes wrong
10
+ * silently: a slot the SDK knows but this file does not would render a badge
11
+ * reading `undefined` — or, with the tables typed as `Record`, fail to compile
12
+ * and be fixed by adding an entry. That is the point of typing them, so the test
13
+ * re-derives both lists from the SDK and asserts every name has a label.
14
+ *
15
+ * The second rule is that a label is a WORD, not the SDK's identifier: a card
16
+ * saying `rightPanel` makes the reader learn the SDK to answer a question the
17
+ * pane should answer in words.
18
+ */
19
+
20
+ import { describe, expect, test } from 'bun:test';
21
+ import { LIST_SLOT_NAMES } from '@kabmo-labs/kabmo-sdk';
22
+ import { PANEL_SLOT_NAMES } from '@/shared/types';
23
+ import { LIST_SLOT_LABELS, POSITIONAL_SLOT_LABELS } from '@/shared/lib/panels/slot-labels';
24
+
25
+ describe('positional slot labels', () => {
26
+ test('every positional slot the manifest may declare has a label', () => {
27
+ for (const slot of PANEL_SLOT_NAMES) {
28
+ const label = POSITIONAL_SLOT_LABELS[slot];
29
+ expect(label).toBeDefined();
30
+ expect(label.label.length).toBeGreaterThan(0);
31
+ expect(label.detail.length).toBeGreaterThan(0);
32
+ expect(label.kind).toBe('panel');
33
+ }
34
+ });
35
+
36
+ test('a label is words, never the registration name', () => {
37
+ for (const slot of PANEL_SLOT_NAMES) {
38
+ expect(POSITIONAL_SLOT_LABELS[slot].label).not.toBe(slot);
39
+ expect(POSITIONAL_SLOT_LABELS[slot].label).toContain(' ');
40
+ }
41
+ });
42
+ });
43
+
44
+ describe('list slot labels', () => {
45
+ test('every list slot the SDK offers has a label', () => {
46
+ for (const slot of LIST_SLOT_NAMES) {
47
+ const label = LIST_SLOT_LABELS[slot];
48
+ expect(label).toBeDefined();
49
+ expect(label.label.length).toBeGreaterThan(0);
50
+ expect(label.detail.length).toBeGreaterThan(0);
51
+ expect(label.kind).toBe('row');
52
+ }
53
+ });
54
+
55
+ test('the table has no row the SDK does not register', () => {
56
+ // A leftover key is a label for a slot nothing can fill — dead weight that
57
+ // reads as support for a feature that does not exist.
58
+ const known = new Set<string>(LIST_SLOT_NAMES);
59
+ for (const key of Object.keys(LIST_SLOT_LABELS)) expect(known.has(key)).toBe(true);
60
+ });
61
+ });
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * What a plugin CONTRIBUTES, named the way a reader understands it.
8
+ *
9
+ * Two vocabularies meet here and they are not the same list. The POSITIONAL
10
+ * slots are places (`rightPanel`, `panel`, `headerPanel`, `settingsSection`) and
11
+ * a plugin fills at most one of each. The LIST slots are rows added to a surface
12
+ * that already exists (`messageAction`, `composerAction`, `fileOpener`, …) and a
13
+ * plugin may contribute several to one.
14
+ *
15
+ * A card has to say which, because "this plugin adds a panel on the right" and
16
+ * "this plugin adds a button to every chat row" are different promises — and a
17
+ * badge reading `rightPanel` makes the reader learn the SDK's vocabulary to
18
+ * answer a question the pane should answer in words.
19
+ *
20
+ * The labels live in ONE table shared by the installed card and the store card,
21
+ * so the same contribution cannot be called two things depending on whether the
22
+ * plugin is installed.
23
+ */
24
+
25
+ import type { ListSlotName } from '@kabmo-labs/kabmo-sdk';
26
+ import type { PanelSlotName } from '@/shared/types';
27
+
28
+ export interface SlotLabel {
29
+ /** The word a badge shows. Short, because a card has one line. */
30
+ label: string;
31
+ /** What it actually adds, for the badge's `title`. */
32
+ detail: string;
33
+ /** `panel` draws a place; `row` adds to a surface that already exists. */
34
+ kind: 'panel' | 'row';
35
+ }
36
+
37
+ /** The positional slots, in the order a card lists them. */
38
+ export const POSITIONAL_SLOT_LABELS: Record<PanelSlotName, SlotLabel> = {
39
+ rightPanel: {
40
+ label: 'Panel view',
41
+ detail: 'A view with its own button — it rides the left dock or the right column.',
42
+ kind: 'panel',
43
+ },
44
+ panel: {
45
+ label: 'Editor takeover',
46
+ detail: 'A full-height view that owns the editor column.',
47
+ kind: 'panel',
48
+ },
49
+ headerPanel: {
50
+ label: 'Header button',
51
+ detail: 'A control in the top navbar — a readout, a dropdown, or a button that opens a panel.',
52
+ kind: 'panel',
53
+ },
54
+ settingsSection: {
55
+ label: 'Settings section',
56
+ detail: 'A block inside this plugin’s own settings pane.',
57
+ kind: 'panel',
58
+ },
59
+ };
60
+
61
+ /** The list slots, keyed by their registration name. */
62
+ export const LIST_SLOT_LABELS: Record<ListSlotName, SlotLabel> = {
63
+ messageAction: {
64
+ label: 'Message actions',
65
+ detail: 'Buttons on every chat message row.',
66
+ kind: 'row',
67
+ },
68
+ commandPaletteAction: {
69
+ label: 'Command palette',
70
+ detail: 'Commands added to the palette.',
71
+ kind: 'row',
72
+ },
73
+ fileOpener: {
74
+ label: 'File openers',
75
+ detail: 'Handlers that open a file in its own viewer instead of the editor.',
76
+ kind: 'row',
77
+ },
78
+ sourceCodeRenderer: {
79
+ label: 'Source renderers',
80
+ detail: 'Alternate renderers for a source file.',
81
+ kind: 'row',
82
+ },
83
+ diffRenderer: {
84
+ label: 'Diff renderers',
85
+ detail: 'Alternate renderers for a diff.',
86
+ kind: 'row',
87
+ },
88
+ timelineRenderer: {
89
+ label: 'Timeline renderers',
90
+ detail: 'Alternate renderers for the chat timeline.',
91
+ kind: 'row',
92
+ },
93
+ composerAction: {
94
+ label: 'Composer buttons',
95
+ detail: 'Buttons in the composer’s toolbar.',
96
+ kind: 'row',
97
+ },
98
+ composerBanner: {
99
+ label: 'Composer banners',
100
+ detail: 'A strip drawn above the composer’s input.',
101
+ kind: 'row',
102
+ },
103
+ providerIcon: {
104
+ label: 'Provider icons',
105
+ detail: 'Marks for a model provider.',
106
+ kind: 'row',
107
+ },
108
+ pendingInteraction: {
109
+ label: 'Pending interactions',
110
+ detail: 'A dialog the agent can block on.',
111
+ kind: 'row',
112
+ },
113
+ messageDirective: {
114
+ label: 'Message directives',
115
+ detail: 'A fenced-block name this plugin renders.',
116
+ kind: 'row',
117
+ },
118
+ contentScript: {
119
+ label: 'Content scripts',
120
+ detail: 'Code that runs while the plugin is enabled and draws nothing.',
121
+ kind: 'row',
122
+ },
123
+ };
124
+
125
+ /** The label for a positional slot. */
126
+ export function positionalSlotLabel(slot: PanelSlotName): SlotLabel {
127
+ return POSITIONAL_SLOT_LABELS[slot];
128
+ }
129
+
130
+ /** The label for a list slot. */
131
+ export function listSlotLabel(slot: ListSlotName): SlotLabel {
132
+ return LIST_SLOT_LABELS[slot];
133
+ }
@@ -73,6 +73,17 @@ function isSlot(value: string): value is PluginPanelSlot {
73
73
  return (PLUGIN_PANEL_SLOTS as readonly string[]).includes(value);
74
74
  }
75
75
 
76
+ /**
77
+ * Whether a value is one of the two PLACEABLE slot names.
78
+ *
79
+ * A card reads a contribution's slot name to decide whether it can offer a
80
+ * placement control, and the name arrives as a plain string — this is the
81
+ * narrowing, rather than a cast at the call site.
82
+ */
83
+ export function isPluginPanelSlot(value: unknown): value is PluginPanelSlot {
84
+ return typeof value === 'string' && isSlot(value);
85
+ }
86
+
76
87
  /**
77
88
  * The parts of a plugin panel id, or null.
78
89
  *
@@ -31,6 +31,12 @@ export interface OpenedFile {
31
31
  * the tab says so after a reload.
32
32
  */
33
33
  handleId?: string;
34
+ /**
35
+ * True when the tab's bytes came from the DEVICE (a document the phone handed
36
+ * over) rather than from the server. It renders, and it cannot be written
37
+ * back: there is no path the server can reach and no writable handle.
38
+ */
39
+ deviceFile?: boolean;
34
40
  }
35
41
 
36
42
  export interface SearchResultItem {
@@ -29,4 +29,5 @@ export * from '@/shared/types/todo';
29
29
  export * from '@/shared/types/plan';
30
30
  export * from '@/shared/types/wiki';
31
31
  export * from '@/shared/types/panels';
32
+ export * from '@/shared/types/panels-registry';
32
33
  export type { RightPanelType } from '@/shared/lib/workspace/right-panels';
@@ -18,6 +18,8 @@ export interface AIModelOption {
18
18
  name: string;
19
19
  provider: string;
20
20
  providerIcon?: string;
21
+ /** The provider's fetched web icon (see {@link ModelEntry.providerIconUrl}). */
22
+ providerIconUrl?: string;
21
23
  contextWindow?: string | number;
22
24
  isCmdAgent?: boolean;
23
25
  /**
@@ -51,6 +53,16 @@ export interface ModelEntry {
51
53
  id: string;
52
54
  name: string;
53
55
  provider: string;
56
+ /**
57
+ * The provider's own web icon, when one has been fetched and stored.
58
+ *
59
+ * `/api/models` is read by the composer's picker, which draws a mark per
60
+ * SECTION and per selected model. Without this the picker could only use the
61
+ * built-in mark table, so a `models.yml` provider — the one kind the table
62
+ * cannot know — showed its initials while the settings panel showed the site's
63
+ * logo for the same provider.
64
+ */
65
+ providerIconUrl?: string;
54
66
  supportsFastMode?: boolean;
55
67
  contextWindow?: number;
56
68
  maxTokens?: number;