@kabmo-labs/kabmo 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.md +1 -1
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +873 -524
  4. package/dist/client/static/js/{index-297dck9a.js → index-jcr5twtp.js} +799 -795
  5. package/dist/client/static/js/index-z3w7n85q.css +1 -0
  6. package/marketplace/plugins/stats/package.json +2 -2
  7. package/marketplace/plugins/stats/src/groups.test.ts +14 -0
  8. package/marketplace/plugins/stats/src/groups.ts +20 -0
  9. package/marketplace/plugins/stats/src/labels.test.ts +9 -0
  10. package/marketplace/plugins/stats/src/labels.ts +7 -0
  11. package/marketplace/plugins/stats/src/server.ts +1 -1
  12. package/package.json +1 -1
  13. package/src/client/App.tsx +20 -19
  14. package/src/client/components/common/ComposerTextarea.tsx +10 -1
  15. package/src/client/components/common/Modal.tsx +2 -6
  16. package/src/client/components/common/PWAInstallButton.tsx +3 -2
  17. package/src/client/components/common/Toast.test.tsx +298 -0
  18. package/src/client/components/common/Toast.tsx +103 -37
  19. package/src/client/components/common/ToastStack.tsx +33 -12
  20. package/src/client/components/common/ViewportSelector.tsx +122 -114
  21. package/src/client/components/common/context-usage-button/Ring.tsx +38 -1
  22. package/src/client/components/common/context-usage-button/index.test.tsx +19 -3
  23. package/src/client/components/common/context-usage-button/index.tsx +5 -2
  24. package/src/client/components/common/harness-glyph/brands.ts +65 -0
  25. package/src/client/components/common/harness-glyph/harness-glyph.test.ts +185 -0
  26. package/src/client/components/common/harness-glyph/index.tsx +131 -0
  27. package/src/client/components/common/header-controls/MoreMenu.tsx +2 -1
  28. package/src/client/components/common/header-controls/index.tsx +16 -8
  29. package/src/client/components/common/header-panel-buttons/index.tsx +4 -3
  30. package/src/client/components/common/panel-mark/index.test.tsx +2 -2
  31. package/src/client/components/common/panel-mark/index.tsx +11 -2
  32. package/src/client/components/common/search-select/index.tsx +305 -0
  33. package/src/client/components/common/search-select/search-select.test.tsx +217 -0
  34. package/src/client/components/common/server-control/index.tsx +3 -2
  35. package/src/client/components/common/session-row/index.tsx +18 -1
  36. package/src/client/components/common/toolbar-row/index.tsx +57 -20
  37. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -3
  38. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +3 -2
  39. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
  40. package/src/client/components/layout/desktop-layout/index.tsx +1 -3
  41. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -0
  42. package/src/client/components/layout/session-sidebar/SessionItem.tsx +18 -1
  43. package/src/client/components/layout/session-sidebar/SessionsView.tsx +1 -3
  44. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +332 -0
  45. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +310 -0
  46. package/src/client/components/layout/session-sidebar/about-modal/SocialLinks.tsx +63 -51
  47. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +4 -2
  48. package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
  49. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +136 -35
  50. package/src/client/components/layout/session-sidebar/harness-mark.test.tsx +126 -0
  51. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +4 -3
  52. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -0
  53. package/src/client/components/mobile/LayoutWrapper.tsx +1 -7
  54. package/src/client/components/mobile/SessionSidebar.tsx +1 -3
  55. package/src/client/components/mobile/mobile-main-view/Header.tsx +3 -2
  56. package/src/client/components/mobile/mobile-session-sidebar/Dialogs.tsx +0 -8
  57. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -0
  58. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +17 -1
  59. package/src/client/components/settings/Modal.tsx +26 -22
  60. package/src/client/components/settings/Sidebar.tsx +45 -5
  61. package/src/client/components/settings/categories/HarnessSettings.tsx +207 -0
  62. package/src/client/components/settings/categories/ProjectSettings.tsx +1 -3
  63. package/src/client/components/settings/categories/ProviderSettings.tsx +0 -4
  64. package/src/client/components/settings/categories/SkillCatalogSettings.tsx +13 -23
  65. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +23 -30
  66. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +20 -11
  67. package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +16 -16
  68. package/src/client/components/settings/categories/harness-settings/AddProviderForm.tsx +219 -0
  69. package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +268 -0
  70. package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +146 -0
  71. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +278 -0
  72. package/src/client/components/settings/categories/harness-settings/ImportSection.tsx +195 -0
  73. package/src/client/components/settings/categories/harness-settings/ProviderPanel.tsx +152 -0
  74. package/src/client/components/settings/categories/harness-settings/ToggleList.tsx +147 -0
  75. package/src/client/components/settings/categories/harness-settings/parts.test.tsx +97 -0
  76. package/src/client/components/settings/categories/harness-settings/parts.tsx +84 -0
  77. package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +313 -0
  78. package/src/client/components/settings/categories/omp-settings/RoleEditor.test.ts +60 -39
  79. package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +32 -41
  80. package/src/client/components/settings/categories/omp-settings/role-picker.test-util.ts +45 -0
  81. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +1 -1
  82. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +11 -4
  83. package/src/client/components/settings/groups.test.tsx +160 -0
  84. package/src/client/components/settings/harness-icons.test.tsx +134 -0
  85. package/src/client/components/workspace/browser-panel/AddressBar.tsx +3 -13
  86. package/src/client/components/workspace/browser-toolbar/clusters.tsx +237 -0
  87. package/src/client/components/workspace/browser-toolbar/index.test.tsx +167 -0
  88. package/src/client/components/workspace/browser-toolbar/index.tsx +99 -100
  89. package/src/client/components/workspace/btw-panel/Messages.tsx +4 -1
  90. package/src/client/components/workspace/btw-panel/index.tsx +2 -0
  91. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +11 -7
  92. package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
  93. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +13 -0
  94. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +13 -0
  95. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.test.ts +41 -0
  96. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +19 -14
  97. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
  98. package/src/client/components/workspace/chat-timeline/MessageList.tsx +6 -0
  99. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +14 -0
  100. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +4 -0
  101. package/src/client/components/workspace/chat-timeline/RunMark.tsx +58 -0
  102. package/src/client/components/workspace/chat-timeline/SubagentView.tsx +4 -1
  103. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +4 -0
  104. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -0
  105. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +11 -0
  106. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +13 -0
  107. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +8 -1
  108. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +27 -1
  109. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +48 -23
  110. package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +1 -0
  111. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +21 -1
  112. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +7 -0
  113. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +13 -0
  114. package/src/client/components/workspace/chat-timeline/chat-input/selection.ts +11 -2
  115. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +1 -0
  116. package/src/client/components/workspace/chat-timeline/index.tsx +17 -15
  117. package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +157 -0
  118. package/src/client/components/workspace/chat-timeline/run-mark.test.ts +104 -0
  119. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
  120. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
  121. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
  122. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
  123. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +31 -3
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +5 -1
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +56 -45
  127. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +38 -94
  128. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-parts.tsx +76 -0
  129. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +2 -1
  130. package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
  131. package/src/client/components/workspace/file-explorer/index.tsx +10 -6
  132. package/src/client/components/workspace/git-panel/index.test.ts +13 -3
  133. package/src/client/components/workspace/git-panel/index.tsx +1 -3
  134. package/src/client/components/workspace/model-dropdown/Fullscreen.tsx +92 -0
  135. package/src/client/components/workspace/model-dropdown/HarnessTabs.tsx +290 -0
  136. package/src/client/components/workspace/model-dropdown/Item.tsx +11 -0
  137. package/src/client/components/workspace/model-dropdown/Panel.tsx +119 -8
  138. package/src/client/components/workspace/model-dropdown/Section.tsx +4 -0
  139. package/src/client/components/workspace/model-dropdown/fullscreen-picker.ts +51 -0
  140. package/src/client/components/workspace/model-dropdown/harness-models.test.ts +177 -0
  141. package/src/client/components/workspace/model-dropdown/harness-models.ts +148 -0
  142. package/src/client/components/workspace/model-dropdown/harness-tabs.test.tsx +336 -0
  143. package/src/client/components/workspace/model-dropdown/index.tsx +114 -85
  144. package/src/client/components/workspace/model-dropdown/placement.test.tsx +127 -0
  145. package/src/client/components/workspace/model-dropdown/popover-metrics.test.ts +107 -0
  146. package/src/client/components/workspace/model-dropdown/popover-metrics.ts +118 -0
  147. package/src/client/components/workspace/model-dropdown/row-mutations.ts +106 -0
  148. package/src/client/components/workspace/model-dropdown/trigger.test.ts +22 -2
  149. package/src/client/components/workspace/model-dropdown/use-popover-size.ts +89 -0
  150. package/src/client/data/settings/omp-schema.json +224 -17
  151. package/src/client/hooks/chat/composer/index.ts +11 -2
  152. package/src/client/hooks/chat/composer/items.test.ts +11 -0
  153. package/src/client/hooks/chat/composer/items.ts +4 -2
  154. package/src/client/hooks/chat/composer/model-selection.test.ts +110 -0
  155. package/src/client/hooks/chat/composer/model-selection.ts +45 -4
  156. package/src/client/hooks/chat/omp/prompt-send.ts +4 -2
  157. package/src/client/hooks/chat/timeline/actions.ts +10 -5
  158. package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
  159. package/src/client/hooks/chat/timeline/composer-local-actions.test.ts +19 -81
  160. package/src/client/hooks/chat/timeline/composer-modes.ts +11 -2
  161. package/src/client/hooks/chat/timeline/composer-refs.ts +16 -1
  162. package/src/client/hooks/chat/timeline/index.ts +27 -35
  163. package/src/client/hooks/chat/timeline/mode-availability.test.ts +51 -0
  164. package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
  165. package/src/client/hooks/chat/timeline/modes.ts +41 -2
  166. package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
  167. package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
  168. package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
  169. package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
  170. package/src/client/hooks/chat/timeline/prompt-text.test.ts +7 -0
  171. package/src/client/hooks/chat/timeline/prompt-text.ts +15 -6
  172. package/src/client/hooks/chat/timeline/rewind-actions.test.ts +51 -1
  173. package/src/client/hooks/chat/timeline/rewind-actions.ts +23 -1
  174. package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
  175. package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
  176. package/src/client/hooks/chat/timeline/send-execute.test.ts +55 -0
  177. package/src/client/hooks/chat/timeline/send-props.ts +11 -3
  178. package/src/client/hooks/chat/timeline/send-steer.test.ts +2 -3
  179. package/src/client/hooks/chat/timeline/send.test-util.ts +3 -2
  180. package/src/client/hooks/chat/timeline/send.test.ts +2 -3
  181. package/src/client/hooks/chat/timeline/send.ts +34 -8
  182. package/src/client/hooks/chat/timeline/session-harness.test.ts +163 -0
  183. package/src/client/hooks/chat/timeline/session-harness.ts +164 -0
  184. package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
  185. package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
  186. package/src/client/hooks/chat/timeline/session-load.ts +6 -14
  187. package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
  188. package/src/client/hooks/chat/timeline/spawn-harness.ts +41 -0
  189. package/src/client/hooks/chat/timeline/timeline-running.ts +55 -0
  190. package/src/client/hooks/chat/timeline/tui-only-guard.ts +9 -0
  191. package/src/client/hooks/chat/timeline/undo-confirmation.test.ts +131 -0
  192. package/src/client/hooks/models/harness-catalog.ts +114 -0
  193. package/src/client/hooks/models/provider-writes.test.ts +81 -0
  194. package/src/client/hooks/models/provider-writes.ts +144 -0
  195. package/src/client/hooks/models/use-harness-versions.test.ts +152 -0
  196. package/src/client/hooks/models/use-harness-versions.ts +136 -0
  197. package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
  198. package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
  199. package/src/client/hooks/models/use-harnesses.test.ts +187 -0
  200. package/src/client/hooks/models/use-harnesses.ts +215 -0
  201. package/src/client/hooks/settings/providers/index.ts +1 -3
  202. package/src/client/hooks/ui/editor-error-toast.ts +10 -3
  203. package/src/client/hooks/ui/icon-style.ts +28 -0
  204. package/src/client/hooks/ui/on-click-outside.test.ts +104 -0
  205. package/src/client/hooks/ui/on-click-outside.ts +14 -2
  206. package/src/client/hooks/ui/theme.ts +6 -0
  207. package/src/client/hooks/ui/toast-queue.test.ts +126 -0
  208. package/src/client/hooks/ui/toasts.ts +132 -27
  209. package/src/client/hooks/ui/ui-feedback.test.ts +4 -91
  210. package/src/client/lib/ui/control-plate.test.ts +76 -0
  211. package/src/client/lib/ui/control-plate.ts +65 -0
  212. package/src/client/tailwind.css +47 -1
  213. package/src/server/lib/assets/shell-attributes.server.ts +9 -2
  214. package/src/server/lib/assets/shell-attributes.test.ts +22 -6
  215. package/src/server/lib/db/schema.ts +4 -0
  216. package/src/server/lib/harness/acp/acp-audit.server.ts +107 -0
  217. package/src/server/lib/harness/acp/acp-goal-driver.server.ts +153 -0
  218. package/src/server/lib/harness/acp/acp-goal-state.server.ts +136 -0
  219. package/src/server/lib/harness/acp/acp-goal.server.ts +273 -0
  220. package/src/server/lib/harness/acp/acp-goal.test.ts +229 -0
  221. package/src/server/lib/harness/acp/acp-telemetry.server.ts +133 -0
  222. package/src/server/lib/harness/acp/acp-telemetry.test.ts +85 -0
  223. package/src/server/lib/harness/acp/acp-todos.server.ts +45 -0
  224. package/src/server/lib/harness/acp/acp-todos.test.ts +43 -0
  225. package/src/server/lib/harness/acp/activation.test.ts +81 -0
  226. package/src/server/lib/harness/acp/activation.ts +72 -0
  227. package/src/server/lib/harness/acp/calls.ts +97 -0
  228. package/src/server/lib/harness/acp/client.test.ts +73 -0
  229. package/src/server/lib/harness/acp/client.ts +339 -0
  230. package/src/server/lib/harness/acp/commands.test.ts +92 -0
  231. package/src/server/lib/harness/acp/commands.ts +165 -0
  232. package/src/server/lib/harness/acp/frames.test.ts +315 -0
  233. package/src/server/lib/harness/acp/frames.ts +349 -0
  234. package/src/server/lib/harness/acp/mapper.ts +204 -0
  235. package/src/server/lib/harness/acp/permissions.test.ts +66 -0
  236. package/src/server/lib/harness/acp/permissions.ts +155 -0
  237. package/src/server/lib/harness/acp/prompt.test.ts +130 -0
  238. package/src/server/lib/harness/acp/prompt.ts +134 -0
  239. package/src/server/lib/harness/acp/protocol.ts +162 -0
  240. package/src/server/lib/harness/acp/session-config.test.ts +73 -0
  241. package/src/server/lib/harness/acp/session-config.ts +148 -0
  242. package/src/server/lib/harness/acp/session-facts.ts +71 -0
  243. package/src/server/lib/harness/acp/session-handshake.ts +89 -0
  244. package/src/server/lib/harness/acp/session-idle.ts +51 -0
  245. package/src/server/lib/harness/acp/session-notifications.ts +95 -0
  246. package/src/server/lib/harness/acp/session-observers.test.ts +193 -0
  247. package/src/server/lib/harness/acp/session-options.ts +33 -0
  248. package/src/server/lib/harness/acp/session-permissions.test.ts +105 -0
  249. package/src/server/lib/harness/acp/session-permissions.ts +74 -0
  250. package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
  251. package/src/server/lib/harness/acp/session-turns.ts +95 -0
  252. package/src/server/lib/harness/acp/session-usage.ts +60 -0
  253. package/src/server/lib/harness/acp/session-web-state.ts +61 -0
  254. package/src/server/lib/harness/acp/session.test-util.ts +160 -0
  255. package/src/server/lib/harness/acp/session.test.ts +233 -0
  256. package/src/server/lib/harness/acp/session.ts +350 -0
  257. package/src/server/lib/harness/acp/turn.ts +199 -0
  258. package/src/server/lib/harness/acp/verbs.ts +87 -0
  259. package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
  260. package/src/server/lib/harness/auto-probe.server.ts +178 -0
  261. package/src/server/lib/harness/capabilities.ts +67 -0
  262. package/src/server/lib/harness/config-invalidation.test.ts +91 -0
  263. package/src/server/lib/harness/config.server.test.ts +105 -0
  264. package/src/server/lib/harness/config.server.ts +98 -0
  265. package/src/server/lib/harness/enabled.server.test.ts +87 -0
  266. package/src/server/lib/harness/enabled.server.ts +61 -0
  267. package/src/server/lib/harness/launch-table.ts +195 -0
  268. package/src/server/lib/harness/launch.test.ts +220 -0
  269. package/src/server/lib/harness/launch.ts +216 -0
  270. package/src/server/lib/harness/probe-cache.server.test.ts +154 -0
  271. package/src/server/lib/harness/probe-cache.server.ts +177 -0
  272. package/src/server/lib/harness/provider-entry.ts +212 -0
  273. package/src/server/lib/harness/provider-file.server.ts +67 -0
  274. package/src/server/lib/harness/provider-import.test.ts +191 -0
  275. package/src/server/lib/harness/provider-probe.server.ts +123 -0
  276. package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
  277. package/src/server/lib/harness/provider-sources.server.ts +308 -0
  278. package/src/server/lib/harness/provider-write-error.ts +19 -0
  279. package/src/server/lib/harness/provider-write.server.test.ts +308 -0
  280. package/src/server/lib/harness/provider-write.server.ts +339 -0
  281. package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
  282. package/src/server/lib/harness/provider-zcode.server.ts +324 -0
  283. package/src/server/lib/harness/register.server.ts +36 -0
  284. package/src/server/lib/harness/registry.ts +58 -0
  285. package/src/server/lib/harness/schema.server.ts +129 -0
  286. package/src/server/lib/harness/session-store.server.test.ts +175 -0
  287. package/src/server/lib/harness/session-store.server.ts +206 -0
  288. package/src/server/lib/harness/session-title.server.test.ts +109 -0
  289. package/src/server/lib/harness/session-title.server.ts +70 -0
  290. package/src/server/lib/harness/session.ts +74 -0
  291. package/src/server/lib/harness/spawn.server.ts +133 -0
  292. package/src/server/lib/harness/update-state.server.ts +185 -0
  293. package/src/server/lib/lifecycle/after-listen.ts +7 -0
  294. package/src/server/lib/models/provider-items.server.ts +1 -1
  295. package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
  296. package/src/server/lib/models/registry-refresh.server.ts +98 -0
  297. package/src/server/lib/omp/config/models-config.ts +4 -0
  298. package/src/server/lib/omp/core/cli.ts +13 -0
  299. package/src/server/lib/omp/core/host-resolution.test.ts +6 -3
  300. package/src/server/lib/omp/rpc/child-config.ts +5 -4
  301. package/src/server/lib/omp/rpc/constants.test.ts +2 -1
  302. package/src/server/lib/omp/rpc/event-fanout.ts +9 -0
  303. package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
  304. package/src/server/lib/omp/rpc/rpc-primitives.test.ts +11 -0
  305. package/src/server/lib/omp/rpc/session-registration.ts +7 -2
  306. package/src/server/lib/omp/rpc/session-registry.test.ts +2 -1
  307. package/src/server/lib/omp/rpc/session-registry.ts +74 -5
  308. package/src/server/lib/omp/session/acp-rows.server.ts +79 -0
  309. package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
  310. package/src/server/lib/omp/session/delete.server.ts +12 -0
  311. package/src/server/lib/omp/session/sidebar-data.harness.test.ts +247 -0
  312. package/src/server/lib/omp/session/sidebar-data.server.ts +56 -3
  313. package/src/server/lib/queue/delivery.server.test.ts +4 -2
  314. package/src/server/lib/queue/payload.test.ts +67 -0
  315. package/src/server/lib/queue/payload.ts +9 -3
  316. package/src/server/lib/realtime/signals.server.test.ts +99 -0
  317. package/src/server/lib/realtime/signals.server.ts +25 -5
  318. package/src/server/lib/realtime/topics/session-data.server.ts +29 -0
  319. package/src/server/lib/realtime/topics/session.server.ts +3 -3
  320. package/src/server/routes/agent/command-resume.test.ts +77 -0
  321. package/src/server/routes/agent/command.test.ts +243 -2
  322. package/src/server/routes/agent/command.ts +78 -15
  323. package/src/server/routes/agent/harness-command.ts +133 -0
  324. package/src/server/routes/agent/new.ts +63 -1
  325. package/src/server/routes/chat/rewind.test.ts +147 -0
  326. package/src/server/routes/chat/rewind.ts +29 -7
  327. package/src/server/routes/chat/session.test.ts +240 -0
  328. package/src/server/routes/chat/session.ts +96 -4
  329. package/src/server/routes/harness/add-provider.test.ts +233 -0
  330. package/src/server/routes/harness/import-action.ts +272 -0
  331. package/src/server/routes/harness/import.test.ts +196 -0
  332. package/src/server/routes/harness/index.ts +13 -0
  333. package/src/server/routes/harness/root.ts +280 -0
  334. package/src/server/routes/harness/toggle.test.ts +127 -0
  335. package/src/server/routes/harness/update.ts +259 -0
  336. package/src/server/routes/harness/versions.test.ts +148 -0
  337. package/src/server/routes/harness/versions.ts +105 -0
  338. package/src/server/routes/index.ts +2 -0
  339. package/src/server/routes/sessions/delete-acp.test.ts +227 -0
  340. package/src/server/routes/sessions/queue.ts +7 -2
  341. package/src/server/routes/sessions/routes-queue.test.ts +52 -0
  342. package/src/server/routes/sessions/routes.test.ts +47 -13
  343. package/src/server/routes/sessions/session.ts +35 -0
  344. package/src/server/routes/settings/commands-harness.test.ts +92 -0
  345. package/src/server/routes/settings/commands.ts +26 -0
  346. package/src/server/routes/settings/model-override.ts +5 -2
  347. package/src/server/routes/settings/provider-entry.ts +2 -2
  348. package/src/server/routes/settings/provider-model.ts +2 -2
  349. package/src/server/routes/settings/provider-models.ts +2 -2
  350. package/src/server/routes/settings/provider-refresh.ts +6 -4
  351. package/src/server/routes/settings/providers.ts +3 -1
  352. package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
  353. package/src/server/routes/settings/skills.ts +12 -0
  354. package/src/shared/lib/chat/ask-form/fields.ts +76 -0
  355. package/src/shared/lib/chat/ask-form/index.ts +323 -0
  356. package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
  357. package/src/shared/lib/chat/ask-form/types.ts +43 -0
  358. package/src/shared/lib/chat/ask-form.test.ts +137 -0
  359. package/src/shared/lib/chat/ask-questions.test.ts +65 -1
  360. package/src/shared/lib/chat/ask-questions.ts +51 -145
  361. package/src/shared/lib/chat/ask-results.ts +198 -0
  362. package/src/shared/lib/chat/composer/client.ts +20 -8
  363. package/src/shared/lib/chat/context/usage.test.ts +8 -4
  364. package/src/shared/lib/chat/context/usage.ts +17 -3
  365. package/src/shared/lib/chat/omp/abort.test.ts +61 -0
  366. package/src/shared/lib/chat/omp/abort.ts +8 -2
  367. package/src/shared/lib/chat/omp/tool-frames.test.ts +23 -0
  368. package/src/shared/lib/chat/omp/tool-frames.ts +12 -2
  369. package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
  370. package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
  371. package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
  372. package/src/shared/lib/chat/tool/summary-wait.test.ts +18 -8
  373. package/src/shared/lib/chat/tool/wait-facts.ts +14 -8
  374. package/src/shared/lib/harness/brand-color.test.ts +66 -0
  375. package/src/shared/lib/harness/brand-color.ts +96 -0
  376. package/src/shared/lib/harness/catalog.test.ts +88 -0
  377. package/src/shared/lib/harness/catalog.ts +169 -0
  378. package/src/shared/lib/harness/config-fields.test.ts +139 -0
  379. package/src/shared/lib/harness/config-fields.ts +168 -0
  380. package/src/shared/lib/harness/config.test.ts +153 -0
  381. package/src/shared/lib/harness/config.ts +206 -0
  382. package/src/shared/lib/harness/dialects.test.ts +140 -0
  383. package/src/shared/lib/harness/dialects.ts +249 -0
  384. package/src/shared/lib/harness/enabled.test.ts +79 -0
  385. package/src/shared/lib/harness/enabled.ts +72 -0
  386. package/src/shared/lib/harness/menu.test.ts +94 -0
  387. package/src/shared/lib/harness/menu.ts +88 -0
  388. package/src/shared/lib/harness/provider-facts.test.ts +199 -0
  389. package/src/shared/lib/harness/provider-facts.ts +349 -0
  390. package/src/shared/lib/harness/provider-slug.ts +46 -0
  391. package/src/shared/lib/harness/providers.ts +175 -0
  392. package/src/shared/lib/harness/rewind.ts +24 -0
  393. package/src/shared/lib/harness/status.test.ts +158 -0
  394. package/src/shared/lib/harness/status.ts +112 -0
  395. package/src/shared/lib/harness/update-plan.test.ts +163 -0
  396. package/src/shared/lib/harness/update-plan.ts +140 -0
  397. package/src/shared/lib/harness/updates.test.ts +106 -0
  398. package/src/shared/lib/harness/updates.ts +177 -0
  399. package/src/shared/lib/icons/icon-paint-authority.test.ts +16 -4
  400. package/src/shared/lib/icons/icon-paint-authority.ts +57 -12
  401. package/src/shared/lib/icons/icon-paint-bucket.test.ts +84 -0
  402. package/src/shared/lib/icons/icon-paint-css.test.ts +23 -25
  403. package/src/shared/lib/icons/icon-paint-css.ts +69 -55
  404. package/src/shared/lib/icons/icon-paint-harness.test.ts +73 -0
  405. package/src/shared/lib/icons/icon-paint-harness.ts +75 -0
  406. package/src/shared/lib/icons/icon-paint-ink.ts +108 -0
  407. package/src/shared/lib/icons/icon-paint-panel.ts +19 -4
  408. package/src/shared/lib/icons/icon-paint-weight.ts +21 -2
  409. package/src/shared/lib/icons/icon-tone.ts +118 -21
  410. package/src/shared/lib/icons/tint-hues.generated.ts +100 -284
  411. package/src/shared/lib/icons/tint-tones.test.ts +79 -25
  412. package/src/shared/lib/icons/tint.ts +66 -6
  413. package/src/shared/lib/models/client.ts +10 -1
  414. package/src/shared/lib/models/provider/vendors.ts +72 -0
  415. package/src/shared/lib/omp/config/schema.test.ts +36 -0
  416. package/src/shared/lib/omp/dialog-methods.ts +4 -3
  417. package/src/shared/lib/omp/session/messages-map-trace.test.ts +42 -0
  418. package/src/shared/lib/omp/session/messages-map.ts +6 -1
  419. package/src/shared/lib/omp/session/parse-message-blocks-toolcall.test.ts +8 -0
  420. package/src/shared/lib/omp/session/parse-message-blocks.ts +6 -1
  421. package/src/shared/lib/omp/session/shell-trace.test.ts +69 -0
  422. package/src/shared/lib/omp/session/shell-trace.ts +63 -0
  423. package/src/shared/lib/omp/session/sidebar.ts +37 -10
  424. package/src/shared/lib/omp/session/wait-idle.test.ts +47 -0
  425. package/src/shared/lib/omp/session/wait-idle.ts +93 -0
  426. package/src/shared/lib/omp/session/wait.test.ts +34 -33
  427. package/src/shared/lib/omp/session/wait.ts +25 -39
  428. package/src/shared/lib/settings/sections.ts +24 -0
  429. package/src/shared/lib/theme/css.ts +2 -0
  430. package/src/shared/lib/theme/ink-scale.ts +21 -1
  431. package/src/shared/lib/theme/theme.test.ts +25 -9
  432. package/src/shared/lib/ui/safe-area.test.ts +28 -0
  433. package/src/shared/lib/ui/safe-area.ts +42 -0
  434. package/src/shared/lib/ui/toast-duration.test.ts +74 -0
  435. package/src/shared/lib/ui/toast-duration.ts +70 -0
  436. package/src/shared/types/harness-version.ts +59 -0
  437. package/src/shared/types/harness.ts +201 -0
  438. package/src/shared/types/index.ts +2 -0
  439. package/src/shared/types/omp/agent.ts +13 -0
  440. package/src/shared/types/settings/state.ts +10 -1
  441. package/src/shared/types/workspace.ts +10 -0
  442. package/src/test-support/env.ts +38 -0
  443. package/src/test-support/file-explorer-render.test-util.ts +37 -0
  444. package/src/test-support/file-explorer.test-util.ts +20 -18
  445. package/src/test-support/harness-table.test-util.ts +108 -0
  446. package/dist/client/static/js/index-7ppta1pb.css +0 -1
