@kabmo-labs/kabmo 0.33.0 → 0.35.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 (272) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +785 -624
  3. package/dist/client/static/js/{CsvGrid-fncjbg6j.js → CsvGrid-0amzgtd7.js} +2 -2
  4. package/dist/client/static/js/{DocxView-c9v2vr3r.js → DocxView-bxjhzxe9.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-vxjksm12.js → DrawioView-7s1yqsf4.js} +2 -2
  6. package/dist/client/static/js/{ImageView-a3g5k226.js → ImageView-ycfbn66h.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-hnjfwsjh.js → LayoutWrapper-tw1q1x0g.js} +2 -2
  8. package/dist/client/static/js/Modal-wqjactyd.js +38 -0
  9. package/dist/client/static/js/{PdfView-ksaes53y.js → PdfView-x6dmtwvr.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-30vcr95v.js → SessionsView-t85wq0me.js} +1 -1
  11. package/dist/client/static/js/{SheetView-vc484scg.js → SheetView-n52nvz8s.js} +25 -25
  12. package/dist/client/static/js/{SvgPreview-tph89jet.js → SvgPreview-59z7syme.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-xbar278c.js → abnfDiagram-O67JEVCF-91gnt049.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-bajpnvy7.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-s171n2z6.js → architectureDiagram-NJMV4G6O-5b9qtff2.js} +4 -4
  16. package/dist/client/static/js/{astro-80bs6hvg.js → astro-31cbyw7b.js} +1 -1
  17. package/dist/client/static/js/bash-0h36tk0k.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-gzx6rv9n.js → blockDiagram-BEXU5L5S-6f23fjkn.js} +3 -3
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-7f00skch.js → c4Diagram-YGBWAQC7-76t6d3am.js} +5 -5
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-j79v95nc.js → classDiagram-v2-NBCMYWYE-f9tb19xm.js} +3 -3
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-5fkn7ee5.js → cose-bilkent-JH36ORCC-t6nwrbwj.js} +1 -1
  22. package/dist/client/static/js/cpp-4wp9sy20.js +1 -0
  23. package/dist/client/static/js/css-c9nsbkh6.js +1 -0
  24. package/dist/client/static/js/cynefin-OW5HDTMX-8q9e90m8.js +1 -0
  25. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-cfs1yvrd.js → cynefinDiagram-VND7K2PF-69gc244j.js} +1 -1
  26. package/dist/client/static/js/{dagre-6A5THRUB-44bgc48p.js → dagre-6A5THRUB-54bry3ey.js} +2 -2
  27. package/dist/client/static/js/{diagram-22UHCM2B-a4g4x83k.js → diagram-22UHCM2B-gfkebye6.js} +11 -11
  28. package/dist/client/static/js/{diagram-3UASUU5V-gm4rg5na.js → diagram-3UASUU5V-a1mr319f.js} +1 -1
  29. package/dist/client/static/js/{diagram-ATOU4E4O-a95y41vk.js → diagram-ATOU4E4O-tkyk0qbe.js} +3 -3
  30. package/dist/client/static/js/{diagram-CDSNMT55-t3j93mmc.js → diagram-CDSNMT55-np0hc9m2.js} +4 -4
  31. package/dist/client/static/js/{diagram-MLGK6HIB-c2wdez02.js → diagram-MLGK6HIB-nh06fshp.js} +2 -2
  32. package/dist/client/static/js/{diagram-MPIPVDR6-gya9jhs5.js → diagram-MPIPVDR6-27q2veks.js} +2 -2
  33. package/dist/client/static/js/{dockerfile-a7q6174s.js → dockerfile-4rtt6c0f.js} +1 -1
  34. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jjhkza6t.js → ebnfDiagram-ZINNZB2B-x9p9jqe8.js} +1 -1
  35. package/dist/client/static/js/{elk-276RUBZZ-f7re45mw.js → elk-276RUBZZ-fw7waks3.js} +1 -1
  36. package/dist/client/static/js/{erDiagram-OPXOYQCR-tpm9g5te.js → erDiagram-OPXOYQCR-fdfgzr5d.js} +5 -5
  37. package/dist/client/static/js/{erlang-qt876zrq.js → erlang-trjm07as.js} +1 -1
  38. package/dist/client/static/js/eventmodeling-NTZA5JFV-kn4hsm3p.js +1 -0
  39. package/dist/client/static/js/flowDiagram-KWPJA3E3-ah8cvps1.js +1 -0
  40. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-fz43n12d.js → ganttDiagram-FUAMR5RP-2avbqgdr.js} +3 -3
  41. package/dist/client/static/js/gitGraph-4MIJSDKK-hvavh16n.js +1 -0
  42. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-f61hgbn6.js → gitGraphDiagram-X574FWY7-9jmc0a3g.js} +12 -12
  43. package/dist/client/static/js/graphql-hbkmxsty.js +1 -0
  44. package/dist/client/static/js/{index-8239j2v1.js → index-0v34a7wf.js} +1 -1
  45. package/dist/client/static/js/{index-vtbbfwx0.js → index-1wjp16f0.js} +2 -2
  46. package/dist/client/static/js/index-2mx9ej4k.css +1 -0
  47. package/dist/client/static/js/{index-q2w6s8n7.js → index-2v1nmxwr.js} +6 -6
  48. package/dist/client/static/js/{index-apvkd37e.js → index-3ecsp1rx.js} +3 -3
  49. package/dist/client/static/js/{index-1y9r4frb.js → index-43qpbxjv.js} +2 -2
  50. package/dist/client/static/js/{index-w0fwb80e.js → index-4vybd9e7.js} +1 -1
  51. package/dist/client/static/js/{index-ahv9y42z.js → index-6f6cmcbq.js} +2 -2
  52. package/dist/client/static/js/{index-9fjt5anh.js → index-7ct7qrsp.js} +2 -2
  53. package/dist/client/static/js/{index-ajs3jj6j.js → index-7q02xnvq.js} +1 -1
  54. package/dist/client/static/js/{index-rytaa8ca.js → index-7smwzkvq.js} +2 -2
  55. package/dist/client/static/js/{index-rg8jpbsw.js → index-8acv5b77.js} +2 -2
  56. package/dist/client/static/js/{index-gs6f0qwa.js → index-8f9x7ev8.js} +2 -2
  57. package/dist/client/static/js/{index-7y6rpsrp.js → index-8mwragbj.js} +2 -2
  58. package/dist/client/static/js/{index-gcs49f3p.js → index-8x9ecxb0.js} +1 -1
  59. package/dist/client/static/js/{index-3rcjx70v.js → index-9ketbkh6.js} +1 -1
  60. package/dist/client/static/js/{index-ypx3qmhq.js → index-a628fg4m.js} +2 -2
  61. package/dist/client/static/js/{index-e4p4cd3r.js → index-a8ffattk.js} +2 -2
  62. package/dist/client/static/js/{index-js7t1vb1.js → index-b8s3xraa.js} +6 -6
  63. package/dist/client/static/js/index-btr2w8cq.js +12 -0
  64. package/dist/client/static/js/index-dfzrpy54.js +2 -0
  65. package/dist/client/static/js/{index-pxv2nw9w.js → index-ee2p07eg.js} +1 -1
  66. package/dist/client/static/js/{index-03h3bkcf.js → index-ek2e773p.js} +1 -1
  67. package/dist/client/static/js/{index-1xqs14fr.js → index-fvc0x6nx.js} +3 -3
  68. package/dist/client/static/js/{index-3zc1b0dv.js → index-jc1yagmk.js} +2 -2
  69. package/dist/client/static/js/{index-d495kfm0.js → index-jmxqefe3.js} +1 -1
  70. package/dist/client/static/js/{index-2x5f66t6.js → index-k7q01ye4.js} +2 -2
  71. package/dist/client/static/js/{index-5tgq7aqx.js → index-kdkfyrja.js} +2 -2
  72. package/dist/client/static/js/{index-m73za75e.js → index-mc4nefs7.js} +3 -3
  73. package/dist/client/static/js/{index-trm9x02n.js → index-nb8tp4mj.js} +30 -30
  74. package/dist/client/static/js/{index-zt75xpq0.js → index-ncrenheb.js} +206 -206
  75. package/dist/client/static/js/{index-qsm2z36d.js → index-p16scjt7.js} +2 -2
  76. package/dist/client/static/js/{index-sdtye3jy.js → index-pc6eg8h2.js} +2 -2
  77. package/dist/client/static/js/{index-zvfvqvn9.js → index-pnt0vc59.js} +2 -2
  78. package/dist/client/static/js/{index-pbe4yed4.js → index-py2k8std.js} +2 -2
  79. package/dist/client/static/js/{index-dbe6afkf.js → index-pzbssnsc.js} +2 -2
  80. package/dist/client/static/js/{index-qckv9nte.js → index-qqz6bcdd.js} +2 -2
  81. package/dist/client/static/js/{index-xj9649ac.js → index-ray2czf6.js} +7 -7
  82. package/dist/client/static/js/{index-0tf0arsp.js → index-rbgemjsp.js} +3 -3
  83. package/dist/client/static/js/{index-vw4brsdx.js → index-rkn0bxxt.js} +1 -1
  84. package/dist/client/static/js/{index-76zb4m0n.js → index-rv89xpaf.js} +2 -2
  85. package/dist/client/static/js/index-sbd5e816.js +1 -0
  86. package/dist/client/static/js/{index-eyzeya95.js → index-sdby39w4.js} +5 -5
  87. package/dist/client/static/js/{index-0n5wwe60.js → index-t6c0pd43.js} +2 -2
  88. package/dist/client/static/js/{index-km2zb6wk.js → index-tp7yb3bv.js} +2 -2
  89. package/dist/client/static/js/{index-vw5k8csz.js → index-vnw3hbeg.js} +56 -56
  90. package/dist/client/static/js/{index-354mqqra.js → index-vq6wts05.js} +2 -2
  91. package/dist/client/static/js/{index-14vndmcr.js → index-w5373tg1.js} +2 -2
  92. package/dist/client/static/js/{index-0e40xskg.js → index-w7tpgt46.js} +1 -1
  93. package/dist/client/static/js/{index-djmg1d7h.js → index-whbtxmwh.js} +2 -2
  94. package/dist/client/static/js/{index-2svnq5gg.js → index-xs1m0bpt.js} +1 -1
  95. package/dist/client/static/js/{index-9y3gjdj7.js → index-xxtsm2rb.js} +2 -2
  96. package/dist/client/static/js/{index-hf52f59k.js → index-y3ms153k.js} +2 -2
  97. package/dist/client/static/js/{index-1a0zkj8h.js → index-yq39qbs1.js} +2 -2
  98. package/dist/client/static/js/{index-j0r5hj0j.js → index-zh2jj56s.js} +2 -2
  99. package/dist/client/static/js/info-A6RAGUB7-fmjz8qwg.js +1 -0
  100. package/dist/client/static/js/{infoDiagram-VRGFBTTK-1qj804sn.js → infoDiagram-VRGFBTTK-g2dky5xg.js} +2 -2
  101. package/dist/client/static/js/ini-72yrpvd4.js +1 -0
  102. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-4j4qsnzw.js → ishikawaDiagram-OU5B5YK6-exrcjwp1.js} +6 -6
  103. package/dist/client/static/js/java-ab5tb2ra.js +1 -0
  104. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-j0brnfft.js → journeyDiagram-ZHPQQLJL-pn752qa5.js} +4 -4
  105. package/dist/client/static/js/jsx-25zj9j3k.js +1 -0
  106. package/dist/client/static/js/{julia-4ghmfy3e.js → julia-evn99h2m.js} +1 -1
  107. package/dist/client/static/js/{kanban-definition-PNTS6WVX-qqc22br0.js → kanban-definition-PNTS6WVX-v8nvr373.js} +5 -5
  108. package/dist/client/static/js/lua-j5w0c9wm.js +1 -0
  109. package/dist/client/static/js/markdown-j6hn4377.js +1 -0
  110. package/dist/client/static/js/{mermaid.core-vv3wbe65.js → mermaid.core-egzv89zv.js} +6 -6
  111. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y5b2z8zp.js → mindmap-definition-NLK3R4M7-t9njmv2w.js} +8 -8
  112. package/dist/client/static/js/one-dark-pro-bm3r4js7.js +1 -0
  113. package/dist/client/static/js/one-light-e07dt7sy.js +1 -0
  114. package/dist/client/static/js/packet-AYTQ26CC-cwr6n1cm.js +1 -0
  115. package/dist/client/static/js/{pegDiagram-GJSIUBJH-0be07mqs.js → pegDiagram-GJSIUBJH-zhycy2b7.js} +1 -1
  116. package/dist/client/static/js/{perl-sd00t4b4.js → perl-506fy8m8.js} +1 -1
  117. package/dist/client/static/js/{php-2zfyqa61.js → php-axtsvxck.js} +1 -1
  118. package/dist/client/static/js/pie-WAS4IAKB-h1ebfzgt.js +1 -0
  119. package/dist/client/static/js/{pieDiagram-5QR66LMP-544w86jk.js → pieDiagram-5QR66LMP-sgctvma2.js} +2 -2
  120. package/dist/client/static/js/properties-q8njes42.js +1 -0
  121. package/dist/client/static/js/python-vqxc7181.js +1 -0
  122. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-p09e7z5s.js → quadrantDiagram-O4NWA36T-kzzhdcph.js} +5 -5
  123. package/dist/client/static/js/r-0k5eej8m.js +1 -0
  124. package/dist/client/static/js/radar-RG4KPBEZ-k7p1m364.js +1 -0
  125. package/dist/client/static/js/railroad-74A4TZTK-d08dw3t0.js +1 -0
  126. package/dist/client/static/js/railroad-abnf-HS5TGJTU-txnjycgk.js +1 -0
  127. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-p0r3cv6w.js +1 -0
  128. package/dist/client/static/js/railroad-peg-WCYAUIDC-sryk900a.js +1 -0
  129. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-de830ed2.js → railroadDiagram-XR7U4H2S-nzjffwxm.js} +1 -1
  130. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b47d74p1.js → requirementDiagram-PLB6GJNP-tz4xxn4d.js} +2 -2
  131. package/dist/client/static/js/{ruby-v9qaqhby.js → ruby-qp7zfk2m.js} +1 -1
  132. package/dist/client/static/js/{rust-fkt0qyrs.js → rust-fz913fvw.js} +1 -1
  133. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-6ezc2fpj.js → sankeyDiagram-IPEJSGJF-2wcb0xr6.js} +4 -4
  134. package/dist/client/static/js/{sass-9bxped7y.js → sass-gnk9vsyp.js} +1 -1
  135. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-by5zqj6w.js → sequenceDiagram-PO4LG4MO-vqgebfns.js} +18 -18
  136. package/dist/client/static/js/{sizeCapture-INFHLROL-q85r06j6.js → sizeCapture-INFHLROL-xc314tes.js} +1 -1
  137. package/dist/client/static/js/sql-0e9mnrda.js +1 -0
  138. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-ep5pyexs.js → stateDiagram-v2-GCMORJYK-8bd9b1h8.js} +3 -3
  139. package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-brpgzrtv.js} +1 -1
  140. package/dist/client/static/js/{swimlanes-2SLR337P-95fcqkh8.js → swimlanes-2SLR337P-t6hbdzcw.js} +1 -1
  141. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-c1czc7kv.js +8 -0
  142. package/dist/client/static/js/{timeline-definition-EJHVYXUP-461e615g.js → timeline-definition-EJHVYXUP-2txxasx5.js} +4 -4
  143. package/dist/client/static/js/treeView-Q6P3EWNA-77kj68p1.js +1 -0
  144. package/dist/client/static/js/treemap-WGGIJYW6-rw94xc82.js +1 -0
  145. package/dist/client/static/js/tsx-yd5wt250.js +1 -0
  146. package/dist/client/static/js/typescript-v7z7crfe.js +1 -0
  147. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ftqfnvhg.js → usecaseDiagram-POWQR4AR-3x353hn4.js} +17 -17
  148. package/dist/client/static/js/{vennDiagram-UO4OBE2U-7t96h6ez.js → vennDiagram-UO4OBE2U-cerpss8e.js} +7 -7
  149. package/dist/client/static/js/{vue-j8vb9d7r.js → vue-apnkw9qy.js} +1 -1
  150. package/dist/client/static/js/wardley-WFR3VGLG-18xe4fhz.js +1 -0
  151. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-0de8w8c6.js → wardleyDiagram-VNRHLVJA-cx6jfsbf.js} +4 -4
  152. package/dist/client/static/js/xml-94fhzrfs.js +1 -0
  153. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-dez9phkf.js → xychartDiagram-PMCCYNJV-tgn23xj1.js} +5 -5
  154. package/dist/client/static/js/yaml-s8af9rnw.js +1 -0
  155. package/package.json +4 -1
  156. package/src/client/components/auth/login-screen/index.tsx +1 -0
  157. package/src/client/components/common/MarkdownRenderer.tsx +9 -12
  158. package/src/client/components/settings/Modal.tsx +14 -84
  159. package/src/client/components/settings/Sidebar.tsx +3 -1
  160. package/src/client/components/settings/categories/ConnectSettings.tsx +105 -0
  161. package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +145 -0
  162. package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +159 -0
  163. package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +189 -0
  164. package/src/client/components/settings/categories/connect-settings/QrCode.tsx +56 -0
  165. package/src/client/components/settings/categories/connect-settings/ServerCard.tsx +94 -0
  166. package/src/client/components/settings/categories/connect-settings/TunnelRow.tsx +127 -0
  167. package/src/client/components/settings/categories/connect-settings/qr-image.ts +76 -0
  168. package/src/client/components/settings/category-content.tsx +116 -0
  169. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.test.tsx +120 -0
  170. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +56 -20
  171. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +1 -0
  172. package/src/client/components/workspace/git-panel/init-state.test.ts +5 -0
  173. package/src/client/hooks/chat/composer/speech-to-text.ts +24 -17
  174. package/src/client/hooks/chat/timeline/change-stats.ts +57 -0
  175. package/src/client/hooks/connect/use-connect-status.ts +116 -0
  176. package/src/client/hooks/connect/use-pairing.ts +100 -0
  177. package/src/client/hooks/editor/file-actions.ts +3 -11
  178. package/src/client/hooks/editor/font.test.ts +2 -1
  179. package/src/client/hooks/editor/use-file-transfer.ts +2 -1
  180. package/src/client/hooks/ui/clipboard.ts +26 -0
  181. package/src/client/lib/browser/download.ts +22 -0
  182. package/src/client/tailwind.css +5 -0
  183. package/src/server/index.ts +2 -0
  184. package/src/server/lib/assets/font-css.server.test.ts +19 -0
  185. package/src/server/lib/auth/client-address.test.ts +58 -0
  186. package/src/server/lib/auth/client-address.ts +37 -3
  187. package/src/server/lib/auth/guard.ts +31 -4
  188. package/src/server/lib/auth/rate-limit.test.ts +25 -8
  189. package/src/server/lib/auth/rate-limit.ts +8 -5
  190. package/src/server/lib/connect/cloudflared.lifecycle.test.ts +88 -0
  191. package/src/server/lib/connect/cloudflared.server.test.ts +65 -0
  192. package/src/server/lib/connect/cloudflared.server.ts +206 -0
  193. package/src/server/lib/connect/devices.server.ts +192 -0
  194. package/src/server/lib/connect/identity.server.ts +81 -0
  195. package/src/server/lib/connect/pairing.server.test.ts +56 -0
  196. package/src/server/lib/connect/pairing.server.ts +113 -0
  197. package/src/server/lib/connect/qr.roundtrip.test.ts +106 -0
  198. package/src/server/lib/connect/qr.server.ts +36 -0
  199. package/src/server/lib/connect/run.server.ts +101 -0
  200. package/src/server/lib/connect/status.server.ts +177 -0
  201. package/src/server/lib/connect/tailscale.server.test.ts +117 -0
  202. package/src/server/lib/connect/tailscale.server.ts +172 -0
  203. package/src/server/lib/db/schema.ts +4 -0
  204. package/src/server/lib/omp/session/changes.test.ts +64 -1
  205. package/src/server/lib/omp/session/changes.ts +94 -1
  206. package/src/server/routes/connect/devices.ts +56 -0
  207. package/src/server/routes/connect/index.ts +15 -0
  208. package/src/server/routes/connect/pair-page.ts +177 -0
  209. package/src/server/routes/connect/pair.ts +158 -0
  210. package/src/server/routes/connect/status.ts +19 -0
  211. package/src/server/routes/connect/tunnels.ts +76 -0
  212. package/src/server/routes/health/probe.ts +5 -0
  213. package/src/server/routes/index.ts +2 -0
  214. package/src/server/routes/sessions/changes.test.ts +12 -3
  215. package/src/server/routes/sessions/changes.ts +27 -3
  216. package/src/server/routes/sessions/index.ts +2 -1
  217. package/src/shared/lib/connect/payload.test.ts +144 -0
  218. package/src/shared/lib/connect/payload.ts +229 -0
  219. package/src/shared/lib/connect/tier.test.ts +73 -0
  220. package/src/shared/lib/connect/tier.ts +105 -0
  221. package/src/shared/lib/connect/types.ts +99 -0
  222. package/src/shared/lib/dictation/capture-failure.test.ts +46 -0
  223. package/src/shared/lib/dictation/capture-failure.ts +36 -0
  224. package/src/shared/lib/markdown/fira-code-fonts.css +65 -6
  225. package/src/shared/lib/markdown/marked.ts +7 -4
  226. package/src/shared/lib/markdown/mermaid-actions.test.ts +78 -0
  227. package/src/shared/lib/markdown/mermaid-actions.ts +45 -0
  228. package/src/shared/lib/markdown/mermaid.ts +41 -7
  229. package/src/shared/lib/settings/sections.ts +6 -1
  230. package/src/shared/types/session-changes.ts +6 -0
  231. package/src/shared/types/settings/state.ts +2 -0
  232. package/dist/client/static/js/Modal-qtftcp2t.js +0 -38
  233. package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +0 -1
  234. package/dist/client/static/js/bash-b3rwyg5p.js +0 -1
  235. package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
  236. package/dist/client/static/js/css-6vj0d308.js +0 -1
  237. package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +0 -1
  238. package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +0 -1
  239. package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +0 -1
  240. package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +0 -1
  241. package/dist/client/static/js/graphql-n43pd5fs.js +0 -1
  242. package/dist/client/static/js/index-at6bhjyf.js +0 -1
  243. package/dist/client/static/js/index-bkye8mz4.js +0 -2
  244. package/dist/client/static/js/index-e94a1en0.css +0 -1
  245. package/dist/client/static/js/index-sffjtm5w.js +0 -12
  246. package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +0 -1
  247. package/dist/client/static/js/ini-j5dyq6gm.js +0 -1
  248. package/dist/client/static/js/java-g4dgwbfd.js +0 -1
  249. package/dist/client/static/js/jsx-7t5ecz9s.js +0 -1
  250. package/dist/client/static/js/lua-1g6w30de.js +0 -1
  251. package/dist/client/static/js/markdown-afx21x8c.js +0 -1
  252. package/dist/client/static/js/one-dark-pro-hm3f56n1.js +0 -1
  253. package/dist/client/static/js/one-light-xrz49rct.js +0 -1
  254. package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +0 -1
  255. package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +0 -1
  256. package/dist/client/static/js/properties-thd83wey.js +0 -1
  257. package/dist/client/static/js/python-264ns4xw.js +0 -1
  258. package/dist/client/static/js/r-qw82kkv9.js +0 -1
  259. package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +0 -1
  260. package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +0 -1
  261. package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +0 -1
  262. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +0 -1
  263. package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +0 -1
  264. package/dist/client/static/js/sql-g8wcshpc.js +0 -1
  265. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xs2en5dv.js +0 -8
  266. package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +0 -1
  267. package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +0 -1
  268. package/dist/client/static/js/tsx-nm94hed6.js +0 -1
  269. package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
  270. package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +0 -1
  271. package/dist/client/static/js/xml-dz51p1m3.js +0 -1
  272. package/dist/client/static/js/yaml-2cfkd30t.js +0 -1
