@kabmo-labs/kabmo 0.37.0 → 0.38.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 (254) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +547 -528
  3. package/dist/client/static/js/{CsvGrid-xb429wvb.js → CsvGrid-90zfbn7f.js} +1 -1
  4. package/dist/client/static/js/{DocxView-g58e0bs7.js → DocxView-vwq2rf16.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-1j66avvy.js → DrawioView-bvx7eqcz.js} +1 -1
  6. package/dist/client/static/js/{ImageView-kraqkypn.js → ImageView-q6xfmbrq.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-85dhbn62.js → LayoutWrapper-qatdaw3n.js} +2 -2
  8. package/dist/client/static/js/{Modal-f0nfya07.js → Modal-6jx1fvfb.js} +15 -15
  9. package/dist/client/static/js/{PdfView-nddkrky9.js → PdfView-tkv2d2zs.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-a595m6g1.js → SessionsView-rbnecykz.js} +1 -1
  11. package/dist/client/static/js/{SheetView-s2p4sk6b.js → SheetView-t08g8kdr.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-ppdx4yb9.js → SvgPreview-9vh6mdcp.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-5cjzxcaq.js → abnfDiagram-O67JEVCF-bxcn33e1.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-62mygavm.js → architectureDiagram-NJMV4G6O-40ggw6e8.js} +2 -2
  16. package/dist/client/static/js/{astro-80bs6hvg.js → astro-p3f5p9p2.js} +1 -1
  17. package/dist/client/static/js/{blockDiagram-BEXU5L5S-s5yz9hcd.js → blockDiagram-BEXU5L5S-k41cvjrd.js} +6 -6
  18. package/dist/client/static/js/c-jkdstn33.js +1 -0
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-rf9xkmrm.js → c4Diagram-YGBWAQC7-rdcmn6ac.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-zfm2cj2a.js → classDiagram-v2-NBCMYWYE-txbmbkxv.js} +5 -5
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-fmgpv55e.js → cose-bilkent-JH36ORCC-bxzh3qj1.js} +1 -1
  22. package/dist/client/static/js/cpp-9d3xdpe3.js +1 -0
  23. package/dist/client/static/js/css-r3wja1ze.js +1 -0
  24. package/dist/client/static/js/css-sebxkh5f.js +1 -0
  25. package/dist/client/static/js/cynefin-OW5HDTMX-w2f2vev7.js +1 -0
  26. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-468r5xc2.js → cynefinDiagram-VND7K2PF-abx5343b.js} +1 -1
  27. package/dist/client/static/js/{dagre-6A5THRUB-w370qmgj.js → dagre-6A5THRUB-baj278kt.js} +2 -2
  28. package/dist/client/static/js/{diagram-22UHCM2B-sfvfjjsy.js → diagram-22UHCM2B-vqvhdc5m.js} +7 -7
  29. package/dist/client/static/js/{diagram-3UASUU5V-3r2c8s14.js → diagram-3UASUU5V-w328rfx0.js} +2 -2
  30. package/dist/client/static/js/{diagram-ATOU4E4O-yathy97a.js → diagram-ATOU4E4O-zzcmwnm8.js} +2 -2
  31. package/dist/client/static/js/{diagram-CDSNMT55-kk437kxq.js → diagram-CDSNMT55-8yw39mmj.js} +1 -1
  32. package/dist/client/static/js/{diagram-MLGK6HIB-qdxfjjhf.js → diagram-MLGK6HIB-zgc386pv.js} +1 -1
  33. package/dist/client/static/js/{diagram-MPIPVDR6-dfqeqa1d.js → diagram-MPIPVDR6-efmvvscm.js} +1 -1
  34. package/dist/client/static/js/{dockerfile-yxrt509r.js → dockerfile-bp5dre33.js} +1 -1
  35. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-s0b0vv4k.js → ebnfDiagram-ZINNZB2B-p66h0dzq.js} +1 -1
  36. package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-jwphgp8j.js} +1 -1
  37. package/dist/client/static/js/{elk-276RUBZZ-mtpw0spa.js → elk-276RUBZZ-g0jjxcqd.js} +1 -1
  38. package/dist/client/static/js/{erDiagram-OPXOYQCR-agjdsm1b.js → erDiagram-OPXOYQCR-39gat96z.js} +4 -4
  39. package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +1 -0
  40. package/dist/client/static/js/flowDiagram-KWPJA3E3-f6jpcqyq.js +1 -0
  41. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-z6ywqqc1.js → ganttDiagram-FUAMR5RP-nsjv1zt4.js} +2 -2
  42. package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +1 -0
  43. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-bvbmfw6h.js → gitGraphDiagram-X574FWY7-r4vnkcy3.js} +2 -2
  44. package/dist/client/static/js/graphql-p4cskvad.js +1 -0
  45. package/dist/client/static/js/html-f26r6vv5.js +1 -0
  46. package/dist/client/static/js/{index-83ts8zmk.js → index-0kxqzafy.js} +1 -1
  47. package/dist/client/static/js/{index-kzhtmrh0.js → index-11bdd235.js} +1 -1
  48. package/dist/client/static/js/{index-we1rpftn.js → index-1qszrvzk.js} +2 -2
  49. package/dist/client/static/js/{index-21b3zyrd.js → index-24yyj78e.js} +2 -2
  50. package/dist/client/static/js/{index-nmc30xaz.js → index-2drjp9ks.js} +1 -1
  51. package/dist/client/static/js/{index-w9zxmev3.js → index-2ndq1ngv.js} +1 -1
  52. package/dist/client/static/js/{index-0j518hqm.js → index-3az1w5f8.js} +2 -2
  53. package/dist/client/static/js/{index-8e0s9p45.js → index-50z4ek83.js} +1 -1
  54. package/dist/client/static/js/{index-sezz011q.js → index-5ebhb94w.js} +1 -1
  55. package/dist/client/static/js/{index-302d35e5.js → index-5y0bvq4q.js} +34 -34
  56. package/dist/client/static/js/{index-jpkj6vqp.js → index-6ax2z70w.js} +1 -1
  57. package/dist/client/static/js/{index-9t82sx0w.js → index-6k3e5dph.js} +2 -2
  58. package/dist/client/static/js/{index-09gx6edj.js → index-73jwm4d5.js} +1 -1
  59. package/dist/client/static/js/{index-zvfvqvn9.js → index-9wd9y6m0.js} +2 -2
  60. package/dist/client/static/js/{index-m3j5yx5f.js → index-9wtg6ywn.js} +4 -4
  61. package/dist/client/static/js/{index-j7r414hf.js → index-a74k07z2.js} +2 -2
  62. package/dist/client/static/js/{index-a0bdavdr.js → index-ashpbfqv.js} +1 -1
  63. package/dist/client/static/js/{index-72t6kqjx.js → index-b9b2nwdd.js} +2 -2
  64. package/dist/client/static/js/{index-cx89yk15.js → index-c15r8jd3.js} +2 -2
  65. package/dist/client/static/js/{index-49dhv8ry.js → index-da10qpns.js} +2 -2
  66. package/dist/client/static/js/{index-xearvz2z.js → index-dfgdn3fj.js} +7 -7
  67. package/dist/client/static/js/{index-0mvcbbmy.js → index-dkseg29t.js} +9 -9
  68. package/dist/client/static/js/{index-0sqa91wb.js → index-e1pr3k50.js} +2 -2
  69. package/dist/client/static/js/{index-k06med7d.js → index-fghst0kd.js} +12 -12
  70. package/dist/client/static/js/{index-vtbbfwx0.js → index-gr6jng0x.js} +2 -2
  71. package/dist/client/static/js/{index-5fn0agag.js → index-gwhx66f4.js} +1 -1
  72. package/dist/client/static/js/{index-z7qnffwj.js → index-h8h5c2r8.js} +1 -1
  73. package/dist/client/static/js/{index-qz8mbxm9.js → index-ha75kff0.js} +2 -2
  74. package/dist/client/static/js/{index-z0frtyje.js → index-hzx81cjq.js} +4 -4
  75. package/dist/client/static/js/{index-es3pt29g.js → index-k9xsvab3.js} +1 -1
  76. package/dist/client/static/js/{index-15zn3sns.js → index-nd4p98mc.js} +1 -1
  77. package/dist/client/static/js/{index-w7xbfv44.js → index-qn4pkjfh.js} +2 -2
  78. package/dist/client/static/js/{index-64mb65wx.js → index-r83kr4s5.js} +2 -2
  79. package/dist/client/static/js/{index-pd0140dx.js → index-ra38ggke.js} +1 -1
  80. package/dist/client/static/js/{index-m87yykre.js → index-rf0p3v7q.js} +5 -5
  81. package/dist/client/static/js/{index-1tyvk778.js → index-rgp69pa8.js} +1 -1
  82. package/dist/client/static/js/{index-actppd4z.js → index-rqrcw8nj.js} +2 -2
  83. package/dist/client/static/js/{index-qznwd6g8.js → index-st202rjv.js} +184 -184
  84. package/dist/client/static/js/{index-6q80csr0.js → index-t5t71dhp.js} +2 -2
  85. package/dist/client/static/js/{index-ntxm8pw3.js → index-tfsaj5d1.js} +2 -2
  86. package/dist/client/static/js/{index-059qyaj0.js → index-tv61v3t3.js} +1 -1
  87. package/dist/client/static/js/index-tzm90bsz.js +1 -0
  88. package/dist/client/static/js/{index-z6g74h7g.js → index-vb6t44dw.js} +2 -2
  89. package/dist/client/static/js/{index-t07b31ny.js → index-vnn7m9yp.js} +3 -3
  90. package/dist/client/static/js/{index-hbtk0c12.js → index-vxd4gykh.js} +2 -2
  91. package/dist/client/static/js/{index-a293pdg7.js → index-y3hdv561.js} +2 -2
  92. package/dist/client/static/js/{index-7sa2e8mn.js → index-z0cpp5bc.js} +2 -2
  93. package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +1 -0
  94. package/dist/client/static/js/{infoDiagram-VRGFBTTK-58bv28d4.js → infoDiagram-VRGFBTTK-e39pvm4j.js} +1 -1
  95. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-tz6b0caw.js → ishikawaDiagram-OU5B5YK6-rqhszgvp.js} +2 -2
  96. package/dist/client/static/js/javascript-nyf39d5r.js +1 -0
  97. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ydamm17a.js → journeyDiagram-ZHPQQLJL-wgy5qrsv.js} +3 -3
  98. package/dist/client/static/js/{julia-v7j460gw.js → julia-237yk557.js} +1 -1
  99. package/dist/client/static/js/{kanban-definition-PNTS6WVX-7jxfsf17.js → kanban-definition-PNTS6WVX-b8bxn0h1.js} +3 -3
  100. package/dist/client/static/js/lua-86fjqj8v.js +1 -0
  101. package/dist/client/static/js/{mermaid.core-vty0aq6f.js → mermaid.core-vb5ehtre.js} +6 -6
  102. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-ra4wrts4.js → mindmap-definition-NLK3R4M7-t4p38s38.js} +2 -2
  103. package/dist/client/static/js/one-dark-pro-dhybn1ff.js +1 -0
  104. package/dist/client/static/js/one-light-bqg77ay0.js +1 -0
  105. package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +1 -0
  106. package/dist/client/static/js/{pegDiagram-GJSIUBJH-ydjcfea9.js → pegDiagram-GJSIUBJH-3gp4madx.js} +1 -1
  107. package/dist/client/static/js/{perl-gg4jdkcr.js → perl-dvz4y1tb.js} +1 -1
  108. package/dist/client/static/js/{php-2q8fm6k8.js → php-n6y7dzhm.js} +1 -1
  109. package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +1 -0
  110. package/dist/client/static/js/{pieDiagram-5QR66LMP-wh04y7wp.js → pieDiagram-5QR66LMP-0cbm773h.js} +2 -2
  111. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-4mhbag8n.js → quadrantDiagram-O4NWA36T-jwg7fc9f.js} +1 -1
  112. package/dist/client/static/js/radar-RG4KPBEZ-m3tsyfv0.js +1 -0
  113. package/dist/client/static/js/railroad-74A4TZTK-5p202a4q.js +1 -0
  114. package/dist/client/static/js/railroad-abnf-HS5TGJTU-hj0y9tgn.js +1 -0
  115. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-8c5dct8f.js +1 -0
  116. package/dist/client/static/js/railroad-peg-WCYAUIDC-3tx8z65q.js +1 -0
  117. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-pagmr4hc.js → railroadDiagram-XR7U4H2S-38xh691s.js} +1 -1
  118. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-jhfhp4eq.js → requirementDiagram-PLB6GJNP-gpddawxh.js} +4 -4
  119. package/dist/client/static/js/{ruby-vag6a82m.js → ruby-7zye3g0e.js} +1 -1
  120. package/dist/client/static/js/{rust-yntkm6hw.js → rust-bx3ecv4n.js} +1 -1
  121. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-qrfxzvp3.js → sankeyDiagram-IPEJSGJF-s6t6bbhk.js} +1 -1
  122. package/dist/client/static/js/{sass-kbwea482.js → sass-m0h9yzfb.js} +1 -1
  123. package/dist/client/static/js/{scss-zphrqp25.js → scss-2pwwfkvn.js} +1 -1
  124. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-fpznwnva.js → sequenceDiagram-PO4LG4MO-wkq51pmb.js} +3 -3
  125. package/dist/client/static/js/{sizeCapture-INFHLROL-3hz930jg.js → sizeCapture-INFHLROL-xtwexf8k.js} +1 -1
  126. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-2m99syxm.js → stateDiagram-v2-GCMORJYK-jnwsqa7y.js} +3 -3
  127. package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-x8f8c8hq.js} +1 -1
  128. package/dist/client/static/js/{swimlanes-2SLR337P-hmhd360r.js → swimlanes-2SLR337P-mnkkqcbx.js} +1 -1
  129. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-a8b7z74e.js → swimlanesDiagram-TC7HE7FX-6xmrz03n.js} +1 -1
  130. package/dist/client/static/js/{timeline-definition-EJHVYXUP-765y3ssa.js → timeline-definition-EJHVYXUP-rxq6heqh.js} +2 -2
  131. package/dist/client/static/js/treeView-Q6P3EWNA-mf0rb2yv.js +1 -0
  132. package/dist/client/static/js/treemap-WGGIJYW6-0x5gf06b.js +1 -0
  133. package/dist/client/static/js/typescript-5nmrzgkj.js +1 -0
  134. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-rex2j507.js → usecaseDiagram-POWQR4AR-dz94f57t.js} +13 -13
  135. package/dist/client/static/js/{vennDiagram-UO4OBE2U-wd51qq26.js → vennDiagram-UO4OBE2U-5mmvkhsq.js} +1 -1
  136. package/dist/client/static/js/{vue-j8vb9d7r.js → vue-myjjd0gd.js} +1 -1
  137. package/dist/client/static/js/wardley-WFR3VGLG-x7ej8dms.js +1 -0
  138. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-6jdqn8f7.js → wardleyDiagram-VNRHLVJA-dctdntpa.js} +1 -1
  139. package/dist/client/static/js/xml-3dd1pter.js +1 -0
  140. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-kcz8y04e.js → xychartDiagram-PMCCYNJV-njyfrqkv.js} +2 -2
  141. package/package.json +1 -1
  142. package/src/client/components/common/ComposerPicker.tsx +24 -12
  143. package/src/client/components/common/ComposerTextarea.tsx +1 -0
  144. package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +1 -1
  145. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +1 -1
  146. package/src/client/components/workspace/chat-timeline/index.tsx +3 -3
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.test.tsx +210 -0
  148. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +342 -0
  149. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/LooseFieldAsk.tsx +44 -0
  150. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.test.tsx +44 -1
  151. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +10 -5
  152. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/PluginPendingInteractions.test.ts +1 -0
  153. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +19 -0
  154. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/form-picks.ts +52 -0
  155. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +2 -2
  156. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +53 -4
  157. package/src/client/components/workspace/model-dropdown/index.tsx +1 -1
  158. package/src/client/components/workspace/model-dropdown/use-catalog.ts +3 -32
  159. package/src/client/data/settings/omp-schema.json +55 -1
  160. package/src/client/hooks/chat/composer/harness-model-picker.ts +84 -0
  161. package/src/client/hooks/chat/composer/index.ts +26 -6
  162. package/src/client/hooks/chat/timeline/ask-frames.test.ts +80 -7
  163. package/src/client/hooks/chat/timeline/ask-frames.ts +95 -21
  164. package/src/client/hooks/models/use-harnesses.ts +15 -2
  165. package/src/server/lib/auth/agent-gate.server.ts +64 -0
  166. package/src/server/lib/auth/agent-tree-gate.test.ts +121 -0
  167. package/src/server/lib/auth/guard.test.ts +18 -18
  168. package/src/server/lib/auth/guard.ts +15 -11
  169. package/src/server/lib/auth/handover-guard.test.ts +1 -1
  170. package/src/server/lib/changes/attach.server.ts +57 -0
  171. package/src/server/lib/changes/attach.test.ts +94 -0
  172. package/src/server/lib/changes/blobs.server.ts +52 -0
  173. package/src/server/lib/changes/capture-bash.server.ts +106 -0
  174. package/src/server/lib/changes/capture-fs.server.ts +64 -0
  175. package/src/server/lib/changes/capture-runs.test.ts +136 -0
  176. package/src/server/lib/changes/capture-test-util.ts +46 -0
  177. package/src/server/lib/changes/capture-types.ts +62 -0
  178. package/src/server/lib/changes/capture.server.ts +333 -0
  179. package/src/server/lib/changes/capture.test.ts +245 -0
  180. package/src/server/lib/changes/classify-command.test.ts +172 -0
  181. package/src/server/lib/changes/classify-command.ts +272 -0
  182. package/src/server/lib/changes/classify-git.ts +88 -0
  183. package/src/server/lib/changes/classify-paths.ts +112 -0
  184. package/src/server/lib/changes/classify-tokenize.ts +185 -0
  185. package/src/server/lib/changes/journal.server.ts +183 -0
  186. package/src/server/lib/changes/journal.test.ts +125 -0
  187. package/src/server/lib/changes/merge.test.ts +137 -0
  188. package/src/server/lib/changes/paths.server.ts +37 -0
  189. package/src/server/lib/changes/purge.server.ts +32 -0
  190. package/src/server/lib/changes/reader.server.ts +322 -0
  191. package/src/server/lib/changes/reader.test.ts +137 -0
  192. package/src/server/lib/changes/records.ts +120 -0
  193. package/src/server/lib/changes/scan.server.ts +89 -0
  194. package/src/server/lib/harness/register.server.ts +3 -0
  195. package/src/server/lib/omp/rpc/event-fanout.test.ts +58 -0
  196. package/src/server/lib/omp/rpc/event-fanout.ts +19 -0
  197. package/src/server/lib/omp/rpc/manager.ts +4 -3
  198. package/src/server/lib/omp/rpc/session-registration.ts +5 -0
  199. package/src/server/lib/omp/rpc/session-registry.ts +4 -5
  200. package/src/server/lib/omp/session/delete.server.ts +4 -0
  201. package/src/server/lib/sessions/agent-token.server.test.ts +28 -5
  202. package/src/server/lib/sessions/agent-token.server.ts +42 -6
  203. package/src/server/lib/sessions/relation-access.server.test.ts +96 -0
  204. package/src/server/lib/sessions/relation-access.server.ts +71 -0
  205. package/src/server/routes/sessions/changes.ts +1 -1
  206. package/src/shared/lib/chat/ask-form/fields.ts +1 -0
  207. package/src/shared/lib/chat/ask-form/types.ts +6 -0
  208. package/src/shared/lib/chat/ask-questions.ts +56 -3
  209. package/src/shared/lib/chat/composer/delegation.ts +2 -13
  210. package/src/shared/lib/chat/composer/filter.test.ts +39 -0
  211. package/src/shared/lib/chat/composer/filter.ts +23 -13
  212. package/src/shared/lib/chat/composer/harness-model-items.test.ts +54 -0
  213. package/src/shared/lib/chat/composer/harness-model-items.ts +41 -0
  214. package/src/shared/lib/chat/composer/trigger.test.ts +50 -0
  215. package/src/shared/lib/chat/composer/trigger.ts +29 -1
  216. package/src/shared/lib/chat/timeline/changed-files.test.ts +16 -0
  217. package/src/shared/lib/chat/timeline/changed-files.ts +102 -25
  218. package/src/shared/lib/harness/catalog.ts +21 -0
  219. package/src/{client/components/workspace/model-dropdown/harness-models.test.ts → shared/lib/harness/models.test.ts} +1 -1
  220. package/src/shared/lib/models/option.ts +46 -0
  221. package/src/shared/lib/omp/config/schema.test.ts +20 -0
  222. package/src/shared/types/chat.ts +12 -6
  223. package/src/shared/types/omp/agent.ts +9 -0
  224. package/src/shared/types/session-changes.ts +4 -0
  225. package/dist/client/static/js/architecture-7GRP2DOG-7ewrw5vc.js +0 -1
  226. package/dist/client/static/js/c-wkgxb1t1.js +0 -1
  227. package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
  228. package/dist/client/static/js/css-r2nhvzff.js +0 -1
  229. package/dist/client/static/js/css-tf1s0nb7.js +0 -1
  230. package/dist/client/static/js/cynefin-OW5HDTMX-yyyx3px0.js +0 -1
  231. package/dist/client/static/js/eventmodeling-NTZA5JFV-cx3ztxfz.js +0 -1
  232. package/dist/client/static/js/flowDiagram-KWPJA3E3-267mw6sv.js +0 -1
  233. package/dist/client/static/js/gitGraph-4MIJSDKK-eg9r85ak.js +0 -1
  234. package/dist/client/static/js/graphql-skw5krjr.js +0 -1
  235. package/dist/client/static/js/html-pv88ny12.js +0 -1
  236. package/dist/client/static/js/index-tcegdd2t.js +0 -1
  237. package/dist/client/static/js/info-A6RAGUB7-7qhah7fs.js +0 -1
  238. package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
  239. package/dist/client/static/js/lua-ke895s2q.js +0 -1
  240. package/dist/client/static/js/one-dark-pro-2pywnqrh.js +0 -1
  241. package/dist/client/static/js/one-light-vfgdt4wf.js +0 -1
  242. package/dist/client/static/js/packet-AYTQ26CC-ag2g7tbk.js +0 -1
  243. package/dist/client/static/js/pie-WAS4IAKB-nqcyj3x1.js +0 -1
  244. package/dist/client/static/js/radar-RG4KPBEZ-60gby7be.js +0 -1
  245. package/dist/client/static/js/railroad-74A4TZTK-cnkmcjse.js +0 -1
  246. package/dist/client/static/js/railroad-abnf-HS5TGJTU-qgfdnazd.js +0 -1
  247. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-609h6cpx.js +0 -1
  248. package/dist/client/static/js/railroad-peg-WCYAUIDC-xqnytjhg.js +0 -1
  249. package/dist/client/static/js/treeView-Q6P3EWNA-8djqab8k.js +0 -1
  250. package/dist/client/static/js/treemap-WGGIJYW6-hdztnffk.js +0 -1
  251. package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
  252. package/dist/client/static/js/wardley-WFR3VGLG-avby77vv.js +0 -1
  253. package/dist/client/static/js/xml-81hxjjt4.js +0 -1
  254. /package/src/{client/components/workspace/model-dropdown/harness-models.ts → shared/lib/harness/models.ts} +0 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Attach a change journal to a live session.
