@moberg_hr/work-tree 2.22.5 → 2.23.1

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 (291) hide show
  1. package/dist/{account-J55P3HXH.js → account-O62WFR7C.js} +23 -20
  2. package/dist/{account-J55P3HXH.js.map → account-O62WFR7C.js.map} +1 -1
  3. package/dist/{add-repo-ALVEGU25.js → add-repo-FTAMMPVM.js} +13 -13
  4. package/dist/{answer-CI2SPQQL.js → answer-LKNMN2ZM.js} +11 -11
  5. package/dist/{attach-7LBIFBLX.js → attach-A3KA4YTK.js} +20 -17
  6. package/dist/{attach-7LBIFBLX.js.map → attach-A3KA4YTK.js.map} +1 -1
  7. package/dist/bin.js +4 -4
  8. package/dist/{block-TVIYWRJ5.js → block-3ZUFH2RO.js} +12 -12
  9. package/dist/{broadcast-GZNMZFOY.js → broadcast-I23BZI3R.js} +8 -8
  10. package/dist/{catchup-ZURJI6BF.js → catchup-G4EOJIZP.js} +13 -13
  11. package/dist/{child-K6YYF6MQ.js → child-MVNEFA2I.js} +11 -11
  12. package/dist/{chunk-ZTWZS5RK.js → chunk-24FQ5XXN.js} +3 -3
  13. package/dist/{chunk-D2SVBU7R.js → chunk-2FNYJEOH.js} +2 -2
  14. package/dist/{chunk-EEHPZMS3.js → chunk-2JLG65GB.js} +2 -2
  15. package/dist/{chunk-DC73NF67.js → chunk-2MJQTFTI.js} +3 -3
  16. package/dist/chunk-44QJVFOF.js +64 -0
  17. package/dist/chunk-44QJVFOF.js.map +1 -0
  18. package/dist/{chunk-7Q5PBXF6.js → chunk-4FN45EAF.js} +51 -10
  19. package/dist/chunk-4FN45EAF.js.map +1 -0
  20. package/dist/{chunk-G4T2HGLJ.js → chunk-4HQEYZIM.js} +4 -4
  21. package/dist/{chunk-WRDULHAN.js → chunk-5QENUGSC.js} +117 -16
  22. package/dist/chunk-5QENUGSC.js.map +1 -0
  23. package/dist/{chunk-CA56ETYX.js → chunk-5SXTMOO6.js} +5 -5
  24. package/dist/chunk-6KMG4WNW.js +87 -0
  25. package/dist/chunk-6KMG4WNW.js.map +1 -0
  26. package/dist/{chunk-OCUUM755.js → chunk-6PZ7RCXK.js} +2 -2
  27. package/dist/{chunk-RTCTD5PJ.js → chunk-773UJC5C.js} +4 -4
  28. package/dist/{chunk-W4GDPHIF.js → chunk-7ZATXG5F.js} +2 -2
  29. package/dist/{chunk-PTAG6WIE.js → chunk-APHVSSLI.js} +17 -3
  30. package/dist/chunk-APHVSSLI.js.map +1 -0
  31. package/dist/chunk-BCYBF7KJ.js +207 -0
  32. package/dist/chunk-BCYBF7KJ.js.map +1 -0
  33. package/dist/{chunk-6Y3VLCKA.js → chunk-BI7HIO2I.js} +3 -3
  34. package/dist/{chunk-FGBLFF4O.js → chunk-BMPTUIP4.js} +2 -2
  35. package/dist/{chunk-VQDE3DRG.js → chunk-DHZ5DF6Y.js} +6 -2
  36. package/dist/{chunk-VQDE3DRG.js.map → chunk-DHZ5DF6Y.js.map} +1 -1
  37. package/dist/{chunk-BQS73CWR.js → chunk-ET5K6S5H.js} +2 -2
  38. package/dist/{chunk-B2WV5RAL.js → chunk-ETAPX4JN.js} +5 -5
  39. package/dist/{chunk-3ZPVKUYD.js → chunk-ETWP7MDS.js} +7 -1
  40. package/dist/chunk-ETWP7MDS.js.map +1 -0
  41. package/dist/{chunk-RLPC3YKZ.js → chunk-FHC6KHIH.js} +2 -2
  42. package/dist/{chunk-DF4GOVDE.js → chunk-GF7RAQFD.js} +2 -2
  43. package/dist/{chunk-ZO7TF5OL.js → chunk-GHY7GZWN.js} +4 -4
  44. package/dist/{chunk-5FIUVBUC.js → chunk-GN7EAXHU.js} +7 -7
  45. package/dist/{chunk-EYJ42LDG.js → chunk-GTFMUWK6.js} +4 -4
  46. package/dist/{chunk-4QMWNAEJ.js → chunk-HCYES6U7.js} +2 -2
  47. package/dist/{chunk-TOMDOA4P.js → chunk-HNZ736XN.js} +2 -2
  48. package/dist/{chunk-ATQB6PTV.js → chunk-HPUD5IGB.js} +3 -3
  49. package/dist/{chunk-FV7BSQPQ.js → chunk-HQDQRC4F.js} +2 -2
  50. package/dist/{chunk-AITL3JYB.js → chunk-HUWWMTNG.js} +399 -69
  51. package/dist/chunk-HUWWMTNG.js.map +1 -0
  52. package/dist/{chunk-SDYY5MHW.js → chunk-INXHVNMZ.js} +7 -7
  53. package/dist/{chunk-QNOJOZYK.js → chunk-IRDWXDID.js} +2 -2
  54. package/dist/{chunk-EA4C6TVY.js → chunk-IVS2MAHD.js} +3 -3
  55. package/dist/{chunk-QOLHDDM2.js → chunk-IXC6EXVJ.js} +4 -4
  56. package/dist/{chunk-IU6LA6EB.js → chunk-IXZOZZGD.js} +4 -4
  57. package/dist/{chunk-SZAD5U3J.js → chunk-LB2GAU7E.js} +2 -2
  58. package/dist/{chunk-VHENFC2S.js → chunk-M2X6OHHR.js} +14 -1
  59. package/dist/chunk-M2X6OHHR.js.map +1 -0
  60. package/dist/{chunk-23QLXVH6.js → chunk-MQXMYVZV.js} +12 -14
  61. package/dist/{chunk-23QLXVH6.js.map → chunk-MQXMYVZV.js.map} +1 -1
  62. package/dist/{chunk-GNERWNZY.js → chunk-MVBBESXK.js} +4 -4
  63. package/dist/{chunk-AIYZJ7XD.js → chunk-N7T6NPE2.js} +5 -5
  64. package/dist/{chunk-GQ5WECPJ.js → chunk-NREZVTBP.js} +3 -3
  65. package/dist/chunk-NRX5V443.js +9 -0
  66. package/dist/{chunk-USENBMUV.js → chunk-NS7WH53I.js} +1 -1
  67. package/dist/chunk-NS7WH53I.js.map +1 -0
  68. package/dist/{chunk-KQMHGEI2.js → chunk-NWKVTUTN.js} +53 -15
  69. package/dist/chunk-NWKVTUTN.js.map +1 -0
  70. package/dist/chunk-NXS53NHR.js +79 -0
  71. package/dist/chunk-NXS53NHR.js.map +1 -0
  72. package/dist/{chunk-NYGKSOQ4.js → chunk-OPV6BE3W.js} +6 -6
  73. package/dist/{chunk-UAF2YFLZ.js → chunk-ROEEXEN7.js} +6 -6
  74. package/dist/{chunk-F4UIKOU6.js → chunk-TL7VLRRF.js} +4 -4
  75. package/dist/{chunk-NOQA7MJ4.js → chunk-U2A2DHWP.js} +3 -3
  76. package/dist/{chunk-Q2B3NUSM.js → chunk-U4XSBYQW.js} +4 -4
  77. package/dist/{chunk-Z4FWXDJG.js → chunk-VH5FRKJM.js} +3 -3
  78. package/dist/{chunk-DCENKA6E.js → chunk-W5YYTITQ.js} +2 -2
  79. package/dist/{chunk-5P27YL64.js → chunk-WOY35FXP.js} +8 -8
  80. package/dist/{chunk-HI674QZF.js → chunk-XIN6XUFL.js} +2 -2
  81. package/dist/{chunk-KU3TQAA7.js → chunk-XTAYJDL2.js} +8 -10
  82. package/dist/{chunk-KU3TQAA7.js.map → chunk-XTAYJDL2.js.map} +1 -1
  83. package/dist/{chunk-EVTMZ5IH.js → chunk-XWKN2HJD.js} +60 -60
  84. package/dist/{chunk-CMRTNTMU.js → chunk-YKTJL4SW.js} +6 -6
  85. package/dist/{chunk-RNPNBGVX.js → chunk-ZG6HB4BO.js} +3 -5
  86. package/dist/{chunk-RNPNBGVX.js.map → chunk-ZG6HB4BO.js.map} +1 -1
  87. package/dist/{chunk-PUJSLL6R.js → chunk-ZLPK2LQ3.js} +5 -5
  88. package/dist/{chunk-LV5JRLBM.js → chunk-ZMJR4Z6O.js} +17 -7
  89. package/dist/chunk-ZMJR4Z6O.js.map +1 -0
  90. package/dist/{chunk-YO3BNAAK.js → chunk-ZNRPBP5O.js} +27 -5
  91. package/dist/chunk-ZNRPBP5O.js.map +1 -0
  92. package/dist/{chunk-Z4P23XG3.js → chunk-ZX4ONO5Y.js} +5 -5
  93. package/dist/{cleanup-G4WQACD6.js → cleanup-ANVUCOBK.js} +32 -31
  94. package/dist/{cleanup-G4WQACD6.js.map → cleanup-ANVUCOBK.js.map} +1 -1
  95. package/dist/{cli-OPORB5PF.js → cli-CAF6VCVO.js} +4 -4
  96. package/dist/{color-C223W3Z6.js → color-7CQNI6Y4.js} +11 -11
  97. package/dist/{config-KQYXQCQA.js → config-EXQY26W4.js} +10 -10
  98. package/dist/{coordinate-4E5GIMC6.js → coordinate-LRY7LXS6.js} +11 -11
  99. package/dist/{diff-HEOLTXO2.js → diff-JRK3AUD5.js} +12 -13
  100. package/dist/{diff-HEOLTXO2.js.map → diff-JRK3AUD5.js.map} +1 -1
  101. package/dist/{digest-GYF4YLUH.js → digest-2AFW3WBL.js} +11 -11
  102. package/dist/{fork-B35ONP3Z.js → fork-DSNMPWUE.js} +29 -26
  103. package/dist/{fork-B35ONP3Z.js.map → fork-DSNMPWUE.js.map} +1 -1
  104. package/dist/{history-25DNQKKC.js → history-RFIDCGQY.js} +8 -8
  105. package/dist/{hook-B4JO2X57.js → hook-XBALB337.js} +20 -20
  106. package/dist/{hydrate-IJEKNZIP.js → hydrate-DAEY4PB6.js} +8 -8
  107. package/dist/{init-UJVOUDJI.js → init-4BK3T34W.js} +12 -12
  108. package/dist/{install-skills-FV2L5QHE.js → install-skills-TL5D7HZU.js} +8 -9
  109. package/dist/install-skills-bin.js +7 -8
  110. package/dist/install-skills-bin.js.map +1 -1
  111. package/dist/{keep-PKXGFZO2.js → keep-57TUKADV.js} +10 -10
  112. package/dist/{list-VYQ3QE2H.js → list-DRQRIT6U.js} +8 -8
  113. package/dist/{move-IAZY23ZX.js → move-UEHJ375P.js} +16 -16
  114. package/dist/{note-6HQUKUYY.js → note-FHPDVBRI.js} +10 -10
  115. package/dist/{overlaps-CGP3RJOW.js → overlaps-GKAKEUB6.js} +13 -13
  116. package/dist/{pin-PAWGQ4Q2.js → pin-CFTQDPPC.js} +11 -11
  117. package/dist/{pr-OJOGE3A3.js → pr-ZP4COZEZ.js} +22 -21
  118. package/dist/{pr-OJOGE3A3.js.map → pr-ZP4COZEZ.js.map} +1 -1
  119. package/dist/{prune-42MS36OR.js → prune-IQB2T45B.js} +29 -29
  120. package/dist/pty-host-BPFGJFBC.js +2658 -0
  121. package/dist/pty-host-BPFGJFBC.js.map +1 -0
  122. package/dist/{read-ATNCW4KH.js → read-DHJ6VY44.js} +10 -10
  123. package/dist/{recent-MTBFQT36.js → recent-OZW2ZNJ4.js} +16 -15
  124. package/dist/{recent-MTBFQT36.js.map → recent-OZW2ZNJ4.js.map} +1 -1
  125. package/dist/{remove-GLDJOKUI.js → remove-MW25RLNV.js} +30 -30
  126. package/dist/{report-AK7Z2Y4S.js → report-II75EKM6.js} +11 -11
  127. package/dist/{restart-DEPDGEZB.js → restart-4BGVRBX6.js} +11 -11
  128. package/dist/{resume-C2QPKKFN.js → resume-4J53KDCO.js} +16 -15
  129. package/dist/{resume-C2QPKKFN.js.map → resume-4J53KDCO.js.map} +1 -1
  130. package/dist/{review-RYAGH3PY.js → review-WKB3K6LI.js} +10 -10
  131. package/dist/{review-now-K4UWD7A5.js → review-now-AT2SPPRO.js} +2 -2
  132. package/dist/{run-WNP2SMNW.js → run-YS2D7WAQ.js} +8 -8
  133. package/dist/{screen-P746M4F2.js → screen-VVRNQXVW.js} +11 -11
  134. package/dist/{search-XQ2WMK5X.js → search-MKYCKZF4.js} +8 -8
  135. package/dist/{section-Q7TPOV7U.js → section-Y6RDD3MN.js} +11 -11
  136. package/dist/{send-EGG23J2B.js → send-AZM2XKN2.js} +12 -12
  137. package/dist/{sessions-2NNCWIND.js → sessions-OER6VNQJ.js} +26 -24
  138. package/dist/{sessions-2NNCWIND.js.map → sessions-OER6VNQJ.js.map} +1 -1
  139. package/dist/{show-KSMC7AJL.js → show-33VV3XCF.js} +10 -10
  140. package/dist/{snooze-4LVYUQEX.js → snooze-OFYZVVYS.js} +10 -10
  141. package/dist/{start-YKLLXW3L.js → start-OEQ5VW7Y.js} +11 -11
  142. package/dist/{state-GM22X3RN.js → state-HK67C4UA.js} +3 -3
  143. package/dist/state-HK67C4UA.js.map +1 -0
  144. package/dist/{status-4HGP4ZEF.js → status-HPYMNO2T.js} +11 -11
  145. package/dist/{statusline-QJ6CJGHB.js → statusline-Z5HLKDIA.js} +5 -5
  146. package/dist/{statusline-hook-Q645N4XF.js → statusline-hook-VPPS3PFO.js} +3 -3
  147. package/dist/{stop-YBQL6NFF.js → stop-QNICDWAU.js} +11 -11
  148. package/dist/{sync-DUXN2MFJ.js → sync-RH3M47QK.js} +29 -29
  149. package/dist/{time-Q42HPZZ3.js → time-PM72GK5W.js} +11 -11
  150. package/dist/{time-actions-IXZRVKKQ.js → time-actions-O3MCB7FU.js} +3 -3
  151. package/dist/{timesheet-YJ6O3GUU.js → timesheet-HJXQ4KHL.js} +15 -15
  152. package/dist/{todo-ZBFRL2A5.js → todo-UVKGOG7D.js} +2 -2
  153. package/dist/{tree-H2UYE6LH.js → tree-RGT736E3.js} +30 -28
  154. package/dist/{tree-H2UYE6LH.js.map → tree-RGT736E3.js.map} +1 -1
  155. package/dist/{update-RGNKMRUL.js → update-CMYVBWV3.js} +15 -15
  156. package/dist/{usage-YZRZKJ3H.js → usage-VEKD3JPL.js} +10 -10
  157. package/dist/{usage-ask-BYPNLA2B.js → usage-ask-V2SIRW4F.js} +3 -3
  158. package/dist/{version-4IOMOIDP.js → version-RJ4PCHPB.js} +5 -5
  159. package/dist/{wait-YOHPFWVJ.js → wait-RQZU3KDY.js} +11 -11
  160. package/dist/wd-bin.js +3 -3
  161. package/dist/web/assets/{PtyView-CYAhB_pW.js → PtyView-qP6blm2-.js} +26 -28
  162. package/dist/web/assets/PtyView-qP6blm2-.js.map +1 -0
  163. package/dist/web/assets/index-DuFRboh6.js +129 -0
  164. package/dist/web/assets/index-DuFRboh6.js.map +1 -0
  165. package/dist/web/assets/index-yBTfBzDm.css +1 -0
  166. package/dist/web/index.html +2 -2
  167. package/dist/{web-Q672AIMZ.js → web-GOCU26ZD.js} +617 -526
  168. package/dist/web-GOCU26ZD.js.map +1 -0
  169. package/npm-shrinkwrap.json +3 -4
  170. package/package.json +2 -2
  171. package/dist/chunk-3ZPVKUYD.js.map +0 -1
  172. package/dist/chunk-7Q5PBXF6.js.map +0 -1
  173. package/dist/chunk-7ZOY2QQN.js +0 -43
  174. package/dist/chunk-7ZOY2QQN.js.map +0 -1
  175. package/dist/chunk-AITL3JYB.js.map +0 -1
  176. package/dist/chunk-EXZ4A6VJ.js +0 -9
  177. package/dist/chunk-ICEP4WAK.js +0 -256
  178. package/dist/chunk-ICEP4WAK.js.map +0 -1
  179. package/dist/chunk-KQMHGEI2.js.map +0 -1
  180. package/dist/chunk-LNHSBM4L.js +0 -26
  181. package/dist/chunk-LNHSBM4L.js.map +0 -1
  182. package/dist/chunk-LV5JRLBM.js.map +0 -1
  183. package/dist/chunk-PTAG6WIE.js.map +0 -1
  184. package/dist/chunk-USENBMUV.js.map +0 -1
  185. package/dist/chunk-VHENFC2S.js.map +0 -1
  186. package/dist/chunk-WRDULHAN.js.map +0 -1
  187. package/dist/chunk-YO3BNAAK.js.map +0 -1
  188. package/dist/pty-host-EAWW62U4.js +0 -1235
  189. package/dist/pty-host-EAWW62U4.js.map +0 -1
  190. package/dist/state-GM22X3RN.js.map +0 -1
  191. package/dist/web/assets/PtyView-CYAhB_pW.js.map +0 -1
  192. package/dist/web/assets/index-Ca7KbCED.css +0 -1
  193. package/dist/web/assets/index-iBmmgBZv.js +0 -129
  194. package/dist/web/assets/index-iBmmgBZv.js.map +0 -1
  195. package/dist/web-Q672AIMZ.js.map +0 -1
  196. /package/dist/{add-repo-ALVEGU25.js.map → add-repo-FTAMMPVM.js.map} +0 -0
  197. /package/dist/{answer-CI2SPQQL.js.map → answer-LKNMN2ZM.js.map} +0 -0
  198. /package/dist/{block-TVIYWRJ5.js.map → block-3ZUFH2RO.js.map} +0 -0
  199. /package/dist/{broadcast-GZNMZFOY.js.map → broadcast-I23BZI3R.js.map} +0 -0
  200. /package/dist/{catchup-ZURJI6BF.js.map → catchup-G4EOJIZP.js.map} +0 -0
  201. /package/dist/{child-K6YYF6MQ.js.map → child-MVNEFA2I.js.map} +0 -0
  202. /package/dist/{chunk-ZTWZS5RK.js.map → chunk-24FQ5XXN.js.map} +0 -0
  203. /package/dist/{chunk-D2SVBU7R.js.map → chunk-2FNYJEOH.js.map} +0 -0
  204. /package/dist/{chunk-EEHPZMS3.js.map → chunk-2JLG65GB.js.map} +0 -0
  205. /package/dist/{chunk-DC73NF67.js.map → chunk-2MJQTFTI.js.map} +0 -0
  206. /package/dist/{chunk-G4T2HGLJ.js.map → chunk-4HQEYZIM.js.map} +0 -0
  207. /package/dist/{chunk-CA56ETYX.js.map → chunk-5SXTMOO6.js.map} +0 -0
  208. /package/dist/{chunk-OCUUM755.js.map → chunk-6PZ7RCXK.js.map} +0 -0
  209. /package/dist/{chunk-RTCTD5PJ.js.map → chunk-773UJC5C.js.map} +0 -0
  210. /package/dist/{chunk-W4GDPHIF.js.map → chunk-7ZATXG5F.js.map} +0 -0
  211. /package/dist/{chunk-6Y3VLCKA.js.map → chunk-BI7HIO2I.js.map} +0 -0
  212. /package/dist/{chunk-FGBLFF4O.js.map → chunk-BMPTUIP4.js.map} +0 -0
  213. /package/dist/{chunk-BQS73CWR.js.map → chunk-ET5K6S5H.js.map} +0 -0
  214. /package/dist/{chunk-B2WV5RAL.js.map → chunk-ETAPX4JN.js.map} +0 -0
  215. /package/dist/{chunk-RLPC3YKZ.js.map → chunk-FHC6KHIH.js.map} +0 -0
  216. /package/dist/{chunk-DF4GOVDE.js.map → chunk-GF7RAQFD.js.map} +0 -0
  217. /package/dist/{chunk-ZO7TF5OL.js.map → chunk-GHY7GZWN.js.map} +0 -0
  218. /package/dist/{chunk-5FIUVBUC.js.map → chunk-GN7EAXHU.js.map} +0 -0
  219. /package/dist/{chunk-EYJ42LDG.js.map → chunk-GTFMUWK6.js.map} +0 -0
  220. /package/dist/{chunk-4QMWNAEJ.js.map → chunk-HCYES6U7.js.map} +0 -0
  221. /package/dist/{chunk-TOMDOA4P.js.map → chunk-HNZ736XN.js.map} +0 -0
  222. /package/dist/{chunk-ATQB6PTV.js.map → chunk-HPUD5IGB.js.map} +0 -0
  223. /package/dist/{chunk-FV7BSQPQ.js.map → chunk-HQDQRC4F.js.map} +0 -0
  224. /package/dist/{chunk-SDYY5MHW.js.map → chunk-INXHVNMZ.js.map} +0 -0
  225. /package/dist/{chunk-QNOJOZYK.js.map → chunk-IRDWXDID.js.map} +0 -0
  226. /package/dist/{chunk-EA4C6TVY.js.map → chunk-IVS2MAHD.js.map} +0 -0
  227. /package/dist/{chunk-QOLHDDM2.js.map → chunk-IXC6EXVJ.js.map} +0 -0
  228. /package/dist/{chunk-IU6LA6EB.js.map → chunk-IXZOZZGD.js.map} +0 -0
  229. /package/dist/{chunk-SZAD5U3J.js.map → chunk-LB2GAU7E.js.map} +0 -0
  230. /package/dist/{chunk-GNERWNZY.js.map → chunk-MVBBESXK.js.map} +0 -0
  231. /package/dist/{chunk-AIYZJ7XD.js.map → chunk-N7T6NPE2.js.map} +0 -0
  232. /package/dist/{chunk-GQ5WECPJ.js.map → chunk-NREZVTBP.js.map} +0 -0
  233. /package/dist/{chunk-EXZ4A6VJ.js.map → chunk-NRX5V443.js.map} +0 -0
  234. /package/dist/{chunk-NYGKSOQ4.js.map → chunk-OPV6BE3W.js.map} +0 -0
  235. /package/dist/{chunk-UAF2YFLZ.js.map → chunk-ROEEXEN7.js.map} +0 -0
  236. /package/dist/{chunk-F4UIKOU6.js.map → chunk-TL7VLRRF.js.map} +0 -0
  237. /package/dist/{chunk-NOQA7MJ4.js.map → chunk-U2A2DHWP.js.map} +0 -0
  238. /package/dist/{chunk-Q2B3NUSM.js.map → chunk-U4XSBYQW.js.map} +0 -0
  239. /package/dist/{chunk-Z4FWXDJG.js.map → chunk-VH5FRKJM.js.map} +0 -0
  240. /package/dist/{chunk-DCENKA6E.js.map → chunk-W5YYTITQ.js.map} +0 -0
  241. /package/dist/{chunk-5P27YL64.js.map → chunk-WOY35FXP.js.map} +0 -0
  242. /package/dist/{chunk-HI674QZF.js.map → chunk-XIN6XUFL.js.map} +0 -0
  243. /package/dist/{chunk-EVTMZ5IH.js.map → chunk-XWKN2HJD.js.map} +0 -0
  244. /package/dist/{chunk-CMRTNTMU.js.map → chunk-YKTJL4SW.js.map} +0 -0
  245. /package/dist/{chunk-PUJSLL6R.js.map → chunk-ZLPK2LQ3.js.map} +0 -0
  246. /package/dist/{chunk-Z4P23XG3.js.map → chunk-ZX4ONO5Y.js.map} +0 -0
  247. /package/dist/{cli-OPORB5PF.js.map → cli-CAF6VCVO.js.map} +0 -0
  248. /package/dist/{color-C223W3Z6.js.map → color-7CQNI6Y4.js.map} +0 -0
  249. /package/dist/{config-KQYXQCQA.js.map → config-EXQY26W4.js.map} +0 -0
  250. /package/dist/{coordinate-4E5GIMC6.js.map → coordinate-LRY7LXS6.js.map} +0 -0
  251. /package/dist/{digest-GYF4YLUH.js.map → digest-2AFW3WBL.js.map} +0 -0
  252. /package/dist/{history-25DNQKKC.js.map → history-RFIDCGQY.js.map} +0 -0
  253. /package/dist/{hook-B4JO2X57.js.map → hook-XBALB337.js.map} +0 -0
  254. /package/dist/{hydrate-IJEKNZIP.js.map → hydrate-DAEY4PB6.js.map} +0 -0
  255. /package/dist/{init-UJVOUDJI.js.map → init-4BK3T34W.js.map} +0 -0
  256. /package/dist/{install-skills-FV2L5QHE.js.map → install-skills-TL5D7HZU.js.map} +0 -0
  257. /package/dist/{keep-PKXGFZO2.js.map → keep-57TUKADV.js.map} +0 -0
  258. /package/dist/{list-VYQ3QE2H.js.map → list-DRQRIT6U.js.map} +0 -0
  259. /package/dist/{move-IAZY23ZX.js.map → move-UEHJ375P.js.map} +0 -0
  260. /package/dist/{note-6HQUKUYY.js.map → note-FHPDVBRI.js.map} +0 -0
  261. /package/dist/{overlaps-CGP3RJOW.js.map → overlaps-GKAKEUB6.js.map} +0 -0
  262. /package/dist/{pin-PAWGQ4Q2.js.map → pin-CFTQDPPC.js.map} +0 -0
  263. /package/dist/{prune-42MS36OR.js.map → prune-IQB2T45B.js.map} +0 -0
  264. /package/dist/{read-ATNCW4KH.js.map → read-DHJ6VY44.js.map} +0 -0
  265. /package/dist/{remove-GLDJOKUI.js.map → remove-MW25RLNV.js.map} +0 -0
  266. /package/dist/{report-AK7Z2Y4S.js.map → report-II75EKM6.js.map} +0 -0
  267. /package/dist/{restart-DEPDGEZB.js.map → restart-4BGVRBX6.js.map} +0 -0
  268. /package/dist/{review-RYAGH3PY.js.map → review-WKB3K6LI.js.map} +0 -0
  269. /package/dist/{review-now-K4UWD7A5.js.map → review-now-AT2SPPRO.js.map} +0 -0
  270. /package/dist/{run-WNP2SMNW.js.map → run-YS2D7WAQ.js.map} +0 -0
  271. /package/dist/{screen-P746M4F2.js.map → screen-VVRNQXVW.js.map} +0 -0
  272. /package/dist/{search-XQ2WMK5X.js.map → search-MKYCKZF4.js.map} +0 -0
  273. /package/dist/{section-Q7TPOV7U.js.map → section-Y6RDD3MN.js.map} +0 -0
  274. /package/dist/{send-EGG23J2B.js.map → send-AZM2XKN2.js.map} +0 -0
  275. /package/dist/{show-KSMC7AJL.js.map → show-33VV3XCF.js.map} +0 -0
  276. /package/dist/{snooze-4LVYUQEX.js.map → snooze-OFYZVVYS.js.map} +0 -0
  277. /package/dist/{start-YKLLXW3L.js.map → start-OEQ5VW7Y.js.map} +0 -0
  278. /package/dist/{status-4HGP4ZEF.js.map → status-HPYMNO2T.js.map} +0 -0
  279. /package/dist/{statusline-QJ6CJGHB.js.map → statusline-Z5HLKDIA.js.map} +0 -0
  280. /package/dist/{statusline-hook-Q645N4XF.js.map → statusline-hook-VPPS3PFO.js.map} +0 -0
  281. /package/dist/{stop-YBQL6NFF.js.map → stop-QNICDWAU.js.map} +0 -0
  282. /package/dist/{sync-DUXN2MFJ.js.map → sync-RH3M47QK.js.map} +0 -0
  283. /package/dist/{time-Q42HPZZ3.js.map → time-PM72GK5W.js.map} +0 -0
  284. /package/dist/{time-actions-IXZRVKKQ.js.map → time-actions-O3MCB7FU.js.map} +0 -0
  285. /package/dist/{timesheet-YJ6O3GUU.js.map → timesheet-HJXQ4KHL.js.map} +0 -0
  286. /package/dist/{todo-ZBFRL2A5.js.map → todo-UVKGOG7D.js.map} +0 -0
  287. /package/dist/{update-RGNKMRUL.js.map → update-CMYVBWV3.js.map} +0 -0
  288. /package/dist/{usage-YZRZKJ3H.js.map → usage-VEKD3JPL.js.map} +0 -0
  289. /package/dist/{usage-ask-BYPNLA2B.js.map → usage-ask-V2SIRW4F.js.map} +0 -0
  290. /package/dist/{version-4IOMOIDP.js.map → version-RJ4PCHPB.js.map} +0 -0
  291. /package/dist/{wait-YOHPFWVJ.js.map → wait-RQZU3KDY.js.map} +0 -0
