@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
@@ -23,6 +23,7 @@ import { h, render } from 'preact';
23
23
  import { act } from 'preact/test-utils';
24
24
  import { GitPanel } from '@/client/components/workspace/git-panel';
25
25
  import { SessionStateProvider } from '@/client/components/common/session-state-provider/index';
26
+ import { resetToasts } from '@/client/hooks/ui/toasts';
26
27
  import { resetRealtimeClient } from '@/shared/lib/realtime/client';
27
28
  import { gitTopic, reposTopic } from '@/shared/lib/realtime/protocol';
28
29
  import { startRealtimeTestServer, type RealtimeTestServer } from '@/test-support/realtime-server';
@@ -65,6 +66,10 @@ afterEach(() => {
65
66
  container.remove();
66
67
  }
67
68
  resetRealtimeClient();
69
+ // The Initialize click pushes a real toast into the module-level queue, which
70
+ // outlives this file: without this, the next file that asserts the queue sees
71
+ // "Initialized the repository" (measured: PairDialog.test.tsx failed on Windows).
72
+ resetToasts();
68
73
  server?.stop();
69
74
  });
70
75
 
@@ -21,6 +21,7 @@
21
21
 
22
22
  import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
23
23
  import { concatSamples, float32ToPcm16 } from '@/shared/lib/dictation/audio';
24
+ import { describeCaptureFailure } from '@/shared/lib/dictation/capture-failure';
24
25
  import { DICTATION_SAMPLE_RATE } from '@/shared/lib/dictation/protocol';
25
26
  import type { DictationServerFrame } from '@/shared/lib/dictation/protocol';
26
27
 
@@ -117,26 +118,32 @@ export function useSpeechToText({ onResult, modelKey, language }: UseSpeechToTex
117
118
  .getUserMedia({ audio: true })
118
119
  .then((stream) => {
119
120
  streamRef.current = stream;
120
- const context = new AudioContext({ sampleRate: DICTATION_SAMPLE_RATE });
121
- contextRef.current = context;
122
- inputRateRef.current = context.sampleRate;
123
-
124
- const source = context.createMediaStreamSource(stream);
125
- sourceRef.current = source;
126
- const processor = context.createScriptProcessor(4096, 1, 1);
127
- processorRef.current = processor;
128
- processor.onaudioprocess = (event) => {
129
- chunksRef.current.push(new Float32Array(event.inputBuffer.getChannelData(0)));
130
- };
131
- source.connect(processor);
132
- processor.connect(context.destination);
133
- setIsListening(true);
121
+ try {
122
+ const context = new AudioContext({ sampleRate: DICTATION_SAMPLE_RATE });
123
+ contextRef.current = context;
124
+ inputRateRef.current = context.sampleRate;
125
+
126
+ const source = context.createMediaStreamSource(stream);
127
+ sourceRef.current = source;
128
+ const processor = context.createScriptProcessor(4096, 1, 1);
129
+ processorRef.current = processor;
130
+ processor.onaudioprocess = (event) => {
131
+ chunksRef.current.push(new Float32Array(event.inputBuffer.getChannelData(0)));
132
+ };
133
+ source.connect(processor);
134
+ processor.connect(context.destination);
135
+ setIsListening(true);
136
+ } catch {
137
+ // The microphone IS open at this point, so the failure is the audio
138
+ // graph, not the permission — and the stream has to be released or
139
+ // the OS keeps showing the microphone in use.
140
+ fail('Could not start audio capture.');
141
+ }
134
142
  })
135
143
  .catch((cause: unknown) => {
136
- const name = cause instanceof DOMException ? cause.name : '';
137
- setError(name === 'NotAllowedError' ? 'Microphone permission denied.' : 'Could not open the microphone.');
144
+ setError(describeCaptureFailure(cause));
138
145
  });
139
- }, [isSupported]);
146
+ }, [fail, isSupported]);
140
147
 