8
+ *
9
+ * The subscription is the RAW frame stream when the transport has one: omp's
10
+ * `bash` trace is stripped before ordinary subscribers see it (it is ~a second
11
+ * copy of the output), and the trace is the only structured record of what a
12
+ * shell command ran. A transport without a raw stream (ACP) falls back to
13
+ * `onEvent`; its tool frames still carry `args`, so the tool adapters work and
14
+ * only the shell layer is weaker.
15
+ *
16
+ * The journal is lazy: a session that never calls a tool writes nothing, so a
17
+ * test that spawns a fake child does not touch the developer's real `~/.kabmo`.
18
+ */
19
+
20
+ import os from 'node:os';
21
+ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
22
+ import { ChangeJournal } from '@/server/lib/changes/journal.server';
23
+ import { ChangeCapture } from '@/server/lib/changes/capture.server';
24
+
25
+ export interface JournalSession {
26
+ readonly sessionId: string;
27
+ readonly cwd: string;
28
+ onEvent(listener: (event: AgentEvent) => void): () => void;
29
+ onRawEvent?(listener: (event: AgentEvent) => void): () => void;
30
+ }
31
+
32
+ export interface JournalAttachment {
33
+ /** Stop listening; the journal flushes and closes in the background. */
34
+ detach(): void;
35
+ /** Await every in-flight capture and append (tests and shutdown). */
36
+ flush(): Promise<void>;
37
+ }
38
+
39
+ /** Start journaling `session`. */
40
+ export function attachChangeJournal(session: JournalSession): JournalAttachment {
41
+ const noop: JournalAttachment = { detach: () => {}, flush: async () => {} };
42
+ if (!session.sessionId) return noop;
43
+ const journal = new ChangeJournal(session.sessionId, session.cwd);
44
+ const capture = new ChangeCapture({ journal, cwd: session.cwd, home: os.homedir() });
45
+ const subscribe = session.onRawEvent ?? session.onEvent;
46
+ // A test double (or a transport that exposes no frame stream) has neither;
47
+ // the journal is an annotation, not a reason to fail a registration.
48
+ if (typeof subscribe !== 'function') return noop;
49
+ const off = subscribe.call(session, (event) => capture.onFrame(event));
50
+ return {
51
+ detach: () => {
52
+ off();
53
+ void capture.flush().finally(() => journal.close());
54
+ },
55
+ flush: () => capture.flush(),
56
+ };
57
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The attach seam: a live session's raw frames reach the journal.
8
+ *
9
+ * The unit tests for the capture and the reader prove the two halves; this one
10
+ * proves the wire between them — `onRawEvent` is the subscription, the real
11
+ * filesystem is the source, and a `bash rm` lands as a `delete` record.
12
+ */
13
+
14
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
15
+ import * as fsp from 'node:fs/promises';
16
+ import * as os from 'node:os';
17
+ import * as path from 'node:path';
18
+ import { attachChangeJournal } from '@/server/lib/changes/attach.server';
19
+ import { journalPath } from '@/server/lib/changes/paths.server';
20
+ import { parseJournalLine, type JournalRecord } from '@/server/lib/changes/records';
21
+ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
22
+
23
+ let dataDir = '';
24
+ let cwd = '';
25
+ let original: string | undefined;
26
+
27
+ beforeAll(async () => {
28
+ original = Bun.env.KABMO_DATA_DIR;
29
+ dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-attach-'));
30
+ cwd = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-cwd-'));
31
+ Bun.env.KABMO_DATA_DIR = dataDir;
32
+ });
33
+
34
+ afterAll(async () => {
35
+ if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
36
+ else Bun.env.KABMO_DATA_DIR = original;
37
+ await fsp.rm(dataDir, { recursive: true, force: true });
38
+ await fsp.rm(cwd, { recursive: true, force: true });
39
+ });
40
+
41
+ describe('attachChangeJournal', () => {
42
+ test('subscribes to the raw stream and journals a bash delete', async () => {
43
+ const file = path.join(cwd, 'a.txt');
44
+ await fsp.writeFile(file, 'old');
45
+ const listeners: ((event: AgentEvent) => void)[] = [];
46
+ const session = {
47
+ sessionId: 'attach-1',
48
+ cwd,
49
+ onEvent: () => () => {},
50
+ onRawEvent: (listener: (event: AgentEvent) => void) => {
51
+ listeners.push(listener);
52
+ return () => {};
53
+ },
54
+ };
55
+
56
+ const attachment = attachChangeJournal(session);
57
+ expect(listeners.length).toBe(1);
58
+
59
+ listeners[0]({
60
+ type: 'tool_execution_start',
61
+ toolCallId: 'c1',
62
+ toolName: 'bash',
63
+ args: { command: 'rm -f a.txt' },
64
+ });
65
+ await attachment.flush();
66
+ await fsp.rm(file);
67
+ listeners[0]({
68
+ type: 'tool_execution_end',
69
+ toolCallId: 'c1',
70
+ toolName: 'bash',
71
+ result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['rm', '-f', 'a.txt'], st: 0 }] }] } } },
72
+ });
73
+ await attachment.flush();
74
+ attachment.detach();
75
+
76
+ const text = await Bun.file(journalPath('attach-1')).text();
77
+ const records = text.split('\n').map(parseJournalLine).filter((line): line is JournalRecord => line !== null);
78
+ const change = records.find((line) => line.type === 'change');
79
+ expect(change?.type).toBe('change');
80
+ if (change?.type !== 'change') throw new Error('expected a change record');
81
+ expect(change.op).toBe('delete');
82
+ expect(change.path).toBe(file);
83
+ expect(change.source).toBe('trace');
84
+ });
85
+
86
+ test('a session with no frame stream is a no-op, not a crash', () => {
87
+ const attachment = attachChangeJournal({
88
+ sessionId: 'attach-2',
89
+ cwd,
90
+ onEvent: undefined as never,
91
+ });
92
+ expect(() => attachment.detach()).not.toThrow();
93
+ });
94
+ });
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Content-addressed gzip blobs for the change journal.
8
+ *
9
+ * The key is `<byteLength base36>-<Bun.hash base36>`, the same shape omp uses,
10
+ * so a blob written by either writer is recognisable. The cap is 32 MB — four
11
+ * times omp's 8 MB — because the journal's job is to answer "what did this run
12
+ * do", and a 10 MB file is exactly the case the old cap could not answer. A
13
+ * file over the cap is not stored: the record carries `undefined`, and the
14
+ * reader reports the two sides as unknown rather than inventing them.
15
+ */
16
+
17
+ import { mkdir } from 'node:fs/promises';
18
+ import path from 'node:path';
19
+
20
+ export const MAX_BLOB_BYTES = 32 * 1024 * 1024;
21
+
22
+ export function blobKey(text: string): string {
23
+ const bytes = Buffer.from(text, 'utf8');
24
+ return `${bytes.byteLength.toString(36)}-${Bun.hash(bytes).toString(36)}`;
25
+ }
26
+
27
+ /** Store `text` and return its key; `null` when it exceeds the cap. */
28
+ export async function writeBlob(dir: string, text: string): Promise<string | null> {
29
+ const bytes = Buffer.from(text, 'utf8');
30
+ if (bytes.byteLength > MAX_BLOB_BYTES) return null;
31
+ const key = blobKey(text);
32
+ const file = path.join(dir, key);
33
+ if (await Bun.file(file).exists()) return key;
34
+ await mkdir(dir, { recursive: true, mode: 0o700 });
35
+ await Bun.write(file, Bun.gzipSync(bytes));
36
+ return key;
37
+ }
38
+
39
+ /** Blob content for a key; `null` = absent file, `undefined` = not stored/missing. */
40
+ export async function readBlob(
41
+ dir: string,
42
+ key: string | null | undefined,
43
+ ): Promise<string | null | undefined> {
44
+ if (key === null) return null;
45
+ if (key === undefined) return undefined;
46
+ try {
47
+ const bytes = await Bun.file(path.join(dir, key)).bytes();
48
+ return new TextDecoder().decode(Bun.gunzipSync(bytes));
49
+ } catch {
50
+ return undefined;
51
+ }
52
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `bash` half of the capture layer: what a shell command changed.
8
+ *
9
+ * Two sources, merged: the script text tokenized at start (which names the
10
+ * redirects the trace does not model) and the trace's `simple` nodes at end
11
+ * (which name the `argv` that actually ran). A rename becomes two records so
12
+ * the existing A/M/D list can render it. An opaque command is reconciled from
13
+ * the two git snapshots, and a command the scan could not cover is a note.
14
+ */
15
+
16
+ import {
17
+ classifyArgv,
18
+ classifyCommand,
19
+ type CommandMutation,
20
+ } from '@/server/lib/changes/classify-command';
21
+ import type {
22
+ ChangeExtra,
23
+ ChangeSource,
24
+ PendingCall,
25
+ ShellTrace,
26
+ } from '@/server/lib/changes/capture-types';
27
+ import type { GitScan } from '@/server/lib/changes/scan.server';
28
+
29
+ export interface BashCaptureHost {
30
+ cwd: string;
31
+ home: string;
32
+ readFile(absolute: string): Promise<string | null | undefined>;
33
+ takeScan(cwd: string): Promise<GitScan | null>;
34
+ readHead(root: string, absolute: string): Promise<string | null>;
35
+ writeChange(
36
+ pending: PendingCall,
37
+ absolute: string,
38
+ before: string | null | undefined,
39
+ after: string | null | undefined,
40
+ source: ChangeSource,
41
+ extra?: ChangeExtra,
42
+ ): Promise<void>;
43
+ note(pending: PendingCall, reason: 'opaque-command' | 'scan-budget', detail?: string): Promise<void>;
44
+ }
45
+
46
+ export async function captureBashChanges(
47
+ pending: PendingCall,
48
+ trace: ShellTrace | null,
49
+ host: BashCaptureHost,
50
+ ): Promise<void> {
51
+ const plan = pending.plan ?? classifyCommand(pending.command ?? '', host.cwd, host.home);
52
+ const mutations = new Map<string, CommandMutation>();
53
+ const remember = (mutation: CommandMutation): void => {
54
+ mutations.set(`${mutation.op}:${mutation.from ?? ''}:${mutation.path}`, mutation);
55
+ };
56
+ for (const mutation of plan.mutations) remember(mutation);
57
+ if (trace) {
58
+ for (const unit of trace.units ?? []) {
59
+ for (const node of unit.nodes ?? []) {
60
+ if (node.k !== 'simple' || !Array.isArray(node.argv) || node.argv.length === 0) continue;
61
+ const argv = node.argv.filter((value): value is string => typeof value === 'string');
62
+ for (const mutation of classifyArgv(argv, host.cwd, host.home).mutations) remember(mutation);
63
+ }
64
+ }
65
+ }
66
+
67
+ const exit = typeof trace?.status === 'number' ? trace.status : undefined;
68
+ for (const mutation of mutations.values()) {
69
+ if (mutation.op === 'rename' && mutation.from) {
70
+ const fromEntry = pending.before.get(mutation.from);
71
+ const before = fromEntry ? fromEntry.text : null;
72
+ const after = await host.readFile(mutation.path);
73
+ if (before === after) continue;
74
+ // Two records, so the existing A/M/D list can render a rename.
75
+ await host.writeChange(pending, mutation.from, before, null, 'trace', { command: pending.command, exit });
76
+ await host.writeChange(pending, mutation.path, null, after, 'trace', { command: pending.command, exit, from: mutation.from });
77
+ continue;
78
+ }
79
+ const pathEntry = pending.before.get(mutation.path);
80
+ const before = pathEntry ? pathEntry.text : null;
81
+ const after = await host.readFile(mutation.path);
82
+ await host.writeChange(pending, mutation.path, before, after, 'trace', { command: pending.command, exit });
83
+ }
84
+
85
+ if (pending.scan) await reconcileScan(pending, pending.scan, host);
86
+ if (plan.opaque) await host.note(pending, 'opaque-command', pending.command);
87
+ }
88
+
89
+ /** Journal the delta an opaque command made, from the two git snapshots. */
90
+ async function reconcileScan(pending: PendingCall, start: GitScan, host: BashCaptureHost): Promise<void> {
91
+ const after = await host.takeScan(host.cwd);
92
+ if (!after) return;
93
+ if (start.truncated || after.truncated) await host.note(pending, 'scan-budget', pending.command);
94
+
95
+ const paths = new Set([...start.dirty.keys(), ...after.dirty.keys()]);
96
+ for (const absolute of paths) {
97
+ const before = start.dirty.has(absolute)
98
+ ? start.dirty.get(absolute) ?? null
99
+ : await host.readHead(start.root, absolute);
100
+ const afterText = after.dirty.has(absolute)
101
+ ? after.dirty.get(absolute) ?? null
102
+ : await host.readFile(absolute);
103
+ if (before === afterText) continue;
104
+ await host.writeChange(pending, absolute, before, afterText, 'scan');
105
+ }
106
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The filesystem half of the capture layer: reading a file, statting it, and
8
+ * the two constants that decide when a tool or a command is worth a note.
9
+ *
10
+ * `displayPathFor` is the one display rule: a path inside the session cwd is
11
+ * shown relative with `/` separators, anything else stays absolute. The chat
12
+ * list and the diff header both read it, so a Windows `src\a.ts` never appears
13
+ * beside a forward-slash path from another producer.
14
+ */
15
+
16
+ import { stat } from 'node:fs/promises';
17
+ import path from 'node:path';
18
+ import { isRecord } from '@/shared/lib/util/guards';
19
+ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
20
+ import type { ShellTrace } from '@/server/lib/changes/capture-types';
21
+
22
+ /** A tool whose name promises a write; only these earn an `unknown-tool` note. */
23
+ export const MUTATING_TOOL = /(edit|write|replace|patch|create|delete|remove|move|rename|apply|insert|append)/i;
24
+
25
+ /**
26
+ * An opaque command worth a filesystem snapshot. A test runner is opaque but
27
+ * usually does not rewrite the tree, and scanning on every `bun test` would
28
+ * cost two git processes per run; a reset, an install or a script is the case
29
+ * the scan exists for.
30
+ */
31
+ export const SCAN_COMMAND = /^(?:git\s+(?:reset|clean|checkout|restore|stash|apply|rebase|merge|pull|cherry-pick|revert)|(?:npm|pnpm|yarn|bun)\s+(?:install|i|add|remove|uninstall)|make|cargo\s+(?:build|run)|go\s+(?:build|run)|(?:sh|bash|zsh|python3?|node)\s)/;
32
+
33
+ export async function defaultReadFile(absolute: string): Promise<string | null> {
34
+ try {
35
+ return await Bun.file(absolute).text();
36
+ } catch {
37
+ return null;
38
+ }
39
+ }
40
+
41
+ export async function defaultStatFile(absolute: string): Promise<{ mtimeMs: number; size: number } | null> {
42
+ try {
43
+ const info = await stat(absolute);
44
+ return { mtimeMs: info.mtimeMs, size: info.size };
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+
50
+ /** `path` relative to the session cwd when inside it, else unchanged. */
51
+ export function displayPathFor(absolute: string, cwd: string): string {
52
+ const relative = path.relative(cwd, absolute);
53
+ if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) return absolute;
54
+ return relative.replaceAll('\\', '/');
55
+ }
56
+
57
+ /** The shell trace on a `bash` result, wherever the transport nested it. */
58
+ export function extractTrace(event: AgentEvent): ShellTrace | null {
59
+ const result = isRecord(event.result) ? event.result : undefined;
60
+ const nested = result && isRecord(result.details) ? result.details : undefined;
61
+ const details = nested ?? (isRecord(event.details) ? event.details : undefined);
62
+ const trace = details && isRecord(details.trace) ? details.trace : undefined;
63
+ return trace ? (trace as ShellTrace) : null;
64
+ }
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Run separation: a run is not every `agent_end`.
8
+ *
9
+ * omp emits a non-terminal `agent_end` while an async subagent is still
10
+ * working, and a retry re-enters `agent_start` without one. The capture must
11
+ * reuse the run id across both, close only on a terminal end, and keep the
12
+ * closed id so a subagent's late write still carries the run that started it.
13
+ *
14
+ * Paths go through `at()`, so the fixture is native on Windows too.
15
+ */
16
+
17
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
18
+ import * as fsp from 'node:fs/promises';
19
+ import * as os from 'node:os';
20
+ import * as path from 'node:path';
21
+ import { makeCapture, records, REPO } from '@/server/lib/changes/capture-test-util';
22
+
23
+ let dataDir = '';
24
+ let original: string | undefined;
25
+
26
+ beforeAll(async () => {
27
+ original = Bun.env.KABMO_DATA_DIR;
28
+ dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-runs-'));
29
+ Bun.env.KABMO_DATA_DIR = dataDir;
30
+ });
31
+
32
+ afterAll(async () => {
33
+ if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
34
+ else Bun.env.KABMO_DATA_DIR = original;
35
+ await fsp.rm(dataDir, { recursive: true, force: true });
36
+ });
37
+
38
+ /** A path inside the fixture repo, spelled the way the host spells it. */
39
+ function at(relative: string): string {
40
+ return path.join(REPO, relative);
41
+ }
42
+
43
+ describe('runs', () => {
44
+ test('agent_start opens a run and the change carries its id', async () => {
45
+ const files = new Map([[at('a.ts'), 'old']]);
46
+ const capture = makeCapture('cap-run', files);
47
+ capture.onFrame({ type: 'agent_start' });
48
+ capture.onFrame({ type: 'tool_execution_start', toolCallId: 'c1', toolName: 'edit', args: { path: 'a.ts' } });
49
+ await capture.flush();
50
+ files.set(at('a.ts'), 'new');
51
+ capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'edit' });
52
+ await capture.flush();
53
+
54
+ const lines = await records('cap-run');
55
+ const start = lines.find((line) => line.type === 'run' && line.phase === 'start');
56
+ const change = lines.find((line) => line.type === 'change');
57
+ expect(start?.type).toBe('run');
58
+ expect(change?.type).toBe('change');
59
+ if (start?.type !== 'run' || change?.type !== 'change') throw new Error('expected records');
60
+ expect(change.runId).toBe(start.runId);
61
+ expect(change.runAt).toBe(start.at);
62
+ });
63
+
64
+ test('a non-terminal agent_end is a continuation: the run id is reused', async () => {
65
+ const files = new Map([[at('a.ts'), 'old']]);
66
+ const capture = makeCapture('cap-run-cont', files);
67
+ capture.onFrame({ type: 'agent_start' });
68
+ capture.onFrame({ type: 'tool_execution_start', toolCallId: 'c1', toolName: 'edit', args: { path: 'a.ts' } });
69
+ await capture.flush();
70
+ files.set(at('a.ts'), 'new');
71
+ capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'edit' });
72
+ capture.onFrame({ type: 'agent_end', isTerminal: false });
73
+ capture.onFrame({ type: 'agent_start' });
74
+ capture.onFrame({ type: 'tool_execution_start', toolCallId: 'c2', toolName: 'edit', args: { path: 'a.ts' } });
75
+ await capture.flush();
76
+ files.set(at('a.ts'), 'newer');
77
+ capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c2', toolName: 'edit' });
78
+ await capture.flush();
79
+
80
+ const lines = await records('cap-run-cont');
81
+ expect(lines.filter((line) => line.type === 'run').map((line) => line.phase)).toEqual(['start']);
82
+ const changes = lines.filter((line) => line.type === 'change');
83
+ expect(changes.length).toBe(2);
84
+ if (changes[0]?.type !== 'change' || changes[1]?.type !== 'change') throw new Error('expected changes');
85
+ expect(changes[0].runId).toBe(changes[1].runId);
86
+ });
87
+
88
+ test('a terminal agent_end closes the run and the next start opens a new one', async () => {
89
+ const files = new Map([[at('b.ts'), 'old']]);
90
+ const capture = makeCapture('cap-run-new', files);
91
+ capture.onFrame({ type: 'agent_start' });
92
+ capture.onFrame({ type: 'tool_execution_start', toolCallId: 'c1', toolName: 'edit', args: { path: 'b.ts' } });
93
+ await capture.flush();
94
+ files.set(at('b.ts'), 'new');
95
+ capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'edit' });
96
+ capture.onFrame({ type: 'agent_end', isTerminal: true });
97
+ await capture.flush();
98
+ capture.onFrame({ type: 'agent_start' });
99
+ capture.onFrame({ type: 'tool_execution_start', toolCallId: 'c2', toolName: 'edit', args: { path: 'b.ts' } });
100
+ await capture.flush();
101
+ files.set(at('b.ts'), 'newer');
102
+ capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c2', toolName: 'edit' });
103
+ await capture.flush();
104
+
105
+ const lines = await records('cap-run-new');
106
+ expect(lines.filter((line) => line.type === 'run').map((line) => line.phase)).toEqual(['start', 'end', 'start']);
107
+ const changes = lines.filter((line) => line.type === 'change');
108
+ if (changes[0]?.type !== 'change' || changes[1]?.type !== 'change') throw new Error('expected changes');
109
+ expect(changes[0].runId).not.toBe(changes[1].runId);
110
+ });
111
+
112
+ test('a change after the terminal end keeps the closed run id', async () => {
113
+ const files = new Map([[at('c.ts'), 'old']]);
114
+ const capture = makeCapture('cap-run-late', files);
115
+ capture.onFrame({ type: 'agent_start' });
116
+ capture.onFrame({ type: 'agent_end', isTerminal: true });
117
+ await capture.flush();
118
+ capture.onFrame({
119
+ type: 'subagent_event',
120
+ payload: { type: 'tool_execution_start', toolCallId: 's1', toolName: 'edit', args: { path: 'c.ts' }, agent: 'Child' },
121
+ });
122
+ await capture.flush();
123
+ files.set(at('c.ts'), 'new');
124
+ capture.onFrame({
125
+ type: 'subagent_event',
126
+ payload: { type: 'tool_execution_end', toolCallId: 's1', toolName: 'edit', agent: 'Child' },
127
+ });
128
+ await capture.flush();
129
+
130
+ const lines = await records('cap-run-late');
131
+ const start = lines.find((line) => line.type === 'run' && line.phase === 'start');
132
+ const change = lines.find((line) => line.type === 'change');
133
+ if (start?.type !== 'run' || change?.type !== 'change') throw new Error('expected records');
134
+ expect(change.runId).toBe(start.runId);
135
+ });
136
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Shared fixtures for the capture tests: a fake filesystem and a journal reader.
8
+ *
9
+ * The fake filesystem is a `Map`, so the before/after pair is deterministic:
10
+ * `flush()` after the start frame proves the snapshot ran before the test
11
+ * changes the file.
12
+ *
13
+ * `REPO` and `HOME` are resolved through `node:path` so the fixtures are
14
+ * native on every host: the capture journals absolute paths as the host spells
15
+ * them, and a hardcoded `/repo` would never match on Windows.
16
+ */
17
+
18
+ import path from 'node:path';
19
+ import { ChangeCapture } from '@/server/lib/changes/capture.server';
20
+ import { ChangeJournal } from '@/server/lib/changes/journal.server';
21
+ import { journalPath } from '@/server/lib/changes/paths.server';
22
+ import { parseJournalLine, type JournalRecord } from '@/server/lib/changes/records';
23
+
24
+ export const REPO = path.resolve('/repo');
25
+ export const HOME = path.resolve('/home/u');
26
+
27
+ export function makeCapture(
28
+ sessionId: string,
29
+ files: Map<string, string>,
30
+ extra: Partial<ConstructorParameters<typeof ChangeCapture>[0]> = {},
31
+ ): ChangeCapture {
32
+ const journal = new ChangeJournal(sessionId, REPO);
33
+ return new ChangeCapture({
34
+ journal,
35
+ cwd: REPO,
36
+ home: HOME,
37
+ readFile: async (absolute) => files.get(absolute) ?? null,
38
+ statFile: async (absolute) => (files.has(absolute) ? { mtimeMs: 1, size: files.get(absolute)?.length ?? 0 } : null),
39
+ ...extra,
40
+ });
41
+ }
42
+
43
+ export async function records(sessionId: string): Promise<JournalRecord[]> {
44
+ const text = await Bun.file(journalPath(sessionId)).text();
45
+ return text.split('\n').map(parseJournalLine).filter((line): line is JournalRecord => line !== null);
46
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The shapes the capture layer shares across its files.
8
+ *
9
+ * `PendingCall` is one tool call between its start and end frame: the args, the
10
+ * before snapshot, and (for `bash`) the plan and the git scan. It lives here so
11
+ * the bash half can read it without importing the class that owns it.
12
+ */
13
+
14
+ import type { CommandPlan } from '@/server/lib/changes/classify-command';
15
+ import type { ChangeJournal } from '@/server/lib/changes/journal.server';
16
+ import type { GitScan } from '@/server/lib/changes/scan.server';
17
+
18
+ export interface PendingCall {
19
+ toolCallId: string;
20
+ /** The run that opened this call; captured at start so a late end keeps it. */
21
+ runId?: string;
22
+ runAt?: number;
23
+ tool: string;
24
+ agent: string;
25
+ parent?: string;
26
+ startedAt: number;
27
+ args: Record<string, unknown>;
28
+ before: Map<string, { text: string | null | undefined; mtimeMs?: number }>;
29
+ plan?: CommandPlan;
30
+ command?: string;
31
+ scan?: GitScan | null;
32
+ ready: Promise<void>;
33
+ }
34
+
35
+ export interface TraceNode {
36
+ k?: string;
37
+ argv?: unknown;
38
+ }
39
+
40
+ export interface ShellTrace {
41
+ status?: number;
42
+ units?: { nodes?: TraceNode[] }[];
43
+ }
44
+
45
+ export type ChangeSource = 'tool' | 'trace' | 'scan';
46
+
47
+ export interface ChangeExtra {
48
+ command?: string;
49
+ exit?: number;
50
+ from?: string;
51
+ }
52
+
53
+ export interface CaptureDeps {
54
+ journal: ChangeJournal;
55
+ cwd: string;
56
+ home: string;
57
+ readFile?: (absolute: string) => Promise<string | null>;
58
+ statFile?: (absolute: string) => Promise<{ mtimeMs: number; size: number } | null>;
59
+ /** The git snapshot seam; tests inject a fake, production uses `scan.server`. */
60
+ takeScan?: (cwd: string) => Promise<GitScan | null>;
61
+ readHead?: (root: string, absolute: string) => Promise<string | null>;
62
+ }