@@ -0,0 +1 @@
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';\nimport { STALE_WORKING_MS } from '../status/session-status.js';\nimport { PROGRESS_INDETERMINATE, PROGRESS_SET, type ProgramKind, type StreamSignal } from './stream-status.js';\n\n/**\n * A status for a session whose tool isn't Claude Code (config `aiCommand`, e.g. opencode, codex): no hooks report its\n * turns, so its terminal stands in. First what the agent says about itself in its output (`statusFromSignal`: OSC 7501\n * program status, else an OSC 9;4 bar), then the PTY host's \"last printed anything\" — a working agent redraws its\n * spinner, an idle one prints nothing: working while it printed in the last `OUTPUT_WORKING_MS`, idle after, never\n * \"done, unseen\" or \"needs input\" (output can't tell a finished turn from a question). Hooks beat both: this is only\n * asked when no hook status exists (session-wire.ts). 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 /** What it says about itself in its output (PtyInfo.signal). */\n signal?: StreamSignal;\n}\n\nexport function statusFromOutput(p: PtyOutput, now: number): SessionAttention | null {\n if (!p.tool || p.tool === 'claude') return null;\n const said = p.signal ? statusFromSignal(p.signal, p.tool, p.lastOutputAt, now) : null;\n if (said) return said;\n if (!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\n/** What a blocked agent waits for, by its `kind`; any other (or none): \"you\". */\nconst WAITING_FOR = new Map<string, string>([\n ['permission', 'your permission'],\n ['question', 'your answer'],\n ['auth', 'you to sign in'],\n] satisfies Array<[ProgramKind, string]>);\n\n/**\n * What the agent said in-band, as a status; null where it says nothing that decides one (no signal, a cleared one, a\n * bar in error or paused), and the output guess decides.\n *\n * - OSC 7501: working → working; blocked → needs input (its `msg` as the summary); idle, done and error → idle, seen.\n * `done` is \"finished, not seen yet\", but nothing here could mark it seen (no status row: `markSeen`), and the agent\n * itself turns it into idle at your next key — so it is shown as idle, its summary saying it finished.\n * - OSC 9;4: a bar with a percent (1) or indeterminate (3) → working. 2 (error) and 4 (paused) don't say whether it is\n * still at work; 0 is no bar.\n *\n * A \"working\" never outlives `STALE_WORKING_MS` of silence: an agent at work redraws something (Codex its elapsed\n * time, Claude Code and opencode a spinner), so a terminal that said working and then printed nothing for 15 minutes\n * went away without saying (killed, crashed under a shell that lives on). It is shown idle and `stale`, as a hook's\n * working is after the same quiet (session-status.ts). The spec forbids requiring a heartbeat; this asks none — any\n * output at all keeps it. Blocked has no expiry: waiting on you is quiet by nature, and a new process (a new mirror)\n * or the agent's next report ends it.\n */\nexport function statusFromSignal(\n signal: StreamSignal,\n tool: string,\n lastOutputAt: string | undefined,\n now: number,\n): SessionAttention | null {\n const by = `${tool} says so in its terminal`;\n const program = signal.program;\n if (program) {\n const percent = program.progress !== undefined ? `, ${program.progress}%` : '';\n const base = {\n since: program.since,\n updatedAt: lastOutputAt ?? program.since,\n ...(program.progress !== undefined ? { progress: program.progress } : {}),\n };\n switch (program.state) {\n case 'working':\n return working(base, lastOutputAt, now, `Working${percent}`, by);\n case 'blocked':\n return {\n ...base,\n state: 'needs_input',\n seen: false,\n stale: false,\n summary: program.message ?? `Waiting for ${WAITING_FOR.get(program.kind ?? '') ?? 'you'}${percent} — ${by}`,\n };\n case 'done':\n return { ...base, state: 'idle', seen: true, stale: false, summary: program.message ?? `Finished — ${by}` };\n case 'error':\n return { ...base, state: 'idle', seen: true, stale: false, summary: program.message ?? `Stopped on an error — ${by}` };\n case 'idle':\n return { ...base, state: 'idle', seen: true, stale: false, summary: `Idle — ${by}` };\n default:\n return null; // a newer host's state this build doesn't know: the guess decides\n }\n }\n const bar = signal.progress;\n if (bar && (bar.state === PROGRESS_SET || bar.state === PROGRESS_INDETERMINATE)) {\n const set = bar.state === PROGRESS_SET;\n const base = { since: bar.since, updatedAt: lastOutputAt ?? bar.since, ...(set ? { progress: bar.percent } : {}) };\n return working(base, lastOutputAt, now, `Busy${set ? `, ${bar.percent}%` : ''}`, `its progress bar (${tool})`);\n }\n return null;\n}\n\nfunction working(\n base: Pick<SessionAttention, 'since' | 'updatedAt' | 'progress'>,\n lastOutputAt: string | undefined,\n now: number,\n what: string,\n by: string,\n): SessionAttention {\n const last = Date.parse(lastOutputAt ?? base.since);\n if (Number.isFinite(last) && now - last > STALE_WORKING_MS) {\n const quiet = `${Math.round(STALE_WORKING_MS / 60_000)} min`;\n return { ...base, state: 'idle', seen: true, stale: true, summary: `Said it was working, then printed nothing for ${quiet} — ${by}` };\n }\n return { ...base, state: 'working', seen: true, stale: false, summary: `${what} — ${by}` };\n}\n","import path from 'node:path';\nimport type { AgentAdapter } from '../agents/types.js';\nimport { agentFor, agentSettings, assistantAgent, sessionToolFor, trustAgentFolder } 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 { parentOf } from '../sessions/session-children.js';\nimport { bestEffort } from '../platform/best-effort.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';\nimport type { Grid } from './terminal-size.js';\nimport { streamSignalFrom } from './stream-status.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, last output and what it says about itself (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 // The signal is the host's data (another build's, maybe): shape-checked, what doesn't fit dropped (stream-status.ts).\n outputs = new Map(\n ptys\n .filter((p) => !p.exited)\n .map((p) => {\n const signal = streamSignalFrom(p.signal);\n return [p.id, { tool: p.tool, lastOutputAt: p.lastOutputAt, startedAt: p.startedAt, pid: p.pid, ...(signal ? { signal } : {}) }];\n }),\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\n/** The scratch folders of the session that started this one (session-children.ts), that exist and are safe to name; none for one nobody started. */\nexport function coordinatorFolders(session: WorktreeSession): string[] {\n return (\n bestEffort(\n `coordinator folders of ${session.target}:${session.branch}`,\n () => {\n const link = parentOf(sessionIdFor(session));\n const parent = link ? findSession(link.parentId) : null;\n return parent ? (agentFor(loadConfig(), parent).tempFolders?.(parent) ?? []) : [];\n },\n [],\n ) ?? []\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 agent = agentFor(config, session);\n const launch = agent.launch;\n // Its folder trusted on its account before it starts there (a worktree work made, a repo you added): no \"do you trust\n // this folder?\" stop for a folder of work's own (claude/folder-trust.ts).\n trustAgentFolder(agent, session, cwd);\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 // A child session reads and writes its coordinator's scratch folders as its own (the task files are there, and what\n // they hand each other): otherwise every read there stops at \"read outside the working directories?\", which its\n // coordinator may not answer (reported: a child of grunnur's main session sat at that question).\n const shared = coordinatorFolders(session);\n const base = sessionToolFor(launch.tool(config), { write: mayStartHost });\n const tool = shared.length && launch.withFolders ? launch.withFolders(base, shared) : base;\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(\n sessionId: string,\n extra: { initialPrompt?: string; grid?: Grid; attachOnly?: boolean } = {},\n): 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 // A terminal reconnecting with its screen kept (`attachOnly`, resume.ts) attaches to what runs and starts nothing,\n // neither a host nor an agent: one stopped on purpose (`work pty-host --stop`, a session that ended) stays stopped,\n // and the tab says the connection closed, as before.\n if (extra.attachOnly) return attachToRunning(sessionId);\n // The first prompt only applies to a fresh spawn (the host ignores the\n // spec when the session's PTY is already running), and so does the grid: the Terminal tab's that starts it\n // (terminal-size.ts), so its agent doesn't start at another size and paint again a moment later. None (a start\n // with no tab): the host takes the last grid a client used.\n const spec = {\n ...base,\n ...(extra.initialPrompt ? { initialPrompt: extra.initialPrompt } : {}),\n ...(extra.grid ? { cols: extra.grid.cols, rows: extra.grid.rows } : {}),\n };\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/** The host's attach address of a terminal that runs now; throws NOT_RUNNING when none does. Never starts anything. */\nasync function attachToRunning(sessionId: string): Promise<string> {\n const look = async (): Promise<{ c: PtyHostClient; info: PtyInfo | null } | null> => {\n const c = await getClient(false);\n return c ? { c, info: await c.get(sessionId) } : null;\n };\n let found = await look();\n if (found && !found.info) {\n // Not there, or a client of a host that was replaced since (another port, its calls fail): asked once more, fresh.\n client = null;\n found = await look();\n }\n if (!found?.info || found.info.exited) throw new Error(NOT_RUNNING);\n live.add(sessionId);\n return found.c.attachUrl(sessionId);\n}\n\n/** What a reconnect is told when its terminal no longer runs (nothing is started for it). */\nexport const NOT_RUNNING = 'its terminal is not running';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAE,mBAAmB,CAAC;AACzD;AAIO,SAAS,gBAAsB;AACpC,MAAI,aAAc,eAAc,YAAY;AAC5C,iBAAe;AACf,WAAS;AACT,SAAO,oBAAI,IAAI;AACf,aAAW,oBAAI,IAAI;AACrB;","names":["working","path","path"]}
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  isSessionCi
4
- } from "./chunk-DC73NF67.js";
4
+ } from "./chunk-2MJQTFTI.js";
5
5
  import {
6
6
  defaultHost,
7
7
  hostForOrigin,
8
8
  hostOfThread,
9
9
  knownHosts
10
- } from "./chunk-NOQA7MJ4.js";
10
+ } from "./chunk-U2A2DHWP.js";
11
11
  import {
12
12
  MAX_THREAD_BODY,
13
13
  isThreadCode,
@@ -19,7 +19,7 @@ import {
19
19
  } from "./chunk-GNIYYXQX.js";
20
20
  import {
21
21
  sessionRepos
22
- } from "./chunk-AITL3JYB.js";
22
+ } from "./chunk-HUWWMTNG.js";
23
23
  import {
24
24
  json,
25
25
  sessionIdFor,
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-Z6ACV5ZQ.js";
32
32
  import {
33
33
  loadConfig
34
- } from "./chunk-3ZPVKUYD.js";
34
+ } from "./chunk-ETWP7MDS.js";
35
35
 
36
36
  // src/core/pr/pr-replies.ts
37
37
  import fs from "fs";
@@ -306,4 +306,4 @@ export {
306
306
  draftReply,
307
307
  retireResolvedReplies
308
308
  };
309
- //# sourceMappingURL=chunk-CA56ETYX.js.map
309
+ //# sourceMappingURL=chunk-5SXTMOO6.js.map
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/pty/flow-control.ts
4
+ var HIGH_WATERMARK = 1e5;
5
+ var LOW_WATERMARK = 5e3;
6
+ var ACK_EVERY = 5e3;
7
+ var FLOW_PARAM = "flow";
8
+ var CATCH_UP_PARAM = "catchup";
9
+ function withFlow(url, opts = {}) {
10
+ const params = `${FLOW_PARAM}=1${opts.screenOnly ? `&${CATCH_UP_PARAM}=screen` : ""}`;
11
+ return `${url}${url.includes("?") ? "&" : "?"}${params}`;
12
+ }
13
+ function utf16Length(bytes) {
14
+ let n = 0;
15
+ for (let i = 0; i < bytes.length; i++) {
16
+ const b = bytes[i];
17
+ if ((b & 192) !== 128) n += b >= 240 ? 2 : 1;
18
+ }
19
+ return n;
20
+ }
21
+ function ackFrame(chars) {
22
+ return JSON.stringify({ type: "ack", chars });
23
+ }
24
+ var AckCounter = class {
25
+ constructor(send, every = ACK_EVERY) {
26
+ this.send = send;
27
+ this.every = every;
28
+ }
29
+ pending = 0;
30
+ drawn(chars) {
31
+ if (!(chars > 0)) return;
32
+ this.pending += chars;
33
+ if (this.pending < this.every) return;
34
+ const n = this.pending;
35
+ this.pending = 0;
36
+ this.send(n);
37
+ }
38
+ };
39
+
40
+ // src/core/pty/terminal-size.ts
41
+ var MIN_COLS = 2;
42
+ var MIN_ROWS = 2;
43
+ var MAX_COLS = 1e3;
44
+ var MAX_ROWS = 500;
45
+ var COLS_PARAM = "cols";
46
+ var ROWS_PARAM = "rows";
47
+ function validGrid(cols, rows) {
48
+ const ok = (n, min, max) => typeof n === "number" && Number.isInteger(n) && n >= min && n <= max;
49
+ return ok(cols, MIN_COLS, MAX_COLS) && ok(rows, MIN_ROWS, MAX_ROWS) ? { cols, rows } : null;
50
+ }
51
+ function withGrid(url, grid) {
52
+ if (!grid) return url;
53
+ return `${url}${url.includes("?") ? "&" : "?"}${COLS_PARAM}=${grid.cols}&${ROWS_PARAM}=${grid.rows}`;
54
+ }
55
+ function gridFromParams(params) {
56
+ const num = (s) => s !== null && /^\d{1,4}$/.test(s) ? Number(s) : NaN;
57
+ return validGrid(num(params.get(COLS_PARAM)), num(params.get(ROWS_PARAM)));
58
+ }
59
+ function sameGrid(a, b) {
60
+ return !!a && !!b && a.cols === b.cols && a.rows === b.rows;
61
+ }
62
+ var CONPTY_REFLOW_BUILD = 21376;
63
+ function windowsPtyFor(platform, release, bundledConpty = false) {
64
+ if (platform !== "win32") return void 0;
65
+ const read = Number(/^\d+\.\d+\.(\d+)/.exec(release)?.[1]);
66
+ const build = Number.isInteger(read) && read > 0 ? read : 0;
67
+ if (bundledConpty) return { backend: "conpty", buildNumber: Math.max(build, CONPTY_REFLOW_BUILD) };
68
+ return build ? { backend: "conpty", buildNumber: build } : void 0;
69
+ }
70
+
71
+ export {
72
+ HIGH_WATERMARK,
73
+ LOW_WATERMARK,
74
+ FLOW_PARAM,
75
+ CATCH_UP_PARAM,
76
+ withFlow,
77
+ utf16Length,
78
+ ackFrame,
79
+ AckCounter,
80
+ MIN_ROWS,
81
+ validGrid,
82
+ withGrid,
83
+ gridFromParams,
84
+ sameGrid,
85
+ windowsPtyFor
86
+ };
87
+ //# sourceMappingURL=chunk-6KMG4WNW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/pty/flow-control.ts","../src/core/pty/terminal-size.ts"],"sourcesContent":["/**\n * Flow control between the PTY host and a client that draws its output (terminal-rendering.md, \"Flow control and\n * coalescing\"). Pure and import-free: the browser's Terminal tab, `work attach` and the host share it.\n *\n * A client that acks says so on its attach address (`?flow=1`), then tells the host every `ACK_EVERY` characters\n * it has finished drawing (`{ type: 'ack', chars }`). The unit is the host's: the output's characters as JavaScript\n * counts them (UTF-16 code units, VS Code's unit). A client receives UTF-8 bytes and counts them with `utf16Length`,\n * without decoding. The numbers are VS Code's (`FlowControlConstants`, platform/terminal/common/terminal.ts).\n */\n\n/** Unacknowledged characters above which a client is too far behind: the PTY waits for it, or it is sent no more. */\nexport const HIGH_WATERMARK = 100_000;\n/** Unacknowledged characters below which it has caught up. */\nexport const LOW_WATERMARK = 5_000;\n/** A client acks once this many characters are drawn. At most LOW_WATERMARK, or a client that stopped short of it would never count as caught up. */\nexport const ACK_EVERY = 5_000;\n/** The query parameter a client that acks adds to its attach address: an older host ignores it (and its acks). */\nexport const FLOW_PARAM = 'flow';\n/**\n * `catchup=screen`: the client's catch-up screens (it fell behind) are the screen only, without the scrollback.\n * `work attach` asks for it: its native terminal keeps your history, which a catch-up must not clear or fill again.\n * An older host ignores it and sends the scrollback too (drawn again into your history, never cleared).\n */\nexport const CATCH_UP_PARAM = 'catchup';\n\n/** `url` with the flow parameter added: this client acks. `screenOnly`: its catch-up screens without the scrollback. */\nexport function withFlow(url: string, opts: { screenOnly?: boolean } = {}): string {\n const params = `${FLOW_PARAM}=1${opts.screenOnly ? `&${CATCH_UP_PARAM}=screen` : ''}`;\n return `${url}${url.includes('?') ? '&' : '?'}${params}`;\n}\n\n/**\n * How many UTF-16 code units the UTF-8 `bytes` decode to: one per sequence, two for a 4-byte one (a surrogate pair).\n * The host's output is a JavaScript string sent as UTF-8, and a string's length survives that round trip (a lone\n * surrogate becomes U+FFFD, also one unit). Split anywhere, the parts still add up: a sequence is counted at its lead byte.\n */\nexport function utf16Length(bytes: Uint8Array): number {\n let n = 0;\n for (let i = 0; i < bytes.length; i++) {\n const b = bytes[i];\n if ((b & 0xc0) !== 0x80) n += b >= 0xf0 ? 2 : 1;\n }\n return n;\n}\n\n/** The ack frame a client sends (ClientFrame `ack`). */\nexport function ackFrame(chars: number): string {\n return JSON.stringify({ type: 'ack', chars });\n}\n\n/**\n * Counts the characters a client finished drawing, and sends an ack once `every` of them are (VS Code's\n * CharCountAckSize). What is left below `every` is never sent; that is why `every` is at most LOW_WATERMARK.\n */\nexport class AckCounter {\n private pending = 0;\n constructor(\n private readonly send: (chars: number) => void,\n private readonly every = ACK_EVERY,\n ) {}\n\n drawn(chars: number): void {\n if (!(chars > 0)) return;\n this.pending += chars;\n if (this.pending < this.every) return;\n const n = this.pending;\n this.pending = 0;\n this.send(n);\n }\n}\n","/**\n * A terminal's size, as clients state it and the PTY host takes it (terminal-rendering.md, \"Resizing and attaching at\n * a size\"). Pure and import-free: the browser's Terminal tab, `work attach`, work web's relay and the host share it.\n *\n * - **Attaching at a size.** A client that takes the PTY's size anyway (the terminal shown, `work attach`; never a\n * hidden one) states its grid on its attach address (`?cols=…&rows=…`, `withGrid`). The host resizes the PTY and its\n * screen copy to it before it takes the snapshot, so the client draws the snapshot at its own grid: no second reflow,\n * no repaint after the fact. An older host ignores the parameters, and the client's resize after the replay (sent as\n * before) does it the old way.\n * - **Starting at a size.** A tab asking for its terminal states the same grid, so an agent it starts is started at it.\n * - **ConPTY.** On Windows the pseudo-console reflows lines itself; a terminal that reflows them again on a resize draws\n * them twice (`windowsPty`, which xterm.js reads to leave that to ConPTY).\n */\n\n/** Columns and rows. */\nexport interface Grid {\n cols: number;\n rows: number;\n}\n\n/** The smallest grid the host takes (one row is no screen for a TUI; the registry refused under 2 before this). */\nexport const MIN_COLS = 2;\nexport const MIN_ROWS = 2;\n/** The largest: a grid is a buffer of cols × (rows + scrollback) cells in the host's screen copy, so a client can't ask for an absurd one. */\nexport const MAX_COLS = 1000;\nexport const MAX_ROWS = 500;\n\n/** The attach address's parameters for a stated grid. An older host ignores them. */\nexport const COLS_PARAM = 'cols';\nexport const ROWS_PARAM = 'rows';\n\n/** `cols` × `rows` when both are whole numbers within MIN..MAX, else null. */\nexport function validGrid(cols: unknown, rows: unknown): Grid | null {\n const ok = (n: unknown, min: number, max: number): n is number => typeof n === 'number' && Number.isInteger(n) && n >= min && n <= max;\n return ok(cols, MIN_COLS, MAX_COLS) && ok(rows, MIN_ROWS, MAX_ROWS) ? { cols, rows } : null;\n}\n\n/** `url` with the grid stated (`?cols=…&rows=…`); `url` as it is when there is none. */\nexport function withGrid(url: string, grid: Grid | null | undefined): string {\n if (!grid) return url;\n return `${url}${url.includes('?') ? '&' : '?'}${COLS_PARAM}=${grid.cols}&${ROWS_PARAM}=${grid.rows}`;\n}\n\n/** The grid stated on an attach address (URLSearchParams), or null: none, or not a valid one. */\nexport function gridFromParams(params: { get(name: string): string | null }): Grid | null {\n const num = (s: string | null) => (s !== null && /^\\d{1,4}$/.test(s) ? Number(s) : NaN);\n return validGrid(num(params.get(COLS_PARAM)), num(params.get(ROWS_PARAM)));\n}\n\n/** Two grids the same (null for none equals nothing). */\nexport function sameGrid(a: Grid | null | undefined, b: Grid | null | undefined): boolean {\n return !!a && !!b && a.cols === b.cols && a.rows === b.rows;\n}\n\n/** xterm.js's `windowsPty` option, as the host tells a client and sets on its screen copy. */\nexport interface WindowsPty {\n backend: 'conpty';\n buildNumber: number;\n}\n\n/**\n * The Windows build ConPTY reflows lines on a resize from, and the one xterm.js 6 compares `windowsPty.buildNumber`\n * with (its only threshold). node-pty's bundled ConPTY (1.1.0 ships conpty 1.23.251008001, Windows Terminal 1.23's)\n * reflows whatever the OS build: Tabby reports this build for it (`WIN_BUILD_CONPTY_REFLOW_SUPPORTED`).\n */\nexport const CONPTY_REFLOW_BUILD = 21376;\n\n/**\n * The `windowsPty` option for a PTY on `platform` with `os.release()` = `release` (\"10.0.22631\"): ConPTY and the\n * Windows build, as VS Code sets it (terminalProcess.ts `getWindowsPty`). xterm.js 6 then reflows lines on a resize\n * only from build 21376 (where ConPTY reflows them too), turns on its wrapping heuristics below it, and adds rows at the\n * bottom on a grow instead of pulling lines back from the scrollback (ConPTY reprints its view). `bundledConpty`: the\n * PTY runs on node-pty's own ConPTY (config `useBundledConpty`), which behaves as at least CONPTY_REFLOW_BUILD.\n * Undefined off Windows, or when the build can't be read (and it isn't the bundled one).\n */\nexport function windowsPtyFor(platform: string, release: string, bundledConpty = false): WindowsPty | undefined {\n if (platform !== 'win32') return undefined;\n const read = Number(/^\\d+\\.\\d+\\.(\\d+)/.exec(release)?.[1]);\n const build = Number.isInteger(read) && read > 0 ? read : 0;\n if (bundledConpty) return { backend: 'conpty', buildNumber: Math.max(build, CONPTY_REFLOW_BUILD) };\n return build ? { backend: 'conpty', buildNumber: build } : undefined;\n}\n\n/** A `windowsPty` as read off the wire (the replay frame): shape-checked, never cast. */\nexport function isWindowsPty(x: unknown): x is WindowsPty {\n const w = x as WindowsPty | null;\n return !!w && typeof w === 'object' && w.backend === 'conpty' && Number.isInteger(w.buildNumber) && w.buildNumber > 0;\n}\n"],"mappings":";;;AAWO,IAAM,i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AGO,SAAS,SAAS,KAAa,MAAuC;AAC3E,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,GAAG,GAAG,GAAG,IAAI,SAAS,GAAG,IAAI,MAAM,GAAG,GAAG,UAAU,IAAI,KAAK,IAAI,IAAI,UAAU,IAAI,KAAK,IAAI;AACpG;AAGO,SAAS,eAAe,QAA2D;AACxF,QAAM,MAAM,CAAC,MAAsB,MAAM,QAAQ,YAAY,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI;AACnF,SAAO,UAAU,IAAI,OAAO,IAAI,UAAU,CAAC,GAAG,IAAI,OAAO,IAAI,UAAU,CAAC,CAAC;AAC3E;AAGO,SAAS,SAAS,GAA4B,GAAqC;AACxF,SAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE;AACzD;AAaO,IAAM,sBAAsB;AAU5B,SAAS,cAAc,UAAkB,SAAiB,gBAAgB,OAA+B;AAC9G,MAAI,aAAa,QAAS,QAAO;AACjC,QAAM,OAAO,OAAO,mBAAmB,KAAK,OAAO,IAAI,CAAC,CAAC;AACzD,QAAM,QAAQ,OAAO,UAAU,IAAI,KAAK,OAAO,IAAI,OAAO;AAC1D,MAAI,cAAe,QAAO,EAAE,SAAS,UAAU,aAAa,KAAK,IAAI,OAAO,mBAAmB,EAAE;AACjG,SAAO,QAAQ,EAAE,SAAS,UAAU,aAAa,MAAM,IAAI;AAC7D;","names":[]}
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createFsWatcher,
4
4
  findSessionById
5
- } from "./chunk-AITL3JYB.js";
5
+ } from "./chunk-HUWWMTNG.js";
6
6
 
