@kabmo-labs/kabmo 0.16.0 → 0.18.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 (381) hide show
  1. package/README.md +2 -2
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +552 -471
  4. package/dist/client/static/js/index-hp75vsv9.css +1 -0
  5. package/dist/client/static/js/{index-cpydmygd.js → index-tc09dtca.js} +897 -886
  6. package/package.json +1 -1
  7. package/src/client/components/common/MarkdownRenderer.tsx +136 -89
  8. package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
  9. package/src/client/components/common/anchored-menu/index.tsx +143 -0
  10. package/src/client/components/common/code-surface/bracket-guide.test.ts +2 -2
  11. package/src/client/components/common/code-surface/bracket-guide.ts +2 -2
  12. package/src/client/components/common/code-surface/conflict-markers.ts +5 -5
  13. package/src/client/components/common/code-surface/extensions.ts +7 -4
  14. package/src/client/components/common/code-surface/theme.ts +34 -9
  15. package/src/client/components/common/code-surface/whitespace.test.ts +223 -0
  16. package/src/client/components/common/code-surface/whitespace.ts +140 -0
  17. package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
  18. package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
  19. package/src/client/components/common/markdown-review/index.tsx +129 -0
  20. package/src/client/components/common/{server-switcher/index.tsx → server-control/Panel.tsx} +92 -44
  21. package/src/client/components/common/server-control/index.test.tsx +217 -0
  22. package/src/client/components/common/server-control/index.tsx +120 -0
  23. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
  24. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +42 -21
  25. package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
  26. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
  27. package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
  28. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
  29. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
  30. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
  31. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +28 -10
  32. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
  33. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
  34. package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
  35. package/src/client/components/layout/update-popup/index.tsx +5 -1
  36. package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
  37. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
  38. package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
  39. package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
  40. package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
  41. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +41 -13
  42. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
  43. package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
  44. package/src/client/components/settings/Modal.tsx +9 -3
  45. package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
  46. package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
  47. package/src/client/components/settings/categories/AgentSettings.tsx +38 -44
  48. package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
  49. package/src/client/components/settings/categories/McpSettings.tsx +4 -21
  50. package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
  51. package/src/client/components/settings/categories/ProjectSettings.tsx +122 -156
  52. package/src/client/components/settings/categories/SkillCatalogSettings.tsx +220 -260
  53. package/src/client/components/settings/categories/SkillSettings.tsx +8 -5
  54. package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
  55. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
  56. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
  57. package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +14 -2
  58. package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
  59. package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
  60. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
  61. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
  62. package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
  63. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +91 -76
  64. package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
  65. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +26 -13
  66. package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
  67. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
  68. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
  69. package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
  70. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
  71. package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
  72. package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
  73. package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
  74. package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
  75. package/src/client/components/settings/categories/project-settings/AccentPalette.test.tsx +189 -0
  76. package/src/client/components/settings/categories/project-settings/AccentPalette.tsx +156 -24
  77. package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +175 -0
  78. package/src/client/components/settings/categories/project-settings/DeleteProjectModal.tsx +107 -0
  79. package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +40 -24
  80. package/src/client/components/settings/categories/project-settings/DetailsHeader.tsx +17 -7
  81. package/src/client/components/settings/categories/project-settings/IconGrid.tsx +164 -69
  82. package/src/client/components/settings/categories/project-settings/ModelDropdown.test.tsx +122 -0
  83. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +124 -53
  84. package/src/client/components/settings/categories/project-settings/NameInput.tsx +57 -11
  85. package/src/client/components/settings/categories/project-settings/PathField.tsx +122 -0
  86. package/src/client/components/settings/categories/project-settings/SidebarList.tsx +100 -59
  87. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +253 -0
  88. package/src/client/components/settings/categories/skill-catalog/SkillCard.tsx +89 -0
  89. package/src/client/components/settings/categories/skill-catalog/SourceRail.tsx +122 -0
  90. package/src/client/components/settings/categories/skill-catalog/catalog-ui.test.tsx +179 -0
  91. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +236 -0
  92. package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +164 -239
  93. package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
  94. package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +144 -87
  95. package/src/client/components/settings/categories/skill-settings/pane.test.tsx +188 -0
  96. package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
  97. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
  98. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
  99. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
  100. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
  101. package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
  102. package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
  103. package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
  104. package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
  105. package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
  106. package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
  107. package/src/client/components/workspace/browser-panel/index.tsx +50 -4
  108. package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
  109. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
  110. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
  111. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
  112. package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
  113. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
  114. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
  115. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +46 -0
  116. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -6
  117. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
  118. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
  119. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +29 -0
  120. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +11 -3
  121. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
  122. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +24 -1
  123. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +6 -2
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
  127. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
  128. package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
  129. package/src/client/components/workspace/diff-panel/changes.ts +28 -12
  130. package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
  131. package/src/client/components/workspace/diff-panel/merge.ts +21 -1
  132. package/src/client/components/workspace/editor/Body.tsx +7 -0
  133. package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
  134. package/src/client/components/workspace/editor/FilePane.tsx +12 -0
  135. package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
  136. package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
  137. package/src/client/components/workspace/editor/index.tsx +25 -22
  138. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
  139. package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
  140. package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
  141. package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
  142. package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +18 -2
  143. package/src/client/components/workspace/editor/viewers/viewers.test.ts +39 -0
  144. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +18 -5
  145. package/src/client/components/workspace/file-explorer/Modals.tsx +15 -1
  146. package/src/client/components/workspace/file-explorer/RowLabel.tsx +68 -0
  147. package/src/client/components/workspace/file-explorer/TreeItem.tsx +47 -57
  148. package/src/client/components/workspace/file-explorer/collapsed-chain.test.ts +167 -0
  149. package/src/client/components/workspace/file-explorer/drag-props.ts +42 -0
  150. package/src/client/components/workspace/file-explorer/drag.test.ts +43 -0
  151. package/src/client/components/workspace/file-explorer/index.tsx +21 -20
  152. package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
  153. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
  154. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
  155. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
  156. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
  157. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
  158. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
  159. package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
  160. package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
  161. package/src/client/data/agent-data/builtin.ts +0 -10
  162. package/src/client/data/agent-data/orchestrator.ts +0 -45
  163. package/src/client/data/agent-data/specialist.ts +0 -100
  164. package/src/client/data/mock/token-usage.ts +170 -120
  165. package/src/client/data/settings/omp-schema.json +123 -4
  166. package/src/client/data/settings/project.ts +9 -28
  167. package/src/client/data/settings/skill.ts +6 -32
  168. package/src/client/hooks/browser/use-annotate.test.ts +143 -0
  169. package/src/client/hooks/browser/use-annotate.ts +98 -0
  170. package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
  171. package/src/client/hooks/browser/use-close-tab.ts +67 -0
  172. package/src/client/hooks/browser/use-screencast.ts +13 -1
  173. package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
  174. package/src/client/hooks/chat/composer/browser-context.ts +40 -16
  175. package/src/client/hooks/chat/composer/items.test.ts +1 -1
  176. package/src/client/hooks/chat/composer/review-context.ts +38 -0
  177. package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
  178. package/src/client/hooks/chat/composer/use-draft.ts +31 -2
  179. package/src/client/hooks/chat/timeline/pending-model.ts +28 -0
  180. package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
  181. package/src/client/hooks/editor/use-document-annotations.ts +124 -0
  182. package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
  183. package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
  184. package/src/client/hooks/editor/use-preview-review.ts +148 -0
  185. package/src/client/hooks/settings/agents.ts +149 -0
  186. package/src/client/hooks/settings/crud-list.test.ts +28 -6
  187. package/src/client/hooks/settings/crud-list.ts +96 -57
  188. package/src/client/hooks/settings/omp-config.ts +164 -0
  189. package/src/client/hooks/settings/projects/index.ts +294 -0
  190. package/src/client/hooks/settings/projects.test.ts +237 -0
  191. package/src/client/hooks/settings/skill-catalog.ts +101 -9
  192. package/src/client/hooks/settings/skill-git-import.ts +153 -0
  193. package/src/client/hooks/settings/useTokenUsage.ts +125 -0
  194. package/src/client/hooks/settings/write-feedback.test.ts +104 -0
  195. package/src/client/hooks/settings/write-feedback.ts +63 -0
  196. package/src/client/hooks/shell/servers.test.ts +166 -0
  197. package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
  198. package/src/client/hooks/ui/markdown-hydration.ts +125 -0
  199. package/src/client/hooks/ui/updates/index.test.ts +100 -1
  200. package/src/client/hooks/ui/updates/index.ts +50 -0
  201. package/src/client/hooks/ui/updates/notes.test.ts +138 -0
  202. package/src/client/hooks/ui/updates/notes.ts +57 -0
  203. package/src/client/hooks/ui/updates/shell-download.ts +1 -1
  204. package/src/client/hooks/ui/updates/shell-update.ts +2 -6
  205. package/src/client/hooks/workspace/file-row-drag.ts +41 -0
  206. package/src/client/hooks/workspace/file-tree-actions.ts +25 -1
  207. package/src/client/hooks/workspace/file-tree-edits.ts +23 -6
  208. package/src/client/hooks/workspace/root-drop-target.ts +77 -0
  209. package/src/client/hooks/workspace/unfolded-chains.ts +165 -0
  210. package/src/client/lib/browser/element-at.test.ts +229 -0
  211. package/src/client/lib/browser/element-at.ts +139 -0
  212. package/src/client/lib/desktop/dropped-paths.ts +1 -1
  213. package/src/client/lib/desktop/titlebar.test.ts +12 -3
  214. package/src/client/lib/desktop/titlebar.ts +1 -1
  215. package/src/client/lib/review/client.ts +73 -0
  216. package/src/client/lib/router/search-params.ts +42 -20
  217. package/src/client/lib/shell/desktop.ts +117 -0
  218. package/src/client/lib/shell/servers.ts +75 -0
  219. package/src/client/lib/shell/transport.ts +216 -0
  220. package/src/client/main.tsx +9 -0
  221. package/src/client/tailwind.css +65 -0
  222. package/src/server/lib/btw/lifecycle.server.ts +2 -2
  223. package/src/server/lib/db/schema.ts +7 -0
  224. package/src/server/lib/db/seed-terminal.test.ts +4 -0
  225. package/src/server/lib/fs/git-merge-conflict.test.ts +14 -1
  226. package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
  227. package/src/server/lib/omp/config/agents.ts +231 -61
  228. package/src/server/lib/omp/config/definitions.test.ts +9 -105
  229. package/src/server/lib/omp/config/extensions.ts +16 -7
  230. package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
  231. package/src/server/lib/omp/config/skill-sources.ts +49 -0
  232. package/src/server/lib/omp/config/skills-git-install.ts +155 -0
  233. package/src/server/lib/omp/config/skills-git-repo.ts +288 -0
  234. package/src/server/lib/omp/config/skills-git.test.ts +220 -0
  235. package/src/server/lib/omp/rpc/constants.test.ts +11 -0
  236. package/src/server/lib/omp/rpc/constants.ts +15 -0
  237. package/src/server/lib/omp/rpc/process.ts +11 -14
  238. package/src/server/lib/omp/rpc/session-commands.ts +6 -3
  239. package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
  240. package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
  241. package/src/server/lib/omp/rpc/utility.ts +12 -0
  242. package/src/server/lib/review/schema.server.ts +45 -0
  243. package/src/server/lib/review/store.server.ts +138 -0
  244. package/src/server/lib/terminal/attach-replay.test.ts +132 -0
  245. package/src/server/lib/terminal/output.test.ts +166 -0
  246. package/src/server/lib/terminal/output.ts +104 -0
  247. package/src/server/lib/terminal/runtime.server.ts +5 -0
  248. package/src/server/lib/terminal/send-result.test.ts +33 -0
  249. package/src/server/lib/terminal/send-result.ts +32 -0
  250. package/src/server/lib/terminal/session.server.ts +45 -11
  251. package/src/server/lib/terminal/store-liveness.test.ts +4 -0
  252. package/src/server/lib/updates/active-notes.test.ts +149 -0
  253. package/src/server/lib/updates/active-notes.ts +75 -0
  254. package/src/server/lib/updates/changelog-file.ts +42 -11
  255. package/src/server/lib/updates/changelog.test.ts +15 -1
  256. package/src/server/lib/updates/omp.ts +42 -15
  257. package/src/server/lib/updates/release-url.ts +27 -1
  258. package/src/server/lib/usage/index-parse.test.ts +200 -0
  259. package/src/server/lib/usage/index-parse.ts +178 -0
  260. package/src/server/lib/usage/index-query.server.ts +248 -0
  261. package/src/server/lib/usage/index-scan.server.ts +343 -0
  262. package/src/server/lib/usage/index-schema.server.ts +82 -0
  263. package/src/server/lib/usage/index.test.ts +234 -0
  264. package/src/server/lib/usage/providers.server.ts +4 -53
  265. package/src/server/lib/workspace/project-model.server.test.ts +102 -0
  266. package/src/server/lib/workspace/project-model.server.ts +47 -0
  267. package/src/server/lib/workspace/project-patch.server.ts +156 -0
  268. package/src/server/routes/agent/new.ts +8 -1
  269. package/src/server/routes/browser/index.ts +3 -0
  270. package/src/server/routes/browser/stream.ts +31 -2
  271. package/src/server/routes/browser/tabs.test.ts +94 -0
  272. package/src/server/routes/browser/tabs.ts +85 -0
  273. package/src/server/routes/index.ts +2 -0
  274. package/src/server/routes/review/bindings.ts +11 -0
  275. package/src/server/routes/review/index.ts +127 -0
  276. package/src/server/routes/review/routes.test.ts +191 -0
  277. package/src/server/routes/settings/agents.test.ts +180 -0
  278. package/src/server/routes/settings/agents.ts +99 -94
  279. package/src/server/routes/settings/mcp.test.ts +135 -0
  280. package/src/server/routes/settings/mcp.ts +14 -6
  281. package/src/server/routes/settings/projects.ts +53 -19
  282. package/src/server/routes/settings/settings-projects-routes.test.ts +214 -0
  283. package/src/server/routes/settings/settings-store-routes.test.ts +11 -115
  284. package/src/server/routes/settings/skills-catalog-actions.ts +195 -0
  285. package/src/server/routes/settings/skills.test.ts +225 -0
  286. package/src/server/routes/settings/skills.ts +18 -15
  287. package/src/server/routes/telemetry/tokens.test.ts +145 -0
  288. package/src/server/routes/telemetry/tokens.ts +70 -149
  289. package/src/server/routes/terminal/ws.ts +6 -5
  290. package/src/server/routes/updates/index.ts +2 -0
  291. package/src/server/routes/updates/notes.ts +34 -0
  292. package/src/server/routes/updates/routes.test.ts +49 -0
  293. package/src/shared/lib/browser/annotate.test.ts +283 -0
  294. package/src/shared/lib/browser/annotate.ts +231 -0
  295. package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
  296. package/src/shared/lib/browser/frame-gate.test.ts +91 -0
  297. package/src/shared/lib/browser/frame-gate.ts +69 -0
  298. package/src/shared/lib/browser/frame-params.test.ts +43 -0
  299. package/src/shared/lib/browser/frame-params.ts +60 -0
  300. package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
  301. package/src/shared/lib/browser/frame-pipeline.ts +80 -0
  302. package/src/shared/lib/browser/page-context.ts +60 -4
  303. package/src/shared/lib/browser/snapshot.test.ts +115 -0
  304. package/src/shared/lib/browser/snapshot.ts +112 -0
  305. package/src/shared/lib/browser/tab-close.test.ts +74 -0
  306. package/src/shared/lib/browser/tab-close.ts +77 -0
  307. package/src/shared/lib/browser/viewer.ts +45 -26
  308. package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
  309. package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
  310. package/src/shared/lib/chat/tool/artifact.ts +55 -20
  311. package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
  312. package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
  313. package/src/shared/lib/chat/tool/minimized.ts +64 -0
  314. package/src/shared/lib/chat/tool/summary.test.ts +28 -8
  315. package/src/shared/lib/chat/tool/summary.ts +3 -32
  316. package/src/shared/lib/fs/folder-chain.test.ts +81 -1
  317. package/src/shared/lib/fs/folder-chain.ts +84 -0
  318. package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
  319. package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
  320. package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
  321. package/src/shared/lib/markdown/blocks/scan.ts +100 -0
  322. package/src/shared/lib/markdown/blocks/types.ts +62 -0
  323. package/src/shared/lib/markdown/marked.ts +58 -147
  324. package/src/shared/lib/markdown/math-extensions.ts +168 -0
  325. package/src/shared/lib/markdown/review/prompt.ts +77 -0
  326. package/src/shared/lib/markdown/review/reconcile.ts +55 -0
  327. package/src/shared/lib/markdown/review/review.test.ts +96 -0
  328. package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
  329. package/src/shared/lib/markdown/xml-sections.ts +139 -0
  330. package/src/shared/lib/models/provider/label.ts +57 -0
  331. package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
  332. package/src/shared/lib/omp/config/agent-file.ts +43 -0
  333. package/src/shared/lib/omp/config/row-value.test.ts +95 -0
  334. package/src/shared/lib/omp/config/row-value.ts +97 -0
  335. package/src/shared/lib/omp/config/schema.test.ts +66 -0
  336. package/src/shared/lib/omp/config/schema.ts +6 -0
  337. package/src/shared/lib/omp/rpc/frame.test.ts +48 -47
  338. package/src/shared/lib/omp/rpc/frame.ts +49 -40
  339. package/src/shared/lib/omp/session/job-progress.test.ts +37 -1
  340. package/src/shared/lib/omp/session/job-progress.ts +31 -0
  341. package/src/shared/lib/omp/session/proc.ts +5 -0
  342. package/src/shared/lib/omp/session/wait.ts +5 -0
  343. package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
  344. package/src/shared/lib/ui/menu-anchor.ts +89 -0
  345. package/src/shared/lib/ui/mobile-overlay.ts +61 -0
  346. package/src/shared/lib/ui/svg-scope.test.ts +97 -0
  347. package/src/shared/lib/ui/svg-scope.ts +134 -0
  348. package/src/shared/lib/usage/breakdown.test.ts +197 -0
  349. package/src/shared/lib/usage/breakdown.ts +241 -0
  350. package/src/shared/lib/usage/range.test.ts +204 -0
  351. package/src/shared/lib/usage/range.ts +240 -0
  352. package/src/shared/lib/usage/view.test.ts +85 -0
  353. package/src/shared/lib/usage/view.ts +74 -0
  354. package/src/shared/lib/workspace/project-accent.test.ts +69 -0
  355. package/src/shared/lib/workspace/project-accent.ts +63 -0
  356. package/src/shared/lib/workspace/project-icon.ts +40 -0
  357. package/src/shared/lib/workspace/project-model.test.ts +79 -0
  358. package/src/shared/lib/workspace/project-model.ts +64 -0
  359. package/src/shared/types/browser.ts +78 -0
  360. package/src/shared/types/index.ts +1 -0
  361. package/src/shared/types/settings/agent.ts +28 -6
  362. package/src/shared/types/settings/skill.ts +53 -3
  363. package/src/shared/types/settings/state.ts +4 -3
  364. package/src/shared/types/settings/write.ts +6 -0
  365. package/src/shared/types/tokenUsage.ts +128 -21
  366. package/src/shared/types/updates.ts +20 -0
  367. package/src/test-support/file-explorer-disk.test-util.ts +25 -1
  368. package/src/test-support/file-explorer-drag.test-util.ts +88 -0
  369. package/src/test-support/file-explorer.test-util.ts +47 -47
  370. package/dist/client/static/js/index-fjnq2z2d.css +0 -1
  371. package/src/client/components/common/code-surface/indent-guide.ts +0 -104
  372. package/src/client/components/common/server-switcher/index.test.tsx +0 -150
  373. package/src/client/components/settings/categories/skill-catalog/AddSourceModal.tsx +0 -133
  374. package/src/client/hooks/desktop/servers.test.ts +0 -73
  375. package/src/client/lib/desktop/bridge.ts +0 -203
  376. package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
  377. package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
  378. package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
  379. package/src/server/lib/omp/session/usage/shaping.ts +0 -130
  380. package/src/shared/lib/code/editor/indent-guide-rule.test.ts +0 -65
  381. package/src/shared/lib/code/editor/indent-guide-rule.ts +0 -47
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The Token Usage panel's view models.
8
+ *
9
+ * These are the numbers a user reads, so each case pins a value that would be a
10
+ * bug if it drifted: a model shown under the wrong provider, a share computed
11
+ * against the wrong denominator, a cadence that relabels without re-bucketing,
12
+ * or a cache rate that divides by the wrong input.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+
17
+ import {
18
+ cacheHitLabel,
19
+ cacheHitRate,
20
+ costLabel,
21
+ costPerMillionLabel,
22
+ tokenLabel,
23
+ toMetricSet,
24
+ } from '@/shared/lib/usage/view';
25
+ import type { UsageTotals } from '@/shared/types';
26
+
27
+ const counters = (cost: number, tokens: number, records = 1, cacheRead = 0, input = 0) => ({
28
+ cost, tokens, input, output: tokens - input - cacheRead, cacheRead, cacheWrite: 0,
29
+ reasoning: 0, cacheReadCost: cost * 0.1, records, unpriced: 0,
30
+ });
31
+
32
+ const totals: UsageTotals = {
33
+ ...counters(20, 1_000_000, 40, 900_000, 50_000),
34
+ unpriced: 4,
35
+ activeDays: 6,
36
+ };
37
+
38
+ describe('formatting', () => {
39
+ test('token labels switch unit at the decimal boundary', () => {
40
+ expect(tokenLabel(0)).toBe('0');
41
+ expect(tokenLabel(999)).toBe('999');
42
+ expect(tokenLabel(1_500)).toBe('1.5K');
43
+ expect(tokenLabel(2_219_000_000)).toBe('2.2B');
44
+ });
45
+
46
+ test('a nonzero sub-cent cost is not rounded into "free"', () => {
47
+ expect(costLabel(0)).toBe('$0.00');
48
+ expect(costLabel(1.234)).toBe('$1.23');
49
+ expect(costLabel(0.0009)).toBe('< $0.01');
50
+ expect(costLabel(0.01)).toBe('$0.01');
51
+ });
52
+
53
+ test('cost per million is derived from cost and tokens, and blank when empty', () => {
54
+ expect(costPerMillionLabel({ cost: 1.7, tokens: 1_000_000 })).toBe('$1.70');
55
+ expect(costPerMillionLabel({ cost: 1.7, tokens: 0 })).toBe('—');
56
+ });
57
+
58
+ test('cache hit rate is cache reads over ALL observed input', () => {
59
+ expect(cacheHitRate({ cacheRead: 900, input: 100 })).toBeCloseTo(0.9, 10);
60
+ expect(cacheHitLabel({ cacheRead: 900, input: 100 })).toBe('90.0%');
61
+ // Nothing observed is not a 100% hit rate.
62
+ expect(cacheHitLabel({ cacheRead: 0, input: 0 })).toBe('—');
63
+ });
64
+ });
65
+
66
+ describe('toMetricSet', () => {
67
+ test('every figure is the period total', () => {
68
+ const metrics = toMetricSet(totals);
69
+ expect(metrics.rawCost).toBe('$20.00');
70
+ expect(metrics.processedTokens).toBe('1.0M');
71
+ expect(metrics.cachedInput).toBe('900.0K');
72
+ expect(metrics.uncachedInput).toBe('50.0K');
73
+ expect(metrics.costPerMillion).toBe('$20.00');
74
+ });
75
+
76
+ test('the activity hint counts the period days, singular at one', () => {
77
+ expect(toMetricSet(totals).activeRate).toBe('6 active days');
78
+ expect(toMetricSet({ ...totals, activeDays: 1 }).activeRate).toBe('1 active day');
79
+ });
80
+
81
+ test('there is no per-day or per-week figure in the set', () => {
82
+ const metrics = toMetricSet(totals);
83
+ expect(Object.keys(metrics).some((key) => /perDay|perWeek|perMonth|average/i.test(key))).toBe(false);
84
+ });
85
+ });
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Formatting and the headline metric set for the Token Usage panel.
8
+ *
9
+ * Nothing here divides or averages: the panel reports ONE period, so every
10
+ * figure is that period's total. A cadence switch used to exist beside the
11
+ * period switch, and a period total cannot move when days are regrouped — which
12
+ * made the control look broken. The period IS the switch now.
13
+ *
14
+ * Pure and shared, so the panel's components hold no arithmetic.
15
+ */
16
+
17
+ import type { TokenUsageMetricSet, UsageCounters, UsageTotals } from '@/shared/types';
18
+
19
+ /**
20
+ * `$1.23` for a cost row, `< $0.01` for a real but sub-cent amount.
21
+ *
22
+ * Rounding a nonzero cost to `$0.00` reads as "this was free", which is the
23
+ * one thing an unpriced/free provider is NOT. `<$0.01` says the cost exists
24
+ * and is below the display precision.
25
+ */
26
+ export function costLabel(value: number, fractionDigits = 2): string {
27
+ if (value > 0 && Number(value.toFixed(fractionDigits)) === 0) return '< $0.01';
28
+ return `$${value.toFixed(fractionDigits)}`;
29
+ }
30
+
31
+ /** Compact token count with decimal units, matching the rest of the app. */
32
+ export function tokenLabel(value: number): string {
33
+ if (!Number.isFinite(value) || value <= 0) return '0';
34
+ if (value >= 1_000_000_000) return `${(value / 1_000_000_000).toFixed(1)}B`;
35
+ if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`;
36
+ if (value >= 1_000) return `${(value / 1_000).toFixed(1)}K`;
37
+ return String(Math.round(value));
38
+ }
39
+
40
+ /** Cache-hit percentage over observed input (cache read + uncached input). */
41
+ export function cacheHitRate(counters: Pick<UsageCounters, 'cacheRead' | 'input'>): number | null {
42
+ const observed = counters.cacheRead + counters.input;
43
+ return observed > 0 ? counters.cacheRead / observed : null;
44
+ }
45
+
46
+ /** `98.7%` or `—` when nothing was cached or read. */
47
+ export function cacheHitLabel(counters: Pick<UsageCounters, 'cacheRead' | 'input'>): string {
48
+ const rate = cacheHitRate(counters);
49
+ return rate === null ? '—' : `${(rate * 100).toFixed(1)}%`;
50
+ }
51
+
52
+ /** `$0.07` per 1M tokens, or `—` when no tokens were processed. */
53
+ export function costPerMillionLabel(counters: Pick<UsageCounters, 'cost' | 'tokens'>): string {
54
+ if (counters.tokens <= 0) return '—';
55
+ return `$${((counters.cost / counters.tokens) * 1_000_000).toFixed(2)}`;
56
+ }
57
+
58
+ /** The headline tiles, as display strings for the selected period. */
59
+ export function toMetricSet(totals: UsageTotals): TokenUsageMetricSet {
60
+ return {
61
+ rawCost: costLabel(totals.cost),
62
+ costPerMillion: costPerMillionLabel(totals),
63
+ processedTokens: tokenLabel(totals.tokens),
64
+ activeRate: `${totals.activeDays} active ${totals.activeDays === 1 ? 'day' : 'days'}`,
65
+ cachedInput: tokenLabel(totals.cacheRead),
66
+ cachedPercent: `${cacheHitLabel(totals)} of observed input`,
67
+ uncachedInput: tokenLabel(totals.input),
68
+ cacheWrite: tokenLabel(totals.cacheWrite),
69
+ outputTokens: tokenLabel(totals.output),
70
+ reasoning: `${tokenLabel(totals.reasoning)} reasoning`,
71
+ records: totals.records,
72
+ unpricedRecords: totals.unpriced,
73
+ };
74
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * A custom accent is user input that ends up in a CSS `color`, so the only
8
+ * accepted shape is a hex colour and the only stored shape is lowercase
9
+ * six-digit. These cases pin both, plus the fact that the palette has no entry
10
+ * that is already the custom default (the picker would look like an eleventh
11
+ * preset).
12
+ */
13
+
14
+ import { describe, expect, test } from 'bun:test';
15
+
16
+ import {
17
+ DEFAULT_CUSTOM_ACCENT,
18
+ PROJECT_ACCENT_OPTIONS,
19
+ isHexAccent,
20
+ normalizeHexAccent,
21
+ } from '@/shared/lib/workspace/project-accent';
22
+
23
+ describe('normalizeHexAccent', () => {
24
+ test('expands the short form and lowercases', () => {
25
+ expect(normalizeHexAccent('#ABC')).toBe('#aabbcc');
26
+ expect(normalizeHexAccent('#0F8')).toBe('#00ff88');
27
+ expect(normalizeHexAccent('#38BDF8')).toBe('#38bdf8');
28
+ });
29
+
30
+ test('leaves a six-digit colour alone apart from case', () => {
31
+ expect(normalizeHexAccent('#7c3aed')).toBe('#7c3aed');
32
+ expect(normalizeHexAccent('#7C3AED')).toBe('#7c3aed');
33
+ });
34
+
35
+ test('refuses everything that is not a hex colour', () => {
36
+ // A style value is not a colour: this is the injection the server now blocks.
37
+ for (const value of ['red', 'red;background:url(//x)', 'rgb(1,2,3)', '#1234', '#1234567', '7c3aed', '#gggggg', '', ' #fff']) {
38
+ expect(normalizeHexAccent(value)).toBeNull();
39
+ }
40
+ });
41
+ });
42
+
43
+ describe('isHexAccent', () => {
44
+ test('accepts only the stored form', () => {
45
+ expect(isHexAccent('#38bdf8')).toBe(true);
46
+ expect(isHexAccent('#ABC')).toBe(false);
47
+ expect(isHexAccent('')).toBe(false);
48
+ });
49
+ });
50
+
51
+ describe('the palette table', () => {
52
+ test('every preset is already in stored form', () => {
53
+ for (const option of PROJECT_ACCENT_OPTIONS) {
54
+ if (option.value === '') continue;
55
+ expect(normalizeHexAccent(option.value)).toBe(option.value);
56
+ }
57
+ });
58
+
59
+ test('the custom default is not a preset', () => {
60
+ // Otherwise picking "custom" would highlight a swatch instead.
61
+ expect(PROJECT_ACCENT_OPTIONS.some((option) => option.value === DEFAULT_CUSTOM_ACCENT)).toBe(false);
62
+ expect(normalizeHexAccent(DEFAULT_CUSTOM_ACCENT)).toBe(DEFAULT_CUSTOM_ACCENT);
63
+ });
64
+
65
+ test('None is the only empty entry, and it comes first', () => {
66
+ expect(PROJECT_ACCENT_OPTIONS.filter((option) => option.value === '')).toHaveLength(1);
67
+ expect(PROJECT_ACCENT_OPTIONS[0]?.value).toBe('');
68
+ });
69
+ });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The accent palette a workspace may be marked with, in ONE table.
8
+ *
9
+ * The server serves it and the settings palette falls back to it, so the two
10
+ * cannot disagree about which swatches exist — they were duplicated before, and
11
+ * a colour added on one side was simply missing on the other.
12
+ *
13
+ * These are DATA, not theme tokens: an accent is a per-project mark, and every
14
+ * value here is drawn as a swatch (never as component chrome), which is why they
15
+ * are allowed literal hex. This table is the PRESETS — a user may also store any
16
+ * other hex through the custom picker, so nothing may treat membership here as
17
+ * the set of valid accents.
18
+ */
19
+
20
+ import type { AccentColorOption } from '@/shared/types';
21
+
22
+ /**
23
+ The accent the custom picker starts on: a violet that is deliberately NOT one of
24
+ the swatches, so the custom control is visibly its own choice rather than an
25
+ eleventh preset.
26
+ */
27
+ export const DEFAULT_CUSTOM_ACCENT = '#7c3aed';
28
+
29
+ /** An accent may be empty (no mark) or `#rgb` / `#rrggbb`, nothing else. */
30
+ const HEX_ACCENT = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
31
+
32
+ /**
33
+ The stored form of a hex accent: lowercase, always six digits.
34
+
35
+ Returns `null` for anything that is not a hex colour, so the caller decides
36
+ whether to refuse it or fall back — this module does not guess. The accent ends
37
+ up in a CSS `color`, and a free-form string there is a style injection: `red;
38
+ background:url(…)` paints the sidebar.
39
+ */
40
+ export function normalizeHexAccent(value: string): string | null {
41
+ if (!HEX_ACCENT.test(value)) return null;
42
+ const lower = value.toLowerCase();
43
+ if (lower.length === 7) return lower;
44
+ return `#${lower[1]}${lower[1]}${lower[2]}${lower[2]}${lower[3]}${lower[3]}`;
45
+ }
46
+
47
+ /** True when the value is a stored-form hex accent, i.e. what the server keeps. */
48
+ export function isHexAccent(value: string): boolean {
49
+ return normalizeHexAccent(value) === value && value !== '';
50
+ }
51
+
52
+ export const PROJECT_ACCENT_OPTIONS: AccentColorOption[] = [
53
+ { label: 'None', value: '', bgHex: 'transparent' },
54
+ { label: 'Sky Blue', value: '#38bdf8', bgHex: '#38bdf8' },
55
+ { label: 'Light Green', value: '#a3e635', bgHex: '#a3e635' },
56
+ { label: 'Coral', value: '#f87171', bgHex: '#f87171' },
57
+ { label: 'Amber', value: '#fbbf24', bgHex: '#fbbf24' },
58
+ { label: 'Teal', value: '#2dd4bf', bgHex: '#2dd4bf' },
59
+ { label: 'Slate', value: '#94a3b8', bgHex: '#94a3b8' },
60
+ { label: 'Rose', value: '#f43f5e', bgHex: '#f43f5e' },
61
+ { label: 'Vivid Blue', value: '#3b82f6', bgHex: '#3b82f6' },
62
+ { label: 'Lime Green', value: '#84cc16', bgHex: '#84cc16' },
63
+ ];
@@ -1,6 +1,15 @@
1
1
  import { BookOpen, Briefcase, Camera, Code2, Database, FlaskConical, Folder, Gamepad2, Globe, Heart, Home, Leaf, Lightbulb, Music, Palette, Rocket, Server, Shield, Smartphone, Terminal } from 'lucide-preact';
2
2
  import type { LucideIcon } from 'lucide-preact';
3
3
 
4
+ /**
5
+ * The workspace icon set, in ONE table.
6
+ *
7
+ * Three surfaces draw a project's mark — the settings grid, the settings list
8
+ * and every sidebar/mobile row — and each used to carry its own map. They had
9
+ * already drifted (`default` was a folder in the sidebar and an ✕ in the
10
+ * settings grid, which reads as "clear the icon"), so the ids, their labels and
11
+ * the glyphs live here and the pickers iterate {@link PROJECT_ICON_OPTIONS}.
12
+ */
4
13
  const PROJECT_ICON_MAP: Record<string, LucideIcon> = {
5
14
  default: Folder,
6
15
  code: Code2,
@@ -24,6 +33,37 @@ const PROJECT_ICON_MAP: Record<string, LucideIcon> = {
24
33
  heart: Heart,
25
34
  };
26
35
 
36
+ export interface ProjectIconOption {
37
+ id: string;
38
+ label: string;
39
+ icon: LucideIcon;
40
+ }
41
+
42
+ /** Every pickable icon, in the grid's display order. */
43
+ export const PROJECT_ICON_OPTIONS: ProjectIconOption[] = [
44
+ { id: 'default', label: 'Default folder', icon: Folder },
45
+ { id: 'code', label: 'Code', icon: Code2 },
46
+ { id: 'terminal', label: 'Terminal', icon: Terminal },
47
+ { id: 'rocket', label: 'Rocket', icon: Rocket },
48
+ { id: 'flask', label: 'Flask', icon: FlaskConical },
49
+ { id: 'gamepad', label: 'Gamepad', icon: Gamepad2 },
50
+ { id: 'briefcase', label: 'Briefcase', icon: Briefcase },
51
+ { id: 'home', label: 'Home', icon: Home },
52
+ { id: 'globe', label: 'Globe', icon: Globe },
53
+ { id: 'leaf', label: 'Leaf', icon: Leaf },
54
+ { id: 'shield', label: 'Shield', icon: Shield },
55
+ { id: 'palette', label: 'Palette', icon: Palette },
56
+ { id: 'server', label: 'Server', icon: Server },
57
+ { id: 'smartphone', label: 'Smartphone', icon: Smartphone },
58
+ { id: 'database', label: 'Database', icon: Database },
59
+ { id: 'lightbulb', label: 'Lightbulb', icon: Lightbulb },
60
+ { id: 'music', label: 'Music', icon: Music },
61
+ { id: 'camera', label: 'Camera', icon: Camera },
62
+ { id: 'book', label: 'Book', icon: BookOpen },
63
+ { id: 'heart', label: 'Heart', icon: Heart },
64
+ ];
65
+
66
+ /** The glyph for a stored icon id, falling back to the plain folder. */
27
67
  export function getProjectIcon(icon: string | undefined): LucideIcon {
28
68
  return PROJECT_ICON_MAP[icon || 'default'] || Folder;
29
69
  }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The project default-model value.
8
+ *
9
+ * The failure this guards is silent: a bare display name or an id without its
10
+ * provider parses to a "model" that either no provider serves or that resolves
11
+ * to whichever provider happens to come first, and the chat then starts on a
12
+ * model the project never asked for.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+
17
+ import {
18
+ NO_PROJECT_MODEL,
19
+ parseProjectModel,
20
+ projectModelLabel,
21
+ projectModelValue,
22
+ } from '@/shared/lib/workspace/project-model';
23
+
24
+ describe('parseProjectModel', () => {
25
+ test('reads a composite provider:model value', () => {
26
+ expect(parseProjectModel('kenari:deepseek-v4-flash')).toEqual({
27
+ provider: 'kenari',
28
+ modelId: 'deepseek-v4-flash',
29
+ });
30
+ });
31
+
32
+ test('trims both halves and keeps an id that carries a colon', () => {
33
+ expect(parseProjectModel(' openrouter : vendor/model:x ')).toEqual({
34
+ provider: 'openrouter',
35
+ modelId: 'vendor/model:x',
36
+ });
37
+ });
38
+
39
+ test('the schema default and a legacy display name both read as "inherit"', () => {
40
+ expect(parseProjectModel(NO_PROJECT_MODEL)).toBeNull();
41
+ expect(parseProjectModel('GPT-4o')).toBeNull();
42
+ expect(parseProjectModel('DeepSeek-V3')).toBeNull();
43
+ });
44
+
45
+ test('malformed values never become a half-named model', () => {
46
+ expect(parseProjectModel('')).toBeNull();
47
+ expect(parseProjectModel(' ')).toBeNull();
48
+ expect(parseProjectModel(':gpt')).toBeNull();
49
+ expect(parseProjectModel('gpt:')).toBeNull();
50
+ expect(parseProjectModel(null)).toBeNull();
51
+ expect(parseProjectModel(42)).toBeNull();
52
+ });
53
+ });
54
+
55
+ describe('projectModelValue / projectModelLabel', () => {
56
+ test('round-trips through the composite value', () => {
57
+ const value = projectModelValue({ provider: 'kenari', modelId: 'deepseek-v4-flash' });
58
+ expect(value).toBe('kenari:deepseek-v4-flash');
59
+ expect(parseProjectModel(value)).toEqual({ provider: 'kenari', modelId: 'deepseek-v4-flash' });
60
+ });
61
+
62
+ test('a stored model the catalog still serves is labelled with its display name', () => {
63
+ expect(
64
+ projectModelLabel('kenari:deepseek-v4-flash', [
65
+ { id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash', provider: 'kenari' },
66
+ { id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash (direct)', provider: 'deepseek' },
67
+ ]),
68
+ ).toBe('kenari · DeepSeek V4 Flash');
69
+ });
70
+
71
+ test('a stale stored model is still named, so it does not read as "inherit"', () => {
72
+ expect(projectModelLabel('kenari:gone', [])).toBe('kenari · gone');
73
+ });
74
+
75
+ test('an unset value has no label', () => {
76
+ expect(projectModelLabel(NO_PROJECT_MODEL, [])).toBeNull();
77
+ expect(projectModelLabel('', [])).toBeNull();
78
+ });
79
+ });
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The default model a workspace folder can carry for its new chats.
8
+ *
9
+ * Stored as the COMPOSITE `provider:modelId` identity, the same one
10
+ * `modelKey` uses, because a model id alone is not unique — the omp registry
11
+ * serves the same id from several providers, and a value keyed on the id alone
12
+ * would silently mean "whichever provider came first".
13
+ *
14
+ * `Not selected` is the historical default written by the schema, and legacy
15
+ * rows also hold bare display names from the retired hardcoded list. Neither
16
+ * resolves to a model, so they read as "inherit Kabmo's default" rather than as
17
+ * a model nobody can start a chat on.
18
+ */
19
+
20
+ import type { SelectedModel } from '@/shared/types';
21
+
22
+ /** The stored spelling of "no project default". */
23
+ export const NO_PROJECT_MODEL = 'Not selected';
24
+
25
+ /**
26
+ * Read a stored project-model value. Anything that is not a non-empty
27
+ * `provider:modelId` pair — including the legacy display names — yields null.
28
+ */
29
+ export function parseProjectModel(value: unknown): SelectedModel | null {
30
+ if (typeof value !== 'string') return null;
31
+ const trimmed = value.trim();
32
+ if (!trimmed || trimmed === NO_PROJECT_MODEL) return null;
33
+
34
+ const separator = trimmed.indexOf(':');
35
+ if (separator <= 0 || separator === trimmed.length - 1) return null;
36
+
37
+ const provider = trimmed.slice(0, separator).trim();
38
+ const modelId = trimmed.slice(separator + 1).trim();
39
+ if (!provider || !modelId) return null;
40
+
41
+ return { provider, modelId };
42
+ }
43
+
44
+ /** The stored spelling of a picked model. */
45
+ export function projectModelValue(model: { provider: string; modelId: string }): string {
46
+ return `${model.provider}:${model.modelId}`;
47
+ }
48
+
49
+ /**
50
+ * The label a stored value gets in a picker: the live catalog's display name
51
+ * when the catalog still serves it, else the raw stored string so a stale pick
52
+ * is visible instead of looking like "inherit".
53
+ */
54
+ export function projectModelLabel(
55
+ value: string,
56
+ entries: readonly { id: string; name: string; provider: string }[],
57
+ ): string | null {
58
+ const parsed = parseProjectModel(value);
59
+ if (!parsed) return null;
60
+ const match = entries.find(
61
+ (entry) => entry.id === parsed.modelId && entry.provider === parsed.provider,
62
+ );
63
+ return match ? `${match.provider} · ${match.name || match.id}` : `${parsed.provider} · ${parsed.modelId}`;
64
+ }
@@ -51,8 +51,86 @@ export interface BrowserPanelAction {
51
51
  label: string;
52
52
  }
53
53
 
54
+ /**
55
+ * How the user marked a spot on the user-browser panel.
56
+ *
57
+ * The panel is a cross-origin iframe, so a mark can never carry PIXELS: the
58
+ * page inside is unreadable to this origin (`contentDocument` is null,
59
+ * `drawImage(iframe)` throws, and a capture would show the user's whole
60
+ * screen). What travels is geometry plus words — the exact region, and what
61
+ * the user says is wrong there.
62
+ */
63
+ export type AnnotateTool = 'box' | 'pin' | 'arrow';
64
+
65
+ /** One point, normalized to the measured panel: 0..1 on both axes. */
66
+ export interface AnnotatePoint {
67
+ x: number;
68
+ y: number;
69
+ }
70
+
71
+ /**
72
+ * What the marked spot IS, when the page allows reading it.
73
+ *
74
+ * Only a SAME-ORIGIN frame can be read (`contentDocument` is non-null); a real
75
+ * dev server runs on its own port, which is a different origin even on the same
76
+ * host — measured in Chromium: `:7101` reading `:7102` yields `contentDocument
77
+ * === null`. So this is present only when the page was readable, and the prompt
78
+ * says so when it is absent instead of pretending.
79
+ */
80
+ export interface AnnotateElement {
81
+ /** `section[aria-label="Ringkasan"] > button#pay`, at most 4 levels. */
82
+ path: string;
83
+ /** Lowercase tag name, e.g. `select`. */
84
+ tag: string;
85
+ /** Explicit `role`, when the element declares one. */
86
+ role?: string;
87
+ /** Visible text, whitespace-collapsed and cut short. */
88
+ text?: string;
89
+ /** `<select>` value and option count, `disabled`, and similar. */
90
+ state?: string;
91
+ }
92
+
93
+ /**
94
+ * One numbered mark. `box`/`arrow` use both points; `pin` uses `start`.
95
+ *
96
+ * `label` is the user's NAME for the region ("Ringkasan pesanan", "form
97
+ * alamat"). It is not derived from the page: the label is the one fact a
98
+ * cross-origin frame can never give us, and the user always has it.
99
+ */
100
+ export interface AnnotateShape {
101
+ id: string;
102
+ tool: AnnotateTool;
103
+ start: AnnotatePoint;
104
+ end: AnnotatePoint;
105
+ /** The user's name for the region; empty until they say it. */
106
+ label: string;
107
+ /** What the user says about this region; empty while they are still drawing. */
108
+ note: string;
109
+ /** The element under the mark, when the frame was same-origin and readable. */
110
+ element?: AnnotateElement;
111
+ }
112
+
113
+ /**
114
+ * The panel box the marks were drawn on, in CSS px.
115
+ *
116
+ * Percentages alone are not enough: `12% of a 1024px panel` and `12% of a
117
+ * 375px panel` are different places, and the agent has to know which page
118
+ * shape the user was looking at to reproduce the view.
119
+ */
120
+ export interface AnnotatePanelSize {
121
+ width: number;
122
+ height: number;
123
+ viewportMode: string;
124
+ /** CSS zoom the panel was showing at (100 = none). */
125
+ zoom: number;
126
+ }
127
+
54
128
  /** Page context handed from a browser panel to the chat composer draft. */
55
129
  export interface BrowserPageContext {
56
130
  url: string;
57
131
  title?: string;
132
+ /** The marks the user made, in draw order. Absent when they only shared a page. */
133
+ annotations?: AnnotateShape[];
134
+ /** The box those marks were normalized against. Present whenever `annotations` is. */
135
+ panel?: AnnotatePanelSize;
58
136
  }
@@ -18,6 +18,7 @@ export * from '@/shared/types/settings/mcp';
18
18
  export * from '@/shared/types/settings/usage';
19
19
  export * from '@/shared/types/settings/skill';
20
20
  export * from '@/shared/types/settings/plugin';
21
+ export * from '@/shared/types/settings/write';
21
22
  export * from '@/shared/types/context';
22
23
  export * from '@/shared/types/omp/session';
23
24
  export * from '@/shared/types/omp/agent';
@@ -1,16 +1,38 @@
1
- export type AgentMode = 'primary' | 'subagent' | 'all';
1
+ /**
2
+ * An omp agent definition.
3
+ *
4
+ * The field set is omp's OWN frontmatter contract (`parseAgentFields` in
5
+ * `@oh-my-pi/pi-coding-agent`), not a shape Kabmo invented: `name`,
6
+ * `description`, `tools`, `spawns`, `model`, `thinkingLevel`, and the body as
7
+ * the system prompt. `mode`/`temperature`/`topP` used to be offered here and
8
+ * were never read by omp, so three controls edited a file to no effect — they
9
+ * are gone, and the pane no longer implies they work.
10
+ */
11
+
2
12
  export type AgentScope = 'system' | 'user' | 'project';
3
13
 
14
+ /** A model selector: `provider/model`, or a role selector such as `@smol`. */
15
+ export type AgentModelSelector = string;
16
+
4
17
  export interface AgentItem {
5
18
  id: string;
6
19
  name: string;
7
20
  description: string;
8
21
  scope: AgentScope;
9
- mode: AgentMode;
10
- overrideModel?: string;
11
- thinkingVariant?: string;
12
- temperature?: number | null;
13
- topP?: number | null;
22
+ /** Absent means omp's default tool set. */
23
+ tools?: string[];
24
+ /** `"*"` or a name list: which agents this one may spawn. */
25
+ spawns?: string;
26
+ model?: AgentModelSelector;
27
+ /** `off` … `max`, or `auto`; absent means the session's level. */
28
+ thinkingLevel?: string;
14
29
  systemPrompt: string;
30
+ /** Listed but not editable: a project agent belongs to that workspace. */
15
31
  isBuiltIn?: boolean;
32
+ /** Absolute path of the definition file omp loads; absent for a demo preset. */
33
+ filePath?: string;
34
+ /** Base name of that file (no `.md`), which is what a write sends. */
35
+ fileName?: string;
36
+ /** Which root the definition was discovered in. */
37
+ sourceRoot?: 'user' | 'project';
16
38
  }