@kabmo-labs/kabmo 0.32.1 → 0.34.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 (334) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +805 -637
  3. package/dist/client/static/js/{CsvGrid-4gx0jevc.js → CsvGrid-vze4m5ag.js} +2 -2
  4. package/dist/client/static/js/{DocxView-0667nr8h.js → DocxView-jbf21gmh.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-522v0d0r.js → DrawioView-b52qybx5.js} +2 -2
  6. package/dist/client/static/js/{ImageView-t8xp60hm.js → ImageView-mdgzj8px.js} +1 -1
  7. package/dist/client/static/js/LayoutWrapper-3c49dvtt.js +2 -0
  8. package/dist/client/static/js/Modal-sqp864vd.js +38 -0
  9. package/dist/client/static/js/{PdfView-3fx172xh.js → PdfView-g06rxqb1.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-n3agmf5t.js → SessionsView-521adxyr.js} +1 -1
  11. package/dist/client/static/js/{SheetView-nmrdb1b8.js → SheetView-h8xmsz7q.js} +22 -22
  12. package/dist/client/static/js/{SvgPreview-0xsc6xam.js → SvgPreview-1j4jvcvz.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-jj31rs62.js → abnfDiagram-O67JEVCF-pasxh4b6.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-fc9kmq1w.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-ay3yr7pf.js → architectureDiagram-NJMV4G6O-ms14g0bm.js} +4 -4
  16. package/dist/client/static/js/{astro-qgx1r159.js → astro-80bs6hvg.js} +1 -1
  17. package/dist/client/static/js/bash-b3rwyg5p.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-4x33e16k.js → blockDiagram-BEXU5L5S-ycn78fcq.js} +4 -4
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-dtb81cgz.js → c4Diagram-YGBWAQC7-vn2gpjfm.js} +5 -5
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-vk5a2n9w.js → classDiagram-v2-NBCMYWYE-fyrm1pr5.js} +5 -5
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-6rbjbe19.js → cose-bilkent-JH36ORCC-ea5nwvgq.js} +1 -1
  22. package/dist/client/static/js/css-6vj0d308.js +1 -0
  23. package/dist/client/static/js/cynefin-OW5HDTMX-a4t8992q.js +1 -0
  24. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-vyjksedr.js → cynefinDiagram-VND7K2PF-j6bsjpre.js} +2 -2
  25. package/dist/client/static/js/{dagre-6A5THRUB-7hey38z5.js → dagre-6A5THRUB-4smdkwv8.js} +2 -2
  26. package/dist/client/static/js/{diagram-22UHCM2B-aes06jde.js → diagram-22UHCM2B-9sm4kqwc.js} +19 -19
  27. package/dist/client/static/js/{diagram-3UASUU5V-3cfkgm3x.js → diagram-3UASUU5V-2h3qxaed.js} +1 -1
  28. package/dist/client/static/js/{diagram-ATOU4E4O-z8mfhwpy.js → diagram-ATOU4E4O-1981bc94.js} +3 -3
  29. package/dist/client/static/js/{diagram-CDSNMT55-t4821ctz.js → diagram-CDSNMT55-3vgsxavc.js} +5 -5
  30. package/dist/client/static/js/{diagram-MLGK6HIB-23yxbfrx.js → diagram-MLGK6HIB-c9gf2r3f.js} +2 -2
  31. package/dist/client/static/js/{diagram-MPIPVDR6-chhtf7v0.js → diagram-MPIPVDR6-gjqeq92d.js} +2 -2
  32. package/dist/client/static/js/{dockerfile-5b87ghm7.js → dockerfile-8v935dkn.js} +1 -1
  33. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-9jejcvfr.js → ebnfDiagram-ZINNZB2B-4vbsgh99.js} +1 -1
  34. package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-vcbg60wv.js} +1 -1
  35. package/dist/client/static/js/{elk-276RUBZZ-xhhtkf58.js → elk-276RUBZZ-nca3t891.js} +1 -1
  36. package/dist/client/static/js/{erDiagram-OPXOYQCR-mt2apjjb.js → erDiagram-OPXOYQCR-5kfkev03.js} +6 -6
  37. package/dist/client/static/js/{erlang-6m6tpt72.js → erlang-qt876zrq.js} +1 -1
  38. package/dist/client/static/js/eventmodeling-NTZA5JFV-18bdrkv5.js +1 -0
  39. package/dist/client/static/js/flowDiagram-KWPJA3E3-fg0yqx0h.js +1 -0
  40. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-8cm7a29w.js → ganttDiagram-FUAMR5RP-mxc73wmq.js} +3 -3
  41. package/dist/client/static/js/gitGraph-4MIJSDKK-8fa6y40p.js +1 -0
  42. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-5s0gbnx2.js → gitGraphDiagram-X574FWY7-7en3ag0e.js} +12 -12
  43. package/dist/client/static/js/graphql-n43pd5fs.js +1 -0
  44. package/dist/client/static/js/html-dbrwss36.js +1 -0
  45. package/dist/client/static/js/{index-ye3sr7db.js → index-0vm41je9.js} +4 -4
  46. package/dist/client/static/js/{index-5y7c62sm.js → index-1b0t1428.js} +5 -5
  47. package/dist/client/static/js/{index-9sd0vjmh.js → index-1ksg88qf.js} +2 -2
  48. package/dist/client/static/js/{index-brj8qwa6.js → index-1y9r4frb.js} +2 -2
  49. package/dist/client/static/js/index-231241f4.js +12 -0
  50. package/dist/client/static/js/index-2mx9ej4k.css +1 -0
  51. package/dist/client/static/js/{index-6q80csr0.js → index-2svnq5gg.js} +1 -1
  52. package/dist/client/static/js/{index-dt7e1328.js → index-354mqqra.js} +2 -2
  53. package/dist/client/static/js/{index-532btjmp.js → index-3zc1b0dv.js} +2 -2
  54. package/dist/client/static/js/{index-h06bcfds.js → index-4g46wbdw.js} +1 -1
  55. package/dist/client/static/js/{index-p7btwjvj.js → index-4qwzxj81.js} +3 -3
  56. package/dist/client/static/js/{index-3vhznzgr.js → index-52rqxgya.js} +1 -1
  57. package/dist/client/static/js/index-6sf2vsp2.js +1 -0
  58. package/dist/client/static/js/{index-xya34x4v.js → index-76zb4m0n.js} +2 -2
  59. package/dist/client/static/js/{index-jz9fpznk.js → index-7a64yjrm.js} +6 -6
  60. package/dist/client/static/js/{index-2xj14800.js → index-7y6rpsrp.js} +2 -2
  61. package/dist/client/static/js/{index-rg8jpbsw.js → index-8acv5b77.js} +2 -2
  62. package/dist/client/static/js/{index-ay34b398.js → index-a0fmsv1d.js} +19 -19
  63. package/dist/client/static/js/{index-2gfc25tq.js → index-ag2rmtas.js} +1 -1
  64. package/dist/client/static/js/{index-sa9cp6km.js → index-ahv9y42z.js} +2 -2
  65. package/dist/client/static/js/{index-g33knza2.js → index-b29afsjh.js} +1 -1
  66. package/dist/client/static/js/{index-629kfbcb.js → index-c3ek61zv.js} +2 -2
  67. package/dist/client/static/js/{index-360d7j0d.js → index-cd65zqba.js} +1 -1
  68. package/dist/client/static/js/{index-4s8ttfxj.js → index-cgzrpvzj.js} +211 -211
  69. package/dist/client/static/js/{index-gbfg0anm.js → index-dbe6afkf.js} +2 -2
  70. package/dist/client/static/js/{index-z4v1xmh1.js → index-ev3yt353.js} +2 -2
  71. package/dist/client/static/js/{index-ehcpzk5b.js → index-eyfcm0cy.js} +1 -1
  72. package/dist/client/static/js/{index-a733k69t.js → index-f7jhhqtk.js} +2 -2
  73. package/dist/client/static/js/{index-hc2jmzpx.js → index-fta1y9pc.js} +65 -65
  74. package/dist/client/static/js/{index-vd0e25p0.js → index-fvmfge3p.js} +1 -1
  75. package/dist/client/static/js/{index-a6k2hqke.js → index-g2dyfze9.js} +1 -1
  76. package/dist/client/static/js/index-h5bn97p6.js +2 -0
  77. package/dist/client/static/js/{index-7fdp9c7m.js → index-hf52f59k.js} +2 -2
  78. package/dist/client/static/js/{index-qkscve6n.js → index-j0r5hj0j.js} +2 -2
  79. package/dist/client/static/js/{index-ejgd8w3s.js → index-j51d5a5m.js} +28 -28
  80. package/dist/client/static/js/{index-kpspnztv.js → index-jsyekbx9.js} +2 -2
  81. package/dist/client/static/js/{index-a0bdavdr.js → index-km2zb6wk.js} +2 -2
  82. package/dist/client/static/js/{index-59jb53v3.js → index-nccwxv0s.js} +2 -2
  83. package/dist/client/static/js/{index-dnp07j57.js → index-p0nz38bm.js} +1 -1
  84. package/dist/client/static/js/{index-c0x6s6f7.js → index-pm6xxwz1.js} +2 -2
  85. package/dist/client/static/js/{index-5x95n3hx.js → index-ptcrwswj.js} +1 -1
  86. package/dist/client/static/js/{index-fdbfzshx.js → index-ptcwae2n.js} +2 -2
  87. package/dist/client/static/js/{index-h7pn9qw6.js → index-qckv9nte.js} +2 -2
  88. package/dist/client/static/js/{index-wzma5n54.js → index-r014brzs.js} +2 -2
  89. package/dist/client/static/js/{index-xj9649ac.js → index-ray2czf6.js} +7 -7
  90. package/dist/client/static/js/{index-qnwqaczk.js → index-rs80cwsv.js} +3 -3
  91. package/dist/client/static/js/{index-pf5sbesf.js → index-rytaa8ca.js} +2 -2
  92. package/dist/client/static/js/{index-c93sp4yh.js → index-rzxcj7cg.js} +1 -1
  93. package/dist/client/static/js/{index-a293pdg7.js → index-s7gkkkyz.js} +2 -2
  94. package/dist/client/static/js/{index-7n68yx6m.js → index-sd66wv26.js} +2 -2
  95. package/dist/client/static/js/{index-bbggh3f8.js → index-vhqe0y82.js} +2 -2
  96. package/dist/client/static/js/{index-dq1kdt03.js → index-vy6termr.js} +1 -1
  97. package/dist/client/static/js/{index-pf7syd7t.js → index-xx6mqpxm.js} +3 -3
  98. package/dist/client/static/js/{index-z5s27s26.js → index-ybm2x4vh.js} +1 -1
  99. package/dist/client/static/js/{index-jppt5mgc.js → index-zvfvqvn9.js} +2 -2
  100. package/dist/client/static/js/info-A6RAGUB7-3hk844f7.js +1 -0
  101. package/dist/client/static/js/{infoDiagram-VRGFBTTK-3w1yz32c.js → infoDiagram-VRGFBTTK-sef80132.js} +2 -2
  102. package/dist/client/static/js/ini-j5dyq6gm.js +1 -0
  103. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-ckt471dy.js → ishikawaDiagram-OU5B5YK6-yhvepp1q.js} +6 -6
  104. package/dist/client/static/js/java-g4dgwbfd.js +1 -0
  105. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kfvn4w7e.js → journeyDiagram-ZHPQQLJL-5w77y95w.js} +5 -5
  106. package/dist/client/static/js/jsx-7t5ecz9s.js +1 -0
  107. package/dist/client/static/js/{julia-0j0gsjvc.js → julia-d4j6wgvf.js} +1 -1
  108. package/dist/client/static/js/{kanban-definition-PNTS6WVX-0q36cm83.js → kanban-definition-PNTS6WVX-02znqtna.js} +6 -6
  109. package/dist/client/static/js/lua-1g6w30de.js +1 -0
  110. package/dist/client/static/js/markdown-afx21x8c.js +1 -0
  111. package/dist/client/static/js/{mermaid.core-b1ssa824.js → mermaid.core-a6e6vck4.js} +6 -6
  112. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-e2ym5en8.js → mindmap-definition-NLK3R4M7-y4n74q9x.js} +8 -8
  113. package/dist/client/static/js/one-dark-pro-vwhfpzr8.js +1 -0
  114. package/dist/client/static/js/one-light-y5t9x6zh.js +1 -0
  115. package/dist/client/static/js/packet-AYTQ26CC-4nj2yy10.js +1 -0
  116. package/dist/client/static/js/{pegDiagram-GJSIUBJH-t8bbdyhe.js → pegDiagram-GJSIUBJH-pr7ehgzb.js} +1 -1
  117. package/dist/client/static/js/{perl-7n7e9ncg.js → perl-srptw5vm.js} +1 -1
  118. package/dist/client/static/js/{php-32vy69vd.js → php-n89g3fk7.js} +1 -1
  119. package/dist/client/static/js/pie-WAS4IAKB-k7rde3f9.js +1 -0
  120. package/dist/client/static/js/{pieDiagram-5QR66LMP-envv4brj.js → pieDiagram-5QR66LMP-39wpsk08.js} +2 -2
  121. package/dist/client/static/js/properties-thd83wey.js +1 -0
  122. package/dist/client/static/js/python-264ns4xw.js +1 -0
  123. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-72rk137a.js → quadrantDiagram-O4NWA36T-esm913km.js} +4 -4
  124. package/dist/client/static/js/r-qw82kkv9.js +1 -0
  125. package/dist/client/static/js/radar-RG4KPBEZ-513dpw4f.js +1 -0
  126. package/dist/client/static/js/railroad-74A4TZTK-9bqnst9c.js +1 -0
  127. package/dist/client/static/js/railroad-abnf-HS5TGJTU-7367d5bv.js +1 -0
  128. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-b806b1mj.js +1 -0
  129. package/dist/client/static/js/railroad-peg-WCYAUIDC-5a67rwf8.js +1 -0
  130. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1ej0f5hr.js → railroadDiagram-XR7U4H2S-wy2mgya6.js} +1 -1
  131. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-rvdaknpd.js → requirementDiagram-PLB6GJNP-6z9xdgbq.js} +4 -4
  132. package/dist/client/static/js/{ruby-5ty7fys7.js → ruby-r81ytgcm.js} +1 -1
  133. package/dist/client/static/js/{rust-2geezrcs.js → rust-frn3szvc.js} +1 -1
  134. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-nxvhtdaw.js → sankeyDiagram-IPEJSGJF-rtmxk3ys.js} +5 -5
  135. package/dist/client/static/js/{sass-mey5150f.js → sass-9bxped7y.js} +1 -1
  136. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-n5cn5qrt.js → sequenceDiagram-PO4LG4MO-awzcrafg.js} +18 -18
  137. package/dist/client/static/js/{sizeCapture-INFHLROL-r074kj7s.js → sizeCapture-INFHLROL-03gy196j.js} +1 -1
  138. package/dist/client/static/js/sql-0e9mnrda.js +1 -0
  139. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-vxghxdb0.js → stateDiagram-v2-GCMORJYK-an8v3q5n.js} +3 -3
  140. package/dist/client/static/js/{svelte-3ewx0hzx.js → svelte-mwtx07d9.js} +1 -1
  141. package/dist/client/static/js/{swimlanes-2SLR337P-qkkv894p.js → swimlanes-2SLR337P-n9yb4wcs.js} +1 -1
  142. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-nx5nfnf0.js +8 -0
  143. package/dist/client/static/js/{timeline-definition-EJHVYXUP-5tbq4ex2.js → timeline-definition-EJHVYXUP-jceb575g.js} +4 -4
  144. package/dist/client/static/js/treeView-Q6P3EWNA-kcy40evb.js +1 -0
  145. package/dist/client/static/js/treemap-WGGIJYW6-fsrvqxf4.js +1 -0
  146. package/dist/client/static/js/tsx-nm94hed6.js +1 -0
  147. package/dist/client/static/js/typescript-0s2t05jj.js +1 -0
  148. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-6p8hf0b7.js → usecaseDiagram-POWQR4AR-888h3100.js} +39 -39
  149. package/dist/client/static/js/vennDiagram-UO4OBE2U-wbfz0rzv.js +34 -0
  150. package/dist/client/static/js/{vue-06rdf4wh.js → vue-c0rtg1wf.js} +1 -1
  151. package/dist/client/static/js/wardley-WFR3VGLG-36dmxww4.js +1 -0
  152. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-km2x4er8.js → wardleyDiagram-VNRHLVJA-rn8c5qf9.js} +4 -4
  153. package/dist/client/static/js/xml-dz51p1m3.js +1 -0
  154. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-kr3sgr4m.js → xychartDiagram-PMCCYNJV-8sn1apt6.js} +5 -5
  155. package/dist/client/static/js/yaml-2cfkd30t.js +1 -0
  156. package/package.json +4 -1
  157. package/src/client/components/auth/login-screen/index.tsx +1 -0
  158. package/src/client/components/common/MarkdownRenderer.tsx +9 -12
  159. package/src/client/components/common/context-usage-button/McpSection.test.tsx +98 -0
  160. package/src/client/components/common/context-usage-button/McpSection.tsx +12 -5
  161. package/src/client/components/common/context-usage-button/SessionStats.tsx +80 -0
  162. package/src/client/components/common/context-usage-button/index.test.tsx +26 -0
  163. package/src/client/components/common/context-usage-button/index.tsx +36 -28
  164. package/src/client/components/common/harness-glyph/brands.ts +8 -0
  165. package/src/client/components/mobile/LayoutWrapper.tsx +12 -3
  166. package/src/client/components/mobile/mobile-right-sidebar/FullDiff.tsx +9 -2
  167. package/src/client/components/settings/Modal.tsx +14 -84
  168. package/src/client/components/settings/Sidebar.tsx +3 -1
  169. package/src/client/components/settings/apply-side-effects.test.ts +11 -0
  170. package/src/client/components/settings/apply-side-effects.ts +7 -0
  171. package/src/client/components/settings/categories/ChatSettings.test.tsx +1 -1
  172. package/src/client/components/settings/categories/ChatSettings.tsx +2 -0
  173. package/src/client/components/settings/categories/ConnectSettings.tsx +105 -0
  174. package/src/client/components/settings/categories/NotificationSettings.tsx +1 -1
  175. package/src/client/components/settings/categories/chat-settings/ChangedFilesSection.tsx +79 -0
  176. package/src/client/components/settings/categories/chat-settings/groups.ts +4 -3
  177. package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +145 -0
  178. package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +160 -0
  179. package/src/client/components/settings/categories/connect-settings/QrCode.tsx +73 -0
  180. package/src/client/components/settings/categories/connect-settings/ServerCard.tsx +94 -0
  181. package/src/client/components/settings/categories/connect-settings/TunnelRow.tsx +127 -0
  182. package/src/client/components/settings/category-content.tsx +116 -0
  183. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.test.tsx +120 -0
  184. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +137 -0
  185. package/src/client/components/workspace/chat-timeline/MessageList.tsx +33 -1
  186. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +22 -1
  187. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +13 -0
  188. package/src/client/components/workspace/chat-timeline/index.tsx +1 -1
  189. package/src/client/components/workspace/diff-panel/Toolbar.tsx +17 -51
  190. package/src/client/components/workspace/diff-panel/index.tsx +23 -4
  191. package/src/client/components/workspace/diff-panel/toolbar-git-actions.tsx +94 -0
  192. package/src/client/components/workspace/editor/Body.tsx +2 -0
  193. package/src/client/data/settings/omp-schema.json +73 -3
  194. package/src/client/hooks/chat/timeline/change-stats.ts +57 -0
  195. package/src/client/hooks/chat/timeline/changed-files-setting.test.ts +31 -0
  196. package/src/client/hooks/chat/timeline/changed-files-setting.ts +60 -0
  197. package/src/client/hooks/chat/timeline/session-changes.ts +51 -0
  198. package/src/client/hooks/connect/use-connect-status.ts +116 -0
  199. package/src/client/hooks/connect/use-pairing.ts +100 -0
  200. package/src/client/hooks/ui/clipboard.ts +26 -0
  201. package/src/client/hooks/ui/notification-events.test.ts +3 -0
  202. package/src/client/hooks/ui/notification-events.ts +3 -1
  203. package/src/client/hooks/ui/notification-sound.ts +13 -6
  204. package/src/client/hooks/ui/ui-sounds.test.ts +15 -0
  205. package/src/client/hooks/workspace/diff-file.ts +11 -4
  206. package/src/client/hooks/workspace/file-tabs.ts +13 -4
  207. package/src/client/hooks/workspace/journal-diff.ts +97 -0
  208. package/src/client/lib/notifications/native-banner-sound.test.ts +93 -0
  209. package/src/client/lib/notifications/native-banner-sound.ts +46 -0
  210. package/src/client/lib/notifications/os.test.ts +14 -5
  211. package/src/client/lib/notifications/os.ts +8 -0
  212. package/src/client/tailwind.css +5 -0
  213. package/src/server/index.ts +2 -0
  214. package/src/server/lib/assets/font-css.server.test.ts +19 -0
  215. package/src/server/lib/auth/client-address.test.ts +58 -0
  216. package/src/server/lib/auth/client-address.ts +37 -3
  217. package/src/server/lib/auth/guard.ts +31 -4
  218. package/src/server/lib/auth/rate-limit.test.ts +25 -8
  219. package/src/server/lib/auth/rate-limit.ts +8 -5
  220. package/src/server/lib/connect/cloudflared.lifecycle.test.ts +88 -0
  221. package/src/server/lib/connect/cloudflared.server.test.ts +65 -0
  222. package/src/server/lib/connect/cloudflared.server.ts +206 -0
  223. package/src/server/lib/connect/devices.server.ts +192 -0
  224. package/src/server/lib/connect/identity.server.ts +81 -0
  225. package/src/server/lib/connect/pairing.server.test.ts +56 -0
  226. package/src/server/lib/connect/pairing.server.ts +113 -0
  227. package/src/server/lib/connect/qr.roundtrip.test.ts +106 -0
  228. package/src/server/lib/connect/qr.server.ts +36 -0
  229. package/src/server/lib/connect/run.server.ts +101 -0
  230. package/src/server/lib/connect/status.server.ts +177 -0
  231. package/src/server/lib/connect/tailscale.server.test.ts +117 -0
  232. package/src/server/lib/connect/tailscale.server.ts +172 -0
  233. package/src/server/lib/db/schema.ts +4 -0
  234. package/src/server/lib/harness/launch-table.ts +10 -0
  235. package/src/server/lib/omp/session/changes.test.ts +201 -0
  236. package/src/server/lib/omp/session/changes.ts +313 -0
  237. package/src/server/lib/omp/session/session-discovery.test.ts +4 -4
  238. package/src/server/lib/omp/session/sidebar-activity.server.test.ts +6 -2
  239. package/src/server/lib/omp/session/subagent-presence-scan.ts +54 -0
  240. package/src/server/lib/omp/session/subagent-presence-store.test.ts +1 -1
  241. package/src/server/lib/omp/session/subagent-presence.test.ts +115 -0
  242. package/src/server/lib/omp/session/subagent-presence.ts +12 -3
  243. package/src/server/lib/omp/session/telemetry/compute.ts +68 -0
  244. package/src/server/lib/omp/session/telemetry.test.ts +81 -0
  245. package/src/server/routes/connect/devices.ts +56 -0
  246. package/src/server/routes/connect/index.ts +15 -0
  247. package/src/server/routes/connect/pair-page.ts +177 -0
  248. package/src/server/routes/connect/pair.ts +158 -0
  249. package/src/server/routes/connect/status.ts +19 -0
  250. package/src/server/routes/connect/tunnels.ts +76 -0
  251. package/src/server/routes/health/probe.ts +5 -0
  252. package/src/server/routes/index.ts +2 -0
  253. package/src/server/routes/sessions/changes.test.ts +99 -0
  254. package/src/server/routes/sessions/changes.ts +79 -0
  255. package/src/server/routes/sessions/index.ts +7 -0
  256. package/src/shared/lib/chat/duration.ts +34 -0
  257. package/src/shared/lib/chat/timeline/changed-files.test.ts +121 -0
  258. package/src/shared/lib/chat/timeline/changed-files.ts +71 -0
  259. package/src/shared/lib/chat/timeline/fork-anchor.test.ts +3 -0
  260. package/src/shared/lib/connect/payload.test.ts +144 -0
  261. package/src/shared/lib/connect/payload.ts +229 -0
  262. package/src/shared/lib/connect/tier.test.ts +73 -0
  263. package/src/shared/lib/connect/tier.ts +105 -0
  264. package/src/shared/lib/connect/types.ts +99 -0
  265. package/src/shared/lib/format/duration.test.ts +31 -0
  266. package/src/shared/lib/format/duration.ts +27 -0
  267. package/src/shared/lib/fs/unified-diff.test.ts +53 -0
  268. package/src/shared/lib/fs/unified-diff.ts +127 -0
  269. package/src/shared/lib/harness/brand-color.ts +3 -0
  270. package/src/shared/lib/harness/catalog.test.ts +13 -0
  271. package/src/shared/lib/harness/catalog.ts +8 -1
  272. package/src/shared/lib/harness/fork.ts +4 -2
  273. package/src/shared/lib/harness/mcp-facts.ts +3 -0
  274. package/src/shared/lib/harness/provider-facts.ts +14 -0
  275. package/src/shared/lib/harness/updates.ts +5 -0
  276. package/src/shared/lib/icons/tint-hues.generated.ts +27 -27
  277. package/src/shared/lib/markdown/fira-code-fonts.css +65 -6
  278. package/src/shared/lib/markdown/marked.ts +7 -4
  279. package/src/shared/lib/markdown/mermaid-actions.test.ts +78 -0
  280. package/src/shared/lib/markdown/mermaid-actions.ts +45 -0
  281. package/src/shared/lib/markdown/mermaid.ts +41 -7
  282. package/src/shared/lib/omp/config/schema.test.ts +4 -2
  283. package/src/shared/lib/settings/defaults.ts +1 -0
  284. package/src/shared/lib/settings/sections.ts +6 -1
  285. package/src/shared/lib/workspace/file-tab-id.ts +9 -0
  286. package/src/shared/types/context.ts +18 -0
  287. package/src/shared/types/fs.ts +21 -0
  288. package/src/shared/types/index.ts +1 -0
  289. package/src/shared/types/omp/session.ts +6 -0
  290. package/src/shared/types/session-changes.ts +64 -0
  291. package/src/shared/types/settings/state.ts +10 -0
  292. package/dist/client/static/js/LayoutWrapper-xjnveecv.js +0 -2
  293. package/dist/client/static/js/Modal-k2jr9hc4.js +0 -38
  294. package/dist/client/static/js/architecture-7GRP2DOG-1y9zvsyt.js +0 -1
  295. package/dist/client/static/js/bash-m0qjsyy0.js +0 -1
  296. package/dist/client/static/js/css-t4ngafan.js +0 -1
  297. package/dist/client/static/js/cynefin-OW5HDTMX-k2188qcq.js +0 -1
  298. package/dist/client/static/js/eventmodeling-NTZA5JFV-pdr0qn0n.js +0 -1
  299. package/dist/client/static/js/flowDiagram-KWPJA3E3-zvz0mxne.js +0 -1
  300. package/dist/client/static/js/gitGraph-4MIJSDKK-wmqf046s.js +0 -1
  301. package/dist/client/static/js/graphql-692h0n2x.js +0 -1
  302. package/dist/client/static/js/html-pv88ny12.js +0 -1
  303. package/dist/client/static/js/index-61tm0v57.js +0 -1
  304. package/dist/client/static/js/index-e94a1en0.css +0 -1
  305. package/dist/client/static/js/index-kg86e3sy.js +0 -12
  306. package/dist/client/static/js/index-nmmxb4va.js +0 -2
  307. package/dist/client/static/js/info-A6RAGUB7-zg3twte6.js +0 -1
  308. package/dist/client/static/js/ini-cg0a5wm3.js +0 -1
  309. package/dist/client/static/js/java-vcck089n.js +0 -1
  310. package/dist/client/static/js/jsx-ht9zyzwa.js +0 -1
  311. package/dist/client/static/js/lua-ke895s2q.js +0 -1
  312. package/dist/client/static/js/markdown-gwmsh53r.js +0 -1
  313. package/dist/client/static/js/one-dark-pro-4geyzhjj.js +0 -1
  314. package/dist/client/static/js/one-light-tqssjm9t.js +0 -1
  315. package/dist/client/static/js/packet-AYTQ26CC-3pav51g0.js +0 -1
  316. package/dist/client/static/js/pie-WAS4IAKB-wqfh7zdk.js +0 -1
  317. package/dist/client/static/js/properties-mzvvbqg5.js +0 -1
  318. package/dist/client/static/js/python-3w64wsyd.js +0 -1
  319. package/dist/client/static/js/r-32re2zwb.js +0 -1
  320. package/dist/client/static/js/radar-RG4KPBEZ-w7qjdr2g.js +0 -1
  321. package/dist/client/static/js/railroad-74A4TZTK-rhr99kkj.js +0 -1
  322. package/dist/client/static/js/railroad-abnf-HS5TGJTU-c4jeea3m.js +0 -1
  323. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-x2ee66ex.js +0 -1
  324. package/dist/client/static/js/railroad-peg-WCYAUIDC-yw8wjfwg.js +0 -1
  325. package/dist/client/static/js/sql-g8wcshpc.js +0 -1
  326. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-y81h9n27.js +0 -8
  327. package/dist/client/static/js/treeView-Q6P3EWNA-ekz05ccs.js +0 -1
  328. package/dist/client/static/js/treemap-WGGIJYW6-aq6qymjr.js +0 -1
  329. package/dist/client/static/js/tsx-0p183w2f.js +0 -1
  330. package/dist/client/static/js/typescript-t9a5jyvv.js +0 -1
  331. package/dist/client/static/js/vennDiagram-UO4OBE2U-7k5jsxf9.js +0 -34
  332. package/dist/client/static/js/wardley-WFR3VGLG-z34tj4y3.js +0 -1
  333. package/dist/client/static/js/xml-81hxjjt4.js +0 -1
  334. package/dist/client/static/js/yaml-yssayv8a.js +0 -1
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `POST /api/connect/tunnels` — start or stop one provider.
8
+ *
9
+ * The response is the whole status payload rather than a boolean: the page has
10
+ * to redraw the address list and the tunnel card together, and a second read
11
+ * would let the two disagree for a frame.
12
+ *
13
+ * A refusal carries the provider's own sentence. "Tailscale refused: HTTPS is
14
+ * not enabled for this tailnet" is actionable; `{ ok: false }` is not.
15
+ */
16
+
17
+ import { json, NO_STORE_HEADERS, type ActionFunctionArgs } from '@/server/lib/remix-compat';
18
+ import { connectStatus, currentPort } from '@/server/lib/connect/status.server';
19
+ import { findTailscale, startServe, stopServe } from '@/server/lib/connect/tailscale.server';
20
+ import {
21
+ findCloudflared,
22
+ readCloudflaredConfig,
23
+ startCloudflared,
24
+ stopCloudflared,
25
+ } from '@/server/lib/connect/cloudflared.server';
26
+
27
+ interface TunnelRequest {
28
+ provider?: unknown;
29
+ action?: unknown;
30
+ }
31
+
32
+ export async function action({ request }: ActionFunctionArgs) {
33
+ if (request.method !== 'POST') {
34
+ return json({ error: 'Method not allowed' }, { status: 405, headers: NO_STORE_HEADERS });
35
+ }
36
+
37
+ const body = (await request.json().catch(() => null)) as TunnelRequest | null;
38
+ const provider = body?.provider;
39
+ const verb = body?.action;
40
+ if ((provider !== 'tailscale' && provider !== 'cloudflare') || (verb !== 'start' && verb !== 'stop')) {
41
+ return json(
42
+ { error: 'Expected { provider: "tailscale" | "cloudflare", action: "start" | "stop" }' },
43
+ { status: 400, headers: NO_STORE_HEADERS },
44
+ );
45
+ }
46
+
47
+ const port = currentPort();
48
+ let failure: string | null = null;
49
+
50
+ if (provider === 'tailscale') {
51
+ const presence = findTailscale();
52
+ if (!presence.binary) {
53
+ failure = presence.reason;
54
+ } else {
55
+ const outcome = verb === 'start' ? await startServe(presence.binary, port) : await stopServe(presence.binary);
56
+ if (!outcome.ok) failure = outcome.reason;
57
+ }
58
+ } else if (verb === 'stop') {
59
+ stopCloudflared(port);
60
+ } else {
61
+ const presence = findCloudflared();
62
+ const config = presence.configPath ? readCloudflaredConfig(presence.configPath) : null;
63
+ if (presence.reason || !presence.binary || !presence.configPath || !config?.hostname) {
64
+ failure = presence.reason ?? 'cloudflared is not configured.';
65
+ } else {
66
+ const outcome = await startCloudflared(presence.binary, presence.configPath, config.hostname, port);
67
+ if (!outcome.ok) failure = outcome.reason;
68
+ }
69
+ }
70
+
71
+ const status = await connectStatus();
72
+ return json(
73
+ failure ? { ok: false, error: failure, status } : { ok: true, status },
74
+ { status: failure ? 400 : 200, headers: NO_STORE_HEADERS },
75
+ );
76
+ }
@@ -8,6 +8,7 @@ import { isTrayEnabledByArgv } from '@/server/lib/lifecycle/argv-flags';
8
8
  import { isTlsEnabledByArgv } from '@/server/lib/lifecycle/tls';