7
7
  // src/core/sessions/web-state.ts
8
8
  function findSession(sessionId) {
@@ -68,4 +68,4 @@ export {
68
68
  disposeSessionWatcher,
69
69
  disposeAllWatchers
70
70
  };
71
- //# sourceMappingURL=chunk-OCUUM755.js.map
71
+ //# sourceMappingURL=chunk-6PZ7RCXK.js.map
@@ -4,17 +4,17 @@ import {
4
4
  } from "./chunk-4CXUVBOD.js";
5
5
  import {
6
6
  buildAiLaunchArgs
7
- } from "./chunk-KQMHGEI2.js";
7
+ } from "./chunk-NWKVTUTN.js";
8
8
  import {
9
9
  applyEnvDelta,
10
10
  hasEnvDelta
11
11
  } from "./chunk-ED6YLB4S.js";
12
12
  import {
13
13
  loadConfig
14
- } from "./chunk-3ZPVKUYD.js";
14
+ } from "./chunk-ETWP7MDS.js";
15
15
  import {
16
16
  detachHere
17
- } from "./chunk-VHENFC2S.js";
17
+ } from "./chunk-M2X6OHHR.js";
18
18
  import {
19
19
  spawn_default
20
20
  } from "./chunk-QOSAWNOU.js";
@@ -132,4 +132,4 @@ export {
132
132
  openVSCode,
133
133
  launchAi
134
134
  };
