@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,172 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Tailscale Serve, driven through the CLI the user already has.
8
+ *
9
+ * Serve is the preferred route for a reason that is not speed: it terminates TLS
10
+ * on THIS machine with a certificate the platform already trusts, so every shell
11
+ * accepts it without pinning, and the origin becomes a secure context — which is
12
+ * what brings back `getUserMedia` (dictation), `navigator.clipboard.readText`,
13
+ * `serviceWorker` and `crypto.subtle`. On the same network it is still a direct
14
+ * WireGuard peer connection, so it costs a fraction of a millisecond over the
15
+ * LAN address it replaces.
16
+ *
17
+ * Two facts about the CLI shape everything here:
18
+ *
19
+ * - `tailscale serve` proxies only to `http://127.0.0.1`, so Kabmo does NOT need
20
+ * `--lan` for this route. The listener stays on loopback.
21
+ * - The macOS App Store and Standalone variants ship the CLI inside the app
22
+ * bundle rather than on PATH, so a `Bun.which` miss is not "not installed".
23
+ */
24
+
25
+ import os from 'os';
26
+ import { run, which } from '@/server/lib/connect/run.server';
27
+
28
+ /** Where the macOS app variants keep the CLI when it is not on PATH. */
29
+ const MACOS_APP_CLI = '/Applications/Tailscale.app/Contents/MacOS/Tailscale';
30
+
31
+ /** The HTTPS port Serve listens on. 443 is the default and the one we use. */
32
+ export const TAILSCALE_HTTPS_PORT = 443;
33
+
34
+ export interface TailscalePresence {
35
+ /** Absolute path to the CLI, or null when it cannot be found. */
36
+ binary: string | null;
37
+ /** Why it is absent, in one sentence, when it is. */
38
+ reason: string | null;
39
+ }
40
+
41
+ export interface TailscaleNode {
42
+ /** `https://<node>.<tailnet>.ts.net`, or null when the node has no name yet. */
43
+ url: string | null;
44
+ /** The node's own tailnet addresses, IPv4 first. */
45
+ addresses: string[];
46
+ /** `Running`, `Stopped`, `NeedsLogin`, … as the daemon reports it. */
47
+ backendState: string;
48
+ }
49
+
50
+ /** Locate the CLI, including the macOS app bundle. */
51
+ export function findTailscale(): TailscalePresence {
52
+ const onPath = which('tailscale');
53
+ if (onPath) return { binary: onPath, reason: null };
54
+ if (process.platform === 'darwin') {
55
+ try {
56
+ if (Bun.file(MACOS_APP_CLI).size > 0) return { binary: MACOS_APP_CLI, reason: null };
57
+ } catch {
58
+ // Not installed as an app either.
59
+ }
60
+ }
61
+ return {
62
+ binary: null,
63
+ reason: 'The tailscale command was not found. Install Tailscale, or add its CLI to PATH.',
64
+ };
65
+ }
66
+
67
+ interface StatusJson {
68
+ BackendState?: unknown;
69
+ Self?: {
70
+ DNSName?: unknown;
71
+ TailscaleIPs?: unknown;
72
+ };
73
+ }
74
+
75
+ /**
76
+ * The node's own identity, or null when the daemon cannot answer.
77
+ *
78
+ * `status --json` blocks against a stopped daemon, which is why the spawn has a
79
+ * timeout: a settings page must render "not running" rather than hang.
80
+ */
81
+ export async function tailscaleNode(binary: string): Promise<TailscaleNode | null> {
82
+ const result = await run([binary, 'status', '--json'], { timeoutMs: 4_000 });
83
+ if (!result.ok) return null;
84
+ let parsed: StatusJson;
85
+ try {
86
+ parsed = JSON.parse(result.stdout) as StatusJson;
87
+ } catch {
88
+ return null;
89
+ }
90
+
91
+ const dnsName = typeof parsed.Self?.DNSName === 'string' ? parsed.Self.DNSName.replace(/\.$/, '') : '';
92
+ const addresses = Array.isArray(parsed.Self?.TailscaleIPs)
93
+ ? parsed.Self.TailscaleIPs.filter((value): value is string => typeof value === 'string')
94
+ : [];
95
+ return {
96
+ url: dnsName ? `https://${dnsName}` : null,
97
+ addresses,
98
+ backendState: typeof parsed.BackendState === 'string' ? parsed.BackendState : 'Unknown',
99
+ };
100
+ }
101
+
102
+ /** Whether Serve is currently sharing the HTTPS port. */
103
+ export async function serveIsUp(binary: string): Promise<boolean> {
104
+ const result = await run([binary, 'serve', 'status', '--json'], { timeoutMs: 4_000 });
105
+ if (!result.ok) return false;
106
+ try {
107
+ const parsed = JSON.parse(result.stdout) as Record<string, unknown>;
108
+ // The shape is `{ TCP: { "443": { HTTPS: true } }, Web: {...} }`; a non-empty
109
+ // object at either key means something is being served.
110
+ const tcp = parsed.TCP;
111
+ const web = parsed.Web;
112
+ const hasTcp = typeof tcp === 'object' && tcp !== null && Object.keys(tcp).length > 0;
113
+ const hasWeb = typeof web === 'object' && web !== null && Object.keys(web).length > 0;
114
+ return hasTcp || hasWeb;
115
+ } catch {
116
+ return false;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Share `port` on the tailnet.
122
+ *
123
+ * `--bg` is what makes it survive a reboot and a `tailscale down`/`up`; without
124
+ * it the share dies with the process that started it, which for a server that
125
+ * restarts on update would mean the phone loses its route silently.
126
+ */
127
+ export async function startServe(binary: string, port: number): Promise<{ ok: boolean; reason: string | null }> {
128
+ const result = await run(
129
+ [binary, 'serve', '--bg', '--yes', `--https=${TAILSCALE_HTTPS_PORT}`, `http://127.0.0.1:${port}`],
130
+ { timeoutMs: 15_000 },
131
+ );
132
+ if (result.ok) return { ok: true, reason: null };
133
+ if (result.error?.startsWith('timed out')) {
134
+ return {
135
+ ok: false,
136
+ reason:
137
+ 'Tailscale did not answer within 15 seconds. HTTPS may be disabled for this tailnet — enable it in the Tailscale admin console, then try again.',
138
+ };
139
+ }
140
+ const detail = (result.stderr || result.stdout || result.error || '').trim();
141
+ return {
142
+ ok: false,
143
+ reason: detail
144
+ ? `Tailscale refused: ${detail.split('\n')[0]}`
145
+ : 'Tailscale refused to share this port. HTTPS may be disabled for the tailnet.',
146
+ };
147
+ }
148
+
149
+ /**
150
+ * Stop sharing the HTTPS port.
151
+ *
152
+ * `off` for the port we turned on, never `reset`: reset would also remove every
153
+ * other share the user configured by hand, which is not ours to remove.
154
+ */
155
+ export async function stopServe(binary: string): Promise<{ ok: boolean; reason: string | null }> {
156
+ const result = await run(
157
+ [binary, 'serve', '--yes', `--https=${TAILSCALE_HTTPS_PORT}`, 'off'],
158
+ { timeoutMs: 10_000 },
159
+ );
160
+ if (result.ok) return { ok: true, reason: null };
161
+ const detail = (result.stderr || result.stdout || result.error || '').trim();
162
+ return { ok: false, reason: detail ? detail.split('\n')[0] : 'Tailscale did not stop the share.' };
163
+ }
164
+
165
+ /** The machine's display name, used as the server label in a pairing payload. */
166
+ export function machineLabel(): string {
167
+ try {
168
+ return os.hostname().replace(/\.local$/, '') || 'Kabmo';
169
+ } catch {
170
+ return 'Kabmo';
171
+ }
172
+ }
@@ -27,6 +27,7 @@ import { ensureSessionRelationsSchema } from '@/server/lib/sessions/schema.serve
27
27
  import { ensurePromptHistorySchema } from '@/server/lib/chat/schema.server';
28
28
  import { ensureSessionMcpSchema } from '@/server/lib/mcp/schema.server';
29
29
  import { ensureNotificationSchema } from '@/server/lib/notifications/schema.server';
30
+ import { ensureConnectSchema } from '@/server/lib/connect/devices.server';
30
31
  import { migrateWorkspaceFolderColumns } from '@/shared/lib/workspace/schema-migrations';
31
32
  import { migrateSessionStreamStateColumns } from '@/shared/lib/omp/session/schema-migrations';
32
33
 
@@ -157,6 +158,9 @@ export async function initSchema(db: DbClient): Promise<void> {
157
158
  // The system-notification outbox: written by the run settles, read by a page
158
159
  // over the realtime socket and by the Android watcher over SSE.
159
160
  await ensureNotificationSchema(db);
161
+ // Paired devices and their token hashes: the Connect page's list, and the
162
+ // credential the auth gate verifies on every request from a phone.
163
+ await ensureConnectSchema(db);
160
164
  await db.exec(`
161
165
  CREATE TABLE IF NOT EXISTS files (
162
166
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -212,4 +212,14 @@ export const HARNESS_LAUNCH: Readonly<Partial<Record<HarnessId, HarnessLaunch>>>
212
212
  install: 'curl -fsSL https://x.ai/cli/install.sh | bash',
213
213
  note: 'native ACP (`grok agent stdio`); xAI models need `grok login` once. A custom model as a [model.<name>] table in ~/.grok/config.toml (base_url + api_key) runs WITHOUT an xAI login — measured on 1.0.77. Sessions advertise model + reasoning_effort options',
214
214
  },
215
+ // Hermes Agent ships its ACP adapter in-tree (`acp_adapter/`), but the stock
216
+ // install does not include the `agent-client-protocol` dependency: the `acp`
217
+ // extra has to be synced once, and until then `hermes acp` is not a command.
218
+ // The adapter logs to stderr, so stdout stays reserved for JSON-RPC.
219
+ hermes: {
220
+ id: 'hermes',
221
+ command: ['hermes', 'acp'],
222
+ install: 'curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash # then: cd ~/.hermes/hermes-agent && python -c "import pm; pm.sync_venv([\'acp\'], explicit=True)"',
223
+ note: 'native ACP (`hermes acp`); the `acp` extra must be synced once or the subcommand does not exist. Configure a provider with `hermes model` (or ~/.hermes/config.yaml / .env) before a turn succeeds; models are published as `provider:model`',
224
+ },
215
225
  };
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Reading the agent change journal behind the chat's per-run file list.
8
+ *
9
+ * The journal is a document omp writes, not one Kabmo wrote, so the tests pin
10
+ * the two things a wrong read would break: the display path (a file outside the
11
+ * session cwd must not be shown as `../…`) and the net change of a run (the
12
+ * first record's `before` to the last record's `after`, not one write's pair).
13
+ * The session dir is redirected through `PI_CODING_AGENT_DIR`, the same seam
14
+ * the artifact tests use.
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 { readSessionChangeDiff, readSessionChangeIndex, readSessionChangeList, readSessionChangeStats } from '@/server/lib/omp/session/changes';
22
+ import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
23
+
24
+ const SESSION_ID = '01a0cc50-fd62-7417-899c-e24ff8c8608c';
25
+ const CWD = '/tmp/project';
26
+ let agentDir = '';
27
+ let sessionFile = '';
28
+ let journalDir = '';
29
+
30
+ /** Write a gzip blob under the journal's `blobs/` and return its key. */
31
+ async function blob(key: string, text: string): Promise<string> {
32
+ await fsp.mkdir(path.join(journalDir, 'blobs'), { recursive: true });
33
+ await fsp.writeFile(path.join(journalDir, 'blobs', key), Bun.gzipSync(Buffer.from(text, 'utf8')));
34
+ return key;
35
+ }
36
+
37
+ async function append(record: Record<string, unknown>): Promise<void> {
38
+ await fsp.appendFile(path.join(journalDir, 'changes.jsonl'), `${JSON.stringify(record)}\n`);
39
+ }
40
+
41
+ beforeAll(async () => {
42
+ agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'omp-changes-test-'));
43
+ process.env.PI_CODING_AGENT_DIR = agentDir;
44
+ const cwdDir = path.join(agentDir, 'sessions', '-tmp-project');
45
+ await fsp.mkdir(cwdDir, { recursive: true });
46
+ sessionFile = path.join(cwdDir, `2026-01-01T00-00-00-000Z_${SESSION_ID}.jsonl`);
47
+ await fsp.writeFile(
48
+ sessionFile,
49
+ `${JSON.stringify({ type: 'session', version: 3, id: SESSION_ID, timestamp: '2026-01-01T00:00:00.000Z', cwd: CWD })}\n`,
50
+ );
51
+ journalDir = sessionFile.slice(0, -'.jsonl'.length);
52
+ await fsp.mkdir(journalDir, { recursive: true });
53
+ clearSessionFileCaches();
54
+ });
55
+
56
+ afterAll(async () => {
57
+ delete process.env.PI_CODING_AGENT_DIR;
58
+ clearSessionFileCaches();
59
+ await fsp.rm(agentDir, { recursive: true, force: true });
60
+ });
61
+
62
+ describe('readSessionChangeIndex', () => {
63
+ test('a session with no journal answers an empty list', async () => {
64
+ expect(await readSessionChangeIndex(SESSION_ID)).toEqual([]);
65
+ });
66
+
67
+ test('resolves a display path inside the cwd and keeps an outside path absolute', async () => {
68
+ const inside = await blob('a1', 'one\n');
69
+ const outside = await blob('a2', 'two\n');
70
+ await append({ type: 'change', at: 1000, agent: 'Main', tool: 'edit', path: `${CWD}/src/a.ts`, before: null, after: inside });
71
+ await append({ type: 'change', at: 1001, agent: 'Main', tool: 'edit', path: '/elsewhere/b.ts', before: null, after: outside });
72
+ // A `call` record is not a file change and must not reach the list.
73
+ await append({ type: 'call', agent: 'Main', tool: 'bash', start: 1002, end: 1003, label: 'bun test' });
74
+
75
+ const records = await readSessionChangeIndex(SESSION_ID);
76
+ expect(records.map((record) => record.displayPath)).toEqual(['src/a.ts', '/elsewhere/b.ts']);
77
+ expect(records[0]?.before).toBeNull();
78
+ expect(records[0]?.after).toBe(inside);
79
+ });
80
+
81
+ test('a torn final line is skipped, not fatal', async () => {
82
+ await fsp.appendFile(path.join(journalDir, 'changes.jsonl'), '{"type":"change","at":\n');
83
+ const records = await readSessionChangeIndex(SESSION_ID);
84
+ expect(records.length).toBe(2);
85
+ });
86
+
87
+ test('a Windows-style separator in the journal path is shown with forward slashes', async () => {
88
+ const after = await blob('a3', 'three\n');
89
+ await append({ type: 'change', at: 1004, agent: 'Main', tool: 'edit', path: `${CWD}/src\\win.ts`, before: null, after });
90
+
91
+ const records = await readSessionChangeIndex(SESSION_ID);
92
+ expect(records.at(-1)?.displayPath).toBe('src/win.ts');
93
+ });
94
+ });
95
+
96
+ describe('readSessionChangeDiff', () => {
97
+ test('returns the net change of a run: first before to last after', async () => {
98
+ const before = await blob('b1', 'line one\nline two\n');
99
+ const middle = await blob('b2', 'line one\nline TWO\n');
100
+ const after = await blob('b3', 'line one\nline TWO\nline three\n');
101
+ const file = `${CWD}/src/net.ts`;
102
+ await append({ type: 'change', at: 2000, agent: 'Main', tool: 'edit', path: file, before, after: middle });
103
+ await append({ type: 'change', at: 2001, agent: 'Main', tool: 'edit', path: file, before: middle, after });
104
+
105
+ const diff = await readSessionChangeDiff(SESSION_ID, file, 2000, 2001);
106
+ expect(diff?.status).toBe('modified');
107
+ expect(diff?.oldContent).toBe('line one\nline two\n');
108
+ expect(diff?.newContent).toBe('line one\nline TWO\nline three\n');
109
+ expect(diff?.diff).toContain('+line three');
110
+ expect(diff?.unavailable).toBe(false);
111
+ });
112
+
113
+ test('a created file is added, a deleted file is deleted', async () => {
114
+ const created = await blob('c1', 'new\n');
115
+ const addedPath = `${CWD}/src/added.ts`;
116
+ await append({ type: 'change', at: 3000, agent: 'Main', tool: 'write', path: addedPath, before: null, after: created });
117
+ const added = await readSessionChangeDiff(SESSION_ID, addedPath, 3000, 3000);
118
+ expect(added?.status).toBe('added');
119
+ expect(added?.oldContent).toBe('');
120
+
121
+ const deletedPath = `${CWD}/src/deleted.ts`;
122
+ await append({ type: 'change', at: 3001, agent: 'Main', tool: 'write', path: deletedPath, before: created, after: null });
123
+ const deleted = await readSessionChangeDiff(SESSION_ID, deletedPath, 3001, 3001);
124
+ expect(deleted?.status).toBe('deleted');
125
+ expect(deleted?.newContent).toBe('');
126
+ });
127
+
128
+ test('a blob that was not stored reports unavailable instead of an empty diff', async () => {
129
+ const file = `${CWD}/src/huge.ts`;
130
+ await append({ type: 'change', at: 4000, agent: 'Main', tool: 'write', path: file, before: undefined, after: undefined });
131
+ const diff = await readSessionChangeDiff(SESSION_ID, file, 4000, 4000);
132
+ expect(diff?.unavailable).toBe(true);
133
+ });
134
+
135
+ test('a path with no record in the range answers null', async () => {
136
+ expect(await readSessionChangeDiff(SESSION_ID, `${CWD}/src/net.ts`, 9000, 9001)).toBeNull();
137
+ });
138
+ });
139
+
140
+ describe('readSessionChangeList', () => {
141
+ test('drops a creation whose file is gone — a bash rm never reaches the journal', async () => {
142
+ const created = await blob('l1', 'gone\n');
143
+ const file = path.join(agentDir, 'gone.ts');
144
+ await append({ type: 'change', at: 6000, agent: 'Main', tool: 'write', path: file, before: null, after: created });
145
+
146
+ expect(await readSessionChangeIndex(SESSION_ID)).toContainEqual(
147
+ expect.objectContaining({ path: file }),
148
+ );
149
+ expect((await readSessionChangeList(SESSION_ID)).some((record) => record.path === file)).toBe(false);
150
+ });
151
+
152
+ test('keeps a creation whose file still exists', async () => {
153
+ const created = await blob('l2', 'here\n');
154
+ const file = path.join(agentDir, 'here.ts');
155
+ await fsp.writeFile(file, 'here\n');
156
+ await append({ type: 'change', at: 6001, agent: 'Main', tool: 'write', path: file, before: null, after: created });
157
+
158
+ expect((await readSessionChangeList(SESSION_ID)).some((record) => record.path === file)).toBe(true);
159
+ });
160
+
161
+ test('keeps a modified path even when the file is gone', async () => {
162
+ const before = await blob('l3', 'a\n');
163
+ const after = await blob('l4', 'b\n');
164
+ const file = path.join(agentDir, 'modified-gone.ts');
165
+ await append({ type: 'change', at: 6002, agent: 'Main', tool: 'edit', path: file, before, after });
166
+
167
+ expect((await readSessionChangeList(SESSION_ID)).some((record) => record.path === file)).toBe(true);
168
+ });
169
+ });
170
+
171
+ describe('readSessionChangeStats', () => {
172
+ test('counts the net change of the run, not each write', async () => {
173
+ const before = await blob('s1', 'alpha\nbeta\n');
174
+ const middle = await blob('s2', 'alpha\nBETA\n');
175
+ const after = await blob('s3', 'alpha\nBETA\ngamma\n');
176
+ const file = `${CWD}/src/stats.ts`;
177
+ await append({ type: 'change', at: 5000, agent: 'Main', tool: 'edit', path: file, before, after: middle });
178
+ await append({ type: 'change', at: 5001, agent: 'Main', tool: 'edit', path: file, before: middle, after });
179
+
180
+ expect(await readSessionChangeStats(SESSION_ID, 5000, 5001)).toEqual({
181
+ [file]: { added: 2, removed: 1 },
182
+ });
183
+ });
184
+
185
+ test('a created file counts its lines as additions', async () => {
186
+ const created = await blob('s4', 'one\ntwo\n');
187
+ const file = `${CWD}/src/created-stats.ts`;
188
+ await append({ type: 'change', at: 5100, agent: 'Main', tool: 'write', path: file, before: null, after: created });
189
+
190
+ expect(await readSessionChangeStats(SESSION_ID, 5100, 5100)).toEqual({
191
+ [file]: { added: 2, removed: 0 },
192
+ });
193
+ });
194
+
195
+ test('a path whose blob was not stored is absent, not zero', async () => {
196
+ const file = `${CWD}/src/unstored.ts`;
197
+ await append({ type: 'change', at: 5200, agent: 'Main', tool: 'write', path: file, before: undefined, after: undefined });
198
+
199
+ expect(await readSessionChangeStats(SESSION_ID, 5200, 5200)).toEqual({});
200
+ });
201
+ });