@moberg_hr/work-tree 2.11.0 → 2.11.2

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 (213) hide show
  1. package/dist/{account-Q5Y3YKI7.js → account-TEV24OIT.js} +13 -13
  2. package/dist/{add-repo-L4ZTGBLO.js → add-repo-RTWDVZLS.js} +7 -7
  3. package/dist/{answer-GNR4ZBWV.js → answer-Z73ZUV4U.js} +4 -4
  4. package/dist/{attach-QNSDKRW7.js → attach-46EMF36G.js} +11 -11
  5. package/dist/bin.js +2 -2
  6. package/dist/{block-3YUIMA62.js → block-YZUWOE32.js} +6 -6
  7. package/dist/{broadcast-DR3JFINO.js → broadcast-WKG6KOY4.js} +2 -2
  8. package/dist/{catchup-YG2UOZBL.js → catchup-QSE2VRQI.js} +7 -7
  9. package/dist/{chunk-MXOHW4U2.js → chunk-2FEJ66UR.js} +3 -3
  10. package/dist/{chunk-OY46QHLX.js → chunk-323URLMS.js} +2 -2
  11. package/dist/{chunk-7NNGYM3G.js → chunk-3JJLUNPD.js} +2 -2
  12. package/dist/{chunk-7NNOGTMC.js → chunk-3XKGKOVC.js} +2 -2
  13. package/dist/{chunk-R5JCCRGD.js → chunk-4DKXJGZU.js} +3 -3
  14. package/dist/{chunk-LQNHIMJM.js → chunk-52WAQNW2.js} +12 -7
  15. package/dist/chunk-52WAQNW2.js.map +1 -0
  16. package/dist/{chunk-URGHBFB3.js → chunk-562VO6OV.js} +5 -5
  17. package/dist/{chunk-H3LP3Z4U.js → chunk-6OG7ERB5.js} +6 -6
  18. package/dist/{chunk-TEVCBUEN.js → chunk-7HNGU6VR.js} +3 -3
  19. package/dist/{chunk-GZNF6762.js → chunk-B5GJNQFD.js} +2 -2
  20. package/dist/{chunk-2QLLPZ2L.js → chunk-BDPRYJL3.js} +2 -2
  21. package/dist/chunk-BDPRYJL3.js.map +1 -0
  22. package/dist/{chunk-ZG2M4ECW.js → chunk-BVTV67Y2.js} +6 -4
  23. package/dist/chunk-BVTV67Y2.js.map +1 -0
  24. package/dist/{chunk-YQBBFX7D.js → chunk-CD6I23QB.js} +5 -5
  25. package/dist/{chunk-PKQROEFP.js → chunk-CGXZSYY3.js} +2 -2
  26. package/dist/{chunk-YPXFDJ76.js → chunk-EUY7ZOAM.js} +2 -2
  27. package/dist/{chunk-IQ4MITHC.js → chunk-EXNL7TI7.js} +2 -2
  28. package/dist/{chunk-VRQKIIC2.js → chunk-FCGFXV6C.js} +2 -2
  29. package/dist/{chunk-F2NOCGMA.js → chunk-FJTMZB4E.js} +10 -10
  30. package/dist/chunk-FJTMZB4E.js.map +1 -0
  31. package/dist/chunk-FL44GFZZ.js +9 -0
  32. package/dist/{chunk-G4ZR5YZL.js → chunk-GYWLYPXX.js} +3 -3
  33. package/dist/{chunk-2KN5ECHJ.js → chunk-GZYXCMJH.js} +3 -3
  34. package/dist/{chunk-FR7B7QH6.js → chunk-H3VAWTA4.js} +2 -2
  35. package/dist/{chunk-SPP7MA3D.js → chunk-HPCGWSTO.js} +3 -3
  36. package/dist/{chunk-F2CDUWZU.js → chunk-I2ZBOLXK.js} +3 -3
  37. package/dist/{chunk-CDYCZ3PR.js → chunk-I4YAFPYP.js} +3 -3
  38. package/dist/{chunk-LHM3GB5K.js → chunk-KJRUC2QY.js} +2 -2
  39. package/dist/{chunk-246OTVRR.js → chunk-MAMO57YN.js} +2 -2
  40. package/dist/{chunk-B6MWNZCN.js → chunk-NUMRRBHL.js} +5 -5
  41. package/dist/{chunk-QLFJNYBV.js → chunk-O36SFV5G.js} +12 -2
  42. package/dist/{chunk-QLFJNYBV.js.map → chunk-O36SFV5G.js.map} +1 -1
  43. package/dist/{chunk-JCFCEJ2D.js → chunk-O4V7K5HL.js} +3 -3
  44. package/dist/{chunk-CR4LUAP4.js → chunk-ODCAGWB7.js} +4 -4
  45. package/dist/{chunk-TEL27NRC.js → chunk-OXKUVNQL.js} +2 -2
  46. package/dist/{chunk-7RHC5U7X.js → chunk-PMR5TOBL.js} +2 -2
  47. package/dist/{chunk-QBI6K23L.js → chunk-QHXMVK75.js} +5 -5
  48. package/dist/{chunk-HJKYE57I.js → chunk-QZU6TQM7.js} +8 -8
  49. package/dist/{chunk-G4QUJO7W.js → chunk-S3QXYWKF.js} +49 -49
  50. package/dist/{chunk-FLHMFRZB.js → chunk-SO3GLVKM.js} +3 -3
  51. package/dist/{chunk-I5FZXDCO.js → chunk-TQEG7UWB.js} +3 -3
  52. package/dist/{chunk-W7MGB3Q2.js → chunk-U4CIMKG2.js} +3 -3
  53. package/dist/{chunk-J3GEINBH.js → chunk-UNKJVL2C.js} +4 -4
  54. package/dist/{chunk-VAMLU5VH.js → chunk-UQJUIOGU.js} +4 -4
  55. package/dist/{chunk-EDIHBLZY.js → chunk-VHYTF5Z3.js} +3 -3
  56. package/dist/{chunk-BLGCU4HT.js → chunk-VPTHUGPB.js} +2 -2
  57. package/dist/{chunk-DZ4LX2EK.js → chunk-WW2FT2L3.js} +5 -5
  58. package/dist/{chunk-JF25PSYF.js → chunk-WZSKGVOQ.js} +3 -3
  59. package/dist/{chunk-2ZQRD73B.js → chunk-XU7TWI23.js} +7 -5
  60. package/dist/chunk-XU7TWI23.js.map +1 -0
  61. package/dist/{chunk-X3RHLYGI.js → chunk-ZGUMZJLW.js} +5 -5
  62. package/dist/{chunk-DYQQLUSB.js → chunk-ZNH72CNE.js} +2 -2
  63. package/dist/{cleanup-X7G66SPY.js → cleanup-4SBO55WC.js} +24 -24
  64. package/dist/{cli-RJVX6HVT.js → cli-73SMUICE.js} +3 -3
  65. package/dist/{config-ZBU5PHMG.js → config-TPMJCP5K.js} +3 -3
  66. package/dist/{diff-ADSD4SNQ.js → diff-BW6BSFQS.js} +4 -4
  67. package/dist/{digest-ORN6JFNE.js → digest-I53EQ6FM.js} +4 -4
  68. package/dist/{fork-VWHAU76U.js → fork-GORLJ5D7.js} +21 -21
  69. package/dist/{history-PP7RHA2V.js → history-QQ72P3PD.js} +2 -2
  70. package/dist/{hook-6AL5LIQO.js → hook-PSCHP6OD.js} +6 -6
  71. package/dist/{hydrate-JW5MIWLZ.js → hydrate-JWUZUKQR.js} +2 -2
  72. package/dist/{init-SIIKJF3K.js → init-C6CCVCZ3.js} +7 -7
  73. package/dist/{list-UTQF7KHP.js → list-LLB6KAFP.js} +2 -2
  74. package/dist/{move-P6WOVUGF.js → move-IU6BI3JN.js} +10 -10
  75. package/dist/{note-GEFCZKMT.js → note-7USST5R5.js} +4 -4
  76. package/dist/{overlaps-QMI2RJSG.js → overlaps-YCKUSS6F.js} +8 -8
  77. package/dist/{pin-ZALBX2XK.js → pin-OVQLMH5R.js} +4 -4
  78. package/dist/{pr-D3EZ7C5H.js → pr-CEH64GGM.js} +15 -15
  79. package/dist/{prune-ZCOBL7IB.js → prune-D2GPBZZ4.js} +22 -22
  80. package/dist/{pty-host-UCM6GV42.js → pty-host-TNIVMCBV.js} +52 -14
  81. package/dist/pty-host-TNIVMCBV.js.map +1 -0
  82. package/dist/{read-NHRSGZI4.js → read-Q47ZI64J.js} +4 -4
  83. package/dist/{recent-V4JVL4Y2.js → recent-YRCOQC4A.js} +8 -8
  84. package/dist/{remove-YNO2I3HR.js → remove-EEQHU53O.js} +21 -21
  85. package/dist/{restart-6YKAD7QQ.js → restart-RVRLKW2Q.js} +4 -4
  86. package/dist/{resume-PNZ7BRXJ.js → resume-2ZAGQMV7.js} +8 -8
  87. package/dist/{run-3QYP7GBN.js → run-MEL42R3A.js} +2 -2
  88. package/dist/{screen-I6N6FKMF.js → screen-JNHBNT3Z.js} +4 -4
  89. package/dist/{search-MLLK3ZCW.js → search-55ZJKEHN.js} +2 -2
  90. package/dist/{section-EQOZ36FS.js → section-KTIOZ67K.js} +4 -4
  91. package/dist/{send-LET73FB6.js → send-NTTZ5K6N.js} +5 -5
  92. package/dist/{sessions-MDOJJZCK.js → sessions-7PSFS7KI.js} +19 -19
  93. package/dist/{snooze-TNA7QTXS.js → snooze-IVWKZMOD.js} +4 -4
  94. package/dist/{start-OV6LZJ2V.js → start-3TQXW22D.js} +4 -4
  95. package/dist/{status-HDDGCX4J.js → status-LNDJJARR.js} +6 -6
  96. package/dist/{stop-3TJWZBJB.js → stop-DZJDYVUY.js} +4 -4
  97. package/dist/{sync-67AOBEYR.js → sync-TZYDXWA6.js} +22 -22
  98. package/dist/{time-F6SLY6HR.js → time-NZG6C7OX.js} +5 -5
  99. package/dist/{timesheet-QUEDQSJ2.js → timesheet-6U35X2KH.js} +7 -7
  100. package/dist/{tree-FOOQBNVW.js → tree-P27UZCXD.js} +20 -20
  101. package/dist/{update-5O3I5P4N.js → update-5UQBKLML.js} +10 -10
  102. package/dist/{usage-DVKHDT5J.js → usage-OZNRH45Z.js} +4 -4
  103. package/dist/{wait-5HZZPKNM.js → wait-MAEZJP4D.js} +5 -5
  104. package/dist/wd-bin.js +2 -2
  105. package/dist/web/assets/PtyView-CKn5mESo.js +96 -0
  106. package/dist/web/assets/PtyView-CKn5mESo.js.map +1 -0
  107. package/dist/web/assets/index-DYhzy-XC.js +126 -0
  108. package/dist/web/assets/index-DYhzy-XC.js.map +1 -0
  109. package/dist/web/index.html +1 -1
  110. package/dist/{web-T7UPV3QY.js → web-7T6QQSJV.js} +143 -62
  111. package/dist/web-7T6QQSJV.js.map +1 -0
  112. package/npm-shrinkwrap.json +2 -2
  113. package/package.json +1 -1
  114. package/dist/chunk-2QLLPZ2L.js.map +0 -1
  115. package/dist/chunk-2ZQRD73B.js.map +0 -1
  116. package/dist/chunk-5PAMO6OG.js +0 -9
  117. package/dist/chunk-F2NOCGMA.js.map +0 -1
  118. package/dist/chunk-LQNHIMJM.js.map +0 -1
  119. package/dist/chunk-ZG2M4ECW.js.map +0 -1
  120. package/dist/pty-host-UCM6GV42.js.map +0 -1
  121. package/dist/web/assets/PtyView-DIGlBtjg.js +0 -96
  122. package/dist/web/assets/PtyView-DIGlBtjg.js.map +0 -1
  123. package/dist/web/assets/index-Cx0PMo6D.js +0 -126
  124. package/dist/web/assets/index-Cx0PMo6D.js.map +0 -1
  125. package/dist/web-T7UPV3QY.js.map +0 -1
  126. /package/dist/{account-Q5Y3YKI7.js.map → account-TEV24OIT.js.map} +0 -0
  127. /package/dist/{add-repo-L4ZTGBLO.js.map → add-repo-RTWDVZLS.js.map} +0 -0
  128. /package/dist/{answer-GNR4ZBWV.js.map → answer-Z73ZUV4U.js.map} +0 -0
  129. /package/dist/{attach-QNSDKRW7.js.map → attach-46EMF36G.js.map} +0 -0
  130. /package/dist/{block-3YUIMA62.js.map → block-YZUWOE32.js.map} +0 -0
  131. /package/dist/{broadcast-DR3JFINO.js.map → broadcast-WKG6KOY4.js.map} +0 -0
  132. /package/dist/{catchup-YG2UOZBL.js.map → catchup-QSE2VRQI.js.map} +0 -0
  133. /package/dist/{chunk-MXOHW4U2.js.map → chunk-2FEJ66UR.js.map} +0 -0
  134. /package/dist/{chunk-OY46QHLX.js.map → chunk-323URLMS.js.map} +0 -0
  135. /package/dist/{chunk-7NNGYM3G.js.map → chunk-3JJLUNPD.js.map} +0 -0
  136. /package/dist/{chunk-7NNOGTMC.js.map → chunk-3XKGKOVC.js.map} +0 -0
  137. /package/dist/{chunk-R5JCCRGD.js.map → chunk-4DKXJGZU.js.map} +0 -0
  138. /package/dist/{chunk-URGHBFB3.js.map → chunk-562VO6OV.js.map} +0 -0
  139. /package/dist/{chunk-H3LP3Z4U.js.map → chunk-6OG7ERB5.js.map} +0 -0
  140. /package/dist/{chunk-TEVCBUEN.js.map → chunk-7HNGU6VR.js.map} +0 -0
  141. /package/dist/{chunk-GZNF6762.js.map → chunk-B5GJNQFD.js.map} +0 -0
  142. /package/dist/{chunk-YQBBFX7D.js.map → chunk-CD6I23QB.js.map} +0 -0
  143. /package/dist/{chunk-PKQROEFP.js.map → chunk-CGXZSYY3.js.map} +0 -0
  144. /package/dist/{chunk-YPXFDJ76.js.map → chunk-EUY7ZOAM.js.map} +0 -0
  145. /package/dist/{chunk-IQ4MITHC.js.map → chunk-EXNL7TI7.js.map} +0 -0
  146. /package/dist/{chunk-VRQKIIC2.js.map → chunk-FCGFXV6C.js.map} +0 -0
  147. /package/dist/{chunk-5PAMO6OG.js.map → chunk-FL44GFZZ.js.map} +0 -0
  148. /package/dist/{chunk-G4ZR5YZL.js.map → chunk-GYWLYPXX.js.map} +0 -0
  149. /package/dist/{chunk-2KN5ECHJ.js.map → chunk-GZYXCMJH.js.map} +0 -0
  150. /package/dist/{chunk-FR7B7QH6.js.map → chunk-H3VAWTA4.js.map} +0 -0
  151. /package/dist/{chunk-SPP7MA3D.js.map → chunk-HPCGWSTO.js.map} +0 -0
  152. /package/dist/{chunk-F2CDUWZU.js.map → chunk-I2ZBOLXK.js.map} +0 -0
  153. /package/dist/{chunk-CDYCZ3PR.js.map → chunk-I4YAFPYP.js.map} +0 -0
  154. /package/dist/{chunk-LHM3GB5K.js.map → chunk-KJRUC2QY.js.map} +0 -0
  155. /package/dist/{chunk-246OTVRR.js.map → chunk-MAMO57YN.js.map} +0 -0
  156. /package/dist/{chunk-B6MWNZCN.js.map → chunk-NUMRRBHL.js.map} +0 -0
  157. /package/dist/{chunk-JCFCEJ2D.js.map → chunk-O4V7K5HL.js.map} +0 -0
  158. /package/dist/{chunk-CR4LUAP4.js.map → chunk-ODCAGWB7.js.map} +0 -0
  159. /package/dist/{chunk-TEL27NRC.js.map → chunk-OXKUVNQL.js.map} +0 -0
  160. /package/dist/{chunk-7RHC5U7X.js.map → chunk-PMR5TOBL.js.map} +0 -0
  161. /package/dist/{chunk-QBI6K23L.js.map → chunk-QHXMVK75.js.map} +0 -0
  162. /package/dist/{chunk-HJKYE57I.js.map → chunk-QZU6TQM7.js.map} +0 -0
  163. /package/dist/{chunk-G4QUJO7W.js.map → chunk-S3QXYWKF.js.map} +0 -0
  164. /package/dist/{chunk-FLHMFRZB.js.map → chunk-SO3GLVKM.js.map} +0 -0
  165. /package/dist/{chunk-I5FZXDCO.js.map → chunk-TQEG7UWB.js.map} +0 -0
  166. /package/dist/{chunk-W7MGB3Q2.js.map → chunk-U4CIMKG2.js.map} +0 -0
  167. /package/dist/{chunk-J3GEINBH.js.map → chunk-UNKJVL2C.js.map} +0 -0
  168. /package/dist/{chunk-VAMLU5VH.js.map → chunk-UQJUIOGU.js.map} +0 -0
  169. /package/dist/{chunk-EDIHBLZY.js.map → chunk-VHYTF5Z3.js.map} +0 -0
  170. /package/dist/{chunk-BLGCU4HT.js.map → chunk-VPTHUGPB.js.map} +0 -0
  171. /package/dist/{chunk-DZ4LX2EK.js.map → chunk-WW2FT2L3.js.map} +0 -0
  172. /package/dist/{chunk-JF25PSYF.js.map → chunk-WZSKGVOQ.js.map} +0 -0
  173. /package/dist/{chunk-X3RHLYGI.js.map → chunk-ZGUMZJLW.js.map} +0 -0
  174. /package/dist/{chunk-DYQQLUSB.js.map → chunk-ZNH72CNE.js.map} +0 -0
  175. /package/dist/{cleanup-X7G66SPY.js.map → cleanup-4SBO55WC.js.map} +0 -0
  176. /package/dist/{cli-RJVX6HVT.js.map → cli-73SMUICE.js.map} +0 -0
  177. /package/dist/{config-ZBU5PHMG.js.map → config-TPMJCP5K.js.map} +0 -0
  178. /package/dist/{diff-ADSD4SNQ.js.map → diff-BW6BSFQS.js.map} +0 -0
  179. /package/dist/{digest-ORN6JFNE.js.map → digest-I53EQ6FM.js.map} +0 -0
  180. /package/dist/{fork-VWHAU76U.js.map → fork-GORLJ5D7.js.map} +0 -0
  181. /package/dist/{history-PP7RHA2V.js.map → history-QQ72P3PD.js.map} +0 -0
  182. /package/dist/{hook-6AL5LIQO.js.map → hook-PSCHP6OD.js.map} +0 -0
  183. /package/dist/{hydrate-JW5MIWLZ.js.map → hydrate-JWUZUKQR.js.map} +0 -0
  184. /package/dist/{init-SIIKJF3K.js.map → init-C6CCVCZ3.js.map} +0 -0
  185. /package/dist/{list-UTQF7KHP.js.map → list-LLB6KAFP.js.map} +0 -0
  186. /package/dist/{move-P6WOVUGF.js.map → move-IU6BI3JN.js.map} +0 -0
  187. /package/dist/{note-GEFCZKMT.js.map → note-7USST5R5.js.map} +0 -0
  188. /package/dist/{overlaps-QMI2RJSG.js.map → overlaps-YCKUSS6F.js.map} +0 -0
  189. /package/dist/{pin-ZALBX2XK.js.map → pin-OVQLMH5R.js.map} +0 -0
  190. /package/dist/{pr-D3EZ7C5H.js.map → pr-CEH64GGM.js.map} +0 -0
  191. /package/dist/{prune-ZCOBL7IB.js.map → prune-D2GPBZZ4.js.map} +0 -0
  192. /package/dist/{read-NHRSGZI4.js.map → read-Q47ZI64J.js.map} +0 -0
  193. /package/dist/{recent-V4JVL4Y2.js.map → recent-YRCOQC4A.js.map} +0 -0
  194. /package/dist/{remove-YNO2I3HR.js.map → remove-EEQHU53O.js.map} +0 -0
  195. /package/dist/{restart-6YKAD7QQ.js.map → restart-RVRLKW2Q.js.map} +0 -0
  196. /package/dist/{resume-PNZ7BRXJ.js.map → resume-2ZAGQMV7.js.map} +0 -0
  197. /package/dist/{run-3QYP7GBN.js.map → run-MEL42R3A.js.map} +0 -0
  198. /package/dist/{screen-I6N6FKMF.js.map → screen-JNHBNT3Z.js.map} +0 -0
  199. /package/dist/{search-MLLK3ZCW.js.map → search-55ZJKEHN.js.map} +0 -0
  200. /package/dist/{section-EQOZ36FS.js.map → section-KTIOZ67K.js.map} +0 -0
  201. /package/dist/{send-LET73FB6.js.map → send-NTTZ5K6N.js.map} +0 -0
  202. /package/dist/{sessions-MDOJJZCK.js.map → sessions-7PSFS7KI.js.map} +0 -0
  203. /package/dist/{snooze-TNA7QTXS.js.map → snooze-IVWKZMOD.js.map} +0 -0
  204. /package/dist/{start-OV6LZJ2V.js.map → start-3TQXW22D.js.map} +0 -0
  205. /package/dist/{status-HDDGCX4J.js.map → status-LNDJJARR.js.map} +0 -0
  206. /package/dist/{stop-3TJWZBJB.js.map → stop-DZJDYVUY.js.map} +0 -0
  207. /package/dist/{sync-67AOBEYR.js.map → sync-TZYDXWA6.js.map} +0 -0
  208. /package/dist/{time-F6SLY6HR.js.map → time-NZG6C7OX.js.map} +0 -0
  209. /package/dist/{timesheet-QUEDQSJ2.js.map → timesheet-6U35X2KH.js.map} +0 -0
  210. /package/dist/{tree-FOOQBNVW.js.map → tree-P27UZCXD.js.map} +0 -0
  211. /package/dist/{update-5O3I5P4N.js.map → update-5UQBKLML.js.map} +0 -0
  212. /package/dist/{usage-DVKHDT5J.js.map → usage-OZNRH45Z.js.map} +0 -0
  213. /package/dist/{wait-5HZZPKNM.js.map → wait-MAEZJP4D.js.map} +0 -0
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@moberg_hr/work-tree",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@moberg_hr/work-tree",
9
- "version": "2.11.0",
9
+ "version": "2.11.2",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moberg_hr/work-tree",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
4
4
  "description": "Cross-platform Git worktree manager for multiple repositories",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/pty/pty-host-protocol.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { getConfigDir } from '../platform/config.js';\nimport type { AiToolSpec } from '../platform/ai-launcher.js';\nimport { isEnvDelta, type EnvDelta } from '../platform/env-delta.js';\n\n/**\n * Wire contract between the PTY host (`work pty-host`, the long-lived\n * process that owns every Claude PTY) and its clients (`work web`,\n * `work attach`). Bump PROTOCOL_VERSION on any incompatible change: a\n * client that finds an older host running tells the user to restart it\n * (`work pty-host --restart`) instead of silently misbehaving — the host\n * outlives rebuilds by design.\n *\n * 2: the restore list moved from pty-sessions.json into state.db. A v1 host\n * still writes the file, which a v2 host adopts on start\n * (adoptLegacyRestoreList).\n */\nexport const PROTOCOL_VERSION = 2;\n\n/**\n * What this host can do beyond PROTOCOL_VERSION, answered by `/health` (additive: a host from before answers none).\n * `agentEnv`: it applies a spawn's / restart's / resume's `agentEnv` (a session's Claude account); `halt`: halt / resume.\n * A client asks before sending something an older host would silently drop (pty-pool.ts).\n */\nexport const HOST_FEATURES = ['agentEnv', 'halt'] as const;\nexport type HostFeature = (typeof HOST_FEATURES)[number];\n\n/** Discovery file: where the running host listens and its auth token. */\nexport interface HostInfo {\n pid: number;\n port: number;\n token: string;\n version: number;\n}\n\n/** What a client asks the host to spawn. The host decides `--continue`\n * itself (see `hasClaudeConversation`) so restores after a reboot make\n * the same call a fresh spawn would. */\nexport interface SpawnSpec {\n cwd: string;\n tool: AiToolSpec;\n port?: number;\n cols?: number;\n rows?: number;\n // No `unsafe` any more: every agent starts in its own permission mode. An older client may still send\n // `unsafe: true`, and a restore list written by an older host may hold it (and its tool an `unsafeFlag`): extra\n // fields, so no PROTOCOL_VERSION bump. A current host starts nothing from them and drops both when it restores or\n // restarts a session (pty-registry.ts); for one release legacy-unsafe.ts reads an entry's `unsafe: true` as \"an\n // older host still runs this agent without permission prompts\" and keeps its guards (REMOVE IN THE NEXT RELEASE).\n /** `--fresh`: start a new conversation even if one exists. First spawn\n * only — a restore always continues. */\n fresh?: boolean;\n /** `--prompt` / `--prompt-file` contents. First spawn only. */\n initialPrompt?: string;\n /** The launching shell's environment. First spawn only and never\n * persisted — it can hold secrets; a restore after reboot uses the\n * host's own environment. */\n env?: Record<string, string>;\n /**\n * What the agent's environment differs by for this session (its account's `CLAUDE_CONFIG_DIR`: set, or `null` = taken\n * out), applied over whatever environment the process starts with — the shell's, or the host's own. Persisted (a\n * folder path is no secret), so a restore keeps it. Additive, no PROTOCOL_VERSION bump: a host from before ignores\n * it and starts the agent on the environment it inherits (`work pty-host --restart` after upgrading).\n */\n agentEnv?: EnvDelta;\n}\n\n/** One entry of the host's restore list: how to respawn a session. The\n * spec as launched, minus `env` (never persisted: it can hold secrets) —\n * except the variables config `hostEnv` names (`keptEnv`), which a restore\n * after a reboot puts back over the host's own environment. */\nexport interface PersistedPty extends SpawnSpec {\n startedAt: string;\n keptEnv?: Record<string, string>;\n}\n\n/** Names that look like secrets (or carry them, as a connection string does): never kept on disk, whatever `hostEnv` says. */\nconst SECRET_NAME =\n /TOKEN|SECRET|PASS|PWD|CREDENTIAL|PRIVATE|KEY|AUTH|BEARER|COOKIE|SESSION|CERT|SIGN|SALT|(^|_)PAT($|_)|DSN|CONN|DATABASE_URL|_URI$|_URL$/i;\n/** Values that carry a password whatever their name: `scheme://user:pass@host`. */\nconst SECRET_VALUE = /:\\/\\/[^/\\s:@]+:[^/\\s@]+@/;\n\n/** Always kept for a restore, whatever `hostEnv` says: the agent's account folder (a path, not a secret — SECRET_VALUE still applies). */\nexport const ALWAYS_KEPT_ENV = ['CLAUDE_CONFIG_DIR'] as const;\n\n/** The variables of `env` to keep for a restore: the ones named (and `ALWAYS_KEPT_ENV`), that exist, and look like neither a secret nor a URL with a password in it. Pure. */\nexport function keepEnv(env: Record<string, string> | undefined, names: readonly string[]): Record<string, string> | undefined {\n if (!env) return undefined;\n const kept = Object.fromEntries(\n [...new Set([...names, ...ALWAYS_KEPT_ENV])]\n .filter((n) => !SECRET_NAME.test(n) && typeof env[n] === 'string' && !SECRET_VALUE.test(env[n]))\n .map((n) => [n, env[n]]),\n );\n return Object.keys(kept).length ? kept : undefined;\n}\nexport type PersistedPtys = Record<string, PersistedPty>;\n\n/** Shape check for a restore-list entry read back from storage. */\nexport function isPersistedPty(x: unknown): x is PersistedPty {\n const e = x as PersistedPty | null;\n return (\n !!e &&\n typeof e === 'object' &&\n typeof e.cwd === 'string' &&\n !!e.tool &&\n typeof e.tool === 'object' &&\n (e.agentEnv === undefined || isEnvDelta(e.agentEnv)) &&\n (e.keptEnv === undefined ||\n (!!e.keptEnv && typeof e.keptEnv === 'object' && Object.values(e.keptEnv).every((v) => typeof v === 'string')))\n );\n}\n\nexport interface PtyInfo {\n id: string;\n cwd: string;\n pid: number;\n exited: boolean;\n cols: number;\n rows: number;\n startedAt: string;\n /** Respawned by the host on startup from the persisted session list\n * (after a crash, `--restart` or reboot), not by a client. */\n restored: boolean;\n /** Clients attached right now (dashboard Terminal tabs, `work attach`).\n * Additive: a host from before it sends none. */\n clients?: number;\n /** When the PTY last printed anything (ISO). Additive, like clients. */\n lastOutputAt?: string;\n /** The tool's binary (`claude`, `opencode`…). Additive, like clients. */\n tool?: string;\n}\n\n/** Client → host frames on the attach WebSocket (text, JSON). Host →\n * client PTY output is sent as binary frames; control frames as text. */\nexport type ClientFrame = { type: 'input'; data: string } | { type: 'resize'; cols: number; rows: number };\n\nexport type HostControlFrame =\n /** Sent once, first, on attach: the serialized screen and the grid it was\n * drawn for. Clients draw it at exactly cols×rows, then resize to their\n * own size (which makes Claude redraw), and only then send input. */\n { type: 'replay'; data: string; cols: number; rows: number } | { type: 'exit'; code: number } | { type: 'error'; message: string };\n\nexport function hostInfoPath(): string {\n return path.join(getConfigDir(), 'pty-host.json');\n}\n\n/** Held by a starting host from \"is one running?\" through writing its\n * discovery file AND restoring the saved sessions — so two hosts can't\n * both start, and a `work remove` racing a start waits for the restore\n * instead of slipping between it (see stopSessionPty). */\nexport function hostStartLockPath(): string {\n return path.join(getConfigDir(), 'pty-host.start.lock');\n}\n\n/** The pre-SQLite restore list. Only the one-time import reads it now. */\nexport function ptySessionsPath(): string {\n return path.join(getConfigDir(), 'pty-sessions.json');\n}\n\nexport function readHostInfo(): HostInfo | null {\n try {\n const raw = JSON.parse(fs.readFileSync(hostInfoPath(), 'utf-8')) as HostInfo;\n if (typeof raw.port === 'number' && typeof raw.token === 'string' && typeof raw.pid === 'number') {\n return raw;\n }\n return null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAiBV,IAAM,mBAAmB;AAOzB,IAAM,gBAAgB,CAAC,YAAY,MAAM;AAqDhD,IAAM,cACJ;AAEF,IAAM,eAAe;AAGd,IAAM,kBAAkB,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ACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/sessions/session-branches.ts","../src/core/git/reflog.ts"],"sourcesContent":["import path from 'node:path';\nimport { json, tx, withDb } from '../platform/db.js';\nimport { checkedOutBranch, gitDirs } from '../git/git-head.js';\nimport { branchCreatedFrom, branchLogChangedSince, branchStart, checkoutBranchHistory } from '../git/reflog.js';\nimport type { WorktreeSession } from './session-types.js';\nimport { sessionIdFor } from './session-id.js';\n\n/**\n * Every branch a session's repos have been on, recorded as it goes — so the\n * dashboard shows the work on all of them without asking git each time.\n * Claude often moves on in the same worktree: a PR merges, and the next fix\n * is a new branch made from origin/dev, then another. Only the checked-out\n * branch was ever looked at, so the earlier one's commits and PR (and the\n * first new one's, once a second came) vanished from the session.\n *\n * Per session in state.db `session_branches` (schema v12, gone with the\n * session: purgeSessionRows): each repo's branches with when they were first\n * and last checked out, and where they were made from when the reflog says.\n * Written at each turn's end (the turn-end hook reads HEAD files, no git),\n * when work checks a branch out (setupWorktree, Update), and once from the\n * reflog for a session recorded before (`backfilled`).\n */\n\nexport interface RecordedBranch {\n /** The repo, as the session names it (Ship and the PR watch): a group's folder, else the target. */\n repo: string;\n name: string;\n /** ISO. */\n firstSeen: string;\n lastSeen: string;\n /** The branch or ref it was made from (`origin/dev`), when known. */\n from?: string;\n /** When it was first seen deleted (the branch facts' look): a merged one stops showing after a while. */\n gone?: string;\n /** It was seen merged (its commits in main, or its PR merged): kept so a deleted one still reads merged. */\n merged?: true;\n /** It was seen on origin once: its PR is asked about even after origin's copy was deleted (a merge's tidy-up). */\n pushed?: true;\n /** The commit it was made at (its reflog's first line): its own work is what it has beyond it, merged or not. */\n start?: string;\n /** Its tip when last looked at (the branch facts): what the Diff tab shows of it once it is deleted. */\n tip?: string;\n}\n\nexport interface SessionBranches {\n branches: RecordedBranch[];\n /** When its reflog was read for the branches before the record began (once per session). */\n backfilled?: string;\n}\n\n/** Most branches kept per repo: the ones last seen longest ago go. */\nexport const MAX_BRANCHES_PER_REPO = 30;\n\nconst isIso = (v: unknown): v is string => typeof v === 'string' && Number.isFinite(Date.parse(v));\nconst isSha = (v: unknown): v is string => typeof v === 'string' && /^[0-9a-f]{40,64}$/.test(v);\n\n/** A stored record, shape-checked; entries that don't hold up are dropped, not the record. */\nexport function cleanBranches(raw: unknown): SessionBranches | null {\n const o = raw as { branches?: unknown; backfilled?: unknown } | null;\n if (!o || typeof o !== 'object' || !Array.isArray(o.branches)) return null;\n const branches: RecordedBranch[] = [];\n for (const b of o.branches as unknown[]) {\n const x = b as Partial<Record<keyof RecordedBranch, unknown>> | null;\n if (!x || typeof x !== 'object' || typeof x.repo !== 'string' || !x.repo || typeof x.name !== 'string' || !x.name) continue;\n if (!isIso(x.firstSeen) || !isIso(x.lastSeen)) continue;\n branches.push({\n repo: x.repo,\n name: x.name,\n firstSeen: x.firstSeen,\n lastSeen: x.lastSeen,\n ...(typeof x.from === 'string' && x.from ? { from: x.from } : {}),\n ...(isIso(x.gone) ? { gone: x.gone } : {}),\n ...(x.merged === true ? { merged: true as const } : {}),\n ...(x.pushed === true ? { pushed: true as const } : {}),\n ...(isSha(x.start) ? { start: x.start } : {}),\n ...(isSha(x.tip) ? { tip: x.tip } : {}),\n });\n }\n return { branches, ...(isIso(o.backfilled) ? { backfilled: o.backfilled } : {}) };\n}\n\nexport function readSessionBranches(sessionId: string): SessionBranches | null {\n const row = withDb(\n (d) => d.prepare('SELECT data FROM session_branches WHERE session_id = ?').get(sessionId) as { data: string } | undefined,\n );\n return row ? cleanBranches(json.parse(row.data)) : null;\n}\n\n/** Every session's record, in one query (the sessions list reads them per build). */\nexport function allSessionBranches(): Map<string, SessionBranches> {\n const rows = withDb(\n (d) => d.prepare('SELECT session_id, data FROM session_branches').all() as Array<{ session_id: string; data: string }>,\n );\n const out = new Map<string, SessionBranches>();\n for (const r of rows) {\n const b = cleanBranches(json.parse(r.data));\n if (b) out.set(r.session_id, b);\n }\n return out;\n}\n\n/** A branch seen checked out (or found in the reflog): its repo, name, and when. */\nexport interface BranchSighting {\n repo: string;\n name: string;\n /** ISO; default now. */\n firstSeen?: string;\n lastSeen?: string;\n from?: string;\n /** The commit it was made at, when its reflog says. */\n start?: string;\n}\n\n/** lastSeen is written again only when it moved this much: a turn's end needn't write the row every time. */\nexport const LAST_SEEN_STEP_MS = 10 * 60_000;\n\n/**\n * The record with these sightings: a new branch appended, a known one's first\n * and last sighting widened, its `from` filled in when it had none; a branch\n * seen again un-gone. Returns the record unchanged (the same object) when\n * nothing worth a write moved. Pure.\n */\nexport function withSightings(\n rec: SessionBranches | null,\n seen: BranchSighting[],\n now: Date,\n opts: { backfilled?: boolean } = {},\n): SessionBranches {\n const base: SessionBranches = rec ?? { branches: [] };\n let changed = !rec || (opts.backfilled === true && !base.backfilled);\n const branches = base.branches.map((b) => ({ ...b }));\n const nowIso = now.toISOString();\n for (const s of seen) {\n const first = s.firstSeen ?? nowIso;\n const last = s.lastSeen ?? nowIso;\n const b = branches.find((x) => x.repo === s.repo && x.name === s.name);\n if (!b) {\n branches.push({\n repo: s.repo,\n name: s.name,\n firstSeen: first,\n lastSeen: last,\n ...(s.from ? { from: s.from } : {}),\n ...(s.start ? { start: s.start } : {}),\n });\n changed = true;\n continue;\n }\n if (Date.parse(first) < Date.parse(b.firstSeen)) {\n b.firstSeen = first;\n changed = true;\n }\n if (Date.parse(last) - Date.parse(b.lastSeen) >= LAST_SEEN_STEP_MS) {\n b.lastSeen = last;\n changed = true;\n }\n if (s.from && !b.from) {\n b.from = s.from;\n changed = true;\n }\n // Where its own work begins moves when it is rebased or fast-forwarded: the newest reading wins.\n if (s.start && b.start !== s.start) {\n b.start = s.start;\n changed = true;\n }\n if (b.gone && s.lastSeen === undefined) {\n // Checked out now: it exists again.\n delete b.gone;\n changed = true;\n }\n }\n if (!changed) return base;\n // Per repo, the most recent MAX_BRANCHES_PER_REPO.\n const kept: RecordedBranch[] = [];\n for (const repo of [...new Set(branches.map((b) => b.repo))]) {\n const mine = branches.filter((b) => b.repo === repo);\n const keep = new Set([...mine].sort((a, b) => Date.parse(b.lastSeen) - Date.parse(a.lastSeen)).slice(0, MAX_BRANCHES_PER_REPO));\n kept.push(...mine.filter((b) => keep.has(b)));\n }\n return {\n branches: kept,\n ...(base.backfilled ? { backfilled: base.backfilled } : opts.backfilled ? { backfilled: nowIso } : {}),\n };\n}\n\nfunction write(sessionId: string, rec: SessionBranches): void {\n withDb((d) => d.prepare('INSERT OR REPLACE INTO session_branches (session_id, data) VALUES (?, ?)').run(sessionId, JSON.stringify(rec)));\n}\n\n/** Record sightings, in one transaction over the row as it is now. Returns the record after; writes only when something moved. */\nexport function noteBranches(\n sessionId: string,\n seen: BranchSighting[],\n now = new Date(),\n opts: { backfilled?: boolean } = {},\n): SessionBranches {\n return tx((d) => {\n const row = d.prepare('SELECT data FROM session_branches WHERE session_id = ?').get(sessionId) as { data: string } | undefined;\n const old = row ? cleanBranches(json.parse(row.data)) : null;\n const next = withSightings(old, seen, now, opts);\n if (next !== old) write(sessionId, next);\n return next;\n });\n}\n\n/**\n * What the branch facts saw of recorded branches: deleted (gone, from when it\n * was first seen so), or merged. One transaction; writes only a change.\n */\nexport function noteBranchFacts(\n sessionId: string,\n facts: Array<{ repo: string; name: string; exists: boolean; merged: boolean; pushed?: boolean; sha?: string | null }>,\n now = new Date(),\n): void {\n tx((d) => {\n const row = d.prepare('SELECT data FROM session_branches WHERE session_id = ?').get(sessionId) as { data: string } | undefined;\n const rec = row ? cleanBranches(json.parse(row.data)) : null;\n if (!rec) return;\n let changed = false;\n for (const f of facts) {\n const b = rec.branches.find((x) => x.repo === f.repo && x.name === f.name);\n if (!b) continue;\n if (!f.exists && !b.gone) {\n b.gone = now.toISOString();\n changed = true;\n } else if (f.exists && b.gone) {\n delete b.gone;\n changed = true;\n }\n if (f.merged && !b.merged) {\n b.merged = true;\n changed = true;\n }\n if (f.pushed && !b.pushed) {\n b.pushed = true;\n changed = true;\n }\n if (f.exists && f.sha && isSha(f.sha) && b.tip !== f.sha) {\n b.tip = f.sha;\n changed = true;\n }\n }\n if (changed) write(sessionId, rec);\n });\n}\n\n/** A session's repo as Ship and the PR watch name it: a group's folder, a single repo's target. */\nexport const repoNameOf = (s: Pick<WorktreeSession, 'isGroup' | 'target'>, checkout: string): string =>\n s.isGroup ? path.basename(checkout) : s.target;\n\n/**\n * The start a turn's sighting carries: only one read now, when the branch's reflog moved (`stale`) — never the\n * record's own, read before the write: carried into it, that would overwrite a newer start another process stored\n * meanwhile (the write is its own transaction, and a sighting with no start keeps the stored one). Pure but for `read`.\n */\nexport function sightingStart(stale: boolean, read: () => string | undefined): string | undefined {\n return stale ? read() : undefined;\n}\n\n/**\n * Record the branch each of the session's repos has checked out now (HEAD\n * files: no git), and for a branch new to the record, where it was made from\n * (its reflog's first line). The turn-end hook's step; cheap. Returns the\n * record after, or null when nothing is checked out on a branch.\n */\nexport function recordCheckedOutBranches(\n s: Pick<WorktreeSession, 'target' | 'branch' | 'isGroup' | 'paths' | 'archivedAt'>,\n now = new Date(),\n): SessionBranches | null {\n if (s.archivedAt) return null;\n const id = sessionIdFor(s);\n const seen: BranchSighting[] = [];\n const known = readSessionBranches(id);\n for (const p of s.paths) {\n const name = checkedOutBranch(p);\n if (!name) continue;\n const repo = repoNameOf(s, p);\n const had = known?.branches.find((b) => b.repo === repo && b.name === name);\n const dirs = gitDirs(p);\n // A new branch: where it came from. Every turn: where its own work begins (a rebase or fast-forward moves it),\n // kept so the Diff tab still has it once the branch — and its reflog — are deleted.\n const from = (!had && dirs && branchCreatedFrom(dirs.commonDir, name)) || undefined;\n // Read only when its reflog was written since the record last saw it (a stat): a repo's own main has a reflog\n // of thousands of lines, and this runs at every turn's end of every Claude.\n const stale = !had?.start || (dirs ? branchLogChangedSince(dirs.commonDir, name, had.lastSeen) : false);\n const start = sightingStart(stale, () => (dirs && branchStart(dirs.commonDir, name)) || undefined);\n seen.push({ repo, name, ...(from && from !== name ? { from } : {}), ...(start ? { start } : {}) });\n }\n if (!seen.length) return null;\n // Nothing moved (the usual turn end): no write transaction at all.\n if (known && withSightings(known, seen, now) === known) return known;\n return noteBranches(id, seen, now);\n}\n\n/**\n * Once per session recorded before the list began: the branches its repos'\n * reflogs show they were on (the session's own branch included), merged into\n * the record and marked backfilled. File reads only; run it in the\n * background, never on a request's path. Returns the record after.\n */\nexport function backfillSessionBranches(\n s: Pick<WorktreeSession, 'target' | 'branch' | 'isGroup' | 'paths' | 'createdAt'>,\n now = new Date(),\n): SessionBranches {\n const id = sessionIdFor(s);\n const seen: BranchSighting[] = [];\n for (const p of s.paths) {\n const repo = repoNameOf(s, p);\n const history = checkoutBranchHistory(p, s.branch);\n if (!history.some((b) => b.name === s.branch) && s.createdAt) {\n // The session's own branch, even when its reflog is gone or cut short.\n seen.push({ repo, name: s.branch, firstSeen: s.createdAt, lastSeen: s.createdAt });\n }\n for (const b of history) {\n seen.push({\n repo,\n name: b.name,\n firstSeen: new Date(b.firstSeen || Date.parse(s.createdAt) || now.getTime()).toISOString(),\n lastSeen: new Date(b.lastSeen || b.firstSeen || now.getTime()).toISOString(),\n ...(b.from ? { from: b.from } : {}),\n ...(b.start ? { start: b.start } : {}),\n });\n }\n }\n return noteBranches(id, seen, now, { backfilled: true });\n}\n\n/** A recorded branch that was seen on origin once (its PR is worth asking about even with origin's copy gone). */\nexport function wasPushed(rec: SessionBranches | null | undefined, repo: string, name: string): boolean {\n return !!rec?.branches.some((b) => b.repo === repo && b.name === name && b.pushed);\n}\n\n/** How long a merged branch that was deleted goes on showing. */\nexport const GONE_SHOWN_MS = 3 * 24 * 3600_000;\n\n/** A recorded branch no longer worth showing: deleted, merged, and that a while ago (kept in the record). */\nexport function branchHidden(b: Pick<RecordedBranch, 'gone' | 'merged'>, now: number, prMerged = false): boolean {\n if (!b.gone || !(b.merged || prMerged)) return false;\n return now - Date.parse(b.gone) >= GONE_SHOWN_MS;\n}\n\n/** How long after it was last checked out another branch is still looked at (the PR watch's window). */\nexport const BRANCH_WATCH_MS = 30 * 24 * 3600_000;\n\n/** At most this many other branches per repo are asked about (git facts, the host's PR). */\nexport const MAX_WATCHED_BRANCHES = 5;\n\n/**\n * A repo's recorded branches other than the one checked out that are worth a\n * look: seen within `withinMs`, not hidden, newest first, at most\n * MAX_WATCHED_BRANCHES. Pure.\n */\nexport function otherBranchesToWatch(\n rec: SessionBranches | null | undefined,\n repo: string,\n current: string | null,\n now: number,\n withinMs: number,\n): string[] {\n return (rec?.branches ?? [])\n .filter((b) => b.repo === repo && b.name !== current && now - Date.parse(b.lastSeen) <= withinMs && !branchHidden(b, now))\n .sort((a, b) => Date.parse(b.lastSeen) - Date.parse(a.lastSeen))\n .slice(0, MAX_WATCHED_BRANCHES)\n .map((b) => b.name);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { checkedOutBranch, gitDirs } from './git-head.js';\n\n/**\n * Which branches a checkout has been on, read from its reflog files — no\n * `git` process. A checkout's own `logs/HEAD` has a line per move of HEAD\n * (`checkout: moving from feat/x to fix/y`, a commit, a reset…), each with\n * its time; a branch's own reflog in the shared folder\n * (`logs/refs/heads/<name>`) starts with where it was made from\n * (`branch: Created from origin/dev`). The parsing is pure; the reads are\n * small files.\n */\n\nexport interface ReflogLine {\n /** When, in ms. */\n at: number;\n /** What git wrote after the tab: `checkout: moving from a to b`, `commit: …`. */\n message: string;\n /** The commit it moved to (the line's second object name), when the line has one. */\n sha?: string;\n}\n\n/** `<old> <new> Name <email> 1793784300 +0100\\t<message>` → its time and message; null for a line that isn't one. */\nexport function parseReflogLine(line: string): ReflogLine | null {\n const tab = line.indexOf('\\t');\n if (tab < 0) return null;\n const m = /\\s(\\d+)\\s+[+-]\\d{4}\\s*$/.exec(line.slice(0, tab));\n if (!m) return null;\n const sha = /^[0-9a-f]{40,64} ([0-9a-f]{40,64}) /.exec(line)?.[1];\n return { at: Number(m[1]) * 1000, message: line.slice(tab + 1).trim(), ...(sha && !/^0+$/.test(sha) ? { sha } : {}) };\n}\n\n/** A checkout target that names a branch: not a commit (detached), not a remote-tracking ref, not HEAD. */\nexport function looksLikeBranch(name: string): boolean {\n if (!name || name === 'HEAD' || /\\s/.test(name)) return false;\n if (/^[0-9a-f]{7,40}$/.test(name)) return false;\n if (/^(?:origin|upstream)\\//.test(name) || name.startsWith('refs/remotes/')) return false;\n return true;\n}\n\nexport interface ReflogBranch {\n name: string;\n /** When HEAD first came to it (ms): its first sighting in this reflog. */\n firstSeen: number;\n /** When HEAD was last on it (ms): the last line written while it was checked out. */\n lastSeen: number;\n /** The branch HEAD left to come to it, the first time. */\n movedFrom?: string;\n}\n\n/**\n * The branches a checkout's HEAD reflog shows it on, in the order it came to\n * them. `start`: the branch it was on before the first move the reflog shows\n * (the session's own); `current`: what HEAD names now — a reflog cut short\n * still has it. Pure.\n */\nexport function branchesFromReflog(lines: ReflogLine[], opts: { start?: string | null; current?: string | null } = {}): ReflogBranch[] {\n const out = new Map<string, ReflogBranch>();\n const firstMove = lines.map((l) => moveOf(l.message)).find((m) => m !== null);\n // Before the first move HEAD was on the branch it moved from — the start branch, when the reflog has no move.\n let on: string | null = firstMove?.from ?? opts.start ?? opts.current ?? null;\n const see = (name: string | null, at: number, from?: string) => {\n if (!name || !looksLikeBranch(name)) return;\n const b = out.get(name);\n if (b) b.lastSeen = Math.max(b.lastSeen, at);\n else out.set(name, { name, firstSeen: at, lastSeen: at, ...(from && looksLikeBranch(from) ? { movedFrom: from } : {}) });\n };\n for (const l of lines) {\n const move = moveOf(l.message);\n if (move) {\n see(on, l.at);\n on = move.to;\n see(on, l.at, move.from);\n continue;\n }\n // `rebase (finish): returning to refs/heads/x`: back on x after a rebase's detached steps.\n const back = /returning to refs\\/heads\\/(.+)$/.exec(l.message);\n if (back) on = back[1].trim();\n see(on, l.at);\n }\n if (opts.current && !out.has(opts.current) && looksLikeBranch(opts.current)) {\n const at = lines.length ? lines[lines.length - 1].at : 0;\n out.set(opts.current, { name: opts.current, firstSeen: at, lastSeen: at });\n }\n return [...out.values()];\n}\n\nfunction moveOf(message: string): { from: string; to: string } | null {\n const m = /^checkout: moving from (\\S+) to (\\S+)$/.exec(message);\n return m ? { from: m[1], to: m[2] } : null;\n}\n\n/** `branch: Created from origin/dev` (a branch's own reflog, its first line) → `origin/dev`; null when it says nothing of the kind. */\nexport function createdFromLine(message: string): string | null {\n const m = /^branch: Created from (\\S+)$/.exec(message);\n return m ? m[1] : null;\n}\n\n/** Lines of a reflog file, oldest first; [] when it isn't there. At most the last `max` lines (a reflog grows for good). */\nexport function readReflog(file: string, max = 5000): ReflogLine[] {\n let text: string;\n try {\n text = fs.readFileSync(file, 'utf8');\n } catch {\n return [];\n }\n const lines = text.split(/\\r?\\n/);\n return lines\n .slice(Math.max(0, lines.length - max))\n .map(parseReflogLine)\n .filter((l): l is ReflogLine => l !== null);\n}\n\n/**\n * Where a branch was made from, as its own reflog says (`origin/dev`), or —\n * made from HEAD (`Created from HEAD`) — the branch HEAD left for it\n * (`movedFrom`). Null when neither says. Reads one small file.\n */\nexport function branchCreatedFrom(commonDir: string, name: string, movedFrom?: string): string | null {\n const first = readReflog(path.join(commonDir, 'logs', 'refs', 'heads', ...name.split('/')), 50)[0];\n const from = first ? createdFromLine(first.message) : null;\n if (from && from !== 'HEAD') return from;\n return movedFrom ?? null;\n}\n\n/**\n * Where a branch's own work begins, from its own reflog: the newest point it was put onto from outside — made\n * (`branch: Created from …`), fast-forwarded (`merge origin/dev: Fast-forward`, `pull: Fast-forward`), reset,\n * or rebased (`rebase (finish): … onto <sha>`: what it was replayed on). Its own work is what it has beyond that,\n * along its first parents, even once it is merged into what it was made from; a merge of its base into it isn't\n * a new start (first parents step over it). Null when the reflog says none (cut short, or never made here). Pure.\n *\n * Reported: a branch made from dev, fast-forwarded and rebased onto newer dev before its first commit listed dev's\n * own merges as its work, read from where it was made.\n *\n * Moves within its own work aren't from outside: a reset or rebase onto a commit the branch itself was at since its\n * start (`reset --soft HEAD~1`, `rebase -i HEAD~2`: a squash) keeps the start, or its earlier commits would drop out\n * of its work; and so does a fast-forward from its own copy (`merge origin/<name>`, `pull origin <name>`: a\n * colleague's commits on the same branch are its work too). `name`: the branch's own name; without it every\n * fast-forward moves the start.\n */\nexport function startFromReflog(lines: ReflogLine[], name?: string, upstream?: string | null): string | null {\n let start: string | null = null;\n // The commits the branch itself was at since its start: a move back onto one of them is within its own work.\n let own = new Set<string>();\n const moveTo = (sha: string) => {\n if (own.has(sha)) return;\n start = sha;\n own = new Set([sha]);\n };\n for (const l of lines) {\n const onto = /\\bonto ([0-9a-f]{40,64})\\s*$/.exec(l.message);\n // `rebase (finish)`, `pull --rebase (finish)`, and `pull --quiet (finish)` — a plain pull with pull.rebase set\n // (work's own re-entry pull) — all replay the branch onto what follows `onto`.\n if (onto && /^(?:rebase|pull)\\b[^:]*\\(finish\\)|^rebase finished/.test(l.message)) moveTo(onto[1]);\n else if (l.sha && createdFromLine(l.message) !== null) {\n start = l.sha;\n own = new Set([l.sha]);\n } else if (l.sha && /: Fast-forward\\b/.test(l.message) && !fromItsOwnCopy(l.message, name, upstream)) moveTo(l.sha);\n else if (l.sha && (/^reset: moving to /.test(l.message) || /^branch: Reset to /.test(l.message))) moveTo(l.sha);\n if (l.sha && start) own.add(l.sha);\n }\n return start;\n}\n\n/**\n * `merge origin/fix/x: Fast-forward`, `pull origin fix/x: Fast-forward`: the branch's own copy brought in. A pull\n * that names no ref (`pull: Fast-forward`, `pull --quiet: Fast-forward` — options aren't refs) took its upstream:\n * its own copy when that is the branch of its own name (`upstream`, branch.<name>.merge), not when it tracks\n * origin/main as work's new branches do.\n */\nfunction fromItsOwnCopy(message: string, name: string | undefined, upstream?: string | null): boolean {\n if (!name) return false;\n const m = /^(merge|pull)\\b(.*?):\\s*Fast-forward/.exec(message);\n if (!m) return false;\n const words = m[2]\n .trim()\n .split(/\\s+/)\n .filter((w) => w && !w.startsWith('-'));\n const ref = words[words.length - 1] ?? (m[1] === 'pull' ? (upstream ?? undefined) : undefined);\n return !!ref && (ref === name || ref.endsWith(`/${name}`));\n}\n\n/**\n * The branch a branch pulls from (`branch.<name>.merge`, `refs/heads/` taken off), read from the repo's config\n * file — no git. Null when it has none or the file can't be read.\n */\nexport function branchUpstream(commonDir: string, name: string): string | null {\n let text: string;\n try {\n text = fs.readFileSync(path.join(commonDir, 'config'), 'utf8');\n } catch {\n return null;\n }\n let inIt = false;\n let merge: string | null = null;\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.trim();\n const section = /^\\[\\s*([A-Za-z0-9.-]+)(?:\\s+\"((?:[^\"\\\\]|\\\\.)*)\")?\\s*\\]/.exec(line);\n if (section) {\n inIt = section[1].toLowerCase() === 'branch' && section[2]?.replace(/\\\\(.)/g, '$1') === name;\n continue;\n }\n if (!inIt) continue;\n const kv = /^merge\\s*=\\s*(.*?)\\s*$/i.exec(line);\n if (kv) merge = kv[1].replace(/^\"(.*)\"$/, '$1'); // the last one wins, as git reads it\n }\n return merge ? merge.replace(/^refs\\/heads\\//, '') : null;\n}\n\n/** A branch's own reflog file. */\nconst branchLogFile = (commonDir: string, name: string): string => path.join(commonDir, 'logs', 'refs', 'heads', ...name.split('/'));\n\n/** startFromReflog over a branch's reflog file. Reads one small file. */\nexport function branchStart(commonDir: string, name: string): string | null {\n return startFromReflog(readReflog(branchLogFile(commonDir, name)), name, branchUpstream(commonDir, name));\n}\n\n/**\n * Whether a branch's reflog was written after `since` (ISO): what it says may have moved. True when it can't be\n * told (no file, a bad date). A stat, no read: the turn-end hook asks it for every repo of every session.\n */\nexport function branchLogChangedSince(commonDir: string, name: string, since: string): boolean {\n const at = Date.parse(since);\n if (!at) return true;\n try {\n return fs.statSync(branchLogFile(commonDir, name)).mtimeMs > at;\n } catch {\n return true;\n }\n}\n\n/**\n * The branches a checkout has been on (its HEAD reflog), each with where it\n * was made from when its own reflog says, and the commit it was made at. File reads only. `start`: the\n * session's branch. [] when it isn't a checkout.\n */\nexport function checkoutBranchHistory(checkout: string, start?: string | null): Array<ReflogBranch & { from?: string; start?: string }> {\n const dirs = gitDirs(checkout);\n if (!dirs) return [];\n const lines = readReflog(path.join(dirs.gitDir, 'logs', 'HEAD'));\n return branchesFromReflog(lines, { start: start ?? null, current: checkedOutBranch(checkout) }).map((b) => {\n const from = branchCreatedFrom(dirs.commonDir, b.name, b.movedFrom);\n const at = branchStart(dirs.commonDir, b.name);\n return { ...b, ...(from && from !== b.name ? { from } : {}), ...(at ? { start: at } : {}) };\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,WAAU;;;ACAjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAuBV,SAAS,gBAAgB,MAAiC;AAC/D,QAAM,MAAM,KAAK,QAAQ,GAAI;AAC7B,MAAI,MAAM,EAAG,QAAO;AACpB,QAAM,IAAI,0BAA0B,KAAK,KAAK,MAAM,GAAG,GAAG,CAAC;AAC3D,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,MAAM,sCAAsC,KAAK,IAAI,IAAI,CAAC;AAChE,SAAO,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC,IAAI,KAAM,SAAS,KAAK,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,GAAI,OAAO,CAAC,OAAO,KAAK,GAAG,IAAI,EAAE,IAAI,IAAI,CAAC,EAAG;AACtH;AAGO,SAAS,gBAAgB,MAAuB;AACrD,MAAI,CAAC,QAAQ,SAAS,UAAU,KAAK,KAAK,IAAI,EAAG,QAAO;AACxD,MAAI,mBAAmB,KAAK,IAAI,EAAG,QAAO;AAC1C,MAAI,yBAAyB,KAAK,IAAI,KAAK,KAAK,WAAW,eAAe,EAAG,QAAO;AACpF,SAAO;AACT;AAkBO,SAAS,mBAAmB,OAAqB,OAA2D,CAAC,GAAmB;AACrI,QAAM,MAAM,oBAAI,IAA0B;AAC1C,QAAM,YAAY,MAAM,IAAI,CAAC,MAAM,OAAO,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,MAAM,IAAI;AAE5E,MAAI,KAAoB,WAAW,QAAQ,KAAK,SAAS,KAA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E,SAAS,WAAW,MAAM,KAAK,MAAM,EAAE,QAAQ,KAAK,YAAY,CAAC,aAAa,GAAG,GAAG,CAAC,EACxH,KAAK,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,QAAQ,IAAI,KAAK,MAAM,EAAE,QAAQ,CAAC,EAC9D,MAAM,GAAG,oBAAoB,EAC7B,IAAI,CAAC,MAAM,EAAE,IAAI;AACtB;","names":["path","path"]}
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/version.ts
4
- var VERSION = true ? "2.11.0" : "dev";
5
-
6
- export {
7
- VERSION
8
- };
9
- //# sourceMappingURL=chunk-5PAMO6OG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/stacks/branch-facts.ts"],"sourcesContent":["import { defaultRunner, type CommandRunner } from '../platform/command-runner.js';\nimport { bestEffort, logSwallowed } from '../platform/best-effort.js';\nimport type { SessionBranchWire, SessionCi, ShipPr } from '../api-types.js';\nimport { stageOfPr } from '../pr/pr-stage.js';\nimport {\n backfillSessionBranches,\n branchHidden,\n MAX_WATCHED_BRANCHES,\n noteBranchFacts,\n readSessionBranches,\n repoNameOf,\n type SessionBranches,\n} from '../sessions/session-branches.js';\nimport { checkedOutBranch } from '../git/git-head.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\n\n/**\n * What a session's other branches hold (session-branches.ts records them):\n * still there, pushed, how many commits its base lacks, how many origin\n * lacks, merged. Git through a CommandRunner (argv only), a few runs per\n * branch — so read in the background (BranchFactsCache, beside behind-main's)\n * and by the PR watch's preflight, never on a request's path.\n */\n\nexport interface BranchFacts {\n exists: boolean;\n /** Its tip, when it exists. */\n sha: string | null;\n /** `origin/<name>` exists. */\n pushed: boolean;\n /** Commits on it that its base (origin/HEAD) doesn't have; null: unknown. */\n commits: number | null;\n /** Commits on it that origin doesn't have (all of `commits` when never pushed); null: unknown. */\n unpushed: number | null;\n /** Its commits are all in its base, and it was pushed (a branch merged the usual way). Never the base itself. */\n merged: boolean;\n /** It is the repo's main line itself (`main` when origin/HEAD is origin/main): never \"merged\" into itself. */\n base?: true;\n}\n\n/** The repo's main line (`origin/main`), as origin/HEAD names it; null when it doesn't. */\nexport async function repoBase(repo: string, run: CommandRunner = defaultRunner): Promise<string | null> {\n const head = await run('git', ['-C', repo, 'rev-parse', '--abbrev-ref', 'origin/HEAD'], repo);\n const base = head.code === 0 ? head.stdout.trim() : '';\n return base && base !== 'origin/HEAD' ? base : null;\n}\n\nconst count = (out: { code: number; stdout: string }) =>\n out.code === 0 && /^\\d+$/.test(out.stdout.trim()) ? Number(out.stdout.trim()) : null;\n\n/** One branch of one repo. `base`: the repo's main line (repoBase), passed so a repo's branches ask it once. */\nexport async function branchFacts(\n repo: string,\n name: string,\n run: CommandRunner = defaultRunner,\n base?: string | null,\n): Promise<BranchFacts> {\n const git = (...args: string[]) => run('git', ['-C', repo, ...args], repo);\n const local = `refs/heads/${name}`;\n const remote = `refs/remotes/origin/${name}`;\n const tip = await git('rev-parse', '--verify', '--quiet', local);\n const exists = tip.code === 0;\n const pushed = (await git('rev-parse', '--verify', '--quiet', remote)).code === 0;\n if (!exists) return { exists, sha: null, pushed, commits: null, unpushed: null, merged: false };\n const main = base === undefined ? await repoBase(repo, run) : base;\n const commits = main ? count(await git('rev-list', '--count', `${main}..${local}`)) : null;\n const unpushed = pushed ? count(await git('rev-list', '--count', `${remote}..${local}`)) : commits;\n // The main line itself is level with origin/main whenever it's pushed: that isn't a merge (it read \"merged\").\n const isBase = !!main && main === `origin/${name}`;\n return {\n exists,\n sha: tip.stdout.trim() || null,\n pushed,\n commits,\n unpushed,\n merged: !isBase && pushed && commits === 0,\n ...(isBase ? { base: true as const } : {}),\n };\n}\n\n/** A repo's other branches to look at: by name, in its checkout. */\nexport interface BranchJob {\n repo: string;\n path: string;\n name: string;\n}\n\nexport const factsKey = (repo: string, name: string) => `${repo}\\u0000${name}`;\n\n/**\n * Per session, refreshed in the background a couple of sessions at a time;\n * reads never wait (BehindCache's way). `onFacts`: what a look found, to keep\n * (a branch seen deleted, or merged: session-branches.ts `noteBranchFacts`).\n */\nexport class BranchFactsCache {\n private readonly entries = new Map<string, { value: Map<string, BranchFacts>; at: number; inFlight: boolean; key: string }>();\n private running = 0;\n private readonly queue: Array<{ id: string; jobs: BranchJob[] }> = [];\n\n constructor(\n private readonly opts: {\n ttlMs?: number;\n concurrency?: number;\n run?: CommandRunner;\n onChange?: () => void;\n onFacts?: (id: string, facts: Array<BranchJob & BranchFacts>) => void;\n now?: () => number;\n } = {},\n ) {}\n\n /** What the last look found (an empty map before the first); schedules one when stale or the branches changed. */\n get(id: string, jobs: BranchJob[]): Map<string, BranchFacts> {\n const now = (this.opts.now ?? Date.now)();\n const key = jobs.map((j) => factsKey(j.repo, j.name)).join('|');\n const e = this.entries.get(id);\n const moved = !!e && e.key !== key;\n if (!e || moved || (!e.inFlight && now - e.at > (this.opts.ttlMs ?? 5 * 60_000))) this.schedule(id, jobs, key);\n return this.entries.get(id)?.value ?? new Map();\n }\n\n /** Look again soon (a turn ended, a push). */\n invalidate(id: string): void {\n const e = this.entries.get(id);\n if (e) e.at = 0;\n }\n\n async idle(): Promise<void> {\n while (this.running > 0 || this.queue.length > 0) await new Promise((r) => setTimeout(r, 5));\n }\n\n private schedule(id: string, jobs: BranchJob[], key: string): void {\n const e = this.entries.get(id) ?? { value: new Map<string, BranchFacts>(), at: 0, inFlight: false, key };\n if (e.inFlight && e.key === key) return;\n e.inFlight = true;\n e.key = key;\n this.entries.set(id, e);\n this.queue.push({ id, jobs });\n this.pump();\n }\n\n private pump(): void {\n while (this.running < (this.opts.concurrency ?? 2) && this.queue.length > 0) {\n const job = this.queue.shift()!;\n this.running++;\n void lookAt(job.jobs, this.opts.run)\n .catch((err) => {\n logSwallowed(`branch facts for ${job.id}`, err);\n return null;\n })\n .then((found) => {\n const e = this.entries.get(job.id)!;\n e.inFlight = false;\n e.at = (this.opts.now ?? Date.now)();\n if (!found) return;\n const value = new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)]));\n const changed = JSON.stringify([...e.value]) !== JSON.stringify([...value]);\n e.value = value;\n this.opts.onFacts?.(job.id, found);\n if (changed) this.opts.onChange?.();\n })\n .finally(() => {\n this.running--;\n this.pump();\n });\n }\n }\n}\n\nconst strip = (f: BranchJob & BranchFacts): BranchFacts => ({\n exists: f.exists,\n sha: f.sha,\n pushed: f.pushed,\n commits: f.commits,\n unpushed: f.unpushed,\n merged: f.merged,\n});\n\nasync function lookAt(jobs: BranchJob[], run?: CommandRunner): Promise<Array<BranchJob & BranchFacts>> {\n const bases = new Map<string, string | null>();\n const out: Array<BranchJob & BranchFacts> = [];\n for (const j of jobs) {\n if (!bases.has(j.path)) bases.set(j.path, await repoBase(j.path, run));\n out.push({ ...j, ...(await branchFacts(j.path, j.name, run, bases.get(j.path))) });\n }\n return out;\n}\n\n/** The PR of a repo's branch, from the PR watch's last check: the checked-out one's, or another's. */\nexport function prOfBranch(ci: SessionCi | null | undefined, repo: string, name: string): ShipPr | null {\n const r = ci?.repos.find((x) => x.name === repo);\n if (!r) return null;\n if (r.branch === name && r.pr) return r.pr;\n return r.otherPrs?.find((o) => o.branch === name)?.pr ?? null;\n}\n\n/**\n * The branches a session's row shows: every recorded one not hidden (merged\n * and deleted a while ago), each with its facts and PR, the checked-out ones\n * first, the rest newest first. Null unless some repo has been on more than\n * one: a session that stayed on its branch shows nothing new. Pure.\n */\nexport function branchesWire(\n rec: SessionBranches | null | undefined,\n current: (repo: string) => string | null,\n facts: Map<string, BranchFacts>,\n ci: SessionCi | null | undefined,\n now: number,\n): SessionBranchWire[] | null {\n if (!rec?.branches.length) return null;\n const rows: SessionBranchWire[] = [];\n for (const b of rec.branches) {\n const pr = prOfBranch(ci, b.repo, b.name);\n if (branchHidden(b, now, pr?.state === 'MERGED')) continue;\n const f = facts.get(factsKey(b.repo, b.name));\n rows.push({\n repo: b.repo,\n name: b.name,\n current: current(b.repo) === b.name,\n firstSeen: b.firstSeen,\n lastSeen: b.lastSeen,\n ...(b.from ? { from: b.from } : {}),\n ...(f\n ? {\n exists: f.exists,\n pushed: f.pushed,\n commits: f.commits,\n unpushed: f.unpushed,\n // Merged as kept once seen — unless the branch, there now, has work of its own again (commits its base\n // lacks) or is the main line itself: a repo's own main read \"6 commits · 6 not pushed · merged\". Its PR\n // merged still says so (a squash merge leaves its commits unmerged).\n merged: pr?.state === 'MERGED' || (!(f.exists && (f.base || (f.commits ?? 0) > 0)) && (f.merged || !!b.merged)),\n }\n : b.merged || pr?.state === 'MERGED'\n ? { merged: true }\n : {}),\n ...(pr ? { pr: { number: pr.number, url: pr.url, state: pr.state, kind: stageOfPr(pr) } } : {}),\n });\n }\n const repos = new Set(rows.map((r) => r.repo));\n if (![...repos].some((repo) => rows.filter((r) => r.repo === repo).length > 1)) return null;\n return rows.sort(\n (a, b) => Number(b.current) - Number(a.current) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen) || a.repo.localeCompare(b.repo),\n );\n}\n\n/**\n * The sessions list's branches (work web): each row's recorded branches with\n * their facts — read in the background (BranchFactsCache), what it finds kept\n * (deleted, merged, pushed once) — and, once per session recorded before the\n * list began, its reflog read into the record (backfillSessionBranches), one\n * session at a time, off the request's path. `wire` never runs git.\n */\nexport function createSessionBranches(\n opts: {\n onChange?: () => void;\n run?: CommandRunner;\n now?: () => number;\n /** Tests: the reflog read and the fact keeping (default: session-branches.ts). */\n backfill?: (s: WorktreeSession) => SessionBranches | void;\n keepFacts?: (id: string, facts: Array<BranchJob & BranchFacts>) => void;\n } = {},\n) {\n const now = opts.now ?? Date.now;\n const facts = new BranchFactsCache({\n ...(opts.run ? { run: opts.run } : {}),\n now,\n onChange: opts.onChange,\n onFacts: (id, found) =>\n bestEffort(`keep the branch facts of ${id}`, () => (opts.keepFacts ?? ((sid, f) => noteBranchFacts(sid, f)))(id, found)),\n });\n const backfill = opts.backfill ?? ((s: WorktreeSession) => backfillSessionBranches(s));\n const asked = new Set<string>();\n const waiting: WorktreeSession[] = [];\n let busy = false;\n const pump = () => {\n if (busy) return;\n const s = waiting.shift();\n if (!s) return;\n busy = true;\n setImmediate(() => {\n const rec = bestEffort(`read the branches of ${s.target}:${s.branch} from its reflog`, () => backfill(s));\n busy = false;\n // Only a session that turns out to have worked on more than one branch looks any different.\n if (rec && branchJobs(s, rec, now())) opts.onChange?.();\n pump();\n });\n };\n return {\n /** The row's branches (branchesWire), from what was recorded and last looked at. */\n wire(s: WorktreeSession, rec: SessionBranches | null | undefined, ci: SessionCi | null | undefined): SessionBranchWire[] | null {\n if (s.archivedAt) return null;\n const id = sessionIdFor(s);\n if (!rec?.backfilled && !asked.has(id)) {\n asked.add(id);\n waiting.push(s);\n pump();\n }\n const plan = branchJobs(s, rec, now());\n return plan ? branchesWire(rec, plan.current, facts.get(id, plan.jobs), ci, now()) : null;\n },\n invalidate: (id: string) => facts.invalidate(id),\n async idle(): Promise<void> {\n await facts.idle();\n while (busy || waiting.length) await new Promise((r) => setTimeout(r, 5));\n },\n };\n}\n\n/**\n * What to look at for a session's row: each repo's visible recorded branches (the checked-out one first, then\n * the most recent, at most MAX_WATCHED_BRANCHES others), and what each repo has checked out (HEAD files). Null\n * when no repo has been on more than one branch. No git.\n */\nexport function branchJobs(\n s: Pick<WorktreeSession, 'target' | 'isGroup' | 'paths'>,\n rec: SessionBranches | null | undefined,\n now: number,\n): { jobs: BranchJob[]; current: (repo: string) => string | null } | null {\n if (!rec?.branches.length) return null;\n const currentOf = new Map(s.paths.map((p) => [repoNameOf(s, p), checkedOutBranch(p)]));\n const visible = rec.branches.filter((b) => !branchHidden(b, now));\n const repos = new Set(visible.map((b) => b.repo));\n if (![...repos].some((r) => visible.filter((b) => b.repo === r).length > 1)) return null;\n const pathOf = new Map(s.paths.map((p) => [repoNameOf(s, p), p]));\n const jobs: BranchJob[] = [];\n for (const repo of repos) {\n const p = pathOf.get(repo);\n if (!p) continue;\n const isCurrent = (name: string) => Number(name === currentOf.get(repo));\n const mine = visible\n .filter((b) => b.repo === repo)\n .sort((a, b) => isCurrent(b.name) - isCurrent(a.name) || Date.parse(b.lastSeen) - Date.parse(a.lastSeen))\n .slice(0, MAX_WATCHED_BRANCHES + 1);\n for (const b of mine) jobs.push({ repo, path: p, name: b.name });\n }\n return { jobs, current: (repo) => currentOf.get(repo) ?? null };\n}\n\n/**\n * The same now, for the CLI (`work sessions --json`, `work status`): the record (read from the reflog first\n * when it never was), each branch looked at with git, the PR from the PR watch's last check. Null when it stayed\n * on one branch.\n */\nexport async function sessionBranchesNow(\n s: WorktreeSession,\n ci: SessionCi | null | undefined,\n run: CommandRunner = defaultRunner,\n now = Date.now(),\n): Promise<SessionBranchWire[] | null> {\n if (s.archivedAt) return null;\n let rec = readSessionBranches(sessionIdFor(s));\n if (!rec?.backfilled) rec = bestEffort(`read the branches of ${s.target}:${s.branch}`, () => backfillSessionBranches(s), rec) ?? rec;\n const plan = branchJobs(s, rec, now);\n if (!plan) return null;\n const found = await lookAt(plan.jobs, run);\n return branchesWire(rec, plan.current, new Map(found.map((f) => [factsKey(f.repo, f.name), strip(f)])), ci, now);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,eAAsB,SAAS,MAAc,MAAqB,eAAuC;AACvG,QAAM,OAAO,MAAM,IAAI,OAAO,CAAC,MAAM,MAAM,aAAa,gBAAgB,aAAa,GAAG,IAAI;AAC5F,QAAM,OAAO,KAAK,SAAS,IAAI,KAAK,OAAO,KAAK,IAAI;AACpD,SAAO,QAAQ,SAAS,gBAAgB,OAAO;AACjD;AAEA,IAAM,QAAQ,CAAC,QACb,IAAI,SAAS,KAAK,QAAQ,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO,IAAI,OAAO,KAAK,CAAC,IAAI;AAGlF,eAAsB,YACpB,MACA,MACA,MAAqB,eACrB,MACsB;AACtB,QAAM,MAAM,IAAI,SAAmB,IAAI,OAAO,CAAC,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI;AACz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ty/account-login.ts"],"sourcesContent":["import type { SessionAttention } from '../api-types.js';\n\n/**\n * A status for a session whose tool isn't Claude Code (config `aiCommand`,\n * e.g. opencode): no hooks report its turns, so the PTY host's \"last printed\n * anything\" stands in — a working agent redraws its spinner, an idle one\n * prints nothing. Working while it printed in the last `OUTPUT_WORKING_MS`,\n * idle after; never \"done, unseen\" or \"needs input\" (output can't tell a\n * finished turn from a question). Pure.\n */\n\nexport const OUTPUT_WORKING_MS = 10_000;\n\nexport interface PtyOutput {\n /** The tool's binary (the host's spawn spec). */\n tool?: string;\n /** When it last printed (ISO). */\n lastOutputAt?: string;\n startedAt: string;\n}\n\nexport function statusFromOutput(p: PtyOutput, now: number): SessionAttention | null {\n if (!p.tool || p.tool === 'claude' || !p.lastOutputAt) return null;\n const at = Date.parse(p.lastOutputAt);\n if (!Number.isFinite(at)) return null;\n const working = now - at < OUTPUT_WORKING_MS;\n return {\n state: working ? 'working' : 'idle',\n seen: true,\n since: p.lastOutputAt,\n updatedAt: p.lastOutputAt,\n stale: false,\n summary: `${working ? 'Printing' : 'Quiet'} — from its terminal output (${p.tool} has no status hooks)`,\n };\n}\n","import path from 'node:path';\nimport type { AgentAdapter } from '../agents/types.js';\nimport { agentFor, agentSettings, assistantAgent } from '../agents/index.js';\nimport { statusFromOutput, type PtyOutput } from './output-status.js';\nimport type { SessionAttention } from '../api-types.js';\nimport type { HostBeat } from './host-health.js';\nimport { PtyHostBusyError } from './pty-host-client.js';\nimport { noClaudeBecause } from '../archive/archiving.js';\nimport { findSession, sessionIdFor } from '../sessions/web-state.js';\nimport type { WorktreeSession } from '../sessions/history.js';\nimport { hostStartLockPath, type SpawnSpec, type HostInfo, type PtyInfo } from './pty-host-protocol.js';\nimport { dbPtySessions } from './pty-sessions-file.js';\nimport { ensureFile, withFileLock } from '../platform/fs-safe.js';\nimport { forgetPersistedSession } from './pty-sessions-file.js';\nimport { loadConfig } from '../platform/config.js';\nimport { hasEnvDelta, type EnvDelta } from '../platform/env-delta.js';\nimport { ensureHost, findHost, PtyHostClient, findHostPatient, PtyHostVersionError } from './pty-host-client.js';\nimport { logSwallowed, swallow } from '../platform/best-effort.js';\nimport { ASSISTANT_ID, prepareAssistantDir } from '../agents/assistant.js';\nimport { accountLoginId, accountOfLoginId } from './account-login-id.js';\nimport { accountLoginSpec } from './account-login.js';\n\n/**\n * `work web`'s view of the Claude PTYs. The PTYs themselves live in the\n * PTY host (`work pty-host`, see core/pty-host.ts), a separate long-lived\n * process — so restarting or rebuilding `work web` never kills an agent,\n * and a real terminal (`work attach`) can share the same session.\n *\n * This module resolves a dashboard session to a spawn spec, asks the host\n * to spawn it on first attach, and keeps a small cache of which sessions\n * have a live PTY for the synchronous badge path (`peekPty`).\n */\n\nlet workBin = process.argv[1] ?? '';\n/** Whether this server may start the PTY host when none runs (not the dev server: see configurePtyPool). */\nlet mayStartHost = true;\nlet client: PtyHostClient | null = null;\nlet live = new Set<string>();\n/** The pids of those PTYs' processes (the Claudes the app runs). */\nlet livePids = new Set<number>();\n/** Each live PTY's tool and last output (for output-status.ts). */\nlet outputs = new Map<string, PtyOutput & { pid: number }>();\nlet refreshTimer: NodeJS.Timeout | null = null;\n/** The heartbeat (host-health.ts): each list request is one. */\nconst beat: HostBeat = { known: false, lastOkAt: null, latencyMs: null, lastError: null, hostVersion: null };\n\n/** How the host answered lately (for GET /api/pty-host/health). */\nexport function hostBeat(): HostBeat {\n return { ...beat };\n}\nconst REFRESH_MS = 2000;\n\n/** Called by `work web` at startup with the resolved `work` binary path,\n * which is what the host is spawned from. */\nexport function configurePtyPool(opts: { workBin: string; startHost?: boolean }): void {\n workBin = opts.workBin;\n // The dev server (`work web --dev`) uses the host that runs and never starts one: started\n // from a checkout's build, the long-lived host that owns every Claude would outlive it,\n // and the installed work would become a client of the checkout's code.\n mayStartHost = opts.startHost ?? true;\n}\n\n/** The `work` binary path, for routes that launch `work attach`. */\nexport function getWorkBin(): string {\n return workBin;\n}\n\nasync function getClient(spawnIfMissing: boolean): Promise<PtyHostClient | null> {\n if (client) {\n // Cheap liveness re-check happens in refresh(); a dead host surfaces\n // as a failed call, which resets `client` below.\n return client;\n }\n const info = spawnIfMissing && mayStartHost ? await ensureHost(workBin) : await findHost();\n if (!info && spawnIfMissing && !mayStartHost)\n throw new Error(\n \"No PTY host is running, and the dev server doesn't start one: start the installed work (its app or `work web`) first.\",\n );\n if (!info) return null;\n client = new PtyHostClient(info);\n startRefresh();\n return client;\n}\n\nasync function refresh(): Promise<void> {\n const t0 = Date.now();\n try {\n const c = await getClient(false);\n if (!c) {\n beat.known = false;\n beat.hostVersion = null; // gone: the next host says its own\n live = new Set();\n livePids = new Set();\n outputs = new Map();\n return;\n }\n beat.known = true;\n const ptys = await c.list();\n beat.lastOkAt = Date.now();\n beat.latencyMs = beat.lastOkAt - t0;\n beat.lastError = null;\n // Asked once per host (the client keeps it): the release it runs, to say when it's older than this work.\n beat.hostVersion = await c.workVersion();\n live = new Set(ptys.filter((p) => !p.exited).map((p) => p.id));\n livePids = new Set(ptys.filter((p) => !p.exited).map((p) => p.pid));\n outputs = new Map(\n ptys.filter((p) => !p.exited).map((p) => [p.id, { tool: p.tool, lastOutputAt: p.lastOutputAt, startedAt: p.startedAt, pid: p.pid }]),\n );\n } catch (err) {\n // Host went away (or was restarted on a new port) — rediscover next tick.\n // A busy host is still a host (it is there, just not answering).\n beat.known = beat.known || err instanceof PtyHostBusyError;\n beat.lastError = (err as Error).message;\n client = null;\n beat.hostVersion = null;\n live = new Set();\n livePids = new Set();\n outputs = new Map();\n }\n}\n\nfunction startRefresh(): void {\n if (refreshTimer) return;\n refreshTimer = setInterval(() => void refresh(), REFRESH_MS);\n refreshTimer.unref?.();\n}\n\n/** Connect to an already-running host at `work web` startup so badges for\n * PTYs that survived a web restart show immediately. Never spawns. */\n/** Re-read the host's PTY list now (the periodic refresh can be seconds old,\n * or not have run at all right after `work web` started). */\nexport async function syncPtyPool(): Promise<void> {\n await refresh();\n}\n\nexport async function initPtyPool(): Promise<void> {\n await refresh().catch(() => {});\n startRefresh();\n}\n\n/**\n * After a reboot (or a host crash) nothing is running but\n * `pty-sessions.json` still lists the sessions that were live. Starting the\n * host restores them; do that when there's something to restore, so\n * reopening `work web` picks up where you left off. Returns how many\n * sessions the host will bring back (0 = nothing to do).\n */\nexport async function resumePersistedSessions(): Promise<number> {\n let count: number;\n try {\n count = Object.keys(dbPtySessions.read()).length;\n } catch {\n return 0;\n }\n if (count === 0) return 0;\n if (await findHost().catch(() => true)) return 0; // already running\n await getClient(true);\n await refresh();\n return count;\n}\n\n/**\n * Where Claude runs for a session — the same directory `work tree` launches\n * in: the worktree for a single repo, the group root (parent of the\n * sub-repos) for a group.\n */\nexport { ASSISTANT_ID };\n\n/** The assistant runs config `assistantAgent` (Claude Code by default), in its folder written for that agent. */\nexport function assistantSpec(): { cwd: string; tool: ReturnType<AgentAdapter['launch']['tool']>; agentEnv?: EnvDelta } {\n const settings = agentSettings();\n const agent = assistantAgent(settings);\n // Work's own session, not any session's: the configured default account (`launch.env(null)`).\n const agentEnv = agent.launch.env?.(null);\n return { cwd: prepareAssistantDir(agent), tool: agent.launch.tool(settings), ...(hasEnvDelta(agentEnv) ? { agentEnv } : {}) };\n}\n\nexport function spawnSpecFor(session: WorktreeSession): SpawnSpec | null {\n const first = session.paths[0];\n if (!first) return null;\n const cwd = session.isGroup ? path.dirname(first) : first;\n const config = loadConfig();\n const launch = agentFor(config, session).launch;\n // The session's account: its agent's folder env, applied by the host over whatever environment it starts with.\n const agentEnv = launch.env?.(session);\n return { cwd, tool: launch.tool(config), port: session.port, ...(hasEnvDelta(agentEnv) ? { agentEnv } : {}) };\n}\n\n/**\n * Ensure a live PTY exists for the session (spawning Claude in the host if\n * needed) and return the host WebSocket URL to attach to. Null for an\n * unknown session.\n */\nexport async function ensurePty(sessionId: string, extra: { initialPrompt?: string } = {}): Promise<string | null> {\n // An account's login terminal (the Accounts page) is no session: the agent's own CLI on that account (account-login.ts).\n const loginFor = accountOfLoginId(sessionId);\n // The dashboard assistant (Ctrl+K) is not a worktree: it runs in its own\n // folder, which is (re)written first (assistant.ts).\n const notASession = sessionId === ASSISTANT_ID || loginFor !== null;\n const session = notASession ? null : findSession(sessionId);\n // Not for a session being archived, or archived: its Claude was stopped on\n // purpose (a Terminal tab still open on it reconnects and would start it).\n const refused = notASession ? null : noClaudeBecause(session, sessionId);\n if (refused) throw new Error(refused);\n const base =\n loginFor !== null\n ? accountLoginSpec(loginFor, agentFor(loadConfig()).accounts)\n : sessionId === ASSISTANT_ID\n ? assistantSpec()\n : session\n ? spawnSpecFor(session)\n : null;\n if (!base) return null;\n // The first prompt only applies to a fresh spawn (the host ignores the\n // spec when the session's PTY is already running).\n const spec = extra.initialPrompt ? { ...base, initialPrompt: extra.initialPrompt } : base;\n\n let c = await getClient(true);\n if (!c) return null;\n // A host from before accounts would start it on its own environment — another account than the session's.\n if (setsEnv(spec.agentEnv) && !(await hostTakesAgentEnv(c)) && !(await runsIn(c, sessionId))) throw new Error(OLD_HOST_ACCOUNTS);\n try {\n await c.spawn(sessionId, spec);\n } catch (err) {\n // Stale client (host restarted on a new port) — retry once, fresh.\n client = null;\n c = await getClient(true);\n if (!c) throw err;\n await c.spawn(sessionId, spec);\n }\n live.add(sessionId);\n return c.attachUrl(sessionId);\n}\n\n/** Start an account's login terminal in the PTY host (or find it running); its id, for the terminal WebSocket. */\nexport async function startAccountLogin(name: string): Promise<string> {\n const id = accountLoginId(name);\n if (!(await ensurePty(id))) throw new Error('the PTY host could not be started');\n return id;\n}\n\n/** Stop an account's login terminal (nothing when none runs). */\nexport async function stopAccountLogin(name: string): Promise<void> {\n await disposePty(accountLoginId(name));\n}\n\n/** Side-effect-free check: does an active (non-exited) PTY exist for this\n * session? Served from the refresh cache — used by session-meta for the\n * \"running/idle\" badge, which must stay synchronous. */\n/** Every PTY in the host, fresh (never starts a host; [] without one). */\nexport async function listHostPtys(): Promise<PtyInfo[]> {\n const c = await getClient(false);\n return c ? c.list() : [];\n}\n\n/** Pids of the Claudes running in the PTY host (from the refresh cache). */\nexport function ptyPids(): ReadonlySet<number> {\n return livePids;\n}\n\n/** A status from its terminal output, for a session whose tool has no hooks (output-status.ts); null for Claude or no PTY. */\nexport function outputStatus(sessionId: string, now = Date.now()): SessionAttention | null {\n const o = outputs.get(sessionId);\n return o ? statusFromOutput(o, now) : null;\n}\n\n/** When a session's terminal last printed (ms, from the refresh cache); null with no PTY or a host that doesn't say. */\nexport function ptyLastOutputMs(sessionId: string): number | null {\n const at = outputs.get(sessionId)?.lastOutputAt;\n const ms = at ? Date.parse(at) : NaN;\n return Number.isFinite(ms) ? ms : null;\n}\n\n/** Its agent's process id in the host (from the refresh cache); null with no PTY. */\nexport function ptyPid(sessionId: string): number | null {\n return outputs.get(sessionId)?.pid ?? null;\n}\n\nexport function peekPty(sessionId: string): boolean {\n return live.has(sessionId);\n}\n\n/** A session's live PTY screen as text; null when there is none (never spawns). */\nexport async function readPtyScreen(sessionId: string): Promise<string | null> {\n if (!live.has(sessionId)) return null;\n const c = await getClient(false);\n return c ? c.screen(sessionId) : null;\n}\n\n/** Write to a session's live PTY. False when there is none (never spawns). */\nexport async function writeToPty(sessionId: string, data: string): Promise<boolean> {\n if (!live.has(sessionId)) return false;\n const c = await getClient(false);\n return c ? c.write(sessionId, data) : false;\n}\n\n/**\n * Restart a session's agent in the host, resuming its conversation, its terminals\n * kept attached (agent-restart.ts). A host from before that call: stopped and\n * started again (an open Terminal tab then offers Enter, as after a stop).\n */\nexport async function restartPty(sessionId: string): Promise<string | void> {\n let c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n let how: Awaited<ReturnType<PtyHostClient['restart']>>;\n try {\n how = await c.restart(sessionId);\n } catch (err) {\n // A stale client (the host restarted on a new port before the refresh noticed): once more, fresh.\n client = null;\n c = await getClient(false);\n if (!c) throw err;\n how = await c.restart(sessionId);\n }\n if (how === 'not-running') throw new Error('its agent is not running in the PTY host');\n if (how === 'unsupported') {\n await disposePty(sessionId);\n if (!(await ensurePty(sessionId))) throw new Error('its agent could not be started again');\n return OLD_HOST_RESTART;\n }\n}\n\n/**\n * Stop a session's agent and keep its session in the host (entry, restore record, attached terminals) until `resumePty`:\n * a switch of account moves its conversation files in between. `stopped`: a host from before the call stopped it the old\n * way (its terminals were told it ended; `resumePtyOnAccount` then starts it fresh); `gone`: nothing was running.\n */\nexport async function haltPty(sessionId: string): Promise<'halted' | 'stopped' | 'gone'> {\n let c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n let how: Awaited<ReturnType<PtyHostClient['halt']>>;\n try {\n how = await c.halt(sessionId);\n } catch (err) {\n // A stale client (the host restarted on a new port before the refresh noticed): once more, fresh.\n client = null;\n c = await getClient(false);\n if (!c) throw err;\n how = await c.halt(sessionId);\n }\n if (how === 'not-running') return 'gone';\n if (how === 'unsupported') {\n await disposePty(sessionId);\n return 'stopped';\n }\n return 'halted';\n}\n\n/** Why a switch of account can't be done in this PTY host now (it is from before accounts), or null: asked before halting. */\nexport async function accountSwitchRefusal(): Promise<string | null> {\n const c = await getClient(false);\n return c && !(await hostTakesAgentEnv(c)) ? OLD_HOST_ACCOUNTS : null;\n}\n\n/**\n * Start a halted session's agent again in place, on `opts.agentEnv` (its terminals carry on). `not-halted`: it isn't\n * halted any more — the host started it again by itself (HALT_RESUME_MS) or restarted, on its old spec.\n */\nexport async function resumePty(sessionId: string, opts: { agentEnv?: EnvDelta } = {}): Promise<'resumed' | 'not-halted'> {\n let c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n if (hasEnvDelta(opts.agentEnv) && !(await hostTakesAgentEnv(c))) throw new Error(OLD_HOST_ACCOUNTS);\n let how: Awaited<ReturnType<PtyHostClient['resume']>>;\n try {\n how = await c.resume(sessionId, opts);\n } catch (err) {\n client = null;\n c = await getClient(false);\n if (!c) throw err;\n how = await c.resume(sessionId, opts);\n }\n return how;\n}\n\n/**\n * Start the agent of a session `haltPty` stopped, on the account the session records NOW (after a switch: the new one;\n * after one that failed: the old): resumed in place with that environment, or — `stopped`, an older host — started\n * again from a fresh spec (its terminals show it ended; opening the session reconnects).\n */\nexport async function resumePtyOnAccount(sessionId: string, how: 'halted' | 'stopped'): Promise<string | void> {\n if (how === 'stopped') {\n if (!(await ensurePty(sessionId))) throw new Error('its agent could not be started again');\n return OLD_HOST_RESTART;\n }\n const session = findSession(sessionId);\n const spec = session ? spawnSpecFor(session) : null;\n if (!spec) throw new Error('unknown session');\n // Nothing in the delta means no account change to apply (the default, with no accounts configured): a plain resume.\n const agentEnv = hasEnvDelta(spec.agentEnv) ? spec.agentEnv : undefined;\n if ((await resumePty(sessionId, agentEnv ? { agentEnv } : {})) === 'resumed') return;\n // Started again meanwhile on its OLD spec (the host's own resume after HALT_RESUME_MS — a long move —, or a host\n // restart's restore): restarted in place on the account the session records now, so it doesn't stay on the old one.\n const c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n const restarted = await c.restart(sessionId, agentEnv ? { agentEnv } : {});\n if (restarted === 'restarted') return RESTARTED_AFTER_AUTO_RESUME;\n // Not running now (it ended), or a host that couldn't take the environment in place: started fresh from the new spec.\n if (restarted === 'unsupported') await disposePty(sessionId);\n if (!(await ensurePty(sessionId))) throw new Error('its agent could not be started again');\n return RESTARTED_AFTER_AUTO_RESUME;\n}\n\n/** What a switch says when its halted Claude had been started again (on the old account) before the move was done. */\nexport const RESTARTED_AFTER_AUTO_RESUME =\n 'it had been started again on its old account while the conversation moved, so it was restarted on the new one';\n\n/** Said when a session on a named account would start in a PTY host that drops the account (one from before accounts). */\nexport const OLD_HOST_ACCOUNTS = 'the PTY host is from before Claude accounts: run `work pty-host --restart`';\n\n/** The delta sets a variable (a session on a named account): what an older host would drop, starting it elsewhere. */\nconst setsEnv = (d: EnvDelta | undefined): boolean => !!d && Object.values(d).some((v) => typeof v === 'string');\n\n/** The host applies `agentEnv`; one that can't be asked right now is given the benefit of the doubt (its restart says). */\nasync function hostTakesAgentEnv(c: PtyHostClient): Promise<boolean> {\n const f = await c.features();\n return f === null || f.includes('agentEnv');\n}\n\n/** Its agent runs in this host now (a spawn would only attach to it). */\nasync function runsIn(c: PtyHostClient, sessionId: string): Promise<boolean> {\n return (await c.list()).some((p) => p.id === sessionId && !p.exited);\n}\n\n/** How a restart on a PTY host from before restart-in-place went: what differs, and the way to the real thing. */\nexport const OLD_HOST_RESTART =\n 'stopped and started again (an older PTY host: open terminals show it ended, and it runs with only the variables `hostEnv` keeps; `work pty-host --restart` gets restarts in place)';\n\n/** Kill one session's PTY (if any). Called before removing a worktree so\n * the Claude process doesn't hold its cwd open (Windows refuses to delete\n * a directory that is some process's working directory). */\nexport async function disposePty(sessionId: string): Promise<void> {\n live.delete(sessionId);\n let c = client;\n if (!c) {\n // A busy host (mid-restore) is waited for, not skipped: skipping left\n // Claude running inside the worktree about to be deleted. A host from\n // another build can't be talked to — nothing to do but proceed.\n let info: HostInfo | null;\n try {\n info = await findHostPatient();\n } catch (err) {\n if (err instanceof PtyHostVersionError) return;\n throw err; // still busy after waiting: let the caller report it\n }\n if (!info) return;\n c = new PtyHostClient(info);\n }\n await c.kill(sessionId).catch(swallow(`stop session ${sessionId} in the PTY host`));\n}\n\n/**\n * Stop a session's Claude in the PTY host before its worktree is deleted —\n * from any caller, including the CLI (`work remove` / prune / sync), which\n * doesn't run a pool. Never starts a host; waits for the process to exit\n * (the host's kill does) so Windows can then delete the directory.\n * Best-effort: no host, or a host that can't be reached, is a no-op.\n */\nexport async function stopSessionPty(target: string, branch: string): Promise<void> {\n const id = sessionIdFor({ target, branch } as WorktreeSession);\n live.delete(id);\n // Under the host START lock: a host that's starting holds it until it has\n // restored, so we either see it running (and kill the session) or know\n // none is — and then drop the session from the saved list so a later\n // start doesn't restore Claude into a worktree that's being deleted.\n const lock = hostStartLockPath();\n ensureFile(lock, '');\n await withFileLock(lock, async () => {\n let info;\n try {\n info = await findHostPatient();\n } catch (err) {\n // A host from another build can't be talked to; one still busy after\n // waiting is running and owns the session — leave both alone (and\n // never drop the saved entry: the host is what it belongs to).\n logSwallowed(`stop session ${id}: PTY host`, err);\n return;\n }\n if (info) await new PtyHostClient(info).kill(id).catch(swallow(`stop session ${id} in the PTY host`));\n else await forgetPersistedSession(id).catch(swallow(`forget saved session ${id}`));\n }).catch(swallow(`stop session ${id}: host start lock`));\n}\n\n/** `work web` shutdown. Deliberately does NOT kill anything: the PTYs belong\n * to the host and outlive the dashboard. Just stops polling. */\nexport function detachPtyPool(): void {\n if (refreshTimer) clearInterval(refreshTimer);\n refreshTimer = null;\n client = null;\n live = new Set();\n livePids = new Set();\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { AccountAdminError, type AgentAccounts } from '../agents/types.js';\nimport { getConfigDir } from '../platform/config.js';\nimport { hasEnvDelta } from '../platform/env-delta.js';\nimport type { SpawnSpec } from './pty-host-protocol.js';\n\n/**\n * The dashboard's login terminal for an account (the Accounts page's Add / Log in): the agent's own CLI on that account\n * (`admin.loginLaunch`, what `work account add` runs in your terminal), started in the PTY host under\n * `accountLoginId(name)` (account-login-id.ts) so the page can show it. A new conversation every time (`fresh`): there is\n * nothing to resume, and it runs in a folder of its own, never a worktree. Never restored by a host restart\n * (pty-registry.ts), and stopped when its panel closes. The agent starts in its own permission mode, as every start.\n */\n\n/** Where the login terminal runs: a folder of work's own (an agent may ask once whether to trust it). */\nexport const accountLoginDir = (): string => path.join(getConfigDir(), 'account-login');\n\n/** The host's spawn spec for an account's login terminal. Throws an AccountAdminError for an account work can't log in to. */\nexport function accountLoginSpec(\n name: string,\n accounts: Pick<AgentAccounts, 'has' | 'admin'> | undefined,\n dir: string = accountLoginDir(),\n): SpawnSpec {\n if (!accounts?.admin) throw new AccountAdminError('its accounts are not managed by work');\n if (!accounts.has(name)) throw new AccountAdminError(`no account “${name}”`);\n const { tool, agentEnv } = accounts.admin.loginLaunch(name);\n fs.mkdirSync(dir, { recursive: true });\n return { cwd: dir, tool, fresh: true, ...(hasEnvDelta(agentEnv) ? { agentEnv } : {}) };\n}\n"],"mappings":";;;;;;;;;;;;;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