@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
@@ -1,11 +1,20 @@
1
1
  import { formatNewSessionTitle } from '@/shared/lib/omp/session/default-title';
2
2
  import { contentProfile } from '@/shared/lib/omp/session/telemetry-blocks';
3
+ import { toEpochMs } from '@/shared/lib/omp/session/timestamps';
4
+ import { isRecord } from '@/shared/lib/util/guards';
3
5
  import type { RawMessageItem, SessionContextTelemetry } from '@/shared/types/context';
4
6
  import type { OmpMessageEntry, OmpUsage } from '@/shared/types/omp/session';
5
7
  import { CONTEXT_LIMIT, buildInfo, contextAnchorTokens, emptyTelemetry, formatCost, formatTs, textOf, tokensOf } from '@/server/lib/omp/session/telemetry/format';
6
8
  import { loadModelsWithCache } from '@/server/lib/models/registry.server';
7
9
  import { scanSessionEntries } from '@/server/lib/omp/session/telemetry/scan';
8
10
 
11
+ /**
12
+ * Below this a request's tokens/second is noise: a cached or instant response
13
+ * divides by almost nothing and reports an absurd rate. Same floor omp's own
14
+ * usage row applies (`pi-tui/overlays/usage-row.ts`).
15
+ */
16
+ const MIN_RATE_DURATION_MS = 100;
17
+
9
18
  /**
10
19
  * Compute real `SessionContextTelemetry` for a session file (all-zero on
11
20
  * unreadable/empty). `rawLimit` caps materialized raw items (0 = none): the
@@ -56,6 +65,17 @@ export async function computeRealSessionTelemetry(
56
65
  let messagesCount = 0;
57
66
  const rawMessages: RawMessageItem[] = [];
58
67
  let cwd = '';
68
+ // Timing: `duration`/`ttft` are per assistant message; a tool call's span runs
69
+ // from its `tool_execution_start` entry to its `toolResult` timestamp. The
70
+ // join is the same one the chat reload path performs (messages-map.ts), so a
71
+ // call states one duration whichever surface reads it.
72
+ let llmDurationMs = 0;
73
+ let toolDurationMs = 0;
74
+ let ttftSum = 0;
75
+ let ttftCount = 0;
76
+ let lastOutputTokens = 0;
77
+ let lastDurationMs: number | undefined;
78
+ const toolStarts = new Map<string, number>();
59
79
 
60
80
  await scanSessionEntries(filePath, (entry, index) => {
61
81
  // Modern session files start with a fixed-width title slot line, so the
@@ -72,6 +92,17 @@ export async function computeRealSessionTelemetry(
72
92
  return;
73
93
  }
74
94
  if (entry.type === 'compaction' && typeof entry.shortSummary === 'string' && !shortSummary) shortSummary = entry.shortSummary;
95
+ // omp records each call's begin as its own `custom` entry; the result entry
96
+ // carries no duration. The map is exact by call id and costs one entry.
97
+ if (entry.type === 'custom' && entry.customType === 'tool_execution_start') {
98
+ const data = isRecord(entry.data) ? entry.data : undefined;
99
+ const callId = typeof data?.toolCallId === 'string' ? data.toolCallId : undefined;
100
+ if (callId) {
101
+ const startedAt = toEpochMs(data?.startedAt) ?? toEpochMs(entry.timestamp);
102
+ if (startedAt !== undefined) toolStarts.set(callId, startedAt);
103
+ }
104
+ return;
105
+ }
75
106
  if (entry.type !== 'message' || !entry.message) return;
76
107
 
77
108
  const msg = entry.message;
@@ -81,6 +112,17 @@ export async function computeRealSessionTelemetry(
81
112
  const info = buildInfo(entry, msg, cwd, index);
82
113
  const tokens = tokensOf(msg.usage);
83
114
 
115
+ // A result closes the span its `tool_execution_start` opened. A call still
116
+ // running when the file was read has no result and adds nothing.
117
+ if (role === 'toolResult') {
118
+ const callId = typeof msg.toolCallId === 'string' ? msg.toolCallId : undefined;
119
+ const startedAt = callId ? toolStarts.get(callId) : undefined;
120
+ const endedAt = toEpochMs(msg.timestamp) ?? toEpochMs(entry.timestamp);
121
+ if (startedAt !== undefined && endedAt !== undefined && endedAt >= startedAt) {
122
+ toolDurationMs += endedAt - startedAt;
123
+ }
124
+ }
125
+
84
126
  toolChars += profile.toolChars;
85
127
 
86
128
  if (role === 'user') {
@@ -93,6 +135,16 @@ export async function computeRealSessionTelemetry(
93
135
  if (msg.usage) lastAsstUsage = msg.usage;
94
136
  const anchor = contextAnchorTokens(msg);
95
137
  if (anchor !== undefined) contextAnchor = anchor;
138
+ const duration = typeof msg.duration === 'number' && Number.isFinite(msg.duration) ? msg.duration : undefined;
139
+ if (duration !== undefined && duration > 0) {
140
+ llmDurationMs += duration;
141
+ lastDurationMs = duration;
142
+ lastOutputTokens = tokens.output;
143
+ }
144
+ if (typeof msg.ttft === 'number' && Number.isFinite(msg.ttft) && msg.ttft > 0) {
145
+ ttftSum += msg.ttft;
146
+ ttftCount += 1;
147
+ }
96
148
  }
97
149
 
98
150
  if (msg.usage) {
@@ -177,6 +229,15 @@ export async function computeRealSessionTelemetry(
177
229
  const cacheHitPercent = lastAsstUsage && lastTokens.input + lastTokens.output + lastTokens.cacheRead > 0 ? Number(((lastTokens.cacheRead / (lastTokens.input + lastTokens.output + lastTokens.cacheRead)) * 100).toFixed(1)) : 0;
178
230
  const cacheHitAverage = cacheAvgInput + cacheAvgCacheRead > 0 ? Number(((cacheAvgCacheRead / (cacheAvgInput + cacheAvgCacheRead)) * 100).toFixed(1)) : 0;
179
231
 
232
+ // Output tokens per second, over the whole request duration — the same
233
+ // arithmetic omp's usage row prints, so the popover and the TUI agree.
234
+ const lastTps = lastDurationMs !== undefined && lastDurationMs > MIN_RATE_DURATION_MS && lastOutputTokens > 0
235
+ ? (lastOutputTokens / lastDurationMs) * 1000
236
+ : undefined;
237
+ const avgTps = llmDurationMs > MIN_RATE_DURATION_MS && sumOutput > 0
238
+ ? (sumOutput / llmDurationMs) * 1000
239
+ : undefined;
240
+
180
241
  return {
181
242
  sessionId,
182
243
  sessionTitle: effectiveTitle || shortSummary || firstUserText
@@ -192,6 +253,13 @@ export async function computeRealSessionTelemetry(
192
253
  assistantCount,
193
254
  totalCost,
194
255
  costFormatted: formatCost(totalCost),
256
+ timing: {
257
+ llmMs: Math.round(llmDurationMs),
258
+ toolMs: Math.round(toolDurationMs),
259
+ ...(ttftCount > 0 ? { ttftAvgMs: Math.round(ttftSum / ttftCount) } : {}),
260
+ ...(lastTps !== undefined ? { lastTps } : {}),
261
+ ...(avgTps !== undefined ? { avgTps } : {}),
262
+ },
195
263
  cacheHitAverage,
196
264
  costBreakdown: { input: costInput, output: costOutput, cacheRead: costCacheRead, cacheWrite: costCacheWrite, total: totalCost },
197
265
  lastMessage: {
@@ -185,3 +185,84 @@ describe('computeRealSessionTelemetry raw items', () => {
185
185
  expect(telemetry.rawMessages[0]?.id).toBe('u1');
186
186
  });
187
187
  });
188
+
189
+ describe('computeRealSessionTelemetry timing', () => {
190
+ /** The call's begin clock: a `custom` entry, the only start omp writes. */
191
+ function toolStart(callId: string, at: string): Record<string, unknown> {
192
+ return {
193
+ type: 'custom',
194
+ customType: 'tool_execution_start',
195
+ timestamp: at,
196
+ data: { toolCallId: callId, toolName: 'bash', startedAt: at },
197
+ };
198
+ }
199
+
200
+ function toolResult(callId: string, at: string): Record<string, unknown> {
201
+ return {
202
+ type: 'message',
203
+ id: `r-${callId}`,
204
+ timestamp: at,
205
+ message: {
206
+ role: 'toolResult',
207
+ toolCallId: callId,
208
+ toolName: 'bash',
209
+ content: [{ type: 'text', text: 'ok' }],
210
+ },
211
+ };
212
+ }
213
+
214
+ test('sums LLM time, tool spans, TTFT and tokens/second', async () => {
215
+ const file = await writeSession([
216
+ header,
217
+ userMessage('u1', 'go'),
218
+ assistantMessage('a1', { duration: 2000, ttft: 500, usage: { input: 10, output: 100 } }),
219
+ toolStart('c1', '2026-09-16T02:32:00.000Z'),
220
+ toolResult('c1', '2026-09-16T02:32:01.500Z'),
221
+ assistantMessage('a2', { duration: 3000, ttft: 1000, usage: { input: 20, output: 150 } }),
222
+ ]);
223
+
224
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
225
+ expect(timing).toEqual({
226
+ llmMs: 5000,
227
+ toolMs: 1500,
228
+ ttftAvgMs: 750,
229
+ // last = 150 output / 3000 ms; avg = 250 output / 5000 ms — both 50/s.
230
+ lastTps: 50,
231
+ avgTps: 50,
232
+ });
233
+ });
234
+
235
+ test('reports no rate when the request is too short to mean anything', async () => {
236
+ const file = await writeSession([
237
+ header,
238
+ userMessage('u1', 'go'),
239
+ assistantMessage('a1', { duration: 80, usage: { input: 10, output: 5 } }),
240
+ ]);
241
+
242
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
243
+ // 80 ms is below the 100 ms floor: the span is real, the rate is not.
244
+ expect(timing).toEqual({ llmMs: 80, toolMs: 0 });
245
+ });
246
+
247
+ test('a tool call with no result contributes no time', async () => {
248
+ const file = await writeSession([
249
+ header,
250
+ userMessage('u1', 'go'),
251
+ toolStart('c1', '2026-09-16T02:32:00.000Z'),
252
+ ]);
253
+
254
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
255
+ expect(timing?.toolMs).toBe(0);
256
+ });
257
+
258
+ test('legacy messages without timing leave the rates unmeasured', async () => {
259
+ const file = await writeSession([
260
+ header,
261
+ userMessage('u1', 'go'),
262
+ assistantMessage('a1', { usage: { input: 10, output: 5 } }),
263
+ ]);
264
+
265
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
266
+ expect(timing).toEqual({ llmMs: 0, toolMs: 0 });
267
+ });
268
+ });
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `GET /api/connect/devices` — the paired list.
8
+ * `DELETE /api/connect/devices?id=…` — revoke one.
9
+ * `POST /api/connect/devices` — a device reports the route it is using.
10
+ *
11
+ * The report is a POST rather than a side effect of every request: the auth gate
12
+ * runs on every call and is synchronous, so writing a row there would put a
13
+ * database write in front of every frame. A device reports once when it
14
+ * connects, which is exactly the fact the page displays.
15
+ */
16
+
17
+ import { json, NO_STORE_HEADERS, type ActionFunctionArgs } from '@/server/lib/remix-compat';
18
+ import { listPairedDevices, revokeDevice, touchDevice } from '@/server/lib/connect/devices.server';
19
+ import { bearerToken } from '@/server/lib/sessions/agent-token.server';
20
+ import { verifyDeviceToken } from '@/server/lib/connect/devices.server';
21
+ import type { ConnectRouteKind } from '@/shared/lib/connect/types';
22
+
23
+ const ROUTE_KINDS: readonly ConnectRouteKind[] = ['cloudflare', 'lan', 'tailscale'];
24
+
25
+ export async function loader() {
26
+ return json({ devices: await listPairedDevices() }, { headers: NO_STORE_HEADERS });
27
+ }
28
+
29
+ export async function action({ request }: ActionFunctionArgs) {
30
+ const url = new URL(request.url);
31
+
32
+ if (request.method === 'DELETE') {
33
+ const id = url.searchParams.get('id') ?? '';
34
+ if (!id) return json({ error: 'Expected ?id=' }, { status: 400, headers: NO_STORE_HEADERS });
35
+ const revoked = await revokeDevice(id);
36
+ if (!revoked) return json({ error: 'No such device' }, { status: 404, headers: NO_STORE_HEADERS });
37
+ return json({ ok: true, devices: await listPairedDevices() }, { headers: NO_STORE_HEADERS });
38
+ }
39
+
40
+ if (request.method === 'POST') {
41
+ const deviceId = verifyDeviceToken(bearerToken(request));
42
+ if (!deviceId) {
43
+ return json({ error: 'A device token is required' }, { status: 401, headers: NO_STORE_HEADERS });
44
+ }
45
+ const body = (await request.json().catch(() => null)) as { route?: unknown; rttMs?: unknown } | null;
46
+ const route = ROUTE_KINDS.find((kind) => kind === body?.route);
47
+ const rttMs = typeof body?.rttMs === 'number' && Number.isFinite(body.rttMs) ? Math.round(body.rttMs) : null;
48
+ if (!route || rttMs === null) {
49
+ return json({ error: 'Expected { route, rttMs }' }, { status: 400, headers: NO_STORE_HEADERS });
50
+ }
51
+ await touchDevice(deviceId, { route, rttMs });
52
+ return json({ ok: true }, { headers: NO_STORE_HEADERS });
53
+ }
54
+
55
+ return json({ error: 'Method not allowed' }, { status: 405, headers: NO_STORE_HEADERS });
56
+ }
@@ -0,0 +1,15 @@
1
+ import { bindingsFor, type HandlerBinding } from '@/server/lib/route-adapter';
2
+ import * as connectStatus from '@/server/routes/connect/status';
3
+ import * as connectTunnels from '@/server/routes/connect/tunnels';
4
+ import * as connectDevices from '@/server/routes/connect/devices';
5
+ import * as connectPair from '@/server/routes/connect/pair';
6
+ import * as connectPairPage from '@/server/routes/connect/pair-page';
7
+
8
+ export const connectBindings: HandlerBinding[] = [
9
+ ...bindingsFor(connectStatus, '/api/connect/status'),
10
+ ...bindingsFor(connectTunnels, '/api/connect/tunnels'),
11
+ ...bindingsFor(connectDevices, '/api/connect/devices'),
12
+ ...bindingsFor(connectPair, '/api/connect/pair'),
13
+ ...bindingsFor(connectPair, '/api/connect/pair/claim'),
14
+ ...bindingsFor(connectPairPage, '/pair'),
15
+ ];
@@ -0,0 +1,177 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `GET /pair` — the page a phone's camera opens.
8
+ *
9
+ * This is what makes a pairing code usable WITHOUT a native scanner: the QR
10
+ * encodes an `https://<address>/pair#<payload>` URL, the phone's own camera app
11
+ * opens it in the browser, and this page redeems the code and lands the browser
12
+ * on the console with a device cookie already set.
13
+ *
14
+ * The payload lives in the FRAGMENT, never the query string. A fragment is not
15
+ * sent to the server, so the one-time secret never reaches an access log, a
16
+ * proxy, or the `Referer` of anything this page loads. The page reads it with
17
+ * `location.hash` and posts it once.
18
+ *
19
+ * No external assets and no framework: this page has to render on a phone that
20
+ * has never reached this server before, over a link that may be slow, and a
21
+ * bundle that fails to load would leave the user staring at a blank screen with
22
+ * a code that is already burning its two minutes.
23
+ */
24
+
25
+ import { NO_STORE_HEADERS } from '@/server/lib/remix-compat';
26
+
27
+ const PAGE = `<!doctype html>
28
+ <html lang="en">
29
+ <head>
30
+ <meta charset="utf-8">
31
+ <meta name="viewport" content="width=device-width, initial-scale=1">
32
+ <meta name="robots" content="noindex">
33
+ <title>Pair with Kabmo</title>
34
+ <style>
35
+ :root { color-scheme: light dark; }
36
+ body { margin: 0; min-height: 100vh; display: grid; place-items: center;
37
+ font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
38
+ background: #f7f5f0; color: #141310; }
39
+ main { width: min(28rem, calc(100vw - 3rem)); padding: 1.5rem;
40
+ border: 1px solid rgba(20,19,16,.12); border-radius: 14px; background: #fff; }
41
+ h1 { margin: 0 0 .5rem; font-size: 1.05rem; }
42
+ p { margin: 0; color: rgba(20,19,16,.65); font-size: .85rem; }
43
+ a { display: inline-block; margin-top: 1rem; padding: .5rem .9rem; border-radius: 8px;
44
+ background: #141310; color: #f7f5f0; text-decoration: none; font-weight: 600; font-size: .85rem; }
45
+ @media (prefers-color-scheme: dark) {
46
+ body { background: #141310; color: #f7f5f0; }
47
+ main { background: #1d1b17; border-color: rgba(247,245,240,.14); }
48
+ p { color: rgba(247,245,240,.65); }
49
+ a { background: #f7f5f0; color: #141310; }
50
+ }
51
+ </style>
52
+ </head>
53
+ <body>
54
+ <main>
55
+ <h1>Pair with Kabmo</h1>
56
+ <p id="status">Pairing…</p>
57
+ <a id="continue" href="/" hidden>Open the console</a>
58
+ </main>
59
+ <script>
60
+ (function () {
61
+ var status = document.getElementById('status');
62
+ var link = document.getElementById('continue');
63
+
64
+ function fail(message) {
65
+ status.textContent = message;
66
+ }
67
+
68
+ function decode(value) {
69
+ var padded = value.replace(/-/g, '+').replace(/_/g, '/');
70
+ while (padded.length % 4) padded += '=';
71
+ var binary = atob(padded);
72
+ var bytes = new Uint8Array(binary.length);
73
+ for (var i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
74
+ return new TextDecoder().decode(bytes);
75
+ }
76
+
77
+ function deviceName() {
78
+ var ua = navigator.userAgent || '';
79
+ if (/iPhone/.test(ua)) return 'iPhone';
80
+ if (/iPad/.test(ua)) return 'iPad';
81
+ if (/Android/.test(ua)) return 'Android device';
82
+ if (/Macintosh/.test(ua)) return 'Mac';
83
+ if (/Windows/.test(ua)) return 'Windows PC';
84
+ return 'Browser';
85
+ }
86
+
87
+ function platform() {
88
+ var ua = navigator.userAgent || '';
89
+ if (/iPhone|iPad|iPod/.test(ua)) return 'ios';
90
+ if (/Android/.test(ua)) return 'android';
91
+ if (/Macintosh/.test(ua)) return 'macos';
92
+ if (/Windows/.test(ua)) return 'windows';
93
+ if (/Linux/.test(ua)) return 'linux';
94
+ return 'web';
95
+ }
96
+
97
+ var raw = location.hash.slice(1);
98
+ if (!raw) { fail('This link is missing its pairing code. Create a new one in Settings → Connect.'); return; }
99
+
100
+ var payload;
101
+ try {
102
+ payload = JSON.parse(decode(raw));
103
+ } catch (error) {
104
+ fail('This link is not a Kabmo pairing code.');
105
+ return;
106
+ }
107
+ if (!payload || !payload.pairingId || !payload.secret) {
108
+ fail('This link is not a Kabmo pairing code.');
109
+ return;
110
+ }
111
+
112
+ // Which candidate this page was opened from, and how fast it answers.
113
+ //
114
+ // The page is served BY the origin it is pairing with, so location.origin
115
+ // matches exactly one candidate — this is a fact, not a guess. The round trip
116
+ // is measured here because the server cannot measure a phone's latency, and
117
+ // the device row's ROUTE/RTT columns are otherwise always empty.
118
+ var route = null;
119
+ var candidates = payload.candidates || [];
120
+ for (var i = 0; i < candidates.length; i += 1) {
121
+ if (candidates[i] && candidates[i].url === location.origin) { route = candidates[i].kind; break; }
122
+ }
123
+
124
+ function measure() {
125
+ if (!window.performance || !performance.now) return Promise.resolve(null);
126
+ var started = performance.now();
127
+ return fetch('/api/health', { cache: 'no-store' })
128
+ .then(function (response) { return response.ok ? Math.round(performance.now() - started) : null; })
129
+ .catch(function () { return null; });
130
+ }
131
+
132
+ measure().then(function (rttMs) {
133
+ var body = {
134
+ pairingId: payload.pairingId,
135
+ secret: payload.secret,
136
+ name: deviceName(),
137
+ platform: platform()
138
+ };
139
+ if (route) body.route = route;
140
+ if (rttMs !== null) body.rttMs = rttMs;
141
+
142
+ return fetch('/api/connect/pair/claim', {
143
+ method: 'POST',
144
+ headers: { 'content-type': 'application/json' },
145
+ body: JSON.stringify(body)
146
+ });
147
+ }).then(function (response) {
148
+ return response.json().catch(function () { return null; }).then(function (body) {
149
+ if (!response.ok) {
150
+ fail((body && body.error) || 'This pairing code could not be redeemed.');
151
+ return;
152
+ }
153
+ status.textContent = 'Paired. Opening the console…';
154
+ link.hidden = false;
155
+ location.replace('/');
156
+ });
157
+ }).catch(function () {
158
+ fail('Could not reach the server. Check that this device is on the same network or tailnet.');
159
+ });
160
+ })();
161
+ </script>
162
+ </body>
163
+ </html>`;
164
+
165
+ export async function loader() {
166
+ return new Response(PAGE, {
167
+ status: 200,
168
+ headers: {
169
+ 'content-type': 'text/html; charset=utf-8',
170
+ ...NO_STORE_HEADERS,
171
+ // The page reads a fragment and posts it once; nothing it loads may leak
172
+ // the URL onward.
173
+ 'referrer-policy': 'no-referrer',
174
+ 'x-content-type-options': 'nosniff',
175
+ },
176
+ });
177
+ }
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `POST /api/connect/pair` — mint a one-time code and its QR.
8
+ * `POST /api/connect/pair/claim` — redeem it for a device token.
9
+ *
10
+ * The two halves have different auth on purpose. Minting requires a session: it
11
+ * is the operator handing out access. Claiming is PUBLIC, because the device
12
+ * doing it has no cookie yet — the one-time secret IS the credential, and it is
13
+ * 32 random bytes with a two-minute life, so it cannot be guessed and cannot be
14
+ * replayed.
15
+ *
16
+ * The claim answers with the server's `serverId` so the device can confirm it
17
+ * reached the machine the QR named. A device that pinned an id and gets a
18
+ * different one must refuse the token it was just handed.
19
+ */
20
+
21
+ import { json, NO_STORE_HEADERS, type ActionFunctionArgs } from '@/server/lib/remix-compat';
22
+ import { connectIdentity } from '@/server/lib/connect/identity.server';
23
+ import { connectStatus } from '@/server/lib/connect/status.server';
24
+ import { createPairing, consumePairing } from '@/server/lib/connect/pairing.server';
25
+ import { mintDeviceToken, touchDevice, DEVICE_COOKIE } from '@/server/lib/connect/devices.server';
26
+ import { isSecureRequest } from '@/server/lib/auth/token';
27
+ import { qrMatrix } from '@/server/lib/connect/qr.server';
28
+ import { encodePairingFragment, encodePairingPayload, PAIRING_VERSION } from '@/shared/lib/connect/payload';
29
+ import { ROUTE_TIER } from '@/shared/lib/connect/tier';
30
+ import type { ConnectCandidate, ConnectRouteKind } from '@/shared/lib/connect/types';
31
+
32
+ const ROUTE_KINDS: readonly ConnectRouteKind[] = ['cloudflare', 'lan', 'tailscale'];
33
+
34
+ /**
35
+ * How long the device cookie lives, in seconds.
36
+ *
37
+ * 400 days is the longest Chrome honours; the token itself never expires, so this
38
+ * is the browser's cap rather than a policy. Revocation is the control that ends
39
+ * a pairing, not time.
40
+ */
41
+ const DEVICE_COOKIE_MAX_AGE = 400 * 24 * 60 * 60;
42
+
43
+ interface ClaimRequest {
44
+ action?: unknown;
45
+ pairingId?: unknown;
46
+ secret?: unknown;
47
+ name?: unknown;
48
+ platform?: unknown;
49
+ route?: unknown;
50
+ rttMs?: unknown;
51
+ }
52
+
53
+ export async function action({ request }: ActionFunctionArgs) {
54
+ if (request.method !== 'POST') {
55
+ return json({ error: 'Method not allowed' }, { status: 405, headers: NO_STORE_HEADERS });
56
+ }
57
+
58
+ const url = new URL(request.url);
59
+ const body = (await request.json().catch(() => null)) as ClaimRequest | null;
60
+ const isClaim = url.pathname.endsWith('/claim');
61
+
62
+ if (isClaim) {
63
+ const pairingId = typeof body?.pairingId === 'string' ? body.pairingId : '';
64
+ const secret = typeof body?.secret === 'string' ? body.secret : '';
65
+ if (!pairingId || !secret) {
66
+ return json({ error: 'Expected { pairingId, secret }' }, { status: 400, headers: NO_STORE_HEADERS });
67
+ }
68
+
69
+ const consumed = consumePairing(pairingId, secret);
70
+ if (!consumed.ok) {
71
+ return json({ error: consumed.reason }, { status: 410, headers: NO_STORE_HEADERS });
72
+ }
73
+
74
+ const name = typeof body?.name === 'string' ? body.name : 'Device';
75
+ const platform = typeof body?.platform === 'string' ? body.platform : 'unknown';
76
+ const device = await mintDeviceToken({ name, platform });
77
+
78
+ const route = ROUTE_KINDS.find((kind) => kind === body?.route);
79
+ const rttMs = typeof body?.rttMs === 'number' && Number.isFinite(body.rttMs) ? Math.round(body.rttMs) : null;
80
+ if (route && rttMs !== null) await touchDevice(device.id, { route, rttMs });
81
+
82
+ // The cookie is what a webview can actually send: it cannot attach an
83
+ // `Authorization` header to its own page requests or to a WebSocket upgrade.
84
+ // `HttpOnly` keeps it away from page script; `SameSite=Lax` is enough because
85
+ // every request that matters is same-origin.
86
+ //
87
+ // `Max-Age` is what makes pairing survive a restart. Without it the cookie is
88
+ // a SESSION cookie, which the browser drops when it closes — so a paired phone
89
+ // asked for a password again the next morning, and the whole point of pairing
90
+ // is that it does not. The token itself has no expiry in the database (only
91
+ // revocation), so the cookie's life is the browser's cap rather than a policy:
92
+ // 400 days is the longest Chrome honours.
93
+ const secure = isSecureRequest(request) ? '; Secure' : '';
94
+ return json(
95
+ {
96
+ deviceId: device.id,
97
+ token: device.token,
98
+ serverId: connectIdentity().serverId,
99
+ candidates: consumed.candidates,
100
+ },
101
+ {
102
+ headers: {
103
+ ...NO_STORE_HEADERS,
104
+ 'set-cookie': `${DEVICE_COOKIE}=${encodeURIComponent(device.token)}; Path=/; Max-Age=${DEVICE_COOKIE_MAX_AGE}; HttpOnly; SameSite=Lax${secure}`,
105
+ },
106
+ },
107
+ );
108
+ }
109
+
110
+ // Minting. Only the addresses that actually answer go into the code: a
111
+ // candidate the device cannot reach would make the first probe fail for no
112
+ // reason, and the page already shows the unavailable ones with their reason.
113
+ const status = await connectStatus();
114
+ const candidates: ConnectCandidate[] = status.addresses
115
+ .filter((address) => address.unavailable === null && address.url !== '')
116
+ .map((address) => ({ kind: address.kind, url: address.url }));
117
+
118
+ if (candidates.length === 0) {
119
+ return json(
120
+ {
121
+ error:
122
+ 'No reachable address to put in a pairing code. Turn on Tailscale Serve, or start this server with --lan.',
123
+ },
124
+ { status: 409, headers: NO_STORE_HEADERS },
125
+ );
126
+ }
127
+
128
+ const pairing = createPairing(candidates);
129
+ const payload = {
130
+ v: PAIRING_VERSION as 1,
131
+ pairingId: pairing.pairingId,
132
+ secret: pairing.secret,
133
+ serverId: status.serverId,
134
+ label: status.label,
135
+ expiresAt: pairing.expiresAt,
136
+ candidates,
137
+ };
138
+ const link = encodePairingPayload(payload);
139
+
140
+ // The QR carries the BROWSER link, not the deep link: a phone's camera app
141
+ // opens an https URL in the browser, which is what makes pairing work with no
142
+ // native scanner. The best candidate is the lowest tier — Tailscale before
143
+ // LAN, because the LAN origin is not a secure context.
144
+ const best = [...candidates].sort((left, right) => ROUTE_TIER[left.kind] - ROUTE_TIER[right.kind])[0];
145
+ const webLink = `${best.url}/pair#${encodePairingFragment(payload)}`;
146
+
147
+ return json(
148
+ {
149
+ pairingId: pairing.pairingId,
150
+ expiresAt: pairing.expiresAt,
151
+ link,
152
+ webLink,
153
+ candidates,
154
+ qr: qrMatrix(webLink),
155
+ },
156
+ { headers: NO_STORE_HEADERS },
157
+ );
158
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `GET /api/connect/status` — everything the Connect page draws.
8
+ *
9
+ * Authenticated like every other API route: the payload names the machine, its
10
+ * addresses and its paired devices, which is reconnaissance a stranger should
11
+ * not get for free.
12
+ */
13
+
14
+ import { json, NO_STORE_HEADERS } from '@/server/lib/remix-compat';
15
+ import { connectStatus } from '@/server/lib/connect/status.server';
16
+
17
+ export async function loader() {
18
+ return json(await connectStatus(), { headers: NO_STORE_HEADERS });
19
+ }