@@ -157,4 +157,27 @@ describe('foldToolEnd', () => {
157
157
  foldToolEnd({ toolCallId: 'c1', result: { content: [{ type: 'text', text: 'done' }] } }, deps);
158
158
  expect(deps.toolResultsRef.current?.get('c1')?.durationMs).toBeUndefined();
159
159
  });
160
+
161
+ test('a transport’s flattened output wins over an envelope this parser cannot walk', () => {
162
+ // ACP sends `{content:[{type:"content", content:{type:"text"}}]}`, which
163
+ // `toolResultText` does not descend into. The mapper flattens it onto
164
+ // `output`; reading only the raw result left the finished card blank.
165
+ const { deps } = makeDeps();
166
+ foldToolEnd({
167
+ toolCallId: 'c1',
168
+ result: { content: [{ type: 'content', content: { type: 'text', text: 'nested' } }] },
169
+ output: 'nested',
170
+ }, deps);
171
+ expect(deps.toolResultsRef.current?.get('c1')?.output).toBe('nested');
172
+ });
173
+
174
+ test('a progress frame’s flattened output is stored too', () => {
175
+ const { deps } = makeDeps();
176
+ foldToolUpdate({
177
+ toolCallId: 'c1',
178
+ partialResult: { content: [{ type: 'content', content: { type: 'text', text: 'nested progress' } }] },
179
+ output: 'nested progress',
180
+ }, deps);
181
+ expect(deps.toolResultsRef.current?.get('c1')?.output).toBe('nested progress');
182
+ });
160
183
  });
