@kabmo-labs/kabmo 0.17.0 → 0.19.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 (438) hide show
  1. package/README.md +10 -7
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +523 -441
  4. package/dist/client/static/js/{index-rerjq5th.js → index-fcee4c13.js} +828 -818
  5. package/dist/client/static/js/index-sxdw908m.css +1 -0
  6. package/marketplace/plugins/command-runner/package.json +3 -2
  7. package/marketplace/plugins/git-forge/package.json +3 -2
  8. package/marketplace/plugins/session-info/package.json +3 -2
  9. package/marketplace/plugins/stats/package.json +3 -2
  10. package/package.json +3 -1
  11. package/src/client/components/auth/login-screen/index.tsx +2 -1
  12. package/src/client/components/common/ComposerPicker.tsx +1 -1
  13. package/src/client/components/common/FolderPicker.tsx +2 -2
  14. package/src/client/components/common/MarkdownRenderer.tsx +136 -89
  15. package/src/client/components/common/Modal.tsx +2 -2
  16. package/src/client/components/common/PWAInstallButton.tsx +2 -2
  17. package/src/client/components/common/ViewportSelector.tsx +1 -1
  18. package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
  19. package/src/client/components/common/anchored-menu/index.tsx +147 -0
  20. package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
  21. package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
  22. package/src/client/components/common/brand-wordmark/index.tsx +13 -2
  23. package/src/client/components/common/checkbox/style.test.ts +139 -0
  24. package/src/client/components/common/checkbox/style.ts +51 -0
  25. package/src/client/components/common/context-usage-button/index.tsx +2 -2
  26. package/src/client/components/common/file-icon/index.tsx +23 -9
  27. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  28. package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
  29. package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
  30. package/src/client/components/common/markdown-review/index.tsx +129 -0
  31. package/src/client/components/common/panel-mark/index.tsx +97 -0
  32. package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
  33. package/src/client/components/common/provider-icon/index.test.ts +14 -0
  34. package/src/client/components/common/provider-icon/index.tsx +4 -0
  35. package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
  36. package/src/client/components/common/provider-icon/resolve.ts +16 -3
  37. package/src/client/components/common/server-control/Panel.tsx +33 -23
  38. package/src/client/components/common/server-control/index.test.tsx +11 -5
  39. package/src/client/components/common/server-control/index.tsx +10 -8
  40. package/src/client/components/common/session-actions-menu/index.tsx +1 -1
  41. package/src/client/components/common/toolbar-row/index.tsx +1 -1
  42. package/src/client/components/layout/ActivityBar.tsx +22 -3
  43. package/src/client/components/layout/LeftDock.tsx +9 -2
  44. package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
  45. package/src/client/components/layout/WindowAura.tsx +27 -0
  46. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
  47. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
  48. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
  49. package/src/client/components/layout/desktop-layout/index.tsx +3 -1
  50. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +44 -23
  51. package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
  52. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
  53. package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
  54. package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
  55. package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
  56. package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
  57. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
  58. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
  59. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
  60. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
  61. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +40 -14
  62. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
  63. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
  64. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  65. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
  66. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
  67. package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
  68. package/src/client/components/layout/update-popup/index.tsx +5 -1
  69. package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
  70. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  71. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
  72. package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
  73. package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
  74. package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
  75. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
  76. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
  77. package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
  78. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  79. package/src/client/components/mobile/panel-chips.tsx +10 -2
  80. package/src/client/components/settings/Modal.tsx +4 -4
  81. package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
  82. package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
  83. package/src/client/components/settings/apply-side-effects.test.ts +30 -0
  84. package/src/client/components/settings/apply-side-effects.ts +14 -0
  85. package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
  86. package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
  87. package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
  88. package/src/client/components/settings/categories/McpSettings.tsx +4 -21
  89. package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
  90. package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
  91. package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
  92. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
  93. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
  94. package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
  95. package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
  96. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
  97. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
  98. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
  99. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
  100. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
  101. package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
  102. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
  103. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
  104. package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
  105. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +93 -77
  106. package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
  107. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +28 -15
  108. package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
  109. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
  110. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
  111. package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
  112. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
  113. package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
  114. package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
  115. package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
  116. package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
  117. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
  118. package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
  119. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
  120. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
  121. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
  122. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
  123. package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
  124. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
  125. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  126. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
  127. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
  128. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  129. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
  130. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +37 -8
  131. package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
  132. package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
  133. package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
  134. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
  135. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
  136. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
  137. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
  138. package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
  139. package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
  140. package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
  141. package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
  142. package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
  143. package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
  144. package/src/client/components/workspace/browser-panel/index.tsx +50 -4
  145. package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
  146. package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
  147. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
  148. package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
  149. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
  150. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
  151. package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
  152. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
  153. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  154. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
  155. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  156. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
  157. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
  158. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  159. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  160. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
  161. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
  162. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
  163. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
  164. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
  165. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
  166. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
  167. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
  168. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
  169. package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
  170. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
  171. package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
  172. package/src/client/components/workspace/diff-panel/changes.ts +28 -12
  173. package/src/client/components/workspace/diff-panel/index.tsx +2 -2
  174. package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
  175. package/src/client/components/workspace/diff-panel/merge.ts +21 -1
  176. package/src/client/components/workspace/editor/Body.tsx +7 -0
  177. package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
  178. package/src/client/components/workspace/editor/FilePane.tsx +12 -0
  179. package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
  180. package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
  181. package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
  182. package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
  183. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  184. package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
  185. package/src/client/components/workspace/editor/index.tsx +25 -22
  186. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
  187. package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
  188. package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
  189. package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
  190. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
  191. package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
  192. package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
  193. package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
  194. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
  195. package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
  196. package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
  197. package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
  198. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
  199. package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
  200. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
  201. package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
  202. package/src/client/components/workspace/git-panel/index.tsx +7 -0
  203. package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
  204. package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
  205. package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
  206. package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
  207. package/src/client/components/workspace/search-panel/Body.tsx +1 -1
  208. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
  209. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
  210. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
  211. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
  212. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
  213. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
  214. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
  215. package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
  216. package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
  217. package/src/client/data/agent-data/builtin.ts +0 -10
  218. package/src/client/data/agent-data/orchestrator.ts +0 -45
  219. package/src/client/data/agent-data/specialist.ts +0 -100
  220. package/src/client/data/mock/token-usage.ts +170 -120
  221. package/src/client/data/settings/omp-schema.json +33 -1
  222. package/src/client/glass.css +785 -0
  223. package/src/client/glass.test.ts +346 -0
  224. package/src/client/hooks/browser/use-annotate.test.ts +143 -0
  225. package/src/client/hooks/browser/use-annotate.ts +98 -0
  226. package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
  227. package/src/client/hooks/browser/use-close-tab.ts +67 -0
  228. package/src/client/hooks/browser/use-screencast.ts +13 -1
  229. package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
  230. package/src/client/hooks/chat/composer/browser-context.ts +40 -16
  231. package/src/client/hooks/chat/composer/items.test.ts +1 -1
  232. package/src/client/hooks/chat/composer/review-context.ts +38 -0
  233. package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
  234. package/src/client/hooks/chat/composer/use-draft.ts +31 -2
  235. package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
  236. package/src/client/hooks/editor/use-document-annotations.ts +124 -0
  237. package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
  238. package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
  239. package/src/client/hooks/editor/use-preview-review.ts +148 -0
  240. package/src/client/hooks/settings/agents.ts +149 -0
  241. package/src/client/hooks/settings/crud-list.test.ts +28 -6
  242. package/src/client/hooks/settings/crud-list.ts +96 -57
  243. package/src/client/hooks/settings/omp-config.ts +164 -0
  244. package/src/client/hooks/settings/useTokenUsage.ts +125 -0
  245. package/src/client/hooks/settings/write-feedback.test.ts +104 -0
  246. package/src/client/hooks/settings/write-feedback.ts +63 -0
  247. package/src/client/hooks/ui/glass-support.ts +57 -0
  248. package/src/client/hooks/ui/icon-style.ts +59 -0
  249. package/src/client/hooks/ui/markdown-hydration.ts +125 -0
  250. package/src/client/hooks/ui/stuck-header.test.ts +188 -0
  251. package/src/client/hooks/ui/stuck-header.ts +91 -0
  252. package/src/client/hooks/ui/style-attributes.test.ts +120 -0
  253. package/src/client/hooks/ui/surface-style.ts +56 -0
  254. package/src/client/hooks/ui/updates/index.test.ts +100 -1
  255. package/src/client/hooks/ui/updates/index.ts +50 -0
  256. package/src/client/hooks/ui/updates/notes.test.ts +138 -0
  257. package/src/client/hooks/ui/updates/notes.ts +57 -0
  258. package/src/client/hooks/workspace/panel-hues.ts +23 -0
  259. package/src/client/lib/browser/element-at.test.ts +229 -0
  260. package/src/client/lib/browser/element-at.ts +139 -0
  261. package/src/client/lib/review/client.ts +73 -0
  262. package/src/client/lib/router/search-params.ts +42 -20
  263. package/src/client/main.tsx +10 -0
  264. package/src/client/tailwind.css +329 -11
  265. package/src/server/lib/assets/shell-attributes.server.ts +80 -0
  266. package/src/server/lib/assets/shell-attributes.test.ts +86 -0
  267. package/src/server/lib/btw/lifecycle.server.ts +2 -2
  268. package/src/server/lib/db/schema.ts +7 -0
  269. package/src/server/lib/db/seed-terminal.test.ts +4 -0
  270. package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
  271. package/src/server/lib/omp/config/agents.ts +231 -61
  272. package/src/server/lib/omp/config/definitions.test.ts +9 -105
  273. package/src/server/lib/omp/config/extensions.ts +16 -7
  274. package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
  275. package/src/server/lib/omp/rpc/constants.test.ts +11 -0
  276. package/src/server/lib/omp/rpc/constants.ts +15 -0
  277. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
  278. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
  279. package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
  280. package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
  281. package/src/server/lib/omp/rpc/manager.ts +2 -2
  282. package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
  283. package/src/server/lib/omp/rpc/process.test.ts +106 -0
  284. package/src/server/lib/omp/rpc/process.ts +39 -18
  285. package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
  286. package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
  287. package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
  288. package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
  289. package/src/server/lib/omp/rpc/session-commands.ts +17 -3
  290. package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
  291. package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
  292. package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
  293. package/src/server/lib/omp/rpc/utility.ts +12 -0
  294. package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
  295. package/src/server/lib/panels/manifest.test.ts +20 -0
  296. package/src/server/lib/panels/manifest.ts +12 -0
  297. package/src/server/lib/panels/scan.server.ts +4 -0
  298. package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
  299. package/src/server/lib/queue/delivery-harness.ts +8 -4
  300. package/src/server/lib/queue/delivery.server.test.ts +29 -0
  301. package/src/server/lib/queue/delivery.server.ts +39 -0
  302. package/src/server/lib/queue/store.server.test.ts +22 -2
  303. package/src/server/lib/queue/store.server.ts +33 -11
  304. package/src/server/lib/review/schema.server.ts +45 -0
  305. package/src/server/lib/review/store.server.ts +138 -0
  306. package/src/server/lib/terminal/attach-replay.test.ts +132 -0
  307. package/src/server/lib/terminal/output.test.ts +166 -0
  308. package/src/server/lib/terminal/output.ts +104 -0
  309. package/src/server/lib/terminal/runtime.server.ts +5 -0
  310. package/src/server/lib/terminal/send-result.test.ts +33 -0
  311. package/src/server/lib/terminal/send-result.ts +32 -0
  312. package/src/server/lib/terminal/session.server.ts +45 -11
  313. package/src/server/lib/terminal/store-liveness.test.ts +4 -0
  314. package/src/server/lib/updates/active-notes.test.ts +149 -0
  315. package/src/server/lib/updates/active-notes.ts +75 -0
  316. package/src/server/lib/updates/changelog-file.ts +42 -11
  317. package/src/server/lib/updates/changelog.test.ts +15 -1
  318. package/src/server/lib/updates/omp.ts +42 -15
  319. package/src/server/lib/updates/release-url.ts +27 -1
  320. package/src/server/lib/usage/index-parse.test.ts +200 -0
  321. package/src/server/lib/usage/index-parse.ts +178 -0
  322. package/src/server/lib/usage/index-query.server.ts +248 -0
  323. package/src/server/lib/usage/index-scan.server.ts +343 -0
  324. package/src/server/lib/usage/index-schema.server.ts +82 -0
  325. package/src/server/lib/usage/index.test.ts +234 -0
  326. package/src/server/lib/usage/providers.server.ts +4 -53
  327. package/src/server/plugins/ssr.ts +22 -5
  328. package/src/server/routes/browser/index.ts +3 -0
  329. package/src/server/routes/browser/stream.ts +31 -2
  330. package/src/server/routes/browser/tabs.test.ts +94 -0
  331. package/src/server/routes/browser/tabs.ts +85 -0
  332. package/src/server/routes/index.ts +2 -0
  333. package/src/server/routes/review/bindings.ts +11 -0
  334. package/src/server/routes/review/index.ts +127 -0
  335. package/src/server/routes/review/routes.test.ts +191 -0
  336. package/src/server/routes/settings/agents.test.ts +180 -0
  337. package/src/server/routes/settings/agents.ts +95 -102
  338. package/src/server/routes/settings/mcp.test.ts +135 -0
  339. package/src/server/routes/settings/mcp.ts +14 -6
  340. package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
  341. package/src/server/routes/telemetry/tokens.test.ts +145 -0
  342. package/src/server/routes/telemetry/tokens.ts +70 -149
  343. package/src/server/routes/terminal/ws.ts +6 -5
  344. package/src/server/routes/updates/index.ts +2 -0
  345. package/src/server/routes/updates/notes.ts +34 -0
  346. package/src/server/routes/updates/routes.test.ts +49 -0
  347. package/src/shared/lib/browser/annotate.test.ts +283 -0
  348. package/src/shared/lib/browser/annotate.ts +231 -0
  349. package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
  350. package/src/shared/lib/browser/frame-gate.test.ts +91 -0
  351. package/src/shared/lib/browser/frame-gate.ts +69 -0
  352. package/src/shared/lib/browser/frame-params.test.ts +43 -0
  353. package/src/shared/lib/browser/frame-params.ts +60 -0
  354. package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
  355. package/src/shared/lib/browser/frame-pipeline.ts +80 -0
  356. package/src/shared/lib/browser/page-context.ts +60 -4
  357. package/src/shared/lib/browser/snapshot.test.ts +115 -0
  358. package/src/shared/lib/browser/snapshot.ts +112 -0
  359. package/src/shared/lib/browser/tab-close.test.ts +74 -0
  360. package/src/shared/lib/browser/tab-close.ts +77 -0
  361. package/src/shared/lib/browser/viewer.ts +45 -26
  362. package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
  363. package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
  364. package/src/shared/lib/chat/tool/artifact.ts +55 -20
  365. package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
  366. package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
  367. package/src/shared/lib/chat/tool/minimized.ts +64 -0
  368. package/src/shared/lib/chat/tool/summary.test.ts +28 -8
  369. package/src/shared/lib/chat/tool/summary.ts +3 -32
  370. package/src/shared/lib/icons/file-brand-color.ts +38 -0
  371. package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
  372. package/src/shared/lib/icons/icon-paint-css.ts +284 -0
  373. package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
  374. package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
  375. package/src/shared/lib/icons/tint.test.ts +273 -0
  376. package/src/shared/lib/icons/tint.ts +219 -0
  377. package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
  378. package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
  379. package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
  380. package/src/shared/lib/markdown/blocks/scan.ts +100 -0
  381. package/src/shared/lib/markdown/blocks/types.ts +62 -0
  382. package/src/shared/lib/markdown/marked.ts +58 -147
  383. package/src/shared/lib/markdown/math-extensions.ts +168 -0
  384. package/src/shared/lib/markdown/review/prompt.ts +77 -0
  385. package/src/shared/lib/markdown/review/reconcile.ts +55 -0
  386. package/src/shared/lib/markdown/review/review.test.ts +96 -0
  387. package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
  388. package/src/shared/lib/markdown/xml-sections.ts +139 -0
  389. package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
  390. package/src/shared/lib/models/provider/brand-color.ts +103 -0
  391. package/src/shared/lib/models/provider/label.ts +57 -0
  392. package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
  393. package/src/shared/lib/omp/config/agent-file.ts +43 -0
  394. package/src/shared/lib/omp/config/row-value.test.ts +95 -0
  395. package/src/shared/lib/omp/config/row-value.ts +97 -0
  396. package/src/shared/lib/omp/config/schema.test.ts +31 -0
  397. package/src/shared/lib/omp/config/schema.ts +6 -0
  398. package/src/shared/lib/omp/rpc/frame.test.ts +113 -47
  399. package/src/shared/lib/omp/rpc/frame.ts +107 -43
  400. package/src/shared/lib/settings/defaults.ts +4 -0
  401. package/src/shared/lib/theme/catalog.test.ts +5 -4
  402. package/src/shared/lib/theme/catalog.ts +18 -3
  403. package/src/shared/lib/theme/glass-support.test.ts +38 -0
  404. package/src/shared/lib/theme/glass-support.ts +73 -0
  405. package/src/shared/lib/theme/icon-style.test.ts +74 -0
  406. package/src/shared/lib/theme/icon-style.ts +90 -0
  407. package/src/shared/lib/theme/legibility.ts +91 -0
  408. package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
  409. package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
  410. package/src/shared/lib/theme/surface-style.test.ts +68 -0
  411. package/src/shared/lib/theme/surface-style.ts +91 -0
  412. package/src/shared/lib/theme/theme.test.ts +11 -7
  413. package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
  414. package/src/shared/lib/ui/menu-anchor.ts +89 -0
  415. package/src/shared/lib/usage/breakdown.test.ts +197 -0
  416. package/src/shared/lib/usage/breakdown.ts +241 -0
  417. package/src/shared/lib/usage/range.test.ts +204 -0
  418. package/src/shared/lib/usage/range.ts +240 -0
  419. package/src/shared/lib/usage/view.test.ts +85 -0
  420. package/src/shared/lib/usage/view.ts +74 -0
  421. package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
  422. package/src/shared/lib/workspace/panel-hues.ts +57 -0
  423. package/src/shared/types/browser.ts +78 -0
  424. package/src/shared/types/index.ts +1 -0
  425. package/src/shared/types/panels-registry.ts +6 -0
  426. package/src/shared/types/panels.ts +14 -0
  427. package/src/shared/types/settings/agent.ts +28 -6
  428. package/src/shared/types/settings/state.ts +30 -3
  429. package/src/shared/types/settings/write.ts +6 -0
  430. package/src/shared/types/tokenUsage.ts +128 -21
  431. package/src/shared/types/updates.ts +20 -0
  432. package/src/test-support/fake-omp-frames.ts +163 -0
  433. package/dist/client/static/js/index-3ve31rzx.css +0 -1
  434. package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
  435. package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
  436. package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
  437. package/src/server/lib/omp/session/usage/shaping.ts +0 -130
  438. /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