9
9
  import { isMockMode } from '@/server/mock.server';
10
10
  import { pluginPlatformReady } from '@/server/lib/plugins/loader.server';
11
+ import { connectIdentity } from '@/server/lib/connect/identity.server';
11
12
 
12
13
  const STARTED_AT = Date.now();
13
14
  const STARTED_ISO = new Date(STARTED_AT).toISOString();
@@ -46,6 +47,10 @@ export async function loader() {
46
47
  // address, so a LAN-bound instance with no password — reachable by anyone
47
48
  // on the network — is visible from the CLI instead of only from a browser.
48
49
  authEnabled: isAuthEnabled(),
50
+ // Stable identity of this install, derived from a persisted key. A paired
51
+ // device pins it and refuses an address that answers with a different one,
52
+ // which is what stops a reassigned LAN address from receiving its token.
53
+ serverId: connectIdentity().serverId,
49
54
  // Reported so discovery does not have to guess the scheme: `status` and
50
55
  // `findLiveInstance` read it to build the URL they print and probe.
51
56
  tls: isTlsEnabledByArgv(),
@@ -31,6 +31,7 @@ import { harnessBindings } from '@/server/routes/harness';
31
31
  import { healthBindings } from '@/server/routes/health';
32
32
  import { wellKnownBindings } from '@/server/routes/well-known';
33
33
  import { notificationsBindings } from '@/server/routes/notifications';
34
+ import { connectBindings } from '@/server/routes/connect';
34
35
 
35
36
  const allBindings: HandlerBinding[] = [
36
37
  ...authBindings,
@@ -61,6 +62,7 @@ const allBindings: HandlerBinding[] = [
61
62
  ...pluginsBindings,
62
63
  ...healthBindings,
63
64
  ...notificationsBindings,
65
+ ...connectBindings,
64
66
  ...wellKnownBindings,
65
67
  ];
66
68
 
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The two journal routes' guards: a missing or unsafe session id, a diff read
8
+ * without its range, and a path with no record in the range. The data itself is
9
+ * covered by `changes.test.ts`; this file pins the HTTP answers a stale click
10
+ * or a crafted id receives.
11
+ */
12
+
13
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
14
+ import * as fsp from 'node:fs/promises';
15
+ import * as os from 'node:os';
16
+ import * as path from 'node:path';
17
+ import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
18
+ import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
19
+ import { getSessionChangeDiff, getSessionChanges } from '@/server/routes/sessions/changes';
20
+
21
+ const SESSION_ID = '01a0cc50-fd62-7417-899c-e24ff8c8608c';
22
+ let CWD = '';
23
+ let agentDir = '';
24
+ let journalDir = '';
25
+
26
+ function args(sessionId: string | undefined, query = ''): LoaderFunctionArgs {
27
+ return {
28
+ params: sessionId === undefined ? {} : { sessionId },
29
+ request: new Request(`http://localhost/api/sessions/${sessionId ?? ''}/changes${query}`),
30
+ context: {},
31
+ } as unknown as LoaderFunctionArgs;
32
+ }
33
+
34
+ beforeAll(async () => {
35
+ agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'omp-changes-route-'));
36
+ process.env.PI_CODING_AGENT_DIR = agentDir;
37
+ CWD = path.join(agentDir, 'project');
38
+ await fsp.mkdir(CWD, { recursive: true });
39
+ // The list drops a creation whose file is gone, so the kept one must exist.
40
+ await fsp.writeFile(path.join(CWD, 'a.ts'), 'one\n');
41
+ const cwdDir = path.join(agentDir, 'sessions', '-tmp-project');
42
+ await fsp.mkdir(cwdDir, { recursive: true });
43
+ const sessionFile = path.join(cwdDir, `2026-01-01T00-00-00-000Z_${SESSION_ID}.jsonl`);
44
+ await fsp.writeFile(
45
+ sessionFile,
46
+ `${JSON.stringify({ type: 'session', version: 3, id: SESSION_ID, timestamp: '2026-01-01T00:00:00.000Z', cwd: CWD })}\n`,
47
+ );
48
+ journalDir = sessionFile.slice(0, -'.jsonl'.length);
49
+ await fsp.mkdir(path.join(journalDir, 'blobs'), { recursive: true });
50
+ const after = 'a1';
51
+ await fsp.writeFile(path.join(journalDir, 'blobs', after), Bun.gzipSync(Buffer.from('one\n', 'utf8')));
52
+ await fsp.writeFile(
53
+ path.join(journalDir, 'changes.jsonl'),
54
+ [
55
+ JSON.stringify({ type: 'change', at: 1000, agent: 'Main', tool: 'write', path: `${CWD}/a.ts`, before: null, after }),
56
+ // Created then `rm`'d: the journal has no delete record, so the list must
57
+ // drop it by checking the path.
58
+ JSON.stringify({ type: 'change', at: 1001, agent: 'Main', tool: 'write', path: `${CWD}/gone.ts`, before: null, after }),
59
+ ].join('\n') + '\n',
60
+ );
61
+ clearSessionFileCaches();
62
+ });
63
+
64
+ afterAll(async () => {
65
+ delete process.env.PI_CODING_AGENT_DIR;
66
+ clearSessionFileCaches();
67
+ await fsp.rm(agentDir, { recursive: true, force: true });
68
+ });
69
+
70
+ describe('getSessionChanges', () => {
71
+ test('answers the records for a real session, minus a creation whose file is gone', async () => {
72
+ const response = (await getSessionChanges(args(SESSION_ID))) as Response;
73
+ expect(response.status).toBe(200);
74
+ const body = (await response.json()) as { records: Array<{ displayPath: string }> };
75
+ expect(body.records.map((record) => record.displayPath)).toEqual(['a.ts']);
76
+ });
77
+
78
+ test('a missing id is a 400, an unsafe id a 404', async () => {
79
+ expect(((await getSessionChanges(args(undefined))) as Response).status).toBe(400);
80
+ expect(((await getSessionChanges(args('../escape'))) as Response).status).toBe(404);
81
+ });
82
+ });
83
+
84
+ describe('getSessionChangeDiff', () => {
85
+ test('answers the net change for a path in range', async () => {
86
+ const query = `?path=${encodeURIComponent(`${CWD}/a.ts`)}&from=1000&to=1000`;
87
+ const response = (await getSessionChangeDiff(args(SESSION_ID, query))) as Response;
88
+ expect(response.status).toBe(200);
89
+ const body = (await response.json()) as { status: string; newContent: string };
90
+ expect(body.status).toBe('added');
91
+ expect(body.newContent).toBe('one\n');
92
+ });
93
+
94
+ test('a missing range is a 400, an unknown path a 404', async () => {
95
+ expect(((await getSessionChangeDiff(args(SESSION_ID, '?path=x'))) as Response).status).toBe(400);
96
+ const query = `?path=${encodeURIComponent(`${CWD}/nope.ts`)}&from=1&to=2`;
97
+ expect(((await getSessionChangeDiff(args(SESSION_ID, query))) as Response).status).toBe(404);
98
+ });
99
+ });
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The chat's per-run file list, read from the session's agent change journal.
8
+ *
9
+ * GET /api/sessions/:sessionId/changes
10
+ * Every `change` record, oldest first, with a display path. No blob
11
+ * content: the client buckets records into runs and only asks for a diff
12
+ * when a file is clicked. A creation whose file is gone is dropped — a
13
+ * `bash rm` never reaches the journal, so the run's list would otherwise
14
+ * count a file that no longer exists.
15
+ *
16
+ * GET /api/sessions/:sessionId/changes/diff?path=<abs>&from=<ms>&to=<ms>
17
+ * The net change of one path inside one run window: the first record's
18
+ * `before` and the last record's `after`, plus a unified patch.
19
+ *
20
+ * GET /api/sessions/:sessionId/changes/stats?from=<ms>&to=<ms>
21
+ * The same net change as `+`/`−` line counts for every path in the window,
22
+ * so the run's file summary can print the totals without opening a diff.
23
+ *
24
+ * A session with no journal (older omp, or no artifacts directory) answers an
25
+ * empty list — a normal state, not an error. The diff read answers 404 when the
26
+ * path has no record in the range, so a stale click reports the real problem.
27
+ */
28
+
29
+ import { json } from '@/server/lib/remix-compat';
30
+ import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
31
+ import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
32
+ import { readSessionChangeDiff, readSessionChangeList, readSessionChangeStats } from '@/server/lib/omp/session/changes';
33
+
34
+ /** GET /api/sessions/:sessionId/changes */
35
+ export async function getSessionChanges({ params }: LoaderFunctionArgs) {
36
+ const sessionId = params.sessionId;
37
+ if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
38
+ if (!isSinglePathSegment(sessionId)) return json({ error: 'Session not found' }, { status: 404 });
39
+ return json({ sessionId, records: await readSessionChangeList(sessionId) });
40
+ }
41
+
42
+ /** GET /api/sessions/:sessionId/changes/diff */
43
+ export async function getSessionChangeDiff({ params, request }: LoaderFunctionArgs) {
44
+ const sessionId = params.sessionId;
45
+ if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
46
+ if (!isSinglePathSegment(sessionId)) return json({ error: 'Session not found' }, { status: 404 });
47
+
48
+ const url = new URL(request.url);
49
+ const file = url.searchParams.get('path');
50
+ const fromRaw = url.searchParams.get('from');
51
+ const toRaw = url.searchParams.get('to');
52
+ const from = fromRaw === null ? Number.NaN : Number(fromRaw);
53
+ const to = toRaw === null ? Number.NaN : Number(toRaw);
54
+ if (!file || !Number.isFinite(from) || !Number.isFinite(to)) {
55
+ return json({ error: 'path, from and to are required' }, { status: 400 });
56
+ }
57
+
58
+ const diff = await readSessionChangeDiff(sessionId, file, from, to);
59
+ if (!diff) return json({ error: 'No change for that path in the range' }, { status: 404 });
60
+ return json({ success: true, ...diff });
61
+ }
62
+
63
+ /** GET /api/sessions/:sessionId/changes/stats */
64
+ export async function getSessionChangeStats({ params, request }: LoaderFunctionArgs) {
65
+ const sessionId = params.sessionId;
66
+ if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
67
+ if (!isSinglePathSegment(sessionId)) return json({ error: 'Session not found' }, { status: 404 });
68
+
69
+ const url = new URL(request.url);
70
+ const fromRaw = url.searchParams.get('from');
71
+ const toRaw = url.searchParams.get('to');
72
+ const from = fromRaw === null ? Number.NaN : Number(fromRaw);
73
+ const to = toRaw === null ? Number.NaN : Number(toRaw);
74
+ if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) {
75
+ return json({ error: 'from and to are required' }, { status: 400 });
76
+ }
77
+
78
+ return json({ sessionId, files: await readSessionChangeStats(sessionId, from, to) });
79
+ }
@@ -21,6 +21,7 @@ import { getSessionRelations, updateSessionParent } from '@/server/routes/sessio
21
21
  import { forkSessionRoute } from '@/server/routes/sessions/fork';