@@ -75,7 +75,13 @@ export function foldToolStart(data: Record<string, unknown>, deps: OmpAgentFoldD
75
75
  export function foldToolUpdate(data: Record<string, unknown>, deps: OmpAgentFoldDeps): void {
76
76
  const callId = typeof data.toolCallId === 'string' ? data.toolCallId : undefined;
77
77
  if (!callId) return;
78
- const partial = toolResultText(data.partialResult);
78
+ // A transport that already flattened its result (`acpToolOutput`) wins: the
79
+ // ACP content envelope can nest its text one level below what
80
+ // `toolResultText` walks, and reading only the raw snapshot left a running
81
+ // card blank on every agent that spells it that way.
82
+ const partial = typeof data.output === 'string' && data.output.length > 0
83
+ ? data.output
84
+ : toolResultText(data.partialResult);
79
85
  const stored = deps.toolResultsRef.current?.get(callId);
80
86
  const details = resultDetails({ result: data.partialResult }) ?? stored?.details;
81
87
  putToolResult(deps, callId, {
@@ -100,7 +106,11 @@ export function foldToolEnd(data: Record<string, unknown>, deps: OmpAgentFoldDep
100
106
  const images = extractToolImages(data.result);
101
107
  const startedAt = deps.toolResultsRef.current?.get(callId)?.startedAt;
102
108
  putToolResult(deps, callId, {
103
- output: toolResultText(data.result),
109
+ // Same precedence as an update: a transport's own flattened read is more
110
+ // faithful than re-walking a raw envelope this parser does not know.
111
+ output: typeof data.output === 'string' && data.output.length > 0
112
+ ? data.output
113
+ : toolResultText(data.result),
104
114
  isError: data.isError === true,
105
115
  details: resultDetails(data),
106
116
  pending: false,
@@ -23,6 +23,7 @@ import {
23
23
  queueStreamingUpdate,
24
24
  } from '@/shared/lib/chat/timeline/stream-coalescer';
25
25
  import { appendNoticeRow } from '@/shared/lib/chat/timeline/command-output';
26
+ import { reportPromptError } from '@/shared/lib/chat/timeline/prompt-error';
26
27
  import { retryNotice } from '@/shared/lib/chat/timeline/provider-retry';
27
28
  import { handleAgentStart, handleResumeStream, handleTurnStart } from '@/shared/lib/chat/timeline/run-signals';
28
29
  import { isAnswerableUiRequest } from '@/shared/lib/omp/dialog-methods';
@@ -271,8 +272,13 @@ export function createOmpAgentCallbacks(deps: OmpAgentCallbacksDeps): OmpAgentCa
271
272
  if (sid) setTimeout(() => refreshSessionMeta(sid), 150);
272
273
  },
273
274
  onPromptError: (errorMessage) => {
275
+ // Drop queued stream updates first: any frame from the failed run that
276
+ // has not been folded yet would resurrect partial content beside the row
277
+ // this error is about to mark.
278
+ disposeStreamingCoalescer();
274
279
  setGenerating(false);
275
280
  abortControllerRef.current = null;
281
+ reportPromptError(errorMessage, deps);
276
282
  console.error('OMP prompt error:', errorMessage);
277
283
  },
278
284
  // The prompt ran a built-in slash command (omp answered on the command
@@ -312,8 +318,14 @@ export function createOmpAgentCallbacks(deps: OmpAgentCallbacksDeps): OmpAgentCa
312
318
  const sid = adoptedSessionIdRef.current ?? sessionIdRef.current;
313
319
  if (sid) refreshSessionMeta(sid);
314
320
  },
315
- onNotice: (_level, message) => {
321
+ onNotice: (level, message) => {
316
322
  console.info('OMP notice:', message);
323
+ // A warning/error notice is the only place some transports report why a
324
+ // turn went nowhere (ACP can push an error `notice` instead of failing
325
+ // the prompt). A console line is not a surface the operator reads.
326
+ if ((level === 'error' || level === 'warning') && message.trim()) {
327
+ appendNoticeRow(message, deps);
328
+ }
317
329
  },
318
330
  onExtensionUiRequest: (request: IncomingExtensionUiRequest) => {
319
331
  // The blocking-method list is SHARED with the server
@@ -0,0 +1,146 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * A prompt failure the timeline must DRAW.
8
+ *
9
+ * ACP's silent turn emits `prompt_error` with no `message_end`; before this the
10
+ * callback only logged it, so the assistant bubble stayed empty and the reason
11
+ * was invisible. These cases pin where the failure lands: the optimistic row it
12
+ * would have streamed into, or a dedicated row when the run already answered.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+ import type { ChatMessageData } from '@/shared/types';
17
+ import { reportPromptError, type PromptErrorDeps } from '@/shared/lib/chat/timeline/prompt-error';
18
+ import {
19
+ createOmpAgentCallbacks,
20
+ type OmpAgentCallbacksDeps,
21
+ } from '@/shared/lib/chat/timeline/omp-callbacks';
22
+
23
+ interface MountedPromptError {
24
+ deps: PromptErrorDeps;
25
+ ref: { current: string | null };
26
+ rows: () => ChatMessageData[];
27
+ persisted: () => ChatMessageData[][];
28
+ }
29
+
30
+ function mount(messages: ChatMessageData[], placeholderId: string | null = null): MountedPromptError {
31
+ let rows = messages;
32
+ const persisted: ChatMessageData[][] = [];
33
+ const ref = { current: placeholderId };
34
+ const deps = {
35
+ setLocalMessages: (update: ChatMessageData[] | ((prev: ChatMessageData[]) => ChatMessageData[])) => {
36
+ rows = typeof update === 'function' ? update(rows) : update;
37
+ },
38
+ aiPlaceholderIdRef: ref,
39
+ persistMessages: (next: ChatMessageData[]) => {
40
+ persisted.push(next);
41
+ },
42
+ };
43
+ return {
44
+ deps,
45
+ ref,
46
+ rows: () => rows,
47
+ persisted: () => persisted,
48
+ };
49
+ }
50
+
51
+ const userRow: ChatMessageData = { id: 'u1', role: 'user', content: 'hello' };
52
+
53
+ describe('reportPromptError', () => {
54
+ test('marks the empty optimistic row and disarms the placeholder', () => {
55
+ const probe = mount([userRow, { id: 'ai1', role: 'ai', content: '' }], 'ai1');
56
+ reportPromptError('The agent ended the turn without sending an answer', probe.deps);
57
+
58
+ expect(probe.ref.current).toBeNull();
59
+ expect(probe.rows()).toHaveLength(2);
60
+ expect(probe.rows()[1]?.error).toEqual({ message: 'The agent ended the turn without sending an answer' });
61
+ expect(probe.persisted()).toHaveLength(1);
62
+ });
63
+
64
+ test('a completed answer is not relabelled as the failure', () => {
65
+ const probe = mount([userRow, { id: 'ai1', role: 'ai', content: 'the answer' }]);
66
+ reportPromptError('agent crashed', probe.deps);
67
+
68
+ expect(probe.rows()).toHaveLength(3);
69
+ expect(probe.rows()[1]?.error).toBeUndefined();
70
+ expect(probe.rows()[2]?.error).toEqual({ message: 'agent crashed' });
71
+ });
72
+
73
+ test('a blank trailing row adopts the error instead of stacking a card', () => {
74
+ const probe = mount([userRow, { id: 'ai1', role: 'ai', content: '' }]);
75
+ reportPromptError('agent crashed', probe.deps);
76
+
77
+ expect(probe.rows()).toHaveLength(2);
78
+ expect(probe.rows()[1]?.error).toEqual({ message: 'agent crashed' });
79
+ });
80
+
81
+ test('the same failure arriving twice does not stack two cards', () => {
82
+ const probe = mount([userRow, { id: 'ai1', role: 'ai', content: 'the answer' }]);
83
+ reportPromptError('agent crashed', probe.deps);
84
+ reportPromptError('agent crashed', probe.deps);
85
+
86
+ expect(probe.rows()).toHaveLength(3);
87
+ });
88
+
89
+ test('the first, specific reason survives a later generic one', () => {
90
+ const probe = mount([userRow, { id: 'ai1', role: 'ai', content: '' }], 'ai1');
91
+ reportPromptError('401 Unauthorized', probe.deps);
92
+ reportPromptError('The agent ended the turn without sending an answer', probe.deps);
93
+
94
+ expect(probe.rows()[1]?.error).toEqual({ message: '401 Unauthorized' });
95
+ });
96
+ });
97
+
98
+ /** The callbacks with every dep defaulted, wiring the three the row needs into
99
+ * this file's state probe. */
100
+ function callbacksFor(probe: MountedPromptError) {
101
+ const deps: OmpAgentCallbacksDeps = {
102
+ setGenerating: () => {},
103
+ setGeneratingVerb: () => {},
104
+ activityRef: { current: '' },
105
+ scrollToBottom: () => {},
106
+ adoptedSessionIdRef: { current: null },
107
+ sessionIdRef: { current: 'sess-1' },
108
+ metaRefreshedRef: { current: null },
109
+ refreshSessionMeta: () => {},
110
+ setLocalMessages: probe.deps.setLocalMessages,
111
+ aiPlaceholderIdRef: probe.ref,
112
+ optimisticUserIdRef: { current: null },
113
+ pendingUserDisplaysRef: { current: [] },
114
+ persistMessages: probe.deps.persistMessages,
115
+ abortControllerRef: { current: null },
116
+ appSettings: {},
117
+ enqueueExtensionDialog: () => {},
118
+ withdrawExtensionDialog: () => {},
119
+ reloadMessages: () => {},
120
+ needsReloadRef: { current: false },
121
+ };
122
+ return createOmpAgentCallbacks(deps);
123
+ }
124
+
125
+ describe('prompt_error / notice wiring', () => {
126
+ test('a silent ACP failure marks the empty assistant row and persists it', () => {
127
+ const probe = mount([userRow, { id: 'ai1', role: 'ai', content: '' }], 'ai1');
128
+ callbacksFor(probe).onPromptError?.('The agent ended the turn without sending an answer');
129
+
130
+ expect(probe.ref.current).toBeNull();
131
+ expect(probe.rows()[1]?.error).toEqual({ message: 'The agent ended the turn without sending an answer' });
132
+ expect(probe.persisted()).toHaveLength(1);
133
+ });
134
+
135
+ test('a warning notice becomes a row; an info notice does not', () => {
136
+ const probe = mount([userRow]);
137
+ const callbacks = callbacksFor(probe);
138
+
139
+ callbacks.onNotice?.('warning', 'provider refused the request');
140
+ callbacks.onNotice?.('info', 'model warmed');
141
+
142
+ expect(probe.rows().filter((row) => row.notice)).toEqual([
143
+ expect.objectContaining({ notice: 'provider refused the request' }),
144
+ ]);
145
+ });
146
+ });
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Turn a `prompt_error` frame into a row the timeline DRAWS.
8
+ *
9
+ * The frame used to reach `onPromptError` only, which logged it and cleared the
10
+ * generating flag. On an ACP harness a silent failure therefore left the
11
+ * optimistic AI bubble exactly as it was — an empty answer — and the reason
12
+ * lived in the console. The row the answer would have streamed into is where
13
+ * the error belongs: `MessageItem` already draws `msg.error` as the
14
+ * Provider/API Error alert for omp's transcript rows, so this path reuses that
15
+ * renderer instead of inventing a second error card.
16
+ *
17
+ * The placeholder is consumed even when it never received a byte; leaving it
18
+ * armed would let a late frame fill an empty bubble after the error.
19
+ */
20
+
21
+ import type { Dispatch, SetStateAction } from 'preact/compat';
22
+ import type { ChatMessageData } from '@/shared/types';
23
+ import { isNoticeRow } from '@/shared/lib/chat/notice-row';
24
+ import { formatClock } from '@/shared/lib/format/time';
25
+
26
+ export interface PromptErrorDeps {
27
+ setLocalMessages: Dispatch<SetStateAction<ChatMessageData[]>>;
28
+ aiPlaceholderIdRef: { current: string | null };
29
+ persistMessages: (messages: ChatMessageData[]) => void;
30
+ }
31
+
32
+ /** A row with nothing the timeline renders: no text, no thinking, no tool. */
33
+ function isBlankAnswer(msg: ChatMessageData): boolean {
34
+ if (typeof msg.content === 'string' && msg.content.trim()) return false;
35
+ if (msg.thinking || msg.monologue) return false;
36
+ return !(msg.toolCalls?.length || msg.actions?.length || msg.actions2?.length);
37
+ }
38
+
39
+ /** Tail-most rendered AI row IF it is still blank, else -1. */
40
+ function blankAssistantIndex(messages: ChatMessageData[]): number {
41
+ for (let index = messages.length - 1; index >= 0; index--) {
42
+ const msg = messages[index];
43
+ if (msg.role === 'user' || isNoticeRow(msg)) continue;
44
+ return isBlankAnswer(msg) ? index : -1;
45
+ }
46
+ return -1;
47
+ }
48
+
49
+ function errorRow(message: string): ChatMessageData {
50
+ return {
51
+ id: `prompt-error-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
52
+ role: 'ai',
53
+ date: `Today, ${formatClock()}`,
54
+ content: '',
55
+ error: { message },
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Attach the failure to the run's own row, or append a dedicated error row when
61
+ * the run already produced an answer (an agent that dies after replying must
62
+ * not relabel that reply as the failure).
63
+ */
64
+ export function reportPromptError(errorMessage: string, deps: PromptErrorDeps): void {
65
+ const message = errorMessage.trim() || 'Prompt failed';
66
+ const placeholderId = deps.aiPlaceholderIdRef.current;
67
+ deps.aiPlaceholderIdRef.current = null;
68
+ const row = errorRow(message);
69
+
70
+ deps.setLocalMessages((prev) => {
71
+ const placeholderIndex = placeholderId ? prev.findIndex((msg) => msg.id === placeholderId) : -1;
72
+ const targetIndex = placeholderIndex !== -1 ? placeholderIndex : blankAssistantIndex(prev);
73
+ if (targetIndex === -1) {
74
+ // Two failure frames for one run must not stack two identical cards.
75
+ if (prev[prev.length - 1]?.error?.message === message) return prev;
76
+ const next = [...prev, row];
77
+ deps.persistMessages(next);
78
+ return next;
79
+ }
80
+ const next = prev.map((msg, index) =>
81
+ index === targetIndex
82
+ ? { ...msg, error: { ...(msg.error ?? {}), message: msg.error?.message || message } }
83
+ : msg,
84
+ );
85
+ deps.persistMessages(next);
86
+ return next;
87
+ });
88
+ }
@@ -59,9 +59,9 @@ describe('toolSummary — wait', () => {
59
59
  const summary = toolSummary(tool({
60
60
  type: 'wait',
61
61
  durationMs: 900,
62
- details: { op: 'wait', from: 'main', waited: { from: 'Sleeper', body: 'done' } },
62
+ details: { op: 'wait', from: 'main', waited: [{ from: 'Sleeper', body: 'done' }] },
63
63
  }));
64
- expect(summary?.line).toBe('900ms · message received');
64
+ expect(summary?.line).toBe('900ms · 1 message');
65
65
  });
66
66
 
67
67
  test('falls back to the measured call span when no job reports one', () => {
@@ -71,16 +71,26 @@ describe('toolSummary — wait', () => {
71
71
  expect(summary?.line).toBe('2m 6s · no jobs');
72
72
  });
73
73
 
74
- test('a capped wait says so instead of “no jobs”', () => {
75
- // The cap and a service wake share `{op:'wait', jobs:[]}`; only the prose
76
- // separates them, and the chip has to carry that distinction.
74
+ test('an idle window says so instead of “no jobs”', () => {
75
+ // The idle return and a service wake share `{op:'wait', jobs:[]}`; only the
76
+ // prose separates them, and the chip has to carry that distinction.
77
77
  const summary = toolSummary(tool({
78
78
  type: 'wait',
79
- durationMs: 1_800_000,
80
- output: 'Wait limit reached; background work may still be running.',
79
+ durationMs: 10_000,
80
+ output: 'No reply within 10s.',
81
81
  details: { op: 'wait', jobs: [] },
82
82
  }));
83
- expect(summary?.line).toBe('30m 0s · 30m limit reached');
83
+ expect(summary?.line).toBe('10s · idle 10s');
84
+ });
85
+
86
+ test('the streak omp names outranks the single window', () => {
87
+ const summary = toolSummary(tool({
88
+ type: 'wait',
89
+ durationMs: 15_000,
90
+ output: 'No reply within 10s.\n\n<system-notice>Nothing new after 15.0s of back-to-back waits. …</system-notice>',
91
+ details: { op: 'wait', jobs: [] },
92
+ }));
93
+ expect(summary?.line).toBe('15s · idle 15s total');
84
94
  });
85
95
 
86
96
  test('an unreadable result keeps the generic fallback', () => {
@@ -16,7 +16,8 @@
16
16
  */
17
17
 
18
18
  import type { ToolCallData } from '@/shared/types/chat';
19
- import { waitCounts, waitHitLimit, waitJobSpanMs, waitViewOf } from '@/shared/lib/omp/session/wait';
19
+ import { waitCounts, waitJobSpanMs, waitViewOf } from '@/shared/lib/omp/session/wait';
20
+ import { waitIdleLabel, waitIdleOf } from '@/shared/lib/omp/session/wait-idle';
20
21
  import { countPhrase, formatToolMs } from '@/shared/lib/chat/tool/labels';
21
22
  import type { ToolFact } from '@/shared/lib/chat/tool/summary';
22
23
 
@@ -37,18 +38,23 @@ export function waitFacts(tool: ToolCallData): ToolFact[] {
37
38
  // own `details: {}`) has an UNKNOWN job list, not an empty one: claiming
38
39
  // "no jobs" would say the call looked and found none.
39
40
  if (!view.reported) return facts;
41
+ // An idle window is the RESULT of this call, so it is read before the job
42
+ // count: a wait whose window elapsed with jobs still running reports both.
43
+ const idle = waitIdleOf(tool.output);
40
44
  if (counts.total > 0) {
41
45
  facts.push({ kind: 'count', label: countPhrase(counts.total, 'job') });
42
46
  if (counts.running > 0) facts.push({ kind: 'note', label: `${counts.running} running` });
43
47
  if (counts.failed > 0) facts.push({ kind: 'warn', label: `${counts.failed} failed`, tone: 'error' });
44
48
  }
45
49
  if (view.interrupted) facts.push({ kind: 'warn', label: 'interrupted', tone: 'warn' });
46
- // The cap firing is an OUTCOME, not an absence: omp answers the same
47
- // `{op:'wait', jobs:[]}` for a service wake, and only the prose tells them
48
- // apart. Without this chip a capped wait read as `no jobs`, which says the
49
- // call found nothing rather than that it ran out of time.
50
- else if (waitHitLimit(view, tool.output)) facts.push({ kind: 'warn', label: '30m limit reached', tone: 'warn' });
51
- else if (view.waited) facts.push({ kind: 'note', label: 'message received' });
52
- else if (counts.total === 0) facts.push({ kind: 'note', label: 'no jobs' });
50
+ // An idle return is an OUTCOME, not an absence: omp answers the same
51
+ // `{op:'wait', jobs:[]}` for a service wake and for a reply that can no longer
52
+ // arrive, and only the prose tells them apart. Without this chip an idle wait
53
+ // read as `no jobs`, which says the call found nothing rather than that its
54
+ // window elapsed (omp 18.17.0 removed the 30-minute cap that used to name it).
55
+ else if (idle) facts.push({ kind: 'warn', label: waitIdleLabel(idle), tone: 'warn' });
56
+ else if (view.waited.length > 0) {
57
+ facts.push({ kind: 'note', label: countPhrase(view.waited.length, 'message') });
58
+ } else if (counts.total === 0) facts.push({ kind: 'note', label: 'no jobs' });
53
59
  return facts;
54
60
  }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The colour a harness mark is painted in.
8
+ *
9
+ * Two properties matter, and each fails silently in production:
10
+ *
11
+ * - **the two omp surfaces must differ.** Both transports share one glyph, so a
12
+ * shared colour draws two identical marks side by side; the hue is the only
13
+ * thing left to tell `omp` (RPC) from `omp` (ACP) once the tab's label is gone.
14
+ * Every value still has to clear the non-text floor on every shipped palette,
15
+ * which is why the pair goes through `legiblePair` rather than a raw hex.
16
+ * - **an unknown key is `null`, not a guess.** A colour invented for a mark with
17
+ * no brand would be the only fabricated hue in the app.
18
+ */
19
+
20
+ import { describe, expect, test } from 'bun:test';
21
+
22
+ import {
23
+ HARNESS_BRAND_COLORS,
24
+ HARNESS_SURFACE_COLORS,
25
+ harnessColorFor,
26
+ } from '@/shared/lib/harness/brand-color';
27
+ import { HARNESS_CATALOG } from '@/shared/lib/harness/catalog';
28
+ import { BRAND_CONTRAST_FLOOR, worstSurfaceContrast } from '@/shared/lib/theme/legibility';
29
+
30
+ describe('harness surfaces', () => {
31
+ test('omp over RPC keeps its purple and omp over ACP is red', () => {
32
+ expect(HARNESS_SURFACE_COLORS['omp-rpc']?.base).toBe('#9b4dff');
33
+ expect(HARNESS_SURFACE_COLORS['omp-acp']?.base).toBe('#dc2626');
34
+ expect(harnessColorFor('omp-rpc', 'light')).not.toBe(harnessColorFor('omp-acp', 'light'));
35
+ });
36
+
37
+ test('the surface id wins over the brand key it shares', () => {
38
+ // `omp` is the brand both transports draw; asking by ID has to answer with
39
+ // the surface, or the override is unreachable.
40
+ expect(HARNESS_BRAND_COLORS.omp.light).toBe(HARNESS_SURFACE_COLORS['omp-rpc']?.light);
41
+ expect(harnessColorFor('omp-acp', 'light')).toBe(HARNESS_SURFACE_COLORS['omp-acp'].light);
42
+ expect(harnessColorFor('omp', 'light')).toBe(HARNESS_BRAND_COLORS.omp.light);
43
+ });
44
+
45
+ test('every painted value clears the non-text floor on its own variant', () => {
46
+ for (const entry of Object.values(HARNESS_SURFACE_COLORS)) {
47
+ expect(worstSurfaceContrast(entry.light, 'light')).toBeGreaterThanOrEqual(BRAND_CONTRAST_FLOOR);
48
+ if (entry.dark) {
49
+ expect(worstSurfaceContrast(entry.dark, 'dark')).toBeGreaterThanOrEqual(BRAND_CONTRAST_FLOOR);
50
+ }
51
+ }
52
+ });
53
+
54
+ test('every surface names a harness this build knows', () => {
55
+ // A typo in the table would be a rule matching nothing — a mark that keeps the
56
+ // shared brand hue with no test to say so.
57
+ for (const id of Object.keys(HARNESS_SURFACE_COLORS)) {
58
+ expect(HARNESS_CATALOG[id as keyof typeof HARNESS_CATALOG]).toBeDefined();
59
+ }
60
+ });
61
+
62
+ test('an unknown key has no colour rather than an invented one', () => {
63
+ expect(harnessColorFor('some-future-agent', 'light')).toBeNull();
64
+ expect(harnessColorFor(null, 'dark')).toBeNull();
65
+ });
66
+ });
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The brand colour of every harness mark, derived the same way provider marks
8
+ * are.
9
+ *
10
+ * **`base` is the brand's OWN hex and nothing else.** The two values that get
11
+ * painted come from {@link legiblePair} against the palettes this build ships,
12
+ * because one hex cannot clear contrast on both a light and a dark paper —
13
+ * `claude`'s `#D97757` is a measured example in the provider table.
14
+ *
15
+ * **`dark: null` means "draw it in the theme's ink".** omp, pi and cursor publish
16
+ * near-monochrome marks (`#000000`, or a gradient that reads as one); mixing a
17
+ * black toward white lands on grey, which is indistinguishable from the ink it
18
+ * was meant to replace while claiming to be a brand colour. That is the honest
19
+ * half of full-colour mode: brand colour WHERE ONE EXISTS, never a tint invented
20
+ * to fill a row.
21
+ *
22
+ * Sources: the vendor's colour variant in `@lobehub/icons-static-svg`, and for
23
+ * omp its own `favicon.svg` gradient stops (`#ed4abf → #9b4dff → #5ad8e6`) of
24
+ * which the middle stop is the one that reads as the brand.
25
+ */
26
+
27
+ import { legiblePair } from '@/shared/lib/theme/legibility';
28
+
29
+ /** The brand's own hex per harness glyph name (`harness-glyph/brands.ts`). */
30
+ const HARNESS_BASES: Readonly<Record<string, string>> = {
31
+ // The favicon's gradient midpoint: the hue a reader recognises as omp.
32
+ omp: '#9b4dff',
33
+ claudecode: '#D97757',
34
+ codex: '#3941FF',
35
+ opencode: '#000000',
36
+ deepseek: '#5786FE',
37
+ commandcode: '#000000',
38
+ pi: '#000000',
39
+ kimi: '#000000',
40
+ minimax: '#E73562',
41
+ qwen: '#6950EF',
42
+ cursor: '#000000',
43
+ // Z.ai publishes a near-monochrome mark (the desktop app's icon is white on
44
+ // black), so it paints in the theme's ink like the other wordmark-style marks.
45
+ zcode: '#000000',
46
+ // A multi-stop mark; the blue stop is the one its own dominant uses carry.
47
+ antigravity: '#3186FF',
48
+ };
49
+
50
+ /**
51
+ * The two omp SURFACES, told apart by colour.
52
+ *
53
+ * A brand table is keyed by the vendor's mark, and omp publishes ONE — so
54
+ * `omp-rpc` and `omp-acp` drew the same purple, which is correct while a tab
55
+ * carries the words "omp" and "omp (ACP)" beside it and wrong the moment the tab
56
+ * is the mark alone: two identical glyphs side by side, naming two different
57
+ * transports. The hue is what carries the difference, and the purple is omp's
58
+ * own (the favicon's gradient midpoint) with the ACP surface moved to red.
59
+ *
60
+ * Keyed by `HarnessId`, not by glyph: this layer exists precisely for the case a
61
+ * glyph cannot express, so it must never be consulted a second time for one.
62
+ */
63
+ const HARNESS_SURFACE_BASES: Readonly<Record<string, string>> = {
64
+ 'omp-rpc': '#9b4dff',
65
+ 'omp-acp': '#dc2626',
66
+ };
67
+
68
+ export interface HarnessBrandColor {
69
+ /** The vendor's published hex, as-is (for tests and documentation). */
70
+ base: string;
71
+ light: string;
72
+ dark: string | null;
73
+ }
74
+
75
+ /** The per-surface table, solved by the same rule as the brand table. */
76
+ export const HARNESS_SURFACE_COLORS: Readonly<Record<string, HarnessBrandColor>> = Object.fromEntries(
77
+ Object.entries(HARNESS_SURFACE_BASES).map(([id, base]) => [id, { base, ...legiblePair(base) }]),
78
+ );
79
+
80
+ export const HARNESS_BRAND_COLORS: Readonly<Record<string, HarnessBrandColor>> = Object.fromEntries(
81
+ Object.entries(HARNESS_BASES).map(([name, base]) => [name, { base, ...legiblePair(base) }]),
82
+ );
83
+
84
+ /**
85
+ * The colour a harness mark is painted in, or `null` for the theme ink.
86
+ *
87
+ * `name` may be a harness ID or a brand glyph key. The SURFACE table wins: when
88
+ * two transports share one mark, the id is the only thing that can tell them
89
+ * apart, and it is the more specific answer.
90
+ */
91
+ export function harnessColorFor(name: string | null | undefined, variant: 'light' | 'dark'): string | null {
92
+ if (!name) return null;
93
+ const entry = HARNESS_SURFACE_COLORS[name] ?? HARNESS_BRAND_COLORS[name];
94
+ if (!entry) return null;
95
+ return variant === 'dark' ? entry.dark : entry.light;
96
+ }