@@ -0,0 +1,177 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Everything the Connect page draws, assembled in one read.
8
+ *
9
+ * The page must never show a row it cannot explain. Every address carries either
10
+ * a URL or a sentence saying why it is not usable, and every tunnel carries a
11
+ * phase plus the reason it is not up — because "greyed out with no text" is the
12
+ * failure mode this module exists to prevent.
13
+ *
14
+ * One fact is deliberately NOT here: which route a device is using right now.
15
+ * The server cannot measure a phone's round trip, so that column is reported by
16
+ * the device (`touchDevice`) and is a report, not an inference.
17
+ */
18
+
19
+ import os from 'os';
20
+ import pkg from '@/../package.json';
21
+ import { connectIdentity } from '@/server/lib/connect/identity.server';
22
+ import { listPairedDevices } from '@/server/lib/connect/devices.server';
23
+ import {
24
+ findTailscale,
25
+ machineLabel,
26
+ serveIsUp,
27
+ tailscaleNode,
28
+ } from '@/server/lib/connect/tailscale.server';
29
+ import {
30
+ cloudflaredAlive,
31
+ findCloudflared,
32
+ runningTunnelUrl,
33
+ } from '@/server/lib/connect/cloudflared.server';
34
+ import type {
35
+ ConnectAddress,
36
+ ConnectStatus,
37
+ TunnelState,
38
+ } from '@/shared/lib/connect/types';
39
+
40
+ /** The port this process listens on. */
41
+ export function currentPort(): number {
42
+ return Number(Bun.env.PORT) || 3000;
43
+ }
44
+
45
+ /** Whether the listener is reachable from another machine at all. */
46
+ function boundBeyondLoopback(): boolean {
47
+ const host = (Bun.env.HOST ?? 'localhost').trim();
48
+ return host === '0.0.0.0' || host === '::' || host === '';
49
+ }
50
+
51
+ /** Every non-internal IPv4 address, as origins on this port. */
52
+ function lanOrigins(port: number): string[] {
53
+ const origins: string[] = [];
54
+ try {
55
+ for (const entries of Object.values(os.networkInterfaces())) {
56
+ for (const entry of entries ?? []) {
57
+ if (entry.family !== 'IPv4' || entry.internal) continue;
58
+ origins.push(`http://${entry.address}:${port}`);
59
+ }
60
+ }
61
+ } catch {
62
+ // A host that cannot enumerate interfaces simply has no LAN address.
63
+ }
64
+ return origins;
65
+ }
66
+
67
+ async function tailscaleState(): Promise<{ tunnel: TunnelState; address: ConnectAddress | null }> {
68
+ const presence = findTailscale();
69
+ if (!presence.binary) {
70
+ return {
71
+ tunnel: { provider: 'tailscale', phase: 'failed', url: null, reason: presence.reason },
72
+ address: { kind: 'tailscale', url: '', unavailable: presence.reason },
73
+ };
74
+ }
75
+
76
+ const node = await tailscaleNode(presence.binary);
77
+ if (!node) {
78
+ const reason = 'The Tailscale daemon did not answer. Open Tailscale and sign in.';
79
+ return {
80
+ tunnel: { provider: 'tailscale', phase: 'failed', url: null, reason },
81
+ address: { kind: 'tailscale', url: '', unavailable: reason },
82
+ };
83
+ }
84
+ if (node.backendState !== 'Running') {
85
+ const reason = `Tailscale is ${node.backendState.toLowerCase()}. Sign in to the tailnet first.`;
86
+ return {
87
+ tunnel: { provider: 'tailscale', phase: 'failed', url: null, reason },
88
+ address: { kind: 'tailscale', url: '', unavailable: reason },
89
+ };
90
+ }
91
+ if (!node.url) {
92
+ const reason = 'This node has no MagicDNS name yet, so there is no HTTPS address to share.';
93
+ return {
94
+ tunnel: { provider: 'tailscale', phase: 'failed', url: null, reason },
95
+ address: { kind: 'tailscale', url: '', unavailable: reason },
96
+ };
97
+ }
98
+
99
+ const up = await serveIsUp(presence.binary);
100
+ return {
101
+ tunnel: {
102
+ provider: 'tailscale',
103
+ phase: up ? 'up' : 'off',
104
+ url: up ? node.url : null,
105
+ reason: up ? null : 'Serve is off. Turn it on to reach this server from your tailnet.',
106
+ },
107
+ address: {
108
+ kind: 'tailscale',
109
+ url: node.url,
110
+ unavailable: up ? null : 'Serve is off, so this address does not answer yet.',
111
+ },
112
+ };
113
+ }
114
+
115
+ function cloudflareState(port: number): { tunnel: TunnelState; address: ConnectAddress | null } {
116
+ const presence = findCloudflared();
117
+ if (presence.reason || !presence.binary || !presence.configPath) {
118
+ const reason = presence.reason ?? 'cloudflared is not configured.';
119
+ return {
120
+ tunnel: { provider: 'cloudflare', phase: 'failed', url: null, reason },
121
+ address: { kind: 'cloudflare', url: '', unavailable: reason },
122
+ };
123
+ }
124
+
125
+ const alive = cloudflaredAlive(port);
126
+ const url = runningTunnelUrl(port);
127
+ if (alive && url) {
128
+ return {
129
+ tunnel: { provider: 'cloudflare', phase: 'up', url, reason: null },
130
+ address: { kind: 'cloudflare', url, unavailable: null },
131
+ };
132
+ }
133
+ return {
134
+ tunnel: {
135
+ provider: 'cloudflare',
136
+ phase: 'off',
137
+ url: null,
138
+ reason: 'The tunnel is not running. Cloudflare terminates TLS and can read the traffic.',
139
+ },
140
+ address: {
141
+ kind: 'cloudflare',
142
+ url: '',
143
+ unavailable: 'The tunnel is not running.',
144
+ },
145
+ };
146
+ }
147
+
148
+ /** The whole page's payload. */
149
+ export async function connectStatus(): Promise<ConnectStatus> {
150
+ const port = currentPort();
151
+ const [tailscale, devices] = await Promise.all([tailscaleState(), listPairedDevices()]);
152
+ const cloudflare = cloudflareState(port);
153
+
154
+ const lanReachable = boundBeyondLoopback();
155
+ const lan: ConnectAddress[] = lanOrigins(port).map((url) => ({
156
+ kind: 'lan',
157
+ url,
158
+ unavailable: lanReachable
159
+ ? null
160
+ : 'This server listens on loopback only. Start it with --lan to answer on this address.',
161
+ }));
162
+
163
+ const addresses: ConnectAddress[] = [
164
+ ...(tailscale.address ? [tailscale.address] : []),
165
+ ...lan,
166
+ ...(cloudflare.address ? [cloudflare.address] : []),
167
+ ].filter((address) => address.url !== '' || address.unavailable !== null);
168
+
169
+ return {
170
+ serverId: connectIdentity().serverId,
171
+ label: machineLabel(),
172
+ version: pkg.version,
173
+ addresses,
174
+ tunnels: [tailscale.tunnel, cloudflare.tunnel],
175
+ devices,
176
+ };
177
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The Tailscale CLI, driven through a stand-in.
8
+ *
9
+ * The real daemon cannot be scripted: `serve` needs HTTPS enabled for the tailnet
10
+ * and a signed-in node, so the happy path is unreachable on a machine that has
11
+ * neither. A fake binary that answers the same JSON is what makes the parsing,
12
+ * the URL derivation and the stop path testable at all — and those are the parts
13
+ * that break silently, because a wrong field name reads as "not running" rather
14
+ * than as an error.
15
+ */
16
+
17
+ import { afterEach, describe, expect, test } from 'bun:test';
18
+ import fs from 'fs';
19
+ import os from 'os';
20
+ import path from 'path';
21
+ import { serveIsUp, startServe, stopServe, tailscaleNode } from '@/server/lib/connect/tailscale.server';
22
+
23
+ // The stand-in is a `#!/bin/sh` script, so this suite is POSIX-only: Windows
24
+ // cannot execute it, and every case would then fail on the spawn instead of on
25
+ // the parsing it exists to measure. The Linux gate covers the behaviour.
26
+ const posixOnly = process.platform !== 'win32';
27
+
28
+ const dirs: string[] = [];
29
+
30
+ function fakeTailscale(script: string): string {
31
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-ts-'));
32
+ dirs.push(dir);
33
+ const file = path.join(dir, 'tailscale');
34
+ fs.writeFileSync(file, `#!/bin/sh\n${script}\n`);
35
+ fs.chmodSync(file, 0o755);
36
+ return file;
37
+ }
38
+
39
+ afterEach(() => {
40
+ for (const dir of dirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
41
+ });
42
+
43
+ const RUNNING = `cat <<'JSON'
44
+ {"BackendState":"Running","Self":{"DNSName":"node.tailnet.ts.net.","TailscaleIPs":["100.1.2.3","fd7a::1"]}}
45
+ JSON`;
46
+
47
+ describe('tailscaleNode', () => {
48
+ test.skipIf(!posixOnly)('derives the https origin from the MagicDNS name', async () => {
49
+ const binary = fakeTailscale(RUNNING);
50
+ const node = await tailscaleNode(binary);
51
+ expect(node?.url).toBe('https://node.tailnet.ts.net');
52
+ expect(node?.addresses).toEqual(['100.1.2.3', 'fd7a::1']);
53
+ expect(node?.backendState).toBe('Running');
54
+ });
55
+
56
+ test.skipIf(!posixOnly)('answers null when the daemon does not answer', async () => {
57
+ const binary = fakeTailscale('exit 1');
58
+ expect(await tailscaleNode(binary)).toBeNull();
59
+ });
60
+
61
+ test.skipIf(!posixOnly)('answers null for output that is not JSON', async () => {
62
+ const binary = fakeTailscale('echo "not json"');
63
+ expect(await tailscaleNode(binary)).toBeNull();
64
+ });
65
+
66
+ test.skipIf(!posixOnly)('reports a node that is not signed in', async () => {
67
+ const binary = fakeTailscale(`echo '{"BackendState":"NeedsLogin","Self":{}}'`);
68
+ const node = await tailscaleNode(binary);
69
+ expect(node?.backendState).toBe('NeedsLogin');
70
+ expect(node?.url).toBeNull();
71
+ });
72
+ });
73
+
74
+ describe('serveIsUp', () => {
75
+ test.skipIf(!posixOnly)('reads a TCP share as up', async () => {
76
+ const binary = fakeTailscale(`echo '{"TCP":{"443":{"HTTPS":true}}}'`);
77
+ expect(await serveIsUp(binary)).toBe(true);
78
+ });
79
+
80
+ test.skipIf(!posixOnly)('reads an empty config as down', async () => {
81
+ const binary = fakeTailscale(`echo '{}'`);
82
+ expect(await serveIsUp(binary)).toBe(false);
83
+ });
84
+
85
+ test.skipIf(!posixOnly)('reads a failing command as down', async () => {
86
+ const binary = fakeTailscale('exit 1');
87
+ expect(await serveIsUp(binary)).toBe(false);
88
+ });
89
+ });
90
+
91
+ describe('startServe / stopServe', () => {
92
+ test.skipIf(!posixOnly)('a successful share reports no reason', async () => {
93
+ const binary = fakeTailscale('exit 0');
94
+ expect(await startServe(binary, 3000)).toEqual({ ok: true, reason: null });
95
+ });
96
+
97
+ test.skipIf(!posixOnly)('a refusal carries the CLI sentence', async () => {
98
+ const binary = fakeTailscale('echo "HTTPS is not enabled for this tailnet" >&2; exit 1');
99
+ const outcome = await startServe(binary, 3000);
100
+ expect(outcome.ok).toBe(false);
101
+ expect(outcome.reason).toContain('HTTPS is not enabled');
102
+ });
103
+
104
+ test.skipIf(!posixOnly)('a silent timeout names the likely cause instead of the timeout', async () => {
105
+ // The real CLI blocks when HTTPS is off, and "timed out" alone tells the user
106
+ // nothing they can act on.
107
+ const binary = fakeTailscale('sleep 30');
108
+ const outcome = await startServe(binary, 3000);
109
+ expect(outcome.ok).toBe(false);
110
+ expect(outcome.reason).toContain('HTTPS may be disabled');
111
+ }, 30_000);
112
+
113
+ test.skipIf(!posixOnly)('stopping a share that is not there still succeeds', async () => {
114
+ const binary = fakeTailscale('exit 0');
115
+ expect(await stopServe(binary)).toEqual({ ok: true, reason: null });
116
+ });
117
+ });
@@ -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,
@@ -18,7 +18,7 @@ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
18
18
  import * as fsp from 'node:fs/promises';
19
19
  import * as os from 'node:os';
20
20
  import * as path from 'node:path';
21
- import { readSessionChangeDiff, readSessionChangeIndex } from '@/server/lib/omp/session/changes';
21
+ import { readSessionChangeDiff, readSessionChangeIndex, readSessionChangeList, readSessionChangeStats } from '@/server/lib/omp/session/changes';
22
22
  import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
23
23
 
24
24
  const SESSION_ID = '01a0cc50-fd62-7417-899c-e24ff8c8608c';
@@ -136,3 +136,66 @@ describe('readSessionChangeDiff', () => {
136
136
  expect(await readSessionChangeDiff(SESSION_ID, `${CWD}/src/net.ts`, 9000, 9001)).toBeNull();
137
137
  });
138
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
+ });
@@ -18,8 +18,13 @@
18
18
  *