141
148
  const stopListening = useCallback(() => {
142
149
  setIsListening(false);
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `+`/`−` line counts of one run's changed files.
8
+ *
9
+ * The chat's run summary prints a per-file and a total stat, so it needs counts
10
+ * without opening a diff. The server computes them from the same net pair the
11
+ * diff tab reads (first `before`, last `after`), so the number and the diff can
12
+ * never disagree.
13
+ *
14
+ * Read once per run summary the reader actually has on screen — the timeline
15
+ * mounts a window of rows, so a long session does not fetch every run's stats
16
+ * at once. A failed read leaves the counts absent; the file list itself still
17
+ * renders, and a made-up `0` would be a lie about the run.
18
+ */
19
+
20
+ import { useEffect, useState } from 'preact/hooks';
21
+ import type { SessionChangeCounts } from '@/shared/types';
22
+
23
+ /** Absolute path → the run's net counts for that path. */
24
+ export type ChangeStatsByPath = Record<string, SessionChangeCounts>;
25
+
26
+ export function useChangeStats(
27
+ sessionId: string | null,
28
+ from: number,
29
+ to: number,
30
+ ): ChangeStatsByPath {
31
+ const [stats, setStats] = useState<ChangeStatsByPath>({});
32
+
33
+ useEffect(() => {
34
+ if (!sessionId) {
35
+ setStats({});
36
+ return;
37
+ }
38
+ let cancelled = false;
39
+ void (async () => {
40
+ try {
41
+ const params = new URLSearchParams({ from: String(from), to: String(to) });
42
+ const res = await fetch(
43
+ `/api/sessions/${encodeURIComponent(sessionId)}/changes/stats?${params.toString()}`,
44
+ );
45
+ const data = (await res.json().catch(() => null)) as { files?: ChangeStatsByPath } | null;
46
+ if (!cancelled && data?.files) setStats(data.files);
47
+ } catch {
48
+ // Counts are an annotation; the list stays truthful without them.
49
+ }
50
+ })();
51
+ return () => {
52
+ cancelled = true;
53
+ };
54
+ }, [sessionId, from, to]);
55
+
56
+ return stats;
57
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The Connect page's one read, and the three actions that change it.
8
+ *
9
+ * Every action answers with the WHOLE status payload rather than a boolean, so
10
+ * the address list and the tunnel card are redrawn from one snapshot. A second
11
+ * read after a toggle would let the two disagree for a frame — the card saying
12
+ * "up" while the address row still says "not running".
13
+ *
14
+ * A refusal is returned as a sentence, never swallowed: the server's own words
15
+ * ("Tailscale refused: HTTPS is not enabled for this tailnet") are the only
16
+ * place the user learns what to fix.
17
+ */
18
+
19
+ import { useCallback, useEffect, useState } from 'preact/hooks';
20
+ import type { ConnectStatus } from '@/shared/lib/connect/types';
21
+
22
+ export type TunnelProvider = 'cloudflare' | 'tailscale';
23
+ export type TunnelVerb = 'start' | 'stop';
24
+
25
+ export interface UseConnectStatusResult {
26
+ status: ConnectStatus | null;
27
+ /** Why the last read or action failed, in the server's words. */
28
+ error: string | null;
29
+ /** Which control is in flight, so only that one is disabled. */
30
+ busy: string | null;
31
+ refresh: () => Promise<void>;
32
+ setTunnel: (provider: TunnelProvider, verb: TunnelVerb) => Promise<string | null>;
33
+ revoke: (id: string) => Promise<string | null>;
34
+ }
35
+
36
+ interface StatusEnvelope {
37
+ status?: ConnectStatus;
38
+ error?: string;
39
+ }
40
+
41
+ export function useConnectStatus(): UseConnectStatusResult {
42
+ const [status, setStatus] = useState<ConnectStatus | null>(null);
43
+ const [error, setError] = useState<string | null>(null);
44
+ const [busy, setBusy] = useState<string | null>(null);
45
+
46
+ const refresh = useCallback(async () => {
47
+ try {
48
+ const response = await fetch('/api/connect/status', { headers: { accept: 'application/json' } });
49
+ if (!response.ok) {
50
+ setError(`Could not read the connection state (HTTP ${response.status}).`);
51
+ return;
52
+ }
53
+ setStatus((await response.json()) as ConnectStatus);
54
+ setError(null);
55
+ } catch (cause) {
56
+ setError(cause instanceof Error ? cause.message : 'Could not read the connection state.');
57
+ }
58
+ }, []);
59
+
60
+ useEffect(() => {
61
+ void refresh();
62
+ }, [refresh]);
63
+
64
+ const setTunnel = useCallback(
65
+ async (provider: TunnelProvider, verb: TunnelVerb): Promise<string | null> => {
66
+ setBusy(`${provider}:${verb}`);
67
+ try {
68
+ const response = await fetch('/api/connect/tunnels', {
69
+ method: 'POST',
70
+ headers: { 'content-type': 'application/json' },
71
+ body: JSON.stringify({ provider, action: verb }),
72
+ });
73
+ const payload = (await response.json().catch(() => null)) as StatusEnvelope | null;
74
+ if (payload?.status) setStatus(payload.status);
75
+ if (!response.ok) {
76
+ const message = payload?.error ?? `The tunnel did not change (HTTP ${response.status}).`;
77
+ setError(message);
78
+ return message;
79
+ }
80
+ setError(null);
81
+ return null;
82
+ } catch (cause) {
83
+ const message = cause instanceof Error ? cause.message : 'The tunnel did not change.';
84
+ setError(message);
85
+ return message;
86
+ } finally {
87
+ setBusy(null);
88
+ }
89
+ },
90
+ [],
91
+ );
92
+
93
+ const revoke = useCallback(async (id: string): Promise<string | null> => {
94
+ setBusy(`device:${id}`);
95
+ try {
96
+ const response = await fetch(`/api/connect/devices?id=${encodeURIComponent(id)}`, { method: 'DELETE' });
97
+ const payload = (await response.json().catch(() => null)) as { devices?: ConnectStatus['devices']; error?: string } | null;
98
+ if (!response.ok) {
99
+ const message = payload?.error ?? `Could not revoke that device (HTTP ${response.status}).`;
100
+ setError(message);
101
+ return message;
102
+ }
103
+ setStatus((current) => (current && payload?.devices ? { ...current, devices: payload.devices } : current));
104
+ setError(null);
105
+ return null;
106
+ } catch (cause) {
107
+ const message = cause instanceof Error ? cause.message : 'Could not revoke that device.';
108
+ setError(message);
109
+ return message;
110
+ } finally {
111
+ setBusy(null);
112
+ }
113
+ }, []);
114
+
115
+ return { status, error, busy, refresh, setTunnel, revoke };
116
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Minting a pairing code, and the countdown that makes its life visible.
8
+ *
9
+ * The code is single-use and expires in two minutes, so the dialog has to say
10
+ * both things and show the clock. A code that silently stops working is
11
+ * indistinguishable from a broken camera, and the user's next move — rescan,
12
+ * restart the app — is the wrong one.
13
+ */
14
+
15
+ import { useCallback, useEffect, useState } from 'preact/hooks';
16
+ import type { ConnectCandidate } from '@/shared/lib/connect/types';
17
+
18
+ export interface PairingCode {
19
+ pairingId: string;
20
+ expiresAt: string;
21
+ /** The `kabmo://` deep link, for a native shell that registers the scheme. */
22
+ link: string;
23
+ /** The `https://…/pair#…` link a browser can open. This is what the QR holds. */
24
+ webLink: string;
25
+ candidates: ConnectCandidate[];
26
+ qr: { size: number; rows: string[] };
27
+ }
28
+
29
+ export interface UsePairingResult {
30
+ code: PairingCode | null;
31
+ error: string | null;
32
+ busy: boolean;
33
+ /** Seconds left before the code stops working; 0 once it has. */
34
+ secondsLeft: number;
35
+ create: () => Promise<void>;
36
+ reset: () => void;
37
+ }
38
+
39
+ interface PairingEnvelope extends Partial<PairingCode> {
40
+ error?: string;
41
+ }
42
+
43
+ export function usePairing(): UsePairingResult {
44
+ const [code, setCode] = useState<PairingCode | null>(null);
45
+ const [error, setError] = useState<string | null>(null);
46
+ const [busy, setBusy] = useState(false);
47
+ const [secondsLeft, setSecondsLeft] = useState(0);
48
+
49
+ const create = useCallback(async () => {
50
+ setBusy(true);
51
+ setError(null);
52
+ try {
53
+ const response = await fetch('/api/connect/pair', {
54
+ method: 'POST',
55
+ headers: { 'content-type': 'application/json' },
56
+ body: JSON.stringify({ action: 'create' }),
57
+ });
58
+ const payload = (await response.json().catch(() => null)) as PairingEnvelope | null;
59
+ if (!response.ok || !payload?.qr || !payload.link) {
60
+ setError(payload?.error ?? `Could not create a pairing code (HTTP ${response.status}).`);
61
+ setCode(null);
62
+ return;
63
+ }
64
+ setCode({
65
+ pairingId: payload.pairingId ?? '',
66
+ expiresAt: payload.expiresAt ?? '',
67
+ link: payload.link,
68
+ webLink: payload.webLink ?? payload.link,
69
+ candidates: payload.candidates ?? [],
70
+ qr: payload.qr,
71
+ });
72
+ } catch (cause) {
73
+ setError(cause instanceof Error ? cause.message : 'Could not create a pairing code.');
74
+ setCode(null);
75
+ } finally {
76
+ setBusy(false);
77
+ }
78
+ }, []);
79
+
80
+ const reset = useCallback(() => {
81
+ setCode(null);
82
+ setError(null);
83
+ setSecondsLeft(0);
84
+ }, []);
85
+
86
+ // The countdown is derived from the server's own `expiresAt`, not from a
87
+ // local two-minute timer: a clock that started when the dialog opened would
88
+ // keep counting through a slow request and claim time the code never had.
89
+ useEffect(() => {
90
+ if (!code) return;
91
+ const deadline = Date.parse(code.expiresAt);
92
+ if (!Number.isFinite(deadline)) return;
93
+ const tick = () => setSecondsLeft(Math.max(0, Math.round((deadline - Date.now()) / 1000)));
94
+ tick();
95
+ const timer = setInterval(tick, 1_000);
96
+ return () => clearInterval(timer);
97
+ }, [code]);
98
+
99
+ return { code, error, busy, secondsLeft, create, reset };
100
+ }
@@ -4,22 +4,14 @@
4
4
  */
5
5
 
6
6
  /**
7
- * Browser file actions shared by the editor surfaces. `saveBlob` is the one
8
- * place that builds and clicks the download anchor, so the text path (a Blob
7
+ * Browser file actions shared by the editor surfaces. The download anchor
8
+ * itself lives in `@/client/lib/browser/download`, so the text path (a Blob
9
9
  * over the buffer) and the image path (a Blob over the fetched bytes) cannot
10
10
  * drift apart — the image case has no text buffer at all, which is why it
11
11
  * needs the URL variant.
12
12
  */
13
13
 
14
- /** Hand `blob` to the browser as a download named `name`. */
15
- export function saveBlob(blob: Blob, name: string): void {
16
- const url = URL.createObjectURL(blob);
17
- const anchor = document.createElement('a');
18
- anchor.href = url;
19
- anchor.download = name;
20
- anchor.click();
21
- URL.revokeObjectURL(url);
22
- }
14
+ import { saveBlob } from '@/client/lib/browser/download';
23
15
 
24
16
  /**
25
17
  * Download a URL's bytes under `name`. Used for images, whose content never
@@ -31,7 +31,8 @@ import {
31
31
  currentEditorFont,
32
32
  useEditorFontStack,
33
33
  } from '@/client/hooks/editor/font';
34
- import { copyImageToClipboard, downloadUrl, saveBlob } from '@/client/hooks/editor/file-actions';
34
+ import { copyImageToClipboard, downloadUrl } from '@/client/hooks/editor/file-actions';
35
+ import { saveBlob } from '@/client/lib/browser/download';
35
36
  import { EDITOR_DEFAULT_FONT_FAMILY, EDITOR_FONT_FAMILY } from '@/shared/lib/code/editor/typography';
36
37
  import { primeKabmoSettings } from '@/shared/lib/settings/client';
37
38
 
@@ -18,7 +18,8 @@
18
18
  */
19
19
 
20
20
  import { useCallback, useState } from 'preact/hooks';
21
- import { copyImageToClipboard, downloadUrl, saveBlob } from '@/client/hooks/editor/file-actions';
21
+ import { copyImageToClipboard, downloadUrl } from '@/client/hooks/editor/file-actions';
22
+ import { saveBlob } from '@/client/lib/browser/download';
22
23
  import type { ByteSource } from '@/client/components/workspace/editor/viewers/bytes';
23
24
 
24
25
  interface FileTransferTarget {
@@ -48,3 +48,29 @@ export async function readClipboardText(): Promise<string | null> {
48
48
  return null;
49
49
  }
50
50
  }
51
+
52
+ const COPY_ICON =
53
+ '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';
54
+ const CHECK_ICON =
55
+ '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>';
56
+
57
+ /**
58
+ * Copy a code block's text and flash the checkmark on its button.
59
+ *
60
+ * The button is markup the markdown renderer injected, so the swap is DOM work
61
+ * rather than component state — and it belongs next to the clipboard call it
62
+ * reports, not in the renderer's delegated click handler.
63
+ */
64
+ export function copyFromButton(button: HTMLButtonElement): void {
65
+ const text = button.dataset.copy ?? '';
66
+ if (!text) return;
67
+ void copyToClipboard(text).then((ok) => {
68
+ if (!ok) return;
69
+ button.setAttribute('data-copied', 'true');
70
+ button.innerHTML = CHECK_ICON;
71
+ setTimeout(() => {
72
+ button.removeAttribute('data-copied');
73
+ button.innerHTML = COPY_ICON;
74
+ }, 2000);
75
+ });
76
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The one place that builds and clicks a download anchor.
8
+ *
9
+ * Every surface that hands the browser a file — the editor's text and image
10
+ * paths, the pairing QR — goes through here, so the object URL is always
11
+ * released and no caller invents a second anchor.
12
+ */
13
+
14
+ /** Hand `blob` to the browser as a download named `name`. */
15
+ export function saveBlob(blob: Blob, name: string): void {
16
+ const url = URL.createObjectURL(blob);
17
+ const anchor = document.createElement('a');
18
+ anchor.href = url;
19
+ anchor.download = name;
20
+ anchor.click();
21
+ URL.revokeObjectURL(url);
22
+ }
@@ -1018,6 +1018,11 @@ html[data-theme-variant="dark"] .shiki span { color: var(--shiki-dark); }
1018
1018
  .prose-content .mermaid-block .code-copy-float {
1019
1019
  z-index: 1;
1020
1020
  }
1021
+ /* Refresh sits left of copy: a blank diagram is the one state where the reader
1022
+ needs it, and it must not cover the copy button they already know. */
1023
+ .prose-content .mermaid-block .code-copy-float.mermaid-refresh-float {
1024
+ right: 2.125rem;
1025
+ }
1021
1026
  .prose-content .mermaid-block[data-mermaid-state='error'] pre {
1022
1027
  color: var(--theme-error);
1023
1028
  }
@@ -11,6 +11,7 @@ import { ssrRoutes } from '@/server/plugins/ssr';
11
11
  import { setListener } from '@/server/lib/lifecycle/listener';
12
12
  import { getDatabasePath } from '@/server/db.server';
13
13
  import { initAgentTokens } from '@/server/lib/sessions/agent-token.server';
14
+ import { initDeviceTokens } from '@/server/lib/connect/devices.server';
14
15
  import { logDetectedRegistry } from '@/server/lib/models/detected-registry.server';
15
16
  import { ompStartupError, ompStartupLogLines } from '@/server/lib/omp/core/startup';
16
17
  import { readInstanceRecord, removeInstanceRecord, writeInstanceRecord } from '@/server/lib/lifecycle/instance';
@@ -76,6 +77,7 @@ console.log(`[kabmo] ui auth: ${authNotice}${runPassword.source === 'argv
76
77
  for (const line of ompStartupLogLines()) console.log(`[kabmo] ${line}`);
77
78
  console.log(`[kabmo] db: ${await getDatabasePath()}`);
78
79
  await initAgentTokens();
80
+ await initDeviceTokens();
79
81
 
80
82
  const port = Number(Bun.env.PORT) || 3000;
81
83
  const host = Bun.env.HOST || 'localhost';
@@ -50,6 +50,25 @@ describe('/fonts.css is assembled from source, not from a build artifact', () =>
50
50
  expect(urls(sheet)).toContain('/fonts/fira-code-latin-400-normal.woff2');
51
51
  });
52
52
 
53
+ /**
54
+ * The `symbols2` subset is the ONLY face carrying U+2500-259F, and it is not
55
+ * a language subset — so a "drop the unused subsets" pass removes it and
56
+ * every ASCII box in a markdown code block silently skews. Measured in
57
+ * WebKit at 12px with the face absent: `M` 7.2px, `─`/`│`/`┌` 8.502px, so a
58
+ * `─` border overshoots its own `│` corner by 1.3px per column. With it
59
+ * declared, all four measure 7.2px and a 42-column box renders every line at
60
+ * exactly 302.4px.
61
+ */
62
+ test('it declares the box-drawing subset, which no language subset carries', () => {
63
+ expect(urls(sheet)).toContain('/fonts/fira-code-symbols2-400-normal.woff2');
64
+ expect(urls(sheet)).toContain('/fonts/fira-code-symbols2-700-normal.woff2');
65
+ // The range is what keeps the 4 kB files off the wire on a page that lays
66
+ // out no box-drawing glyph, so a face without it is a different contract.
67
+ const symbols2 = [...sheet.matchAll(/@font-face\s*\{[^{}]*symbols2[^{}]*\}/g)].map(([block]) => block);
68
+ expect(symbols2.length).toBe(4);
69
+ for (const block of symbols2) expect(block).toContain('U+2500-259F');
70
+ });
71
+
53
72
  test('every url is rewritten to the served route — no relative or node_modules path survives', () => {
54
73
  const targets = urls(sheet);
55
74
  expect(targets.length).toBeGreaterThan(20);
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Which address the login throttle keys on.
8
+ *
9
+ * Two failures are being prevented, and they point in opposite directions:
10
+ *
11
+ * - trusting `x-forwarded-for` from a DIRECT remote connection lets one attacker
12
+ * present a fresh identity per guess and walk through the budget;
13
+ * - ignoring it behind a tunnel makes every client share `127.0.0.1`, so ten
14
+ * failures from anywhere lock the owner out for fifteen minutes.
15
+ *
16
+ * The socket address is what separates the two cases, so that is what these
17
+ * tests vary.
18
+ */
19
+
20
+ import { describe, expect, test } from 'bun:test';
21
+ import { effectiveClientAddress } from '@/server/lib/auth/client-address';
22
+ import { UNKNOWN_CLIENT_KEY } from '@/server/lib/auth/rate-limit';
23
+
24
+ function request(headers: Record<string, string> = {}): Request {
25
+ return new Request('http://localhost:3000/api/auth/login', { method: 'POST', headers });
26
+ }
27
+
28
+ describe('effectiveClientAddress', () => {
29
+ test('uses the socket address for a direct remote connection', () => {
30
+ const address = effectiveClientAddress(request({ 'x-forwarded-for': '1.2.3.4' }), '192.168.18.50');
31
+ expect(address).toBe('192.168.18.50');
32
+ });
33
+
34
+ test('uses the forwarded address when the socket is loopback', () => {
35
+ const address = effectiveClientAddress(request({ 'x-forwarded-for': '203.0.113.9' }), '127.0.0.1');
36
+ expect(address).toBe('203.0.113.9');
37
+ });
38
+
39
+ test('takes the first entry of a forwarded chain', () => {
40
+ const address = effectiveClientAddress(
41
+ request({ 'x-forwarded-for': '203.0.113.9, 10.0.0.1, 127.0.0.1' }),
42
+ '::1',
43
+ );
44
+ expect(address).toBe('203.0.113.9');
45
+ });
46
+
47
+ test('keeps loopback when a tunnel sent no forwarded header', () => {
48
+ expect(effectiveClientAddress(request(), '127.0.0.1')).toBe('127.0.0.1');
49
+ });
50
+
51
+ test('falls back to the shared unknown key when there is no socket address', () => {
52
+ expect(effectiveClientAddress(request({ 'x-forwarded-for': '203.0.113.9' }), undefined)).toBe(UNKNOWN_CLIENT_KEY);
53
+ });
54
+
55
+ test('treats an empty forwarded value as absent', () => {
56
+ expect(effectiveClientAddress(request({ 'x-forwarded-for': ' ' }), '127.0.0.1')).toBe('127.0.0.1');
57
+ });
58
+ });
@@ -16,8 +16,20 @@
16
16
  * and the handler are handed the SAME object (verified on Elysia 1.4.30). It is
17
17
  * also self-cleaning: the entry disappears with the request.
18
18
  *
19
- * This is the socket address, never `x-forwarded-for` — that header is
20
- * caller-supplied, so a rate limit keyed on it would be trivially evaded.
19
+ * ## Why `x-forwarded-for` is read, and only from loopback
20
+ *
21
+ * The header is caller-supplied, so a rate limit keyed on it unconditionally is
22
+ * trivially evaded — that was the original rule, and it is still right for a
23
+ * direct connection. But a tunnel breaks the other way: `cloudflared` and
24
+ * `tailscale serve` both connect to this server from `127.0.0.1`, so EVERY
25
+ * client behind a tunnel shares one socket address. Ten failed logins from an
26
+ * attacker anywhere on the internet then locked the owner out for fifteen
27
+ * minutes — a denial of service against the person the limit exists to protect.
28
+ *
29
+ * The condition is therefore the socket, not the header: the forwarded value is
30
+ * used only when the connection itself came from loopback. A remote attacker
31
+ * cannot make their own socket address loopback, and a local process that can
32
+ * forge the header already has the machine.
21
33
  *
22
34
  * NOTE: there is deliberately no `clientAddressFromContext(context)` here.
23
35
  *
@@ -38,9 +50,31 @@ import { UNKNOWN_CLIENT_KEY } from '@/server/lib/auth/rate-limit';
38
50
 
39
51
  const addresses = new WeakMap<Request, string>();
40
52
 
53
+ /** Whether a socket address is this machine talking to itself. */
54
+ function isLoopback(address: string): boolean {
55
+ return address === '127.0.0.1' || address === '::1' || address === '::ffff:127.0.0.1';
56
+ }
57
+
58
+ /**
59
+ * The address a rate limit should key on.
60
+ *
61
+ * Behind a tunnel the socket is loopback for every client, so the forwarded
62
+ * value is the only thing that distinguishes them. It is trusted ONLY in that
63
+ * case — see the module comment for why the socket, not the header, is the
64
+ * condition.
65
+ */
66
+ export function effectiveClientAddress(request: Request, socketAddress: string | undefined): string {
67
+ if (!socketAddress) return UNKNOWN_CLIENT_KEY;
68
+ if (!isLoopback(socketAddress)) return socketAddress;
69
+ const forwarded = request.headers.get('x-forwarded-for');
70
+ if (!forwarded) return socketAddress;
71
+ const first = forwarded.split(',')[0]?.trim();
72
+ return first || socketAddress;
73
+ }
74
+
41
75
  /** Record the socket address for `request`. Called by the auth gate. */
42
76
  export function rememberClientAddress(request: Request, address: string | undefined): void {
43
- addresses.set(request, address && address.length > 0 ? address : UNKNOWN_CLIENT_KEY);
77
+ addresses.set(request, effectiveClientAddress(request, address));
44
78
  }
45
79
 
46
80
  /**