135
- //# sourceMappingURL=chunk-RTCTD5PJ.js.map
135
+ //# sourceMappingURL=chunk-773UJC5C.js.map
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  detachHere,
7
7
  killTree
8
- } from "./chunk-VHENFC2S.js";
8
+ } from "./chunk-M2X6OHHR.js";
9
9
  import {
10
10
  spawn_default
11
11
  } from "./chunk-QOSAWNOU.js";
@@ -158,4 +158,4 @@ export {
158
158
  userStatusLine,
159
159
  runStatusLineCommand
160
160
  };
161
- //# sourceMappingURL=chunk-W4GDPHIF.js.map
161
+ //# sourceMappingURL=chunk-7ZATXG5F.js.map
@@ -8,13 +8,15 @@ import {
8
8
  applyPlacePatch,
9
9
  applySectionOp,
10
10
  asRailPlace,
11
+ asRailView,
11
12
  cleanSections,
12
13
  loadConfig,
13
14
  projectColorsOf
14
- } from "./chunk-3ZPVKUYD.js";
15
+ } from "./chunk-ETWP7MDS.js";
15
16
 
16
17
  // src/core/rail/rail-store.ts
17
18
  var SECTIONS_KEY = "ui:rail-sections";
19
+ var VIEW_KEY = "ui:rail-view";
18
20
  function readSections(d) {
19
21
  const row = d.prepare("SELECT value FROM meta WHERE key = ?").get(SECTIONS_KEY);
20
22
  return row && cleanSections(json.parse(row.value)) || [];
@@ -27,9 +29,20 @@ function readRailLayout() {
27
29
  if (p) places[r.session_id] = p;
28
30
  }
29
31
  const projectColors = projectColorsOf(loadConfig()?.colors);
30
- return { sections: readSections(d), places, ...Object.keys(projectColors).length ? { projectColors } : {} };
32
+ const stored = d.prepare("SELECT value FROM meta WHERE key = ?").get(VIEW_KEY);
33
+ const view = stored ? asRailView(json.parse(stored.value)) : null;
34
+ return {
35
+ sections: readSections(d),
36
+ places,
37
+ ...Object.keys(projectColors).length ? { projectColors } : {},
38
+ ...view ? { view } : {}
39
+ };
31
40
  });