19
19
  * - {@link readSessionChangeIndex} — every record, with a display path, for
20
20
  * the chat's per-run file list. No blob content, so it stays small.
21
+ * - {@link readSessionChangeList} — that index minus creations whose file is
22
+ * gone (a `bash rm` is never journaled). The route serves this one.
21
23
  * - {@link readSessionChangeDiff} — the net change of one path inside one
22
24
  * run window: the first record's `before` and the last record's `after`.
25
+ * - {@link readSessionChangeStats} — that same net change as `+`/`−` line
26
+ * counts for every path in one window, which the run's file summary shows
27
+ * without opening a diff.
23
28
  *
24
29
  * The journal is append-only and can grow to megabytes, so the parse is cached
25
30
  * by size+mtime (the same rule `plans.ts` follows). A session with no journal
@@ -33,7 +38,12 @@ import { readRawHeaderLine } from '@/server/lib/omp/session/files';
33
38
  import { findSessionFileById } from '@/server/lib/omp/session/locator';
34
39
  import { siblingDirForSession } from '@/server/lib/omp/subagent/history/paths';
35
40
  import { unifiedDiff } from '@/shared/lib/fs/unified-diff';
36
- import type { SessionChangeDiff, SessionChangeRecord } from '@/shared/types/session-changes';
41
+ import { patchSides } from '@/shared/lib/fs/patch-sides';
42
+ import type {
43
+ SessionChangeCounts,
44
+ SessionChangeDiff,
45
+ SessionChangeRecord,
46
+ } from '@/shared/types/session-changes';
37
47
 
