@kabmo-labs/kabmo 0.24.0 → 0.26.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 (325) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +585 -512
  3. package/dist/client/static/js/{index-jcr5twtp.js → index-95b3n20k.js} +1105 -1207
  4. package/dist/client/static/js/index-p2yw9ywf.css +1 -0
  5. package/package.json +2 -4
  6. package/src/cli/lib/args.js +24 -1
  7. package/src/cli/lib/args.test.js +16 -0
  8. package/src/cli/lib/commands/session.js +233 -0
  9. package/src/cli/lib/commands/session.test.js +103 -0
  10. package/src/cli/main.js +1 -1
  11. package/src/client/components/common/ComposerPicker.tsx +3 -0
  12. package/src/client/components/common/code-surface/shiki.test.ts +82 -0
  13. package/src/client/components/common/code-surface/shiki.ts +28 -7
  14. package/src/client/components/common/session-actions-menu/index.tsx +59 -2
  15. package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
  16. package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
  17. package/src/client/components/common/session-branch/index.tsx +169 -0
  18. package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
  19. package/src/client/components/common/session-branch/style.ts +29 -0
  20. package/src/client/components/common/session-row/StatusSlot.tsx +17 -5
  21. package/src/client/components/common/session-row/index.tsx +28 -3
  22. package/src/client/components/common/session-row/session-row.test.tsx +11 -0
  23. package/src/client/components/common/session-state-provider/index.tsx +1 -1
  24. package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
  25. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +70 -61
  26. package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
  27. package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
  28. package/src/client/components/layout/session-sidebar/SessionItem.tsx +35 -7
  29. package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
  30. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +39 -198
  31. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +114 -0
  32. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
  33. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +128 -0
  34. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +56 -0
  35. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +44 -36
  36. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +62 -47
  37. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +63 -50
  38. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
  39. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +37 -12
  40. package/src/client/components/settings/Sidebar.tsx +1 -1
  41. package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
  42. package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
  43. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
  44. package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
  45. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
  46. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
  47. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
  48. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +128 -122
  49. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
  50. package/src/client/components/workspace/chat-timeline/MessageList.tsx +11 -5
  51. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
  52. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
  53. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
  54. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
  55. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
  56. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
  57. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
  58. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
  59. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
  60. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
  61. package/src/client/components/workspace/chat-timeline/index.tsx +11 -20
  62. package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
  63. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
  64. package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
  65. package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
  66. package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
  67. package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
  68. package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
  69. package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
  70. package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
  71. package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
  72. package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
  73. package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
  74. package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
  75. package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
  76. package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
  77. package/src/client/data/settings/omp-schema.json +1 -1
  78. package/src/client/data/theme/terminal.test.ts +25 -0
  79. package/src/client/data/theme/terminal.ts +96 -79
  80. package/src/client/hooks/chat/composer/items.test.ts +31 -26
  81. package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
  82. package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
  83. package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
  84. package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
  85. package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
  86. package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
  87. package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
  88. package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
  89. package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
  90. package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
  91. package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
  92. package/src/client/hooks/chat/omp/run-switch.ts +1 -1
  93. package/src/client/hooks/chat/omp/session-list.tsx +4 -0
  94. package/src/client/hooks/chat/subagents/roster.ts +122 -0
  95. package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
  96. package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
  97. package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
  98. package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
  99. package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
  100. package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
  101. package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
  102. package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
  103. package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
  104. package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
  105. package/src/client/hooks/chat/timeline/modes.ts +42 -29
  106. package/src/client/hooks/chat/timeline/pending-branch.ts +205 -0
  107. package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
  108. package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
  109. package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
  110. package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
  111. package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
  112. package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
  113. package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
  114. package/src/client/hooks/chat/timeline/send.test.ts +3 -1
  115. package/src/client/hooks/chat/timeline/send.ts +48 -133
  116. package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
  117. package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
  118. package/src/client/hooks/chat/timeline/use-fork-session.ts +58 -0
  119. package/src/client/hooks/models/use-harness-update.test.ts +286 -0
  120. package/src/client/hooks/models/use-harness-update.ts +250 -0
  121. package/src/client/hooks/ui/input-required-alert.ts +12 -5
  122. package/src/client/hooks/ui/notifications.ts +45 -0
  123. package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
  124. package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
  125. package/src/client/hooks/workspace/terminal/index.ts +17 -3
  126. package/src/client/hooks/workspace/terminal/socket.ts +9 -4
  127. package/src/client/lib/native/open-session.ts +33 -0
  128. package/src/client/lib/notifications/os.test.ts +125 -0
  129. package/src/client/lib/notifications/os.ts +130 -0
  130. package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
  131. package/src/client/lib/router/open-session.test.ts +75 -0
  132. package/src/client/lib/router/open-session.ts +34 -0
  133. package/src/client/lib/session-tree.test.ts +50 -0
  134. package/src/client/lib/session-tree.ts +59 -0
  135. package/src/client/lib/signals.ts +5 -1
  136. package/src/client/main.tsx +6 -0
  137. package/src/client/tailwind.css +17 -11
  138. package/src/server/index.ts +2 -0
  139. package/src/server/lib/auth/guard.ts +10 -0
  140. package/src/server/lib/btw/session-copy.server.ts +6 -44
  141. package/src/server/lib/btw/session-copy.test.ts +2 -1
  142. package/src/server/lib/db/schema.ts +5 -0
  143. package/src/server/lib/db/seed-terminal.test.ts +1 -1
  144. package/src/server/lib/db/seed.test.ts +1 -1
  145. package/src/server/lib/harness/acp/background-work.test.ts +262 -0
  146. package/src/server/lib/harness/acp/background-work.ts +320 -0
  147. package/src/server/lib/harness/acp/calls.ts +15 -1
  148. package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
  149. package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
  150. package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
  151. package/src/server/lib/harness/acp/client-fs.ts +131 -0
  152. package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
  153. package/src/server/lib/harness/acp/client-initialize.ts +84 -0
  154. package/src/server/lib/harness/acp/client.ts +33 -23
  155. package/src/server/lib/harness/acp/commands.test.ts +5 -5
  156. package/src/server/lib/harness/acp/commands.ts +14 -2
  157. package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
  158. package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
  159. package/src/server/lib/harness/acp/frames.ts +71 -158
  160. package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
  161. package/src/server/lib/harness/acp/gateway-env.ts +70 -0
  162. package/src/server/lib/harness/acp/mapper.test.ts +40 -0
  163. package/src/server/lib/harness/acp/mapper.ts +12 -0
  164. package/src/server/lib/harness/acp/permissions.ts +6 -0
  165. package/src/server/lib/harness/acp/prompt.test.ts +20 -0
  166. package/src/server/lib/harness/acp/prompt.ts +19 -3
  167. package/src/server/lib/harness/acp/protocol.ts +41 -2
  168. package/src/server/lib/harness/acp/session-background.test.ts +129 -0
  169. package/src/server/lib/harness/acp/session-exit.ts +31 -0
  170. package/src/server/lib/harness/acp/session-facts.ts +1 -1
  171. package/src/server/lib/harness/acp/session-handshake.test.ts +197 -0
  172. package/src/server/lib/harness/acp/session-handshake.ts +110 -7
  173. package/src/server/lib/harness/acp/session-idle.ts +7 -6
  174. package/src/server/lib/harness/acp/session-listeners.ts +31 -0
  175. package/src/server/lib/harness/acp/session-notifications.ts +41 -2
  176. package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
  177. package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
  178. package/src/server/lib/harness/acp/session-permissions.ts +36 -0
  179. package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
  180. package/src/server/lib/harness/acp/session-requests.ts +89 -0
  181. package/src/server/lib/harness/acp/session-turns.ts +28 -8
  182. package/src/server/lib/harness/acp/session-usage.ts +4 -0
  183. package/src/server/lib/harness/acp/session-web-state.ts +30 -2
  184. package/src/server/lib/harness/acp/session.test-util.ts +42 -2
  185. package/src/server/lib/harness/acp/session.ts +115 -115
  186. package/src/server/lib/harness/acp/tool-calls.ts +223 -0
  187. package/src/server/lib/harness/acp/turn.test.ts +183 -0
  188. package/src/server/lib/harness/acp/turn.ts +102 -10
  189. package/src/server/lib/harness/acp/v2.test.ts +144 -0
  190. package/src/server/lib/harness/acp/v2.ts +220 -0
  191. package/src/server/lib/harness/acp/verbs.ts +58 -8
  192. package/src/server/lib/harness/launch.test.ts +25 -0
  193. package/src/server/lib/harness/launch.ts +24 -10
  194. package/src/server/lib/harness/session.ts +3 -0
  195. package/src/server/lib/harness/spawn.server.ts +15 -2
  196. package/src/server/lib/harness/update-job-store.test.ts +151 -0
  197. package/src/server/lib/harness/update-job-store.ts +115 -0
  198. package/src/server/lib/harness/update-job.server.ts +94 -0
  199. package/src/server/lib/harness/update-queue.server.ts +292 -0
  200. package/src/server/lib/harness/update-queue.test.ts +265 -0
  201. package/src/server/lib/harness/update-spawn.server.ts +96 -0
  202. package/src/server/lib/harness/update-worker.test.ts +153 -0
  203. package/src/server/lib/harness/update-worker.ts +202 -0
  204. package/src/server/lib/lifecycle/after-listen.ts +9 -0
  205. package/src/server/lib/lifecycle/paths.ts +28 -0
  206. package/src/server/lib/omp/rpc/manager.ts +5 -5
  207. package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
  208. package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
  209. package/src/server/lib/omp/rpc/session-registry.ts +14 -2
  210. package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
  211. package/src/server/lib/omp/rpc/terminal-settle.ts +58 -6
  212. package/src/server/lib/omp/session/delete-flow.server.ts +48 -0
  213. package/src/server/lib/omp/session/delete.server.ts +5 -0
  214. package/src/server/lib/omp/session/rewind-file.ts +39 -21
  215. package/src/server/lib/omp/session/sidebar-data.server.ts +16 -18
  216. package/src/server/lib/omp/session/transcript-copy.ts +123 -0
  217. package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
  218. package/src/server/lib/sessions/agent-token.server.ts +134 -0
  219. package/src/server/lib/sessions/answers.server.test.ts +33 -0
  220. package/src/server/lib/sessions/answers.server.ts +37 -0
  221. package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
  222. package/src/server/lib/sessions/dispatch.server.ts +128 -0
  223. package/src/server/lib/sessions/fork.server.test.ts +277 -0
  224. package/src/server/lib/sessions/fork.server.ts +329 -0
  225. package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
  226. package/src/server/lib/sessions/lifecycle.server.ts +71 -0
  227. package/src/server/lib/sessions/notify.server.test.ts +112 -0
  228. package/src/server/lib/sessions/notify.server.ts +212 -0
  229. package/src/server/lib/sessions/relation-types.ts +76 -0
  230. package/src/server/lib/sessions/relations.server.test.ts +207 -0
  231. package/src/server/lib/sessions/relations.server.ts +337 -0
  232. package/src/server/lib/sessions/resolve.server.ts +106 -0
  233. package/src/server/lib/sessions/schema.server.ts +82 -0
  234. package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
  235. package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
  236. package/src/server/lib/sessions/spawn.server.test.ts +237 -0
  237. package/src/server/lib/sessions/spawn.server.ts +335 -0
  238. package/src/server/lib/terminal/attach-replay.test.ts +2 -2
  239. package/src/server/lib/terminal/output.test.ts +2 -2
  240. package/src/server/lib/terminal/output.ts +1 -1
  241. package/src/server/lib/terminal/resize.test.ts +99 -0
  242. package/src/server/lib/terminal/runtime.server.ts +26 -6
  243. package/src/server/lib/terminal/send-result.test.ts +18 -1
  244. package/src/server/lib/terminal/send-result.ts +26 -2
  245. package/src/server/lib/terminal/session.server.ts +6 -6
  246. package/src/server/lib/usage/new-api.test.ts +92 -0
  247. package/src/server/lib/usage/new-api.ts +131 -0
  248. package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
  249. package/src/server/lib/usage/provider-key.ts +33 -0
  250. package/src/server/lib/usage/providers.server.ts +10 -3
  251. package/src/server/lib/usage/vendor-balance.server.ts +4 -53
  252. package/src/server/lib/usage/vendor-http.ts +41 -0
  253. package/src/server/lib/usage/window.ts +55 -0
  254. package/src/server/routes/agent/command.ts +14 -1
  255. package/src/server/routes/agent/harness-command.ts +12 -5
  256. package/src/server/routes/agent/new.ts +15 -0
  257. package/src/server/routes/chat/stream.ts +7 -2
  258. package/src/server/routes/harness/add-provider.test.ts +9 -1
  259. package/src/server/routes/harness/import-action.ts +4 -0
  260. package/src/server/routes/harness/import.test.ts +1 -1
  261. package/src/server/routes/harness/index.ts +5 -1
  262. package/src/server/routes/harness/update-status.ts +32 -0
  263. package/src/server/routes/harness/update.test.ts +156 -0
  264. package/src/server/routes/harness/update.ts +64 -147
  265. package/src/server/routes/sessions/answer.ts +24 -0
  266. package/src/server/routes/sessions/batch-delete.ts +11 -5
  267. package/src/server/routes/sessions/body-readers.ts +43 -0
  268. package/src/server/routes/sessions/delete.ts +4 -2
  269. package/src/server/routes/sessions/fork.ts +89 -0
  270. package/src/server/routes/sessions/index.ts +14 -0
  271. package/src/server/routes/sessions/relations.ts +85 -0
  272. package/src/server/routes/sessions/routes.test.ts +1 -2
  273. package/src/server/routes/sessions/session.ts +23 -0
  274. package/src/server/routes/sessions/spawn.ts +137 -0
  275. package/src/server/routes/terminal/ws.ts +3 -3
  276. package/src/shared/lib/chat/composer/client.ts +31 -2
  277. package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
  278. package/src/shared/lib/chat/composer/delegation.ts +206 -0
  279. package/src/shared/lib/chat/notice-text.ts +1 -1
  280. package/src/shared/lib/chat/omp/agent-events.ts +11 -0
  281. package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
  282. package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
  283. package/src/shared/lib/code/ansi.ts +1 -1
  284. package/src/shared/lib/fonts/nerd-symbols.css +4 -3
  285. package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
  286. package/src/shared/lib/harness/mode-signal.ts +20 -0
  287. package/src/shared/lib/harness/provider-facts.test.ts +27 -0
  288. package/src/shared/lib/harness/providers.ts +35 -1
  289. package/src/shared/lib/harness/session-modes.ts +24 -0
  290. package/src/shared/lib/harness/update-job.ts +80 -0
  291. package/src/shared/lib/harness/update-plan.test.ts +21 -6
  292. package/src/shared/lib/harness/update-plan.ts +12 -4
  293. package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
  294. package/src/shared/lib/notifications/outcomes.test.ts +96 -0
  295. package/src/shared/lib/notifications/outcomes.ts +64 -0
  296. package/src/shared/lib/notifications/settings.test.ts +49 -0
  297. package/src/shared/lib/notifications/settings.ts +34 -0
  298. package/src/shared/lib/omp/session/default-title.ts +5 -4
  299. package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
  300. package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
  301. package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
  302. package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
  303. package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
  304. package/src/shared/lib/omp/session/wait-idle.ts +12 -2
  305. package/src/shared/lib/settings/defaults.ts +3 -0
  306. package/src/shared/lib/theme/catalog.test.ts +13 -9
  307. package/src/shared/lib/theme/color.test.ts +2 -2
  308. package/src/shared/lib/theme/color.ts +4 -4
  309. package/src/shared/lib/theme/theme.test.ts +1 -1
  310. package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
  311. package/src/shared/lib/workspace/terminal/input.ts +33 -0
  312. package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
  313. package/src/shared/lib/workspace/terminal/keys.ts +7 -7
  314. package/src/shared/types/chat.ts +1 -1
  315. package/src/shared/types/harness-update.ts +89 -0
  316. package/src/shared/types/omp/agent.ts +19 -2
  317. package/src/shared/types/realtime.ts +2 -0
  318. package/src/shared/types/settings/state.ts +10 -0
  319. package/src/shared/types/workspace.ts +8 -0
  320. package/src/test-support/fake-omp-fork.ts +16 -2
  321. package/src/test-support/harness-table.test-util.ts +31 -1
  322. package/dist/client/static/js/index-z3w7n85q.css +0 -1
  323. package/src/client/components/common/subagent-list/index.tsx +0 -165
  324. package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
  325. package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
