@kabmo-labs/kabmo 0.42.2 → 0.43.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 (348) hide show
  1. package/README.md +1 -1
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +619 -582
  4. package/dist/client/static/js/{CsvGrid-g6rek8y9.js → CsvGrid-3fr85032.js} +2 -2
  5. package/dist/client/static/js/{DocxView-41t9ryws.js → DocxView-pqbp2fpd.js} +4 -4
  6. package/dist/client/static/js/{DrawioView-mfxhfz1h.js → DrawioView-m0vecq1m.js} +2 -2
  7. package/dist/client/static/js/ImageView-rbejbjwg.js +1 -0
  8. package/dist/client/static/js/LayoutWrapper-mxfsqh57.js +2 -0
  9. package/dist/client/static/js/Modal-vnwg4xn3.js +59 -0
  10. package/dist/client/static/js/{PdfView-bek8k888.js → PdfView-wmg0vk2p.js} +1 -1
  11. package/dist/client/static/js/SessionsView-90z2t4qe.js +1 -0
  12. package/dist/client/static/js/{SheetView-vezssf6b.js → SheetView-rg5gkcd7.js} +13 -13
  13. package/dist/client/static/js/{SvgPreview-f1qaw73k.js → SvgPreview-wpb7b0ez.js} +1 -1
  14. package/dist/client/static/js/{abnfDiagram-O67JEVCF-4qn94h52.js → abnfDiagram-O67JEVCF-4pxqt66j.js} +1 -1
  15. package/dist/client/static/js/architecture-7GRP2DOG-7j23x20s.js +1 -0
  16. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-tbewzdya.js → architectureDiagram-NJMV4G6O-kwt1va5y.js} +11 -11
  17. package/dist/client/static/js/{astro-nn7xg0we.js → astro-dpfdhc5e.js} +1 -1
  18. package/dist/client/static/js/bash-vv2ysp0a.js +1 -0
  19. package/dist/client/static/js/{blockDiagram-BEXU5L5S-njgnwckz.js → blockDiagram-BEXU5L5S-hbj5v7n7.js} +7 -7
  20. package/dist/client/static/js/c-8jf64j6h.js +1 -0
  21. package/dist/client/static/js/{c4Diagram-YGBWAQC7-f58pcvbk.js → c4Diagram-YGBWAQC7-epfzh8dw.js} +6 -6
  22. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-52g73vyw.js → classDiagram-v2-NBCMYWYE-kbks4qgz.js} +6 -6
  23. package/dist/client/static/js/{cose-bilkent-JH36ORCC-ptdnshzh.js → cose-bilkent-JH36ORCC-dvdmckrf.js} +1 -1
  24. package/dist/client/static/js/cpp-vh94zee0.js +1 -0
  25. package/dist/client/static/js/css-p57h1fme.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-me5xnx6a.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-qabfdkzr.js → cynefinDiagram-VND7K2PF-r084stj5.js} +2 -2
  28. package/dist/client/static/js/{dagre-6A5THRUB-kyf5jetf.js → dagre-6A5THRUB-64qc51n1.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-bxrsjtv9.js → diagram-22UHCM2B-70qtb1rm.js} +16 -16
  30. package/dist/client/static/js/{diagram-3UASUU5V-0f41s00j.js → diagram-3UASUU5V-dgkvnsme.js} +1 -1
  31. package/dist/client/static/js/{diagram-ATOU4E4O-0z1zx9h1.js → diagram-ATOU4E4O-rnpsp26v.js} +3 -3
  32. package/dist/client/static/js/{diagram-CDSNMT55-znrmr6bk.js → diagram-CDSNMT55-26hthh60.js} +5 -5
  33. package/dist/client/static/js/{diagram-MLGK6HIB-jfe2jhk0.js → diagram-MLGK6HIB-nc1s85r5.js} +2 -2
  34. package/dist/client/static/js/{diagram-MPIPVDR6-2kaawmwa.js → diagram-MPIPVDR6-e4dckqhv.js} +3 -3
  35. package/dist/client/static/js/{dockerfile-12exatm9.js → dockerfile-rxtyyhr1.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-s5n37rfp.js → ebnfDiagram-ZINNZB2B-3w9h8qk7.js} +1 -1
  37. package/dist/client/static/js/{elixir-szk51ehr.js → elixir-5ewfhvfh.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-433rd9fp.js → elk-276RUBZZ-httpkyb1.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-key6ah0b.js → erDiagram-OPXOYQCR-3qhvf7se.js} +8 -8
  40. package/dist/client/static/js/{erlang-zwy7cqdk.js → erlang-jqqa3ehb.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-5zbvjj84.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-1jat076e.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-4efkhmca.js → ganttDiagram-FUAMR5RP-t53m50e5.js} +6 -6
  44. package/dist/client/static/js/gitGraph-4MIJSDKK-tjhkv71w.js +1 -0
  45. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ac376y2k.js → gitGraphDiagram-X574FWY7-b5wn9eht.js} +14 -14
  46. package/dist/client/static/js/graphql-kesh8gk0.js +1 -0
  47. package/dist/client/static/js/html-sxpfydga.js +1 -0
  48. package/dist/client/static/js/{index-e1yz59fa.js → index-0c6vpk89.js} +2 -2
  49. package/dist/client/static/js/{index-p0ez6hqd.js → index-181p91hf.js} +1 -1
  50. package/dist/client/static/js/{index-s4gv0rpk.js → index-1dwdgp27.js} +1 -1
  51. package/dist/client/static/js/{index-0e9nkc0g.js → index-2q23dwrs.js} +2 -2
  52. package/dist/client/static/js/{index-4cncqz8j.js → index-38v0781h.js} +2 -2
  53. package/dist/client/static/js/{index-zs7sjv6x.js → index-4banz7gr.js} +1 -1
  54. package/dist/client/static/js/{index-nh29fkk9.js → index-7dp90ad1.js} +2 -2
  55. package/dist/client/static/js/{index-yjmm73jm.js → index-7z9tz4ze.js} +2 -2
  56. package/dist/client/static/js/{index-zs73zwjz.js → index-7zc1z9z9.js} +4 -4
  57. package/dist/client/static/js/{index-z78bzryw.js → index-8y51kgan.js} +3 -3
  58. package/dist/client/static/js/{index-gp57dx2v.js → index-axszsg7a.js} +1 -1
  59. package/dist/client/static/js/{index-pxtff3ez.js → index-bvjct7sp.js} +2 -2
  60. package/dist/client/static/js/{index-8b3t2y77.js → index-cqnpsw2m.js} +2 -2
  61. package/dist/client/static/js/{index-yzda8j2d.js → index-d8r84zjd.js} +12 -12
  62. package/dist/client/static/js/{index-02543wk3.js → index-dg3b0mfk.js} +2 -2
  63. package/dist/client/static/js/index-dkqgmacr.js +4 -0
  64. package/dist/client/static/js/{index-pkes9492.js → index-e7yf273s.js} +2 -2
  65. package/dist/client/static/js/{index-8k7vjp8b.js → index-egd0vfey.js} +1 -1
  66. package/dist/client/static/js/{index-dzmar8jr.js → index-enb6chty.js} +1 -1
  67. package/dist/client/static/js/{index-v3f7we4n.js → index-f4fqvct6.js} +22 -22
  68. package/dist/client/static/js/{index-pysqpc5n.js → index-fg965t62.js} +2 -2
  69. package/dist/client/static/js/{index-raca8tsh.js → index-fgyenbv8.js} +4 -4
  70. package/dist/client/static/js/{index-qsw5edtk.js → index-fjnkzk12.js} +5 -5
  71. package/dist/client/static/js/{index-50mdqev0.js → index-g3a9j9hf.js} +1 -1
  72. package/dist/client/static/js/{index-1t5ybx9v.js → index-g4rsmakg.js} +3 -3
  73. package/dist/client/static/js/{index-qx6x4z0y.js → index-gmnmnfm0.js} +2 -2
  74. package/dist/client/static/js/{index-f33c4paw.js → index-gwqb7m8g.js} +1 -1
  75. package/dist/client/static/js/{index-ykfd2fyj.js → index-j60gtvw8.js} +1 -1
  76. package/dist/client/static/js/index-jvs2fvqz.js +2 -0
  77. package/dist/client/static/js/{index-r8cc80w5.js → index-jz93j0at.js} +2 -2
  78. package/dist/client/static/js/{index-82vk27q1.js → index-k9ws464d.js} +2 -2
  79. package/dist/client/static/js/{index-0pabfaac.js → index-kc3c2gzb.js} +1 -1
  80. package/dist/client/static/js/{index-5jnvz9hw.js → index-kccp6tgd.js} +2 -2
  81. package/dist/client/static/js/{index-1y3rzw6b.js → index-kmzd0adv.js} +1 -1
  82. package/dist/client/static/js/{index-77t0nvt1.js → index-ksph3kpr.js} +2 -2
  83. package/dist/client/static/js/{index-dfqmwm7j.js → index-m9s9rg5k.js} +2 -2
  84. package/dist/client/static/js/{index-gsxebrq9.js → index-n9scbxy5.js} +2 -2
  85. package/dist/client/static/js/{index-7a2efrbj.js → index-q1gwgmxt.js} +2 -2
  86. package/dist/client/static/js/{index-b42t14wk.js → index-q81rxwh7.js} +35 -35
  87. package/dist/client/static/js/{index-ktbrmp29.js → index-qhytrsyb.js} +2 -2
  88. package/dist/client/static/js/index-qzw4jnnv.js +1 -0
  89. package/dist/client/static/js/{index-cz50ha6x.js → index-r11bbnek.js} +78 -78
  90. package/dist/client/static/js/{index-zndbhb9w.js → index-rv4qs3wm.js} +2 -2
  91. package/dist/client/static/js/{index-hga3e13s.js → index-s78n0dtv.js} +2 -2
  92. package/dist/client/static/js/{index-03pyvmcz.js → index-sesghshh.js} +2 -2
  93. package/dist/client/static/js/index-tnv3dryk.js +9 -0
  94. package/dist/client/static/js/{index-dtj73vs1.js → index-tzbzehqd.js} +1 -1
  95. package/dist/client/static/js/index-vcrh95gf.css +1 -0
  96. package/dist/client/static/js/{index-8kbp24xg.js → index-vmgzhp41.js} +1 -1
  97. package/dist/client/static/js/{index-r9db1gsf.js → index-wmv3crye.js} +2 -2
  98. package/dist/client/static/js/{index-b0v6gwym.js → index-ycks7gyg.js} +2 -2
  99. package/dist/client/static/js/{index-hw14rhen.js → index-ynaxep06.js} +2 -2
  100. package/dist/client/static/js/{index-rab39785.js → index-ys0xpw3q.js} +2 -2
  101. package/dist/client/static/js/{index-feffxxss.js → index-yvgbr7ek.js} +2 -2
  102. package/dist/client/static/js/index-zqthmaxq.js +478 -0
  103. package/dist/client/static/js/info-A6RAGUB7-m6qz24p8.js +1 -0
  104. package/dist/client/static/js/{infoDiagram-VRGFBTTK-4e7ej63f.js → infoDiagram-VRGFBTTK-qv7438m3.js} +1 -1
  105. package/dist/client/static/js/ini-1x0ad976.js +1 -0
  106. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-k3yet1ec.js → ishikawaDiagram-OU5B5YK6-p1w6zg5y.js} +4 -4
  107. package/dist/client/static/js/java-3944nq02.js +1 -0
  108. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-qe352kyd.js → journeyDiagram-ZHPQQLJL-ywk6xqxr.js} +5 -5
  109. package/dist/client/static/js/json-g5ggnd94.js +1 -0
  110. package/dist/client/static/js/jsx-f6p72qpc.js +1 -0
  111. package/dist/client/static/js/{julia-2eekpjq8.js → julia-0h9krgsd.js} +1 -1
  112. package/dist/client/static/js/{kanban-definition-PNTS6WVX-58hag75n.js → kanban-definition-PNTS6WVX-gtrmhggc.js} +5 -5
  113. package/dist/client/static/js/lua-edn2b3wn.js +1 -0
  114. package/dist/client/static/js/markdown-9dhg1fax.js +1 -0
  115. package/dist/client/static/js/{mermaid.core-6e89h6vm.js → mermaid.core-5s24b4hh.js} +6 -6
  116. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-ncsam2fm.js → mindmap-definition-NLK3R4M7-3wx7abqn.js} +4 -4
  117. package/dist/client/static/js/one-dark-pro-3vya9z02.js +1 -0
  118. package/dist/client/static/js/one-light-1yrwn9my.js +1 -0
  119. package/dist/client/static/js/packet-AYTQ26CC-ng6wq5xj.js +1 -0
  120. package/dist/client/static/js/{pegDiagram-GJSIUBJH-b5ckc39d.js → pegDiagram-GJSIUBJH-yvyqnjya.js} +1 -1
  121. package/dist/client/static/js/{perl-dtn1fccw.js → perl-rptyx23q.js} +1 -1
  122. package/dist/client/static/js/{php-7av78hch.js → php-sagvq3wz.js} +1 -1
  123. package/dist/client/static/js/pie-WAS4IAKB-rf6jhxf6.js +1 -0
  124. package/dist/client/static/js/{pieDiagram-5QR66LMP-s4d47ve8.js → pieDiagram-5QR66LMP-26x6pj38.js} +3 -3
  125. package/dist/client/static/js/properties-fcmj08pv.js +1 -0
  126. package/dist/client/static/js/python-532d8ezm.js +1 -0
  127. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-zm0ekvjz.js → quadrantDiagram-O4NWA36T-qhe8h0j9.js} +6 -6
  128. package/dist/client/static/js/r-ptmdxs2a.js +1 -0
  129. package/dist/client/static/js/radar-RG4KPBEZ-ygp6hxq4.js +1 -0
  130. package/dist/client/static/js/railroad-74A4TZTK-rxgnrb2g.js +1 -0
  131. package/dist/client/static/js/railroad-abnf-HS5TGJTU-xkv52a2p.js +1 -0
  132. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-bvcktbqh.js +1 -0
  133. package/dist/client/static/js/railroad-peg-WCYAUIDC-9c3v7jsq.js +1 -0
  134. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-52vdqf53.js → railroadDiagram-XR7U4H2S-dwy3k2jx.js} +1 -1
  135. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-7kf8bmk9.js → requirementDiagram-PLB6GJNP-hcmgfesg.js} +4 -4
  136. package/dist/client/static/js/{ruby-s2bqr910.js → ruby-9qyx7knh.js} +1 -1
  137. package/dist/client/static/js/{rust-q98kssv3.js → rust-bmb4ee5w.js} +1 -1
  138. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-bcb9f54a.js → sankeyDiagram-IPEJSGJF-s6d3k4zs.js} +6 -6
  139. package/dist/client/static/js/{sass-bm32bb5k.js → sass-07rteya0.js} +1 -1
  140. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-76ywvj7g.js → sequenceDiagram-PO4LG4MO-0fcmzgdy.js} +19 -19
  141. package/dist/client/static/js/{sizeCapture-INFHLROL-p9bsf5dc.js → sizeCapture-INFHLROL-t8fcm7rq.js} +1 -1
  142. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1ecfb3fs.js → stateDiagram-v2-GCMORJYK-jr80hfeg.js} +6 -6
  143. package/dist/client/static/js/{svelte-ztkaww47.js → svelte-w365cpwa.js} +1 -1
  144. package/dist/client/static/js/{swimlanes-2SLR337P-2pyjr946.js → swimlanes-2SLR337P-x1ay6w39.js} +1 -1
  145. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xj123xrp.js +8 -0
  146. package/dist/client/static/js/{timeline-definition-EJHVYXUP-4csxwmn2.js → timeline-definition-EJHVYXUP-qz0g6msb.js} +2 -2
  147. package/dist/client/static/js/treeView-Q6P3EWNA-fb58a7z1.js +1 -0
  148. package/dist/client/static/js/treemap-WGGIJYW6-ej4qhksx.js +1 -0
  149. package/dist/client/static/js/typescript-683kkkaw.js +1 -0
  150. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0p1jnbsn.js → usecaseDiagram-POWQR4AR-sxzrv8ht.js} +43 -43
  151. package/dist/client/static/js/{vennDiagram-UO4OBE2U-y1hgdet4.js → vennDiagram-UO4OBE2U-qsqgnjcv.js} +5 -5
  152. package/dist/client/static/js/{vue-cbqm4bed.js → vue-d6cesny1.js} +1 -1
  153. package/dist/client/static/js/wardley-WFR3VGLG-mkp0kanv.js +1 -0
  154. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-p578yrgm.js → wardleyDiagram-VNRHLVJA-rvwxn458.js} +4 -4
  155. package/dist/client/static/js/xml-6ct32gys.js +1 -0
  156. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-b08b4ah0.js → xychartDiagram-PMCCYNJV-nb4w7rcg.js} +5 -5
  157. package/dist/client/static/js/yaml-1d5m3bfj.js +1 -0
  158. package/marketplace/plugins/command-runner/package.json +2 -2
  159. package/marketplace/plugins/command-runner/src/app.test.tsx +161 -0
  160. package/marketplace/plugins/command-runner/src/app.tsx +37 -3
  161. package/marketplace/plugins/command-runner/src/panel/Glyph.tsx +22 -4
  162. package/marketplace/plugins/git-forge/package.json +2 -2
  163. package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +22 -3
  164. package/marketplace/plugins/git-forge/src/panel/index.tsx +21 -3
  165. package/marketplace/plugins/git-forge/src/panel/refresh.test.tsx +192 -0
  166. package/marketplace/plugins/git-forge/src/panel/use-forge.ts +4 -2
  167. package/marketplace/plugins/git-forge/src/panel/write.test.tsx +21 -0
  168. package/marketplace/plugins/stats/package.json +2 -2
  169. package/marketplace/plugins/stats/src/RefreshButton.tsx +9 -7
  170. package/marketplace/plugins/stats/src/app.tsx +15 -1
  171. package/marketplace/plugins/stats/src/refresh.test.tsx +166 -0
  172. package/package.json +1 -1
  173. package/src/client/components/common/anchored-menu/index.tsx +26 -8
  174. package/src/client/components/common/context-usage-button/McpSection.test.tsx +34 -5
  175. package/src/client/components/common/context-usage-button/McpSection.tsx +25 -3
  176. package/src/client/components/common/harness-glyph/brands.ts +3 -0
  177. package/src/client/components/common/harness-glyph/omo.ts +22 -0
  178. package/src/client/components/common/server-control/Panel.tsx +24 -86
  179. package/src/client/components/common/server-control/Row.tsx +98 -0
  180. package/src/client/components/common/server-control/index.test.tsx +69 -9
  181. package/src/client/components/layout/VisibilityMenu.tsx +18 -6
  182. package/src/client/components/layout/new-workspace-host/index.test.tsx +84 -0
  183. package/src/client/components/layout/new-workspace-host/index.tsx +35 -0
  184. package/src/client/components/mobile/header-titlebar.test.tsx +38 -3
  185. package/src/client/components/settings/Sidebar.tsx +2 -1
  186. package/src/client/components/settings/categories/GitSettings.tsx +31 -0
  187. package/src/client/components/settings/categories/git-settings/CommitMessageSection.tsx +292 -0
  188. package/src/client/components/settings/categories/git-settings/IdentitySection.tsx +215 -0
  189. package/src/client/components/settings/category-content.tsx +3 -0
  190. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +8 -0
  191. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +55 -2
  192. package/src/client/components/workspace/chat-timeline/MessageList.tsx +13 -1
  193. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +56 -50
  194. package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +38 -2
  195. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +13 -1
  196. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +50 -0
  197. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +20 -1
  198. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +2 -1
  199. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +1 -4
  200. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
  201. package/src/client/components/workspace/git-panel/CommitBox.test.tsx +98 -0
  202. package/src/client/components/workspace/git-panel/CommitBox.tsx +68 -3
  203. package/src/client/components/workspace/git-panel/index.test.ts +12 -0
  204. package/src/client/components/workspace/git-panel/index.tsx +20 -1
  205. package/src/client/components/workspace/repo-picker/index.test.tsx +20 -0
  206. package/src/client/components/workspace/repo-picker/index.tsx +5 -6
  207. package/src/client/data/settings/omp-schema.json +134 -8
  208. package/src/client/hooks/chat/context/mcp.ts +19 -1
  209. package/src/client/hooks/chat/timeline/jump-rail.ts +1 -0
  210. package/src/client/hooks/chat/timeline/row-window.test.ts +38 -3
  211. package/src/client/hooks/chat/timeline/row-window.ts +33 -9
  212. package/src/client/hooks/chat/timeline/scroll-geometry.ts +19 -1
  213. package/src/client/hooks/chat/timeline/scroll.ts +15 -0
  214. package/src/client/hooks/chat/timeline/thinking-open.ts +10 -4
  215. package/src/client/hooks/workspace/commit-box.test.ts +62 -1
  216. package/src/client/hooks/workspace/commit-box.ts +94 -2
  217. package/src/client/hooks/workspace/git-panel-data.ts +15 -7
  218. package/src/client/hooks/workspace/repo-scope/index.test.ts +10 -3
  219. package/src/client/hooks/workspace/repo-scope/index.ts +21 -9
  220. package/src/client/lib/plugins/repo-scope-service.ts +7 -25
  221. package/src/server/lib/chat/session-store.server.ts +22 -1
  222. package/src/server/lib/fs/git-commit-context.test.ts +111 -0
  223. package/src/server/lib/fs/git-commit-context.ts +85 -0
  224. package/src/server/lib/fs/git-commit-message.server.ts +251 -0
  225. package/src/server/lib/fs/git-commit-message.test.ts +211 -0
  226. package/src/server/lib/fs/git-commit-prompt.test.ts +69 -0
  227. package/src/server/lib/fs/git-commit-prompt.ts +57 -0
  228. package/src/server/lib/fs/git-commit-settings.server.ts +42 -0
  229. package/src/server/lib/fs/git-identity.server.test.ts +129 -0
  230. package/src/server/lib/fs/git-identity.server.ts +130 -0
  231. package/src/server/lib/harness/acp/acp-audit.server.ts +13 -62
  232. package/src/server/lib/harness/acp/acp-frames.server.test.ts +105 -0
  233. package/src/server/lib/harness/acp/acp-frames.server.ts +217 -0
  234. package/src/server/lib/harness/acp/acp-raw-messages.server.test.ts +69 -0
  235. package/src/server/lib/harness/acp/acp-raw-messages.server.ts +129 -0
  236. package/src/server/lib/harness/acp/acp-telemetry.server.ts +19 -0
  237. package/src/server/lib/harness/acp/one-shot.server.ts +141 -0
  238. package/src/server/lib/harness/acp/raw-listeners.ts +30 -0
  239. package/src/server/lib/harness/acp/session-handshake.ts +11 -3
  240. package/src/server/lib/harness/acp/session.test-util.ts +2 -0
  241. package/src/server/lib/harness/acp/session.ts +8 -0
  242. package/src/server/lib/harness/capabilities.ts +11 -0
  243. package/src/server/lib/harness/launch-table.ts +19 -0
  244. package/src/server/lib/harness/launch.ts +4 -0
  245. package/src/server/lib/harness/schema.server.ts +23 -0
  246. package/src/server/lib/harness/spawn.server.ts +18 -2
  247. package/src/server/lib/mcp/agent-config.server.test.ts +111 -0
  248. package/src/server/lib/mcp/agent-config.server.ts +205 -0
  249. package/src/server/lib/mcp/probe.server.ts +7 -1
  250. package/src/server/lib/mcp/registry.server.ts +4 -3
  251. package/src/server/lib/mcp/secrets.server.test.ts +85 -0
  252. package/src/server/lib/mcp/secrets.server.ts +108 -0
  253. package/src/server/lib/omp/core/print.server.ts +100 -0
  254. package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
  255. package/src/server/lib/omp/session/artifacts.server.test.ts +15 -5
  256. package/src/server/lib/omp/session/artifacts.server.ts +41 -26
  257. package/src/server/lib/omp/session/delete.server.ts +2 -0
  258. package/src/server/lib/omp/session/goal-auditor.server.ts +10 -48
  259. package/src/server/lib/realtime/topics/session-data.server.ts +6 -14
  260. package/src/server/routes/fs/git-message.test.ts +101 -0
  261. package/src/server/routes/fs/git-message.ts +60 -0
  262. package/src/server/routes/fs/index.ts +2 -0
  263. package/src/server/routes/omp/artifact.ts +4 -3
  264. package/src/server/routes/sessions/mcp.test.ts +65 -1
  265. package/src/server/routes/sessions/mcp.ts +77 -5
  266. package/src/server/routes/settings/git-identity.test.ts +77 -0
  267. package/src/server/routes/settings/git-identity.ts +47 -0
  268. package/src/server/routes/settings/index.ts +2 -0
  269. package/src/server/routes/telemetry/acp-telemetry.test.ts +149 -0
  270. package/src/server/routes/telemetry/context.ts +31 -0
  271. package/src/server/routes/telemetry/raw-messages.ts +34 -0
  272. package/src/shared/lib/chat/tool/artifact.test.ts +4 -2
  273. package/src/shared/lib/chat/tool/artifact.ts +6 -1
  274. package/src/shared/lib/chat/tool/proc-facts.ts +2 -1
  275. package/src/shared/lib/fs/paths.test.ts +2 -0
  276. package/src/shared/lib/fs/repo-label.test.ts +22 -1
  277. package/src/shared/lib/fs/repo-label.ts +29 -0
  278. package/src/shared/lib/git/commit-prompt.test.ts +47 -0
  279. package/src/shared/lib/git/commit-prompt.ts +72 -0
  280. package/src/shared/lib/git/identity.test.ts +46 -0
  281. package/src/shared/lib/git/identity.ts +70 -0
  282. package/src/shared/lib/harness/brand-color.ts +3 -0
  283. package/src/shared/lib/harness/catalog.test.ts +14 -0
  284. package/src/shared/lib/harness/catalog.ts +9 -1
  285. package/src/shared/lib/harness/mcp-facts.ts +4 -0
  286. package/src/shared/lib/harness/provider-facts.test.ts +11 -0
  287. package/src/shared/lib/harness/provider-facts.ts +14 -0
  288. package/src/shared/lib/harness/providers.ts +2 -2
  289. package/src/shared/lib/harness/updates.test.ts +8 -0
  290. package/src/shared/lib/harness/updates.ts +9 -0
  291. package/src/shared/lib/omp/session/proc-daemon.ts +124 -0
  292. package/src/shared/lib/omp/session/proc.test.ts +30 -3
  293. package/src/shared/lib/omp/session/proc.ts +6 -82
  294. package/src/shared/lib/omp/session/wait-idle.test.ts +15 -4
  295. package/src/shared/lib/omp/session/wait-idle.ts +11 -4
  296. package/src/shared/lib/settings/defaults.ts +5 -0
  297. package/src/shared/lib/workspace/new-workspace.ts +20 -0
  298. package/src/shared/types/settings/mcp.ts +2 -2
  299. package/src/shared/types/settings/state.ts +16 -0
  300. package/src/test-support/preload.ts +1 -0
  301. package/dist/client/static/js/ImageView-bxqw3t4k.js +0 -1
  302. package/dist/client/static/js/LayoutWrapper-zt14rv9m.js +0 -2
  303. package/dist/client/static/js/Modal-cm35g20x.js +0 -38
  304. package/dist/client/static/js/SessionsView-gn53zyn7.js +0 -1
  305. package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +0 -1
  306. package/dist/client/static/js/bash-fjzhxy10.js +0 -1
  307. package/dist/client/static/js/c-wqtyezvw.js +0 -1
  308. package/dist/client/static/js/cpp-y0nzwner.js +0 -1
  309. package/dist/client/static/js/css-n2waj098.js +0 -1
  310. package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +0 -1
  311. package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +0 -1
  312. package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +0 -1
  313. package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +0 -1
  314. package/dist/client/static/js/graphql-gvb7e2eb.js +0 -1
  315. package/dist/client/static/js/html-tbz83eke.js +0 -1
  316. package/dist/client/static/js/index-0gbj4270.js +0 -2
  317. package/dist/client/static/js/index-38xv8h4t.js +0 -1
  318. package/dist/client/static/js/index-f4vr1c6e.css +0 -1
  319. package/dist/client/static/js/index-fb6pw9xb.js +0 -2
  320. package/dist/client/static/js/index-pzvr1699.js +0 -478
  321. package/dist/client/static/js/index-rf29f3fq.js +0 -9
  322. package/dist/client/static/js/index-zw621xez.js +0 -4
  323. package/dist/client/static/js/info-A6RAGUB7-n495k952.js +0 -1
  324. package/dist/client/static/js/ini-2gvjwh83.js +0 -1
  325. package/dist/client/static/js/java-1xwcq79s.js +0 -1
  326. package/dist/client/static/js/json-4pqjabgq.js +0 -1
  327. package/dist/client/static/js/jsx-wcsss15s.js +0 -1
  328. package/dist/client/static/js/lua-h7vjcn0h.js +0 -1
  329. package/dist/client/static/js/markdown-f30jjjh9.js +0 -1
  330. package/dist/client/static/js/one-dark-pro-qmyne0tn.js +0 -1
  331. package/dist/client/static/js/one-light-dj0ecjcj.js +0 -1
  332. package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +0 -1
  333. package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +0 -1
  334. package/dist/client/static/js/properties-ymexza6q.js +0 -1
  335. package/dist/client/static/js/python-31ycwa66.js +0 -1
  336. package/dist/client/static/js/r-t2nne4xp.js +0 -1
  337. package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +0 -1
  338. package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +0 -1
  339. package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +0 -1
  340. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +0 -1
  341. package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +0 -1
  342. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-qr5hdxm4.js +0 -8
  343. package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +0 -1
  344. package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +0 -1
  345. package/dist/client/static/js/typescript-p3syh43m.js +0 -1
  346. package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +0 -1
  347. package/dist/client/static/js/xml-4enq788a.js +0 -1
  348. package/dist/client/static/js/yaml-pjtt3jsc.js +0 -1
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
7
+ import fs from 'node:fs';
8
+ import os from 'node:os';
9
+ import path from 'node:path';
10
+ import { getDb } from '@/server/db.server';
11
+ import { writeSettingsJson } from '@/server/lib/db/settings-store';
12
+ import {
13
+ applyGitIdentity,
14
+ readGitIdentity,
15
+ readGitIdentitySettings,
16
+ type GitIdentityDeps,
17
+ } from '@/server/lib/fs/git-identity.server';
18
+ import { SETTINGS_BLOB_KEY } from '@/shared/lib/settings/keys';
19
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
20
+ import { removeDir } from '@/test-support/remove-dir';
21
+
22
+ const dirs: string[] = [];
23
+ const WORK = { id: 'work', name: 'Work User', email: 'work@example.invalid' };
24
+ const PERSONAL = { id: 'personal', name: 'Personal', email: 'me@example.invalid' };
25
+
26
+ function gitConfig(file: string, ...args: string[]): string {
27
+ const result = Bun.spawnSync({ cmd: ['git', 'config', '--file', file, ...args] });
28
+ if (result.exitCode !== 0) {
29
+ throw new Error(`git config ${args.join(' ')} failed: ${result.stderr.toString()}`);
30
+ }
31
+ return result.stdout.toString().trim();
32
+ }
33
+
34
+ function makeConfig(local: { name: string; email: string } | null): GitIdentityDeps {
35
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-identity-'));
36
+ dirs.push(dir);
37
+ const file = path.join(dir, 'gitconfig');
38
+ fs.writeFileSync(file, '');
39
+ if (local) {
40
+ gitConfig(file, 'user.name', local.name);
41
+ gitConfig(file, 'user.email', local.email);
42
+ }
43
+ return { configArgs: ['--file', file] };
44
+ }
45
+
46
+ beforeEach(async () => {
47
+ await isolateDb();
48
+ });
49
+
50
+ afterEach(async () => {
51
+ await releaseDb();
52
+ });
53
+
54
+ afterAll(() => {
55
+ for (const dir of dirs) removeDir(dir);
56
+ });
57
+
58
+ describe('readGitIdentitySettings', () => {
59
+ test('reads the saved list', async () => {
60
+ const db = await getDb();
61
+ await writeSettingsJson(db, SETTINGS_BLOB_KEY, {
62
+ gitIdentities: [WORK, PERSONAL],
63
+ });
64
+ expect(await readGitIdentitySettings()).toEqual({ identities: [WORK, PERSONAL] });
65
+ });
66
+
67
+ test('a malformed list is empty', async () => {
68
+ const db = await getDb();
69
+ await writeSettingsJson(db, SETTINGS_BLOB_KEY, {
70
+ gitIdentities: [{ id: 'bad', name: '', email: 'x@y' }],
71
+ });
72
+ expect(await readGitIdentitySettings()).toEqual({ identities: [] });
73
+ });
74
+ });
75
+
76
+ describe('readGitIdentity', () => {
77
+ test('reads the global config', async () => {
78
+ const deps = makeConfig({ name: 'Global User', email: 'global@example.invalid' });
79
+
80
+ const read = await readGitIdentity(deps);
81
+
82
+ expect(read.global).toEqual({ name: 'Global User', email: 'global@example.invalid' });
83
+ expect(read.appliedId).toBeNull();
84
+ });
85
+ });
86
+
87
+ describe('applyGitIdentity', () => {
88
+ test('writes the identity to the global config and marks it', async () => {
89
+ const deps = makeConfig({ name: 'Global User', email: 'global@example.invalid' });
90
+
91
+ const read = await applyGitIdentity(WORK, deps);
92
+
93
+ expect(read.global).toEqual({ name: WORK.name, email: WORK.email });
94
+ expect(read.appliedId).toBe(WORK.id);
95
+ expect(gitConfig(deps.configArgs![1], '--get', 'user.name')).toBe(WORK.name);
96
+ expect(gitConfig(deps.configArgs![1], '--get', 'user.email')).toBe(WORK.email);
97
+ });
98
+
99
+ test('global config restores the previous values', async () => {
100
+ const deps = makeConfig({ name: 'Global User', email: 'global@example.invalid' });
101
+ await applyGitIdentity(WORK, deps);
102
+
103
+ const read = await applyGitIdentity(null, deps);
104
+
105
+ expect(read.global).toEqual({ name: 'Global User', email: 'global@example.invalid' });
106
+ expect(read.appliedId).toBeNull();
107
+ expect(gitConfig(deps.configArgs![1], '--get', 'user.name')).toBe('Global User');
108
+ });
109
+
110
+ test('a second apply keeps the original backup', async () => {
111
+ const deps = makeConfig({ name: 'Global User', email: 'global@example.invalid' });
112
+ await applyGitIdentity(WORK, deps);
113
+ await applyGitIdentity(PERSONAL, deps);
114
+
115
+ const read = await applyGitIdentity(null, deps);
116
+
117
+ expect(read.global).toEqual({ name: 'Global User', email: 'global@example.invalid' });
118
+ });
119
+
120
+ test('a config with no identity is restored to no identity', async () => {
121
+ const deps = makeConfig(null);
122
+ await applyGitIdentity(WORK, deps);
123
+
124
+ const read = await applyGitIdentity(null, deps);
125
+
126
+ expect(read.global).toBeNull();
127
+ expect(read.appliedId).toBeNull();
128
+ });
129
+ });
@@ -0,0 +1,130 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The commit identity, read from and written to the user's GLOBAL git config.
8
+ *
9
+ * The saved identities are a library; the global config is the source of truth.
10
+ * Applying one writes `user.name` / `user.email` with `git config --global`, so
11
+ * every repository that has no local override commits as that person. "Global
12
+ * config" restores what was there before Kabmo wrote — including "nothing",
13
+ * which unsets the key and lets git's own default answer.
14
+ *
15
+ * The previous values and the applied id live in the same config under
16
+ * `kabmo.identity.*`, so the backup survives a Kabmo restart and cannot be
17
+ * applied to the wrong scope.
18
+ *
19
+ * `configArgs` is the test seam: production passes `['--global']`, a test passes
20
+ * `['--file', tempPath]` so it never touches the developer's real config.
21
+ */
22
+
23
+ import { readSettingsJson } from '@/server/lib/db/settings-store';
24
+ import { getDb } from '@/server/db.server';
25
+ import { runGit } from '@/server/lib/fs/git-run';
26
+ import { SETTINGS_BLOB_KEY } from '@/shared/lib/settings/keys';
27
+ import {
28
+ normalizeGitIdentities,
29
+ type GitIdentity,
30
+ type GitIdentityRead,
31
+ type GitIdentityValue,
32
+ } from '@/shared/lib/git/identity';
33
+
34
+ const MARKER = 'kabmo.identity.applied';
35
+ const PREVIOUS_NAME = 'kabmo.identity.previousName';
36
+ const PREVIOUS_EMAIL = 'kabmo.identity.previousEmail';
37
+
38
+ export interface GitIdentityDeps {
39
+ /** The config scope: `['--global']` in production, `['--file', path]` in tests. */
40
+ configArgs?: string[];
41
+ }
42
+
43
+ export async function readGitIdentitySettings(): Promise<{ identities: GitIdentity[] }> {
44
+ try {
45
+ const db = await getDb();
46
+ const blob = await readSettingsJson<Record<string, unknown> | null>(db, SETTINGS_BLOB_KEY, null);
47
+ return { identities: normalizeGitIdentities(blob?.gitIdentities) };
48
+ } catch {
49
+ return { identities: [] };
50
+ }
51
+ }
52
+
53
+ async function configValue(configArgs: string[], key: string): Promise<string | null> {
54
+ const result = await runGit(['config', ...configArgs, '--get', key], {
55
+ cwd: process.cwd(),
56
+ timeout: 5_000,
57
+ });
58
+ if (result.error || result.exitCode !== 0) return null;
59
+ const value = result.stdout.trim();
60
+ return value.length > 0 ? value : null;
61
+ }
62
+
63
+ async function setConfig(configArgs: string[], key: string, value: string | null): Promise<void> {
64
+ const result = await runGit(
65
+ value === null
66
+ ? ['config', ...configArgs, '--unset', key]
67
+ : ['config', ...configArgs, key, value],
68
+ { cwd: process.cwd(), timeout: 5_000 },
69
+ );
70
+ if (result.error) throw result.error;
71
+ // `--unset` exits 5 when the key is absent; that is the desired state.
72
+ if (result.exitCode !== 0 && !(value === null && result.exitCode === 5)) {
73
+ throw new Error(result.stderr.trim() || `git config ${key} failed`);
74
+ }
75
+ }
76
+
77
+ function pair(name: string | null, email: string | null): GitIdentityValue | null {
78
+ return name && email ? { name, email } : null;
79
+ }
80
+
81
+ export async function readGitIdentity(deps: GitIdentityDeps = {}): Promise<GitIdentityRead> {
82
+ const configArgs = deps.configArgs ?? ['--global'];
83
+ const [name, email, appliedId] = await Promise.all([
84
+ configValue(configArgs, 'user.name'),
85
+ configValue(configArgs, 'user.email'),
86
+ configValue(configArgs, MARKER),
87
+ ]);
88
+ return { global: pair(name, email), appliedId };
89
+ }
90
+
91
+ /**
92
+ * Apply a saved identity to the global config, or restore the config when
93
+ * `identity` is null.
94
+ *
95
+ * The first apply backs up the global values; later applies keep that backup,
96
+ * so "Global config" always returns to what the user had before Kabmo touched
97
+ * it.
98
+ */
99
+ export async function applyGitIdentity(
100
+ identity: GitIdentity | null,
101
+ deps: GitIdentityDeps = {},
102
+ ): Promise<GitIdentityRead> {
103
+ const configArgs = deps.configArgs ?? ['--global'];
104
+
105
+ if (identity) {
106
+ const marker = await configValue(configArgs, MARKER);
107
+ if (!marker) {
108
+ const currentName = await configValue(configArgs, 'user.name');
109
+ const currentEmail = await configValue(configArgs, 'user.email');
110
+ await setConfig(configArgs, PREVIOUS_NAME, currentName);
111
+ await setConfig(configArgs, PREVIOUS_EMAIL, currentEmail);
112
+ }
113
+ await setConfig(configArgs, 'user.name', identity.name);
114
+ await setConfig(configArgs, 'user.email', identity.email);
115
+ await setConfig(configArgs, MARKER, identity.id);
116
+ return readGitIdentity(deps);
117
+ }
118
+
119
+ const marker = await configValue(configArgs, MARKER);
120
+ if (marker) {
121
+ const previousName = await configValue(configArgs, PREVIOUS_NAME);
122
+ const previousEmail = await configValue(configArgs, PREVIOUS_EMAIL);
123
+ await setConfig(configArgs, 'user.name', previousName);
124
+ await setConfig(configArgs, 'user.email', previousEmail);
125
+ await setConfig(configArgs, PREVIOUS_NAME, null);
126
+ await setConfig(configArgs, PREVIOUS_EMAIL, null);
127
+ await setConfig(configArgs, MARKER, null);
128
+ }
129
+ return readGitIdentity(deps);
130
+ }
@@ -15,20 +15,17 @@
15
15
  * omp RPC child is involved.