22
22
  import { getSessionAnswer } from '@/server/routes/sessions/answer';
23
23
  import { getSessionMcp, probeSessionMcp, setSessionMcp } from '@/server/routes/sessions/mcp';
24
+ import { getSessionChangeDiff, getSessionChanges, getSessionChangeStats } from '@/server/routes/sessions/changes';
24
25
 
25
26
  export const sessionsBindings: HandlerBinding[] = [
26
27
  ...bindingsFor(sessionsList, '/api/sessions/list'),
@@ -42,6 +43,12 @@ export const sessionsBindings: HandlerBinding[] = [
42
43
  { method: 'POST', path: '/api/sessions/:sessionId/parent', handler: updateSessionParent },
43
44
  { method: 'POST', path: '/api/sessions/:sessionId/fork', handler: forkSessionRoute },
44
45
  { method: 'GET', path: '/api/sessions/:sessionId/answer', handler: getSessionAnswer },
46
+ // The agent's own change journal: the per-run file list and one file's net
47
+ // diff. Static suffixes under the same `:sessionId` position, so the
48
+ // parameter name must stay `sessionId`.
49
+ { method: 'GET', path: '/api/sessions/:sessionId/changes', handler: getSessionChanges },
50
+ { method: 'GET', path: '/api/sessions/:sessionId/changes/diff', handler: getSessionChangeDiff },
51
+ { method: 'GET', path: '/api/sessions/:sessionId/changes/stats', handler: getSessionChangeStats },
45
52
  // The MCP list this session has, and the per-session switch. A static suffix
46
53
  // under the same `:sessionId` position, so the parameter name must stay
47
54
  // `sessionId` (Elysia requires one name per position).
@@ -80,3 +80,37 @@ export function responseRunDurationMs(
80
80
  if (start === null || end <= start) return null;
81
81
  return end - start;
82
82
  }
83
+
84
+ /**
85
+ * Wall-clock window of one run: the opening row's start to the owner row's end.
86
+ *
87
+ * The change journal records epoch-ms write times and nothing that names a
88
+ * message, so this window is what buckets a write into the run that made it.
89
+ * `null` when either end is unmeasurable — a caller then shows no file list
90
+ * rather than guessing.
91
+ */
92
+ export function runWindowMs(
93
+ messages: TimedMessage[],
94
+ runStartIndex: number,
95
+ ownerIndex: number,
96
+ ): { start: number; end: number } | null {
97
+ // A session file can start mid-run: the first run then has no user row
98
+ // (`runStartIndex` is -1), and falling back to the OWNER row's start would
99
+ // begin the window at the last assistant message — after every write the run
100
+ // made. Walk forward from the first row instead.
101
+ const start = runStartIndex >= 0
102
+ ? (msgStartMs(messages[runStartIndex]) ?? msgStartMs(messages[ownerIndex]))
103
+ : firstStartMs(messages, ownerIndex);
104
+ const end = msgEndMs(messages[ownerIndex]);
105
+ if (start === null || end === null || end < start) return null;
106
+ return { start, end };
107
+ }
108
+
109
+ /** First measurable start at or before `lastIndex`, scanning from the top. */
110
+ function firstStartMs(messages: TimedMessage[], lastIndex: number): number | null {
111
+ for (let index = 0; index <= lastIndex; index++) {
112
+ const start = msgStartMs(messages[index]);
113
+ if (start !== null) return start;
114
+ }
115
+ return null;
116
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Bucketing the change journal into runs. The journal has no message id, so the
8
+ * run window is the whole contract: a write one millisecond outside it belongs
9
+ * to another run, and a file written twice must show the NET change, not the
10
+ * last write's pair.
11
+ */
12
+
13
+ import { describe, expect, test } from 'bun:test';
14
+ import { bucketChangesByRun } from '@/shared/lib/chat/timeline/changed-files';
15
+ import type { RunFooterSlot } from '@/shared/lib/chat/timeline/run-footer';
16
+ import type { ChatMessageData, SessionChangeRecord } from '@/shared/types';
17
+
18
+ function message(overrides: Partial<ChatMessageData>): ChatMessageData {
19
+ return { id: 'm', role: 'ai', content: '', ...overrides };
20
+ }
21
+
22
+ function footer(ownerIndex: number, runStartIndex: number): RunFooterSlot {
23
+ return {
24
+ msg: message({ id: `owner-${ownerIndex}` }),
25
+ ownerIndex,
26
+ durationMs: null,
27
+ runStartIndex,
28
+ runUserId: `user-${runStartIndex}`,
29
+ answerText: '',
30
+ };
31
+ }
32
+
33
+ function record(overrides: Partial<SessionChangeRecord>): SessionChangeRecord {
34
+ return {
35
+ at: 0,
36
+ agent: 'Main',
37
+ tool: 'edit',
38
+ path: '/repo/a.ts',
39
+ displayPath: 'a.ts',
40
+ before: 'b1',
41
+ after: 'b2',
42
+ ...overrides,
43
+ };
44
+ }
45
+
46
+ describe('bucketChangesByRun', () => {
47
+ const messages: ChatMessageData[] = [
48
+ message({ id: 'u1', role: 'user', startedAt: 1000 }),
49
+ message({ id: 'a1', role: 'ai', startedAt: 1100, completedAt: 2000 }),
50
+ message({ id: 'u2', role: 'user', startedAt: 3000 }),
51
+ message({ id: 'a2', role: 'ai', startedAt: 3100, completedAt: 4000 }),
52
+ ];
53
+ const footers = [null, footer(1, 0), null, footer(3, 2)];
54
+
55
+ test('a write belongs to the run whose window contains it', () => {
56
+ const buckets = bucketChangesByRun(messages, footers, [
57
+ record({ at: 1500, path: '/repo/a.ts', displayPath: 'a.ts' }),
58
+ record({ at: 3500, path: '/repo/b.ts', displayPath: 'b.ts' }),
59
+ ]);
60
+ expect(buckets.get(1)?.map((file) => file.displayPath)).toEqual(['a.ts']);
61
+ expect(buckets.get(3)?.map((file) => file.displayPath)).toEqual(['b.ts']);
62
+ });
63
+
64
+ test('a write outside every window is dropped', () => {
65
+ const buckets = bucketChangesByRun(messages, footers, [record({ at: 2500 })]);
66
+ expect(buckets.size).toBe(0);
67
+ });
68
+
69
+ test('a file written twice shows the net change', () => {
70
+ const buckets = bucketChangesByRun(messages, footers, [
71
+ record({ at: 1200, before: 'b1', after: 'b2' }),
72
+ record({ at: 1300, before: 'b2', after: 'b3' }),
73
+ ]);
74
+ expect(buckets.get(1)).toEqual([
75
+ { path: '/repo/a.ts', displayPath: 'a.ts', status: 'modified', agent: 'Main' },
76
+ ]);
77
+ });
78
+
79
+ test('created and deleted in one run is not a change', () => {
80
+ const buckets = bucketChangesByRun(messages, footers, [
81
+ record({ at: 1200, before: null, after: 'b2' }),
82
+ record({ at: 1300, before: 'b2', after: null }),
83
+ ]);
84
+ expect(buckets.size).toBe(0);
85
+ });
86
+
87
+ test('written back to the same blob is not a change', () => {
88
+ const buckets = bucketChangesByRun(messages, footers, [
89
+ record({ at: 1200, before: 'b1', after: 'b2' }),
90
+ record({ at: 1300, before: 'b2', after: 'b1' }),
91
+ ]);
92
+ expect(buckets.size).toBe(0);
93
+ });
94
+
95
+ test('added and deleted statuses come from the first before and last after', () => {
96
+ const buckets = bucketChangesByRun(messages, footers, [
97
+ record({ at: 1200, path: '/repo/new.ts', displayPath: 'new.ts', before: null, after: 'b2' }),
98
+ record({ at: 1300, path: '/repo/gone.ts', displayPath: 'gone.ts', before: 'b1', after: null }),
99
+ ]);
100
+ expect(buckets.get(1)?.map((file) => file.status)).toEqual(['deleted', 'added']);
101
+ });
102
+
103
+ test('a subagent write keeps its agent id', () => {
104
+ const buckets = bucketChangesByRun(messages, footers, [
105
+ record({ at: 1200, agent: 'AuthLoader' }),
106
+ ]);
107
+ expect(buckets.get(1)?.[0]?.agent).toBe('AuthLoader');
108
+ });
109
+
110
+ test('a session that starts mid-run uses the first row as the window start', () => {
111
+ // The first run has no user row (`runStartIndex` is -1). Falling back to
112
+ // the OWNER row's start would begin the window at the last assistant
113
+ // message, after every write the run made.
114
+ const midRun: ChatMessageData[] = [
115
+ message({ id: 'a0', role: 'ai', startedAt: 1000, completedAt: 1200 }),
116
+ message({ id: 'a1', role: 'ai', startedAt: 1300, completedAt: 2000 }),
117
+ ];
118
+ const buckets = bucketChangesByRun(midRun, [null, footer(1, -1)], [record({ at: 1500 })]);
119
+ expect(buckets.get(1)?.length).toBe(1);
120
+ });
121
+ });
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Bucket the agent change journal into chat runs.
8
+ *
9
+ * The journal records epoch-ms write times and nothing that names a message, so
10
+ * a write belongs to the run whose wall-clock window contains it. A run's
11
+ * window is its opening row's start to its owner row's end (`runWindowMs`).
12
+ *
13
+ * One file can be written several times in a run; the list shows the NET change
14
+ * — the first record's `before` to the last record's `after` — because that is
15
+ * what the run did to the file. A file created and deleted in the same run, or
16
+ * written back to the same blob, is not a change and is dropped.
17
+ */
18
+
19
+ import type { ChangedFile, ChatMessageData, SessionChangeRecord } from '@/shared/types';
20
+ import type { RunFooterSlot } from '@/shared/lib/chat/timeline/run-footer';
21
+ import { runWindowMs } from '@/shared/lib/chat/duration';
22
+
23
+ /** One file's first and last write inside a run. */
24
+ interface PathSpan {
25
+ first: SessionChangeRecord;
26
+ last: SessionChangeRecord;
27
+ }
28
+
29
+ /**
30
+ * `ownerIndex → files` for every run that changed something. Runs with no
31
+ * journal records are absent, so a caller renders nothing for them.
32
+ */
33
+ export function bucketChangesByRun(
34
+ messages: ChatMessageData[],
35
+ footers: (RunFooterSlot | null)[],
36
+ records: readonly SessionChangeRecord[],
37
+ ): Map<number, ChangedFile[]> {
38
+ const byOwner = new Map<number, ChangedFile[]>();
39
+ if (records.length === 0) return byOwner;
40
+ const sorted = [...records].sort((a, b) => a.at - b.at);
41
+
42
+ for (const slot of footers) {
43
+ if (!slot) continue;
44
+ const window = runWindowMs(messages, slot.runStartIndex, slot.ownerIndex);
45
+ if (!window) continue;
46
+ const inWindow = sorted.filter((record) => record.at >= window.start && record.at <= window.end);
47
+ if (inWindow.length === 0) continue;
48
+
49
+ const byPath = new Map<string, PathSpan>();
50
+ for (const record of inWindow) {
51
+ const span = byPath.get(record.path);
52
+ if (span) span.last = record;
53
+ else byPath.set(record.path, { first: record, last: record });
54
+ }
55
+
56
+ const files: ChangedFile[] = [];
57
+ for (const [path, { first, last }] of byPath) {
58
+ // Created and deleted in the same run: no net change.
59
+ if (first.before === null && last.after === null) continue;
60
+ // Written back to the same content: no net change. Only a real blob key
61
+ // can prove that; `undefined` means "not stored", not "unchanged".
62
+ if (typeof first.before === 'string' && first.before === last.after) continue;
63
+ const status = first.before === null ? 'added' : last.after === null ? 'deleted' : 'modified';
64
+ files.push({ path, displayPath: last.displayPath, status, agent: last.agent });
65
+ }
66
+ if (files.length === 0) continue;
67
+ files.sort((a, b) => a.displayPath.localeCompare(b.displayPath));
68
+ byOwner.set(slot.ownerIndex, files);
69
+ }
70
+ return byOwner;
71
+ }
@@ -26,6 +26,9 @@ describe('forkCapability', () => {
26
26
  expect(forkCapability('opencode')).toBe('tip');
27
27
  expect(forkCapability('minimax')).toBe('tip');
28
28
  expect(forkCapability('zcode')).toBe('tip');
29
+ // Hermes advertises `SessionForkCapabilities()` and its `fork_session` takes
30
+ // only cwd + session id, so the fork copies the whole conversation.
31
+ expect(forkCapability('hermes')).toBe('tip');
29
32
  });
30
33
 
31
34
  test('a harness with no session/fork is none', () => {