@@ -11,7 +11,7 @@
11
11
  * contains. `@fontsource/fira-code`'s latin subset maps 226 codepoints and not
12
12
  * one of them is above U+FFFF, so the terminal's stack can only reach them
13
13
  * through a Nerd Font. Until now the stack named installed families only
14
- * (`XTERM_GLYPH_FALLBACKS`), which means the glyphs appeared on the machine
14
+ * (`TERMINAL_GLYPH_FALLBACKS`), which means the glyphs appeared on the machine
15
15
  * that had one installed and were hollow tofu boxes on every other device — a
16
16
  * phone, a second laptop, a colleague's browser.
17
17
  *
@@ -29,8 +29,9 @@
29
29
  *
30
30
  * `font-display: block` rather than `swap`, unlike the text faces beside it: a
31
31
  * swapped symbol paints a tofu box first and repaints, and in a terminal that
32
- * box is exactly the artifact this face exists to remove. `mount.ts` awaits the
33
- * face before opening xterm for the same reason — see `ensureNerdGlyphs`.
32
+ * box is exactly the artifact this face exists to remove. `mount.ts` waits for
33
+ * the face before opening the terminal for the same reason — see
34
+ * `ensureNerdGlyphs`.
34
35
  *
35
36
  * Generated by `bun run scripts/nerd-symbols-font.mjs` from
