@moberg_hr/work-tree 2.23.1 → 2.23.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 (227) hide show
  1. package/dist/{account-O62WFR7C.js → account-6ZQ3VFA2.js} +15 -13
  2. package/dist/{account-O62WFR7C.js.map → account-6ZQ3VFA2.js.map} +1 -1
  3. package/dist/{add-repo-FTAMMPVM.js → add-repo-WXDEKZRX.js} +6 -6
  4. package/dist/{answer-LKNMN2ZM.js → answer-L55DWMR5.js} +4 -4
  5. package/dist/{attach-A3KA4YTK.js → attach-KLVI7BHS.js} +9 -9
  6. package/dist/bin.js +2 -2
  7. package/dist/{block-3ZUFH2RO.js → block-BRNRP226.js} +6 -6
  8. package/dist/{broadcast-I23BZI3R.js → broadcast-GQE7H3MF.js} +2 -2
  9. package/dist/{catchup-G4EOJIZP.js → catchup-ZMG4OWF2.js} +7 -7
  10. package/dist/{child-MVNEFA2I.js → child-MPXXJ2QX.js} +4 -4
  11. package/dist/{chunk-N7T6NPE2.js → chunk-6S3DYLGH.js} +4 -4
  12. package/dist/{chunk-ZLPK2LQ3.js → chunk-7BH2PUYY.js} +3 -3
  13. package/dist/{chunk-NXS53NHR.js → chunk-7HQSILMM.js} +4 -4
  14. package/dist/{chunk-4HQEYZIM.js → chunk-A53OR6P5.js} +3 -3
  15. package/dist/{chunk-5QENUGSC.js → chunk-BBI4YQTS.js} +5 -5
  16. package/dist/{chunk-GHY7GZWN.js → chunk-BGQ6NUU7.js} +3 -3
  17. package/dist/{chunk-BI7HIO2I.js → chunk-BZOYUBK4.js} +2 -2
  18. package/dist/{chunk-6PZ7RCXK.js → chunk-C5BBVVHW.js} +2 -2
  19. package/dist/{chunk-INXHVNMZ.js → chunk-CRAGAIOS.js} +5 -5
  20. package/dist/{chunk-HQDQRC4F.js → chunk-DK3UMOX7.js} +2 -2
  21. package/dist/{chunk-TL7VLRRF.js → chunk-DNC2ZJOF.js} +3 -3
  22. package/dist/chunk-DYKA3LO3.js +9 -0
  23. package/dist/{chunk-MQXMYVZV.js → chunk-G4VKMMIC.js} +8 -8
  24. package/dist/{chunk-ZX4ONO5Y.js → chunk-HBYXSFLN.js} +4 -4
  25. package/dist/{chunk-HPUD5IGB.js → chunk-HO5KESIB.js} +2 -2
  26. package/dist/{chunk-4FN45EAF.js → chunk-HUGHF45U.js} +2 -2
  27. package/dist/{chunk-5SXTMOO6.js → chunk-IUVMVNIO.js} +4 -4
  28. package/dist/chunk-JVOQSU6R.js +151 -0
  29. package/dist/chunk-JVOQSU6R.js.map +1 -0
  30. package/dist/{chunk-OPV6BE3W.js → chunk-K6FD5WDW.js} +4 -4
  31. package/dist/{chunk-ET5K6S5H.js → chunk-KJAE7WO5.js} +21 -10
  32. package/dist/chunk-KJAE7WO5.js.map +1 -0
  33. package/dist/{chunk-IXZOZZGD.js → chunk-KWJ6S4NZ.js} +2 -2
  34. package/dist/{chunk-U4XSBYQW.js → chunk-LCYYJFSZ.js} +3 -3
  35. package/dist/{chunk-ZMJR4Z6O.js → chunk-LOFGDH5B.js} +2 -2
  36. package/dist/{chunk-YKTJL4SW.js → chunk-LW6VCL6S.js} +5 -5
  37. package/dist/{chunk-44QJVFOF.js → chunk-M2P722BR.js} +2 -2
  38. package/dist/{chunk-VH5FRKJM.js → chunk-MMEFW2PI.js} +2 -2
  39. package/dist/{chunk-ETAPX4JN.js → chunk-MYASALCU.js} +3 -3
  40. package/dist/{chunk-DHZ5DF6Y.js → chunk-MYXEX6BB.js} +2 -1
  41. package/dist/{chunk-WOY35FXP.js → chunk-NLU6MBYT.js} +8 -6
  42. package/dist/chunk-NLU6MBYT.js.map +1 -0
  43. package/dist/{chunk-W5YYTITQ.js → chunk-P53UYZZ4.js} +2 -2
  44. package/dist/{chunk-U2A2DHWP.js → chunk-PSALWCBD.js} +2 -2
  45. package/dist/{chunk-IVS2MAHD.js → chunk-QAIG5FSQ.js} +2 -2
  46. package/dist/{chunk-2MJQTFTI.js → chunk-QMWV4UKB.js} +3 -3
  47. package/dist/{chunk-MVBBESXK.js → chunk-QSSCVTFG.js} +3 -3
  48. package/dist/{chunk-ZNRPBP5O.js → chunk-RGKGJOES.js} +135 -4
  49. package/dist/chunk-RGKGJOES.js.map +1 -0
  50. package/dist/{chunk-24FQ5XXN.js → chunk-SF3DIIKN.js} +3 -3
  51. package/dist/{chunk-GTFMUWK6.js → chunk-SUHANL3G.js} +3 -3
  52. package/dist/{chunk-XTAYJDL2.js → chunk-VNZBFVGY.js} +3 -3
  53. package/dist/{chunk-IXC6EXVJ.js → chunk-VPZ5ILKT.js} +3 -3
  54. package/dist/{chunk-FHC6KHIH.js → chunk-VQEMPGJL.js} +2 -2
  55. package/dist/{chunk-2FNYJEOH.js → chunk-WH6DAD6D.js} +2 -2
  56. package/dist/{chunk-GN7EAXHU.js → chunk-XB4SCJWD.js} +82 -20
  57. package/dist/chunk-XB4SCJWD.js.map +1 -0
  58. package/dist/{chunk-HUWWMTNG.js → chunk-XL4YNA3L.js} +1 -1
  59. package/dist/chunk-XL4YNA3L.js.map +1 -0
  60. package/dist/{chunk-HNZ736XN.js → chunk-XT3FON6A.js} +2 -2
  61. package/dist/{chunk-ROEEXEN7.js → chunk-XWUX474Q.js} +4 -150
  62. package/dist/chunk-XWUX474Q.js.map +1 -0
  63. package/dist/{chunk-XWKN2HJD.js → chunk-ZHK5XOV5.js} +56 -56
  64. package/dist/{chunk-IRDWXDID.js → chunk-ZPDCVDE2.js} +2 -2
  65. package/dist/{cleanup-ANVUCOBK.js → cleanup-DRELB6UC.js} +22 -22
  66. package/dist/{cli-CAF6VCVO.js → cli-C3U2BC44.js} +3 -3
  67. package/dist/{color-7CQNI6Y4.js → color-T75ANAWG.js} +4 -4
  68. package/dist/{config-EXQY26W4.js → config-KI6JOXKW.js} +3 -3
  69. package/dist/{coordinate-LRY7LXS6.js → coordinate-4PPZN4U4.js} +5 -5
  70. package/dist/{diff-JRK3AUD5.js → diff-NDZPRQV7.js} +4 -4
  71. package/dist/{digest-2AFW3WBL.js → digest-H5YFX5WR.js} +4 -4
  72. package/dist/{fork-DSNMPWUE.js → fork-HHHATXVI.js} +18 -18
  73. package/dist/{history-RFIDCGQY.js → history-3Z7AS2AC.js} +2 -2
  74. package/dist/{hook-XBALB337.js → hook-KOK7NKCO.js} +8 -8
  75. package/dist/{hydrate-DAEY4PB6.js → hydrate-VI3XSZQH.js} +2 -2
  76. package/dist/{init-4BK3T34W.js → init-7NOKRHNJ.js} +6 -6
  77. package/dist/{keep-57TUKADV.js → keep-G62GSDOQ.js} +4 -4
  78. package/dist/{list-DRQRIT6U.js → list-CEVAZQ4V.js} +2 -2
  79. package/dist/{move-UEHJ375P.js → move-ISAW6RDM.js} +7 -7
  80. package/dist/{note-FHPDVBRI.js → note-YIVFXTGM.js} +4 -4
  81. package/dist/{overlaps-GKAKEUB6.js → overlaps-YBEHBRRK.js} +5 -5
  82. package/dist/{pin-CFTQDPPC.js → pin-J4IDSHRG.js} +4 -4
  83. package/dist/{pr-ZP4COZEZ.js → pr-Z7CPBBGT.js} +13 -13
  84. package/dist/{prune-IQB2T45B.js → prune-UA3UDZSM.js} +19 -19
  85. package/dist/{pty-host-BPFGJFBC.js → pty-host-JIQUP62K.js} +49 -7
  86. package/dist/pty-host-JIQUP62K.js.map +1 -0
  87. package/dist/{read-DHJ6VY44.js → read-DG4PCLFH.js} +4 -4
  88. package/dist/{recent-OZW2ZNJ4.js → recent-PGD6QYAH.js} +7 -7
  89. package/dist/{remove-MW25RLNV.js → remove-TPLA64HP.js} +20 -20
  90. package/dist/{report-II75EKM6.js → report-K3OTT2ED.js} +4 -4
  91. package/dist/{restart-4BGVRBX6.js → restart-477IX2JX.js} +4 -4
  92. package/dist/{resume-4J53KDCO.js → resume-OYBAJCYE.js} +7 -7
  93. package/dist/{review-WKB3K6LI.js → review-6PWFSBAO.js} +3 -3
  94. package/dist/{run-YS2D7WAQ.js → run-XEHF2N4A.js} +2 -2
  95. package/dist/{screen-VVRNQXVW.js → screen-SFU6TCDV.js} +4 -4
  96. package/dist/{search-MKYCKZF4.js → search-VJ3BGWPX.js} +2 -2
  97. package/dist/{section-Y6RDD3MN.js → section-ZLINSTGS.js} +4 -4
  98. package/dist/{send-AZM2XKN2.js → send-NBP2WYBG.js} +5 -5
  99. package/dist/{sessions-OER6VNQJ.js → sessions-UT4I7A43.js} +14 -14
  100. package/dist/{show-33VV3XCF.js → show-RK2EWOR6.js} +3 -3
  101. package/dist/{snooze-OFYZVVYS.js → snooze-T2WWIKZN.js} +4 -4
  102. package/dist/{start-OEQ5VW7Y.js → start-AWHOIA3Q.js} +4 -4
  103. package/dist/{status-HPYMNO2T.js → status-QE2DA6RR.js} +5 -5
  104. package/dist/{stop-QNICDWAU.js → stop-YOU3P3ZR.js} +4 -4
  105. package/dist/{sync-RH3M47QK.js → sync-74EFTPBJ.js} +19 -19
  106. package/dist/{time-PM72GK5W.js → time-ZGMZZ5OY.js} +5 -5
  107. package/dist/{time-actions-O3MCB7FU.js → time-actions-VAGRSY5B.js} +2 -2
  108. package/dist/{timesheet-HJXQ4KHL.js → timesheet-N74LPF5M.js} +11 -10
  109. package/dist/timesheet-N74LPF5M.js.map +1 -0
  110. package/dist/{tree-RGT736E3.js → tree-FXTCWC6D.js} +18 -18
  111. package/dist/{update-CMYVBWV3.js → update-5QSRHIWH.js} +9 -9
  112. package/dist/{usage-VEKD3JPL.js → usage-CW7CDFU3.js} +4 -4
  113. package/dist/{wait-RQZU3KDY.js → wait-XXC3I6DK.js} +5 -5
  114. package/dist/wd-bin.js +2 -2
  115. package/dist/web/assets/{PtyView-qP6blm2-.js → PtyView-BLTE5F3E.js} +2 -2
  116. package/dist/web/assets/{PtyView-qP6blm2-.js.map → PtyView-BLTE5F3E.js.map} +1 -1
  117. package/dist/web/assets/{index-DuFRboh6.js → index-BiadbzE6.js} +59 -59
  118. package/dist/web/assets/index-BiadbzE6.js.map +1 -0
  119. package/dist/web/assets/{index-yBTfBzDm.css → index-CfTmdABt.css} +1 -1
  120. package/dist/web/index.html +2 -2
  121. package/dist/{web-GOCU26ZD.js → web-SUSR4IAK.js} +87 -54
  122. package/dist/web-SUSR4IAK.js.map +1 -0
  123. package/npm-shrinkwrap.json +2 -2
  124. package/package.json +1 -1
  125. package/dist/chunk-ET5K6S5H.js.map +0 -1
  126. package/dist/chunk-GN7EAXHU.js.map +0 -1
  127. package/dist/chunk-HUWWMTNG.js.map +0 -1
  128. package/dist/chunk-NRX5V443.js +0 -9
  129. package/dist/chunk-ROEEXEN7.js.map +0 -1
  130. package/dist/chunk-WOY35FXP.js.map +0 -1
  131. package/dist/chunk-ZNRPBP5O.js.map +0 -1
  132. package/dist/pty-host-BPFGJFBC.js.map +0 -1
  133. package/dist/timesheet-HJXQ4KHL.js.map +0 -1
  134. package/dist/web/assets/index-DuFRboh6.js.map +0 -1
  135. package/dist/web-GOCU26ZD.js.map +0 -1
  136. /package/dist/{add-repo-FTAMMPVM.js.map → add-repo-WXDEKZRX.js.map} +0 -0
  137. /package/dist/{answer-LKNMN2ZM.js.map → answer-L55DWMR5.js.map} +0 -0
  138. /package/dist/{attach-A3KA4YTK.js.map → attach-KLVI7BHS.js.map} +0 -0
  139. /package/dist/{block-3ZUFH2RO.js.map → block-BRNRP226.js.map} +0 -0
  140. /package/dist/{broadcast-I23BZI3R.js.map → broadcast-GQE7H3MF.js.map} +0 -0
  141. /package/dist/{catchup-G4EOJIZP.js.map → catchup-ZMG4OWF2.js.map} +0 -0
  142. /package/dist/{child-MVNEFA2I.js.map → child-MPXXJ2QX.js.map} +0 -0
  143. /package/dist/{chunk-N7T6NPE2.js.map → chunk-6S3DYLGH.js.map} +0 -0
  144. /package/dist/{chunk-ZLPK2LQ3.js.map → chunk-7BH2PUYY.js.map} +0 -0
  145. /package/dist/{chunk-NXS53NHR.js.map → chunk-7HQSILMM.js.map} +0 -0
  146. /package/dist/{chunk-4HQEYZIM.js.map → chunk-A53OR6P5.js.map} +0 -0
  147. /package/dist/{chunk-5QENUGSC.js.map → chunk-BBI4YQTS.js.map} +0 -0
  148. /package/dist/{chunk-GHY7GZWN.js.map → chunk-BGQ6NUU7.js.map} +0 -0
  149. /package/dist/{chunk-BI7HIO2I.js.map → chunk-BZOYUBK4.js.map} +0 -0
  150. /package/dist/{chunk-6PZ7RCXK.js.map → chunk-C5BBVVHW.js.map} +0 -0
  151. /package/dist/{chunk-INXHVNMZ.js.map → chunk-CRAGAIOS.js.map} +0 -0
  152. /package/dist/{chunk-HQDQRC4F.js.map → chunk-DK3UMOX7.js.map} +0 -0
  153. /package/dist/{chunk-TL7VLRRF.js.map → chunk-DNC2ZJOF.js.map} +0 -0
  154. /package/dist/{chunk-NRX5V443.js.map → chunk-DYKA3LO3.js.map} +0 -0
  155. /package/dist/{chunk-MQXMYVZV.js.map → chunk-G4VKMMIC.js.map} +0 -0
  156. /package/dist/{chunk-ZX4ONO5Y.js.map → chunk-HBYXSFLN.js.map} +0 -0
  157. /package/dist/{chunk-HPUD5IGB.js.map → chunk-HO5KESIB.js.map} +0 -0
  158. /package/dist/{chunk-4FN45EAF.js.map → chunk-HUGHF45U.js.map} +0 -0
  159. /package/dist/{chunk-5SXTMOO6.js.map → chunk-IUVMVNIO.js.map} +0 -0
  160. /package/dist/{chunk-OPV6BE3W.js.map → chunk-K6FD5WDW.js.map} +0 -0
  161. /package/dist/{chunk-IXZOZZGD.js.map → chunk-KWJ6S4NZ.js.map} +0 -0
  162. /package/dist/{chunk-U4XSBYQW.js.map → chunk-LCYYJFSZ.js.map} +0 -0
  163. /package/dist/{chunk-ZMJR4Z6O.js.map → chunk-LOFGDH5B.js.map} +0 -0
  164. /package/dist/{chunk-YKTJL4SW.js.map → chunk-LW6VCL6S.js.map} +0 -0
  165. /package/dist/{chunk-44QJVFOF.js.map → chunk-M2P722BR.js.map} +0 -0
  166. /package/dist/{chunk-VH5FRKJM.js.map → chunk-MMEFW2PI.js.map} +0 -0
  167. /package/dist/{chunk-ETAPX4JN.js.map → chunk-MYASALCU.js.map} +0 -0
  168. /package/dist/{chunk-DHZ5DF6Y.js.map → chunk-MYXEX6BB.js.map} +0 -0
  169. /package/dist/{chunk-W5YYTITQ.js.map → chunk-P53UYZZ4.js.map} +0 -0
  170. /package/dist/{chunk-U2A2DHWP.js.map → chunk-PSALWCBD.js.map} +0 -0
  171. /package/dist/{chunk-IVS2MAHD.js.map → chunk-QAIG5FSQ.js.map} +0 -0
  172. /package/dist/{chunk-2MJQTFTI.js.map → chunk-QMWV4UKB.js.map} +0 -0
  173. /package/dist/{chunk-MVBBESXK.js.map → chunk-QSSCVTFG.js.map} +0 -0
  174. /package/dist/{chunk-24FQ5XXN.js.map → chunk-SF3DIIKN.js.map} +0 -0
  175. /package/dist/{chunk-GTFMUWK6.js.map → chunk-SUHANL3G.js.map} +0 -0
  176. /package/dist/{chunk-XTAYJDL2.js.map → chunk-VNZBFVGY.js.map} +0 -0
  177. /package/dist/{chunk-IXC6EXVJ.js.map → chunk-VPZ5ILKT.js.map} +0 -0
  178. /package/dist/{chunk-FHC6KHIH.js.map → chunk-VQEMPGJL.js.map} +0 -0
  179. /package/dist/{chunk-2FNYJEOH.js.map → chunk-WH6DAD6D.js.map} +0 -0
  180. /package/dist/{chunk-HNZ736XN.js.map → chunk-XT3FON6A.js.map} +0 -0
  181. /package/dist/{chunk-XWKN2HJD.js.map → chunk-ZHK5XOV5.js.map} +0 -0
  182. /package/dist/{chunk-IRDWXDID.js.map → chunk-ZPDCVDE2.js.map} +0 -0
  183. /package/dist/{cleanup-ANVUCOBK.js.map → cleanup-DRELB6UC.js.map} +0 -0
  184. /package/dist/{cli-CAF6VCVO.js.map → cli-C3U2BC44.js.map} +0 -0
  185. /package/dist/{color-7CQNI6Y4.js.map → color-T75ANAWG.js.map} +0 -0
  186. /package/dist/{config-EXQY26W4.js.map → config-KI6JOXKW.js.map} +0 -0
  187. /package/dist/{coordinate-LRY7LXS6.js.map → coordinate-4PPZN4U4.js.map} +0 -0
  188. /package/dist/{diff-JRK3AUD5.js.map → diff-NDZPRQV7.js.map} +0 -0
  189. /package/dist/{digest-2AFW3WBL.js.map → digest-H5YFX5WR.js.map} +0 -0
  190. /package/dist/{fork-DSNMPWUE.js.map → fork-HHHATXVI.js.map} +0 -0
  191. /package/dist/{history-RFIDCGQY.js.map → history-3Z7AS2AC.js.map} +0 -0
  192. /package/dist/{hook-XBALB337.js.map → hook-KOK7NKCO.js.map} +0 -0
  193. /package/dist/{hydrate-DAEY4PB6.js.map → hydrate-VI3XSZQH.js.map} +0 -0
  194. /package/dist/{init-4BK3T34W.js.map → init-7NOKRHNJ.js.map} +0 -0
  195. /package/dist/{keep-57TUKADV.js.map → keep-G62GSDOQ.js.map} +0 -0
  196. /package/dist/{list-DRQRIT6U.js.map → list-CEVAZQ4V.js.map} +0 -0
  197. /package/dist/{move-UEHJ375P.js.map → move-ISAW6RDM.js.map} +0 -0
  198. /package/dist/{note-FHPDVBRI.js.map → note-YIVFXTGM.js.map} +0 -0
  199. /package/dist/{overlaps-GKAKEUB6.js.map → overlaps-YBEHBRRK.js.map} +0 -0
  200. /package/dist/{pin-CFTQDPPC.js.map → pin-J4IDSHRG.js.map} +0 -0
  201. /package/dist/{pr-ZP4COZEZ.js.map → pr-Z7CPBBGT.js.map} +0 -0
  202. /package/dist/{prune-IQB2T45B.js.map → prune-UA3UDZSM.js.map} +0 -0
  203. /package/dist/{read-DHJ6VY44.js.map → read-DG4PCLFH.js.map} +0 -0
  204. /package/dist/{recent-OZW2ZNJ4.js.map → recent-PGD6QYAH.js.map} +0 -0
  205. /package/dist/{remove-MW25RLNV.js.map → remove-TPLA64HP.js.map} +0 -0
  206. /package/dist/{report-II75EKM6.js.map → report-K3OTT2ED.js.map} +0 -0
  207. /package/dist/{restart-4BGVRBX6.js.map → restart-477IX2JX.js.map} +0 -0
  208. /package/dist/{resume-4J53KDCO.js.map → resume-OYBAJCYE.js.map} +0 -0
  209. /package/dist/{review-WKB3K6LI.js.map → review-6PWFSBAO.js.map} +0 -0
  210. /package/dist/{run-YS2D7WAQ.js.map → run-XEHF2N4A.js.map} +0 -0
  211. /package/dist/{screen-VVRNQXVW.js.map → screen-SFU6TCDV.js.map} +0 -0
  212. /package/dist/{search-MKYCKZF4.js.map → search-VJ3BGWPX.js.map} +0 -0
  213. /package/dist/{section-Y6RDD3MN.js.map → section-ZLINSTGS.js.map} +0 -0
  214. /package/dist/{send-AZM2XKN2.js.map → send-NBP2WYBG.js.map} +0 -0
  215. /package/dist/{sessions-OER6VNQJ.js.map → sessions-UT4I7A43.js.map} +0 -0
  216. /package/dist/{show-33VV3XCF.js.map → show-RK2EWOR6.js.map} +0 -0
  217. /package/dist/{snooze-OFYZVVYS.js.map → snooze-T2WWIKZN.js.map} +0 -0
  218. /package/dist/{start-OEQ5VW7Y.js.map → start-AWHOIA3Q.js.map} +0 -0
  219. /package/dist/{status-HPYMNO2T.js.map → status-QE2DA6RR.js.map} +0 -0
  220. /package/dist/{stop-QNICDWAU.js.map → stop-YOU3P3ZR.js.map} +0 -0
  221. /package/dist/{sync-RH3M47QK.js.map → sync-74EFTPBJ.js.map} +0 -0
  222. /package/dist/{time-PM72GK5W.js.map → time-ZGMZZ5OY.js.map} +0 -0
  223. /package/dist/{time-actions-O3MCB7FU.js.map → time-actions-VAGRSY5B.js.map} +0 -0
  224. /package/dist/{tree-RGT736E3.js.map → tree-FXTCWC6D.js.map} +0 -0
  225. /package/dist/{update-CMYVBWV3.js.map → update-5QSRHIWH.js.map} +0 -0
  226. /package/dist/{usage-VEKD3JPL.js.map → usage-CW7CDFU3.js.map} +0 -0
  227. /package/dist/{wait-RQZU3KDY.js.map → wait-XXC3I6DK.js.map} +0 -0
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/version.ts
4
- var VERSION = true ? "2.23.1" : "dev";
5
-
6
- export {
7
- VERSION
8
- };
9
- //# sourceMappingURL=chunk-NRX5V443.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/sessions/account-switch-rules.ts","../src/core/sessions/account-switch.ts","../src/core/sessions/account-switch-deps.ts","../src/core/sessions/account-users.ts","../src/core/sessions/account-admin.ts"],"sourcesContent":["/**\n * When a switch of account is refused before anything is stopped or moved — the rules the real switch\n * (account-switch.ts) and the demo's (server/demo/demo-accounts.ts) share. Pure: no imports.\n */\n\n/** An account as the rules see it (agents/types.ts `AccountInfo`; the wire's `AccountWire`). */\nexport interface SwitchAccountInfo {\n name: string;\n /** Logged in; null: can't tell (macOS keeps Claude's credentials in the keychain) — allowed. */\n loggedIn: boolean | null;\n}\n\nexport interface SwitchFacts {\n /** Archived, or being archived right now. */\n archived: boolean;\n /** Its agent's accounts and the one it is on; null: its agent has none. */\n accounts: { list: readonly SwitchAccountInfo[]; current: string } | null;\n /** Where a switch being done now goes; null: none. */\n pendingTo: string | null;\n /** Its agent runs in the PTY host (a switch can stop and start it there). */\n inHost: boolean;\n /** Its agent runs in a terminal outside work. */\n runningOutside: boolean;\n}\n\nexport type SwitchRefusal = { status: 400 | 409; error: string };\n\n/** Why the session can't be moved to `to` (status and reason), or null. In the order the user is told them. */\nexport function switchRefusal(to: string, f: SwitchFacts): SwitchRefusal | null {\n if (f.archived) return { status: 409, error: 'it is archived: restore it first' };\n if (!f.accounts) return { status: 409, error: \"its agent doesn't have accounts\" };\n const target = f.accounts.list.find((a) => a.name === to);\n if (!target) return { status: 400, error: `no account “${to}” (see \\`work account list\\`)` };\n if (target.loggedIn === false)\n return { status: 409, error: `nobody is logged in on “${to}”: run \\`work account add ${to}\\` again to log in, or /login on it` };\n if (f.pendingTo !== null) return { status: 409, error: `a switch is already being done (to ${f.pendingTo || 'another account'})` };\n if (f.accounts.current === to) return { status: 409, error: `it already runs on “${to}”` };\n if (!f.inHost && f.runningOutside)\n return {\n status: 409,\n error: 'its Claude runs in a terminal outside work: stop it there first (its conversation would be moved from under it)',\n };\n return null;\n}\n","import type { AccountInfo } from '../agents/types.js';\nimport type { WorktreeSession } from './session-types.js';\nimport type { ActivityLog } from '../platform/activity.js';\nimport { switchRefusal } from './account-switch-rules.js';\n\n/**\n * Moving a session to another account of its agent (Claude: another login, for when the first one's limit runs out).\n * The policy is here; I/O is passed in (account-routes.ts and web-server.ts give the real one, tests a fake).\n *\n * Refused: an unknown or archived session, an agent with no accounts, an unknown account, one nobody is logged in to, the\n * account it is on, a Claude running in a terminal outside work (a switch can't stop it), one switch already being done.\n *\n * Not running in the PTY host: its conversations move and the account is recorded — the next start uses it. Running and\n * idle: its Claude is halted in the host (stopped, its terminals kept), the conversations move, the account is recorded, and it\n * is resumed in place on the new account — in that order, so nothing writes into the old folder while it moves. Working, or waiting\n * on you: the same, at once — its turn is interrupted (asked for: a switch that waited for the turn to end kept a session\n * whose limit ran out on the old account). The turn it interrupted is continued: once the restarted Claude is ready,\n * work tells it to (`carryOn`, asked for: \"send continue after the switch is done\", for the interrupted ones only); an\n * idle session is left alone. Without `carryOn` the answer and Activity say to tell it. An agent restart waiting\n * for that turn is dropped (the switch restarts it), and one asked for meanwhile is folded into it (account-switch-link.ts).\n */\n\nexport interface AccountSwitchDeps {\n session: (id: string) => WorktreeSession | null;\n /** Being archived right now (its Claude was stopped on purpose, and mustn't be started again). */\n beingArchived: (id: string) => boolean;\n /** Its agent's accounts; null: its agent has none. */\n accounts: (session: WorktreeSession) => { list: AccountInfo[]; current: string } | null;\n /** Move its conversations to `to`'s folders (puts back what it moved when it fails, and throws). */\n switchFiles: (session: WorktreeSession, to: string) => Promise<{ moved: string[] }>;\n /** Record the account on the session, in one transaction. */\n record: (session: WorktreeSession, to: string) => Promise<void>;\n /** Its Claude runs in the PTY host. */\n hostRuns: (id: string) => boolean;\n /** Its Claude runs in a terminal outside work. */\n runningOutside: (id: string) => boolean;\n /** A folder whose conversations the switch would move where another agent (of any account, not this session's own in\n * the host) runs now — its files would move from under it; null: none. */\n othersRunningIn?: (session: WorktreeSession, id: string) => string | null;\n /** Why the PTY host can't run it on another account (one from before accounts), or null. Asked before anything stops. */\n hostRefusal?: () => Promise<string | null>;\n /** Working, or waiting on you: a switch doesn't wait for it, but says the turn it interrupted. */\n busy: (id: string, opts?: { turnEnded?: boolean }) => boolean;\n /** Stop its Claude in the host and keep its session (terminals attached) until `resume`: the files move only after it is stopped.\n * `stopped`: an older host stopped it the old way; `gone`: nothing was running. */\n halt: (id: string) => Promise<'halted' | 'stopped' | 'gone'>;\n /** Start it again after `halt`, on the account the session records now (so the old one after a switch that failed): in place\n * when it was `halted` (its terminals carry on), from a fresh spec when `stopped` (an older host). A string: how it went instead. */\n resume: (id: string, how: 'halted' | 'stopped') => Promise<string | void>;\n /** One line of what a switch decided, for the Activity panel. */\n note?: (id: string, text: string, level: 'action' | 'info' | 'warn') => void;\n changed?: () => void;\n /** Drop an agent restart waiting for its turn (agent-restart.ts): the switch restarts it anyway. True when one was waiting. */\n cancelRestart?: (id: string) => boolean;\n /** Tell its restarted Claude to continue, once it is ready for a prompt. Resolves whether it was told. */\n carryOn?: (id: string) => Promise<boolean>;\n}\n\nexport type SwitchOutcome = 'switched' | 'recorded';\n\nexport type SwitchResult =\n | { ok: true; outcome: SwitchOutcome; moved?: number; interrupted?: boolean; continued?: boolean }\n | { ok: false; status: 400 | 404 | 409 | 502; error: string };\n\n/** Said of a switch that stopped its Claude mid-turn: the conversation is there, the turn's remaining work isn't done. */\nexport const INTERRUPTED = '; it was working or waiting on you, so that turn was interrupted: tell it to continue';\n/** Said when work tells it to continue itself (asked for: \"send continue after the switch is done\"). */\nexport const CONTINUED = '; it was working or waiting on you, so that turn was interrupted: work tells it to continue once it is ready';\n\nconst msg = (err: unknown) => (err instanceof Error ? err.message : String(err));\n\nexport function createAccountSwitcher(deps: AccountSwitchDeps) {\n /** Where each switch being done goes. */\n const targets = new Map<string, string>();\n\n const name = (s: WorktreeSession) => `${s.target} ${s.branch}`;\n\n /** Move the files and record the account; a failed record puts the files back. Returns how many entries moved. */\n const moveAndRecord = async (s: WorktreeSession, to: string, from: string): Promise<number> => {\n const { moved } = await deps.switchFiles(s, to);\n try {\n await deps.record(s, to);\n } catch (err) {\n // The files are in the new account's folders and the session still says the old one: back, or its --continue finds\n // nothing. A move back that fails is said with the error (its message names what is stuck where).\n const back = await deps.switchFiles({ ...s, account: to }, from).then(\n () => '',\n (e2: unknown) => `; and its conversations couldn't all be moved back: ${msg(e2)}`,\n );\n throw new Error(`${msg(err)}${back}`, { cause: err });\n }\n return moved.length;\n };\n\n /** A switch of a session running in the host: the stop, the move, the record, the start again. */\n const perform = async (id: string, to: string): Promise<{ moved: number; interrupted: boolean; continued: boolean }> => {\n const s = deps.session(id);\n try {\n if (!s) throw new Error('the session is gone');\n if (s.archivedAt || deps.beingArchived(id)) throw new Error('it was archived meanwhile');\n const acc = deps.accounts(s);\n if (!acc) throw new Error('its agent has no accounts');\n const from = acc.current;\n if (from === to) return { moved: 0, interrupted: false, continued: false };\n const before = await refusalBeforeStop(s, id);\n if (before) throw new Error(`stays on ${from}: ${before}`);\n // A restart of its agent that waited for this turn too would stop it a second time: the switch's restart does its job.\n if (deps.cancelRestart?.(id)) deps.note?.(id, 'its agent restart that waited for this turn is done by the switch instead', 'info');\n // Stopped first: a running (or just exiting) Claude writes to its transcript, and on Windows holds the file.\n let halted: 'halted' | 'stopped' | null = null;\n let interrupted = false;\n if (deps.hostRuns(id)) {\n interrupted = deps.busy(id);\n let h: 'halted' | 'stopped' | 'gone';\n try {\n h = await deps.halt(id);\n } catch (err) {\n throw new Error(`stays on ${from}: couldn't stop its Claude: ${msg(err)}`, { cause: err });\n }\n if (h !== 'gone') halted = h;\n }\n /** Start it again on the account the session records (still the old one until the record is made). */\n const resume = async (): Promise<string | void> => (halted ? deps.resume(id, halted) : undefined);\n let moved: number;\n try {\n moved = await moveAndRecord(s, to, from);\n } catch (err) {\n // Put back (the move rolled itself back, a failed record moved the files back): it goes on running on the account it has.\n const back = await resume().then(\n () => '',\n (e2: unknown) => ` (and couldn't start its Claude again: ${msg(e2)}; opening the session starts it)`,\n );\n throw new Error(`stays on ${from}: ${msg(err)}${back}`, { cause: err });\n }\n if (!halted) {\n deps.note?.(id, `moved to the ${to} account (${moved} entries moved; its next start uses it)`, 'action');\n return { moved, interrupted: false, continued: false };\n }\n try {\n const how = await resume();\n // Interrupted by this switch: told to continue, once its Claude is up — not awaited, so the switch answers at\n // once; the note says how that went. Only that turn: an idle session is left alone (asked for: \"just interrupted ones\").\n const continued = interrupted && !!deps.carryOn;\n const cut = continued ? CONTINUED : interrupted ? INTERRUPTED : '';\n deps.note?.(id, `moved to the ${to} account: its Claude restarted on it${how ? ` (${how})` : ''}${cut}`, 'action');\n if (continued)\n void deps.carryOn!(id).then(\n (told) =>\n deps.note?.(\n id,\n told ? 'told it to continue' : \"couldn't tell it to continue (it didn't get ready in time): send it a message to carry on\",\n told ? 'action' : 'warn',\n ),\n (err: unknown) => deps.note?.(id, `couldn't tell it to continue: ${msg(err)}`, 'warn'),\n );\n return { moved, interrupted, continued };\n } catch (err) {\n // The account is recorded and the files are there: opening the session starts it on the new one.\n const why = `moved to the ${to} account, but its Claude couldn't be restarted: ${msg(err)} (opening the session starts it on ${to})`;\n deps.note?.(id, why, 'warn');\n throw new Error(why, { cause: err });\n }\n } catch (err) {\n if (s && !String(msg(err)).startsWith('moved to')) deps.note?.(id, `couldn't switch: ${msg(err)}`, 'warn');\n throw err;\n }\n };\n\n /** What stops a switch before anything is stopped or moved: an older PTY host, another Claude in one of its folders. */\n const refusalBeforeStop = async (s: WorktreeSession, id: string): Promise<string | null> => {\n const other = deps.othersRunningIn?.(s, id);\n if (other) return `a Claude outside this session runs in ${other}`;\n return deps.hostRuns(id) ? ((await deps.hostRefusal?.()) ?? null) : null;\n };\n\n async function switchAccount(id: string, to: string): Promise<SwitchResult> {\n const s = deps.session(id);\n if (!s) return { ok: false, status: 404, error: 'unknown session' };\n const acc = deps.accounts(s);\n const inHost = deps.hostRuns(id);\n const refused = switchRefusal(to, {\n archived: !!s.archivedAt || deps.beingArchived(id),\n accounts: acc,\n pendingTo: targets.get(id) ?? null,\n inHost,\n runningOutside: !inHost && deps.runningOutside(id),\n });\n if (refused) return { ok: false, ...refused };\n if (!acc) return { ok: false, status: 409, error: \"its agent doesn't have accounts\" }; // (refused above: for the type)\n\n const before = await refusalBeforeStop(s, id);\n if (before) return { ok: false, status: 409, error: `stays on ${acc.current}: ${before}` };\n\n if (!inHost) {\n // Nothing to stop: the files move and the account is recorded; the next start uses it.\n try {\n const moved = await moveAndRecord(s, to, acc.current);\n deps.note?.(id, `${name(s)}: moved to the ${to} account (${moved} entries moved; its next start uses it)`, 'action');\n deps.changed?.();\n return { ok: true, outcome: 'recorded', moved };\n } catch (err) {\n deps.note?.(id, `couldn't switch: ${msg(err)}`, 'warn');\n return { ok: false, status: 502, error: `stays on ${acc.current}: ${msg(err)}` };\n }\n }\n\n // At once, working or not: a switch is asked for when the account must change now (its limit ran out).\n targets.set(id, to);\n try {\n const { moved, interrupted, continued } = await perform(id, to);\n return {\n ok: true,\n outcome: 'switched',\n moved,\n ...(interrupted ? { interrupted: true } : {}),\n ...(continued ? { continued: true } : {}),\n };\n } catch (err) {\n return { ok: false, status: 502, error: msg(err) };\n } finally {\n targets.delete(id);\n deps.changed?.();\n }\n }\n\n return {\n switchAccount,\n /** The account a switch being done now moves it to; null: none. Its agent restarts with it. */\n restartsAnyway: (id: string): string | null => targets.get(id) ?? null,\n };\n}\n\nexport type AccountSwitcher = ReturnType<typeof createAccountSwitcher>;\n\n/** What a switch types to carry on a turn it found cut short. */\nexport const CONTINUE_TEXT = 'continue';\n\n/**\n * Tell a just-restarted Claude to continue, once it says it is at its prompt (`ready`): typed before Claude Code is up,\n * the nudge would be lost and the message wait for your next prompt. Asked every `everyMs` up to `timeoutMs`; false\n * when it never got ready (nothing is sent).\n */\nexport async function continueWhenReady(\n id: string,\n io: { ready: (id: string) => boolean; send: (id: string, text: string) => Promise<unknown>; sleep?: (ms: number) => Promise<void> },\n opts: { everyMs?: number; timeoutMs?: number } = {},\n): Promise<boolean> {\n const every = opts.everyMs ?? 1000;\n const tries = Math.max(1, Math.ceil((opts.timeoutMs ?? 60_000) / every));\n const sleep = io.sleep ?? ((ms: number) => new Promise<void>((r) => setTimeout(r, ms)));\n for (let i = 0; i < tries; i++) {\n if (io.ready(id)) {\n await io.send(id, CONTINUE_TEXT);\n return true;\n }\n await sleep(every);\n }\n return false;\n}\n\n/** The switcher's `note` as Activity runs: one run per note, a failure (`warn`) failing it, so the Activity dot lights. */\nexport function accountSwitchNote(\n activity: Pick<ActivityLog, 'start'>,\n label: (id: string) => string | null,\n): NonNullable<AccountSwitchDeps['note']> {\n return (id, text, level) => {\n const name = label(id);\n const run = activity.start('accounts', 'Switching a Claude account');\n run.note(`${name ?? id}: ${text}`, { level, sessionId: name ? id : undefined });\n if (level === 'warn') run.fail(text);\n else run.done(text);\n };\n}\n","import path from 'node:path';\nimport { agentOf, liveAgents } from '../agents/index.js';\nimport { isArchiving } from '../archive/archiving.js';\nimport { accountSwitchRefusal, peekPty, ptyPid, ptyPids, haltPty, resumePtyOnAccount } from '../pty/pty-pool.js';\nimport type { AccountSwitchDeps } from './account-switch.js';\nimport { loadHistory, setSessionAccount } from './history.js';\nimport { agentsBySession } from './live-agents.js';\nimport { findSession } from './web-state.js';\n\n/** The real inputs of createAccountSwitcher (account-switch.ts); work web gives `busy`, the Activity notes and the broadcast. */\nexport function defaultAccountSwitchDeps(opts: Pick<AccountSwitchDeps, 'busy'> & Partial<AccountSwitchDeps>): AccountSwitchDeps {\n return {\n session: findSession,\n beingArchived: isArchiving,\n accounts: (s) => {\n const accounts = agentOf(s).accounts;\n return accounts ? { list: accounts.list(), current: accounts.current(s) } : null;\n },\n switchFiles: (s, to) => {\n const accounts = agentOf(s).accounts;\n if (!accounts) throw new Error('its agent has no accounts');\n return accounts.switchFiles(s, to);\n },\n record: async (s, to) => {\n if (!(await setSessionAccount(s.target, s.branch, to))) throw new Error('unknown session');\n },\n hostRuns: peekPty,\n // Claude Code's process files say one runs for it that isn't the host's (terminal-ws.ts, session-control-routes.ts).\n runningOutside: (id) => {\n const hostPids = ptyPids();\n return (agentsBySession(liveAgents(), loadHistory()).get(id) ?? []).some((c) => !hostPids.has(c.pid));\n },\n othersRunningIn: (s, id) => {\n const folders = agentOf(s).accounts?.folders(s) ?? [];\n if (!folders.length) return null;\n const own = ptyPid(id);\n const key = (p: string) => {\n const r = path.resolve(p).replace(/[\\\\/]+$/, '');\n return process.platform === 'win32' ? r.toLowerCase() : r;\n };\n const wanted = new Map(folders.map((f) => [key(f), f]));\n const other = liveAgents().find((a) => a.pid !== own && wanted.has(key(a.cwd)));\n return other ? (wanted.get(key(other.cwd)) ?? other.cwd) : null;\n },\n hostRefusal: accountSwitchRefusal,\n halt: haltPty,\n resume: resumePtyOnAccount,\n ...opts,\n };\n}\n","import { agentOf, AccountAdminError, type AccountUsers, type AgentAccounts } from '../agents/index.js';\nimport { loadHistory } from './history.js';\nimport type { WorktreeSession } from './session-types.js';\n\n/**\n * Which sessions are on an account, and forgetting one (`work account remove`): agent-neutral — a session's account is\n * what its own agent's `accounts` part says (agents/types.ts); a session of an agent without accounts is on none.\n */\n\nconst label = (s: WorktreeSession) => `${s.target} · ${s.branch}`;\n\n/** The sessions on `name` of the agent `accounts` belongs to: live ones, and archived ones (a Restore would start one on it). */\nexport function sessionsOnAccount(\n name: string,\n accounts: Pick<AgentAccounts, 'current'>,\n sessions: readonly WorktreeSession[] = loadHistory(),\n): AccountUsers {\n const on = sessions.filter((s) => agentOf(s).accounts === accounts && accounts.current(s) === name);\n return { live: on.filter((s) => !s.archivedAt).map(label), archived: on.filter((s) => s.archivedAt).map(label) };\n}\n\n/**\n * Forget an account of an agent. Refused while a live session runs on it, and while archived ones use it unless `force`\n * (their Restore would then start on the default account): the sessions are read under the config's lock, right before\n * the write, so one made meanwhile on it still stops it.\n */\nexport async function removeAgentAccount(\n accounts: AgentAccounts,\n name: string,\n opts: { force?: boolean; sessions?: () => readonly WorktreeSession[] } = {},\n): Promise<void> {\n if (!accounts.admin) throw new AccountAdminError('its accounts are not managed by work');\n await accounts.admin.remove(name, () => {\n const users = sessionsOnAccount(name, accounts, opts.sessions ? opts.sessions() : loadHistory());\n return opts.force ? { live: users.live, archived: [] } : users;\n });\n}\n","import { AccountAdminError, type AgentAccountAdmin, type AgentAccounts } from '../agents/index.js';\nimport type { ActivityLog } from '../platform/activity.js';\nimport type { UsageAccount } from '../usage/usage.js';\nimport { sessionsOnAccount } from './account-users.js';\nimport { loadHistory } from './history.js';\nimport type { WorktreeSession } from './session-types.js';\n\n/**\n * The accounts of an agent as `work account` and the dashboard's Accounts page both manage them: one overview (who is\n * logged in, its last usage reading, the sessions on it), adding one and choosing the default through the agent's\n * `accounts.admin`, and the login terminals the page opens (start, stop, and work's skills put into a new account's\n * folder once its first login is over). Agent-neutral: everything of the agent's goes through its adapter.\n */\n\n/** One account, with what the page and `work account list` show of it. */\nexport interface AccountOverview {\n name: string;\n dir: string;\n isDefault: boolean;\n /** Null: can't tell (macOS keeps Claude's credentials in the keychain). */\n loggedIn: boolean | null;\n /** The sessions on it as \"target · branch\": the live ones, and the archived ones (whose Restore needs it). */\n live: string[];\n archived: string[];\n /** Its last usage reading (as recorded: a window past its reset is aged by whoever shows it); null: none yet. */\n usage: UsageAccount | null;\n}\n\nexport function accountOverview(\n accounts: AgentAccounts,\n readings: readonly UsageAccount[],\n sessions: readonly WorktreeSession[] = loadHistory(),\n): AccountOverview[] {\n return accounts.list().map((a) => {\n const users = sessionsOnAccount(a.name, accounts, sessions);\n return {\n name: a.name,\n dir: a.dir,\n isDefault: a.isDefault,\n loggedIn: a.loggedIn,\n live: users.live,\n archived: users.archived,\n usage: readings.find((r) => r.account === a.name) ?? null,\n };\n });\n}\n\n/** The agent's account administration, or the refusal every caller says the same way. */\nfunction adminOf(accounts: AgentAccounts | undefined): AgentAccountAdmin {\n if (!accounts?.admin) throw new AccountAdminError('its accounts are not managed by work');\n return accounts.admin;\n}\n\n/** Record a new account (its folder: `folder`, else the agent's default place, made when missing). Returns the folder. */\nexport async function addAgentAccount(accounts: AgentAccounts | undefined, name: string, folder?: string): Promise<string> {\n return adminOf(accounts).add(name, folder?.trim() || undefined);\n}\n\n/** New sessions use this account. */\nexport async function setDefaultAgentAccount(accounts: AgentAccounts | undefined, name: string): Promise<void> {\n return adminOf(accounts).setDefault(name);\n}\n\nexport interface SkillsOutcome {\n ok: boolean;\n message: string;\n}\n\n/** What the login terminals need: the account lookup, the PTY host, and work's skills install for one account. */\nexport interface AccountLoginDeps {\n has(name: string): boolean;\n /** Start (or find running) the account's login terminal in the PTY host; its id. */\n start(name: string): Promise<string>;\n stop(name: string): Promise<void>;\n /** Put work's skills into the account's folder (slow: the agent's own CLI, several times). */\n installSkills(name: string): Promise<SkillsOutcome>;\n /** How an install went (the Activity panel). */\n note?(name: string, outcome: SkillsOutcome): void;\n}\n\nexport interface AccountLogins {\n /** The login terminal's id. Refused (AccountAdminError) for an account there isn't. */\n start(name: string): Promise<string>;\n /**\n * Stop the login terminal. The first time for an account in this process, work's skills go into its folder after —\n * as `work account add` installs them once the login is over (installing while the agent writes its settings would\n * race it). `skills`: that install, under way (null: none started); nobody need wait for it.\n */\n stop(name: string): Promise<{ skills: Promise<SkillsOutcome> | null }>;\n}\n\nexport function createAccountLogins(deps: AccountLoginDeps): AccountLogins {\n const installed = new Set<string>();\n const installing = new Set<string>();\n return {\n async start(name) {\n if (!deps.has(name)) throw new AccountAdminError(`no account “${name}”`);\n return deps.start(name);\n },\n async stop(name) {\n await deps.stop(name);\n if (!deps.has(name) || installed.has(name) || installing.has(name)) return { skills: null };\n installing.add(name);\n const skills = deps\n .installSkills(name)\n .catch((e: unknown): SkillsOutcome => ({ ok: false, message: e instanceof Error ? e.message : String(e) }))\n .then((r) => {\n installing.delete(name);\n // A failed install is tried again at the next close.\n if (r.ok) installed.add(name);\n deps.note?.(name, r);\n return r;\n });\n return { skills };\n },\n };\n}\n\n/** How a skills install for an account went, as an Activity run (kind `accounts`): a failure lights the Activity dot. */\nexport function accountSkillsNote(activity: Pick<ActivityLog, 'start'>): NonNullable<AccountLoginDeps['note']> {\n return (name, r) => {\n const run = activity.start('accounts', `Work's skills for the ${name} account`);\n if (r.ok) run.done(r.message);\n else {\n run.note(`${r.message} — or run \\`work account skills ${name}\\``, { level: 'warn' });\n run.fail(r.message);\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,SAAS,cAAc,IAAY,GAAsC;AAC9E,MAAI,EAAE,SAAU,QAAO,EAAE,QAAQ,KAAK,OAAO,mCAAmC;AAChF,MAAI,CAAC,EAAE,SAAU,QAAO,EAAE,QAAQ,KAAK,OAAO,kCAAkC;AAChF,QAAM,SAAS,EAAE,SAAS,KAAK,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE;AACxD,MAAI,CAAC,OAAQ,QAAO,EAAE,QAAQ,KAAK,OAAO,oBAAe,EAAE,qCAAgC;AAC3F,MAAI,OAAO,aAAa;AACtB,WAAO,EAAE,QAAQ,KAAK,OAAO,gCAA2B,EAAE,kCAA6B,EAAE,sCAAsC;AACjI,MAAI,EAAE,cAAc,KAAM,QAAO,EAAE,QAAQ,KAAK,OAAO,sCAAsC,EAAE,aAAa,iBAAiB,IAAI;AACjI,MAAI,EAAE,SAAS,YAAY,GAAI,QAAO,EAAE,QAAQ,KAAK,OAAO,4BAAuB,EAAE,SAAI;AACzF,MAAI,CAAC,EAAE,UAAU,EAAE;AACjB,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,OAAO;AAAA,IACT;AACF,SAAO;AACT;;;ACsBO,IAAM,cAAc;AAEpB,IAAM,YAAY;AAEzB,IAAM,MAAM,CAAC,QAAkB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAEvE,SAAS,sBAAsB,MAAyB;AAE7D,QAAM,UAAU,oBAAI,IAAoB;AAExC,QAAM,OAAO,CAAC,MAAuB,GAAG,EAAE,MAAM,IAAI,EAAE,MAAM;AAG5D,QAAM,gBAAgB,OAAO,GAAoB,IAAY,SAAkC;AAC7F,UAAM,EAAE,MAAM,IAAI,MAAM,KAAK,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G,OAAM,IAAI,kBAAkB,oBAAe,IAAI,QAAG;AACvE,aAAO,KAAK,MAAM,IAAI;AAAA,IACxB;AAAA,IACA,MAAM,KAAK,MAAM;AACf,YAAM,KAAK,KAAK,IAAI;AACpB,UAAI,CAAC,KAAK,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,EAAG,QAAO,EAAE,QAAQ,KAAK;AAC1F,iBAAW,IAAI,IAAI;AACnB,YAAM,SAAS,KACZ,cAAc,IAAI,EAClB,MAAM,CAAC,OAA+B,EAAE,IAAI,OAAO,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE,EAAE,EACzG,KAAK,CAAC,MAAM;AACX,mBAAW,OAAO,IAAI;AAEtB,YAAI,EAAE,GAAI,WAAU,IAAI,IAAI;AAC5B,aAAK,OAAO,MAAM,CAAC;AACnB,eAAO;AAAA,MACT,CAAC;AACH,aAAO,EAAE,OAAO;AAAA,IAClB;AAAA,EACF;AACF;AAGO,SAAS,kBAAkB,UAA6E;AAC7G,SAAO,CAAC,MAAM,MAAM;AAClB,UAAM,MAAM,SAAS,MAAM,YAAY,yBAAyB,IAAI,UAAU;AAC9E,QAAI,EAAE,GAAI,KAAI,KAAK,EAAE,OAAO;AAAA,SACvB;AACH,UAAI,KAAK,GAAG,EAAE,OAAO,wCAAmC,IAAI,MAAM,EAAE,OAAO,OAAO,CAAC;AACnF,UAAI,KAAK,EAAE,OAAO;AAAA,IACpB;AAAA,EACF;AACF;","names":["label"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/sessions/session-wire.ts","../src/core/comments/linked-stores.ts","../src/core/sessions/session-meta.ts","../src/core/conversations/context-usage.ts","../src/core/conversations/session-title.ts"],"sourcesContent":["import { sessionIssue } from '../issues/issue-source.js';\nimport type { SessionLocalReviewWire } from '../api-types.js';\nimport fs from 'node:fs';\nimport { agentOf, agentWire } from '../agents/index.js';\nimport { readStatus } from '../status/session-status.js';\nimport { snoozeActive, type Snooze } from '../rail/snooze.js';\nimport { idleFrom, withLiveClaude } from '../status/session-status.js';\nimport path from 'node:path';\nimport { readSessionMeta } from './session-meta.js';\nimport { checkedOutBranch } from '../git/git-head.js';\nimport { sessionIdFor } from './web-state.js';\nimport { readContextUsage } from '../conversations/context-usage.js';\nimport { bestEffort } from '../platform/best-effort.js';\nimport type { WorktreeSession } from './history.js';\nimport type {\n DiffStat,\n SessionArchiveInfo,\n SessionAttention,\n SessionClaudes,\n SessionWire,\n BlockerWire,\n PrStageWire,\n SessionBranchWire,\n ElsewherePr,\n} from '../api-types.js';\nimport { archiveDirFor, archivedByOf, keptList, readArchive } from '../archive/session-archive.js';\nimport { isArchiving, isRestoring } from '../archive/archiving.js';\nimport { sessionTitle } from '../conversations/session-title.js';\nimport { prStageOf, stageRepos, STAGE_WANTS_YOU, type StagePr } from '../pr/pr-stage.js';\nimport { stageInputOf } from '../pr/branch-work.js';\nimport { isLeftover } from '../worktree/leftover.js';\nimport { recordedRepos, sessionRepos } from './session-repos.js';\nimport { DEFAULT_ACCOUNT, getConfigPath, loadConfig, type WorkConfig } from '../platform/config.js';\n\n/**\n * One session as every client sees it — the dashboard's /api/sessions rows\n * and `work sessions --json` alike: identity, status, activity, comments,\n * context, archive state. Built in one place so the two can't drift.\n */\nexport interface SessionWireOptions {\n /** The session's `+N −M`, when the caller has one (the web cache). */\n diffStatFor?: (id: string, s: WorktreeSession, hasStatus: boolean) => DiffStat | null;\n /** Whether its Claude runs in the PTY host (the CLI asks the host; the\n * web server's pool knows it already). */\n ptyLive?: (id: string) => boolean;\n /** Its running Claudes, wherever they were started (live-claudes.ts). */\n claudesFor?: (id: string) => SessionClaudes | null;\n /** It shares its folder with another session that owns it\n * (shared-folders.ts): the folder's activity isn't this one's. */\n shadowed?: (id: string) => boolean;\n /** Unresolved review threads on its open PRs (the PR watch's last check). */\n reviewThreadsFor?: (id: string) => number;\n /** Reply drafts its Claude wrote for you to post (pr-replies.ts). */\n replyDraftsFor?: (id: string) => number;\n /** Where its own review stands (local-review.ts `row`); null: it has none. */\n localReviewFor?: (id: string) => SessionLocalReviewWire | null;\n /** Where its PR stands (pr-stage.ts over the PR watch's last check), and whether you've seen it there. */\n prStageFor?: (id: string) => PrStageWire | null;\n /** You have notes on it (session-notes.ts). */\n hasNote?: (id: string) => boolean;\n /** What it waits on that isn't done yet (session-blocks.ts). */\n blockedByFor?: (id: string) => BlockerWire[];\n /** The running Claudes were read against a real process list, so \"none\" means none. */\n liveKnown?: boolean;\n /** A Claude of ours runs for it (PTY host), whether or not Claude Code's file shows it yet. */\n hostedLive?: (id: string) => boolean;\n /** A question its agent is stopped at before its first turn (startup-question.ts): it needs you, whatever was recorded. */\n startupQuestionFor?: (id: string) => { what: string; since: string } | null;\n /** A status read from its terminal output, for a tool with no hooks (output-status.ts). */\n outputStatusFor?: (id: string) => SessionAttention | null;\n /** Its snooze, if any (snooze-store.ts); shown only while it holds. */\n snoozeFor?: (id: string) => Snooze | null;\n /** How far behind main — or the session it is stacked on — it is (behind-main.ts's cache). */\n /** `lastActivity`: its agent's last write (ms; 0 none), so a session entered long ago but worked in today counts as in use. */\n behindFor?: (\n id: string,\n s: WorktreeSession,\n lastActivity: number,\n ) => { base: string; commits: number; conflicts: boolean; stacked?: true } | null;\n /** Every branch it worked on, with what's known of each (branch-facts.ts `createSessionBranches`); null when\n * it stayed on one. */\n branchesFor?: (id: string, s: WorktreeSession) => SessionBranchWire[] | null;\n /** Where it sits in a stack (stack-sessions.ts). */\n stackFor?: (id: string) => {\n parent: { id: string; branch: string; title?: string } | null;\n children: number;\n merged?: { id: string; branch: string } | null;\n };\n}\n\nexport function sessionWire(s: WorktreeSession, opts: SessionWireOptions = {}): SessionWire {\n const id = sessionIdFor(s);\n const meta = readSessionMeta(id, s);\n const shadowed = opts.shadowed?.(id) ?? false;\n const claudes = shadowed ? null : (opts.claudesFor?.(id) ?? null);\n const reviewThreads = s.archivedAt ? 0 : (opts.reviewThreadsFor?.(id) ?? 0);\n const replyDrafts = s.archivedAt ? 0 : (opts.replyDraftsFor?.(id) ?? 0);\n const prStage = s.archivedAt ? null : (opts.prStageFor?.(id) ?? null);\n const localReview = s.archivedAt ? null : (opts.localReviewFor?.(id) ?? null);\n const startup = s.archivedAt || shadowed ? null : (opts.startupQuestionFor?.(id) ?? null);\n const wire: SessionWire = {\n id,\n target: s.target,\n branch: s.branch,\n isGroup: s.isGroup,\n paths: s.paths,\n repos: wireRepos(s),\n ...(isBaseCheckout(s) ? { baseCheckout: true as const } : {}),\n folder: s.isGroup,\n baseBranch: s.baseBranch,\n issueKey: s.issueKey,\n // Its issue whatever it came from (a Jira key is one): what a row links to.\n ...(sessionIssue(s) ? { issue: sessionIssue(s)! } : {}),\n createdAt: s.createdAt,\n lastAccessedAt: s.lastAccessedAt,\n draftCount: meta.draftCount,\n commentCount: meta.commentCount,\n claudeCount: meta.claudeCount,\n ptyStatus: opts.ptyLive ? (opts.ptyLive(id) ? 'running' : 'idle') : meta.ptyStatus,\n lastActivity: shadowed ? null : meta.lastActivity,\n // A running Claude is open even when it writes nothing (idle at its prompt).\n activityState: shadowed\n ? 'stale'\n : claudes\n ? claudes.busy\n ? 'active'\n : meta.activityState === 'active'\n ? 'active'\n : 'open'\n : meta.activityState,\n ...(claudes ? { agents: claudes, claudes } : {}),\n agent: agentWire(agentOf(s)),\n // Only a session on an account other than the default says which.\n ...(s.account && s.account !== DEFAULT_ACCOUNT ? { account: s.account } : {}),\n ...(s.archivedAt ? archiveInfo(id) : {}),\n title: bestEffort(\n `title of ${s.target}:${s.branch}`,\n () => sessionTitle(s, s.archivedAt ? readArchive(id)?.summary.prompts[0]?.text : null),\n null,\n ),\n ...(s.title ? { titleIsYours: true } : {}),\n pendingForClaudeCount: meta.pendingForClaudeCount,\n // Stopped at its own question before any turn (no hook says so): it waits for you, whatever was recorded before.\n // Else Claude Code's own state file over what the hooks recorded, when newer.\n attention: startup\n ? { state: 'needs_input', seen: false, since: startup.since, updatedAt: startup.since, stale: false, summary: startup.what }\n : meta.attention && !shadowed && opts.claudesFor\n ? withLiveClaude(meta.attention, claudes, {\n known: opts.liveKnown === true,\n hosted: opts.hostedLive?.(id) ?? true,\n background: () => agentOf(s).conversation?.backgroundWorkSince?.(s, idleFrom(meta.attention!)) ?? null,\n commands: () =>\n bestEffort(\n `background commands of ${s.target}:${s.branch}`,\n () => agentOf(s).conversation?.backgroundCommandNames?.(s, 0) ?? [],\n [],\n ) ?? [],\n })\n : (meta.attention ?? (shadowed || s.archivedAt ? null : (opts.outputStatusFor?.(id) ?? null))),\n diffStat: opts.diffStatFor ? opts.diffStatFor(id, s, meta.attention !== null) : null,\n archivedAt: s.archivedAt ?? null,\n port: s.port ?? null,\n context: s.archivedAt ? null : bestEffort(`context usage for ${s.target}:${s.branch}`, () => readContextUsage(s), null),\n ...(reviewThreads > 0 ? { openReviewThreads: reviewThreads } : {}),\n ...(replyDrafts > 0 ? { replyDrafts } : {}),\n ...(prStage ? { prStage } : {}),\n ...(localReview ? { localReview } : {}),\n ...otherBranches(s),\n };\n // Snoozed: only while it holds (a time not yet reached, or the status it\n // was snoozed in). \"Its status\" is what the hooks recorded — the same the\n // snooze was taken against — not the shown one, which a live Claude's state\n // file can override (that would end a snooze the moment it was set).\n const snooze = s.archivedAt ? null : (opts.snoozeFor?.(id) ?? null);\n if (snooze && snoozeActive(snooze, { attention: readStatus(id), openReviewThreads: wire.openReviewThreads, prStage: wire.prStage }))\n wire.snoozed = { until: snooze.until };\n const behind = s.archivedAt ? null : (opts.behindFor?.(id, s, wire.lastActivity ?? 0) ?? null);\n if (behind && behind.commits > 0) wire.behind = behind;\n const stack = s.archivedAt ? null : (opts.stackFor?.(id) ?? null);\n if (stack?.parent) wire.stackedOn = stack.parent;\n if (stack?.children) wire.stackedChildren = stack.children;\n if (stack?.merged) wire.stackParentMerged = stack.merged;\n const branches = s.archivedAt ? null : (opts.branchesFor?.(id, s) ?? null);\n if (branches?.length) wire.branches = branches;\n if (opts.hasNote?.(id)) wire.hasNote = true;\n if (s.keepAfterMerge && !s.archivedAt) wire.keepAfterMerge = true;\n if (isArchiving(id)) wire.archiving = true;\n if (!s.archivedAt && isAsleep(readStatus(id)?.stoppedAt, wire.ptyStatus === 'running', wire.lastActivity ?? 0)) wire.asleep = true;\n const blockers = s.archivedAt ? [] : (opts.blockedByFor?.(id) ?? []);\n if (blockers.length) wire.blockedBy = blockers;\n return wire;\n}\n\n/**\n * Asleep: work stopped its Claude (idle sleep, `work stop`: `stoppedAt`), it\n * isn't running now, and its conversation wasn't written since — one started\n * again (opened, sent a note, started in a terminal) is awake. Pure.\n */\nexport function isAsleep(stoppedAt: string | undefined, ptyRunning: boolean, lastActivityMs: number): boolean {\n const stopped = stoppedAt ? Date.parse(stoppedAt) : NaN;\n return Number.isFinite(stopped) && !ptyRunning && lastActivityMs <= stopped;\n}\n\n/** The row, marked Restoring while a Restore of it runs (a copy: archived rows are cached). */\nexport function withRestoring(w: SessionWire): SessionWire {\n return isRestoring(w.id) ? { ...w, restoring: true } : w;\n}\n\n/**\n * Its repos' aliases, one per path (`sessionRepos`). A recorded list needs no\n * config; a group's row from before reads the group's members from the\n * config, read once per change of the file (this runs per row of every list).\n */\nexport function wireRepos(\n s: Pick<WorktreeSession, 'target' | 'isGroup' | 'paths' | 'repos'>,\n config: () => Pick<WorkConfig, 'repos' | 'groups'> | null = repoConfig,\n): string[] {\n const recorded = recordedRepos(s);\n if (recorded) return recorded.map((r) => r.alias);\n return sessionRepos(s, s.isGroup ? config() : null).map((r) => r.alias);\n}\n\n/**\n * A repo's own checkout (`work tree api` with no branch), not a worktree work made: its path is the configured repo's\n * (as `baseCheckoutSession`). The Project view puts it first in its project's card. Config read once per change.\n */\nexport function isBaseCheckout(\n s: Pick<WorktreeSession, 'target' | 'isGroup' | 'paths'>,\n config: () => Pick<WorkConfig, 'repos'> | null = repoConfig,\n): boolean {\n if (s.isGroup || !s.paths[0]) return false;\n const repo = config()?.repos[s.target];\n if (!repo) return false;\n const norm = (p: string) => path.resolve(p).replace(/\\\\/g, '/').replace(/\\/+$/, '').toLowerCase();\n return norm(s.paths[0]) === norm(repo);\n}\n\nlet configCache: { key: string; value: Pick<WorkConfig, 'repos' | 'groups'> | null } | null = null;\n\nfunction repoConfig(): Pick<WorkConfig, 'repos' | 'groups'> | null {\n const file = getConfigPath();\n let key: string;\n try {\n const st = fs.statSync(file);\n key = `${file}|${st.size}|${st.mtimeMs}`;\n } catch {\n return null;\n }\n if (configCache?.key === key) return configCache.value;\n const cfg = bestEffort('config for session repos', () => loadConfig(), null);\n configCache = { key, value: cfg ? { repos: cfg.repos, groups: cfg.groups } : null };\n return configCache.value;\n}\n\n/**\n * Repos of the session checked out on another branch than the session's\n * (read from HEAD files, no git). Ship and the PR watch follow the real\n * branch already; this is so the dashboard says so.\n */\nexport function otherBranches(s: Pick<WorktreeSession, 'branch' | 'paths' | 'target' | 'isGroup' | 'archivedAt'>): {\n onOtherBranch?: Array<{ repo: string; branch: string | null; noGit?: true }>;\n} {\n if (s.archivedAt || !s.branch) return {};\n const out: Array<{ repo: string; branch: string | null; noGit?: true }> = [];\n for (const p of s.paths) {\n if (!fs.existsSync(p)) continue;\n // A folder with no git left in it (a removal that stopped halfway) is on no branch at all.\n if (isLeftover(p)) {\n out.push({ repo: s.isGroup ? path.basename(p) : s.target, branch: null, noGit: true });\n continue;\n }\n const branch = checkedOutBranch(p);\n if (branch !== s.branch) out.push({ repo: s.isGroup ? path.basename(p) : s.target, branch });\n }\n return out.length ? { onOtherBranch: out } : {};\n}\n\n/** A session's unresolved review threads, from the PR watch's per-repo counts (open PRs only). */\nexport function reviewThreadsOf(ci: { repos: Array<{ pr: { state: string } | null; openThreads?: number }> } | null | undefined): number {\n return (ci?.repos ?? []).reduce((n, r) => n + (r.pr?.state === 'OPEN' ? (r.openThreads ?? 0) : 0), 0);\n}\n\n/** The `pr_watch_seen` key that says you saw a session at a PR stage. */\nexport const stageSeenKey = (stageKey: string) => `stage:${stageKey}`;\n\n/**\n * A session's PR stage from the PR watch's last check, with `seen` read only\n * for a stage that would bring it back to the Inbox (one lookup, not one per row).\n */\nexport function prStageWire(\n ci:\n | {\n repos: Array<{ name: string; pr: StagePr | null; branch?: string; otherPrs?: Array<{ branch: string; pr: StagePr }> }>;\n elsewhere?: ElsewherePr[];\n }\n | null\n | undefined,\n seen: (key: string) => boolean,\n): PrStageWire | null {\n // Every open PR across the branches it worked on (stageRepos), and its listed PRs in repos it doesn't have.\n const stage = prStageOf(stageRepos(stageInputOf(ci)));\n if (!stage) return null;\n return STAGE_WANTS_YOU.has(stage.kind) && seen(stageSeenKey(stage.key)) ? { ...stage, seen: true } : stage;\n}\n\n/** Saved uncommitted files a Restore hasn't put back yet. */\nfunction savedFiles(saved: Record<string, { files: number; restoredAt?: string; restoreError?: string }> | undefined): {\n savedUncommitted?: number;\n} {\n const n = Object.values(saved ?? {})\n .filter((u) => !u.restoredAt && !u.restoreError)\n .reduce((sum, u) => sum + u.files, 0);\n return n ? { savedUncommitted: n } : {};\n}\n\nfunction archiveInfo(id: string): { archive?: SessionArchiveInfo } {\n const rec = readArchive(id);\n if (!rec) return {};\n const by = archivedByOf(rec);\n const kept = keptList(rec.kept);\n return {\n archive: {\n ...(by ? { by } : {}),\n worktreeRemoved: rec.worktreeRemoved,\n keptBecause: rec.keptBecause,\n promptCount: rec.summary.promptCount,\n prompts: rec.summary.prompts.map((p) => p.text),\n lastSummary: rec.summary.lastSummary,\n ...(rec.summary.written ? { written: rec.summary.written } : {}),\n ...(rec.buildFolders ? { buildFolders: rec.buildFolders } : {}),\n ...savedFiles(rec.uncommitted),\n ...(kept ? { kept } : {}),\n },\n };\n}\n\n/** Newest sign of life (ms): the hook update, Claude's last write, the\n * `work tree` entry — the same rule as the dashboard's \"Last active\". */\nexport function lastActiveMs(w: Pick<SessionWire, 'lastAccessedAt' | 'lastActivity' | 'attention'>): number {\n return Math.max(Date.parse(w.lastAccessedAt) || 0, w.lastActivity ?? 0, w.attention ? Date.parse(w.attention.updatedAt) || 0 : 0);\n}\n\n/**\n * Archived sessions' rows, kept between builds of the list: an archived\n * session doesn't change — its Claude is stopped, its worktree mostly gone —\n * and building its row reads its archive (2/3 of /api/sessions' time with\n * fifty of them). A row is built again when its archive file was written\n * (the summary lands after archiving, a Restore records what came back), it\n * was renamed or entered, or your note on it came or went.\n */\nexport function createArchivedRows(\n archiveFile: (id: string) => string = (id) => path.join(archiveDirFor(id), 'archive.json'),\n): (s: WorktreeSession, extra: { hasNote: boolean }, build: () => SessionWire) => SessionWire {\n const rows = new Map<string, { key: string; row: SessionWire }>();\n return (s, extra, build) => {\n if (!s.archivedAt) return build();\n const id = sessionIdFor(s);\n let mtime = 0;\n try {\n mtime = fs.statSync(archiveFile(id)).mtimeMs;\n } catch {\n /* none yet */\n }\n const key = `${s.archivedAt}|${mtime}|${s.title ?? ''}|${s.lastAccessedAt}|${extra.hasNote}`;\n const hit = rows.get(id);\n if (hit?.key === key) return hit.row;\n const row = build();\n rows.set(id, { key, row });\n return row;\n };\n}\n","import type { WorktreeSession } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { readStoresComments } from './comment-file-store.js';\nimport { scopeStoreIdsForPaths } from './pending-delivery.js';\nimport type { Comment } from './comment-types.js';\n\n/**\n * One worktree's comments live in two kinds of store: the session's own (the\n * dashboard's Diff tab posts there) and a `wd` scope's (`scope-<hash>`: the\n * browser diff page, `/diff/<hash>`, posts there). Claude was handed both\n * (`readPendingForWorktree`), but each view showed only its own, so a comment\n * made on one wasn't there on the other. Each view now lists its own store\n * first and the linked ones after: the session's view its scope stores, a\n * scope's view the session(s) whose worktree it covers.\n *\n * The stores stay separate — a new `wd -c` run clears its scope's comments\n * (`ensureScope`), which must never clear the session's.\n */\n\n/** A session as these lookups need it: its id (its store's) and its worktree paths. */\nexport interface LinkedSession {\n id: string;\n paths: string[];\n}\n\nexport const linkedSession = (s: WorktreeSession): LinkedSession => ({ id: sessionIdFor(s), paths: s.paths });\n\n/** The session's store, then every scope store over its paths. */\nexport function sessionLinkedStoreIds(session: LinkedSession): string[] {\n return [session.id, ...scopeStoreIdsForPaths(session.paths)];\n}\n\n/** The scope's store, then each session whose paths that scope covers (the whole worktree, or one repo of a group). */\nexport function scopeLinkedStoreIds(hash: string, sessions: LinkedSession[]): string[] {\n const own = `scope-${hash}`;\n return [own, ...new Set(sessions.filter((s) => scopeStoreIdsForPaths(s.paths).includes(own)).map((s) => s.id))];\n}\n\nexport type Read = (storeId: string) => Comment[];\n\n/** These stores read in one query (they're mostly empty: a scope store has rows only once its page was commented on). */\nexport function readerFor(storeIds: string[]): Read {\n const rows = readStoresComments(storeIds);\n return (id) => rows.get(id) ?? [];\n}\n\n/**\n * Every comment the view shows: the first store's whole, the linked ones'\n * without their drafts (a draft is that view's unsent review; this view's\n * Submit wouldn't send it). Oldest first, each comment once.\n */\nexport function linkedComments(storeIds: string[], read: Read = readerFor(storeIds)): Comment[] {\n const seen = new Set<string>();\n const out: Comment[] = [];\n storeIds.forEach((id, i) => {\n for (const c of read(id)) {\n if (seen.has(c.id) || (i > 0 && c.status === 'draft')) continue;\n seen.add(c.id);\n out.push(c);\n }\n });\n return out.sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n}\n\n/** Which of these stores holds the comment (a delete, a resolve or a reply acts there), or null. */\nexport function storeHolding(storeIds: string[], commentId: string, read: Read = readerFor(storeIds)): string | null {\n return storeIds.find((id) => read(id).some((c) => c.id === commentId)) ?? null;\n}\n\n/** Who to tell a store changed: the sessions and scopes whose views list it. */\nexport function viewersOf(storeId: string, sessions: LinkedSession[]): { sessionIds: string[]; scopeHashes: string[] } {\n if (storeId.startsWith('scope-')) {\n return {\n sessionIds: [...new Set(sessions.filter((s) => scopeStoreIdsForPaths(s.paths).includes(storeId)).map((s) => s.id))],\n scopeHashes: [storeId.slice('scope-'.length)],\n };\n }\n const session = sessions.find((s) => s.id === storeId);\n return {\n sessionIds: [storeId],\n scopeHashes: session ? scopeStoreIdsForPaths(session.paths).map((id) => id.slice('scope-'.length)) : [],\n };\n}\n\n/** How a front-end tells a view its comments changed: a session's Diff tab by id, a scope page on its own stream. */\nexport interface Tell {\n session: (sessionId: string, data: Record<string, unknown>) => void;\n scope: (scopeHash: string, data: Record<string, unknown>) => void;\n}\n\n/** A store changed: every view listing it is told (both comment routes use this, so they can't drift apart). */\nexport function announceChange(storeId: string, sessions: LinkedSession[], tell: Tell, data: Record<string, unknown>): void {\n const { sessionIds, scopeHashes } = viewersOf(storeId, sessions);\n for (const sessionId of sessionIds) tell.session(sessionId, { ...data, sessionId });\n for (const scopeHash of scopeHashes) tell.scope(scopeHash, { ...data, scopeHash });\n}\n","import { peekPty } from '../pty/pty-pool.js';\nimport { sessionStatusView } from '../status/turn-activity.js';\nimport type { ActivityState } from '../api-types.js';\nimport { readSessionActivity } from './session-activity.js';\nimport { linkedComments, sessionLinkedStoreIds } from '../comments/linked-stores.js';\nimport { readPendingForWorktree } from '../comments/pending-delivery.js';\nimport type { WorktreeSession } from './history.js';\nimport { readStatus, type EffectiveStatus } from '../status/session-status.js';\n\nexport type { PtyStatus } from '../api-types.js';\nimport type { PtyStatus } from '../api-types.js';\n\nexport interface SessionMeta {\n draftCount: number;\n /** Open comment threads (top-level, not resolved): the Diff tab's badge. */\n commentCount: number;\n /** Comments authored by claude — used by the client to compute unread. */\n claudeCount: number;\n /** Set when *our* PTY pool has a live Claude for this session. Doesn't\n * catch external terminals — `activityState` does. */\n ptyStatus: PtyStatus;\n /** ms since epoch of Claude's last write across this worktree, or null. */\n lastActivity: number | null;\n /** Derived from `lastActivity`: 'active' (≤30 s), 'open' (≤5 min), 'stale'. */\n activityState: ActivityState;\n /** Published user comments not yet surfaced to Claude via the\n * UserPromptSubmit hook. Drops to zero after Claude takes its next turn. */\n pendingForClaudeCount: number;\n /** Hook-driven agent status for the attention inbox; null until the\n * session's Claude has fired a hook under a full `work web`. */\n attention: EffectiveStatus | null;\n}\n\n/**\n * Cheap per-session metadata. Goes through the file-store cache so badge\n * counts reflect in-flight writes that haven't yet hit disk — reading the\n * raw JSON behind the cache's back produced stale counts under load.\n *\n * `session` is required because we need the worktree paths to look up\n * Claude's transcript directory (the sessionId hash alone isn't enough).\n */\nexport function readSessionMeta(sessionId: string, session: WorktreeSession): SessionMeta {\n // As the Diff tab lists them: with those made on the browser diff page (linked-stores.ts).\n const comments = linkedComments(sessionLinkedStoreIds({ id: sessionId, paths: session.paths }));\n let drafts = 0;\n let claude = 0;\n let open = 0;\n for (const c of comments) {\n if (c.status === 'draft') drafts++;\n if (c.author === 'claude') claude++;\n // The Diff tab's badge: threads still open. One Claude worked through is resolved (resolveAddressed).\n if (!c.parentId && !c.resolved) open++;\n }\n const activity = readSessionActivity(session);\n // What the hooks will hand over: the session's and its scopes' (readPendingForWorktree), as the badges count.\n const pending = readPendingForWorktree(session, sessionId).length;\n const status = readStatus(sessionId);\n return {\n draftCount: drafts,\n commentCount: open,\n claudeCount: claude,\n ptyStatus: peekPty(sessionId) ? 'running' : 'idle',\n lastActivity: activity.lastActivity,\n activityState: activity.state,\n pendingForClaudeCount: pending,\n attention: status ? sessionStatusView(status, session, activity.lastActivity ?? 0) : null,\n };\n}\n","import { readJsonlTail } from './jsonl.js';\nimport { agentOf } from '../agents/index.js';\nimport type { ConversationEntry } from '../agents/types.js';\nimport type { ContextUsage } from '../api-types.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\n\nexport type { ContextUsage } from '../api-types.js';\n\n/**\n * How full a session's conversation is. Every assistant message in the\n * transcript carries the token usage of the request that produced it, so\n * the newest one says how big the context is now: its prompt (input +\n * cache reads + cache writes) plus its reply, which the next turn carries.\n * Near the window Claude Code compacts the conversation, and answers get\n * worse before that — the dashboard shows when to start fresh.\n */\n\n/** From conversation entries (oldest first): the newest main-thread usage, in the agent's window (`window`). */\nexport function contextUsageFrom(\n entries: readonly ConversationEntry[],\n window: (model: string | undefined, used: number) => number,\n): ContextUsage | null {\n for (let i = entries.length - 1; i >= 0; i--) {\n const e = entries[i];\n // Subagent (Task) turns run in their own context.\n if (e.role !== 'agent' || e.sidechain || !e.usage) continue;\n const used = e.usage.prompt + e.usage.reply;\n if (used === 0) continue;\n return { used, window: window(e.model, used), ...(e.model ? { model: e.model } : {}) };\n }\n return null;\n}\n\n// Claude Code's transcript files, for the callers that still read Claude's own records (turn activity): agents/claude-files.ts.\nexport type { ConversationFile as TranscriptFile } from '../agents/types.js';\n\n/** Only the tail is read — a usage line is always near the end. */\nconst USAGE_TAIL_BYTES = 64 * 1024;\nconst cache = new Map<string, { key: string; usage: ContextUsage | null }>();\n\n/** The session's context usage now, through its agent; re-reads a conversation only after it changed. Null when work can't read its agent's conversations. */\nexport function readContextUsage(session: WorktreeSession): ContextUsage | null {\n const conv = agentOf(session).conversation;\n if (!conv) return null;\n let t: { file: string; size: number; mtimeMs: number } | null = null;\n for (const f of conv.files(session)) if (!t || f.mtimeMs > t.mtimeMs) t = f;\n if (!t) return null;\n const key = `${t.file}:${t.size}:${t.mtimeMs}`;\n const id = session.paths.join('|');\n const hit = cache.get(id);\n if (hit?.key === key) return hit.usage;\n const usage = contextUsageFrom(conv.entries(readJsonlTail(t.file, USAGE_TAIL_BYTES)), conv.contextWindow);\n cache.set(id, { key, usage });\n return usage;\n}\n","import fs from 'node:fs';\nimport { promptsSince } from './digest.js';\nimport { agentOf } from '../agents/index.js';\nimport type { ConversationEntry } from '../agents/types.js';\nimport type { WorktreeSession } from '../sessions/session-types.js';\n\n/**\n * A human name for a session, beside its branch: the name you gave it, or\n * else what you first asked its Claude (\"Rotate the terminal encryption\n * keys\"), or else its Jira key. Worked out when read — the first prompt is\n * read from the start of its oldest transcript, cached per file — so a GET\n * writes nothing; only a rename is stored.\n */\n\nconst TITLE_CHARS = 80;\nconst HEAD_BYTES = 256 * 1024;\nconst cache = new Map<string, { size: number; title: string | null }>();\n\n/** The first prompt in a conversation file (read from its start), its lines read by `toEntries` (the agent's). */\nexport function firstPromptOf(file: string, toEntries: (lines: readonly unknown[]) => ConversationEntry[]): string | null {\n let size: number;\n try {\n size = fs.statSync(file).size;\n } catch {\n return null;\n }\n const hit = cache.get(file);\n // The start of a file doesn't change as it grows, unless it was replaced\n // (smaller). \"No prompt in it\" holds as long as the file is the same, or\n // its whole head was read already: re-reading 256 KB of every such\n // transcript on every session-list build cost the most of all.\n if (hit && size >= hit.size && (hit.title !== null || size === hit.size || hit.size >= HEAD_BYTES)) return hit.title;\n let text: string;\n try {\n const fd = fs.openSync(file, 'r');\n try {\n const buf = Buffer.alloc(Math.min(size, HEAD_BYTES));\n fs.readSync(fd, buf, 0, buf.length, 0);\n text = buf.toString('utf8');\n } finally {\n fs.closeSync(fd);\n }\n } catch {\n return null;\n }\n const lines: unknown[] = [];\n for (const line of text.split('\\n')) {\n try {\n lines.push(JSON.parse(line));\n } catch {\n /* the last, cut-off line */\n }\n }\n const first = promptsSince([toEntries(lines)], 0)[0]?.text ?? null;\n const readable = first ? titleText(first) : null;\n const title = readable ? clip(readable) : null;\n cache.set(file, { size, title });\n return title;\n}\n\nconst clip = (s: string) => (s.length > TITLE_CHARS ? s.slice(0, TITLE_CHARS - 1).trimEnd() + '…' : s);\n\n/**\n * A prompt as a name: what you wrote, without markup. A pasted block\n * (`<pasted_content …>…</pasted_content>`, a log or code you pasted) is left\n * out when you also wrote something; a prompt that is only a paste keeps its\n * text. Other tags are dropped, their text kept. Null when nothing is left.\n */\nexport function titleText(prompt: string): string | null {\n const flat = (s: string) =>\n s\n .replace(/<\\/?[A-Za-z][\\w-]*(?:\\s[^>]*)?>/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim();\n const outside = flat(prompt.replace(/<pasted_content\\b[^>]*>[\\s\\S]*?<\\/pasted_content>/g, ' '));\n const text = outside || flat(prompt);\n return text ? text : null;\n}\n\n/** The session's name: yours, else its first prompt, else its Jira key. */\nexport function sessionTitle(s: WorktreeSession, fallbackPrompt?: string | null): string | null {\n if (s.title?.trim()) return s.title.trim();\n const conv = agentOf(s).conversation;\n const oldestFirst = (conv?.files(s) ?? []).sort((a, b) => a.mtimeMs - b.mtimeMs);\n for (const t of oldestFirst) {\n const p = firstPromptOf(t.file, conv!.entries);\n if (p) return p;\n }\n const fallback = fallbackPrompt ? titleText(fallbackPrompt) : null;\n if (fallback) return clip(fallback);\n return s.issueKey ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOA,SAAQ;AAKf,OAAO,UAAU;;;ACkBV,IAAM,gBAAgB,CAAC,OAAuC,EAAE,IAAI,aAAa,CAAC,GAAG,OAAO,EAAE,MAAM;AAGpG,SAAS,sBAAsB,SAAkC;AACtE,SAAO,CAAC,QAAQ,IAAI,GAAG,sBAAsB,QAAQ,KAAK,CAAC;AAC7D;AAGO,SAAS,oBAAoB,MAAc,UAAqC;AACrF,QAAM,MAAM,SAAS,IAAI;AACzB,SAAO,CAAC,KAAK,GAAG,IAAI,IAAI,SAAS,OAAO,CAAC,MAAM,sBAAsB,EAAE,KAAK,EAAE,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAChH;AAKO,SAAS,UAAU,UAA0B;AAClD,QAAM,OAAO,mBAAmB,QAAQ;AACxC,SAAO,CAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC;AAClC;AAOO,SAAS,eAAe,UAAoB,OAAa,UAAU,QAAQ,GAAc;AAC9F,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,MAAiB,CAAC;AACxB,WAAS,QAAQ,CAAC,IAAI,MAAM;AAC1B,eAAW,KAAK,KAAK,EAAE,GAAG;AACxB,UAAI,KAAK,IAAI,EAAE,EAAE,KAAM,IAAI,KAAK,EAAE,WAAW,QAAU;AACvD,WAAK,IAAI,EAAE,EAAE;AACb,UAAI,KAAK,CAAC;AAAA,IACZ;AAAA,EACF,CAAC;AACD,SAAO,IAAI,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,cAAc,EAAE,SAAS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Q;AAAA,IAER;AACA,UAAM,MAAM,GAAG,EAAE,UAAU,IAAI,KAAK,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,IAAI,MAAM,OAAO;AAC1F,UAAM,MAAM,KAAK,IAAI,EAAE;AACvB,QAAI,KAAK,QAAQ,IAAK,QAAO,IAAI;AACjC,UAAM,MAAM,MAAM;AAClB,SAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;AACzB,WAAO;AAAA,EACT;AACF;","names":["fs","cache","fs"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/pty/host-control.ts","../src/core/platform/shell-path.ts","../src/core/agents/agent-path.ts","../src/core/pty/resume.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { execFile } from 'node:child_process';\nimport { programPath } from '../platform/program-path.js';\nimport { ensureHost, probeHostDetailed } from './pty-host-client.js';\nimport { hostInfoPath, readHostInfo } from './pty-host-protocol.js';\nimport { isPidAlive, killTree } from '../platform/process.js';\n\n/**\n * Stopping and restarting the PTY host — the CLI's `work pty-host\n * --stop/--restart` and the dashboard's Restart share it. The persisted\n * session list stays, so the next host restores them with --continue.\n */\n\nexport type StopOutcome = 'stopped' | 'not-running' | 'stale-file' | 'unresponsive' | 'failed';\n\n/** A process's command line, or null when it isn't running or can't be read (Windows: CIM; elsewhere: ps). */\nexport function commandLineOf(pid: number): Promise<string | null> {\n return new Promise((resolve) => {\n const done = (err: Error | null, out: string) => resolve(err ? null : out.trim() || null);\n if (process.platform === 'win32')\n execFile(\n programPath('powershell'),\n ['-NoProfile', '-Command', `(Get-CimInstance Win32_Process -Filter 'ProcessId=${Math.trunc(pid)}').CommandLine`],\n { windowsHide: true, timeout: 15_000 },\n (err, out) => done(err, String(out)),\n );\n else\n execFile(programPath('ps'), ['-o', 'args=', '-p', String(Math.trunc(pid))], { windowsHide: true, timeout: 5000 }, (err, out) =>\n done(err, String(out)),\n );\n });\n}\n\n/**\n * The recorded pid really is a running PTY host of work's: alive, and its command line runs `pty-host` (not a\n * `--stop`/`--restart`/`--status` call). Pids get reused — on Windows fast — so a host that doesn't answer is only\n * force-stopped after this: blind, it could take down any process that took its number. Pure over its inputs.\n */\nexport function looksLikeHost(commandLine: string | null): boolean {\n return (\n !!commandLine && /(^|\\s|[\"'\\\\/])pty-host(\\s|$|[\"'])/.test(commandLine) && !/\\bpty-host\\b.*--(stop|restart|status)\\b/.test(commandLine)\n );\n}\n\n/**\n * Kill the running host and its PTYs. Only a PID that proves it's our host gets killed: it answers /health with the\n * discovery file's token and that same PID — or, with `force`, it doesn't answer at all (hung: a ConPTY start that\n * blocked its event loop) but its process is alive and runs `work pty-host` (`looksLikeHost`). The file survives\n * crashes and reboots (TerminateProcess skips cleanup), and Windows reuses PIDs. A stale file is just removed.\n */\nexport async function stopHost(\n kill: (pid: number) => boolean = killTree,\n probeTimeoutMs = 5000,\n opts: { force?: boolean; isOurHost?: (pid: number) => Promise<boolean> } = {},\n): Promise<StopOutcome> {\n const hostInfo = readHostInfo();\n if (!hostInfo) return 'not-running';\n // A busy host (restoring many sessions) can miss a short probe; give it\n // longer before concluding anything.\n const probe = await probeHostDetailed(hostInfo, probeTimeoutMs);\n if (probe.kind === 'timeout') {\n // Alive-but-slow must NOT be treated as stale: deleting the file would\n // orphan a live host, and --restart would then start a second one that\n // restores every session again. Keep the file, kill nothing — unless\n // asked to stop a hung one, and it proves to be ours.\n const ours = opts.isOurHost ?? (async (pid: number) => isPidAlive(pid) && looksLikeHost(await commandLineOf(pid)));\n if (!opts.force || !(await ours(hostInfo.pid))) return 'unresponsive';\n return killAndForget(kill, hostInfo.pid);\n }\n if (probe.kind !== 'host' || probe.pid !== hostInfo.pid) {\n // Nothing listening, or someone else on that port: the file is stale\n // (reboot, crash, PID/port reused). Remove it; kill nothing.\n removeInfo();\n return 'stale-file';\n }\n return killAndForget(kill, hostInfo.pid);\n}\n\nfunction killAndForget(kill: (pid: number) => boolean, pid: number): StopOutcome {\n const ok = kill(pid);\n // TerminateProcess means the host never runs its own cleanup.\n removeInfo();\n return ok ? 'stopped' : 'failed';\n}\n\nfunction removeInfo(): void {\n try {\n fs.unlinkSync(hostInfoPath());\n } catch {\n /* */\n }\n}\n\n/**\n * Stop the host and start a new one, which restores every saved session with --continue. `force`: a host that\n * doesn't answer is stopped too (see stopHost). Never starts a second host beside one it couldn't stop.\n */\nexport async function restartHost(\n workBin: string,\n opts: { force?: boolean } = {},\n steps: { stop?: (force: boolean) => Promise<StopOutcome>; start?: (workBin: string) => Promise<{ pid: number }>; pauseMs?: number } = {},\n): Promise<{ outcome: StopOutcome; pid: number | null }> {\n const outcome = await (steps.stop ?? ((force) => stopHost(killTree, 5000, { force })))(!!opts.force);\n if (outcome === 'failed' || outcome === 'unresponsive') return { outcome, pid: null };\n // The old one's port and lock let go before the new one takes them.\n await new Promise((r) => setTimeout(r, steps.pauseMs ?? 500));\n const host = await (steps.start ?? ensureHost)(workBin);\n return { outcome, pid: host.pid };\n}\n","import { spawnSync, type SpawnSyncOptionsWithStringEncoding } from 'node:child_process';\nimport path from 'node:path';\nimport { findOnPath } from './find-on-path.js';\nimport { report } from './report.js';\nimport { debugLog } from './logger.js';\nimport { detachHere } from './process.js';\n\n/**\n * The PATH of the user's login shell, for a work started without one.\n *\n * Reported from a Mac: every session ended at once with \"session exited with code 1\", and Enter\n * gave the same. The desktop app started from the Dock or Finder gets the system's minimal PATH\n * (/usr/bin:/bin:/usr/sbin:/sbin), not the one the user's shell sets up, and passes it on to work\n * web, the PTY host and every Claude: `claude` (in ~/.local/bin, /opt/homebrew/bin, an nvm folder…)\n * isn't found, and node-pty's child exits with 1 when its exec fails. So when work web or the PTY\n * host starts on macOS or Linux and the agent's command isn't on its PATH, it asks the login shell\n * for its PATH (`$SHELL -ilc`, as a terminal would set it up) and puts it first. Started from a\n * terminal, the command is found and nothing is asked.\n */\n\nconst MARK = '__WORK_SHELL_PATH__';\n\n/** The shell's PATH first, then what we had that it lacks (e.g. the app's ~/.work/bin). */\nexport function mergePath(current: string | undefined, shellPath: string, sep = path.delimiter): string {\n const out: string[] = [];\n for (const d of [...shellPath.split(sep), ...(current ?? '').split(sep)]) if (d && !out.includes(d)) out.push(d);\n return out.join(sep);\n}\n\n/** The PATH between the markers of the shell's output (an interactive shell may print a greeting around it). */\nexport function parseShellPath(stdout: string): string | null {\n const m = new RegExp(`${MARK}(.*?)${MARK}`, 's').exec(stdout);\n const p = m?.[1].trim();\n return p ? p : null;\n}\n\n/** How long the login shell may take to say its PATH. */\nexport const SHELL_PATH_TIMEOUT_MS = 5_000;\n\n/** The shell's arguments: a login, interactive shell (what a terminal runs) printing its PATH between markers. */\nexport const shellPathArgs = (): string[] => ['-ilc', `printf '%s%s%s' '${MARK}' \"$PATH\" '${MARK}'`];\n\n/**\n * How it's started. `killSignal: SIGKILL`: an interactive bash or zsh ignores SIGTERM (spawnSync's\n * default at the timeout), and Node then waits for it — a stuck profile held work web up for as long as\n * it hung (reproduced: a 2 s timeout returned after 8 s). `detached` (POSIX): its own session, so it\n * never takes this terminal's foreground group — killed while holding it, it left `work web` in the\n * background, where Ctrl+C no longer reached it (reproduced).\n */\nexport const shellPathSpawnOptions = (timeoutMs = SHELL_PATH_TIMEOUT_MS): SpawnSyncOptionsWithStringEncoding =>\n // `detached` isn't in @types/node's spawnSync options, but spawnSync honors it (spawn_sync reads it).\n ({\n encoding: 'utf8',\n timeout: timeoutMs,\n killSignal: 'SIGKILL',\n detached: detachHere(),\n stdio: ['ignore', 'pipe', 'ignore'],\n windowsHide: true,\n }) as SpawnSyncOptionsWithStringEncoding;\n\ntype ShellRun = (cmd: string, args: string[]) => { stdout?: string | null; status?: number | null; signal?: string | null; error?: Error };\n\n/** Ask the login shell for its PATH: its PATH, or why it couldn't say (a timeout, no such shell, no markers). */\nexport function readShellPath(\n shell = process.env.SHELL || '/bin/zsh',\n run: ShellRun = (cmd, args) => spawnSync(cmd, args, shellPathSpawnOptions()),\n): { path: string } | { why: string } {\n try {\n const r = run(shell, shellPathArgs());\n const p = parseShellPath(r.stdout ?? '');\n if (p) return { path: p };\n const how = r.error\n ? r.error.message\n : r.signal\n ? `stopped by ${r.signal} (over ${SHELL_PATH_TIMEOUT_MS / 1000} s?)`\n : `exit ${r.status ?? '?'}, no PATH printed`;\n return { why: `${shell} -ilc: ${how}` };\n } catch (err) {\n return { why: `${shell} -ilc: ${(err as Error).message}` };\n }\n}\n\n/**\n * Make sure the commands in `need` (the agent's binary) can be found: on macOS and Linux, when one\n * isn't on PATH, the login shell's PATH is merged into this process's (which everything it starts\n * inherits). Says what it did; never throws.\n */\nexport function ensureShellPath(\n need: string[],\n opts: {\n platform?: NodeJS.Platform;\n env?: NodeJS.ProcessEnv;\n readPath?: () => { path: string } | { why: string };\n find?: (cmd: string, env: NodeJS.ProcessEnv) => string | null;\n } = {},\n): 'found' | 'added' | 'unavailable' {\n const platform = opts.platform ?? process.platform;\n const env = opts.env ?? process.env;\n if (platform === 'win32') return 'found';\n const find = opts.find ?? ((c: string, e: NodeJS.ProcessEnv) => findOnPath(c, e, platform));\n const missing = need.filter((c) => !find(c, env));\n if (!missing.length) return 'found';\n // Said in the debug log too: started by the desktop app, nothing shows what a reporter prints.\n const say = (level: 'info' | 'warn', text: string) => {\n report(level, text);\n debugLog(level === 'warn' ? 'WARN' : 'INFO', text);\n };\n const read = (opts.readPath ?? (() => readShellPath(env.SHELL)))();\n if ('why' in read) {\n say('warn', `${missing.join(', ')} isn't on PATH (${env.PATH ?? ''}), and the login shell's PATH couldn't be read: ${read.why}`);\n return 'unavailable';\n }\n env.PATH = mergePath(env.PATH, read.path);\n const still = missing.filter((c) => !find(c, env));\n say(\n still.length ? 'warn' : 'info',\n still.length\n ? `${still.join(', ')} isn't on PATH, even with the login shell's (${env.PATH})`\n : `${missing.join(', ')} found with the login shell's PATH: using it (${env.PATH})`,\n );\n return 'added';\n}\n","import { agentFor, agentSettings, assistantAgent, internalAgent } from './index.js';\nimport type { AgentSettings } from './index.js';\nimport { ensureShellPath } from '../platform/shell-path.js';\nimport { debugLog } from '../platform/logger.js';\n\n/**\n * The agents' commands, found on PATH before work web or the PTY host starts any of them\n * (`core/platform/shell-path.ts` says why: the Mac app from the Dock gets the system's PATH).\n */\n\n/** The commands work starts agents with, from the registry: new sessions', the Ctrl+K assistant's, the summaries'. */\nexport function agentCommands(settings: AgentSettings = agentSettings()): string[] {\n return [...new Set([agentFor(settings), assistantAgent(settings), internalAgent(settings)].map((a) => a.launch.tool(settings).cmd))];\n}\n\n/** For `work web` and the PTY host as they start (not wd's lean server: it starts no agent). Never throws. */\nexport function ensureAgentPath(\n deps: { commands?: () => string[]; ensure?: (need: string[]) => ReturnType<typeof ensureShellPath> } = {},\n): ReturnType<typeof ensureShellPath> | 'failed' {\n try {\n return (deps.ensure ?? ensureShellPath)((deps.commands ?? agentCommands)());\n } catch (err) {\n debugLog('WARN', 'finding the agents on PATH failed:', err);\n return 'failed';\n }\n}\n","import { validGrid } from './terminal-size.js';\n\n/**\n * Reattach where a client left off (terminal-rendering.md, \"Reattach where you left off\"). Pure; the Terminal tab and\n * the PTY host share it.\n *\n * Every screen the host sends (the `replay` frame) says which output stream it belongs to (`stream`: one per PTY entry\n * in one host, so a new spawn under the same id after the entry ended, or a host started again, is another stream) and\n * the offset it stands at (`offset`: characters of output since the entry was spawned, the pacer's unit, UTF-16 code\n * units). A restart or halt of its agent in place keeps the entry, and so the stream and the count: the clients attached\n * through it are sent the new process's output as it continues the old one's, with no screen in between, and a client\n * resuming across it is sent the same characters from its offset (pty-registry.test.ts, \"across a restart\"). Live\n * output follows in frames that are contiguous slices of that output, so a client knows its offset without any stamp\n * on them: the screen's offset plus what it was sent since (`utf16Length` of each binary frame, flow-control.ts).\n *\n * Reconnecting, a client that kept its screen states `?resume=<stream>-<offset>-<cols>x<rows>`: it has drawn\n * everything of that stream up to that offset, and its terminal is that grid. If the host can prove that sending what\n * came since is all it needs, it sends that (`replay` with `resumed: true`) and no screen; otherwise a screen as on\n * any attach. Absent, or from an older host or client, nothing changes: a screen.\n */\n\n/** The attach address's parameter a reconnecting client states its position in. An older host ignores it. */\nexport const RESUME_PARAM = 'resume';\n\n/** Where a client stands in a PTY's output: it has drawn all of `stream` up to `offset`, at this grid. */\nexport interface ResumePoint {\n stream: string;\n offset: number;\n cols: number;\n rows: number;\n}\n\n/** A stream id: what the host makes (pty-registry.ts), hex. */\nconst STREAM = /^[0-9a-f]{8,64}$/;\nconst FORMAT = /^([0-9a-f]{8,64})-(\\d{1,15})-(\\d{1,4})x(\\d{1,4})$/;\n\nexport function isStreamId(s: unknown): s is string {\n return typeof s === 'string' && STREAM.test(s);\n}\n\n/** `url` with the client's position added (`?resume=…`). */\nexport function withResume(url: string, at: ResumePoint | null | undefined): string {\n if (!at) return url;\n const value = `${at.stream}-${at.offset}-${at.cols}x${at.rows}`;\n return `${url}${url.includes('?') ? '&' : '?'}${RESUME_PARAM}=${value}`;\n}\n\n/** The position stated on an attach address, or null when there is none or it isn't one (then: a screen). */\nexport function resumeFromParams(params: URLSearchParams): ResumePoint | null {\n const m = FORMAT.exec(params.get(RESUME_PARAM) ?? '');\n if (!m) return null;\n const offset = Number(m[2]);\n const grid = validGrid(Number(m[3]), Number(m[4]));\n if (!Number.isSafeInteger(offset) || !grid) return null;\n return { stream: m[1], offset, cols: grid.cols, rows: grid.rows };\n}\n\n/** What a `replay` frame says about the stream (fields a host from before sends none of). */\nexport interface ReplayPosition {\n stream?: unknown;\n offset?: unknown;\n resumed?: unknown;\n}\n\n/**\n * A client's position in the PTY's output, as it receives it: set by each `replay` frame (a screen, or what it missed),\n * moved on by each binary frame. Unknown (null) when the host said nothing of it (an older host): then the client\n * never asks to resume.\n */\nexport class StreamPosition {\n private stream: string | null = null;\n private at = 0;\n\n /** A `replay` frame: it stands at its offset now (a screen replaces what was drawn; what was missed continues it). */\n replay(msg: ReplayPosition): void {\n const ok = isStreamId(msg.stream) && typeof msg.offset === 'number' && Number.isSafeInteger(msg.offset) && msg.offset >= 0;\n this.stream = ok ? (msg.stream as string) : null;\n this.at = ok ? (msg.offset as number) : 0;\n }\n\n /** A frame of live output, `chars` long in the host's unit (`utf16Length` of its bytes). */\n output(chars: number): void {\n if (this.stream !== null && chars > 0) this.at += chars;\n }\n\n /** Where it stands, at its terminal's grid; null when unknown. */\n point(cols: number, rows: number): ResumePoint | null {\n if (this.stream === null) return null;\n const grid = validGrid(cols, rows);\n return grid ? { stream: this.stream, offset: this.at, cols: grid.cols, rows: grid.rows } : null;\n }\n\n /** Forget it (the screen will be replaced whatever the host says: a fresh terminal). */\n forget(): void {\n this.stream = null;\n this.at = 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,SAAS,gBAAgB;AAelB,SAAS,cAAc,KAAqC;AACjE,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,OAAO,CAAC,KAAmB,QAAgB,QAAQ,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI;AACxF,QAAI,QAAQ,aAAa;AACvB;AAAA,QACE,YAAY,YAAY;AAAA,QACxB,CAAC,cAAc,YAAY,qDAAqD,KAAK,MAAM,GAAG,CAAC,gBAAgB;AAAA,QAC/G,EAAE,aAAa,MAAM,SAAS,KAAO;AAAA,QACrC,CAAC,KAAK,QAAQ,KAAK,KAAK,OAAO,GAAG,CAAC;AAAA,MACrC;AAAA;AAEA;AAAA,QAAS,YAAY,IAAI;AAAA,QAAG,CAAC,MAAM,SAAS,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC;AAAA,QAAG,EAAE,aAAa,MAAM,SAAS,IAAK;AAAA,QAAG,CAAC,KAAK,QACtH,KAAK,KAAK,OAAO,GAAG,CAAC;AAAA,MACvB;AAAA,EACJ,CAAC;AACH;AAOO,SAAS,cAAc,aAAqC;AACjE,SACE,CAAC,CAAC,eAAe,oCAAoC,KAAK,WAAW,KAAK,CAAC,0CAA0C,KAAK,WAAW;AAEzI;AAQA,eAAsB,SACpB,OAAiC,UACjC,iBAAiB,K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