@@ -4,17 +4,15 @@
4
4
  */
5
5
 
6
6
  /**
7
- * The definition files Kabmo owns (agents, instruction files) and the plugin CLI wrapper. Agent discovery is read-only and forgiving: a malformed
8
- * frontmatter field becomes a default (`mode: all`, `temperature: null`) rather
9
- * than dropping the agent, a non-`.md` entry and an oversized file are skipped,
10
- * and a USER agent wins over a project agent with the same base name.
11
- * `writeAgentDefinition` is the only writer — it refuses a name that escapes the
12
- * agents directory and an empty prompt, and emits exactly the frontmatter keys
13
- * omp reads (`thinking-level`, `top_p`) with quoted scalars. An instruction file
14
- * of only whitespace REMOVES the file, or an empty AGENTS.md would still claim
15
- * the context scope; plugin wrappers pass `--scope` only where omp accepts it,
16
- * and `pluginCliError` prefers stderr. `PI_CODING_AGENT_DIR` points at a temp
17
- * dir and `KABMO_OMP_BIN` at a stub recording its argv — no real process (the stub is a compiled executable, so it spawns on both platforms).
7
+ * The definition files Kabmo owns besides agent definitions (the instruction
8
+ * files) and the plugin CLI wrapper. Agent discovery and the agent-file writer
9
+ * have their own suite, `agent-definitions.test.ts`.
10
+ *
11
+ * An instruction file of only whitespace REMOVES the file, or an empty AGENTS.md
12
+ * would still claim the context scope; plugin wrappers pass `--scope` only where
13
+ * omp accepts it, and `pluginCliError` prefers stderr. `PI_CODING_AGENT_DIR`
14
+ * points at a temp dir and `KABMO_OMP_BIN` at a stub recording its argv — no real
15
+ * process (the stub is a compiled executable, so it spawns on both platforms).
18
16
  */