16
16
  *
17
17
  * The session is disposable: no registry entry, no stream row, no title, no
18
- * goal driver. Only the assistant text is kept.
18
+ * goal driver. Only the assistant text is kept. The transport itself lives in
19
+ * `one-shot.server.ts`, shared with the commit-message generator.
19
20
  */
20
21
 
21
- import { AcpSession } from '@/server/lib/harness/acp/session';
22
- import { loadHarnessConfig, resolveLaunch } from '@/server/lib/harness/config.server';
23
- import { sessionLaunchCommand } from '@/server/lib/harness/launch';
22
+ import { runAcpOneShot } from '@/server/lib/harness/acp/one-shot.server';
24
23
  import {
25
24
  buildGoalAuditPrompt,
26
25
  readGoalAuditAnswers,
27
26
  type GoalAuditAnswers,
28
27
  } from '@/server/lib/omp/session/goal-auditor.server';
29
- import { extractTextFromContent } from '@/shared/lib/omp/session/mapper';
30
28
  import type { HarnessId } from '@/shared/lib/harness/catalog';
31
- import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
32
29
 
33
30
  export interface AcpGoalAuditRequest {
34
31
  harness: HarnessId;
@@ -40,9 +37,6 @@ export interface AcpGoalAuditRequest {
40
37
  timeoutMs?: number;
41
38
  }
42
39
 
43
- /** How long one audit may take. The harness may be slower than print mode. */
44
- const DEFAULT_TIMEOUT_MS = 90_000;
45
-
46
40
  /**
47
41
  * Ask the ACP agent to classify the last turn's report.
48
42
  *
@@ -50,58 +44,15 @@ const DEFAULT_TIMEOUT_MS = 90_000;
50
44
  * reply); the driver treats that the same way it treats an omp audit failure.
51
45
  */
52
46
  export async function runAcpGoalAudit(request: AcpGoalAuditRequest): Promise<GoalAuditAnswers | null> {
53
- let launch;
54
- try {
55
- const configured = await loadHarnessConfig(request.harness);
56
- launch = resolveLaunch(request.harness, configured);
57
- } catch {
58
- return null;
59
- }
60
-
61
- const session = new AcpSession(
62
- {
63
- harness: request.harness,
64
- command: sessionLaunchCommand(request.harness, launch.command),
65
- ...(launch.env ? { env: launch.env } : {}),
66
- model: request.model,
67
- // A classification, not a task: the cheapest level the agent offers.
68
- thinkingLevel: 'off',
69
- accessMode: 'yolo',
70
- },
71
- request.cwd,
72
- );
73
- // A disposable reader: no stream row, no turn settle, no queue, no title.
74
- session.markStream = () => {};
75
- session.onTurnEnded = async () => {};
76
-
77
- const events: AgentEvent[] = [];
78
- session.onEvent((event) => events.push(event));
79
- const ended = Promise.withResolvers<void>();
80
- const stop = session.onEvent((event) => {
81
- if (event.type === 'agent_end') ended.resolve();
47
+ const outcome = await runAcpOneShot({
48
+ harness: request.harness,
49
+ cwd: request.cwd,
50
+ model: request.model,
51
+ prompt: buildGoalAuditPrompt(request.objective, request.answer),
52
+ ...(request.timeoutMs !== undefined ? { timeoutMs: request.timeoutMs } : {}),
53
+ // The audit is a classification, not a task: the agent may use its own
54
+ // tools to read the report, and the prompt is the only thing it is asked.
55
+ denyTools: false,
82
56
  });
83
- const timer = setTimeout(() => {
84
- void session.destroyAndWait();
85
- ended.resolve();
86
- }, request.timeoutMs ?? DEFAULT_TIMEOUT_MS);
87
-
88
- try {
89
- await session.start();
90
- // `synthetic` keeps the audit prompt from becoming this session's title.
91
- await session.send({
92
- type: 'prompt',
93
- message: buildGoalAuditPrompt(request.objective, request.answer),
94
- synthetic: true,
95
- });
96
- await ended.promise;
97
- const message = [...events].reverse().find((event) => event.type === 'message_end')?.message;
98
- if (!message || typeof message !== 'object' || !('content' in message)) return null;
99
- return readGoalAuditAnswers(extractTextFromContent((message as { content: unknown }).content));
100
- } catch {
101
- return null;
102
- } finally {
103
- clearTimeout(timer);
104
- stop();
105
- await session.destroyAndWait().catch(() => {});
106
- }
57
+ return outcome.ok ? readGoalAuditAnswers(outcome.text) : null;
107
58
  }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The raw ACP frame log.
8
+ *
9
+ * The transcript is Kabmo's fold; the raw panel must show the original
10
+ * `session/update` payloads. These cases pin the write path (batched, ordered),
11
+ * the role mapping the panel filters on, and the page reader's `rawPayload`.
12
+ */
13
+
14
+ import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
15
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
16
+ import { AcpFrameRecorder, frameRole, loadAcpFramesPage } from '@/server/lib/harness/acp/acp-frames.server';
17
+
18
+ const SESSION = 'frame-session';
19
+
20
+ beforeEach(async () => {
21
+ await isolateDb();
22
+ });
23
+
24
+ afterAll(async () => {
25
+ await releaseDb();
26
+ });
27
+
28
+ describe('frameRole', () => {
29
+ test('maps the message kinds the panel filters on', () => {
30
+ expect(frameRole('user_message_chunk')).toBe('user');
31
+ expect(frameRole('agent_message_chunk')).toBe('assistant');
32
+ expect(frameRole('agent_thought_chunk')).toBe('assistant');
33
+ expect(frameRole('tool_call')).toBe('assistant');
34
+ expect(frameRole('usage_update')).toBe('system');
35
+ });
36
+ });
37
+
38
+ describe('AcpFrameRecorder', () => {
39
+ test('stores the original payload and pages it newest first', async () => {
40
+ const recorder = new AcpFrameRecorder(() => SESSION);
41
+ recorder.record('session/update', {
42
+ sessionId: SESSION,
43
+ update: { sessionUpdate: 'user_message_chunk', content: { type: 'text', text: 'hello' } },
44
+ });
45
+ recorder.record('session/update', {
46
+ sessionId: SESSION,
47
+ update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'hi there' } },
48
+ });
49
+ recorder.record('session/update', {
50
+ sessionId: SESSION,
51
+ update: { sessionUpdate: 'usage_update', used: 1200, size: 200000, cost: { amount: 0.01, currency: 'USD' } },
52
+ });
53
+ await recorder.flush();
54
+
55
+ const page = await loadAcpFramesPage(SESSION, 1, 10, 'all', { modelId: 'claude/sonnet', cwd: '/tmp/p' });
56
+ expect(page.total).toBe(3);
57
+ expect(page.filteredTotal).toBe(3);
58
+ expect(page.items.map((item) => item.type)).toEqual(['usage_update', 'agent_message_chunk', 'user_message_chunk']);
59
+
60
+ const usage = page.items[0];
61
+ expect(usage.tokenSummary).toBe('1,200 / 200,000');
62
+ expect(usage.info.cost).toBe(0.01);
63
+ expect(usage.rawPayload).toEqual({
64
+ sessionId: SESSION,
65
+ update: { sessionUpdate: 'usage_update', used: 1200, size: 200000, cost: { amount: 0.01, currency: 'USD' } },
66
+ });
67
+
68
+ const assistant = page.items[1];
69
+ expect(assistant.info.role).toBe('assistant');
70
+ expect(assistant.info.modelID).toBe('claude/sonnet');
71
+ expect(assistant.info.path).toEqual({ cwd: '/tmp/p', root: '/tmp/p' });
72
+ expect(assistant.badgeLabel).toBe('agent_message_chunk: hi there');
73
+ });
74
+
75
+ test('filters by role and pages without re-reading the payloads', async () => {
76
+ const recorder = new AcpFrameRecorder(() => SESSION);
77
+ for (let i = 0; i < 5; i += 1) {
78
+ recorder.record('session/update', {
79
+ sessionId: SESSION,
80
+ update: { sessionUpdate: i % 2 === 0 ? 'user_message_chunk' : 'agent_message_chunk', content: { type: 'text', text: `m${i}` } },
81
+ });
82
+ }
83
+ await recorder.flush();
84
+
85
+ const users = await loadAcpFramesPage(SESSION, 1, 10, 'user');
86
+ expect(users.total).toBe(5);
87
+ expect(users.filteredTotal).toBe(3);
88
+ expect(users.items.every((item) => item.info.role === 'user')).toBe(true);
89
+
90
+ const second = await loadAcpFramesPage(SESSION, 2, 2, 'all');
91
+ expect(second.items).toHaveLength(2);
92
+ expect(second.items.map((item) => item.type)).toEqual(['user_message_chunk', 'agent_message_chunk']);
93
+ });
94
+
95
+ test('a dispose flushes the buffered frames', async () => {
96
+ const recorder = new AcpFrameRecorder(() => SESSION);
97
+ recorder.record('session/update', {
98
+ sessionId: SESSION,
99
+ update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'last' } },
100
+ });
101
+ await recorder.dispose();
102
+ const page = await loadAcpFramesPage(SESSION, 1, 10, 'all');
103
+ expect(page.total).toBe(1);
104
+ });
105
+ });
@@ -0,0 +1,217 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The raw `session/update` frames an ACP session received, and the page the
8
+ * context panel's Raw Messages view reads.
9
+ *
10
+ * The transcript (`acp_transcripts`) is Kabmo's REFACTORED view: one row per
11
+ * message, tool calls folded in, chunks merged. The raw panel exists to show
12
+ * what the agent actually sent, so it reads these frames — the original ACP
13
+ * payloads — and never the fold. A frame is written once, in arrival order,
14
+ * with the `sessionUpdate` kind and the role it maps to denormalized so the
15
+ * panel can page and filter without parsing every payload.
16
+ *
17
+ * Writes are batched on the same debounce as the transcript recorder: a turn
18
+ * emits a frame per chunk, and one INSERT per chunk would put SQLite on the
19
+ * hot path of every token.
20
+ */
21
+
22
+ import { getDb } from '@/server/db.server';
23
+ import type { RawMessageItem } from '@/shared/types/context';
24
+
25
+ const FLUSH_DEBOUNCE_MS = 250;
26
+
27
+ export type AcpFrameRole = 'user' | 'assistant' | 'system';
28
+
29
+ /** The role the panel's filter uses for one `sessionUpdate` kind. */
30
+ export function frameRole(kind: string): AcpFrameRole {
31
+ if (kind === 'user_message_chunk') return 'user';
32
+ if (
33
+ kind === 'agent_message_chunk' ||
34
+ kind === 'agent_thought_chunk' ||
35
+ kind === 'tool_call' ||
36
+ kind === 'tool_call_update'
37
+ ) {
38
+ return 'assistant';
39
+ }
40
+ return 'system';
41
+ }
42
+
43
+ interface BufferedFrame {
44
+ method: string;
45
+ kind: string;
46
+ role: AcpFrameRole;
47
+ payload: string;
48
+ createdAt: number;
49
+ }
50
+
51
+ /** The text a frame carries, for the collapsed row's badge. */
52
+ function frameText(update: Record<string, unknown>): string {
53
+ const content = update.content;
54
+ if (content && typeof content === 'object' && !Array.isArray(content)) {
55
+ const text = (content as Record<string, unknown>).text;
56
+ if (typeof text === 'string') return text;
57
+ }
58
+ if (typeof update.title === 'string') return update.title;
59
+ if (typeof update.text === 'string') return update.text;
60
+ return '';
61
+ }
62
+
63
+ /** One stored frame, in the shape the raw panel draws. */
64
+ function frameItem(
65
+ row: { id: number; method: string; kind: string; role: string; payload: string; created_at: number },
66
+ context: { modelId?: string; cwd?: string },
67
+ ): RawMessageItem {
68
+ let params: Record<string, unknown> = {};
69
+ try {
70
+ const parsed: unknown = JSON.parse(row.payload);
71
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) params = parsed as Record<string, unknown>;
72
+ } catch {
73
+ params = {};
74
+ }
75
+ const update = params.update && typeof params.update === 'object' && !Array.isArray(params.update)
76
+ ? (params.update as Record<string, unknown>)
77
+ : {};
78
+ const text = frameText(update);
79
+ const usage = row.kind === 'usage_update' ? update : null;
80
+ const used = usage && typeof usage.used === 'number' ? usage.used : 0;
81
+ const size = usage && typeof usage.size === 'number' ? usage.size : 0;
82
+ const cost = usage && usage.cost && typeof usage.cost === 'object' && typeof (usage.cost as Record<string, unknown>).amount === 'number'
83
+ ? Number((usage.cost as Record<string, unknown>).amount)
84
+ : 0;
85
+ const timestamp = new Date(row.created_at).toLocaleString('en-US', {
86
+ month: 'numeric',
87
+ day: 'numeric',
88
+ hour: 'numeric',
89
+ minute: '2-digit',
90
+ hour12: true,
91
+ });
92
+ const role = row.role === 'user' || row.role === 'assistant' ? row.role : 'system';
93
+ return {
94
+ id: `frame-${row.id}`,
95
+ type: row.kind || row.method,
96
+ badgeLabel: `${row.kind || row.method}${text ? `: ${text.slice(0, 60)}` : ''}`,
97
+ tokenSummary: usage ? `${used.toLocaleString()} / ${size.toLocaleString()}` : '',
98
+ timestamp,
99
+ info: {
100
+ id: `frame-${row.id}`,
101
+ role,
102
+ modelID: context.modelId ?? '',
103
+ ...(context.cwd ? { path: { cwd: context.cwd, root: context.cwd } } : {}),
104
+ cost,
105
+ tokens: { total: 0, input: 0, output: 0, reasoning: 0, cache: { write: 0, read: 0 } },
106
+ ...(text ? { contentSnippet: text.slice(0, 200) } : {}),
107
+ timestamp,
108
+ },
109
+ rawPayload: params,
110
+ };
111
+ }
112
+
113
+ /**
114
+ * One session's frame writer. `record` is called for every `session/update`
115
+ * the live session receives; `flush` runs on the debounce and on dispose.
116
+ */
117
+ export class AcpFrameRecorder {
118
+ private readonly frames: BufferedFrame[] = [];
119
+ private timer: ReturnType<typeof setTimeout> | undefined;
120
+ private disposed = false;
121
+
122
+ constructor(private readonly sessionId: () => string) {}
123
+
124
+ record(method: string, params: Record<string, unknown>): void {
125
+ if (this.disposed) return;
126
+ const update = params.update;
127
+ const kind = update && typeof update === 'object' && !Array.isArray(update)
128
+ && typeof (update as Record<string, unknown>).sessionUpdate === 'string'
129
+ ? String((update as Record<string, unknown>).sessionUpdate)
130
+ : '';
131
+ this.frames.push({
132
+ method,
133
+ kind,
134
+ role: frameRole(kind),
135
+ payload: JSON.stringify(params),
136
+ createdAt: Date.now(),
137
+ });
138
+ this.schedule();
139
+ }
140
+
141
+ async flush(): Promise<void> {
142
+ if (this.frames.length === 0 || this.disposed) return;
143
+ const sessionId = this.sessionId();
144
+ if (!sessionId) return;
145
+ const rows = this.frames.splice(0);
146
+ try {
147
+ const db = await getDb();
148
+ await db.writeMany(
149
+ 'INSERT INTO acp_frames (session_id, method, kind, role, payload, created_at) VALUES (?, ?, ?, ?, ?, ?)',
150
+ rows.map((row) => [sessionId, row.method, row.kind, row.role, row.payload, row.createdAt]),
151
+ );
152
+ } catch (error) {
153
+ // A failed write is not a lost turn: the next frame retries, and the
154
+ // transcript still holds the conversation.
155
+ this.frames.unshift(...rows);
156
+ console.error('[harness] could not record the ACP frames:', error);
157
+ }
158
+ }
159
+
160
+ async dispose(): Promise<void> {
161
+ clearTimeout(this.timer);
162
+ this.timer = undefined;
163
+ await this.flush();
164
+ this.disposed = true;
165
+ }
166
+
167
+ private schedule(): void {
168
+ if (this.timer !== undefined) return;
169
+ this.timer = setTimeout(() => {
170
+ this.timer = undefined;
171
+ void this.flush();
172
+ }, FLUSH_DEBOUNCE_MS);
173
+ this.timer.unref?.();
174
+ }
175
+ }
176
+
177
+ export interface AcpFramesPage {
178
+ items: RawMessageItem[];
179
+ total: number;
180
+ filteredTotal: number;
181
+ }
182
+
183
+ /**
184
+ * One page of a session's raw frames, newest first. `role` filters on the
185
+ * denormalized column, so a page costs one indexed read rather than a parse of
186
+ * every payload.
187
+ */
188
+ export async function loadAcpFramesPage(
189
+ sessionId: string,
190
+ page: number,
191
+ pageSize: number,
192
+ role: 'all' | 'assistant' | 'user',
193
+ context: { modelId?: string; cwd?: string } = {},
194
+ ): Promise<AcpFramesPage> {
195
+ const db = await getDb();
196
+ const where = role === 'all' ? 'session_id = ?' : 'session_id = ? AND role = ?';
197
+ const params: (string | number)[] = role === 'all' ? [sessionId] : [sessionId, role];
198
+ const totalRow = await db.get<{ n: number }>('SELECT COUNT(*) AS n FROM acp_frames WHERE session_id = ?', [sessionId]);
199
+ const filteredRow = await db.get<{ n: number }>(`SELECT COUNT(*) AS n FROM acp_frames WHERE ${where}`, params);
200
+ const rows = await db.all<{
201
+ id: number;
202
+ method: string;
203
+ kind: string;
204
+ role: string;
205
+ payload: string;
206
+ created_at: number;
207
+ }>(
208
+ `SELECT id, method, kind, role, payload, created_at FROM acp_frames
209
+ WHERE ${where} ORDER BY id DESC LIMIT ? OFFSET ?`,
210
+ [...params, pageSize, (page - 1) * pageSize],
211
+ );
212
+ return {
213
+ items: rows.map((row) => frameItem(row, context)),
214
+ total: totalRow?.n ?? 0,
215
+ filteredTotal: filteredRow?.n ?? 0,
216
+ };
217
+ }