36
37
  * `SymbolsNerdFontMono-Regular.ttf` (Nerd Fonts v3.5.1). See NOTICE.md in this
@@ -8,7 +8,7 @@
8
8
  * and every way it can break is silent at runtime:
9
9
  *
10
10
  * - The bundled face's family name is written twice — in the stack
11
- * (`XTERM_FONT_FAMILY`) and in the `@font-face` (`nerd-symbols.css`). If they
11
+ * (`TERMINAL_FONT_FAMILY`) and in the `@font-face` (`nerd-symbols.css`). If they
12
12
  * drift, the face loads and nothing uses it: prompts render as tofu boxes
13
13
  * with no error anywhere.
14
14
  * - The face must stay LAST in the stack. Moved ahead of the installed families
@@ -30,8 +30,8 @@ import { join } from 'node:path';
30
30
 
31
31
  import {
32
32
  NERD_SYMBOLS_FAMILY,
33
- XTERM_FONT_FAMILY,
34
- XTERM_GLYPH_FALLBACKS,
33
+ TERMINAL_FONT_FAMILY,
34
+ TERMINAL_GLYPH_FALLBACKS,
35
35
  } from '@/client/data/theme/terminal';
36
36
 
37
37
  const FONT_DIR = import.meta.dir;
@@ -67,19 +67,19 @@ describe('bundled Nerd Font symbols face', () => {
67
67
  // machine that has none — which is also what keeps the desktop from
68
68
  // downloading it (its unicode-range is PUA-only, so it is never fetched
69
69
  // when another family supplies the glyph).
70
- expect(XTERM_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY)).toBeGreaterThan(
71
- XTERM_FONT_FAMILY.indexOf('PowerlineSymbols'),
70
+ expect(TERMINAL_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY)).toBeGreaterThan(
71
+ TERMINAL_FONT_FAMILY.indexOf('PowerlineSymbols'),
72
72
  );
73
73
  // Only the generic fallbacks may follow it.
74
- const after = XTERM_FONT_FAMILY.slice(XTERM_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY));
74
+ const after = TERMINAL_FONT_FAMILY.slice(TERMINAL_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY));
75
75
  expect(after).not.toMatch(/Nerd Font Mono'/);
76
76
  });
