@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.
- package/dist/{account-J55P3HXH.js → account-O62WFR7C.js} +23 -20
- package/dist/{account-J55P3HXH.js.map → account-O62WFR7C.js.map} +1 -1
- package/dist/{add-repo-ALVEGU25.js → add-repo-FTAMMPVM.js} +13 -13
- package/dist/{answer-CI2SPQQL.js → answer-LKNMN2ZM.js} +11 -11
- package/dist/{attach-7LBIFBLX.js → attach-A3KA4YTK.js} +20 -17
- package/dist/{attach-7LBIFBLX.js.map → attach-A3KA4YTK.js.map} +1 -1
- package/dist/bin.js +4 -4
- package/dist/{block-TVIYWRJ5.js → block-3ZUFH2RO.js} +12 -12
- package/dist/{broadcast-GZNMZFOY.js → broadcast-I23BZI3R.js} +8 -8
- package/dist/{catchup-ZURJI6BF.js → catchup-G4EOJIZP.js} +13 -13
- package/dist/{child-K6YYF6MQ.js → child-MVNEFA2I.js} +11 -11
- package/dist/{chunk-ZTWZS5RK.js → chunk-24FQ5XXN.js} +3 -3
- package/dist/{chunk-D2SVBU7R.js → chunk-2FNYJEOH.js} +2 -2
- package/dist/{chunk-EEHPZMS3.js → chunk-2JLG65GB.js} +2 -2
- package/dist/{chunk-DC73NF67.js → chunk-2MJQTFTI.js} +3 -3
- package/dist/chunk-44QJVFOF.js +64 -0
- package/dist/chunk-44QJVFOF.js.map +1 -0
- package/dist/{chunk-7Q5PBXF6.js → chunk-4FN45EAF.js} +51 -10
- package/dist/chunk-4FN45EAF.js.map +1 -0
- package/dist/{chunk-G4T2HGLJ.js → chunk-4HQEYZIM.js} +4 -4
- package/dist/{chunk-WRDULHAN.js → chunk-5QENUGSC.js} +117 -16
- package/dist/chunk-5QENUGSC.js.map +1 -0
- package/dist/{chunk-CA56ETYX.js → chunk-5SXTMOO6.js} +5 -5
- package/dist/chunk-6KMG4WNW.js +87 -0
- package/dist/chunk-6KMG4WNW.js.map +1 -0
- package/dist/{chunk-OCUUM755.js → chunk-6PZ7RCXK.js} +2 -2
- package/dist/{chunk-RTCTD5PJ.js → chunk-773UJC5C.js} +4 -4
- package/dist/{chunk-W4GDPHIF.js → chunk-7ZATXG5F.js} +2 -2
- package/dist/{chunk-PTAG6WIE.js → chunk-APHVSSLI.js} +17 -3
- package/dist/chunk-APHVSSLI.js.map +1 -0
- package/dist/chunk-BCYBF7KJ.js +207 -0
- package/dist/chunk-BCYBF7KJ.js.map +1 -0
- package/dist/{chunk-6Y3VLCKA.js → chunk-BI7HIO2I.js} +3 -3
- package/dist/{chunk-FGBLFF4O.js → chunk-BMPTUIP4.js} +2 -2
- package/dist/{chunk-VQDE3DRG.js → chunk-DHZ5DF6Y.js} +6 -2
- package/dist/{chunk-VQDE3DRG.js.map → chunk-DHZ5DF6Y.js.map} +1 -1
- package/dist/{chunk-BQS73CWR.js → chunk-ET5K6S5H.js} +2 -2
- package/dist/{chunk-B2WV5RAL.js → chunk-ETAPX4JN.js} +5 -5
- package/dist/{chunk-3ZPVKUYD.js → chunk-ETWP7MDS.js} +7 -1
- package/dist/chunk-ETWP7MDS.js.map +1 -0
- package/dist/{chunk-RLPC3YKZ.js → chunk-FHC6KHIH.js} +2 -2
- package/dist/{chunk-DF4GOVDE.js → chunk-GF7RAQFD.js} +2 -2
- package/dist/{chunk-ZO7TF5OL.js → chunk-GHY7GZWN.js} +4 -4
- package/dist/{chunk-5FIUVBUC.js → chunk-GN7EAXHU.js} +7 -7
- package/dist/{chunk-EYJ42LDG.js → chunk-GTFMUWK6.js} +4 -4
- package/dist/{chunk-4QMWNAEJ.js → chunk-HCYES6U7.js} +2 -2
- package/dist/{chunk-TOMDOA4P.js → chunk-HNZ736XN.js} +2 -2
- package/dist/{chunk-ATQB6PTV.js → chunk-HPUD5IGB.js} +3 -3
- package/dist/{chunk-FV7BSQPQ.js → chunk-HQDQRC4F.js} +2 -2
- package/dist/{chunk-AITL3JYB.js → chunk-HUWWMTNG.js} +399 -69
- package/dist/chunk-HUWWMTNG.js.map +1 -0
- package/dist/{chunk-SDYY5MHW.js → chunk-INXHVNMZ.js} +7 -7
- package/dist/{chunk-QNOJOZYK.js → chunk-IRDWXDID.js} +2 -2
- package/dist/{chunk-EA4C6TVY.js → chunk-IVS2MAHD.js} +3 -3
- package/dist/{chunk-QOLHDDM2.js → chunk-IXC6EXVJ.js} +4 -4
- package/dist/{chunk-IU6LA6EB.js → chunk-IXZOZZGD.js} +4 -4
- package/dist/{chunk-SZAD5U3J.js → chunk-LB2GAU7E.js} +2 -2
- package/dist/{chunk-VHENFC2S.js → chunk-M2X6OHHR.js} +14 -1
- package/dist/chunk-M2X6OHHR.js.map +1 -0
- package/dist/{chunk-23QLXVH6.js → chunk-MQXMYVZV.js} +12 -14
- package/dist/{chunk-23QLXVH6.js.map → chunk-MQXMYVZV.js.map} +1 -1
- package/dist/{chunk-GNERWNZY.js → chunk-MVBBESXK.js} +4 -4
- package/dist/{chunk-AIYZJ7XD.js → chunk-N7T6NPE2.js} +5 -5
- package/dist/{chunk-GQ5WECPJ.js → chunk-NREZVTBP.js} +3 -3
- package/dist/chunk-NRX5V443.js +9 -0
- package/dist/{chunk-USENBMUV.js → chunk-NS7WH53I.js} +1 -1
- package/dist/chunk-NS7WH53I.js.map +1 -0
- package/dist/{chunk-KQMHGEI2.js → chunk-NWKVTUTN.js} +53 -15
- package/dist/chunk-NWKVTUTN.js.map +1 -0
- package/dist/chunk-NXS53NHR.js +79 -0
- package/dist/chunk-NXS53NHR.js.map +1 -0
- package/dist/{chunk-NYGKSOQ4.js → chunk-OPV6BE3W.js} +6 -6
- package/dist/{chunk-UAF2YFLZ.js → chunk-ROEEXEN7.js} +6 -6
- package/dist/{chunk-F4UIKOU6.js → chunk-TL7VLRRF.js} +4 -4
- package/dist/{chunk-NOQA7MJ4.js → chunk-U2A2DHWP.js} +3 -3
- package/dist/{chunk-Q2B3NUSM.js → chunk-U4XSBYQW.js} +4 -4
- package/dist/{chunk-Z4FWXDJG.js → chunk-VH5FRKJM.js} +3 -3
- package/dist/{chunk-DCENKA6E.js → chunk-W5YYTITQ.js} +2 -2
- package/dist/{chunk-5P27YL64.js → chunk-WOY35FXP.js} +8 -8
- package/dist/{chunk-HI674QZF.js → chunk-XIN6XUFL.js} +2 -2
- package/dist/{chunk-KU3TQAA7.js → chunk-XTAYJDL2.js} +8 -10
- package/dist/{chunk-KU3TQAA7.js.map → chunk-XTAYJDL2.js.map} +1 -1
- package/dist/{chunk-EVTMZ5IH.js → chunk-XWKN2HJD.js} +60 -60
- package/dist/{chunk-CMRTNTMU.js → chunk-YKTJL4SW.js} +6 -6
- package/dist/{chunk-RNPNBGVX.js → chunk-ZG6HB4BO.js} +3 -5
- package/dist/{chunk-RNPNBGVX.js.map → chunk-ZG6HB4BO.js.map} +1 -1
- package/dist/{chunk-PUJSLL6R.js → chunk-ZLPK2LQ3.js} +5 -5
- package/dist/{chunk-LV5JRLBM.js → chunk-ZMJR4Z6O.js} +17 -7
- package/dist/chunk-ZMJR4Z6O.js.map +1 -0
- package/dist/{chunk-YO3BNAAK.js → chunk-ZNRPBP5O.js} +27 -5
- package/dist/chunk-ZNRPBP5O.js.map +1 -0
- package/dist/{chunk-Z4P23XG3.js → chunk-ZX4ONO5Y.js} +5 -5
- package/dist/{cleanup-G4WQACD6.js → cleanup-ANVUCOBK.js} +32 -31
- package/dist/{cleanup-G4WQACD6.js.map → cleanup-ANVUCOBK.js.map} +1 -1
- package/dist/{cli-OPORB5PF.js → cli-CAF6VCVO.js} +4 -4
- package/dist/{color-C223W3Z6.js → color-7CQNI6Y4.js} +11 -11
- package/dist/{config-KQYXQCQA.js → config-EXQY26W4.js} +10 -10
- package/dist/{coordinate-4E5GIMC6.js → coordinate-LRY7LXS6.js} +11 -11
- package/dist/{diff-HEOLTXO2.js → diff-JRK3AUD5.js} +12 -13
- package/dist/{diff-HEOLTXO2.js.map → diff-JRK3AUD5.js.map} +1 -1
- package/dist/{digest-GYF4YLUH.js → digest-2AFW3WBL.js} +11 -11
- package/dist/{fork-B35ONP3Z.js → fork-DSNMPWUE.js} +29 -26
- package/dist/{fork-B35ONP3Z.js.map → fork-DSNMPWUE.js.map} +1 -1
- package/dist/{history-25DNQKKC.js → history-RFIDCGQY.js} +8 -8
- package/dist/{hook-B4JO2X57.js → hook-XBALB337.js} +20 -20
- package/dist/{hydrate-IJEKNZIP.js → hydrate-DAEY4PB6.js} +8 -8
- package/dist/{init-UJVOUDJI.js → init-4BK3T34W.js} +12 -12
- package/dist/{install-skills-FV2L5QHE.js → install-skills-TL5D7HZU.js} +8 -9
- package/dist/install-skills-bin.js +7 -8
- package/dist/install-skills-bin.js.map +1 -1
- package/dist/{keep-PKXGFZO2.js → keep-57TUKADV.js} +10 -10
- package/dist/{list-VYQ3QE2H.js → list-DRQRIT6U.js} +8 -8
- package/dist/{move-IAZY23ZX.js → move-UEHJ375P.js} +16 -16
- package/dist/{note-6HQUKUYY.js → note-FHPDVBRI.js} +10 -10
- package/dist/{overlaps-CGP3RJOW.js → overlaps-GKAKEUB6.js} +13 -13
- package/dist/{pin-PAWGQ4Q2.js → pin-CFTQDPPC.js} +11 -11
- package/dist/{pr-OJOGE3A3.js → pr-ZP4COZEZ.js} +22 -21
- package/dist/{pr-OJOGE3A3.js.map → pr-ZP4COZEZ.js.map} +1 -1
- package/dist/{prune-42MS36OR.js → prune-IQB2T45B.js} +29 -29
- package/dist/pty-host-BPFGJFBC.js +2658 -0
- package/dist/pty-host-BPFGJFBC.js.map +1 -0
- package/dist/{read-ATNCW4KH.js → read-DHJ6VY44.js} +10 -10
- package/dist/{recent-MTBFQT36.js → recent-OZW2ZNJ4.js} +16 -15
- package/dist/{recent-MTBFQT36.js.map → recent-OZW2ZNJ4.js.map} +1 -1
- package/dist/{remove-GLDJOKUI.js → remove-MW25RLNV.js} +30 -30
- package/dist/{report-AK7Z2Y4S.js → report-II75EKM6.js} +11 -11
- package/dist/{restart-DEPDGEZB.js → restart-4BGVRBX6.js} +11 -11
- package/dist/{resume-C2QPKKFN.js → resume-4J53KDCO.js} +16 -15
- package/dist/{resume-C2QPKKFN.js.map → resume-4J53KDCO.js.map} +1 -1
- package/dist/{review-RYAGH3PY.js → review-WKB3K6LI.js} +10 -10
- package/dist/{review-now-K4UWD7A5.js → review-now-AT2SPPRO.js} +2 -2
- package/dist/{run-WNP2SMNW.js → run-YS2D7WAQ.js} +8 -8
- package/dist/{screen-P746M4F2.js → screen-VVRNQXVW.js} +11 -11
- package/dist/{search-XQ2WMK5X.js → search-MKYCKZF4.js} +8 -8
- package/dist/{section-Q7TPOV7U.js → section-Y6RDD3MN.js} +11 -11
- package/dist/{send-EGG23J2B.js → send-AZM2XKN2.js} +12 -12
- package/dist/{sessions-2NNCWIND.js → sessions-OER6VNQJ.js} +26 -24
- package/dist/{sessions-2NNCWIND.js.map → sessions-OER6VNQJ.js.map} +1 -1
- package/dist/{show-KSMC7AJL.js → show-33VV3XCF.js} +10 -10
- package/dist/{snooze-4LVYUQEX.js → snooze-OFYZVVYS.js} +10 -10
- package/dist/{start-YKLLXW3L.js → start-OEQ5VW7Y.js} +11 -11
- package/dist/{state-GM22X3RN.js → state-HK67C4UA.js} +3 -3
- package/dist/state-HK67C4UA.js.map +1 -0
- package/dist/{status-4HGP4ZEF.js → status-HPYMNO2T.js} +11 -11
- package/dist/{statusline-QJ6CJGHB.js → statusline-Z5HLKDIA.js} +5 -5
- package/dist/{statusline-hook-Q645N4XF.js → statusline-hook-VPPS3PFO.js} +3 -3
- package/dist/{stop-YBQL6NFF.js → stop-QNICDWAU.js} +11 -11
- package/dist/{sync-DUXN2MFJ.js → sync-RH3M47QK.js} +29 -29
- package/dist/{time-Q42HPZZ3.js → time-PM72GK5W.js} +11 -11
- package/dist/{time-actions-IXZRVKKQ.js → time-actions-O3MCB7FU.js} +3 -3
- package/dist/{timesheet-YJ6O3GUU.js → timesheet-HJXQ4KHL.js} +15 -15
- package/dist/{todo-ZBFRL2A5.js → todo-UVKGOG7D.js} +2 -2
- package/dist/{tree-H2UYE6LH.js → tree-RGT736E3.js} +30 -28
- package/dist/{tree-H2UYE6LH.js.map → tree-RGT736E3.js.map} +1 -1
- package/dist/{update-RGNKMRUL.js → update-CMYVBWV3.js} +15 -15
- package/dist/{usage-YZRZKJ3H.js → usage-VEKD3JPL.js} +10 -10
- package/dist/{usage-ask-BYPNLA2B.js → usage-ask-V2SIRW4F.js} +3 -3
- package/dist/{version-4IOMOIDP.js → version-RJ4PCHPB.js} +5 -5
- package/dist/{wait-YOHPFWVJ.js → wait-RQZU3KDY.js} +11 -11
- package/dist/wd-bin.js +3 -3
- package/dist/web/assets/{PtyView-CYAhB_pW.js → PtyView-qP6blm2-.js} +26 -28
- package/dist/web/assets/PtyView-qP6blm2-.js.map +1 -0
- package/dist/web/assets/index-DuFRboh6.js +129 -0
- package/dist/web/assets/index-DuFRboh6.js.map +1 -0
- package/dist/web/assets/index-yBTfBzDm.css +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-Q672AIMZ.js → web-GOCU26ZD.js} +617 -526
- package/dist/web-GOCU26ZD.js.map +1 -0
- package/npm-shrinkwrap.json +3 -4
- package/package.json +2 -2
- package/dist/chunk-3ZPVKUYD.js.map +0 -1
- package/dist/chunk-7Q5PBXF6.js.map +0 -1
- package/dist/chunk-7ZOY2QQN.js +0 -43
- package/dist/chunk-7ZOY2QQN.js.map +0 -1
- package/dist/chunk-AITL3JYB.js.map +0 -1
- package/dist/chunk-EXZ4A6VJ.js +0 -9
- package/dist/chunk-ICEP4WAK.js +0 -256
- package/dist/chunk-ICEP4WAK.js.map +0 -1
- package/dist/chunk-KQMHGEI2.js.map +0 -1
- package/dist/chunk-LNHSBM4L.js +0 -26
- package/dist/chunk-LNHSBM4L.js.map +0 -1
- package/dist/chunk-LV5JRLBM.js.map +0 -1
- package/dist/chunk-PTAG6WIE.js.map +0 -1
- package/dist/chunk-USENBMUV.js.map +0 -1
- package/dist/chunk-VHENFC2S.js.map +0 -1
- package/dist/chunk-WRDULHAN.js.map +0 -1
- package/dist/chunk-YO3BNAAK.js.map +0 -1
- package/dist/pty-host-EAWW62U4.js +0 -1235
- package/dist/pty-host-EAWW62U4.js.map +0 -1
- package/dist/state-GM22X3RN.js.map +0 -1
- package/dist/web/assets/PtyView-CYAhB_pW.js.map +0 -1
- package/dist/web/assets/index-Ca7KbCED.css +0 -1
- package/dist/web/assets/index-iBmmgBZv.js +0 -129
- package/dist/web/assets/index-iBmmgBZv.js.map +0 -1
- package/dist/web-Q672AIMZ.js.map +0 -1
- /package/dist/{add-repo-ALVEGU25.js.map → add-repo-FTAMMPVM.js.map} +0 -0
- /package/dist/{answer-CI2SPQQL.js.map → answer-LKNMN2ZM.js.map} +0 -0
- /package/dist/{block-TVIYWRJ5.js.map → block-3ZUFH2RO.js.map} +0 -0
- /package/dist/{broadcast-GZNMZFOY.js.map → broadcast-I23BZI3R.js.map} +0 -0
- /package/dist/{catchup-ZURJI6BF.js.map → catchup-G4EOJIZP.js.map} +0 -0
- /package/dist/{child-K6YYF6MQ.js.map → child-MVNEFA2I.js.map} +0 -0
- /package/dist/{chunk-ZTWZS5RK.js.map → chunk-24FQ5XXN.js.map} +0 -0
- /package/dist/{chunk-D2SVBU7R.js.map → chunk-2FNYJEOH.js.map} +0 -0
- /package/dist/{chunk-EEHPZMS3.js.map → chunk-2JLG65GB.js.map} +0 -0
- /package/dist/{chunk-DC73NF67.js.map → chunk-2MJQTFTI.js.map} +0 -0
- /package/dist/{chunk-G4T2HGLJ.js.map → chunk-4HQEYZIM.js.map} +0 -0
- /package/dist/{chunk-CA56ETYX.js.map → chunk-5SXTMOO6.js.map} +0 -0
- /package/dist/{chunk-OCUUM755.js.map → chunk-6PZ7RCXK.js.map} +0 -0
- /package/dist/{chunk-RTCTD5PJ.js.map → chunk-773UJC5C.js.map} +0 -0
- /package/dist/{chunk-W4GDPHIF.js.map → chunk-7ZATXG5F.js.map} +0 -0
- /package/dist/{chunk-6Y3VLCKA.js.map → chunk-BI7HIO2I.js.map} +0 -0
- /package/dist/{chunk-FGBLFF4O.js.map → chunk-BMPTUIP4.js.map} +0 -0
- /package/dist/{chunk-BQS73CWR.js.map → chunk-ET5K6S5H.js.map} +0 -0
- /package/dist/{chunk-B2WV5RAL.js.map → chunk-ETAPX4JN.js.map} +0 -0
- /package/dist/{chunk-RLPC3YKZ.js.map → chunk-FHC6KHIH.js.map} +0 -0
- /package/dist/{chunk-DF4GOVDE.js.map → chunk-GF7RAQFD.js.map} +0 -0
- /package/dist/{chunk-ZO7TF5OL.js.map → chunk-GHY7GZWN.js.map} +0 -0
- /package/dist/{chunk-5FIUVBUC.js.map → chunk-GN7EAXHU.js.map} +0 -0
- /package/dist/{chunk-EYJ42LDG.js.map → chunk-GTFMUWK6.js.map} +0 -0
- /package/dist/{chunk-4QMWNAEJ.js.map → chunk-HCYES6U7.js.map} +0 -0
- /package/dist/{chunk-TOMDOA4P.js.map → chunk-HNZ736XN.js.map} +0 -0
- /package/dist/{chunk-ATQB6PTV.js.map → chunk-HPUD5IGB.js.map} +0 -0
- /package/dist/{chunk-FV7BSQPQ.js.map → chunk-HQDQRC4F.js.map} +0 -0
- /package/dist/{chunk-SDYY5MHW.js.map → chunk-INXHVNMZ.js.map} +0 -0
- /package/dist/{chunk-QNOJOZYK.js.map → chunk-IRDWXDID.js.map} +0 -0
- /package/dist/{chunk-EA4C6TVY.js.map → chunk-IVS2MAHD.js.map} +0 -0
- /package/dist/{chunk-QOLHDDM2.js.map → chunk-IXC6EXVJ.js.map} +0 -0
- /package/dist/{chunk-IU6LA6EB.js.map → chunk-IXZOZZGD.js.map} +0 -0
- /package/dist/{chunk-SZAD5U3J.js.map → chunk-LB2GAU7E.js.map} +0 -0
- /package/dist/{chunk-GNERWNZY.js.map → chunk-MVBBESXK.js.map} +0 -0
- /package/dist/{chunk-AIYZJ7XD.js.map → chunk-N7T6NPE2.js.map} +0 -0
- /package/dist/{chunk-GQ5WECPJ.js.map → chunk-NREZVTBP.js.map} +0 -0
- /package/dist/{chunk-EXZ4A6VJ.js.map → chunk-NRX5V443.js.map} +0 -0
- /package/dist/{chunk-NYGKSOQ4.js.map → chunk-OPV6BE3W.js.map} +0 -0
- /package/dist/{chunk-UAF2YFLZ.js.map → chunk-ROEEXEN7.js.map} +0 -0
- /package/dist/{chunk-F4UIKOU6.js.map → chunk-TL7VLRRF.js.map} +0 -0
- /package/dist/{chunk-NOQA7MJ4.js.map → chunk-U2A2DHWP.js.map} +0 -0
- /package/dist/{chunk-Q2B3NUSM.js.map → chunk-U4XSBYQW.js.map} +0 -0
- /package/dist/{chunk-Z4FWXDJG.js.map → chunk-VH5FRKJM.js.map} +0 -0
- /package/dist/{chunk-DCENKA6E.js.map → chunk-W5YYTITQ.js.map} +0 -0
- /package/dist/{chunk-5P27YL64.js.map → chunk-WOY35FXP.js.map} +0 -0
- /package/dist/{chunk-HI674QZF.js.map → chunk-XIN6XUFL.js.map} +0 -0
- /package/dist/{chunk-EVTMZ5IH.js.map → chunk-XWKN2HJD.js.map} +0 -0
- /package/dist/{chunk-CMRTNTMU.js.map → chunk-YKTJL4SW.js.map} +0 -0
- /package/dist/{chunk-PUJSLL6R.js.map → chunk-ZLPK2LQ3.js.map} +0 -0
- /package/dist/{chunk-Z4P23XG3.js.map → chunk-ZX4ONO5Y.js.map} +0 -0
- /package/dist/{cli-OPORB5PF.js.map → cli-CAF6VCVO.js.map} +0 -0
- /package/dist/{color-C223W3Z6.js.map → color-7CQNI6Y4.js.map} +0 -0
- /package/dist/{config-KQYXQCQA.js.map → config-EXQY26W4.js.map} +0 -0
- /package/dist/{coordinate-4E5GIMC6.js.map → coordinate-LRY7LXS6.js.map} +0 -0
- /package/dist/{digest-GYF4YLUH.js.map → digest-2AFW3WBL.js.map} +0 -0
- /package/dist/{history-25DNQKKC.js.map → history-RFIDCGQY.js.map} +0 -0
- /package/dist/{hook-B4JO2X57.js.map → hook-XBALB337.js.map} +0 -0
- /package/dist/{hydrate-IJEKNZIP.js.map → hydrate-DAEY4PB6.js.map} +0 -0
- /package/dist/{init-UJVOUDJI.js.map → init-4BK3T34W.js.map} +0 -0
- /package/dist/{install-skills-FV2L5QHE.js.map → install-skills-TL5D7HZU.js.map} +0 -0
- /package/dist/{keep-PKXGFZO2.js.map → keep-57TUKADV.js.map} +0 -0
- /package/dist/{list-VYQ3QE2H.js.map → list-DRQRIT6U.js.map} +0 -0
- /package/dist/{move-IAZY23ZX.js.map → move-UEHJ375P.js.map} +0 -0
- /package/dist/{note-6HQUKUYY.js.map → note-FHPDVBRI.js.map} +0 -0
- /package/dist/{overlaps-CGP3RJOW.js.map → overlaps-GKAKEUB6.js.map} +0 -0
- /package/dist/{pin-PAWGQ4Q2.js.map → pin-CFTQDPPC.js.map} +0 -0
- /package/dist/{prune-42MS36OR.js.map → prune-IQB2T45B.js.map} +0 -0
- /package/dist/{read-ATNCW4KH.js.map → read-DHJ6VY44.js.map} +0 -0
- /package/dist/{remove-GLDJOKUI.js.map → remove-MW25RLNV.js.map} +0 -0
- /package/dist/{report-AK7Z2Y4S.js.map → report-II75EKM6.js.map} +0 -0
- /package/dist/{restart-DEPDGEZB.js.map → restart-4BGVRBX6.js.map} +0 -0
- /package/dist/{review-RYAGH3PY.js.map → review-WKB3K6LI.js.map} +0 -0
- /package/dist/{review-now-K4UWD7A5.js.map → review-now-AT2SPPRO.js.map} +0 -0
- /package/dist/{run-WNP2SMNW.js.map → run-YS2D7WAQ.js.map} +0 -0
- /package/dist/{screen-P746M4F2.js.map → screen-VVRNQXVW.js.map} +0 -0
- /package/dist/{search-XQ2WMK5X.js.map → search-MKYCKZF4.js.map} +0 -0
- /package/dist/{section-Q7TPOV7U.js.map → section-Y6RDD3MN.js.map} +0 -0
- /package/dist/{send-EGG23J2B.js.map → send-AZM2XKN2.js.map} +0 -0
- /package/dist/{show-KSMC7AJL.js.map → show-33VV3XCF.js.map} +0 -0
- /package/dist/{snooze-4LVYUQEX.js.map → snooze-OFYZVVYS.js.map} +0 -0
- /package/dist/{start-YKLLXW3L.js.map → start-OEQ5VW7Y.js.map} +0 -0
- /package/dist/{status-4HGP4ZEF.js.map → status-HPYMNO2T.js.map} +0 -0
- /package/dist/{statusline-QJ6CJGHB.js.map → statusline-Z5HLKDIA.js.map} +0 -0
- /package/dist/{statusline-hook-Q645N4XF.js.map → statusline-hook-VPPS3PFO.js.map} +0 -0
- /package/dist/{stop-YBQL6NFF.js.map → stop-QNICDWAU.js.map} +0 -0
- /package/dist/{sync-DUXN2MFJ.js.map → sync-RH3M47QK.js.map} +0 -0
- /package/dist/{time-Q42HPZZ3.js.map → time-PM72GK5W.js.map} +0 -0
- /package/dist/{time-actions-IXZRVKKQ.js.map → time-actions-O3MCB7FU.js.map} +0 -0
- /package/dist/{timesheet-YJ6O3GUU.js.map → timesheet-HJXQ4KHL.js.map} +0 -0
- /package/dist/{todo-ZBFRL2A5.js.map → todo-UVKGOG7D.js.map} +0 -0
- /package/dist/{update-RGNKMRUL.js.map → update-CMYVBWV3.js.map} +0 -0
- /package/dist/{usage-YZRZKJ3H.js.map → usage-VEKD3JPL.js.map} +0 -0
- /package/dist/{usage-ask-BYPNLA2B.js.map → usage-ask-V2SIRW4F.js.map} +0 -0
- /package/dist/{version-4IOMOIDP.js.map → version-RJ4PCHPB.js.map} +0 -0
- /package/dist/{wait-YOHPFWVJ.js.map → wait-RQZU3KDY.js.map} +0 -0
|
@@ -1,1235 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
ensureAgentPath,
|
|
4
|
-
stopHost
|
|
5
|
-
} from "./chunk-YO3BNAAK.js";
|
|
6
|
-
import {
|
|
7
|
-
PtyHostBusyError,
|
|
8
|
-
PtyHostClient,
|
|
9
|
-
PtyHostVersionError,
|
|
10
|
-
ensureHost,
|
|
11
|
-
findHost
|
|
12
|
-
} from "./chunk-GQ5WECPJ.js";
|
|
13
|
-
import {
|
|
14
|
-
adoptLegacyRestoreList,
|
|
15
|
-
dbPtySessions
|
|
16
|
-
} from "./chunk-4QMWNAEJ.js";
|
|
17
|
-
import {
|
|
18
|
-
HOST_FEATURES,
|
|
19
|
-
PROTOCOL_VERSION,
|
|
20
|
-
hostInfoPath,
|
|
21
|
-
hostStartLockPath,
|
|
22
|
-
isPersistedPty,
|
|
23
|
-
keepEnv
|
|
24
|
-
} from "./chunk-USENBMUV.js";
|
|
25
|
-
import {
|
|
26
|
-
isAccountLoginId
|
|
27
|
-
} from "./chunk-SJBEIYLK.js";
|
|
28
|
-
import {
|
|
29
|
-
ASSISTANT_ID
|
|
30
|
-
} from "./chunk-TOMDOA4P.js";
|
|
31
|
-
import "./chunk-7E5XPDKX.js";
|
|
32
|
-
import "./chunk-FV7BSQPQ.js";
|
|
33
|
-
import {
|
|
34
|
-
batchArgProblem,
|
|
35
|
-
programFor
|
|
36
|
-
} from "./chunk-4CXUVBOD.js";
|
|
37
|
-
import {
|
|
38
|
-
loadHistory
|
|
39
|
-
} from "./chunk-AITL3JYB.js";
|
|
40
|
-
import "./chunk-NEJVK5CF.js";
|
|
41
|
-
import {
|
|
42
|
-
sessionIdFor
|
|
43
|
-
} from "./chunk-QGUBOOEN.js";
|
|
44
|
-
import {
|
|
45
|
-
agentById,
|
|
46
|
-
bestEffort,
|
|
47
|
-
buildAiLaunchArgs,
|
|
48
|
-
logSwallowed,
|
|
49
|
-
sessionToolFor,
|
|
50
|
-
swallow
|
|
51
|
-
} from "./chunk-KQMHGEI2.js";
|
|
52
|
-
import "./chunk-KGHWHAVF.js";
|
|
53
|
-
import "./chunk-FGBLFF4O.js";
|
|
54
|
-
import {
|
|
55
|
-
applyEnvDelta,
|
|
56
|
-
hasEnvDelta,
|
|
57
|
-
isEnvDelta
|
|
58
|
-
} from "./chunk-ED6YLB4S.js";
|
|
59
|
-
import {
|
|
60
|
-
VERSION
|
|
61
|
-
} from "./chunk-EXZ4A6VJ.js";
|
|
62
|
-
import "./chunk-Z6ACV5ZQ.js";
|
|
63
|
-
import "./chunk-JUGF3YE7.js";
|
|
64
|
-
import {
|
|
65
|
-
resolveWorkBinPath
|
|
66
|
-
} from "./chunk-HK6AZQ5Z.js";
|
|
67
|
-
import "./chunk-HI674QZF.js";
|
|
68
|
-
import {
|
|
69
|
-
loadConfig
|
|
70
|
-
} from "./chunk-3ZPVKUYD.js";
|
|
71
|
-
import "./chunk-W4GDPHIF.js";
|
|
72
|
-
import "./chunk-BR6OWWAA.js";
|
|
73
|
-
import {
|
|
74
|
-
killTree
|
|
75
|
-
} from "./chunk-VHENFC2S.js";
|
|
76
|
-
import {
|
|
77
|
-
shellEnv
|
|
78
|
-
} from "./chunk-QOSAWNOU.js";
|
|
79
|
-
import {
|
|
80
|
-
atomicWriteFile,
|
|
81
|
-
ensureFile,
|
|
82
|
-
withFileLock,
|
|
83
|
-
withFileLockSync
|
|
84
|
-
} from "./chunk-D2J3AD6L.js";
|
|
85
|
-
import {
|
|
86
|
-
report
|
|
87
|
-
} from "./chunk-5ZCCUM75.js";
|
|
88
|
-
import {
|
|
89
|
-
debug
|
|
90
|
-
} from "./chunk-IAKOKZYW.js";
|
|
91
|
-
import "./chunk-F2ECTTSY.js";
|
|
92
|
-
|
|
93
|
-
// src/commands/pty-host.ts
|
|
94
|
-
import chalk from "chalk";
|
|
95
|
-
|
|
96
|
-
// src/core/pty/pty-host.ts
|
|
97
|
-
import http from "http";
|
|
98
|
-
import crypto2 from "crypto";
|
|
99
|
-
import fs3 from "fs";
|
|
100
|
-
import { WebSocketServer } from "ws";
|
|
101
|
-
|
|
102
|
-
// src/core/pty/pty-registry.ts
|
|
103
|
-
import fs2 from "fs";
|
|
104
|
-
|
|
105
|
-
// src/core/pty/pty-session.ts
|
|
106
|
-
import pty from "node-pty";
|
|
107
|
-
import crossSpawn from "cross-spawn";
|
|
108
|
-
import xtermHeadless from "@xterm/headless";
|
|
109
|
-
import xtermSerialize from "@xterm/addon-serialize";
|
|
110
|
-
import childProcess from "child_process";
|
|
111
|
-
import { createRequire } from "module";
|
|
112
|
-
import os from "os";
|
|
113
|
-
import path2 from "path";
|
|
114
|
-
|
|
115
|
-
// src/core/pty/spawn-helper.ts
|
|
116
|
-
import fs from "fs";
|
|
117
|
-
import path from "path";
|
|
118
|
-
function makeSpawnHelperExecutable(ptyDir, platform = process.platform, arch = process.arch, f = fs) {
|
|
119
|
-
const out = { fixed: [], failed: [] };
|
|
120
|
-
if (platform === "win32") return out;
|
|
121
|
-
for (const file of [
|
|
122
|
-
path.join(ptyDir, "prebuilds", `${platform}-${arch}`, "spawn-helper"),
|
|
123
|
-
path.join(ptyDir, "build", "Release", "spawn-helper")
|
|
124
|
-
]) {
|
|
125
|
-
let mode;
|
|
126
|
-
try {
|
|
127
|
-
mode = f.statSync(file).mode;
|
|
128
|
-
} catch {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if ((mode & 73) === 73) continue;
|
|
132
|
-
try {
|
|
133
|
-
f.chmodSync(file, mode & 511 | 493);
|
|
134
|
-
out.fixed.push(file);
|
|
135
|
-
} catch (err) {
|
|
136
|
-
out.failed.push({ file, error: err.message });
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return out;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// src/core/pty/pty-session.ts
|
|
143
|
-
var HIDDEN = /* @__PURE__ */ Symbol.for("work.forkHidesConsole");
|
|
144
|
-
function hideForkConsoles(cp) {
|
|
145
|
-
if (cp.fork[HIDDEN]) return;
|
|
146
|
-
const orig = cp.fork;
|
|
147
|
-
const wrapped = function(modulePath, a, b) {
|
|
148
|
-
const args = Array.isArray(a) ? a : [];
|
|
149
|
-
const options = (Array.isArray(a) || a == null ? b : a) ?? {};
|
|
150
|
-
return orig.call(cp, modulePath, args, { windowsHide: true, ...options });
|
|
151
|
-
};
|
|
152
|
-
wrapped[HIDDEN] = true;
|
|
153
|
-
cp.fork = wrapped;
|
|
154
|
-
}
|
|
155
|
-
if (process.platform === "win32") hideForkConsoles(childProcess);
|
|
156
|
-
var spawnHelperChecked = false;
|
|
157
|
-
function ensureSpawnHelper() {
|
|
158
|
-
if (spawnHelperChecked) return;
|
|
159
|
-
spawnHelperChecked = true;
|
|
160
|
-
try {
|
|
161
|
-
const dir = path2.dirname(createRequire(import.meta.url).resolve("node-pty/package.json"));
|
|
162
|
-
const { fixed, failed } = makeSpawnHelperExecutable(dir);
|
|
163
|
-
for (const file of fixed) debug("made node-pty spawn-helper executable", file);
|
|
164
|
-
for (const { file, error } of failed)
|
|
165
|
-
report(
|
|
166
|
-
"warn",
|
|
167
|
-
`node-pty's spawn-helper isn't executable and couldn't be made so (${error}): terminals can't start. Run: chmod +x "${file}"`
|
|
168
|
-
);
|
|
169
|
-
} catch (err) {
|
|
170
|
-
debug("spawn-helper check failed", err.message);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
var { Terminal } = xtermHeadless;
|
|
174
|
-
var { SerializeAddon } = xtermSerialize;
|
|
175
|
-
function startsAsBatch(cmd, env = process.env, platform = process.platform, cwd) {
|
|
176
|
-
return platform === "win32" && programFor(cmd, { env, cwd })?.batch === true;
|
|
177
|
-
}
|
|
178
|
-
function resolvePtyCommand(cmd, args, opts = {}) {
|
|
179
|
-
if (process.platform !== "win32") return { file: cmd, args };
|
|
180
|
-
const program = programFor(cmd, { env: opts.env ?? process.env, cwd: opts.cwd });
|
|
181
|
-
if (!program) throw new Error(`${cmd} not found on PATH`);
|
|
182
|
-
if (!program.batch) return { file: program.file, args: [...program.pre, ...args] };
|
|
183
|
-
const why = batchArgProblem(args);
|
|
184
|
-
if (why) throw new Error(`${cmd}: ${why}`);
|
|
185
|
-
const parse = crossSpawn._parse;
|
|
186
|
-
const parsed = parse(program.file, args, opts);
|
|
187
|
-
const env = shellEnv(opts.env ?? process.env);
|
|
188
|
-
if (parsed.options.windowsVerbatimArguments) {
|
|
189
|
-
return { file: parsed.command, args: parsed.args.join(" "), env };
|
|
190
|
-
}
|
|
191
|
-
return { file: parsed.file ?? parsed.command, args: parsed.args, env };
|
|
192
|
-
}
|
|
193
|
-
var PROMPT_SETTLE_MS = 800;
|
|
194
|
-
var PROMPT_WAIT_MS = 2e4;
|
|
195
|
-
function typeWhenSettled(target, text, opts) {
|
|
196
|
-
let quiet;
|
|
197
|
-
let typed = false;
|
|
198
|
-
const stop = () => {
|
|
199
|
-
typed = true;
|
|
200
|
-
clearTimeout(quiet);
|
|
201
|
-
clearTimeout(cap);
|
|
202
|
-
sub.dispose();
|
|
203
|
-
};
|
|
204
|
-
const type = () => {
|
|
205
|
-
if (typed) return;
|
|
206
|
-
stop();
|
|
207
|
-
if (opts.exited()) return;
|
|
208
|
-
opts.submit(text).catch((err) => debug("PtySession: typing the first prompt failed", err.message));
|
|
209
|
-
};
|
|
210
|
-
const cap = setTimeout(type, opts.waitMs ?? PROMPT_WAIT_MS);
|
|
211
|
-
cap.unref?.();
|
|
212
|
-
const sub = target.onData(() => {
|
|
213
|
-
if (typed) return;
|
|
214
|
-
clearTimeout(quiet);
|
|
215
|
-
quiet = setTimeout(type, opts.settleMs ?? PROMPT_SETTLE_MS);
|
|
216
|
-
});
|
|
217
|
-
target.onExit(() => {
|
|
218
|
-
if (!typed) stop();
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function readUseBundledConpty() {
|
|
222
|
-
try {
|
|
223
|
-
return loadConfig()?.useBundledConpty === true;
|
|
224
|
-
} catch {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
function conptyOptions(platform, useBundled) {
|
|
229
|
-
return platform === "win32" && useBundled ? { useConptyDll: true } : {};
|
|
230
|
-
}
|
|
231
|
-
function readAgentsLowPriority() {
|
|
232
|
-
try {
|
|
233
|
-
return loadConfig()?.agentsLowPriority === true;
|
|
234
|
-
} catch {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
function lowerPriority(pid, set = os.setPriority) {
|
|
239
|
-
try {
|
|
240
|
-
set(pid, os.constants.priority.PRIORITY_BELOW_NORMAL);
|
|
241
|
-
return null;
|
|
242
|
-
} catch (err) {
|
|
243
|
-
return err.message;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function slowStart(ms) {
|
|
247
|
-
return {
|
|
248
|
-
note: ms > 1e3 ? `(the start took ${ms} ms)` : "",
|
|
249
|
-
warn: ms > 5e3 ? `[pty] starting a terminal took ${Math.round(ms / 1e3)} s: the PTY host answered nothing meanwhile` : null
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
var PtySession = class {
|
|
253
|
-
pty;
|
|
254
|
-
terminal;
|
|
255
|
-
serializer = new SerializeAddon();
|
|
256
|
-
cwd;
|
|
257
|
-
outputHandler;
|
|
258
|
-
_exited = false;
|
|
259
|
-
_outputBuffer = "";
|
|
260
|
-
_loggedOutput = false;
|
|
261
|
-
onExit;
|
|
262
|
-
constructor(cwd, cols, rows, command, aiOptions) {
|
|
263
|
-
this.cwd = cwd;
|
|
264
|
-
this.terminal = new Terminal({
|
|
265
|
-
cols,
|
|
266
|
-
rows,
|
|
267
|
-
scrollback: 200,
|
|
268
|
-
allowProposedApi: true
|
|
269
|
-
});
|
|
270
|
-
this.terminal.loadAddon(this.serializer);
|
|
271
|
-
let rawCmd;
|
|
272
|
-
let rawArgs;
|
|
273
|
-
let typeLater;
|
|
274
|
-
if (command) {
|
|
275
|
-
rawCmd = command.cmd;
|
|
276
|
-
rawArgs = command.args;
|
|
277
|
-
} else if (aiOptions) {
|
|
278
|
-
const launchOpts = { resume: aiOptions.resume, promptFile: aiOptions.promptFile };
|
|
279
|
-
({ cmd: rawCmd, args: rawArgs } = buildAiLaunchArgs(aiOptions.tool, { ...launchOpts, initialPrompt: aiOptions.initialPrompt }));
|
|
280
|
-
if (aiOptions.initialPrompt && batchArgProblem([aiOptions.initialPrompt]) && startsAsBatch(aiOptions.tool.cmd, aiOptions.env, process.platform, cwd)) {
|
|
281
|
-
({ cmd: rawCmd, args: rawArgs } = buildAiLaunchArgs(aiOptions.tool, launchOpts));
|
|
282
|
-
typeLater = aiOptions.initialPrompt;
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
throw new Error("PtySession requires either a custom command or aiOptions");
|
|
286
|
-
}
|
|
287
|
-
const env = Object.fromEntries(
|
|
288
|
-
Object.entries(agentById(aiOptions?.tool.cmd ?? "claude").launch.cleanEnv(aiOptions?.env ?? process.env)).filter(
|
|
289
|
-
(e) => e[1] != null
|
|
290
|
-
)
|
|
291
|
-
);
|
|
292
|
-
if (aiOptions?.port !== void 0) {
|
|
293
|
-
env.PORT = String(aiOptions.port);
|
|
294
|
-
}
|
|
295
|
-
const { file: spawnCmd, args: spawnArgs, env: batchEnv } = resolvePtyCommand(rawCmd, rawArgs, { env, cwd });
|
|
296
|
-
debug("PtySession spawn", { spawnCmd, spawnArgs, cwd, cols, rows });
|
|
297
|
-
ensureSpawnHelper();
|
|
298
|
-
const started = Date.now();
|
|
299
|
-
this.pty = pty.spawn(spawnCmd, spawnArgs, {
|
|
300
|
-
name: "xterm-256color",
|
|
301
|
-
cwd,
|
|
302
|
-
cols,
|
|
303
|
-
rows,
|
|
304
|
-
env: batchEnv ?? env,
|
|
305
|
-
...conptyOptions(process.platform, readUseBundledConpty())
|
|
306
|
-
});
|
|
307
|
-
const slow = slowStart(Date.now() - started);
|
|
308
|
-
debug("PtySession spawned pid=", this.pty.pid, slow.note);
|
|
309
|
-
if (slow.warn) report("warn", slow.warn);
|
|
310
|
-
if (aiOptions && readAgentsLowPriority()) {
|
|
311
|
-
const why = lowerPriority(this.pty.pid);
|
|
312
|
-
debug(why ? `PtySession: couldn't lower the agent's priority (${why})` : "PtySession: agent started below normal priority");
|
|
313
|
-
}
|
|
314
|
-
this.pty.onData((data) => {
|
|
315
|
-
this.terminal.write(data);
|
|
316
|
-
this.outputHandler?.(data);
|
|
317
|
-
if (!this._loggedOutput) {
|
|
318
|
-
this._outputBuffer = (this._outputBuffer || "") + data;
|
|
319
|
-
if (this._outputBuffer.length > 500) {
|
|
320
|
-
debug("PtySession first output", { cwd, output: this._outputBuffer.slice(0, 500) });
|
|
321
|
-
this._loggedOutput = true;
|
|
322
|
-
this._outputBuffer = "";
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
if (typeLater !== void 0) {
|
|
327
|
-
const agent = agentById(aiOptions?.tool.cmd ?? "claude");
|
|
328
|
-
typeWhenSettled(this.pty, typeLater, {
|
|
329
|
-
exited: () => this._exited,
|
|
330
|
-
submit: (text) => agent.input.submit((d) => {
|
|
331
|
-
this.write(d);
|
|
332
|
-
return Promise.resolve(!this._exited);
|
|
333
|
-
}, text)
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
this.pty.onExit(({ exitCode }) => {
|
|
337
|
-
if (!this._loggedOutput && this._outputBuffer) {
|
|
338
|
-
debug("PtySession output before exit", { cwd, output: this._outputBuffer.slice(0, 500) });
|
|
339
|
-
}
|
|
340
|
-
this._outputBuffer = "";
|
|
341
|
-
debug("PtySession exited", { cwd, exitCode });
|
|
342
|
-
this._exited = true;
|
|
343
|
-
this.onExit?.(exitCode);
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
get exited() {
|
|
347
|
-
return this._exited;
|
|
348
|
-
}
|
|
349
|
-
write(data) {
|
|
350
|
-
if (!this._exited) {
|
|
351
|
-
try {
|
|
352
|
-
this.pty.write(data);
|
|
353
|
-
} catch {
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
resize(cols, rows) {
|
|
358
|
-
if (!this._exited) {
|
|
359
|
-
try {
|
|
360
|
-
this.pty.resize(cols, rows);
|
|
361
|
-
} catch {
|
|
362
|
-
}
|
|
363
|
-
this.terminal.resize(cols, rows);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* The current screen + scrollback as escape sequences that redraw it
|
|
368
|
-
* exactly (colors, cursor, modes, alt screen). What a late attacher is
|
|
369
|
-
* sent instead of raw output history — raw bytes can start mid-sequence
|
|
370
|
-
* and were drawn for another client's grid (VS Code does the same).
|
|
371
|
-
*/
|
|
372
|
-
serialize() {
|
|
373
|
-
try {
|
|
374
|
-
return this.serializer.serialize();
|
|
375
|
-
} catch {
|
|
376
|
-
return "";
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* serialize(), once the screen has parsed everything written to it so far:
|
|
381
|
-
* xterm queues writes, and a write's callback runs right after that write
|
|
382
|
-
* is parsed — before any written later. What a new client is sent first.
|
|
383
|
-
*/
|
|
384
|
-
serializeSettled() {
|
|
385
|
-
return new Promise((resolve) => {
|
|
386
|
-
try {
|
|
387
|
-
this.terminal.write("", () => resolve(this.serialize()));
|
|
388
|
-
} catch {
|
|
389
|
-
resolve(this.serialize());
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
/** The visible screen as plain text, one line per row (no colors).
|
|
394
|
-
* What the dashboard checks before answering a prompt by keystroke. */
|
|
395
|
-
screenText() {
|
|
396
|
-
try {
|
|
397
|
-
const buf = this.terminal.buffer.active;
|
|
398
|
-
const lines = [];
|
|
399
|
-
for (let y = buf.viewportY; y < buf.viewportY + this.terminal.rows; y++) {
|
|
400
|
-
lines.push(buf.getLine(y)?.translateToString(true) ?? "");
|
|
401
|
-
}
|
|
402
|
-
return lines.join("\n");
|
|
403
|
-
} catch {
|
|
404
|
-
return "";
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
setOutputHandler(handler) {
|
|
408
|
-
this.outputHandler = handler;
|
|
409
|
-
}
|
|
410
|
-
dispose() {
|
|
411
|
-
this.setOutputHandler(void 0);
|
|
412
|
-
if (!this._exited) {
|
|
413
|
-
try {
|
|
414
|
-
this.pty.kill();
|
|
415
|
-
} catch {
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
this.terminal.dispose();
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
// src/core/pty/pty-registry.ts
|
|
423
|
-
var REPLAY_MAX = 256 * 1024;
|
|
424
|
-
var HALT_RESUME_MS = 5 * 6e4;
|
|
425
|
-
var FORGET_EXITED_MS = 5e3;
|
|
426
|
-
var definedEnv = (env) => Object.fromEntries(Object.entries(env).filter((e) => typeof e[1] === "string"));
|
|
427
|
-
var defaultSpawner = (spec) => new PtySession(spec.cwd, spec.cols ?? 120, spec.rows ?? 32, void 0, {
|
|
428
|
-
tool: spec.tool,
|
|
429
|
-
resume: spec.resume,
|
|
430
|
-
port: spec.port,
|
|
431
|
-
initialPrompt: spec.initialPrompt,
|
|
432
|
-
env: spec.env
|
|
433
|
-
});
|
|
434
|
-
function fileSessionsStore(file) {
|
|
435
|
-
return {
|
|
436
|
-
read() {
|
|
437
|
-
const out = {};
|
|
438
|
-
try {
|
|
439
|
-
const raw = JSON.parse(fs2.readFileSync(file, "utf-8"));
|
|
440
|
-
if (raw && typeof raw === "object") {
|
|
441
|
-
for (const [id, entry] of Object.entries(raw)) if (isPersistedPty(entry)) out[id] = entry;
|
|
442
|
-
}
|
|
443
|
-
} catch {
|
|
444
|
-
}
|
|
445
|
-
return out;
|
|
446
|
-
},
|
|
447
|
-
write(all) {
|
|
448
|
-
ensureFile(file, "{}");
|
|
449
|
-
withFileLockSync(file, () => atomicWriteFile(file, JSON.stringify(all, null, 2)));
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
var PtyRegistry = class {
|
|
454
|
-
entries = /* @__PURE__ */ new Map();
|
|
455
|
-
spawner;
|
|
456
|
-
hasConversation;
|
|
457
|
-
store;
|
|
458
|
-
cwdExists;
|
|
459
|
-
keepEnvNames;
|
|
460
|
-
sessionTool;
|
|
461
|
-
/** Serializes persistence writes inside this process. */
|
|
462
|
-
writeChain = Promise.resolve();
|
|
463
|
-
constructor(deps = {}) {
|
|
464
|
-
this.spawner = deps.spawner ?? defaultSpawner;
|
|
465
|
-
this.hasConversation = deps.hasConversation ?? ((cwd, tool, env) => agentById(tool).launch.canResume(cwd, { env }));
|
|
466
|
-
this.store = deps.sessions ?? (deps.sessionsPath ? fileSessionsStore(deps.sessionsPath) : dbPtySessions);
|
|
467
|
-
this.cwdExists = deps.cwdExists ?? ((p) => fs2.existsSync(p));
|
|
468
|
-
this.keepEnvNames = deps.keepEnvNames ?? (() => loadConfig()?.hostEnv ?? []);
|
|
469
|
-
this.sessionTool = deps.sessionTool ?? sessionToolFor;
|
|
470
|
-
}
|
|
471
|
-
list() {
|
|
472
|
-
return [...this.entries.values()].map((e) => this.info(e));
|
|
473
|
-
}
|
|
474
|
-
get(id) {
|
|
475
|
-
const e = this.entries.get(id);
|
|
476
|
-
return e ? this.info(e) : null;
|
|
477
|
-
}
|
|
478
|
-
/** Spawn unless a live PTY already exists for `id` (idempotent). */
|
|
479
|
-
spawn(id, spec, restored = false) {
|
|
480
|
-
const existing = this.entries.get(id);
|
|
481
|
-
if (existing && (!existing.pty.exited || existing.restarting || existing.halted)) return this.info(existing);
|
|
482
|
-
const { unsafeFlag: _retired, ...tool } = spec.tool;
|
|
483
|
-
spec = { ...spec, tool: this.sessionTool(tool) };
|
|
484
|
-
const agentEnv = hasEnvDelta(spec.agentEnv) ? spec.agentEnv : void 0;
|
|
485
|
-
const kept = spec.env ? keepEnv(definedEnv(applyEnvDelta(spec.env, agentEnv)), this.keepEnvNames()) : spec.keptEnv ?? existing?.spec.keptEnv;
|
|
486
|
-
const env = this.launchEnv({ env: spec.env, keptEnv: kept, agentEnv });
|
|
487
|
-
if (env) spec = { ...spec, env };
|
|
488
|
-
const cols = spec.cols ?? 120;
|
|
489
|
-
const rows = spec.rows ?? 32;
|
|
490
|
-
const pty2 = this.spawner({
|
|
491
|
-
...spec,
|
|
492
|
-
cols,
|
|
493
|
-
rows,
|
|
494
|
-
// `--continue` hard-errors in a directory Claude never ran in;
|
|
495
|
-
// `--fresh` opts out even when one exists.
|
|
496
|
-
resume: !spec.fresh && this.hasConversation(spec.cwd, spec.tool.cmd, spec.env ?? process.env)
|
|
497
|
-
});
|
|
498
|
-
const entry = {
|
|
499
|
-
id,
|
|
500
|
-
// Only what a restore may reuse: env/prompt/fresh are one-shot (and
|
|
501
|
-
// env can hold secrets), so they never reach pty-sessions.json — but
|
|
502
|
-
// the variables config `hostEnv` names do (keepEnv), so a restore after
|
|
503
|
-
// a reboot gets the JAVA_HOME / PATH it was started with.
|
|
504
|
-
spec: {
|
|
505
|
-
cwd: spec.cwd,
|
|
506
|
-
tool: spec.tool,
|
|
507
|
-
port: spec.port,
|
|
508
|
-
...kept ? { keptEnv: kept } : {},
|
|
509
|
-
...agentEnv ? { agentEnv } : {}
|
|
510
|
-
},
|
|
511
|
-
env: spec.env,
|
|
512
|
-
pty: pty2,
|
|
513
|
-
cols,
|
|
514
|
-
rows,
|
|
515
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
516
|
-
restored,
|
|
517
|
-
replay: "",
|
|
518
|
-
subscribers: /* @__PURE__ */ new Set(),
|
|
519
|
-
exitSubscribers: /* @__PURE__ */ new Set(),
|
|
520
|
-
exitCode: null,
|
|
521
|
-
lastOutputAt: Date.now()
|
|
522
|
-
};
|
|
523
|
-
this.wire(entry, pty2);
|
|
524
|
-
this.entries.set(id, entry);
|
|
525
|
-
void this.persist();
|
|
526
|
-
return this.info(entry);
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* The env a spawn runs with: the shell's when it came from one; else the host's plus what its session kept; then the
|
|
530
|
-
* session's account change (`agentEnv`) over it — on the host's own environment when there is nothing else, so a
|
|
531
|
-
* default session never inherits a CLAUDE_CONFIG_DIR the host was started with. Undefined: no change, the host's own env.
|
|
532
|
-
*/
|
|
533
|
-
launchEnv(spec) {
|
|
534
|
-
const base = spec.env ?? (spec.keptEnv ? { ...process.env, ...spec.keptEnv } : void 0);
|
|
535
|
-
return hasEnvDelta(spec.agentEnv) ? definedEnv(applyEnvDelta(base ?? process.env, spec.agentEnv)) : base;
|
|
536
|
-
}
|
|
537
|
-
/** `pty` becomes the entry's process: its output to the entry's clients, its exit told to them (then forgotten). */
|
|
538
|
-
wire(entry, pty2) {
|
|
539
|
-
const id = entry.id;
|
|
540
|
-
entry.pty = pty2;
|
|
541
|
-
const keepRaw = !pty2.serialize;
|
|
542
|
-
pty2.setOutputHandler((data) => {
|
|
543
|
-
entry.lastOutputAt = Date.now();
|
|
544
|
-
if (keepRaw) {
|
|
545
|
-
entry.replay += data;
|
|
546
|
-
if (entry.replay.length > REPLAY_MAX) {
|
|
547
|
-
entry.replay = entry.replay.slice(entry.replay.length - REPLAY_MAX);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
for (const cb of entry.subscribers) {
|
|
551
|
-
try {
|
|
552
|
-
cb(data);
|
|
553
|
-
} catch {
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
pty2.onExit = (code) => {
|
|
558
|
-
entry.exitCode = code;
|
|
559
|
-
for (const cb of entry.exitSubscribers) {
|
|
560
|
-
try {
|
|
561
|
-
cb(code);
|
|
562
|
-
} catch {
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
setTimeout(() => {
|
|
566
|
-
if (this.entries.get(id) === entry) {
|
|
567
|
-
this.entries.delete(id);
|
|
568
|
-
void this.persist();
|
|
569
|
-
}
|
|
570
|
-
}, FORGET_EXITED_MS).unref?.();
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
/** The live PTY's visible screen as text; null when there is none (or
|
|
574
|
-
* it can't render one — test fakes). */
|
|
575
|
-
screen(id) {
|
|
576
|
-
const e = this.entries.get(id);
|
|
577
|
-
if (!e || e.pty.exited || !e.pty.screenText) return null;
|
|
578
|
-
return e.pty.screenText();
|
|
579
|
-
}
|
|
580
|
-
write(id, data) {
|
|
581
|
-
const e = this.entries.get(id);
|
|
582
|
-
if (!e || e.pty.exited) return false;
|
|
583
|
-
e.pty.write(data);
|
|
584
|
-
return true;
|
|
585
|
-
}
|
|
586
|
-
/** Last writer wins — with several clients attached (browser + a real
|
|
587
|
-
* terminal) the host calls this when one resizes AND when one is typed in
|
|
588
|
-
* (its own grid again), so the client used last sets the grid, like
|
|
589
|
-
* tmux's `window-size latest` (pty-host.ts). */
|
|
590
|
-
resize(id, cols, rows) {
|
|
591
|
-
const e = this.entries.get(id);
|
|
592
|
-
if (!e || e.pty.exited) return;
|
|
593
|
-
if (cols < 2 || rows < 2 || cols === e.cols && rows === e.rows) return;
|
|
594
|
-
e.cols = cols;
|
|
595
|
-
e.rows = rows;
|
|
596
|
-
e.pty.resize(cols, rows);
|
|
597
|
-
}
|
|
598
|
-
/**
|
|
599
|
-
* Attach a client: the screen snapshot, a disposer, and — for a real
|
|
600
|
-
* session — `ready`, the snapshot once the screen has parsed everything
|
|
601
|
-
* that arrived before this attach, then `start()` once it was sent.
|
|
602
|
-
*
|
|
603
|
-
* Output reaches clients the moment it arrives, but the screen parses it a
|
|
604
|
-
* moment later (xterm's write is queued). A client attaching in between got
|
|
605
|
-
* a snapshot without that output and subscribed too late to be sent it: it
|
|
606
|
-
* was lost (a Linux PTY answers fast enough to land there). So output
|
|
607
|
-
* arriving from the attach on is held for this client until `start()`, and
|
|
608
|
-
* `ready` is the screen exactly as of the attach — nothing lost, nothing
|
|
609
|
-
* twice. `replay` (taken at once) is for screens with no parsing step.
|
|
610
|
-
*/
|
|
611
|
-
attach(id, onData, onExit) {
|
|
612
|
-
const e = this.entries.get(id);
|
|
613
|
-
if (!e) return null;
|
|
614
|
-
const exitedWith = e.pty.exited && !e.restarting && !e.halted ? e.exitCode ?? 0 : null;
|
|
615
|
-
const restarting = !!e.restarting || !!e.halted;
|
|
616
|
-
const settled = restarting ? void 0 : e.pty.serializeSettled;
|
|
617
|
-
let held = settled ? [] : null;
|
|
618
|
-
const sub = (d) => held ? held.push(d) : onData(d);
|
|
619
|
-
if (exitedWith === null) {
|
|
620
|
-
e.subscribers.add(sub);
|
|
621
|
-
e.exitSubscribers.add(onExit);
|
|
622
|
-
}
|
|
623
|
-
const snapshot = (data) => ({ data, cols: e.cols, rows: e.rows });
|
|
624
|
-
const replay = snapshot(restarting ? "" : e.pty.serialize?.() || e.replay);
|
|
625
|
-
return {
|
|
626
|
-
exitedWith,
|
|
627
|
-
replay,
|
|
628
|
-
ready: settled ? settled.call(e.pty).then((d) => snapshot(d || e.replay)) : Promise.resolve(replay),
|
|
629
|
-
start: () => {
|
|
630
|
-
const q = held;
|
|
631
|
-
held = null;
|
|
632
|
-
for (const d of q ?? []) onData(d);
|
|
633
|
-
},
|
|
634
|
-
detach: () => {
|
|
635
|
-
e.subscribers.delete(sub);
|
|
636
|
-
e.exitSubscribers.delete(onExit);
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Explicit kill (worktree removal, user closed the session). Removed
|
|
642
|
-
* from the persisted list so it is NOT restored.
|
|
643
|
-
*
|
|
644
|
-
* Resolves once the process has actually exited (or after `timeoutMs`):
|
|
645
|
-
* on Windows a just-killed process still holds its cwd for a moment, and
|
|
646
|
-
* the caller's next step is usually deleting that very directory.
|
|
647
|
-
*/
|
|
648
|
-
async kill(id, timeoutMs = 3e3) {
|
|
649
|
-
const e = this.entries.get(id);
|
|
650
|
-
if (!e) return;
|
|
651
|
-
this.entries.delete(id);
|
|
652
|
-
if (e.halted) clearTimeout(e.halted.timer);
|
|
653
|
-
const attached = [...e.exitSubscribers];
|
|
654
|
-
e.subscribers.clear();
|
|
655
|
-
e.exitSubscribers.clear();
|
|
656
|
-
const exited = e.pty.exited ? Promise.resolve(e.exitCode ?? 0) : new Promise((resolve) => {
|
|
657
|
-
const timer = setTimeout(() => resolve(0), timeoutMs);
|
|
658
|
-
e.pty.onExit = (code2) => {
|
|
659
|
-
clearTimeout(timer);
|
|
660
|
-
resolve(code2);
|
|
661
|
-
};
|
|
662
|
-
});
|
|
663
|
-
e.pty.dispose();
|
|
664
|
-
const [code] = await Promise.all([exited, this.persist()]);
|
|
665
|
-
for (const cb of attached) {
|
|
666
|
-
try {
|
|
667
|
-
cb(code);
|
|
668
|
-
} catch {
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Its agent stopped and started again in place, resuming its conversation (a
|
|
674
|
-
* tool that updated runs its new version). The new process goes into the same
|
|
675
|
-
* entry, so the terminals attached stay attached (and a detach still finds them),
|
|
676
|
-
* see the new one draw, and one that attaches meanwhile joins it; the restore
|
|
677
|
-
* list keeps it. Null when there's no live PTY of that id.
|
|
678
|
-
*
|
|
679
|
-
* Never two agents on one conversation: an old one that hasn't exited within
|
|
680
|
-
* `timeoutMs` is left running and tracked, and the restart fails. A new one that
|
|
681
|
-
* can't start (its tool gone mid-update) ends the session as a kill does, its
|
|
682
|
-
* terminals told so.
|
|
683
|
-
*
|
|
684
|
-
* `agentEnv`: the agent's environment for the new process differs from the old one's by this (a session moved to
|
|
685
|
-
* another account): it replaces the entry's own, in the restore list too — the process is started on what the
|
|
686
|
-
* session is now, not on what it was.
|
|
687
|
-
*/
|
|
688
|
-
restart(id, timeoutMs = 3e3, agentEnv) {
|
|
689
|
-
const e = this.entries.get(id);
|
|
690
|
-
if (!e) return Promise.resolve(null);
|
|
691
|
-
if (e.restarting) return e.restarting;
|
|
692
|
-
if (e.halted) return Promise.reject(new Error("its agent is halted: resume it first"));
|
|
693
|
-
if (e.pty.exited) return Promise.resolve(null);
|
|
694
|
-
const running = this.haltEntry(e, timeoutMs).then((ok) => ok ? this.resumeEntry(e, agentEnv) : this.get(e.id)).finally(() => {
|
|
695
|
-
e.restarting = void 0;
|
|
696
|
-
});
|
|
697
|
-
e.restarting = running;
|
|
698
|
-
return running;
|
|
699
|
-
}
|
|
700
|
-
/**
|
|
701
|
-
* Its agent stopped, and kept stopped until `resume` (a switch of account moves its conversation files in between,
|
|
702
|
-
* which a running — or just exiting — agent would write into again). The entry, its restore-list record and the
|
|
703
|
-
* attached clients stay, and none is told it ended. Refused while it is being restarted or already halted; an agent that
|
|
704
|
-
* doesn't stop within `timeoutMs` ends the session as `restart` does. A `resume` that never comes (work web died)
|
|
705
|
-
* can't leave the session dead: after `resumeAfterMs` it is started again on its old spec. Null: nothing runs.
|
|
706
|
-
*/
|
|
707
|
-
halt(id, timeoutMs = 3e3, resumeAfterMs = HALT_RESUME_MS) {
|
|
708
|
-
const e = this.entries.get(id);
|
|
709
|
-
if (!e) return Promise.resolve(null);
|
|
710
|
-
if (e.restarting || e.halted) return Promise.reject(new Error("its agent is already being restarted or halted"));
|
|
711
|
-
if (e.pty.exited) return Promise.resolve(null);
|
|
712
|
-
const running = this.haltEntry(e, timeoutMs).then((ok) => {
|
|
713
|
-
if (!ok) return this.get(id);
|
|
714
|
-
const timer = setTimeout(() => {
|
|
715
|
-
report("warn", `${id}: halted, and no resume within ${Math.round(resumeAfterMs / 1e3)} s: starting it again on its old spec`);
|
|
716
|
-
this.resume(id).catch(swallow(`resume halted ${id}`));
|
|
717
|
-
}, resumeAfterMs);
|
|
718
|
-
timer.unref?.();
|
|
719
|
-
e.halted = { timer };
|
|
720
|
-
return this.info(e);
|
|
721
|
-
}).finally(() => {
|
|
722
|
-
e.restarting = void 0;
|
|
723
|
-
});
|
|
724
|
-
e.restarting = running;
|
|
725
|
-
return running;
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* Start a halted agent again in place, resuming its conversation, on `agentEnv` when given (as `restart` takes it): the
|
|
729
|
-
* clients carry on. Null when it isn't halted.
|
|
730
|
-
*/
|
|
731
|
-
resume(id, agentEnv) {
|
|
732
|
-
const e = this.entries.get(id);
|
|
733
|
-
if (!e?.halted) return Promise.resolve(null);
|
|
734
|
-
clearTimeout(e.halted.timer);
|
|
735
|
-
e.halted = void 0;
|
|
736
|
-
const running = this.resumeEntry(e, agentEnv).finally(() => {
|
|
737
|
-
e.restarting = void 0;
|
|
738
|
-
});
|
|
739
|
-
e.restarting = running;
|
|
740
|
-
return running;
|
|
741
|
-
}
|
|
742
|
-
/** Stop the entry's process and wait for it to exit (timeoutMs); one that won't ends the session and throws. False: it was killed meanwhile. */
|
|
743
|
-
async haltEntry(e, timeoutMs) {
|
|
744
|
-
const id = e.id;
|
|
745
|
-
const old = e.pty;
|
|
746
|
-
const stopped = await new Promise((resolve) => {
|
|
747
|
-
const timer = setTimeout(() => resolve(false), timeoutMs);
|
|
748
|
-
old.onExit = () => {
|
|
749
|
-
clearTimeout(timer);
|
|
750
|
-
resolve(true);
|
|
751
|
-
};
|
|
752
|
-
old.dispose();
|
|
753
|
-
});
|
|
754
|
-
if (this.entries.get(id) !== e) return false;
|
|
755
|
-
if (!stopped) {
|
|
756
|
-
await this.endEntry(e);
|
|
757
|
-
throw new Error(
|
|
758
|
-
`its agent didn't stop within ${Math.round(timeoutMs / 1e3)} s; its session was stopped (open it to start it again)`
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
return true;
|
|
762
|
-
}
|
|
763
|
-
/** Start the entry's agent again in place (its process is gone): `--continue`, on `agentEnv` when given. */
|
|
764
|
-
async resumeEntry(e, agentEnv) {
|
|
765
|
-
if (this.entries.get(e.id) !== e) return this.get(e.id);
|
|
766
|
-
if (agentEnv) this.useAgentEnv(e, agentEnv);
|
|
767
|
-
e.spec = { ...e.spec, tool: this.sessionTool(e.spec.tool) };
|
|
768
|
-
let pty2;
|
|
769
|
-
try {
|
|
770
|
-
const env = e.env ?? this.launchEnv(e.spec);
|
|
771
|
-
pty2 = this.spawner({
|
|
772
|
-
...e.spec,
|
|
773
|
-
env,
|
|
774
|
-
cols: e.cols,
|
|
775
|
-
rows: e.rows,
|
|
776
|
-
resume: this.hasConversation(e.spec.cwd, e.spec.tool.cmd, env ?? process.env)
|
|
777
|
-
});
|
|
778
|
-
} catch (err) {
|
|
779
|
-
await this.endEntry(e);
|
|
780
|
-
throw err;
|
|
781
|
-
}
|
|
782
|
-
e.exitCode = null;
|
|
783
|
-
e.replay = "";
|
|
784
|
-
e.startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
785
|
-
e.restored = false;
|
|
786
|
-
e.lastOutputAt = Date.now();
|
|
787
|
-
this.wire(e, pty2);
|
|
788
|
-
void this.persist();
|
|
789
|
-
return this.info(e);
|
|
790
|
-
}
|
|
791
|
-
/** The entry's agent environment becomes `delta`: in its spec (the restore list), the variables it kept, and the environment it started with. */
|
|
792
|
-
useAgentEnv(e, delta) {
|
|
793
|
-
const { agentEnv: _old, keptEnv, ...rest } = e.spec;
|
|
794
|
-
const kept = keptEnv ? definedEnv(applyEnvDelta(keptEnv, delta)) : void 0;
|
|
795
|
-
e.spec = {
|
|
796
|
-
...rest,
|
|
797
|
-
...kept && Object.keys(kept).length ? { keptEnv: kept } : {},
|
|
798
|
-
...hasEnvDelta(delta) ? { agentEnv: delta } : {}
|
|
799
|
-
};
|
|
800
|
-
if (e.env) e.env = definedEnv(applyEnvDelta(e.env, delta));
|
|
801
|
-
}
|
|
802
|
-
/** A restart that can't go on ends the session as a kill does: its terminals told (they offer Enter to start it again), forgotten. */
|
|
803
|
-
async endEntry(e) {
|
|
804
|
-
if (e.halted) clearTimeout(e.halted.timer);
|
|
805
|
-
if (this.entries.get(e.id) === e) this.entries.delete(e.id);
|
|
806
|
-
const attached = [...e.exitSubscribers];
|
|
807
|
-
e.subscribers.clear();
|
|
808
|
-
e.exitSubscribers.clear();
|
|
809
|
-
await this.persist();
|
|
810
|
-
for (const cb of attached) {
|
|
811
|
-
try {
|
|
812
|
-
cb(1);
|
|
813
|
-
} catch {
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
/**
|
|
818
|
-
* Respawn everything in the persisted list. Called once at host startup.
|
|
819
|
-
* Worktrees that no longer exist are dropped, and so is the Ctrl+K
|
|
820
|
-
* assistant: it starts when you open it (its conversation resumes then) —
|
|
821
|
-
* restored, one opened once ran for good, a Claude nobody used. Nor is an
|
|
822
|
-
* account's login terminal (account-login.ts): it is the Accounts page's,
|
|
823
|
-
* for as long as its panel is open.
|
|
824
|
-
*/
|
|
825
|
-
async restore() {
|
|
826
|
-
const saved = this.readPersisted();
|
|
827
|
-
const restored = [];
|
|
828
|
-
for (const [id, entry] of Object.entries(saved)) {
|
|
829
|
-
if (id === ASSISTANT_ID || isAccountLoginId(id) || !this.cwdExists(entry.cwd)) continue;
|
|
830
|
-
try {
|
|
831
|
-
this.spawn(id, entry, true);
|
|
832
|
-
restored.push(id);
|
|
833
|
-
} catch (err) {
|
|
834
|
-
logSwallowed(`restore session ${id} in ${entry.cwd}`, err);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
await this.persist();
|
|
838
|
-
return restored;
|
|
839
|
-
}
|
|
840
|
-
/** Host shutdown: kill every PTY but KEEP the persisted list, so the next
|
|
841
|
-
* host start restores them. */
|
|
842
|
-
disposeAllKeepingState() {
|
|
843
|
-
for (const e of this.entries.values()) {
|
|
844
|
-
e.pty.onExit = void 0;
|
|
845
|
-
e.subscribers.clear();
|
|
846
|
-
e.exitSubscribers.clear();
|
|
847
|
-
e.pty.dispose();
|
|
848
|
-
}
|
|
849
|
-
this.entries.clear();
|
|
850
|
-
}
|
|
851
|
-
/** Resolves once every queued persistence write has landed. */
|
|
852
|
-
flush() {
|
|
853
|
-
return this.writeChain;
|
|
854
|
-
}
|
|
855
|
-
info(e) {
|
|
856
|
-
return {
|
|
857
|
-
id: e.id,
|
|
858
|
-
cwd: e.spec.cwd,
|
|
859
|
-
pid: e.pty.pty.pid,
|
|
860
|
-
exited: e.pty.exited,
|
|
861
|
-
cols: e.cols,
|
|
862
|
-
rows: e.rows,
|
|
863
|
-
startedAt: e.startedAt,
|
|
864
|
-
restored: e.restored,
|
|
865
|
-
clients: e.subscribers.size,
|
|
866
|
-
lastOutputAt: new Date(e.lastOutputAt).toISOString(),
|
|
867
|
-
tool: e.spec.tool.cmd
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
readPersisted() {
|
|
871
|
-
try {
|
|
872
|
-
return this.store.read();
|
|
873
|
-
} catch (err) {
|
|
874
|
-
logSwallowed("read the PTY restore list", err);
|
|
875
|
-
return {};
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
persist() {
|
|
879
|
-
const snapshot = {};
|
|
880
|
-
for (const e of this.entries.values()) {
|
|
881
|
-
snapshot[e.id] = { ...e.spec, startedAt: e.startedAt };
|
|
882
|
-
}
|
|
883
|
-
this.writeChain = this.writeChain.then(() => this.store.write(snapshot)).catch(swallow("persist the PTY restore list (next change retries)"));
|
|
884
|
-
return this.writeChain;
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
// src/core/pty/terminal-tickets.ts
|
|
889
|
-
import crypto from "crypto";
|
|
890
|
-
var TICKET_TTL_MS = 3e4;
|
|
891
|
-
var LOOPBACK_ORIGIN = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\])(?::\d{1,5})?$/;
|
|
892
|
-
var isLoopbackOrigin = (origin) => LOOPBACK_ORIGIN.test(origin);
|
|
893
|
-
function createTicketBook(now = Date.now) {
|
|
894
|
-
const book = /* @__PURE__ */ new Map();
|
|
895
|
-
const sweep = () => {
|
|
896
|
-
const t = now();
|
|
897
|
-
for (const [k, v] of book) if (v.expires <= t) book.delete(k);
|
|
898
|
-
};
|
|
899
|
-
return {
|
|
900
|
-
issue(id, origin) {
|
|
901
|
-
if (!id || !isLoopbackOrigin(origin)) return null;
|
|
902
|
-
sweep();
|
|
903
|
-
const ticket = crypto.randomBytes(24).toString("hex");
|
|
904
|
-
book.set(ticket, { id, origin, expires: now() + TICKET_TTL_MS });
|
|
905
|
-
return ticket;
|
|
906
|
-
},
|
|
907
|
-
redeem(ticket, id, origin) {
|
|
908
|
-
const t = book.get(ticket);
|
|
909
|
-
if (!t) return false;
|
|
910
|
-
book.delete(ticket);
|
|
911
|
-
return t.expires > now() && t.id === id && t.origin === origin;
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
// src/core/pty/pty-host.ts
|
|
917
|
-
var ATTACH_PATH = /^\/ptys\/([^/?]+)\/attach(?:\?|$)/;
|
|
918
|
-
var PTY_PATH = /^\/ptys\/([^/?]+)(\/write|\/screen|\/restart|\/halt|\/resume)?$/;
|
|
919
|
-
var MAX_BODY = 1024 * 1024;
|
|
920
|
-
var REPLY = /^(?:\x1b\[[IO]|\x1b\[[?>=][\d;]*c|\x1b\[(?!1;[2-8]R)\d+;\d+R|\x1b\[\??\d*n|\x1b\[\?\d*u|\x1b\[\??[\d;]*\$y|\x1b\[\d+(?:;\d+)*t|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[P_][\s\S]*?\x1b\\|\x1b\[<(?:35|39|43|47|51|55|59|63);\d+;\d+M)+$/;
|
|
921
|
-
function isTerminalReply(data) {
|
|
922
|
-
return REPLY.test(data);
|
|
923
|
-
}
|
|
924
|
-
function readBody(req) {
|
|
925
|
-
return new Promise((resolve, reject) => {
|
|
926
|
-
let size = 0;
|
|
927
|
-
const chunks = [];
|
|
928
|
-
req.on("data", (c) => {
|
|
929
|
-
size += c.length;
|
|
930
|
-
if (size > MAX_BODY) {
|
|
931
|
-
reject(new Error("body too large"));
|
|
932
|
-
req.destroy();
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
chunks.push(c);
|
|
936
|
-
});
|
|
937
|
-
req.on("end", () => {
|
|
938
|
-
try {
|
|
939
|
-
const text = Buffer.concat(chunks).toString("utf-8");
|
|
940
|
-
resolve(text ? JSON.parse(text) : {});
|
|
941
|
-
} catch (err) {
|
|
942
|
-
reject(err);
|
|
943
|
-
}
|
|
944
|
-
});
|
|
945
|
-
req.on("error", reject);
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
function send(res, status, body) {
|
|
949
|
-
res.writeHead(status, { "Content-Type": "application/json" });
|
|
950
|
-
res.end(JSON.stringify(body));
|
|
951
|
-
}
|
|
952
|
-
function isSpawnSpec(v) {
|
|
953
|
-
if (!v || typeof v !== "object") return false;
|
|
954
|
-
const s = v;
|
|
955
|
-
return typeof s.cwd === "string" && s.cwd.length > 0 && !!s.tool && typeof s.tool.cmd === "string" && Array.isArray(s.tool.baseArgs);
|
|
956
|
-
}
|
|
957
|
-
async function startPtyHost(opts = {}) {
|
|
958
|
-
const registry = opts.registry ?? new PtyRegistry();
|
|
959
|
-
const token = crypto2.randomBytes(24).toString("hex");
|
|
960
|
-
let allowedHosts = /* @__PURE__ */ new Set();
|
|
961
|
-
const tickets = createTicketBook();
|
|
962
|
-
const authorized = (req, url) => {
|
|
963
|
-
if (!req.headers.host || !allowedHosts.has(req.headers.host)) return false;
|
|
964
|
-
const given = req.headers["x-work-token"] ?? url.searchParams.get("token") ?? "";
|
|
965
|
-
const a = Buffer.from(given);
|
|
966
|
-
const b = Buffer.from(token);
|
|
967
|
-
return a.length === b.length && crypto2.timingSafeEqual(a, b);
|
|
968
|
-
};
|
|
969
|
-
const server = http.createServer(async (req, res) => {
|
|
970
|
-
const url = new URL(req.url ?? "/", "http://localhost");
|
|
971
|
-
if (!authorized(req, url)) return send(res, 403, { error: "forbidden" });
|
|
972
|
-
try {
|
|
973
|
-
if (req.method === "GET" && url.pathname === "/health") {
|
|
974
|
-
return send(res, 200, { version: PROTOCOL_VERSION, pid: process.pid, features: HOST_FEATURES, work: VERSION });
|
|
975
|
-
}
|
|
976
|
-
if (req.method === "GET" && url.pathname === "/ptys") {
|
|
977
|
-
return send(res, 200, registry.list());
|
|
978
|
-
}
|
|
979
|
-
if (req.method === "POST" && url.pathname === "/tickets") {
|
|
980
|
-
const body = await readBody(req).catch(() => ({}));
|
|
981
|
-
const ticket = typeof body.id === "string" && typeof body.origin === "string" ? tickets.issue(body.id, body.origin) : null;
|
|
982
|
-
return ticket ? send(res, 200, { ticket }) : send(res, 400, { error: "a terminal id and a page origin on this machine" });
|
|
983
|
-
}
|
|
984
|
-
const m = url.pathname.match(PTY_PATH);
|
|
985
|
-
if (m) {
|
|
986
|
-
const id = decodeURIComponent(m[1]);
|
|
987
|
-
if (m[2] === "/screen" && req.method === "GET") {
|
|
988
|
-
const text = registry.screen(id);
|
|
989
|
-
return text === null ? send(res, 404, { error: "not found" }) : send(res, 200, { text });
|
|
990
|
-
}
|
|
991
|
-
if (m[2] === "/restart" && req.method === "POST") {
|
|
992
|
-
const body = await readBody(req).catch(() => ({}));
|
|
993
|
-
const agentEnv = isEnvDelta(body.agentEnv) ? body.agentEnv : void 0;
|
|
994
|
-
const info3 = await registry.restart(id, void 0, agentEnv);
|
|
995
|
-
return info3 ? send(res, 200, agentEnv ? { ...info3, agentEnvApplied: true } : info3) : send(res, 409, { error: "not running" });
|
|
996
|
-
}
|
|
997
|
-
if (m[2] === "/halt" && req.method === "POST") {
|
|
998
|
-
const info3 = await registry.halt(id);
|
|
999
|
-
return info3 ? send(res, 200, info3) : send(res, 409, { error: "not running" });
|
|
1000
|
-
}
|
|
1001
|
-
if (m[2] === "/resume" && req.method === "POST") {
|
|
1002
|
-
const body = await readBody(req).catch(() => ({}));
|
|
1003
|
-
const info3 = await registry.resume(id, isEnvDelta(body.agentEnv) ? body.agentEnv : void 0);
|
|
1004
|
-
return info3 ? send(res, 200, info3) : send(res, 409, { error: "not halted" });
|
|
1005
|
-
}
|
|
1006
|
-
if (m[2] === "/write" && req.method === "POST") {
|
|
1007
|
-
const body = await readBody(req);
|
|
1008
|
-
if (typeof body.data !== "string") return send(res, 400, { error: "data required" });
|
|
1009
|
-
return send(res, registry.write(id, body.data) ? 200 : 404, {});
|
|
1010
|
-
}
|
|
1011
|
-
if (!m[2] && req.method === "POST") {
|
|
1012
|
-
const spec = await readBody(req);
|
|
1013
|
-
if (!isSpawnSpec(spec)) return send(res, 400, { error: "invalid spawn spec" });
|
|
1014
|
-
if (!fs3.existsSync(spec.cwd)) return send(res, 400, { error: "cwd does not exist" });
|
|
1015
|
-
return send(res, 200, registry.spawn(id, spec));
|
|
1016
|
-
}
|
|
1017
|
-
if (!m[2] && req.method === "GET") {
|
|
1018
|
-
const info3 = registry.get(id);
|
|
1019
|
-
return info3 ? send(res, 200, info3) : send(res, 404, { error: "not found" });
|
|
1020
|
-
}
|
|
1021
|
-
if (!m[2] && req.method === "DELETE") {
|
|
1022
|
-
await registry.kill(id);
|
|
1023
|
-
return send(res, 200, {});
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
return send(res, 404, { error: "not found" });
|
|
1027
|
-
} catch (err) {
|
|
1028
|
-
return send(res, 500, { error: err.message });
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
const wss = new WebSocketServer({ noServer: true });
|
|
1032
|
-
server.on("upgrade", (req, socket, head) => {
|
|
1033
|
-
const url = new URL(req.url ?? "/", "http://localhost");
|
|
1034
|
-
const m = (req.url ?? "").match(ATTACH_PATH);
|
|
1035
|
-
const id = m ? decodeURIComponent(m[1]) : "";
|
|
1036
|
-
const ticket = url.searchParams.get("ticket");
|
|
1037
|
-
const ok = !!m && (ticket ? !!req.headers.host && allowedHosts.has(req.headers.host) && tickets.redeem(ticket, id, req.headers.origin) : authorized(req, url));
|
|
1038
|
-
if (!ok) {
|
|
1039
|
-
socket.destroy();
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
1043
|
-
const attached = registry.attach(
|
|
1044
|
-
id,
|
|
1045
|
-
(data) => {
|
|
1046
|
-
try {
|
|
1047
|
-
ws.send(Buffer.from(data, "utf-8"), { binary: true });
|
|
1048
|
-
} catch {
|
|
1049
|
-
}
|
|
1050
|
-
},
|
|
1051
|
-
(code) => {
|
|
1052
|
-
try {
|
|
1053
|
-
ws.send(JSON.stringify({ type: "exit", code }));
|
|
1054
|
-
ws.close(1e3);
|
|
1055
|
-
} catch {
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
);
|
|
1059
|
-
if (!attached) {
|
|
1060
|
-
try {
|
|
1061
|
-
ws.send(JSON.stringify({ type: "error", message: "no such pty" }));
|
|
1062
|
-
ws.close(1011);
|
|
1063
|
-
} catch {
|
|
1064
|
-
}
|
|
1065
|
-
return;
|
|
1066
|
-
}
|
|
1067
|
-
void attached.ready.then((replay) => {
|
|
1068
|
-
try {
|
|
1069
|
-
ws.send(JSON.stringify({ type: "replay", ...replay }));
|
|
1070
|
-
} catch {
|
|
1071
|
-
}
|
|
1072
|
-
if (attached.exitedWith !== null) {
|
|
1073
|
-
try {
|
|
1074
|
-
ws.send(JSON.stringify({ type: "exit", code: attached.exitedWith }));
|
|
1075
|
-
ws.close(1e3);
|
|
1076
|
-
} catch {
|
|
1077
|
-
}
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
attached.start();
|
|
1081
|
-
});
|
|
1082
|
-
if (attached.exitedWith !== null) return;
|
|
1083
|
-
let size = null;
|
|
1084
|
-
ws.on("message", (raw, isBinary) => {
|
|
1085
|
-
if (isBinary) return;
|
|
1086
|
-
let msg;
|
|
1087
|
-
try {
|
|
1088
|
-
msg = JSON.parse(raw.toString("utf-8"));
|
|
1089
|
-
} catch {
|
|
1090
|
-
return;
|
|
1091
|
-
}
|
|
1092
|
-
if (msg.type === "input" && typeof msg.data === "string") {
|
|
1093
|
-
if (size && !isTerminalReply(msg.data)) registry.resize(id, size.cols, size.rows);
|
|
1094
|
-
registry.write(id, msg.data);
|
|
1095
|
-
} else if (msg.type === "resize" && Number.isInteger(msg.cols) && Number.isInteger(msg.rows)) {
|
|
1096
|
-
size = { cols: msg.cols, rows: msg.rows };
|
|
1097
|
-
registry.resize(id, msg.cols, msg.rows);
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
ws.on("close", () => attached.detach());
|
|
1101
|
-
ws.on("error", () => attached.detach());
|
|
1102
|
-
});
|
|
1103
|
-
});
|
|
1104
|
-
await new Promise((resolve, reject) => {
|
|
1105
|
-
server.once("error", reject);
|
|
1106
|
-
server.listen(0, "127.0.0.1", () => resolve());
|
|
1107
|
-
});
|
|
1108
|
-
const port = server.address().port;
|
|
1109
|
-
allowedHosts = /* @__PURE__ */ new Set([`127.0.0.1:${port}`, `localhost:${port}`]);
|
|
1110
|
-
const info2 = { pid: process.pid, port, token, version: PROTOCOL_VERSION };
|
|
1111
|
-
if (opts.writeInfo !== false) {
|
|
1112
|
-
atomicWriteFile(hostInfoPath(), JSON.stringify(info2));
|
|
1113
|
-
}
|
|
1114
|
-
if (opts.restore !== false) {
|
|
1115
|
-
if (!opts.registry) {
|
|
1116
|
-
const adopted = bestEffort("adopt the old pty-sessions.json", () => adoptLegacyRestoreList(), null);
|
|
1117
|
-
if (adopted !== null && adopted !== void 0)
|
|
1118
|
-
report("info", `[pty-host] adopted ${adopted} session(s) from an older host's pty-sessions.json`);
|
|
1119
|
-
}
|
|
1120
|
-
await registry.restore();
|
|
1121
|
-
}
|
|
1122
|
-
return {
|
|
1123
|
-
info: info2,
|
|
1124
|
-
registry,
|
|
1125
|
-
async stop() {
|
|
1126
|
-
registry.disposeAllKeepingState();
|
|
1127
|
-
for (const c of wss.clients) c.terminate();
|
|
1128
|
-
wss.close();
|
|
1129
|
-
server.closeAllConnections();
|
|
1130
|
-
await new Promise((r) => server.close(() => r()));
|
|
1131
|
-
if (opts.writeInfo !== false) {
|
|
1132
|
-
try {
|
|
1133
|
-
const cur = JSON.parse(fs3.readFileSync(hostInfoPath(), "utf-8"));
|
|
1134
|
-
if (cur.pid === process.pid) fs3.unlinkSync(hostInfoPath());
|
|
1135
|
-
} catch {
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
// src/commands/pty-host.ts
|
|
1143
|
-
function info(message) {
|
|
1144
|
-
process.stderr.write(message + "\n");
|
|
1145
|
-
}
|
|
1146
|
-
async function printStatus() {
|
|
1147
|
-
let host;
|
|
1148
|
-
try {
|
|
1149
|
-
host = await findHost();
|
|
1150
|
-
} catch (err) {
|
|
1151
|
-
if (err instanceof PtyHostVersionError || err instanceof PtyHostBusyError) {
|
|
1152
|
-
info(chalk.yellow(err.message));
|
|
1153
|
-
return;
|
|
1154
|
-
}
|
|
1155
|
-
throw err;
|
|
1156
|
-
}
|
|
1157
|
-
if (!host) {
|
|
1158
|
-
info(chalk.gray("No PTY host running."));
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
const ptys = await new PtyHostClient(host).list();
|
|
1162
|
-
const names = new Map(loadHistory().map((s) => [sessionIdFor(s), `${s.target} \xB7 ${s.branch}`]));
|
|
1163
|
-
info(chalk.gray(`PTY host PID ${host.pid}, port ${host.port} \u2014 ${ptys.length} session(s)`));
|
|
1164
|
-
for (const p of ptys) {
|
|
1165
|
-
const state = p.exited ? chalk.red("exited") : chalk.green("live");
|
|
1166
|
-
const tag = p.restored ? chalk.gray(" (restored)") : "";
|
|
1167
|
-
info(` ${state} ${names.get(p.id) ?? p.id}${tag} ${chalk.gray(p.cwd)}`);
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
var ptyHostCommand = {
|
|
1171
|
-
command: "pty-host",
|
|
1172
|
-
describe: false,
|
|
1173
|
-
// internal — started on demand by `work web` / `work attach`
|
|
1174
|
-
builder: (yargs) => yargs.option("stop", { type: "boolean", default: false, describe: "Stop the PTY host (sessions restore on next start)." }).option("restart", { type: "boolean", default: false, describe: "Restart the PTY host, e.g. after upgrading work." }).option("status", { type: "boolean", default: false, describe: "List the sessions the PTY host owns." }).option("force", {
|
|
1175
|
-
type: "boolean",
|
|
1176
|
-
default: false,
|
|
1177
|
-
describe: "With --stop/--restart: also stop a host that doesn't answer (hung), once it proves to be work's PTY host."
|
|
1178
|
-
}),
|
|
1179
|
-
handler: async (argv) => {
|
|
1180
|
-
if (argv.status) {
|
|
1181
|
-
await printStatus();
|
|
1182
|
-
return;
|
|
1183
|
-
}
|
|
1184
|
-
if (argv.stop || argv.restart) {
|
|
1185
|
-
const outcome = await stopHost(killTree, 5e3, { force: argv.force });
|
|
1186
|
-
info(
|
|
1187
|
-
chalk.gray(
|
|
1188
|
-
{
|
|
1189
|
-
stopped: "Stopped the PTY host.",
|
|
1190
|
-
"not-running": "No PTY host running.",
|
|
1191
|
-
"stale-file": "No PTY host running (removed a stale discovery file; nothing was killed).",
|
|
1192
|
-
unresponsive: argv.force ? "The PTY host is not responding, and its process doesn't look like work's PTY host: nothing was stopped." : "The PTY host is not responding (busy, or hung). Nothing was stopped \u2014 try again in a moment, or add --force to stop a hung one.",
|
|
1193
|
-
failed: "Could not stop the PTY host."
|
|
1194
|
-
}[outcome]
|
|
1195
|
-
)
|
|
1196
|
-
);
|
|
1197
|
-
if (outcome === "failed" || outcome === "unresponsive") {
|
|
1198
|
-
process.exitCode = 1;
|
|
1199
|
-
return;
|
|
1200
|
-
}
|
|
1201
|
-
if (argv.stop) return;
|
|
1202
|
-
await new Promise((r) => setTimeout(r, 500));
|
|
1203
|
-
const host = await ensureHost(resolveWorkBinPath(process.argv[1]));
|
|
1204
|
-
info(chalk.gray(`PTY host restarted (PID ${host.pid}); sessions are being restored.`));
|
|
1205
|
-
return;
|
|
1206
|
-
}
|
|
1207
|
-
const lock = hostStartLockPath();
|
|
1208
|
-
ensureFile(lock, "");
|
|
1209
|
-
const handle = await withFileLock(lock, async () => {
|
|
1210
|
-
const running = await findHost().catch(
|
|
1211
|
-
(err) => err instanceof PtyHostVersionError || err instanceof PtyHostBusyError ? true : null
|
|
1212
|
-
);
|
|
1213
|
-
if (running) return null;
|
|
1214
|
-
ensureAgentPath();
|
|
1215
|
-
return startPtyHost();
|
|
1216
|
-
});
|
|
1217
|
-
if (!handle) {
|
|
1218
|
-
info(chalk.gray("PTY host already running."));
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
info(chalk.gray(`PTY host listening on 127.0.0.1:${handle.info.port} (PID ${process.pid})`));
|
|
1222
|
-
const shutdown = () => {
|
|
1223
|
-
void handle.stop().finally(() => process.exit(0));
|
|
1224
|
-
};
|
|
1225
|
-
process.on("SIGINT", shutdown);
|
|
1226
|
-
process.on("SIGTERM", shutdown);
|
|
1227
|
-
await new Promise(() => {
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
};
|
|
1231
|
-
export {
|
|
1232
|
-
ptyHostCommand,
|
|
1233
|
-
stopHost
|
|
1234
|
-
};
|
|
1235
|
-
//# sourceMappingURL=pty-host-EAWW62U4.js.map
|