19
17
 
20
18
  import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
@@ -23,7 +21,6 @@ import fs from 'node:fs';
23
21
  import { tmpdir } from 'node:os';
24
22
  import { join } from 'node:path';
25
23
 
26
- import { deleteAgentDefinition, discoverNativeAgents, writeAgentDefinition } from '@/server/lib/omp/config/agents';
27
24
  import { invalidateOmpCliCache } from '@/server/lib/omp/core/cli';
28
25
  import {
29
26
  clearInstructionFile,
@@ -111,99 +108,6 @@ afterAll(() => {
111
108
  fs.rmSync(root, { recursive: true, force: true });
112
109
  });
113
110
 
114
- describe('discoverNativeAgents', () => {
115
- test('shapes frontmatter, defaults malformed fields, and skips non-markdown entries', async () => {
116
- write(join(userAgents, 'one.md'), [
117
- '---',
118
- 'name: First',
119
- 'description: "a description"',
120
- 'mode: subagent',
121
- 'model: fast',
122
- 'thinking: high',
123
- 'temperature: 0.5',
124
- 'top_p: nope',
125
- '---',
126
- '',
127
- ' system prompt ',
128
- '',
129
- ].join('\n'));
130
- write(join(userAgents, 'two.md'), 'no frontmatter body\n');
131
- write(join(userAgents, 'ignored.txt'), 'x');
132
- fs.mkdirSync(join(userAgents, 'nested.md'), { recursive: true });
133
-
134
- const found = await discoverNativeAgents();
135
- expect(found.map((agent) => agent.id).sort()).toEqual(['omp-user-one', 'omp-user-two']);
136
- // By id, never by index: `readdir` order is not guaranteed (Windows returned `two` first).
137
- const byId = new Map(found.map((agent) => [agent.id, agent]));
138
- expect(byId.get('omp-user-one')).toMatchObject({
139
- name: 'First', description: 'a description', mode: 'subagent', overrideModel: 'fast', thinkingVariant: 'high',
140
- temperature: 0.5, topP: null, systemPrompt: 'system prompt', sourceRoot: 'user', filePath: join(userAgents, 'one.md'),
141
- });
142
- expect(byId.get('omp-user-two')).toMatchObject({
143
- name: 'two', description: '', mode: 'all', temperature: null, topP: null, systemPrompt: 'no frontmatter body',
144
- });
145
- });
146
-
147
- test('an unrecognized mode and a non-numeric temperature degrade to defaults', async () => {
148
- write(join(userAgents, 'weird.md'), '---\nmode: wizard\ntemperature: hot\n---\nbody\n');
149
- const agent = (await discoverNativeAgents()).find((item) => item.id === 'omp-user-weird');
150
- expect(agent).toMatchObject({ mode: 'all', temperature: null });
151
- });
152
-
153
- test('a user agent wins over a project agent with the same base name', async () => {
154
- write(join(userAgents, 'shared.md'), '---\nname: FromUser\n---\nuser body\n');
155
- write(join(projectAgents, 'shared.md'), '---\nname: FromProject\n---\nproject body\n');
156
- write(join(projectAgents, 'project-only.md'), '---\nname: OnlyProject\n---\nbody\n');
157
-
158
- const found = await discoverNativeAgents(projectAgents);
159
- expect(found.find((agent) => agent.filePath === join(userAgents, 'shared.md'))?.name).toBe('FromUser');
160
- expect(found.some((agent) => agent.filePath === join(projectAgents, 'shared.md'))).toBe(false);
161
- expect(found.find((agent) => agent.id === 'omp-project-project-only')?.sourceRoot).toBe('project');
162
- });
163
-
164
- test('an oversized definition is skipped and a missing directory is not an error', async () => {
165
- write(join(userAgents, 'huge.md'), `---\nname: Huge\n---\n${'x'.repeat(512 * 1024 + 1)}\n`);
166
- const found = await discoverNativeAgents();
167
- expect(found.some((agent) => agent.name === 'Huge')).toBe(false);
168
- expect(await discoverNativeAgents(join(root, 'no-such-dir'))).toEqual(found);
169
- });
170
- });
171
-
172
- describe('writeAgentDefinition', () => {
173
- test('refuses an unsafe file name and an empty system prompt', async () => {
174
- await expect(writeAgentDefinition({ fileName: '../escape', systemPrompt: 'x' })).rejects.toThrow(/may contain letters/);
175
- await expect(writeAgentDefinition({ fileName: 'ok', systemPrompt: ' ' })).rejects.toThrow(/cannot be empty/);
176
- expect(fs.existsSync(join(userAgents, 'ok.md'))).toBe(false);
177
- });
178
-
179
- test('writes omp frontmatter keys, quoting scalars, then deletes on request', async () => {
180
- const { path } = await writeAgentDefinition({
181
- fileName: 'written',
182
- description: 'has "quotes" and \\ slashes',
183
- mode: 'primary',
184
- thinking: 'low',
185
- temperature: 0.2,
186
- topP: 0.9,
187
- tools: ['read', 'bash'],
188
- systemPrompt: 'do the thing',
189
- });
190
- expect(path).toBe(join(userAgents, 'written.md'));
191
- const text = fs.readFileSync(path, 'utf8');
192
- expect(text).toContain('name: "written"');
193
- expect(text).toContain('mode: "primary"');
194
- expect(text).toContain('thinking-level: "low"');
195
- expect(text).toContain('temperature: 0.2');
196
- expect(text).toContain('top_p: 0.9');
197
- expect(text).toContain('tools: "read", "bash"');
198
- expect(text).toContain('has \\"quotes\\" and \\\\ slashes');
199
- expect(text.endsWith('\n')).toBe(true);
200
-
201
- expect(await deleteAgentDefinition('written')).toBe(true);
202
- expect(await deleteAgentDefinition('written')).toBe(false);
203
- await expect(deleteAgentDefinition('bad/name')).rejects.toThrow(/Invalid agent file name/);
204
- });
205
- });
206
-
207
111
  describe('instruction files', () => {
208
112
  test('narrows the kind and resolves the two omp basenames', () => {
209
113
  expect(isInstructionFileKind('agents')).toBe(true);
@@ -12,7 +12,7 @@
12
12
  import { join } from 'path';
13
13
  import { getAgentDir, pathExists } from '@/server/lib/omp/core/paths';
14
14
  import { getOmpConfigPath } from '@/server/lib/omp/config/yaml';
15
- import { withOmpYamlDocument } from '@/server/lib/omp/config/document';
15
+ import { seqAt, valueAt, withOmpYamlDocument } from '@/server/lib/omp/config/document';
16
16
  import { isRecord } from '@/shared/lib/util/guards';
17
17
 
18
18
  export interface DiscoveredExtension {
@@ -75,17 +75,26 @@ export async function readDisabledExtensions(): Promise<Set<string>> {
75
75
  }
76
76
  }
77
77
 
78
- /** Toggle one extension id in config.yml disabledExtensions atomically. */
78
+ /**
79
+ * Toggle one extension id in config.yml `disabledExtensions` atomically.
80
+ *
81
+ * The list is read through `valueAt`, which unwraps the YAML node: `doc.get()`
82
+ * returns a SEQ node, and `Array.isArray` on a node is `false` — so the whole
83
+ * list read as empty. Disabling then wrote a one-item list over the user's
84
+ * others, and ENABLING found the id absent from its own empty view, answered
85
+ * "nothing to do", and left the extension disabled forever.
86
+ */
79
87
  export async function setExtensionDisabled(id: string, disabled: boolean): Promise<boolean> {
80
88
  if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(id)) throw new Error('Invalid extension id');
81
89
  const path = getOmpConfigPath();
82
90
  return withOmpYamlDocument(path, (doc) => {
83
- const current = doc.get('disabledExtensions');
84
- const list = Array.isArray(current)
85
- ? current.filter((item): item is string => typeof item === 'string')
86
- : [];
91
+ const raw = valueAt(doc, ['disabledExtensions']);
92
+ const list = Array.isArray(raw) ? raw.filter((item): item is string => typeof item === 'string') : [];
87
93
  if (disabled === list.includes(id)) return { result: false, changed: false };
88
- doc.set('disabledExtensions', disabled ? [...list, id] : list.filter((item) => item !== id));
94
+ const next = disabled ? [...list, id] : list.filter((item) => item !== id);
95
+ const seq = seqAt(doc, ['disabledExtensions']);
96
+ if (seq) seq.items = next;
97
+ else doc.set('disabledExtensions', next);
89
98
  return { result: true, changed: true };
90
99
  });
91
100
  }
@@ -248,6 +248,33 @@ describe('extensions', () => {
248
248
  expect(await setExtensionDisabled('skill:a', false)).toBe(false);
249
249
  expect(await fs.promises.readFile(configPath, 'utf8')).toBe('theme: dark\n');
250
250
  });
251
+
252
+ /**
253
+ * The list was read with `doc.get()`, which returns a YAML SEQ node —
254
+ * `Array.isArray` on that is `false`, so the panel saw an empty list. Turning
255
+ * an extension back ON then found its id "absent" and answered "nothing to
256
+ * do", leaving it disabled forever; turning one OFF overwrote every other
257
+ * disabled id. Both directions are pinned here.
258
+ */
259
+ test('disabling keeps the ids already in the list', async () => {
260
+ const agent = await freshAgentDir();
261
+ const configPath = join(agent, 'config.yml');
262
+ await Bun.write(configPath, 'disabledExtensions:\n - skill:a\n - skill:b\n');
263
+ expect(await setExtensionDisabled('extension-module:c', true)).toBe(true);
264
+ expect(Bun.YAML.parse(await fs.promises.readFile(configPath, 'utf8'))).toEqual({
265
+ disabledExtensions: ['skill:a', 'skill:b', 'extension-module:c'],
266
+ });
267
+ });
268
+
269
+ test('enabling removes only its own id and reports the change', async () => {
270
+ const agent = await freshAgentDir();
271
+ const configPath = join(agent, 'config.yml');
272
+ await Bun.write(configPath, 'disabledExtensions:\n - skill:a\n - skill:b\n');
273
+ expect(await setExtensionDisabled('skill:a', false)).toBe(true);
274
+ expect(Bun.YAML.parse(await fs.promises.readFile(configPath, 'utf8'))).toEqual({
275
+ disabledExtensions: ['skill:b'],
276
+ });
277
+ });
251
278
  });
252
279
 
253
280
  describe('behavior rules', () => {
@@ -30,6 +30,7 @@ import {
30
30
  GET_STATE_TIMEOUT_MS,
31
31
  IDLE_REAP_MS,
32
32
  IMAGE_BEARING_COMMANDS,
33
+ IMAGE_PROMPT_ACK_TIMEOUT_MS,
33
34
  MAX_AGGREGATE_IMAGE_BYTES,
34
35
  MAX_ATTACHED_IMAGE_BYTES,
35
36
  MAX_ATTACHED_IMAGES,
@@ -43,6 +44,7 @@ import {
43
44
  SESSION_BUSY_MESSAGE,
44
45
  SUBAGENT_STALE_MS,
45
46
  buildSessionSpawnArgs,
47
+ promptAckTimeoutMs,
46
48
  resolveSpawnCwd,
47
49
  toImageContents,
48
50
  validateAgentImages,
@@ -71,11 +73,20 @@ describe('timeout windows and messages', () => {
71
73
  expect(READY_TIMEOUT_MS).toBe(120_000);
72
74
  expect(GET_STATE_TIMEOUT_MS).toBe(5_000);
73
75
  expect(PROMPT_ACK_TIMEOUT_MS).toBe(30_000);
76
+ expect(IMAGE_PROMPT_ACK_TIMEOUT_MS).toBe(120_000);
74
77
  expect(RELOAD_PLUGINS_TIMEOUT_MS).toBe(10_000);
75
78
  expect(NON_TERMINAL_CONTINUATION_GRACE_MS).toBe(2_000);
76
79
  expect(AWAITING_AGENT_START_TIMEOUT_MS).toBe(10_000);
77
80
  });
78
81
 
82
+ test('an image prompt gets the longer ack budget; a text prompt keeps the short one', () => {
83
+ // omp describes the image before it acks, which measured 21-26 s — past the
84
+ // text budget, and overrunning it RESETS the child and loses the turn.
85
+ expect(promptAckTimeoutMs([{ type: 'image', data: 'AAAA', mimeType: 'image/png' }])).toBe(IMAGE_PROMPT_ACK_TIMEOUT_MS);
86
+ expect(promptAckTimeoutMs(undefined)).toBe(PROMPT_ACK_TIMEOUT_MS);
87
+ expect(promptAckTimeoutMs([])).toBe(PROMPT_ACK_TIMEOUT_MS);
88
+ });
89
+
79
90
  test('user-facing messages are verbatim', () => {
80
91
  expect(RESTARTING_MESSAGE).toBe('This session is restarting — retry in a moment.');
81
92
  expect(SESSION_BUSY_MESSAGE).toBe('The OMP session is busy with the running turn; retry once it settles.');
@@ -88,6 +88,14 @@ export const SUBAGENT_STALE_MS = 30 * 60 * 1000;
88
88
  export const READY_TIMEOUT_MS = 120_000;
89
89
  export const GET_STATE_TIMEOUT_MS = 5_000;
90
90
  export const PROMPT_ACK_TIMEOUT_MS = 30_000;
91
+ // An image-bearing prompt is NOT ack'd at dispatch time: omp stores the bytes,
92
+ // downscales them and asks the vision model for a description FIRST. Measured
93
+ // on 18.16.0: a plain prompt acks in ~0 ms, while a 1 MB PNG took 21 s and a
94
+ // 30 MB one 26 s — a size-independent cost dominated by that model call, which
95
+ // left 4 s of headroom under the text budget. Overrunning the ack cap does not
96
+ // merely report late: `settleCommandTimeout` RESETS the child, destroying the
97
+ // turn the operator just sent.
98
+ export const IMAGE_PROMPT_ACK_TIMEOUT_MS = 120_000;
91
99
  // A `/reload-plugins` re-read of the skill/command roots. omp answers it in
92
100
  // ~16-40 ms even mid-turn (measured on 18.4.3), so a short cap only bounds a
93
101
  // child that stopped answering at all — the caller's retry is the recovery.
@@ -253,6 +261,13 @@ export function toImageContents(value: unknown): Array<{ type: 'image'; data: st
253
261
  return images?.length ? images : undefined;
254
262
  }
255
263
 
264
+ /** How long a prompt dispatch may wait for its ack, given what it carries.
265
+ * One function because both dispatch paths (the session command router and the
266
+ * BTW side question) must give an image prompt the same window. */
267
+ export function promptAckTimeoutMs(images: unknown): number {
268
+ return toImageContents(images) ? IMAGE_PROMPT_ACK_TIMEOUT_MS : PROMPT_ACK_TIMEOUT_MS;
269
+ }
270
+
256
271
  /** Pick a spawn cwd that actually exists. A session records the directory it
257
272
  * was created in, but that directory may have been deleted since: spawn()
258
273
  * would fail with ENOENT and `omp --cwd <missing>` throws in setProjectDir. */
@@ -29,6 +29,7 @@ export function makeHost(overrides: Partial<SessionFrameHost> = {}): SessionFram
29
29
  promptRunning: false,
30
30
  streaming: false,
31
31
  compacting: false,
32
+ runAborted: false,
32
33
  awaitingAgentStart: false,
33
34
  awaitingAgentStartDeadline: 0,
34
35
  continuationGraceUntil: 0,
@@ -25,37 +25,9 @@
25
25
 
26
26
  import { describe, expect, test } from 'bun:test';
27
27
 
28
- import { foldSessionFrame, type SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold';
28
+ import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
29
+ import { makeHost } from '@/server/lib/omp/rpc/frame-fold-host.test-util';
29
30
  import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
30
- import { ModeMirror } from '@/server/lib/omp/rpc/mode-mirror';
31
-
32
- /** The same minimal host the sibling suite uses. */
33
- function makeHost(overrides: Partial<SessionFrameHost> = {}): SessionFrameHost {
34
- return {
35
- sessionId: '',
36
- autoTitleWindowUntil: 0,
37
- autoTitleClaims: 0,
38
- autoTitleDispatch: null,
39
- autoTitlePending: true,
40
- autoTitleRequested: false,
41
- promptRunning: false,
42
- streaming: false,
43
- compacting: false,
44
- awaitingAgentStart: false,
45
- awaitingAgentStartDeadline: 0,
46
- continuationGraceUntil: 0,
47
- proc: { sendCommand: async () => undefined as never },
48
- emit() {},
49
- trackUiDialog() {},
50
- observeSubagent() {},
51
- syncRunModel() {},
52
- modeMirror: new ModeMirror(),
53
- isAlive: () => true,
54
- isBusy: () => false,
55
- send: async () => undefined,
56
- ...overrides,
57
- };
58
- }
59
31
 
60
32
  /**
61
33
  * The `tool_execution_end` frame is what moves a running session's sidebar row
@@ -119,6 +119,61 @@ describe('auto-title trigger wiring', () => {
119
119
  });
120
120
  });
121
121
 
122
+ describe('the abort verdict survives agent_end compaction', () => {
123
+ test('an aborted assistant message is remembered before agent_end trims it', () => {
124
+ // omp drops the messages it already delivered via `message_end` when the
125
+ // terminal frame is oversized, and the aborted assistant message is one of
126
+ // them — so reading the verdict from `agent_end.messages` alone reports a
127
+ // stopped run as finished. Measured on 18.16.0: `message_end`
128
+ // (role=assistant, stopReason=aborted) arrives BEFORE `agent_end`.
129
+ const host = makeHost();
130
+ fold(host, { type: 'agent_start' });
131
+ fold(host, { type: 'message_end', message: { role: 'user', content: 'go' } });
132
+ fold(host, { type: 'message_end', message: { role: 'assistant', stopReason: 'aborted' } });
133
+
134
+ expect(host.runAborted).toBe(true);
135
+
136
+ // The compacted terminal frame: everything streamed, nothing left to carry
137
+ // the stopReason.
138
+ fold(host, { type: 'agent_end', isTerminal: true, messages: [], messageCount: 2 });
139
+
140
+ // A stopped turn is not a settle, so the title latch must survive.
141
+ expect(host.autoTitlePending).toBe(true);
142
+ });
143
+
144
+ test('a natural stop is not remembered as an abort', () => {
145
+ const host = makeHost();
146
+ fold(host, { type: 'agent_start' });
147
+ fold(host, { type: 'message_end', message: { role: 'assistant', stopReason: 'stop' } });
148
+
149
+ expect(host.runAborted).toBe(false);
150
+ fold(host, { type: 'agent_end', isTerminal: true, messages: [] });
151
+ expect(host.autoTitlePending).toBe(false);
152
+ });
153
+
154
+ test('a new run starts un-aborted', () => {
155
+ const host = makeHost();
156
+ fold(host, { type: 'agent_start' });
157
+ fold(host, { type: 'message_end', message: { role: 'assistant', stopReason: 'aborted' } });
158
+ expect(host.runAborted).toBe(true);
159
+
160
+ fold(host, { type: 'agent_start' });
161
+ expect(host.runAborted).toBe(false);
162
+ });
163
+
164
+ test('the frame is still read for a host that attached mid-run', () => {
165
+ // A synthetic terminal frame (`run-settle.server.ts`) carries no
166
+ // `message_end` history, so the array remains the fallback source.
167
+ const host = makeHost();
168
+ fold(host, {
169
+ type: 'agent_end',
170
+ isTerminal: true,
171
+ messages: [{ role: 'assistant', stopReason: 'aborted' }],
172
+ });
173
+ expect(host.autoTitlePending).toBe(true);
174
+ });
175
+ });
176
+
122
177
  /**
123
178
  * The Kabmo's own background `/rename` answers on `prompt_result` with
124
179
  * `agentInvoked:false` — auto-title fires it right after the first settled user
@@ -46,6 +46,8 @@ export interface SessionFrameHost extends AutoTitleHost, QueueDeliveryHost {
46
46
  promptRunning: boolean;
47
47
  streaming: boolean;
48
48
  compacting: boolean;
49
+ /** Abort verdict of the current run — see `endedAborted` in `terminal-settle.ts`. */
50
+ runAborted: boolean;
49
51
  awaitingAgentStart: boolean;
50
52
  awaitingAgentStartDeadline: number;
51
53
  continuationGraceUntil: number;
@@ -99,6 +101,7 @@ export interface FrameFoldResult {
99
101
  */
100
102
  function handleMessageEnd(host: SessionFrameHost, event: AgentEvent): void {
101
103
  const message = event.message as Record<string, unknown> | undefined;
104
+ if (message?.role === 'assistant' && message.stopReason === 'aborted') host.runAborted = true;
102
105
  if (message?.role === 'user') void triggerAutoSessionTitle(host, 'opening');
103
106
  else if (message?.role === 'custom' && message.customType === SKILL_PROMPT_CUSTOM_TYPE) {
104
107
  void triggerAutoSessionTitle(host, 'opening');
@@ -188,6 +191,7 @@ export function foldSessionFrame(host: SessionFrameHost, event: AgentEvent): Fra
188
191
  case 'agent_start':
189
192
  host.promptRunning = true;
190
193
  host.streaming = true;
194
+ host.runAborted = false;
191
195
  host.awaitingAgentStart = false;
192
196
  host.awaitingAgentStartDeadline = 0;
193
197
  host.continuationGraceUntil = 0;
@@ -52,8 +52,7 @@ export class AgentSessionWrapper {
52
52
  promptDispatchPendingCount = 0;
53
53
  awaitingAgentStart = false;
54
54
  awaitingAgentStartDeadline = 0;
55
- /** Watches the deadline above so a dispatch whose turn never opens cannot
56
- * strand the session (see `AgentStartWatchdog`). */
55
+ /** Watches the deadline above so a stranded dispatch is settled (`AgentStartWatchdog`). */
57
56
  private readonly agentStartWatchdog: AgentStartWatchdog;
58
57
  /** Settles a run omp no longer owns (see `run-settle.server.ts`). */
59
58
  readonly runSettle: RunSettle;
@@ -61,6 +60,7 @@ export class AgentSessionWrapper {
61
60
  bashRunning = false;
62
61
  streaming = false;
63
62
  compacting = false;
63
+ runAborted = false;
64
64
  fastModeEnabled = false;
65
65
  runModel: SessionRunModel | null = null;
66
66
  private onDestroyCallback: (() => void) | null = null;
@@ -68,3 +68,14 @@ export interface RpcProcessOptions {
68
68
  }
69
69
 
70
70
  export const STDERR_TAIL_LIMIT = 8 * 1024;
71
+
72
+ /**
73
+ * How many transport notices one child may push before the reader stops
74
+ * repeating itself.
75
+ *
76
+ * A malformed chunk sequence is recoverable (the logical frame is lost, the
77
+ * session is not), but a server stuck emitting invalid chunks would otherwise
78
+ * append a notice per line and bury the transcript. Three is enough to prove
79
+ * the fault is real; the stderr tail keeps the full account for diagnostics.
80
+ */
81
+ export const MAX_PROTOCOL_ERROR_NOTICES = 3;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The transport faults `RpcProcess` has to survive.
8
+ *
9
+ * Two behaviours are pinned here, and neither can be observed against a real
10
+ * child (omp 18.16.0 advertises one set of ceilings and never emits a malformed
11
+ * chunk), so the scripted child says what the test needs:
12
+ *
13
+ * - **The ceilings come from `ready`.** The same chunk record is valid under
14
+ * the default 1 MiB physical ceiling and invalid under an advertised 4 MiB
15
+ * one — a 2 MiB logical frame is never chunked at 4 MiB — so the two runs
16
+ * differ only in what the server advertised.
17
+ * - **A malformed chunk sequence does not kill the session.** It used to call
18
+ * `dispose(0)`, which took the child's LSP servers, browser targets and
19
+ * prewarm slot down for a transport fault; now the reader reports a notice,
20
+ * loses that one logical frame, and keeps answering.
21
+ */
22
+
23
+ import { afterEach, expect, test } from 'bun:test';
24
+ import { mkdtempSync, rmSync } from 'node:fs';
25
+ import { tmpdir } from 'node:os';
26
+ import { join } from 'node:path';
27
+
28
+ import { describePosix } from '@/test-support/platform';
29
+ import { RpcProcess, type RpcFrame } from '@/server/lib/omp/rpc/process';
30
+
31
+ const FAKE_OMP = join(import.meta.dir, '../../../../test-support/fake-omp-frames.ts');
32
+
33
+ const started: RpcProcess[] = [];
34
+ let root = '';
35
+
36
+ function start(env: Record<string, string>): { proc: RpcProcess; frames: RpcFrame[] } {
37
+ root ||= mkdtempSync(join(tmpdir(), 'omp-frames-test-'));
38
+ const frames: RpcFrame[] = [];
39
+ const proc = new RpcProcess({
40
+ cwd: root,
41
+ env,
42
+ onFrame: (frame) => frames.push(frame),
43
+ dependencies: { resolveOmpBin: () => FAKE_OMP },
44
+ });
45
+ started.push(proc);
46
+ return { proc, frames };
47
+ }
48
+
49
+ /** Ready + v2 negotiation, the state every chunk test needs. */
50
+ async function negotiated(env: Record<string, string>): Promise<{ proc: RpcProcess; frames: RpcFrame[] }> {
51
+ const { proc, frames } = start(env);
52
+ const ready = await proc.waitReady(20_000);
53
+ await proc.negotiateProtocol(ready);
54
+ return { proc, frames };
55
+ }
56
+
57
+ afterEach(async () => {
58
+ for (const proc of started.splice(0)) await proc.dispose(500);
59
+ if (root) {
60
+ rmSync(root, { recursive: true, force: true });
61
+ root = '';
62
+ }
63
+ });
64
+
65
+ describePosix('RpcProcess framing', () => {
66
+ test('the advertised frame ceiling is what the decoder applies', async () => {
67
+ // 4 MiB advertised: a 2 MiB logical frame is below it, so it would never be
68
+ // chunked — the record is a protocol fault and must be reported, once.
69
+ const { proc, frames } = await negotiated({
70
+ FAKE_OMP_READY_MAX_FRAME_BYTES: String(4 * 1024 * 1024),
71
+ FAKE_OMP_CHUNK: 'valid-1mib',
72
+ });
73
+
74
+ const result = await proc.sendCommand<{ exitCode?: number }>({ type: 'bash', command: 'true' }, 20_000);
75
+
76
+ // The response still arrived: the reader continued past the bad record.
77
+ expect(result.exitCode).toBe(0);
78
+ const notices = frames.filter((frame) => frame.type === 'notice');
79
+ expect(notices).toHaveLength(1);
80
+ expect(String(notices[0].message)).toContain('malformed RPC frame');
81
+ expect(proc.isAlive).toBe(true);
82
+ }, 30_000);
83
+
84
+ test('the same record is accepted under the default ceiling', async () => {
85
+ // Control for the test above: identical bytes, no advertised override. The
86
+ // record is a valid FIRST slice, so nothing is reported and nothing is lost.
87
+ const { proc, frames } = await negotiated({ FAKE_OMP_CHUNK: 'valid-1mib' });
88
+
89
+ const result = await proc.sendCommand<{ exitCode?: number }>({ type: 'bash', command: 'true' }, 20_000);
90
+
91
+ expect(result.exitCode).toBe(0);
92
+ expect(frames.filter((frame) => frame.type === 'notice')).toHaveLength(0);
93
+ }, 30_000);
94
+
95
+ test('a malformed sequence costs one frame, not the child', async () => {
96
+ const { proc, frames } = await negotiated({ FAKE_OMP_CHUNK: 'bad-index' });
97
+
98
+ await proc.sendCommand({ type: 'bash', command: 'true' }, 20_000);
99
+ expect(frames.filter((frame) => frame.type === 'notice')).toHaveLength(1);
100
+
101
+ // The session is still there: a later command is answered by the SAME child.
102
+ const state = await proc.sendCommand<{ sessionId?: string }>({ type: 'get_state' }, 20_000);
103
+ expect(state.sessionId).toBe('fake-session');
104
+ expect(proc.isAlive).toBe(true);
105
+ }, 30_000);
106
+ });