32
41
  }
42
+ function saveRailView(view) {
43
+ tx((d) => d.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)").run(VIEW_KEY, JSON.stringify(view)));
44
+ return readRailLayout();
45
+ }
33
46
  function changeRailSections(op) {
34
47
  const error = tx((d) => {
35
48
  const r = applySectionOp(readSections(d), op);
@@ -65,7 +78,8 @@ function writePlace(d, sessionId, place) {
65
78
 
66
79
  export {
67
80
  readRailLayout,
81
+ saveRailView,
68
82
  changeRailSections,
69
83
  placeSession
70
84
  };
71
- //# sourceMappingURL=chunk-PTAG6WIE.js.map
85
+ //# sourceMappingURL=chunk-APHVSSLI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/rail/rail-store.ts"],"sourcesContent":["import { loadConfig } from '../platform/config.js';\nimport { json, tx, withDb, type Db } from '../platform/db.js';\nimport {\n applyPlacePatch,\n applySectionOp,\n asRailPlace,\n asRailView,\n cleanSections,\n projectColorsOf,\n type PlacePatch,\n type RailLayout,\n type RailPlace,\n type RailSection,\n type RailViewId,\n type SectionOp,\n} from './rail-layout.js';\n\n/**\n * The rail's pins, sections and colors in state.db (rail-layout.ts has the rules):\n * the sections in `meta` (one list, yours), each session's place in\n * `rail_place` (one row per session, gone with it: purgeSessionRows).\n * And the view picked last, in `meta`: work web's address changes with every\n * start (its port), so the browser's own storage does not keep it.\n */\nconst SECTIONS_KEY = 'ui:rail-sections';\nconst VIEW_KEY = 'ui:rail-view';\n\nfunction readSections(d: Db): RailSection[] {\n const row = d.prepare('SELECT value FROM meta WHERE key = ?').get(SECTIONS_KEY) as { value: string } | undefined;\n return (row && cleanSections(json.parse(row.value))) || [];\n}\n\nexport function readRailLayout(): RailLayout {\n return withDb((d) => {\n const places: Record<string, RailPlace> = {};\n for (const r of d.prepare('SELECT session_id, data FROM rail_place').all() as Array<{ session_id: string; data: string }>) {\n const p = asRailPlace(json.parse(r.data));\n if (p) places[r.session_id] = p;\n }\n const projectColors = projectColorsOf(loadConfig()?.colors);\n const stored = d.prepare('SELECT value FROM meta WHERE key = ?').get(VIEW_KEY) as { value: string } | undefined;\n const view = stored ? asRailView(json.parse(stored.value)) : null;\n return {\n sections: readSections(d),\n places,\n ...(Object.keys(projectColors).length ? { projectColors } : {}),\n ...(view ? { view } : {}),\n };\n });\n}\n\n/** Remember the view picked last. */\nexport function saveRailView(view: RailViewId): RailLayout {\n tx((d) => d.prepare('INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)').run(VIEW_KEY, JSON.stringify(view)));\n return readRailLayout();\n}\n\n/** One change to the sections, against the list as it is now (rail-layout.ts SectionOp). */\nexport function changeRailSections(op: SectionOp): PlaceResult {\n const error = tx((d) => {\n const r = applySectionOp(readSections(d), op);\n if (!r.ok) return r.error;\n writeSections(d, r.sections);\n return null;\n });\n return error ? { ok: false, error } : { ok: true, layout: readRailLayout() };\n}\n\n/** Replace the section list. Sessions in a removed section go back to the rest. */\nexport function saveRailSections(sections: RailSection[]): RailLayout {\n tx((d) => writeSections(d, sections));\n return readRailLayout();\n}\n\nfunction writeSections(d: Db, sections: RailSection[]): void {\n d.prepare('INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)').run(SECTIONS_KEY, JSON.stringify(sections));\n const known = new Set(sections.map((s) => s.id));\n for (const r of d.prepare('SELECT session_id, data FROM rail_place').all() as Array<{ session_id: string; data: string }>) {\n const p = asRailPlace(json.parse(r.data));\n if (!p?.section || known.has(p.section)) continue;\n writePlace(d, r.session_id, applyPlacePatch(p, { section: null }));\n }\n}\n\nexport type PlaceResult = { ok: true; layout: RailLayout } | { ok: false; error: string };\n\n/** Pin / unpin a session, move it into or out of a section (which must exist), or color it. */\nexport function placeSession(sessionId: string, patch: PlacePatch): PlaceResult {\n const error = tx((d) => {\n if (patch.section && !readSections(d).some((s) => s.id === patch.section)) return 'no such section';\n const row = d.prepare('SELECT data FROM rail_place WHERE session_id = ?').get(sessionId) as { data: string } | undefined;\n const prev = row ? (asRailPlace(json.parse(row.data)) ?? undefined) : undefined;\n writePlace(d, sessionId, applyPlacePatch(prev, patch));\n return null;\n });\n return error ? { ok: false, error } : { ok: true, layout: readRailLayout() };\n}\n\nfunction writePlace(d: Db, sessionId: string, place: RailPlace | null): void {\n if (place) d.prepare('INSERT OR REPLACE INTO rail_place (session_id, data) VALUES (?, ?)').run(sessionId, JSON.stringify(place));\n else d.prepare('DELETE FROM rail_place WHERE session_id = ?').run(sessionId);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,IAAM,eAAe;AACrB,IAAM,WAAW;AAEjB,SAAS,aAAa,GAAsB;AAC1C,QAAM,MAAM,EAAE,QAAQ,sCAAsC,EAAE,IAAI,YAAY;AAC9E,SAAQ,OAAO,cAAc,KAAK,MAAM,IAAI,KAAK,CAAC,KAAM,CAAC;AAC3D;AAEO,SAAS,iBAA6B;AAC3C,SAAO,OAAO,CAAC,MAAM;AACnB,UAAM,SAAoC,CAAC;AAC3C,eAAW,KAAK,EAAE,QAAQ,yCAAyC,EAAE,IAAI,GAAkD;AACzH,YAAM,IAAI,YAAY,KAAK,MAAM,EAAE,IAAI,CAAC;AACxC,UAAI,EAAG,QAAO,EAAE,UAAU,IAAI;AAAA,IAChC;AACA,UAAM,gBAAgB,gBAAgB,WAAW,GAAG,MAAM;AAC1D,UAAM,SAAS,EAAE,QAAQ,sCAAsC,EAAE,IAAI,QAAQ;AAC7E,UAAM,OAAO,SAAS,WAAW,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,WAAW,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,OAAO,EAAG,QAAO;AAClF,UAAM,MAAM,EAAE,QAAQ,kDAAkD,EAAE,IAAI,SAAS;AACvF,UAAM,OAAO,MAAO,YAAY,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,SAAa;AACtE,eAAW,GAAG,WAAW,gBAAgB,MAAM,KAAK,CAAC;AACrD,WAAO;AAAA,EACT,CAAC;AACD,SAAO,QAAQ,EAAE,IAAI,OAAO,MAAM,IAAI,EAAE,IAAI,MAAM,QAAQ,eAAe,EAAE;AAC7E;AAEA,SAAS,WAAW,GAAO,WAAmB,OAA+B;AAC3E,MAAI,MAAO,GAAE,QAAQ,oEAAoE,EAAE,IAAI,WAAW,KAAK,UAAU,KAAK,CAAC;AAAA,MAC1H,GAAE,QAAQ,6CAA6C,EAAE,IAAI,SAAS;AAC7E;","names":[]}
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/pty/stream-status.ts
4
+ var PROGRAM_STATES = ["idle", "working", "blocked", "done", "error"];
5
+ var PROGRAM_KINDS = ["permission", "question", "auth"];
6
+ var PROGRESS_REMOVE = 0;
7
+ var PROGRESS_SET = 1;
8
+ var PROGRESS_ERROR = 2;
9
+ var PROGRESS_INDETERMINATE = 3;
10
+ var PROGRESS_PAUSED = 4;
11
+ var MAX_RECORDS = 64;
12
+ var MAX_PAYLOAD = 4087;
13
+ var MAX_KEY = 16;
14
+ var MAX_APP = 32;
15
+ var MAX_ID = 128;
16
+ var TEXT_LIMITS = { title: { encoded: 256, decoded: 192 }, msg: { encoded: 2732, decoded: 2048 } };
17
+ var VALUE_REX = /^[A-Za-z0-9_.,+/=-]*$/;
18
+ var APP_REX = /^[A-Za-z0-9_.+-]{1,32}$/;
19
+ var ID_REX = /^[A-Za-z0-9_.+-]{1,32}(?:\/[A-Za-z0-9_.+-]{1,32}){0,7}$/;
20
+ var PROGRESS_REX = /^0*([0-9]{1,3})$/;
21
+ var BASE64_REX = /^[A-Za-z0-9+/]*={0,2}$/;
22
+ var CONTROL_REX = new RegExp("\\p{Control}", "u");
23
+ var KNOWN_KEYS = /* @__PURE__ */ new Set(["state", "id", "kind", "progress", "app", "title", "msg"]);
24
+ function toInt(s) {
25
+ return /^[0-9]*$/.test(s) ? Number(s || "0") : -1;
26
+ }
27
+ function parseProgress(data, lastPercent) {
28
+ if (!data.startsWith("4;")) return void 0;
29
+ const parts = data.split(";");
30
+ if (parts.length > 3) return void 0;
31
+ const state = toInt(parts[1]);
32
+ const pr = toInt(parts[2] ?? "");
33
+ const clamp = (n) => Math.min(Math.max(n, 0), 100);
34
+ switch (state) {
35
+ case PROGRESS_REMOVE:
36
+ return { state, percent: 0 };
37
+ case PROGRESS_SET:
38
+ return pr < 0 ? void 0 : { state, percent: clamp(pr) };
39
+ case PROGRESS_ERROR:
40
+ case PROGRESS_PAUSED:
41
+ return pr < 0 ? void 0 : { state, percent: clamp(pr || lastPercent) };
42
+ case PROGRESS_INDETERMINATE:
43
+ return { state, percent: clamp(lastPercent) };
44
+ default:
45
+ return void 0;
46
+ }
47
+ }
48
+ var utf8Length = (s) => Buffer.byteLength(s, "utf8");
49
+ var trim = (s) => s.replace(/^[ \t\n\v\f\r]+/, "").replace(/[ \t\n\v\f\r]+$/, "");
50
+ function decodeText(value, max) {
51
+ if (value.length % 4 === 1 || value.endsWith("=") && value.length % 4 !== 0 || !BASE64_REX.test(value)) return void 0;
52
+ const bytes = Buffer.from(value, "base64");
53
+ if (bytes.length > max) return void 0;
54
+ if (bytes.toString("base64").replace(/=+$/, "") !== value.replace(/=+$/, "")) return void 0;
55
+ let text;
56
+ try {
57
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
58
+ } catch {
59
+ return void 0;
60
+ }
61
+ return CONTROL_REX.test(text) ? void 0 : text;
62
+ }
63
+ function parseProgramStatus(data) {
64
+ if (data.length > MAX_PAYLOAD || utf8Length(data) > MAX_PAYLOAD) return void 0;
65
+ const v = {};
66
+ for (const pair of data.split(":")) {
67
+ const eq = pair.indexOf("=");
68
+ if (eq === -1) continue;
69
+ const key = trim(pair.slice(0, eq));
70
+ if (!KNOWN_KEYS.has(key)) {
71
+ if (utf8Length(key) > MAX_KEY) return void 0;
72
+ continue;
73
+ }
74
+ const value = trim(pair.slice(eq + 1));
75
+ const readable = VALUE_REX.test(value);
76
+ if (key === "state" || key === "kind" || key === "progress") {
77
+ if (readable) v[key] = value;
78
+ } else if (key === "id") {
79
+ if (value.length > MAX_ID || !ID_REX.test(value)) return void 0;
80
+ v.id = value;
81
+ } else if (key === "app") {
82
+ if ((readable ? value.length : utf8Length(value)) > MAX_APP) return void 0;
83
+ if (readable) v.app = value;
84
+ } else {
85
+ const limits = TEXT_LIMITS[key];
86
+ if ((readable ? value.length : utf8Length(value)) > limits.encoded) return void 0;
87
+ if (!readable) continue;
88
+ const text = decodeText(value, limits.decoded);
89
+ if (text === void 0) return void 0;
90
+ if (key === "msg") v.msg = text;
91
+ }
92
+ }
93
+ const id = v.id ?? "";
94
+ if (v.state === "clear") return { state: "clear", id };
95
+ const state = PROGRAM_STATES.find((s) => s === v.state);
96
+ if (!state) return void 0;
97
+ const record = { id, state };
98
+ const kind = PROGRAM_KINDS.find((k) => k === v.kind);
99
+ if (state === "blocked" && kind) record.kind = kind;
100
+ if ((state === "working" || state === "blocked") && v.progress !== void 0) {
101
+ const digits = PROGRESS_REX.exec(v.progress)?.[1];
102
+ if (digits !== void 0 && Number(digits) <= 100) record.progress = Number(digits);
103
+ }
104
+ if (v.app !== void 0 && APP_REX.test(v.app)) record.app = v.app;
105
+ if (v.msg !== void 0) record.message = v.msg;
106
+ return record;
107
+ }
108
+ function summarize(records) {
109
+ const latest = (state) => [...records].reverse().find((r) => r.state === state);
110
+ return latest("blocked") ?? latest("working") ?? records.find((r) => r.id === "") ?? records.at(-1);
111
+ }
112
+ var StreamStatus = class {
113
+ constructor(now = Date.now) {
114
+ this.now = now;
115
+ }
116
+ /** Insertion order is update order: a report deletes its id first, so the first entry is the least recently updated. */
117
+ records = /* @__PURE__ */ new Map();
118
+ bar = null;
119
+ lastPercent = 0;
120
+ programSeen = false;
121
+ /** The data of an OSC 9 sequence (only `4;…` counts). */
122
+ osc9(data) {
123
+ if (this.programSeen) return;
124
+ const report = parseProgress(data, this.lastPercent);
125
+ if (!report) return;
126
+ this.lastPercent = report.percent;
127
+ if (report.state === PROGRESS_REMOVE) this.bar = null;
128
+ else this.bar = { ...report, sinceMs: this.bar?.state === report.state ? this.bar.sinceMs : this.now() };
129
+ }
130
+ /** The data of an OSC 7501 sequence. */
131
+ osc7501(data) {
132
+ const report = parseProgramStatus(data);
133
+ if (!report) return;
134
+ this.programSeen = true;
135
+ this.bar = null;
136
+ if (report.state === "clear") {
137
+ for (const id of [...this.records.keys()]) {
138
+ if (report.id === "" || id === report.id || id.startsWith(`${report.id}/`)) this.records.delete(id);
139
+ }
140
+ return;
141
+ }
142
+ const before = this.records.get(report.id);
143
+ const sinceMs = before && before.state === report.state && before.kind === report.kind ? before.sinceMs : this.now();
144
+ this.records.delete(report.id);
145
+ const [oldest] = this.records.keys();
146
+ if (oldest !== void 0 && this.records.size >= MAX_RECORDS) this.records.delete(oldest);
147
+ this.records.set(report.id, { ...report, sinceMs });
148
+ }
149
+ /** RIS. */
150
+ reset() {
151
+ this.records.clear();
152
+ this.bar = null;
153
+ this.lastPercent = 0;
154
+ this.programSeen = false;
155
+ }
156
+ /** What it says now; null when it says nothing. */
157
+ signal() {
158
+ const iso = (ms) => new Date(ms).toISOString();
159
+ const top = summarize([...this.records.values()]);
160
+ if (top) {
161
+ const { sinceMs, ...record } = top;
162
+ return { program: { ...record, since: iso(sinceMs) } };
163
+ }
164
+ if (this.bar) {
165
+ const { sinceMs, ...bar } = this.bar;
166
+ return { progress: { ...bar, since: iso(sinceMs) } };
167
+ }
168
+ return null;
169
+ }
170
+ };
171
+ function streamSignalFrom(raw) {
172
+ if (!raw || typeof raw !== "object") return null;
173
+ const { program: p, progress: b } = raw;
174
+ const out = {};
175
+ const text = (v) => typeof v === "string";
176
+ const pct = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 && v <= 100;
177
+ if (p && typeof p === "object") {
178
+ const r = p;
179
+ const state = PROGRAM_STATES.find((s) => s === r.state);
180
+ if (state && text(r.id) && text(r.since)) {
181
+ const kind = PROGRAM_KINDS.find((k) => k === r.kind);
182
+ out.program = {
183
+ id: r.id,
184
+ state,
185
+ since: r.since,
186
+ ...kind ? { kind } : {},
187
+ ...pct(r.progress) ? { progress: r.progress } : {},
188
+ ...text(r.app) ? { app: r.app } : {},
189
+ ...text(r.message) ? { message: r.message } : {}
190
+ };
191
+ }
192
+ }
193
+ if (b && typeof b === "object") {
194
+ const r = b;
195
+ const state = [0, 1, 2, 3, 4].find((s) => s === r.state);
196
+ if (state !== void 0 && pct(r.percent) && text(r.since)) out.progress = { state, percent: r.percent, since: r.since };
197
+ }
198
+ return out.program || out.progress ? out : null;
199
+ }
200
+
201
+ export {
202
+ PROGRESS_SET,
203
+ PROGRESS_INDETERMINATE,
204
+ StreamStatus,
205
+ streamSignalFrom
206
+ };
207
+ //# sourceMappingURL=chunk-BCYBF7KJ.js.map