@moberg_hr/work-tree 2.22.2 → 2.22.4

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 (244) hide show
  1. package/dist/{account-37DWHKUY.js → account-J55P3HXH.js} +22 -18
  2. package/dist/account-J55P3HXH.js.map +1 -0
  3. package/dist/{add-repo-DDJ3KYAR.js → add-repo-ALVEGU25.js} +9 -9
  4. package/dist/{answer-6LVQFTR7.js → answer-CI2SPQQL.js} +7 -7
  5. package/dist/{attach-MWUYIY3K.js → attach-7LBIFBLX.js} +14 -14
  6. package/dist/bin.js +2 -2
  7. package/dist/{block-IJDNEBIA.js → block-TVIYWRJ5.js} +9 -9
  8. package/dist/{broadcast-YRQWTE3C.js → broadcast-GZNMZFOY.js} +5 -5
  9. package/dist/{catchup-DJ4GAE4C.js → catchup-ZURJI6BF.js} +10 -10
  10. package/dist/{child-AXSUNVZF.js → child-K6YYF6MQ.js} +6 -6
  11. package/dist/{chunk-TIGPNEGX.js → chunk-23QLXVH6.js} +9 -9
  12. package/dist/{chunk-OHX7WKZU.js → chunk-4QMWNAEJ.js} +2 -2
  13. package/dist/{chunk-FPX33QEY.js → chunk-5FIUVBUC.js} +5 -5
  14. package/dist/{chunk-CR7KJ4PE.js → chunk-5P27YL64.js} +7 -7
  15. package/dist/{chunk-37Y65CNK.js → chunk-6Y3VLCKA.js} +3 -3
  16. package/dist/{chunk-IQF5ID6Z.js → chunk-7Q5PBXF6.js} +3 -3
  17. package/dist/{chunk-NYN5MJEV.js → chunk-7ZOY2QQN.js} +2 -2
  18. package/dist/{chunk-NBHTNKDM.js → chunk-AITL3JYB.js} +2 -2
  19. package/dist/chunk-AITL3JYB.js.map +1 -0
  20. package/dist/{chunk-XNHL3E4V.js → chunk-AIYZJ7XD.js} +4 -4
  21. package/dist/{chunk-VUGFAGL5.js → chunk-ATQB6PTV.js} +2 -2
  22. package/dist/{chunk-6O4FII75.js → chunk-B2WV5RAL.js} +4 -4
  23. package/dist/{chunk-7PAVUZZJ.js → chunk-CA56ETYX.js} +4 -4
  24. package/dist/{chunk-RSZ5DCM4.js → chunk-CMRTNTMU.js} +5 -5
  25. package/dist/{chunk-FIEEJ3UL.js → chunk-D2SVBU7R.js} +2 -2
  26. package/dist/{chunk-7PIMCNLP.js → chunk-DC73NF67.js} +3 -3
  27. package/dist/{chunk-OGIJE6B3.js → chunk-DCENKA6E.js} +2 -2
  28. package/dist/{chunk-ORBZDEPN.js → chunk-DF4GOVDE.js} +2 -2
  29. package/dist/{chunk-WUNXXRAP.js → chunk-EA4C6TVY.js} +3 -3
  30. package/dist/{chunk-YQSWVHKK.js → chunk-ED6YLB4S.js} +13 -13
  31. package/dist/chunk-ED6YLB4S.js.map +1 -0
  32. package/dist/{chunk-JBQOBCH4.js → chunk-EEHPZMS3.js} +2 -2
  33. package/dist/{chunk-Y5JKFPII.js → chunk-EYJ42LDG.js} +4 -4
  34. package/dist/{chunk-6ZJ54FJP.js → chunk-F4UIKOU6.js} +4 -4
  35. package/dist/{chunk-HF4VUIGE.js → chunk-FGBLFF4O.js} +2 -2
  36. package/dist/{chunk-RHWL5IJC.js → chunk-FV7BSQPQ.js} +2 -2
  37. package/dist/{chunk-V4MABHCF.js → chunk-G4T2HGLJ.js} +4 -4
  38. package/dist/{chunk-KKN5YKPX.js → chunk-GNERWNZY.js} +3 -3
  39. package/dist/{chunk-VRMALBZK.js → chunk-GQ5WECPJ.js} +2 -2
  40. package/dist/{chunk-NO27TCWS.js → chunk-HUW27DSB.js} +57 -57
  41. package/dist/{chunk-LJXQXYSC.js → chunk-IU6LA6EB.js} +3 -3
  42. package/dist/{chunk-QWD76K3E.js → chunk-KQMHGEI2.js} +805 -739
  43. package/dist/chunk-KQMHGEI2.js.map +1 -0
  44. package/dist/{chunk-ZX6AIIN4.js → chunk-KU3TQAA7.js} +3 -3
  45. package/dist/{chunk-FNFU4QZP.js → chunk-LV5JRLBM.js} +2 -2
  46. package/dist/{chunk-ZHPDAUWH.js → chunk-NOQA7MJ4.js} +2 -2
  47. package/dist/{chunk-YFEPBQUA.js → chunk-NYGKSOQ4.js} +6 -6
  48. package/dist/{chunk-SIXBZSYC.js → chunk-OCUUM755.js} +2 -2
  49. package/dist/{chunk-H3W335HC.js → chunk-PUJSLL6R.js} +5 -5
  50. package/dist/{chunk-UWRFPX5Q.js → chunk-Q2B3NUSM.js} +3 -3
  51. package/dist/{chunk-NQDRE5QJ.js → chunk-QNOJOZYK.js} +2 -2
  52. package/dist/{chunk-2RFBSYDL.js → chunk-QOLHDDM2.js} +4 -4
  53. package/dist/{chunk-UEZASL3E.js → chunk-RLPC3YKZ.js} +2 -2
  54. package/dist/{chunk-5C6N447O.js → chunk-RNPNBGVX.js} +2 -2
  55. package/dist/{chunk-GRHVKD2K.js → chunk-RTCTD5PJ.js} +3 -3
  56. package/dist/{chunk-MVC4H7UY.js → chunk-SDYY5MHW.js} +6 -6
  57. package/dist/chunk-TDJVYUF2.js +9 -0
  58. package/dist/{chunk-OF3QDYVU.js → chunk-TOMDOA4P.js} +2 -2
  59. package/dist/{chunk-FWLYUYJN.js → chunk-UAF2YFLZ.js} +44 -12
  60. package/dist/chunk-UAF2YFLZ.js.map +1 -0
  61. package/dist/{chunk-DLV7TRON.js → chunk-USENBMUV.js} +2 -2
  62. package/dist/{chunk-BIOSMX6Z.js → chunk-WRDULHAN.js} +14 -11
  63. package/dist/chunk-WRDULHAN.js.map +1 -0
  64. package/dist/{chunk-OOFCBN43.js → chunk-YO3BNAAK.js} +4 -4
  65. package/dist/{chunk-7GFPJXOJ.js → chunk-Z4FWXDJG.js} +3 -3
  66. package/dist/{chunk-3ELAI6JY.js → chunk-Z4P23XG3.js} +4 -4
  67. package/dist/{chunk-5PPRIUIC.js → chunk-ZO7TF5OL.js} +3 -3
  68. package/dist/{chunk-RLDMZLAQ.js → chunk-ZTWZS5RK.js} +3 -3
  69. package/dist/{cleanup-DN4H43RE.js → cleanup-G4WQACD6.js} +26 -26
  70. package/dist/{cli-7Z3SDBOO.js → cli-XI2W5KRQ.js} +3 -3
  71. package/dist/{color-ENEYNILL.js → color-C223W3Z6.js} +7 -7
  72. package/dist/{config-SWQ5QZWI.js → config-KQYXQCQA.js} +7 -7
  73. package/dist/{coordinate-73WGNBTT.js → coordinate-4E5GIMC6.js} +7 -7
  74. package/dist/{diff-I6ODIOEF.js → diff-HEOLTXO2.js} +8 -8
  75. package/dist/{digest-44QUV6XY.js → digest-GYF4YLUH.js} +7 -7
  76. package/dist/{fork-JSYC6VP4.js → fork-B35ONP3Z.js} +23 -23
  77. package/dist/{history-5W4SXTTY.js → history-25DNQKKC.js} +5 -5
  78. package/dist/{hook-K62MH6RA.js → hook-B4JO2X57.js} +8 -8
  79. package/dist/{hydrate-3LOALPJG.js → hydrate-IJEKNZIP.js} +5 -5
  80. package/dist/{init-C6JA37UJ.js → init-UJVOUDJI.js} +9 -9
  81. package/dist/{install-skills-KSLTHRHH.js → install-skills-FV2L5QHE.js} +5 -5
  82. package/dist/install-skills-bin.js +4 -4
  83. package/dist/{keep-IIVBHYTG.js → keep-PKXGFZO2.js} +7 -7
  84. package/dist/{list-LGONVFPI.js → list-VYQ3QE2H.js} +5 -5
  85. package/dist/{move-K7BY73WF.js → move-IAZY23ZX.js} +12 -12
  86. package/dist/{note-YRPPN6S5.js → note-6HQUKUYY.js} +7 -7
  87. package/dist/{overlaps-42USMLAZ.js → overlaps-CGP3RJOW.js} +10 -10
  88. package/dist/{pin-NDWEAY2R.js → pin-PAWGQ4Q2.js} +7 -7
  89. package/dist/{pr-VMNZGFUF.js → pr-OJOGE3A3.js} +17 -17
  90. package/dist/{prune-WETEKBQX.js → prune-42MS36OR.js} +24 -24
  91. package/dist/{pty-host-NANTBLHW.js → pty-host-ULVOMW3R.js} +12 -12
  92. package/dist/{read-VL6ZL7GI.js → read-ATNCW4KH.js} +7 -7
  93. package/dist/{recent-UQP3IR3S.js → recent-MTBFQT36.js} +15 -13
  94. package/dist/recent-MTBFQT36.js.map +1 -0
  95. package/dist/{remove-4QHUYGE2.js → remove-GLDJOKUI.js} +25 -25
  96. package/dist/{report-YES72I5M.js → report-AK7Z2Y4S.js} +6 -6
  97. package/dist/{restart-E4FSMFVK.js → restart-DEPDGEZB.js} +7 -7
  98. package/dist/{resume-MYXJKGMG.js → resume-C2QPKKFN.js} +15 -13
  99. package/dist/resume-C2QPKKFN.js.map +1 -0
  100. package/dist/{review-IVMH2HDQ.js → review-RYAGH3PY.js} +6 -6
  101. package/dist/{run-YW7L4AND.js → run-WNP2SMNW.js} +5 -5
  102. package/dist/{screen-IZTZAK74.js → screen-P746M4F2.js} +7 -7
  103. package/dist/{search-CVFYS2CC.js → search-XQ2WMK5X.js} +5 -5
  104. package/dist/{section-7LOOR4LX.js → section-Q7TPOV7U.js} +7 -7
  105. package/dist/{send-RQGTUJ5E.js → send-EGG23J2B.js} +8 -8
  106. package/dist/{sessions-RFSGXKGU.js → sessions-2NNCWIND.js} +21 -21
  107. package/dist/{show-LVKLIXSK.js → show-KSMC7AJL.js} +6 -6
  108. package/dist/{snooze-Z2UEHKZL.js → snooze-4LVYUQEX.js} +7 -7
  109. package/dist/{start-NTPMFY6T.js → start-YKLLXW3L.js} +7 -7
  110. package/dist/{status-4RJXTMEX.js → status-4HGP4ZEF.js} +8 -8
  111. package/dist/{stop-ATV324OT.js → stop-YBQL6NFF.js} +7 -7
  112. package/dist/{sync-NWES4BRO.js → sync-DUXN2MFJ.js} +24 -24
  113. package/dist/{time-YDXPHJAV.js → time-Q42HPZZ3.js} +8 -8
  114. package/dist/{timesheet-Z5SNLTVF.js → timesheet-YJ6O3GUU.js} +10 -10
  115. package/dist/{tree-MU5RQGDG.js → tree-H2UYE6LH.js} +26 -24
  116. package/dist/tree-H2UYE6LH.js.map +1 -0
  117. package/dist/{update-35KH4XZ7.js → update-RGNKMRUL.js} +12 -12
  118. package/dist/{usage-AWYA6R6J.js → usage-YZRZKJ3H.js} +7 -7
  119. package/dist/{usage-ask-52X2RMQC.js → usage-ask-BYPNLA2B.js} +2 -2
  120. package/dist/{version-6A3FWFQR.js → version-4IOMOIDP.js} +3 -3
  121. package/dist/{wait-H4YPUGGF.js → wait-YOHPFWVJ.js} +8 -8
  122. package/dist/wd-bin.js +2 -2
  123. package/dist/web/assets/{PtyView-D55ZhVC2.js → PtyView-CW2GxKSc.js} +2 -2
  124. package/dist/web/assets/{PtyView-D55ZhVC2.js.map → PtyView-CW2GxKSc.js.map} +1 -1
  125. package/dist/web/assets/{index-36vcNwHw.js → index-DEdSxNCA.js} +6 -6
  126. package/dist/web/assets/index-DEdSxNCA.js.map +1 -0
  127. package/dist/web/index.html +1 -1
  128. package/dist/{web-KHE3G6VQ.js → web-EC3KKH6E.js} +75 -53
  129. package/dist/web-EC3KKH6E.js.map +1 -0
  130. package/npm-shrinkwrap.json +2 -2
  131. package/package.json +1 -1
  132. package/dist/account-37DWHKUY.js.map +0 -1
  133. package/dist/chunk-76NYQDUN.js +0 -9
  134. package/dist/chunk-BIOSMX6Z.js.map +0 -1
  135. package/dist/chunk-FWLYUYJN.js.map +0 -1
  136. package/dist/chunk-NBHTNKDM.js.map +0 -1
  137. package/dist/chunk-QWD76K3E.js.map +0 -1
  138. package/dist/chunk-YQSWVHKK.js.map +0 -1
  139. package/dist/recent-UQP3IR3S.js.map +0 -1
  140. package/dist/resume-MYXJKGMG.js.map +0 -1
  141. package/dist/tree-MU5RQGDG.js.map +0 -1
  142. package/dist/web/assets/index-36vcNwHw.js.map +0 -1
  143. package/dist/web-KHE3G6VQ.js.map +0 -1
  144. /package/dist/{add-repo-DDJ3KYAR.js.map → add-repo-ALVEGU25.js.map} +0 -0
  145. /package/dist/{answer-6LVQFTR7.js.map → answer-CI2SPQQL.js.map} +0 -0
  146. /package/dist/{attach-MWUYIY3K.js.map → attach-7LBIFBLX.js.map} +0 -0
  147. /package/dist/{block-IJDNEBIA.js.map → block-TVIYWRJ5.js.map} +0 -0
  148. /package/dist/{broadcast-YRQWTE3C.js.map → broadcast-GZNMZFOY.js.map} +0 -0
  149. /package/dist/{catchup-DJ4GAE4C.js.map → catchup-ZURJI6BF.js.map} +0 -0
  150. /package/dist/{child-AXSUNVZF.js.map → child-K6YYF6MQ.js.map} +0 -0
  151. /package/dist/{chunk-TIGPNEGX.js.map → chunk-23QLXVH6.js.map} +0 -0
  152. /package/dist/{chunk-OHX7WKZU.js.map → chunk-4QMWNAEJ.js.map} +0 -0
  153. /package/dist/{chunk-FPX33QEY.js.map → chunk-5FIUVBUC.js.map} +0 -0
  154. /package/dist/{chunk-CR7KJ4PE.js.map → chunk-5P27YL64.js.map} +0 -0
  155. /package/dist/{chunk-37Y65CNK.js.map → chunk-6Y3VLCKA.js.map} +0 -0
  156. /package/dist/{chunk-IQF5ID6Z.js.map → chunk-7Q5PBXF6.js.map} +0 -0
  157. /package/dist/{chunk-NYN5MJEV.js.map → chunk-7ZOY2QQN.js.map} +0 -0
  158. /package/dist/{chunk-XNHL3E4V.js.map → chunk-AIYZJ7XD.js.map} +0 -0
  159. /package/dist/{chunk-VUGFAGL5.js.map → chunk-ATQB6PTV.js.map} +0 -0
  160. /package/dist/{chunk-6O4FII75.js.map → chunk-B2WV5RAL.js.map} +0 -0
  161. /package/dist/{chunk-7PAVUZZJ.js.map → chunk-CA56ETYX.js.map} +0 -0
  162. /package/dist/{chunk-RSZ5DCM4.js.map → chunk-CMRTNTMU.js.map} +0 -0
  163. /package/dist/{chunk-FIEEJ3UL.js.map → chunk-D2SVBU7R.js.map} +0 -0
  164. /package/dist/{chunk-7PIMCNLP.js.map → chunk-DC73NF67.js.map} +0 -0
  165. /package/dist/{chunk-OGIJE6B3.js.map → chunk-DCENKA6E.js.map} +0 -0
  166. /package/dist/{chunk-ORBZDEPN.js.map → chunk-DF4GOVDE.js.map} +0 -0
  167. /package/dist/{chunk-WUNXXRAP.js.map → chunk-EA4C6TVY.js.map} +0 -0
  168. /package/dist/{chunk-JBQOBCH4.js.map → chunk-EEHPZMS3.js.map} +0 -0
  169. /package/dist/{chunk-Y5JKFPII.js.map → chunk-EYJ42LDG.js.map} +0 -0
  170. /package/dist/{chunk-6ZJ54FJP.js.map → chunk-F4UIKOU6.js.map} +0 -0
  171. /package/dist/{chunk-HF4VUIGE.js.map → chunk-FGBLFF4O.js.map} +0 -0
  172. /package/dist/{chunk-RHWL5IJC.js.map → chunk-FV7BSQPQ.js.map} +0 -0
  173. /package/dist/{chunk-V4MABHCF.js.map → chunk-G4T2HGLJ.js.map} +0 -0
  174. /package/dist/{chunk-KKN5YKPX.js.map → chunk-GNERWNZY.js.map} +0 -0
  175. /package/dist/{chunk-VRMALBZK.js.map → chunk-GQ5WECPJ.js.map} +0 -0
  176. /package/dist/{chunk-NO27TCWS.js.map → chunk-HUW27DSB.js.map} +0 -0
  177. /package/dist/{chunk-LJXQXYSC.js.map → chunk-IU6LA6EB.js.map} +0 -0
  178. /package/dist/{chunk-ZX6AIIN4.js.map → chunk-KU3TQAA7.js.map} +0 -0
  179. /package/dist/{chunk-FNFU4QZP.js.map → chunk-LV5JRLBM.js.map} +0 -0
  180. /package/dist/{chunk-ZHPDAUWH.js.map → chunk-NOQA7MJ4.js.map} +0 -0
  181. /package/dist/{chunk-YFEPBQUA.js.map → chunk-NYGKSOQ4.js.map} +0 -0
  182. /package/dist/{chunk-SIXBZSYC.js.map → chunk-OCUUM755.js.map} +0 -0
  183. /package/dist/{chunk-H3W335HC.js.map → chunk-PUJSLL6R.js.map} +0 -0
  184. /package/dist/{chunk-UWRFPX5Q.js.map → chunk-Q2B3NUSM.js.map} +0 -0
  185. /package/dist/{chunk-NQDRE5QJ.js.map → chunk-QNOJOZYK.js.map} +0 -0
  186. /package/dist/{chunk-2RFBSYDL.js.map → chunk-QOLHDDM2.js.map} +0 -0
  187. /package/dist/{chunk-UEZASL3E.js.map → chunk-RLPC3YKZ.js.map} +0 -0
  188. /package/dist/{chunk-5C6N447O.js.map → chunk-RNPNBGVX.js.map} +0 -0
  189. /package/dist/{chunk-GRHVKD2K.js.map → chunk-RTCTD5PJ.js.map} +0 -0
  190. /package/dist/{chunk-MVC4H7UY.js.map → chunk-SDYY5MHW.js.map} +0 -0
  191. /package/dist/{chunk-76NYQDUN.js.map → chunk-TDJVYUF2.js.map} +0 -0
  192. /package/dist/{chunk-OF3QDYVU.js.map → chunk-TOMDOA4P.js.map} +0 -0
  193. /package/dist/{chunk-DLV7TRON.js.map → chunk-USENBMUV.js.map} +0 -0
  194. /package/dist/{chunk-OOFCBN43.js.map → chunk-YO3BNAAK.js.map} +0 -0
  195. /package/dist/{chunk-7GFPJXOJ.js.map → chunk-Z4FWXDJG.js.map} +0 -0
  196. /package/dist/{chunk-3ELAI6JY.js.map → chunk-Z4P23XG3.js.map} +0 -0
  197. /package/dist/{chunk-5PPRIUIC.js.map → chunk-ZO7TF5OL.js.map} +0 -0
  198. /package/dist/{chunk-RLDMZLAQ.js.map → chunk-ZTWZS5RK.js.map} +0 -0
  199. /package/dist/{cleanup-DN4H43RE.js.map → cleanup-G4WQACD6.js.map} +0 -0
  200. /package/dist/{cli-7Z3SDBOO.js.map → cli-XI2W5KRQ.js.map} +0 -0
  201. /package/dist/{color-ENEYNILL.js.map → color-C223W3Z6.js.map} +0 -0
  202. /package/dist/{config-SWQ5QZWI.js.map → config-KQYXQCQA.js.map} +0 -0
  203. /package/dist/{coordinate-73WGNBTT.js.map → coordinate-4E5GIMC6.js.map} +0 -0
  204. /package/dist/{diff-I6ODIOEF.js.map → diff-HEOLTXO2.js.map} +0 -0
  205. /package/dist/{digest-44QUV6XY.js.map → digest-GYF4YLUH.js.map} +0 -0
  206. /package/dist/{fork-JSYC6VP4.js.map → fork-B35ONP3Z.js.map} +0 -0
  207. /package/dist/{history-5W4SXTTY.js.map → history-25DNQKKC.js.map} +0 -0
  208. /package/dist/{hook-K62MH6RA.js.map → hook-B4JO2X57.js.map} +0 -0
  209. /package/dist/{hydrate-3LOALPJG.js.map → hydrate-IJEKNZIP.js.map} +0 -0
  210. /package/dist/{init-C6JA37UJ.js.map → init-UJVOUDJI.js.map} +0 -0
  211. /package/dist/{install-skills-KSLTHRHH.js.map → install-skills-FV2L5QHE.js.map} +0 -0
  212. /package/dist/{keep-IIVBHYTG.js.map → keep-PKXGFZO2.js.map} +0 -0
  213. /package/dist/{list-LGONVFPI.js.map → list-VYQ3QE2H.js.map} +0 -0
  214. /package/dist/{move-K7BY73WF.js.map → move-IAZY23ZX.js.map} +0 -0
  215. /package/dist/{note-YRPPN6S5.js.map → note-6HQUKUYY.js.map} +0 -0
  216. /package/dist/{overlaps-42USMLAZ.js.map → overlaps-CGP3RJOW.js.map} +0 -0
  217. /package/dist/{pin-NDWEAY2R.js.map → pin-PAWGQ4Q2.js.map} +0 -0
  218. /package/dist/{pr-VMNZGFUF.js.map → pr-OJOGE3A3.js.map} +0 -0
  219. /package/dist/{prune-WETEKBQX.js.map → prune-42MS36OR.js.map} +0 -0
  220. /package/dist/{pty-host-NANTBLHW.js.map → pty-host-ULVOMW3R.js.map} +0 -0
  221. /package/dist/{read-VL6ZL7GI.js.map → read-ATNCW4KH.js.map} +0 -0
  222. /package/dist/{remove-4QHUYGE2.js.map → remove-GLDJOKUI.js.map} +0 -0
  223. /package/dist/{report-YES72I5M.js.map → report-AK7Z2Y4S.js.map} +0 -0
  224. /package/dist/{restart-E4FSMFVK.js.map → restart-DEPDGEZB.js.map} +0 -0
  225. /package/dist/{review-IVMH2HDQ.js.map → review-RYAGH3PY.js.map} +0 -0
  226. /package/dist/{run-YW7L4AND.js.map → run-WNP2SMNW.js.map} +0 -0
  227. /package/dist/{screen-IZTZAK74.js.map → screen-P746M4F2.js.map} +0 -0
  228. /package/dist/{search-CVFYS2CC.js.map → search-XQ2WMK5X.js.map} +0 -0
  229. /package/dist/{section-7LOOR4LX.js.map → section-Q7TPOV7U.js.map} +0 -0
  230. /package/dist/{send-RQGTUJ5E.js.map → send-EGG23J2B.js.map} +0 -0
  231. /package/dist/{sessions-RFSGXKGU.js.map → sessions-2NNCWIND.js.map} +0 -0
  232. /package/dist/{show-LVKLIXSK.js.map → show-KSMC7AJL.js.map} +0 -0
  233. /package/dist/{snooze-Z2UEHKZL.js.map → snooze-4LVYUQEX.js.map} +0 -0
  234. /package/dist/{start-NTPMFY6T.js.map → start-YKLLXW3L.js.map} +0 -0
  235. /package/dist/{status-4RJXTMEX.js.map → status-4HGP4ZEF.js.map} +0 -0
  236. /package/dist/{stop-ATV324OT.js.map → stop-YBQL6NFF.js.map} +0 -0
  237. /package/dist/{sync-NWES4BRO.js.map → sync-DUXN2MFJ.js.map} +0 -0
  238. /package/dist/{time-YDXPHJAV.js.map → time-Q42HPZZ3.js.map} +0 -0
  239. /package/dist/{timesheet-Z5SNLTVF.js.map → timesheet-YJ6O3GUU.js.map} +0 -0
  240. /package/dist/{update-35KH4XZ7.js.map → update-RGNKMRUL.js.map} +0 -0
  241. /package/dist/{usage-AWYA6R6J.js.map → usage-YZRZKJ3H.js.map} +0 -0
  242. /package/dist/{usage-ask-52X2RMQC.js.map → usage-ask-BYPNLA2B.js.map} +0 -0
  243. /package/dist/{version-6A3FWFQR.js.map → version-4IOMOIDP.js.map} +0 -0
  244. /package/dist/{wait-H4YPUGGF.js.map → wait-YOHPFWVJ.js.map} +0 -0
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@moberg_hr/work-tree",
3
- "version": "2.22.2",
3
+ "version": "2.22.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@moberg_hr/work-tree",
9
- "version": "2.22.2",
9
+ "version": "2.22.4",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moberg_hr/work-tree",
3
- "version": "2.22.2",
3
+ "version": "2.22.4",
4
4
  "description": "Cross-platform Git worktree manager for multiple repositories",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/account.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { CommandModule } from 'yargs';\nimport { AccountAdminError, agentFor, type AgentAccounts } from '../core/agents/index.js';\nimport { loadConfig } from '../core/platform/config.js';\nimport { callWorkWeb } from '../core/platform/web-discovery.js';\nimport { sessionIdFor } from '../core/sessions/session-id.js';\nimport { createAccountSwitcher } from '../core/sessions/account-switch.js';\nimport { defaultAccountSwitchDeps } from '../core/sessions/account-switch-deps.js';\nimport { removeAgentAccount } from '../core/sessions/account-users.js';\nimport { accountOverview, addAgentAccount, setDefaultAgentAccount } from '../core/sessions/account-admin.js';\nimport { listHostPtys } from '../core/pty/pty-pool.js';\nimport { agedWindow, usageText } from '../core/usage/usage.js';\nimport type { AccountSwitchAllWire, AccountSwitchWire } from '../core/api-types.js';\nimport { sessionFromArgs } from './shared/session-arg.js';\n\n/**\n * `work account` — the accounts (logins) of the configured agent (Claude Code: each a config folder,\n * `CLAUDE_CONFIG_DIR`), so a second login can take over when the first one's limit runs out. add / list / default /\n * remove, and switch: move a session to another account (`work account switch [target] [branch] --to <name>`). Every\n * piece of it goes through the agent's adapter (its `accounts` part): nothing here knows Claude.\n */\n\nfunction fail(message: string): void {\n console.error(chalk.red(message));\n process.exitCode = 1;\n}\n\n/** The configured agent's accounts part, or null (said) when it has none. */\nfunction accountsOrFail(): { name: string; accounts: AgentAccounts } | null {\n const agent = agentFor(loadConfig());\n if (agent.accounts) return { name: agent.name, accounts: agent.accounts };\n fail(`${agent.name} has no accounts work knows about`);\n return null;\n}\n\n// The usage line is core's (the dashboard's Accounts page says the same); kept exported here for older callers.\nexport { ageText, usageText } from '../core/usage/usage.js';\n\nfunction list(json: boolean): void {\n const found = accountsOrFail();\n if (!found) return;\n const { accounts } = found;\n const now = Date.now();\n const readings = agentFor(loadConfig()).usage?.read() ?? [];\n const overview = accountOverview(accounts, readings);\n const rows = overview.map((a) => ({\n name: a.name,\n folder: a.dir,\n default: a.isDefault,\n loggedIn: a.loggedIn,\n liveSessions: a.live.length,\n usage: a.usage\n ? {\n at: a.usage.at,\n ageMs: Math.max(0, now - Date.parse(a.usage.at)) || 0,\n windows: a.usage.windows.map((w) => ({\n id: w.id,\n label: w.label,\n usedPercent: agedWindow(w, now).usedPercent,\n resetsAt: w.resetsAt,\n })),\n }\n : null,\n }));\n if (json) {\n console.log(JSON.stringify(rows, null, 2));\n return;\n }\n for (const r of rows) {\n const login = r.loggedIn === null ? 'login unknown' : r.loggedIn ? 'logged in' : 'not logged in';\n console.log(\n `${chalk.bold(r.name)}${r.default ? chalk.cyan(' (default)') : ''} ${chalk.gray(r.folder)} ${login} ` +\n chalk.gray(`${r.liveSessions} live session${r.liveSessions === 1 ? '' : 's'}`) +\n ` ${usageText(overview.find((x) => x.name === r.name)?.usage, now)}`,\n );\n }\n}\n\nasync function add(name: string | undefined, folder: string | undefined, login: boolean): Promise<void> {\n if (!name) return fail('Usage: work account add <name> [folder]');\n const found = accountsOrFail();\n if (!found) return;\n const dir = await addAgentAccount(found.accounts, name, folder);\n const admin = found.accounts.admin!;\n console.log(chalk.green(`Added account ${name}: ${dir}`));\n if (login) {\n console.log(chalk.gray(`Starting ${found.name} on it so you can log in: type /login, then exit when done.`));\n admin.login(name);\n }\n // Work's skills live in each account's folder: this one's too. Its hooks and status line come with each Claude work\n // starts on it (`--settings`, agents/session-hooks.ts): nothing to install.\n const skills = admin.installSkills(name);\n console.log(skills.ok ? chalk.gray(skills.message) : chalk.yellow(skills.message));\n}\n\n/** Work's skills into the account's folder (the dashboard's Accounts page runs this in a child after a first login). */\nfunction skills(name: string | undefined): void {\n if (!name) return fail('Usage: work account skills <name>');\n const found = accountsOrFail();\n if (!found) return;\n if (!found.accounts.admin) return fail('its accounts are not managed by work');\n const r = found.accounts.admin.installSkills(name);\n if (r.ok) console.log(r.message);\n else fail(r.message);\n}\n\nasync function setDefault(name: string | undefined): Promise<void> {\n if (!name) return fail('Usage: work account default <name>');\n const found = accountsOrFail();\n if (!found) return;\n await setDefaultAgentAccount(found.accounts, name);\n console.log(chalk.green(`New sessions use the ${name} account.`));\n}\n\nasync function remove(name: string | undefined, force: boolean): Promise<void> {\n if (!name) return fail('Usage: work account remove <name> [--force]');\n const found = accountsOrFail();\n if (!found) return;\n try {\n await removeAgentAccount(found.accounts, name, { force });\n } catch (e) {\n if (e instanceof AccountAdminError && e.kind === 'archived')\n return fail(`${e.message}: ${e.sessions.join(', ')}. Restore them on another account first, or --force to remove it anyway`);\n throw e;\n }\n console.log(chalk.green(`Removed account ${name} (its folder is left as it is).`));\n}\n\nconst INTERRUPTED_TEXT = 'It was working or waiting on you, so that turn was interrupted: tell it to continue.';\n\nconst OUTCOME_TEXT: Record<AccountSwitchWire['outcome'], string> = {\n switched: 'its Claude restarted on it (its conversation goes on)',\n recorded: 'its Claude is not running: the next start uses it',\n};\n\n/** Copy `from`'s setup to `to` (`work account copy-setup <to> --from <from>`); `dryRun`: only say what it would do. */\nasync function copySetup(to: string | undefined, from: string | undefined, dryRun: boolean): Promise<void> {\n if (!to || !from) return fail('Usage: work account copy-setup <to> --from <from> [--dry-run]');\n const found = accountsOrFail();\n if (!found) return;\n const admin = found.accounts.admin;\n if (!admin?.setupPlan || !admin.copySetup) return fail(`${found.name} has no setup to copy`);\n const plan = admin.setupPlan(from, to);\n if (plan.length === 0) return void console.log(chalk.green(`${to} already has ${from}'s setup: nothing to copy.`));\n if (dryRun) {\n console.log(`Copying ${from}'s setup to ${to} would do ${plan.length} thing${plan.length === 1 ? '' : 's'}:`);\n for (const i of plan) console.log(` ${i.does} ${i.kind} ${i.name}${i.note ? chalk.gray(` — ${i.note}`) : ''}`);\n return;\n }\n console.log(\n chalk.gray(\n `Copying ${plan.length} thing${plan.length === 1 ? '' : 's'} from ${from} to ${to} (plugins are installed from their marketplaces: this can take a minute)…`,\n ),\n );\n const done = await admin.copySetup(from, to);\n for (const i of done)\n console.log(\n i.ok\n ? ` ${chalk.green('✓')} ${i.kind} ${i.name}${i.note ? chalk.gray(` — ${i.note}`) : ''}`\n : ` ${chalk.red('✗')} ${i.kind} ${i.name}: ${i.error}`,\n );\n const failed = done.filter((i) => !i.ok).length;\n console.log(\n (failed ? chalk.yellow : chalk.green)(\n `Copied ${done.length - failed} of ${done.length}${failed ? `; ${failed} failed` : ''}. Restart a session's Claude for it to see them.`,\n ),\n );\n if (failed) process.exitCode = 1;\n}\n\n/** Move every session (or those on `from`) to the account `to`: work web does it, one session after another. */\nasync function switchAll(to: string | undefined, from: string | undefined): Promise<void> {\n if (!to) return fail('Usage: work account switch --all --to <name> [--from <name>]');\n const r = await callWorkWeb<AccountSwitchAllWire>(\n 'POST',\n `/api/accounts/${encodeURIComponent(to)}/sessions`,\n from ? { from } : {},\n 900_000,\n );\n if (!r.ok) return fail(r.status === 0 ? 'work web is not running: start it (or open the app) and run this again' : r.error);\n console.log(chalk.green(r.body.summary));\n for (const s of r.body.sessions)\n console.log(\n s.outcome\n ? chalk.gray(` ${s.label}: ${OUTCOME_TEXT[s.outcome]}${s.interrupted ? '; its turn was interrupted: tell it to continue' : ''}`)\n : chalk.yellow(` ${s.label}: ${s.error}`),\n );\n}\n\n/** Move the session for `target` / `branch` (or this folder) to the account `to`. */\nasync function switchSession(target: string | undefined, branch: string | undefined, to: string | undefined): Promise<void> {\n if (!to) return fail('Usage: work account switch [target] [branch] --to <name>');\n const s = sessionFromArgs({ target, branch });\n if (!s) return;\n const id = sessionIdFor(s);\n const label = `${s.target} · ${s.branch}`;\n // Only work web can drive its terminal; waits for the old process to stop and the move to finish.\n const r = await callWorkWeb<AccountSwitchWire>('POST', `/api/sessions/${id}/account`, { to }, 90_000);\n if (r.ok) {\n console.log(chalk.green(`${label}: moved to the ${to} account${r.body.moved ? ` (${r.body.moved} conversation entries moved)` : ''}`));\n console.log(chalk.gray(OUTCOME_TEXT[r.body.outcome]));\n if (r.body.interrupted) console.log(chalk.yellow(INTERRUPTED_TEXT));\n return;\n }\n if (r.status !== 0) return fail(`${label}: ${r.error}`);\n // No work web: nothing here can stop or start a Claude in the PTY host, so only a session whose Claude isn't running goes.\n if ((await listHostPtys().catch(() => [])).some((p) => p.id === id && !p.exited)) {\n return fail(`${label}: its Claude runs in the PTY host: start work web (or open the app) and run this again`);\n }\n const local = await createAccountSwitcher(defaultAccountSwitchDeps({ busy: () => false, hostRuns: () => false })).switchAccount(id, to);\n if (!local.ok) return fail(`${label}: ${local.error}`);\n console.log(chalk.green(`${label}: moved to the ${to} account${local.moved ? ` (${local.moved} conversation entries moved)` : ''}`));\n console.log(chalk.gray(`${OUTCOME_TEXT.recorded}. (work web is not running.)`));\n}\n\nexport const accountCommand: CommandModule = {\n command: 'account <action> [name] [folder]',\n describe:\n \"The agent's accounts (Claude Code logins): add, list, default, remove, switch, copy-setup (also on the dashboard's Accounts page)\",\n builder: (yargs) =>\n yargs\n .positional('action', {\n describe: 'What to do',\n choices: ['add', 'list', 'default', 'remove', 'switch', 'skills', 'copy-setup'] as const,\n type: 'string',\n demandOption: true,\n })\n .positional('name', {\n describe: 'The account name (lower-case letters, digits, dashes); switch: the session’s repo or group',\n type: 'string',\n })\n .positional('folder', {\n describe: 'add: its Claude config folder (default ~/.claude-<name>); switch: the session’s branch',\n type: 'string',\n })\n .option('to', { type: 'string', describe: 'switch: the account to move the session to' })\n .option('all', { type: 'boolean', describe: 'switch: every session (not archived ones), not one' })\n .option('from', {\n type: 'string',\n describe: 'switch --all: only the sessions on this account; copy-setup: the account whose setup is copied',\n })\n .option('dry-run', { type: 'boolean', describe: 'copy-setup: only say what it would copy' })\n .option('json', { type: 'boolean', describe: 'list: print JSON' })\n .option('force', {\n type: 'boolean',\n describe: 'remove: even though archived sessions use it (their Restore starts on the default account)',\n })\n .option('login', {\n type: 'boolean',\n default: true,\n describe: 'add: start Claude on the new account to log in (--no-login skips it)',\n }),\n handler: async (argv) => {\n const action = argv.action as string;\n const name = argv.name as string | undefined;\n try {\n switch (action) {\n case 'add':\n return await add(name, argv.folder as string | undefined, argv.login !== false);\n case 'list':\n return list(argv.json === true);\n case 'default':\n return await setDefault(name);\n case 'copy-setup':\n return await copySetup(name, argv.from as string | undefined, argv.dryRun === true);\n case 'switch':\n // For a switch the two positionals are the session's: <target> [branch] (none: the session for this folder).\n if (argv.all) return await switchAll(argv.to as string | undefined, argv.from as string | undefined);\n return await switchSession(name, argv.folder as string | undefined, argv.to as string | undefined);\n case 'remove':\n return await remove(name, argv.force === true);\n case 'skills':\n return skills(name);\n }\n } catch (e) {\n if (!(e instanceof AccountAdminError)) throw e;\n fail(e.sessions.length ? `${e.message}: ${e.sessions.join(', ')}` : e.message);\n }\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAsBlB,SAAS,KAAK,SAAuB;AACnC,UAAQ,MAAM,MAAM,IAAI,OAAO,CAAC;AAChC,UAAQ,WAAW;AACrB;AAGA,SAAS,iBAAmE;AAC1E,QAAM,QAAQ,SAAS,WAAW,CAAC;AACnC,MAAI,MAAM,SAAU,QAAO,EAAE,MAAM,MAAM,MAAM,UAAU,MAAM,SAAS;AACxE,OAAK,GAAG,MAAM,IAAI,mCAAmC;AACrD,SAAO;AACT;AAKA,SAAS,KAAK,MAAqB;AACjC,QAAM,QAAQ,eAAe;AAC7B,MAAI,CAAC,MAAO;AACZ,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,MAAM,KAAK,IAAI;AACrB,QAAM,WAAW,SAAS,WAAW,CAAC,EAAE,OAAO,KAAK,KAAK,CAAC;AAC1D,QAAM,WAAW,gBAAgB,UAAU,QAAQ;AACnD,QAAM,OAAO,SAAS,IAAI,CAAC,OAAO;AAAA,IAChC,MAAM,EAAE;AAAA,IACR,QAAQ,EAAE;AAAA,IACV,SAAS,EAAE;AAAA,IACX,UAAU,EAAE;AAAA,IACZ,cAAc,EAAE,KAAK;AAAA,IACrB,OAAO,EAAE,QACL;AAAA,MACE,IAAI,EAAE,MAAM;AAAA,MACZ,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK,M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skills"]}
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/version.ts
4
- var VERSION = true ? "2.22.2" : "dev";
5
-
6
- export {
7
- VERSION
8
- };
9
- //# sourceMappingURL=chunk-76NYQDUN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/pty/output-status.ts","../src/core/pty/pty-pool.ts","../src/core/pty/account-login.ts"],"sourcesContent":["import type { SessionAttention } from '../api-types.js';\n\n/**\n * A status for a session whose tool isn't Claude Code (config `aiCommand`,\n * e.g. opencode): no hooks report its turns, so the PTY host's \"last printed\n * anything\" stands in — a working agent redraws its spinner, an idle one\n * prints nothing. Working while it printed in the last `OUTPUT_WORKING_MS`,\n * idle after; never \"done, unseen\" or \"needs input\" (output can't tell a\n * finished turn from a question). Pure.\n */\n\nexport const OUTPUT_WORKING_MS = 10_000;\n\nexport interface PtyOutput {\n /** The tool's binary (the host's spawn spec). */\n tool?: string;\n /** When it last printed (ISO). */\n lastOutputAt?: string;\n startedAt: string;\n}\n\nexport function statusFromOutput(p: PtyOutput, now: number): SessionAttention | null {\n if (!p.tool || p.tool === 'claude' || !p.lastOutputAt) return null;\n const at = Date.parse(p.lastOutputAt);\n if (!Number.isFinite(at)) return null;\n const working = now - at < OUTPUT_WORKING_MS;\n return {\n state: working ? 'working' : 'idle',\n seen: true,\n since: p.lastOutputAt,\n updatedAt: p.lastOutputAt,\n stale: false,\n summary: `${working ? 'Printing' : 'Quiet'} — from its terminal output (${p.tool} has no status hooks)`,\n };\n}\n","import path from 'node:path';\nimport type { AgentAdapter } from '../agents/types.js';\nimport { agentFor, agentSettings, assistantAgent, sessionToolFor } from '../agents/index.js';\nimport { statusFromOutput, type PtyOutput } from './output-status.js';\nimport type { SessionAttention } from '../api-types.js';\nimport type { HostBeat } from './host-health.js';\nimport { PtyHostBusyError } from './pty-host-client.js';\nimport { noClaudeBecause } from '../archive/archiving.js';\nimport { findSession, sessionIdFor } from '../sessions/web-state.js';\nimport type { WorktreeSession } from '../sessions/history.js';\nimport { hostStartLockPath, type SpawnSpec, type HostInfo, type PtyInfo } from './pty-host-protocol.js';\nimport { dbPtySessions } from './pty-sessions-file.js';\nimport { ensureFile, withFileLock } from '../platform/fs-safe.js';\nimport { forgetPersistedSession } from './pty-sessions-file.js';\nimport { loadConfig } from '../platform/config.js';\nimport { hasEnvDelta, type EnvDelta } from '../platform/env-delta.js';\nimport { ensureHost, findHost, PtyHostClient, findHostPatient, PtyHostVersionError } from './pty-host-client.js';\nimport { logSwallowed, swallow } from '../platform/best-effort.js';\nimport { ASSISTANT_ID, prepareAssistantDir } from '../agents/assistant.js';\nimport { accountLoginId, accountOfLoginId } from './account-login-id.js';\nimport { accountLoginSpec } from './account-login.js';\n\n/**\n * `work web`'s view of the Claude PTYs. The PTYs themselves live in the\n * PTY host (`work pty-host`, see core/pty-host.ts), a separate long-lived\n * process — so restarting or rebuilding `work web` never kills an agent,\n * and a real terminal (`work attach`) can share the same session.\n *\n * This module resolves a dashboard session to a spawn spec, asks the host\n * to spawn it on first attach, and keeps a small cache of which sessions\n * have a live PTY for the synchronous badge path (`peekPty`).\n */\n\nlet workBin = process.argv[1] ?? '';\n/** Whether this server may start the PTY host when none runs (not the dev server: see configurePtyPool). */\nlet mayStartHost = true;\nlet client: PtyHostClient | null = null;\nlet live = new Set<string>();\n/** The pids of those PTYs' processes (the Claudes the app runs). */\nlet livePids = new Set<number>();\n/** Each live PTY's tool and last output (for output-status.ts). */\nlet outputs = new Map<string, PtyOutput & { pid: number }>();\nlet refreshTimer: NodeJS.Timeout | null = null;\n/** The heartbeat (host-health.ts): each list request is one. */\nconst beat: HostBeat = { known: false, lastOkAt: null, latencyMs: null, lastError: null, hostVersion: null };\n\n/** How the host answered lately (for GET /api/pty-host/health). */\nexport function hostBeat(): HostBeat {\n return { ...beat };\n}\nconst REFRESH_MS = 2000;\n\n/** Called by `work web` at startup with the resolved `work` binary path,\n * which is what the host is spawned from. */\nexport function configurePtyPool(opts: { workBin: string; startHost?: boolean }): void {\n workBin = opts.workBin;\n // The dev server (`work web --dev`) uses the host that runs and never starts one: started\n // from a checkout's build, the long-lived host that owns every Claude would outlive it,\n // and the installed work would become a client of the checkout's code.\n mayStartHost = opts.startHost ?? true;\n}\n\n/** The `work` binary path, for routes that launch `work attach`. */\nexport function getWorkBin(): string {\n return workBin;\n}\n\nasync function getClient(spawnIfMissing: boolean): Promise<PtyHostClient | null> {\n if (client) {\n // Cheap liveness re-check happens in refresh(); a dead host surfaces\n // as a failed call, which resets `client` below.\n return client;\n }\n const info = spawnIfMissing && mayStartHost ? await ensureHost(workBin) : await findHost();\n if (!info && spawnIfMissing && !mayStartHost)\n throw new Error(\n \"No PTY host is running, and the dev server doesn't start one: start the installed work (its app or `work web`) first.\",\n );\n if (!info) return null;\n client = new PtyHostClient(info);\n startRefresh();\n return client;\n}\n\nasync function refresh(): Promise<void> {\n const t0 = Date.now();\n try {\n const c = await getClient(false);\n if (!c) {\n beat.known = false;\n beat.hostVersion = null; // gone: the next host says its own\n live = new Set();\n livePids = new Set();\n outputs = new Map();\n return;\n }\n beat.known = true;\n const ptys = await c.list();\n beat.lastOkAt = Date.now();\n beat.latencyMs = beat.lastOkAt - t0;\n beat.lastError = null;\n // Asked once per host (the client keeps it): the release it runs, to say when it's older than this work.\n beat.hostVersion = await c.workVersion();\n live = new Set(ptys.filter((p) => !p.exited).map((p) => p.id));\n livePids = new Set(ptys.filter((p) => !p.exited).map((p) => p.pid));\n outputs = new Map(\n ptys.filter((p) => !p.exited).map((p) => [p.id, { tool: p.tool, lastOutputAt: p.lastOutputAt, startedAt: p.startedAt, pid: p.pid }]),\n );\n } catch (err) {\n // Host went away (or was restarted on a new port) — rediscover next tick.\n // A busy host is still a host (it is there, just not answering).\n beat.known = beat.known || err instanceof PtyHostBusyError;\n beat.lastError = (err as Error).message;\n client = null;\n beat.hostVersion = null;\n live = new Set();\n livePids = new Set();\n outputs = new Map();\n }\n}\n\nfunction startRefresh(): void {\n if (refreshTimer) return;\n refreshTimer = setInterval(() => void refresh(), REFRESH_MS);\n refreshTimer.unref?.();\n}\n\n/** Connect to an already-running host at `work web` startup so badges for\n * PTYs that survived a web restart show immediately. Never spawns. */\n/** Re-read the host's PTY list now (the periodic refresh can be seconds old,\n * or not have run at all right after `work web` started). */\nexport async function syncPtyPool(): Promise<void> {\n await refresh();\n}\n\nexport async function initPtyPool(): Promise<void> {\n await refresh().catch(() => {});\n startRefresh();\n}\n\n/**\n * After a reboot (or a host crash) nothing is running but\n * `pty-sessions.json` still lists the sessions that were live. Starting the\n * host restores them; do that when there's something to restore, so\n * reopening `work web` picks up where you left off. Returns how many\n * sessions the host will bring back (0 = nothing to do).\n */\nexport async function resumePersistedSessions(): Promise<number> {\n let count: number;\n try {\n count = Object.keys(dbPtySessions.read()).length;\n } catch {\n return 0;\n }\n if (count === 0) return 0;\n if (await findHost().catch(() => true)) return 0; // already running\n await getClient(true);\n await refresh();\n return count;\n}\n\n/**\n * Where Claude runs for a session — the same directory `work tree` launches\n * in: the worktree for a single repo, the group root (parent of the\n * sub-repos) for a group.\n */\nexport { ASSISTANT_ID };\n\n/** The assistant runs config `assistantAgent` (Claude Code by default), in its folder written for that agent. */\nexport function assistantSpec(): { cwd: string; tool: ReturnType<AgentAdapter['launch']['tool']>; agentEnv?: EnvDelta } {\n const settings = agentSettings();\n const agent = assistantAgent(settings);\n // Work's own session, not any session's: the configured default account (`launch.env(null)`).\n const agentEnv = agent.launch.env?.(null);\n return {\n cwd: prepareAssistantDir(agent),\n tool: sessionToolFor(agent.launch.tool(settings), { write: mayStartHost }),\n ...(hasEnvDelta(agentEnv) ? { agentEnv } : {}),\n };\n}\n\nexport function spawnSpecFor(session: WorktreeSession): SpawnSpec | null {\n const first = session.paths[0];\n if (!first) return null;\n const cwd = session.isGroup ? path.dirname(first) : first;\n const config = loadConfig();\n const launch = agentFor(config, session).launch;\n // The session's account: its agent's folder env, applied by the host over whatever environment it starts with.\n const agentEnv = launch.env?.(session);\n // Its hooks in the spec itself (`--settings`, agents/session-hooks.ts), so a PTY host from before this build — it\n // outlives updates — starts it with them too; a current host replaces the flag with its own, never twice. The dev\n // server names the file the installed work wrote, never its own build (`write: false`).\n const tool = sessionToolFor(launch.tool(config), { write: mayStartHost });\n return { cwd, tool, port: session.port, ...(hasEnvDelta(agentEnv) ? { agentEnv } : {}) };\n}\n\n/**\n * Ensure a live PTY exists for the session (spawning Claude in the host if\n * needed) and return the host WebSocket URL to attach to. Null for an\n * unknown session.\n */\nexport async function ensurePty(sessionId: string, extra: { initialPrompt?: string } = {}): Promise<string | null> {\n // An account's login terminal (the Accounts page) is no session: the agent's own CLI on that account (account-login.ts).\n const loginFor = accountOfLoginId(sessionId);\n // The dashboard assistant (Ctrl+K) is not a worktree: it runs in its own\n // folder, which is (re)written first (assistant.ts).\n const notASession = sessionId === ASSISTANT_ID || loginFor !== null;\n const session = notASession ? null : findSession(sessionId);\n // Not for a session being archived, or archived: its Claude was stopped on\n // purpose (a Terminal tab still open on it reconnects and would start it).\n const refused = notASession ? null : noClaudeBecause(session, sessionId);\n if (refused) throw new Error(refused);\n const base =\n loginFor !== null\n ? accountLoginSpec(loginFor, agentFor(loadConfig()).accounts)\n : sessionId === ASSISTANT_ID\n ? assistantSpec()\n : session\n ? spawnSpecFor(session)\n : null;\n if (!base) return null;\n // The first prompt only applies to a fresh spawn (the host ignores the\n // spec when the session's PTY is already running).\n const spec = extra.initialPrompt ? { ...base, initialPrompt: extra.initialPrompt } : base;\n\n let c = await getClient(true);\n if (!c) return null;\n // A host from before accounts would start it on its own environment — another account than the session's.\n if (setsEnv(spec.agentEnv) && !(await hostTakesAgentEnv(c)) && !(await runsIn(c, sessionId))) throw new Error(OLD_HOST_ACCOUNTS);\n try {\n await c.spawn(sessionId, spec);\n } catch (err) {\n // Stale client (host restarted on a new port) — retry once, fresh.\n client = null;\n c = await getClient(true);\n if (!c) throw err;\n await c.spawn(sessionId, spec);\n }\n live.add(sessionId);\n return c.attachUrl(sessionId);\n}\n\n/**\n * Where a dashboard page connects a terminal straight to the PTY host (with a one-time ticket for its origin), once\n * `ensurePty` has it running. Null when the host can't give one (from before tickets): the page goes through work\n * web's relay as before.\n */\nexport async function terminalTicketUrl(sessionId: string, origin: string): Promise<string | null> {\n const c = await getClient(false);\n return c ? c.ticketUrl(sessionId, origin).catch(() => null) : null;\n}\n\n/** Start an account's login terminal in the PTY host (or find it running); its id, for the terminal WebSocket. */\nexport async function startAccountLogin(name: string): Promise<string> {\n const id = accountLoginId(name);\n if (!(await ensurePty(id))) throw new Error('the PTY host could not be started');\n return id;\n}\n\n/** Stop an account's login terminal (nothing when none runs). */\nexport async function stopAccountLogin(name: string): Promise<void> {\n await disposePty(accountLoginId(name));\n}\n\n/** Side-effect-free check: does an active (non-exited) PTY exist for this\n * session? Served from the refresh cache — used by session-meta for the\n * \"running/idle\" badge, which must stay synchronous. */\n/** Every PTY in the host, fresh (never starts a host; [] without one). */\nexport async function listHostPtys(): Promise<PtyInfo[]> {\n const c = await getClient(false);\n return c ? c.list() : [];\n}\n\n/** Pids of the Claudes running in the PTY host (from the refresh cache). */\nexport function ptyPids(): ReadonlySet<number> {\n return livePids;\n}\n\n/** The live terminals with when each started and last printed (from the refresh cache), for startup-question.ts. */\nexport function ptyTerminals(): Array<{ id: string; startedAt: string; lastOutputAt?: string }> {\n return [...outputs].map(([id, o]) => ({ id, startedAt: o.startedAt, ...(o.lastOutputAt ? { lastOutputAt: o.lastOutputAt } : {}) }));\n}\n\n/** A status from its terminal output, for a session whose tool has no hooks (output-status.ts); null for Claude or no PTY. */\nexport function outputStatus(sessionId: string, now = Date.now()): SessionAttention | null {\n const o = outputs.get(sessionId);\n return o ? statusFromOutput(o, now) : null;\n}\n\n/** When a session's terminal last printed (ms, from the refresh cache); null with no PTY or a host that doesn't say. */\nexport function ptyLastOutputMs(sessionId: string): number | null {\n const at = outputs.get(sessionId)?.lastOutputAt;\n const ms = at ? Date.parse(at) : NaN;\n return Number.isFinite(ms) ? ms : null;\n}\n\n/** Its agent's process id in the host (from the refresh cache); null with no PTY. */\nexport function ptyPid(sessionId: string): number | null {\n return outputs.get(sessionId)?.pid ?? null;\n}\n\nexport function peekPty(sessionId: string): boolean {\n return live.has(sessionId);\n}\n\n/** A session's live PTY screen as text; null when there is none (never spawns). */\nexport async function readPtyScreen(sessionId: string): Promise<string | null> {\n if (!live.has(sessionId)) return null;\n const c = await getClient(false);\n return c ? c.screen(sessionId) : null;\n}\n\n/** Write to a session's live PTY. False when there is none (never spawns). */\nexport async function writeToPty(sessionId: string, data: string): Promise<boolean> {\n if (!live.has(sessionId)) return false;\n const c = await getClient(false);\n return c ? c.write(sessionId, data) : false;\n}\n\n/**\n * Restart a session's agent in the host, resuming its conversation, its terminals\n * kept attached (agent-restart.ts). A host from before that call: stopped and\n * started again (an open Terminal tab then offers Enter, as after a stop).\n */\nexport async function restartPty(sessionId: string): Promise<string | void> {\n let c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n let how: Awaited<ReturnType<PtyHostClient['restart']>>;\n try {\n how = await c.restart(sessionId);\n } catch (err) {\n // A stale client (the host restarted on a new port before the refresh noticed): once more, fresh.\n client = null;\n c = await getClient(false);\n if (!c) throw err;\n how = await c.restart(sessionId);\n }\n if (how === 'not-running') throw new Error('its agent is not running in the PTY host');\n if (how === 'unsupported') {\n await disposePty(sessionId);\n if (!(await ensurePty(sessionId))) throw new Error('its agent could not be started again');\n return OLD_HOST_RESTART;\n }\n}\n\n/**\n * Stop a session's agent and keep its session in the host (entry, restore record, attached terminals) until `resumePty`:\n * a switch of account moves its conversation files in between. `stopped`: a host from before the call stopped it the old\n * way (its terminals were told it ended; `resumePtyOnAccount` then starts it fresh); `gone`: nothing was running.\n */\nexport async function haltPty(sessionId: string): Promise<'halted' | 'stopped' | 'gone'> {\n let c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n let how: Awaited<ReturnType<PtyHostClient['halt']>>;\n try {\n how = await c.halt(sessionId);\n } catch (err) {\n // A stale client (the host restarted on a new port before the refresh noticed): once more, fresh.\n client = null;\n c = await getClient(false);\n if (!c) throw err;\n how = await c.halt(sessionId);\n }\n if (how === 'not-running') return 'gone';\n if (how === 'unsupported') {\n await disposePty(sessionId);\n return 'stopped';\n }\n return 'halted';\n}\n\n/** Why a switch of account can't be done in this PTY host now (it is from before accounts), or null: asked before halting. */\nexport async function accountSwitchRefusal(): Promise<string | null> {\n const c = await getClient(false);\n return c && !(await hostTakesAgentEnv(c)) ? OLD_HOST_ACCOUNTS : null;\n}\n\n/**\n * Start a halted session's agent again in place, on `opts.agentEnv` (its terminals carry on). `not-halted`: it isn't\n * halted any more — the host started it again by itself (HALT_RESUME_MS) or restarted, on its old spec.\n */\nexport async function resumePty(sessionId: string, opts: { agentEnv?: EnvDelta } = {}): Promise<'resumed' | 'not-halted'> {\n let c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n if (hasEnvDelta(opts.agentEnv) && !(await hostTakesAgentEnv(c))) throw new Error(OLD_HOST_ACCOUNTS);\n let how: Awaited<ReturnType<PtyHostClient['resume']>>;\n try {\n how = await c.resume(sessionId, opts);\n } catch (err) {\n client = null;\n c = await getClient(false);\n if (!c) throw err;\n how = await c.resume(sessionId, opts);\n }\n return how;\n}\n\n/**\n * Start the agent of a session `haltPty` stopped, on the account the session records NOW (after a switch: the new one;\n * after one that failed: the old): resumed in place with that environment, or — `stopped`, an older host — started\n * again from a fresh spec (its terminals show it ended; opening the session reconnects).\n */\nexport async function resumePtyOnAccount(sessionId: string, how: 'halted' | 'stopped'): Promise<string | void> {\n if (how === 'stopped') {\n if (!(await ensurePty(sessionId))) throw new Error('its agent could not be started again');\n return OLD_HOST_RESTART;\n }\n const session = findSession(sessionId);\n const spec = session ? spawnSpecFor(session) : null;\n if (!spec) throw new Error('unknown session');\n // Nothing in the delta means no account change to apply (the default, with no accounts configured): a plain resume.\n const agentEnv = hasEnvDelta(spec.agentEnv) ? spec.agentEnv : undefined;\n if ((await resumePty(sessionId, agentEnv ? { agentEnv } : {})) === 'resumed') return;\n // Started again meanwhile on its OLD spec (the host's own resume after HALT_RESUME_MS — a long move —, or a host\n // restart's restore): restarted in place on the account the session records now, so it doesn't stay on the old one.\n const c = await getClient(false);\n if (!c) throw new Error('the PTY host is not running');\n const restarted = await c.restart(sessionId, agentEnv ? { agentEnv } : {});\n if (restarted === 'restarted') return RESTARTED_AFTER_AUTO_RESUME;\n // Not running now (it ended), or a host that couldn't take the environment in place: started fresh from the new spec.\n if (restarted === 'unsupported') await disposePty(sessionId);\n if (!(await ensurePty(sessionId))) throw new Error('its agent could not be started again');\n return RESTARTED_AFTER_AUTO_RESUME;\n}\n\n/** What a switch says when its halted Claude had been started again (on the old account) before the move was done. */\nexport const RESTARTED_AFTER_AUTO_RESUME =\n 'it had been started again on its old account while the conversation moved, so it was restarted on the new one';\n\n/** Said when a session on a named account would start in a PTY host that drops the account (one from before accounts). */\nexport const OLD_HOST_ACCOUNTS = 'the PTY host is from before Claude accounts: run `work pty-host --restart`';\n\n/** The delta sets a variable (a session on a named account): what an older host would drop, starting it elsewhere. */\nconst setsEnv = (d: EnvDelta | undefined): boolean => !!d && Object.values(d).some((v) => typeof v === 'string');\n\n/** The host applies `agentEnv`; one that can't be asked right now is given the benefit of the doubt (its restart says). */\nasync function hostTakesAgentEnv(c: PtyHostClient): Promise<boolean> {\n const f = await c.features();\n return f === null || f.includes('agentEnv');\n}\n\n/** Its agent runs in this host now (a spawn would only attach to it). */\nasync function runsIn(c: PtyHostClient, sessionId: string): Promise<boolean> {\n return (await c.list()).some((p) => p.id === sessionId && !p.exited);\n}\n\n/** How a restart on a PTY host from before restart-in-place went: what differs, and the way to the real thing. */\nexport const OLD_HOST_RESTART =\n 'stopped and started again (an older PTY host: open terminals show it ended, and it runs with only the variables `hostEnv` keeps; `work pty-host --restart` gets restarts in place)';\n\n/** Kill one session's PTY (if any). Called before removing a worktree so\n * the Claude process doesn't hold its cwd open (Windows refuses to delete\n * a directory that is some process's working directory). */\nexport async function disposePty(sessionId: string): Promise<void> {\n live.delete(sessionId);\n let c = client;\n if (!c) {\n // A busy host (mid-restore) is waited for, not skipped: skipping left\n // Claude running inside the worktree about to be deleted. A host from\n // another build can't be talked to — nothing to do but proceed.\n let info: HostInfo | null;\n try {\n info = await findHostPatient();\n } catch (err) {\n if (err instanceof PtyHostVersionError) return;\n throw err; // still busy after waiting: let the caller report it\n }\n if (!info) return;\n c = new PtyHostClient(info);\n }\n await c.kill(sessionId).catch(swallow(`stop session ${sessionId} in the PTY host`));\n}\n\n/**\n * Stop a session's Claude in the PTY host before its worktree is deleted —\n * from any caller, including the CLI (`work remove` / prune / sync), which\n * doesn't run a pool. Never starts a host; waits for the process to exit\n * (the host's kill does) so Windows can then delete the directory.\n * Best-effort: no host, or a host that can't be reached, is a no-op.\n */\nexport async function stopSessionPty(target: string, branch: string): Promise<void> {\n const id = sessionIdFor({ target, branch } as WorktreeSession);\n live.delete(id);\n // Under the host START lock: a host that's starting holds it until it has\n // restored, so we either see it running (and kill the session) or know\n // none is — and then drop the session from the saved list so a later\n // start doesn't restore Claude into a worktree that's being deleted.\n const lock = hostStartLockPath();\n ensureFile(lock, '');\n await withFileLock(lock, async () => {\n let info;\n try {\n info = await findHostPatient();\n } catch (err) {\n // A host from another build can't be talked to; one still busy after\n // waiting is running and owns the session — leave both alone (and\n // never drop the saved entry: the host is what it belongs to).\n logSwallowed(`stop session ${id}: PTY host`, err);\n return;\n }\n if (info) await new PtyHostClient(info).kill(id).catch(swallow(`stop session ${id} in the PTY host`));\n else await forgetPersistedSession(id).catch(swallow(`forget saved session ${id}`));\n }).catch(swallow(`stop session ${id}: host start lock`));\n}\n\n/** `work web` shutdown. Deliberately does NOT kill anything: the PTYs belong\n * to the host and outlive the dashboard. Just stops polling. */\nexport function detachPtyPool(): void {\n if (refreshTimer) clearInterval(refreshTimer);\n refreshTimer = null;\n client = null;\n live = new Set();\n livePids = new Set();\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { AccountAdminError, type AgentAccounts } from '../agents/types.js';\nimport { getConfigDir } from '../platform/config.js';\nimport { hasEnvDelta } from '../platform/env-delta.js';\nimport type { SpawnSpec } from './pty-host-protocol.js';\n\n/**\n * The dashboard's login terminal for an account (the Accounts page's Add / Log in): the agent's own CLI on that account\n * (`admin.loginLaunch`, what `work account add` runs in your terminal), started in the PTY host under\n * `accountLoginId(name)` (account-login-id.ts) so the page can show it. A new conversation every time (`fresh`): there is\n * nothing to resume, and it runs in a folder of its own, never a worktree. Never restored by a host restart\n * (pty-registry.ts), and stopped when its panel closes. The agent starts in its own permission mode, as every start.\n */\n\n/** Where the login terminal runs: a folder of work's own (an agent may ask once whether to trust it). */\nexport const accountLoginDir = (): string => path.join(getConfigDir(), 'account-login');\n\n/** The host's spawn spec for an account's login terminal. Throws an AccountAdminError for an account work can't log in to. */\nexport function accountLoginSpec(\n name: string,\n accounts: Pick<AgentAccounts, 'has' | 'admin'> | undefined,\n dir: string = accountLoginDir(),\n): SpawnSpec {\n if (!accounts?.admin) throw new AccountAdminError('its accounts are not managed by work');\n if (!accounts.has(name)) throw new AccountAdminError(`no account “${name}”`);\n const { tool, agentEnv } = accounts.admin.loginLaunch(name);\n fs.mkdirSync(dir, { recursive: true });\n return { cwd: dir, tool, fresh: true, ...(hasEnvDelta(agentEnv) ? { agentEnv } : {}) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,IAAM,oBAAoB;AAU1B,SAAS,iBAAiB,GAAc,KAAsC;AACnF,MAAI,CAAC,EAAE,QAAQ,EAAE,SAAS,YAAY,CAAC,EAAE,aAAc,QAAO;AAC9D,QAAM,KAAK,KAAK,MAAM,EAAE,YAAY;AACpC,MAAI,CAAC,OAAO,SAAS,EAAE,EAAG,QAAO;AACjC,QAAM,UAAU,MAAM,KAAK;AAC3B,SAAO;AAAA,IACL,OAAO,UAAU,YAAY;AAAA,IAC7B,MAAM;AAAA,IACN,OAAO,EAAE;AA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AC;AACzD;AAIO,SAAS,gBAAsB;AACpC,MAAI,aAAc,eAAc,YAAY;AAC5C,iBAAe;AACf,WAAS;AACT,SAAO,oBAAI,IAAI;AACf,aAAW,oBAAI,IAAI;AACrB;","names":["path","path"]}
@@ -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), and the answer and Activity say to tell it to continue. 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}\n\nexport type SwitchOutcome = 'switched' | 'recorded';\n\nexport type SwitchResult =\n { ok: true; outcome: SwitchOutcome; moved?: number; interrupted?: boolean } | { 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\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 }> => {\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 };\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 };\n }\n try {\n const how = await resume();\n const cut = interrupted ? INTERRUPTED : '';\n deps.note?.(id, `moved to the ${to} account: its Claude restarted on it${how ? ` (${how})` : ''}${cut}`, 'action');\n return { moved, interrupted };\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 } = await perform(id, to);\n return { ok: true, outcome: 'switched', moved, ...(interrupted ? { interrupted: true } : {}) };\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/** 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;;;ACiBO,IAAM,cAAc;AAE3B,IAAM,MAAM,CAAC,QAAkB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAEvE,SAAS,sB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