77
77
 
78
78
  test('every installed family is still offered before the bundled one', () => {
79
79
  for (const family of ['FiraCode Nerd Font Mono', 'JetBrainsMono Nerd Font', 'Symbols Nerd Font Mono']) {
80
- expect(XTERM_GLYPH_FALLBACKS).toContain(family);
81
- expect(XTERM_FONT_FAMILY.indexOf(family)).toBeLessThan(
82
- XTERM_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY),
80
+ expect(TERMINAL_GLYPH_FALLBACKS).toContain(family);
81
+ expect(TERMINAL_FONT_FAMILY.indexOf(family)).toBeLessThan(
82
+ TERMINAL_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY),
83
83
  );
84
84
  }
85
85
  });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Publishing "the agent changed its session mode/config".
8
+ *
9
+ * The fold sees `mode_changed` / `config_changed` frames; the composer's mode
10
+ * dropdown owns the `/modes` read and cannot see frames. This one-hop signal
11
+ * keeps the dropdown from polling: the frame is the event, and the consumer
12
+ * re-reads the authoritative value once.
13
+ */
14
+
15
+ import { publishClientSignal } from '@/client/lib/signals';
16
+
17
+ export function emitSessionModesChanged(sessionId: string | undefined): void {
18
+ if (!sessionId) return;
19
+ publishClientSignal('session-modes-changed', { sessionId });
20
+ }
@@ -26,6 +26,7 @@
26
26
 
27
27
  import { describe, expect, test } from 'bun:test';
28
28
  import {
29
+ aliasModelFor,
29
30
  credentialFieldLabel,
30
31
  credentialIsEnvName,
31
32
  dialectChoices,
@@ -187,6 +188,32 @@ describe('providerEnv', () => {
187
188
  ]);
188
189
  });
189
190
 