38
48
  const JOURNAL_FILE = 'changes.jsonl';
39
49
  const BLOB_DIR = 'blobs';
@@ -169,6 +179,49 @@ export async function readSessionChangeIndex(sessionId: string): Promise<Session
169
179
  }));
170
180
  }
171
181
 
182
+ /** True when the path is still on disk; a stat error other than ENOENT counts
183
+ * as present, so a permission problem never hides a real change. */
184
+ async function pathExists(absolute: string): Promise<boolean> {
185
+ try {
186
+ await stat(absolute);
187
+ return true;
188
+ } catch (error) {
189
+ return (error as NodeJS.ErrnoException).code !== 'ENOENT';
190
+ }
191
+ }
192
+
193
+ /**
194
+ * The index the chat's per-run list reads: {@link readSessionChangeIndex} minus
195
+ * creations whose file is gone.
196
+ *
197
+ * omp journals edit-tool writes only. A delete through `bash` (`rm`, `git
198
+ * clean`, a script) never reaches `changes.jsonl`, so a file the run created
199
+ * and then removed still reads as `added` — measured on a real session: the
200
+ * run wrote `MarkdownRenderer.test.tsx`, `rm`'d it six seconds later, and the
201
+ * list counted 8 files while the commit had 7. A creation whose path is absent
202
+ * now is that case, and its net change is zero.
203
+ *
204
+ * A MODIFIED path is kept even when absent: the run did change it, and the
205
+ * journal diff still holds both sides.
206
+ */
207
+ export async function readSessionChangeList(sessionId: string): Promise<SessionChangeRecord[]> {
208
+ const records = await readSessionChangeIndex(sessionId);
209
+ if (records.length === 0) return records;
210
+
211
+ const firstByPath = new Map<string, SessionChangeRecord>();
212
+ for (const record of records) {
213
+ if (!firstByPath.has(record.path)) firstByPath.set(record.path, record);
214
+ }
215
+ const gone = new Set<string>();
216
+ await Promise.all(
217
+ [...firstByPath].map(async ([absolutePath, first]) => {
218
+ if (first.before !== null) return;
219
+ if (!(await pathExists(absolutePath))) gone.add(absolutePath);
220
+ }),
221
+ );
222
+ return gone.size === 0 ? records : records.filter((record) => !gone.has(record.path));
223
+ }
224
+
172
225
  /**
173
226
  * The net change of `absolutePath` inside `[from, to]`: the first record's
174
227
  * `before` and the last record's `after`. `null` when the path has no record in
@@ -218,3 +271,43 @@ export async function readSessionChangeDiff(
218
271
  unavailable: false,
219
272
  };
220
273
  }
274
+
275
+ /**
276
+ * Net `+`/`−` line counts for every path changed inside `[from, to]`.
277
+ *
278
+ * The net rule is {@link readSessionChangeDiff}'s — first record's `before` to
279
+ * last record's `after` — so the summary's numbers describe the diff the file
280
+ * opens, not the churn of each intermediate write. A path whose blob was not
281
+ * stored is absent rather than counted as zero: a count would be a guess.
282
+ */
283
+ export async function readSessionChangeStats(
284
+ sessionId: string,
285
+ from: number,
286
+ to: number,
287
+ ): Promise<Record<string, SessionChangeCounts>> {
288
+ const journal = await readJournal(sessionId);
289
+ if (!journal) return {};
290
+
291
+ const spans = new Map<string, { first: RawChangeRecord; last: RawChangeRecord }>();
292
+ for (const record of journal.records) {
293
+ if (record.at < from || record.at > to) continue;
294
+ const span = spans.get(record.path);
295
+ if (span) span.last = record;
296
+ else spans.set(record.path, { first: record, last: record });
297
+ }
298
+
299
+ const stats: Record<string, SessionChangeCounts> = {};
300
+ await Promise.all(
301
+ [...spans].map(async ([absolutePath, { first, last }]) => {
302
+ const [before, after] = await Promise.all([
303
+ resolveBlob(journal.dir, first.before),
304
+ resolveBlob(journal.dir, last.after),
305
+ ]);
306
+ if (before === undefined || after === undefined) return;
307
+ const sides = patchSides(unifiedDiff(absolutePath, before ?? '', after ?? ''));
308
+ if (sides.additions === 0 && sides.deletions === 0) return;
309
+ stats[absolutePath] = { added: sides.additions, removed: sides.deletions };
310
+ }),
311
+ );
312
+ return stats;
313
+ }