191
+ test('a versioned provider id is reduced to the id the endpoint expects', () => {
192
+ // The gateway's own list may spell the model provider-qualified; the env
193
+ // variable names the model, not the route.
194
+ expect(aliasModelFor('sonnet', ['kenari/claude-sonnet-5'])).toBe('claude-sonnet-5');
195
+ });
196
+
197
+ test('an endpoint with no model of the family pins nothing', () => {
198
+ expect(aliasModelFor('opus', ['qwen3-8-27b:free', 'glm-5-3-flash'])).toBeNull();
199
+ expect(providerEnv('claude', { baseUrl: 'https://gw', apiKey: 'sk-1', models: ['qwen3-8-27b:free'] }))
200
+ .not.toHaveProperty('ANTHROPIC_DEFAULT_OPUS_MODEL');
201
+ });
202
+
203
+ test('every alias the endpoint serves is pinned, and none it does not', () => {
204
+ // Measured on kenari: `sonnet` and `opus` are answered 400 as literal ids
205
+ // while their family ids complete. The list is the authority.
206
+ const env = providerEnv('claude', {
207
+ baseUrl: 'https://gw',
208
+ apiKey: 'sk-1',
209
+ models: ['claude-sonnet-5', 'claude-opus-5', 'deepseek-v4-pro'],
210
+ });
211
+ expect(env.ANTHROPIC_DEFAULT_SONNET_MODEL).toBe('claude-sonnet-5');
212
+ expect(env.ANTHROPIC_DEFAULT_OPUS_MODEL).toBe('claude-opus-5');
213
+ expect(env).not.toHaveProperty('ANTHROPIC_DEFAULT_HAIKU_MODEL');
214
+ expect(env).not.toHaveProperty('ANTHROPIC_DEFAULT_FABLE_MODEL');
215
+ });
216
+
190
217
  test('a blank field writes no variable at all', () => {
191
218
  // An empty env var is a real thing to set, so the form must not do it by
192
219
  // accident.
@@ -57,6 +57,31 @@ export function supportsProviderEditor(id: string | null | undefined): boolean {
57
57
  return providerLevel(id) === 'full';
58
58
  }
59
59
 
60
+ /**
61
+ * The id an endpoint serves for one picker alias, or null when it serves no
62
+ * model of that family.
63
+ *
64
+ * Claude Code's picker offers FAMILY aliases (`opus`, `sonnet`, `haiku`,
65
+ * `fable`). An alias that is not pinned with `ANTHROPIC_DEFAULT_*_MODEL` keeps
66
+ * resolving to Anthropic's own model id, which a gateway answers with
67
+ * `400 model not found: sonnet` (measured against kenari.id). The model list
68
+ * the endpoint published is what says which id belongs to the family.
69
+ *
70
+ * The id is returned BARE: `kenari/claude-sonnet-5` becomes
71
+ * `claude-sonnet-5`, because the variable names the model the endpoint expects,
72
+ * not the provider-qualified spelling an agent's own list may use.
73
+ */
74
+ export function aliasModelFor(family: string, models: readonly string[]): string | null {
75
+ const pattern = new RegExp(`\\b${family.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'i');
76
+ for (const raw of models) {
77
+ const id = raw.trim();
78
+ if (!id) continue;
79
+ const bare = id.slice(id.lastIndexOf('/') + 1);
80
+ if (pattern.test(bare)) return bare;
81
+ }
82
+ return null;
83
+ }
84
+
60
85
  /**
61
86
  * The env a provider becomes for an `environment` harness.
62
87
  *
@@ -65,10 +90,15 @@ export function supportsProviderEditor(id: string | null | undefined): boolean {
65
90
  * form labels each field with the variable it becomes. A blank field writes NO
66
91
  * variable — an empty env var is a real thing to set, so the form must not do it
67
92
  * by accident.
93
+ *
94
+ * `models` is the endpoint's own listing. When given, every picker alias that
95
+ * family serves is PINNED to that id. Without the pin the alias still resolves
96
+ * to the vendor's model, so a picker row the user can see answers a gateway
97
+ * with `400 model not found` (measured on `sonnet` against kenari.id).
68
98
  */
69
99
  export function providerEnv(
70
100
  id: string | null | undefined,
71
- provider: { baseUrl: string; apiKey: string; model?: string },
101
+ provider: { baseUrl: string; apiKey: string; model?: string; models?: readonly string[] },
72
102
  ): Record<string, string> {
73
103
  const contract = providerFacts(id).env;
74
104
  if (!contract) return {};
@@ -76,6 +106,10 @@ export function providerEnv(
76
106
  if (provider.baseUrl.trim()) env[contract.baseUrl] = provider.baseUrl.trim();
77
107
  if (provider.apiKey.trim()) env[contract.apiKey] = provider.apiKey.trim();
78
108
  if (contract.model && provider.model?.trim()) env[contract.model] = provider.model.trim();
109
+ for (const alias of contract.modelAliases ?? []) {
110
+ const model = aliasModelFor(alias.family, provider.models ?? []);
111
+ if (model) env[alias.env] = model;
112
+ }
79
113
  return env;
80
114
  }
81
115
 
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The ACP session-mode selector, as the composer reads it.
8
+ *
9
+ * ACP exposes modes as a `mode`-category config option; this is the normalized
10
+ * shape the `/modes` route answers and the dropdown renders. It is shared so
11
+ * the server route, the client hook and the component agree on one spelling.
12
+ */
13
+
14
+ export interface SessionModeChoice {
15
+ value: string;
16
+ name: string;
17
+ }
18
+
19
+ export interface SessionModeState {
20
+ /** The agent's current mode id. */
21
+ currentValue: string;
22
+ /** Every advertised value, in the agent's order. */
23
+ values: SessionModeChoice[];
24
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Reading a harness-update record that came from somewhere else, and the three
8
+ * questions every reader asks of one: is it waiting, is it running, and which
9
+ * step is it on.
10
+ *
11
+ * Two readers get one over the wire or off disk — the About card, which parses
12
+ * the status response, and the server, which parses the files a detached worker
13
+ * wrote — and neither may assume the shape: a half-written file or an older
14
+ * build's payload would otherwise reach `job.steps.find(...)` and throw inside a
15
+ * render. The guard IS the check, so a payload that fails it reads as "no run".
16
+ */
17
+
18
+ import type { HarnessUpdateJob } from '@/shared/types/harness-update';
19
+
20
+ export function isHarnessUpdateJob(value: unknown): value is HarnessUpdateJob {
21
+ if (!value || typeof value !== 'object') return false;
22
+ const job = value as Partial<HarnessUpdateJob>;
23
+ return typeof job.harness === 'string'
24
+ && typeof job.label === 'string'
25
+ && typeof job.startedAt === 'number'
26
+ && Array.isArray(job.steps)
27
+ && (job.finishedAt === null || typeof job.finishedAt === 'number');
28
+ }
29
+
30
+ /** The `job` field of a refusal payload, or null when it is not a record. */
31
+ export function updateJobFrom(payload: unknown): HarnessUpdateJob | null {
32
+ if (!payload || typeof payload !== 'object' || !('job' in payload)) return null;
33
+ return isHarnessUpdateJob(payload.job) ? payload.job : null;
34
+ }
35
+
36
+ /** The `jobs` field of a status payload, dropping anything that is not a record. */
37
+ export function updateJobsFrom(payload: unknown): HarnessUpdateJob[] {
38
+ if (!payload || typeof payload !== 'object' || !('jobs' in payload)) return [];
39
+ const found = payload.jobs;
40
+ return Array.isArray(found) ? found.filter(isHarnessUpdateJob) : [];
41
+ }
42
+
43
+ /**
44
+ * Is this run WAITING for another install to finish?
45
+ *
46
+ * The queue keeps the record on disk before the worker exists, so the ordinary
47
+ * "no pid and not finished" test would call it a run that died without writing a
48
+ * result. `queuedAt` is what separates the two.
49
+ */
50
+ export function jobQueued(job: HarnessUpdateJob | null): boolean {
51
+ return job !== null && job.finishedAt === null && job.pid === null && (job.queuedAt ?? null) !== null;
52
+ }
53
+
54
+ /** Is a worker installing right now? A queued run is not one. */
55
+ export function jobRunning(job: HarnessUpdateJob | null): boolean {
56
+ return job !== null && job.finishedAt === null && !jobQueued(job);
57
+ }
58
+
59
+ /** Has this record got a result yet (running, queued, or settled)? */
60
+ export function jobUnfinished(job: HarnessUpdateJob | null): boolean {
61
+ return job !== null && job.finishedAt === null;
62
+ }
63
+
64
+ /**
65
+ * Is anything still moving for this record?
66
+ *
67
+ * A settled run is not always finished with the reader: the server probes the
68
+ * freshly installed agent afterwards, and until that answer lands the row quotes
69
+ * the version the update just replaced. Both the queue's ticker and the dialog's
70
+ * poll wait for `probe` to leave `pending`.
71
+ */
72
+ export function jobMoving(job: HarnessUpdateJob | null): boolean {
73
+ return jobUnfinished(job) || (job !== null && job.probe === 'pending');
74
+ }
75
+
76
+ /** The step the worker is on (`adapter`, `Claude Code`, …), when it says. */
77
+ export function runningStepOf(job: HarnessUpdateJob | null): string | null {
78
+ const steps = job && Array.isArray(job.steps) ? job.steps : [];
79
+ return steps.find((step) => step.state === 'running')?.part ?? null;
80
+ }
@@ -41,8 +41,11 @@ function state(overrides: Partial<UpdatePlanState> = {}): UpdatePlanState {
41
41
  describe('repointing a launch line after an adapter install', () => {
42
42
  const install: HarnessUpdateStep = {
43
43
  part: 'adapter',
44
- command: 'npm install -g @agentclientprotocol/claude-agent-acp@0.101.0',
45
- argv: ['npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0'],
44
+ command: 'npm install -g @agentclientprotocol/claude-agent-acp@0.101.0 --allow-scripts=@agentclientprotocol/claude-agent-acp',
45
+ argv: [
46
+ 'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
47
+ '--allow-scripts=@agentclientprotocol/claude-agent-acp',
48
+ ],
46
49
  };
47
50
 
48
51
  test('a pinned npx adapter is pointed at the binary the install wrote', () => {
@@ -68,7 +71,13 @@ describe('planning a harness update', () => {
68
71
  test('both parts behind runs the install AND the CLI updater, in that order', () => {
69
72
  const steps = planHarnessUpdate('claude', CLAUDE, state(), '0.100.0');
70
73
  expect(steps.map((step) => step.argv[0])).toEqual(['npm', 'claude']);
71
- expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0']);
74
+ // The per-package `--allow-scripts` is part of the plan: npm 11 skips
75
+ // postinstall by default, and a native CLI installed without it is broken on
76
+ // disk (measured: `bin/claude.exe` left as a "native binary not installed" stub).
77
+ expect(steps[0].argv).toEqual([
78
+ 'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
79
+ '--allow-scripts=@agentclientprotocol/claude-agent-acp',
80
+ ]);
72
81
  expect(steps[0].part).toBe('adapter');
73
82
  expect(steps[1].argv).toEqual(['claude', 'update']);
74
83
  expect(steps[1].part).toBe('Claude Code');
@@ -95,7 +104,13 @@ describe('planning a harness update', () => {
95
104
  '0.100.0',
96
105
  );
97
106
  expect(steps).toHaveLength(1);
98
- expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0']);
107
+ // The per-package `--allow-scripts` is part of the plan: npm 11 skips
108
+ // postinstall by default, and a native CLI installed without it is broken on
109
+ // disk (measured: `bin/claude.exe` left as a "native binary not installed" stub).
110
+ expect(steps[0].argv).toEqual([
111
+ 'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
112
+ '--allow-scripts=@agentclientprotocol/claude-agent-acp',
113
+ ]);
99
114
  });
100
115
 
101
116
  test('nothing behind plans nothing, so the route can say "already up to date"', () => {
@@ -146,7 +161,7 @@ describe('planning a harness update', () => {
146
161
  );
147
162
  expect(steps).toHaveLength(1);
148
163
  expect(steps[0].part).toBe('deepseek-harness');
149
- expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@deepseek-ai/dsh@0.3.0']);
164
+ expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@deepseek-ai/dsh@0.3.0', '--allow-scripts=@deepseek-ai/dsh']);
150
165
  });
151
166
 
152
167
  test('a plain npm harness names itself, not "adapter"', () => {
@@ -158,6 +173,6 @@ describe('planning a harness update', () => {
158
173
  );
159
174
  expect(steps).toHaveLength(1);
160
175
  expect(steps[0].part).toBe('qwen');
161
- expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@qwen-code/qwen-code@0.10.0']);
176
+ expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@qwen-code/qwen-code@0.10.0', '--allow-scripts=@qwen-code/qwen-code']);
162
177
  });
163
178
  });
@@ -19,6 +19,14 @@
19
19
  * read (a `self` CLI, a CLI with no package in the facts) is never planned: Kabmo
20
20
  * cannot claim it is behind.
21
21
  *
22
+ * **The install allows the vendor's own lifecycle scripts, for that package only.**
23
+ * npm 11 blocks postinstall by default, and the packages here need it: measured on
24
+ * this machine, `@anthropic-ai/claude-code` was present with its native binary
25
+ * missing — `bin/claude.exe` was a stub printing "claude native binary not
26
+ * installed", and `claude update` then failed with
27
+ * `update_apply_native_binary_missing`. A per-package `--allow-scripts=<pkg>` is
28
+ * the narrow form; blanket script execution is not.
29
+ *
22
30
  * Pure, so the decision is testable without spawning anything — the route only
23
31
  * runs the argv this returns.
24
32
  */
@@ -77,8 +85,8 @@ export function planHarnessUpdate(
77
85
  // An adapter over a CLI is named `adapter`, so a report cannot be read as
78
86
  // "the CLI moved" when only its bridge did.
79
87
  part: state.cli ? 'adapter' : label,
80
- command: `npm install -g ${facts.pkg}@${latest}`,
81
- argv: ['npm', 'install', '-g', `${facts.pkg}@${latest}`],
88
+ command: `npm install -g ${facts.pkg}@${latest} --allow-scripts=${facts.pkg}`,
89
+ argv: ['npm', 'install', '-g', `${facts.pkg}@${latest}`, `--allow-scripts=${facts.pkg}`],
82
90
  });
83
91
  }
84
92
  }
@@ -100,8 +108,8 @@ export function planHarnessUpdate(
100
108
  } else if (facts.cli?.pkg) {
101
109
  steps.push({
102
110
  part: cli.name,
103
- command: `npm install -g ${facts.cli.pkg}@${cli.latest}`,
104
- argv: ['npm', 'install', '-g', `${facts.cli.pkg}@${cli.latest}`],
111
+ command: `npm install -g ${facts.cli.pkg}@${cli.latest} --allow-scripts=${facts.cli.pkg}`,
112
+ argv: ['npm', 'install', '-g', `${facts.cli.pkg}@${cli.latest}`, `--allow-scripts=${facts.cli.pkg}`],
105
113
  });
106
114
  }
107
115
  }
@@ -33,40 +33,40 @@ import type { PaperBucket } from '@/shared/lib/icons/icon-tone';
33
33
  export const ICON_HUES: Readonly<Record<string, number>> = {
34
34
  Activity: 240, AlignJustify: 100, AlignLeft: 150, Archive: 50, ArchiveRestore: 90, ArrowDown: 100,
35
35
  ArrowDownToLine: 330, ArrowLeft: 350, ArrowRight: 80, ArrowUp: 150, ArrowUpDown: 310, ArrowUpRight: 70,
36
- BarChart3: 150, Blocks: 110, Bot: 220, Box: 260, Boxes: 220, Brain: 350,
37
- BrainCircuit: 300, Briefcase: 310, Camera: 60, CaseSensitive: 110, ChevronDown: 120, ChevronLeft: 250,
38
- ChevronRight: 300, ChevronUp: 250, ChevronsUpDown: 80, Circle: 50, CircleDashed: 120, CircleDot: 240,
39
- ClipboardCopy: 280, ClipboardList: 290, ClipboardPaste: 200, Cloud: 340, CloudDownload: 300, Code: 200,
40
- Code2: 260, Coins: 210, Columns: 280, Columns2: 20, Command: 100, Component: 200,
41
- Copy: 320, CopyPlus: 40, CornerDownLeft: 10, Cpu: 250, Database: 280, Dice5: 50,
42
- Diff: 300, DollarSign: 220, Download: 210, DownloadCloud: 180, Edit2: 210, Ellipsis: 100,
43
- ExternalLink: 60, Eye: 20, EyeOff: 350, File: 310, FileCode: 260, FileCog: 340,
44
- FileEdit: 270, FileImage: 40, FilePlus: 350, FilePlus2: 350, FileSearch: 310, FileText: 80,
45
- Files: 320, Flag: 350, FlaskConical: 170, Folder: 290, FolderGit: 190, FolderGit2: 190,
46
- FolderInput: 310, FolderOpen: 330, FolderPlus: 250, FolderSearch: 10, FolderTree: 10, Gamepad2: 300,
47
- GitBranch: 30, GitCommitVertical: 240, GitCompare: 340, GitFork: 30, GitMerge: 90, GitPullRequest: 10,
48
- Globe: 340, GraduationCap: 190, GripVertical: 350, Hammer: 310, Hand: 200, HardDrive: 0,
49
- Hash: 330, Heading: 250, Heart: 270, History: 110, Home: 20, Image: 140,
50
- Key: 240, KeyRound: 240, Keyboard: 120, Laptop: 170, Layers: 30, LayoutTemplate: 170,
51
- Leaf: 50, Library: 160, Lightbulb: 0, List: 170, ListChecks: 320, ListFilter: 230,
52
- ListOrdered: 220, ListTodo: 210, ListTree: 330, Loader2: 40, Lock: 220, LockKeyhole: 270,
53
- LockOpen: 180, LogIn: 140, LogOut: 190, Maximize: 310, Maximize2: 270, Menu: 100,
54
- MessageSquare: 150, MessageSquareOff: 40, MessageSquarePlus: 350, MessagesSquare: 220, Mic: 160, MicOff: 170,
55
- Minimize: 290, Minimize2: 130, Minus: 110, Monitor: 250, Moon: 80, MoreHorizontal: 160,
56
- MousePointerClick: 70, MoveVertical: 300, Music: 280, Package: 270, Paintbrush: 250, Palette: 320,
57
- PanelLeft: 280, PanelLeftClose: 160, PanelRight: 330, PanelRightClose: 350, Paperclip: 310, Pause: 10,
58
- Pencil: 0, PencilLine: 260, Pin: 0, PinOff: 50, Pipette: 120, Play: 310,
59
- Plug: 50, Plus: 210, Power: 340, Puzzle: 50, Quote: 110, Radio: 320,
60
- Ratio: 160, RefreshCw: 180, Regex: 280, Replace: 190, ReplaceAll: 140, Rocket: 210,
61
- RotateCcw: 330, RotateCw: 0, Rows: 160, Rows3: 250, Save: 40, SaveAll: 190,
62
- Scissors: 260, Search: 250, Send: 110, Server: 300, ServerCog: 50, Settings: 240,
63
- Settings2: 20, Shield: 160, Shrink: 160, Sliders: 290, SlidersHorizontal: 50, Smartphone: 20,
64
- Space: 290, Sparkles: 180, Square: 60, SquareFunction: 220, SquarePen: 10, Star: 170,
65
- StickyNote: 100, Store: 340, Sun: 90, Tablet: 290, Tag: 310, Target: 200,
66
- Terminal: 210, TextSelect: 220, Ticket: 170, Type: 170, Undo2: 310, Upload: 0,
67
- UploadCloud: 50, User: 140, Variable: 330, Volume2: 270, VolumeX: 50, Wand2: 270,
68
- WandSparkles: 40, Waypoints: 30, WholeWord: 240, WrapText: 340, Wrench: 0, X: 230,
69
- Zap: 120, ZoomIn: 250, ZoomOut: 340,
36
+ BarChart3: 150, BellRing: 260, Blocks: 110, Bot: 220, Box: 260, Boxes: 220,
37
+ Brain: 350, BrainCircuit: 300, Briefcase: 310, Camera: 60, CaseSensitive: 110, ChevronDown: 120,
38
+ ChevronLeft: 250, ChevronRight: 300, ChevronUp: 250, ChevronsUpDown: 80, Circle: 50, CircleCheck: 350,
39
+ CircleDashed: 120, CircleDot: 240, ClipboardCopy: 280, ClipboardList: 290, ClipboardPaste: 200, Cloud: 340,
40
+ CloudDownload: 300, Code: 200, Code2: 260, Coins: 210, Columns: 280, Columns2: 20,
41
+ Command: 100, Component: 200, Copy: 320, CopyPlus: 40, CornerDownLeft: 10, Cpu: 250,
42
+ Database: 280, Dice5: 50, Diff: 300, DollarSign: 220, Download: 210, DownloadCloud: 180,
43
+ Edit2: 210, Ellipsis: 100, ExternalLink: 60, Eye: 20, EyeOff: 350, File: 310,
44
+ FileCode: 260, FileCog: 340, FileEdit: 270, FileImage: 40, FilePlus: 350, FilePlus2: 350,
45
+ FileSearch: 310, FileText: 80, Files: 320, Flag: 350, FlaskConical: 170, Folder: 290,
46
+ FolderGit: 190, FolderGit2: 190, FolderInput: 310, FolderOpen: 330, FolderPlus: 250, FolderSearch: 10,
47
+ FolderTree: 10, Gamepad2: 300, GitBranch: 30, GitCommitVertical: 240, GitCompare: 340, GitFork: 30,
48
+ GitMerge: 90, GitPullRequest: 10, Globe: 340, GraduationCap: 190, GripVertical: 350, Hammer: 310,
49
+ Hand: 200, HardDrive: 0, Hash: 330, Heading: 250, Heart: 270, History: 110,
50
+ Home: 20, Image: 140, Key: 240, KeyRound: 240, Keyboard: 120, Laptop: 170,
51
+ Layers: 30, LayoutTemplate: 170, Leaf: 50, Library: 160, Lightbulb: 0, List: 170,
52
+ ListChecks: 320, ListFilter: 230, ListOrdered: 220, ListTodo: 210, ListTree: 330, Loader2: 40,
53
+ Lock: 220, LockKeyhole: 270, LockOpen: 180, LogIn: 140, LogOut: 190, Maximize: 310,
54
+ Maximize2: 270, Menu: 100, MessageSquare: 150, MessageSquareOff: 40, MessageSquarePlus: 350, MessagesSquare: 220,
55
+ Mic: 160, MicOff: 170, Minimize: 290, Minimize2: 130, Minus: 110, Monitor: 250,
56
+ Moon: 80, MoreHorizontal: 160, MousePointerClick: 70, MoveVertical: 300, Music: 280, Package: 270,
57
+ Paintbrush: 250, Palette: 320, PanelLeft: 280, PanelLeftClose: 160, PanelRight: 330, PanelRightClose: 350,
58
+ Paperclip: 310, Pause: 10, Pencil: 0, PencilLine: 260, Pin: 0, PinOff: 50,
59
+ Pipette: 120, Play: 310, Plug: 50, Plus: 210, Power: 340, Puzzle: 50,
60
+ Quote: 110, Radio: 320, Ratio: 160, RefreshCw: 180, Regex: 280, Replace: 190,
61
+ ReplaceAll: 140, Rocket: 210, RotateCcw: 330, RotateCw: 0, Rows: 160, Rows3: 250,
62
+ Save: 40, SaveAll: 190, Scissors: 260, Search: 250, Send: 110, Server: 300,
63
+ ServerCog: 50, Settings: 240, Settings2: 20, Shield: 160, Shrink: 160, Sliders: 290,
64
+ SlidersHorizontal: 50, Smartphone: 20, Space: 290, Sparkles: 180, Square: 60, SquareFunction: 220,
65
+ SquarePen: 10, Star: 170, StickyNote: 100, Store: 340, Sun: 90, Tablet: 290,
66
+ Tag: 310, Target: 200, Terminal: 210, TextSelect: 220, Ticket: 170, TriangleAlert: 210,
67
+ Type: 170, Undo2: 310, Upload: 0, UploadCloud: 50, User: 140, Variable: 330,
68
+ Volume2: 270, VolumeX: 50, Wand2: 270, WandSparkles: 40, Waypoints: 30, WholeWord: 240,
69
+ WrapText: 340, Wrench: 0, X: 230, Zap: 120, ZoomIn: 250, ZoomOut: 340,
70
70
  };
71
71
 
72
72
  /**
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /** Only a NEW stream→finish transition earns a notice; failures ride the same rule. */
7
+
8
+ import { describe, expect, test } from 'bun:test';
9
+
10
+ import {
11
+ runOutcomeNotices,
12
+ streamOutcomes,
13
+ type StreamOutcome,
14
+ } from '@/shared/lib/notifications/outcomes';
15
+ import type { WorkspaceFolderData } from '@/shared/types';
16
+
17
+ function folders(
18
+ sessions: Array<{
19
+ id: string;
20
+ title?: string;
21
+ streamStatus?: StreamOutcome;
22
+ runFailure?: string;
23
+ }>,
24
+ ): WorkspaceFolderData[] {
25
+ return [
26
+ {
27
+ id: 1,
28
+ name: 'workspace',
29
+ isExpanded: true,
30
+ hasMore: false,
31
+ totalSessions: sessions.length,
32
+ sessions: sessions.map((session) => ({
33
+ id: session.id,
34
+ folder_id: 1,
35
+ title: session.title ?? session.id,
36
+ streamStatus: session.streamStatus,
37
+ runFailure: session.runFailure,
38
+ })),
39
+ },
40
+ ];
41
+ }
42
+
43
+ describe('run outcome notices', () => {
44
+ test('a run that finished after streaming is one notice', () => {
45
+ const previous = new Map<string, StreamOutcome>([['a', 'stream']]);
46
+ expect(runOutcomeNotices(previous, folders([{ id: 'a', streamStatus: 'finish' }]))).toEqual([
47
+ { kind: 'finish', sessionId: 'a', title: 'a', detail: 'The run finished.' },
48
+ ]);
49
+ });
50
+
51
+ test('a badge already present at page load is not news', () => {
52
+ const previous = streamOutcomes(folders([{ id: 'a', streamStatus: 'finish' }]));
53
+ expect(runOutcomeNotices(previous, folders([{ id: 'a', streamStatus: 'finish' }]))).toEqual([]);
54
+ });
55
+
56
+ test('an aborted run is silent', () => {
57
+ const previous = new Map<string, StreamOutcome>([['a', 'stream']]);
58
+ expect(runOutcomeNotices(previous, folders([{ id: 'a', streamStatus: 'abort' }]))).toEqual([]);
59
+ });
60
+
61
+ test('a failure is an error notice carrying the reason', () => {
62
+ const previous = new Map<string, StreamOutcome>([['a', 'stream']]);
63
+ expect(
64
+ runOutcomeNotices(previous, folders([
65
+ { id: 'a', title: 'Fix the build', streamStatus: 'finish', runFailure: ' 401 invalid api key ' },
66
+ ])),
67
+ ).toEqual([
68
+ { kind: 'error', sessionId: 'a', title: 'Fix the build', detail: '401 invalid api key' },
69
+ ]);
70
+ });
71
+
72
+ test('an untitled session still names Kabmo', () => {
73
+ const previous = new Map<string, StreamOutcome>([['a', 'stream']]);
74
+ const [notice] = runOutcomeNotices(previous, folders([{ id: 'a', title: ' ', streamStatus: 'finish' }]));
75
+ expect(notice?.title).toBe('Kabmo');
76
+ });
77
+
78
+ test('only sessions that moved are reported', () => {
79
+ const previous = new Map<string, StreamOutcome>([
80
+ ['a', 'stream'],
81
+ ['b', 'finish'],
82
+ ['c', undefined],
83
+ ]);
84
+ const notices = runOutcomeNotices(previous, folders([
85
+ { id: 'a', streamStatus: 'finish' },
86
+ { id: 'b', streamStatus: 'finish' },
87
+ { id: 'c', streamStatus: 'finish' },
88
+ ]));
89
+ expect(notices.map((notice) => notice.sessionId)).toEqual(['a']);
90
+ });
91
+
92
+ test('a stream that keeps streaming earns nothing', () => {
93
+ const previous = new Map<string, StreamOutcome>([['a', 'stream']]);
94
+ expect(runOutcomeNotices(previous, folders([{ id: 'a', streamStatus: 'stream' }]))).toEqual([]);
95
+ });
96
+ });
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The run outcomes a sidebar-status snapshot is worth a notification for.
8
+ *
9
+ * Only `stream → finish` is news. `abort` is not: the operator either stopped
10
+ * the run themselves or a heal pass settled a process that had already gone
11
+ * away, and neither is an event to raise a banner for. A `finish` badge that is
12
+ * ALREADY there when the page loads is not news either — it is the state of the
13
+ * world the page woke up to, which is why the caller compares against the
14
+ * previous snapshot rather than notifying on presence.
15
+ *
16
+ * A failed run is the same transition with `runFailure` set, so the two
17
+ * notifications share one rule and cannot disagree about when they fire.
18
+ */
19
+
20
+ import type { WorkspaceFolderData } from '@/shared/types';
21
+
22
+ export type StreamOutcome = 'stream' | 'finish' | 'abort' | undefined;
23
+
24
+ export interface RunOutcomeNotice {
25
+ kind: 'finish' | 'error';
26
+ /** The session the message is about; also the notification's tag. */
27
+ sessionId: string;
28
+ title: string;
29
+ detail: string;
30
+ }
31
+
32
+ /** The status map one folder snapshot carries, for the next comparison. */
33
+ export function streamOutcomes(folders: WorkspaceFolderData[]): Map<string, StreamOutcome> {
34
+ const outcomes = new Map<string, StreamOutcome>();
35
+ for (const folder of folders) {
36
+ for (const session of folder.sessions ?? []) {
37
+ outcomes.set(String(session.id), session.streamStatus);
38
+ }
39
+ }
40
+ return outcomes;
41
+ }
42
+
43
+ /** The notices `folders` earns against `previous`. */
44
+ export function runOutcomeNotices(
45
+ previous: ReadonlyMap<string, StreamOutcome>,
46
+ folders: WorkspaceFolderData[],
47
+ ): RunOutcomeNotice[] {
48
+ const notices: RunOutcomeNotice[] = [];
49
+ for (const folder of folders) {
50
+ for (const session of folder.sessions ?? []) {
51
+ const sessionId = String(session.id);
52
+ if (session.streamStatus !== 'finish') continue;
53
+ if (previous.get(sessionId) !== 'stream') continue;
54
+ const failure = typeof session.runFailure === 'string' ? session.runFailure.trim() : '';
55
+ notices.push({
56
+ kind: failure ? 'error' : 'finish',
57
+ sessionId,
58
+ title: session.title?.trim() || 'Kabmo',
59
+ detail: failure || 'The run finished.',
60
+ });
61
+ }
62
+ }
63
+ return notices;
64
+ }