@moberg_hr/work-tree 2.7.0 → 2.8.0
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-SOJAHTL5.js +245 -0
- package/dist/account-SOJAHTL5.js.map +1 -0
- package/dist/{add-repo-E7KWNJJV.js → add-repo-B4ITRH4Q.js} +26 -22
- package/dist/{add-repo-E7KWNJJV.js.map → add-repo-B4ITRH4Q.js.map} +1 -1
- package/dist/{answer-2CBOWCL5.js → answer-JHK4SZAH.js} +15 -12
- package/dist/{answer-2CBOWCL5.js.map → answer-JHK4SZAH.js.map} +1 -1
- package/dist/{attach-AWRY4LSI.js → attach-3IU7O7YE.js} +19 -16
- package/dist/{attach-AWRY4LSI.js.map → attach-3IU7O7YE.js.map} +1 -1
- package/dist/bin.js +7 -5
- package/dist/bin.js.map +1 -1
- package/dist/{block-JTJX5QIO.js → block-JTA7ULQS.js} +15 -12
- package/dist/{block-JTJX5QIO.js.map → block-JTA7ULQS.js.map} +1 -1
- package/dist/{broadcast-3SF55HA6.js → broadcast-JKPTCLUZ.js} +12 -9
- package/dist/{broadcast-3SF55HA6.js.map → broadcast-JKPTCLUZ.js.map} +1 -1
- package/dist/{catchup-2WNHEMLD.js → catchup-MT55LLAS.js} +18 -15
- package/dist/{catchup-2WNHEMLD.js.map → catchup-MT55LLAS.js.map} +1 -1
- package/dist/{chunk-TPPTL7LA.js → chunk-26MWJLDS.js} +3 -3
- package/dist/{chunk-ZNXACRZ5.js → chunk-27BDXWSY.js} +9 -5
- package/dist/{chunk-ZNXACRZ5.js.map → chunk-27BDXWSY.js.map} +1 -1
- package/dist/{chunk-5GA3PFK5.js → chunk-27UC5NXT.js} +13 -9
- package/dist/chunk-27UC5NXT.js.map +1 -0
- package/dist/{chunk-KUVL75PL.js → chunk-2MQWAQ2D.js} +8 -8
- package/dist/{chunk-O34CKSE4.js → chunk-3N3UQEC4.js} +2 -2
- package/dist/{chunk-EPNYZJMM.js → chunk-3TN77GOI.js} +9 -6
- package/dist/chunk-3TN77GOI.js.map +1 -0
- package/dist/{chunk-J5CMORVD.js → chunk-45DVD6HF.js} +15 -11
- package/dist/{chunk-J5CMORVD.js.map → chunk-45DVD6HF.js.map} +1 -1
- package/dist/chunk-4NITDMDH.js +372 -0
- package/dist/chunk-4NITDMDH.js.map +1 -0
- package/dist/{chunk-SNRP2MC3.js → chunk-5QGCF3PS.js} +2 -2
- package/dist/chunk-6THUVP6T.js +118 -0
- package/dist/chunk-6THUVP6T.js.map +1 -0
- package/dist/{chunk-MCSEYS2J.js → chunk-7GGIVYWP.js} +5 -5
- package/dist/{chunk-WIWO3YWP.js → chunk-7NVEGPZT.js} +2 -2
- package/dist/{chunk-JIYGGN2N.js → chunk-AU27USPZ.js} +2 -2
- package/dist/chunk-BOEAOIQT.js +43 -0
- package/dist/chunk-BOEAOIQT.js.map +1 -0
- package/dist/{chunk-5BNNPXID.js → chunk-BUX66OI7.js} +4 -4
- package/dist/{chunk-W4YWFAYC.js → chunk-C4T3F3XO.js} +4 -4
- package/dist/{chunk-QGKJXCEJ.js → chunk-CI4EAIMR.js} +19 -13
- package/dist/chunk-CI4EAIMR.js.map +1 -0
- package/dist/chunk-DJ2X4LKE.js +9 -0
- package/dist/{chunk-FUNZ7TOS.js → chunk-F6M255O5.js} +534 -121
- package/dist/chunk-F6M255O5.js.map +1 -0
- package/dist/chunk-FDKJFIUU.js +169 -0
- package/dist/chunk-FDKJFIUU.js.map +1 -0
- package/dist/{chunk-USUQYM6V.js → chunk-FMCSF2QB.js} +58 -54
- package/dist/chunk-FMCSF2QB.js.map +1 -0
- package/dist/{chunk-YNHIMOE7.js → chunk-GNGXYXBC.js} +2 -2
- package/dist/{chunk-C5HPSURF.js → chunk-HN2QQMMX.js} +12 -12
- package/dist/{chunk-KU63EHZO.js → chunk-ICJPVSRY.js} +2 -2
- package/dist/{chunk-ZS6F6JLC.js → chunk-IRKYLDMX.js} +88 -12
- package/dist/chunk-IRKYLDMX.js.map +1 -0
- package/dist/{chunk-LDFICXOZ.js → chunk-IWO4DILT.js} +10 -6
- package/dist/{chunk-LDFICXOZ.js.map → chunk-IWO4DILT.js.map} +1 -1
- package/dist/{chunk-B2HUKRWX.js → chunk-IXC7JM35.js} +4 -4
- package/dist/{chunk-UHYIB6AV.js → chunk-J2AZIO22.js} +2 -2
- package/dist/{chunk-VEKEA3ER.js → chunk-J36ULZBO.js} +2 -2
- package/dist/{chunk-4PRPDACI.js → chunk-JU5T3JIN.js} +10 -7
- package/dist/chunk-JU5T3JIN.js.map +1 -0
- package/dist/{chunk-3UHKPHTB.js → chunk-KH3TRWUV.js} +4 -4
- package/dist/{chunk-DYJ4VJJD.js → chunk-KLY6QDA5.js} +8 -33
- package/dist/chunk-KLY6QDA5.js.map +1 -0
- package/dist/{chunk-TBY6ZFAV.js → chunk-KNRGVUW7.js} +3 -3
- package/dist/{chunk-TTTIKTNR.js → chunk-LKZSPHAT.js} +2 -2
- package/dist/{chunk-5WEDCEZG.js → chunk-LXU24GCM.js} +5 -5
- package/dist/{chunk-CFLMBFBO.js → chunk-M6LJ3GE3.js} +76 -10
- package/dist/chunk-M6LJ3GE3.js.map +1 -0
- package/dist/{chunk-BVJ2ZE7B.js → chunk-MJGKE7XZ.js} +34 -13
- package/dist/chunk-MJGKE7XZ.js.map +1 -0
- package/dist/{chunk-3PLWNCRM.js → chunk-MMFXUIQQ.js} +2 -2
- package/dist/{chunk-YJ4CAD3X.js → chunk-MXA2RZBC.js} +5 -5
- package/dist/{chunk-OFCY7RCM.js → chunk-MZTPKKTO.js} +4 -4
- package/dist/{chunk-2IKWNRMV.js → chunk-NMAJM3C5.js} +3 -3
- package/dist/{chunk-W7WC7UA2.js → chunk-NPCBJV7T.js} +5 -5
- package/dist/{chunk-BHU26CNH.js → chunk-OAVHTRML.js} +6 -4
- package/dist/{chunk-BHU26CNH.js.map → chunk-OAVHTRML.js.map} +1 -1
- package/dist/{chunk-46UTKL5L.js → chunk-OMIMK3LB.js} +2 -2
- package/dist/chunk-P2HOLCBF.js +34 -0
- package/dist/chunk-P2HOLCBF.js.map +1 -0
- package/dist/{chunk-PUTZR6F5.js → chunk-P4EQWC5W.js} +2 -2
- package/dist/{chunk-MGQK6BWH.js → chunk-QLAVWIDJ.js} +35 -18
- package/dist/chunk-QLAVWIDJ.js.map +1 -0
- package/dist/{chunk-ZMCU2PZN.js → chunk-RCGFHJM7.js} +5 -3
- package/dist/chunk-RCGFHJM7.js.map +1 -0
- package/dist/{chunk-G2FE7HUB.js → chunk-RGUSVBGN.js} +2 -2
- package/dist/{chunk-R3DASZQF.js → chunk-S3BAD4IR.js} +2 -2
- package/dist/{chunk-LQXGNO5X.js → chunk-SDQI3QB3.js} +3 -3
- package/dist/{chunk-B7C3RYSJ.js → chunk-SG5LUMGE.js} +3 -3
- package/dist/{chunk-5XSY3C6E.js → chunk-UBOKRHNV.js} +13 -13
- package/dist/chunk-UBOKRHNV.js.map +1 -0
- package/dist/chunk-UESDYZG3.js +442 -0
- package/dist/chunk-UESDYZG3.js.map +1 -0
- package/dist/{chunk-PIKOCEWX.js → chunk-WTF4CYHH.js} +5 -5
- package/dist/{chunk-DO5NW46X.js → chunk-X4AXKO3A.js} +2 -2
- package/dist/{chunk-KE2TFF7B.js → chunk-XNLQSW6J.js} +23 -212
- package/dist/chunk-XNLQSW6J.js.map +1 -0
- package/dist/{chunk-ZGPWIBSZ.js → chunk-YEXW2OCN.js} +9 -34
- package/dist/chunk-YEXW2OCN.js.map +1 -0
- package/dist/{chunk-AFW7HREX.js → chunk-YKMURNKL.js} +9 -41
- package/dist/chunk-YKMURNKL.js.map +1 -0
- package/dist/{chunk-LWKFZOCJ.js → chunk-YRW4YF4U.js} +3 -3
- package/dist/{chunk-COKQPFLB.js → chunk-YYBXQBW2.js} +3 -3
- package/dist/{chunk-3JY3QT4J.js → chunk-YZPP6354.js} +5 -5
- package/dist/chunk-ZDMJPEBO.js +31 -0
- package/dist/chunk-ZDMJPEBO.js.map +1 -0
- package/dist/chunk-ZXHMC7UO.js +106 -0
- package/dist/chunk-ZXHMC7UO.js.map +1 -0
- package/dist/{cleanup-PWN4XZ2F.js → cleanup-PNTCVB2S.js} +31 -27
- package/dist/{cleanup-PWN4XZ2F.js.map → cleanup-PNTCVB2S.js.map} +1 -1
- package/dist/cli-OYO6OXNK.js +19 -0
- package/dist/{command-hook-installer-RJH5QLCD.js → command-hook-installer-7Q7UD7AU.js} +9 -8
- package/dist/command-hook-installer-7Q7UD7AU.js.map +1 -0
- package/dist/{config-KGDVJKQN.js → config-VILJYT6P.js} +19 -15
- package/dist/{config-KGDVJKQN.js.map → config-VILJYT6P.js.map} +1 -1
- package/dist/{diff-ZORXBJDI.js → diff-J6VRJYKR.js} +16 -13
- package/dist/{diff-ZORXBJDI.js.map → diff-J6VRJYKR.js.map} +1 -1
- package/dist/{digest-PUUBJTD3.js → digest-GMJLCYTF.js} +14 -11
- package/dist/{digest-PUUBJTD3.js.map → digest-GMJLCYTF.js.map} +1 -1
- package/dist/{fork-7L76HZAS.js → fork-NNHH2BXV.js} +27 -24
- package/dist/{fork-7L76HZAS.js.map → fork-NNHH2BXV.js.map} +1 -1
- package/dist/{history-YX74IRQY.js → history-52MGO5V5.js} +13 -8
- package/dist/{hook-JCD6SDB3.js → hook-SWX7NXJN.js} +20 -19
- package/dist/{hook-JCD6SDB3.js.map → hook-SWX7NXJN.js.map} +1 -1
- package/dist/{hydrate-W4V5RJYU.js → hydrate-F5XVXZ2T.js} +14 -11
- package/dist/{hydrate-W4V5RJYU.js.map → hydrate-F5XVXZ2T.js.map} +1 -1
- package/dist/{init-5MMV2UF5.js → init-MRGRQWQM.js} +14 -11
- package/dist/{init-5MMV2UF5.js.map → init-MRGRQWQM.js.map} +1 -1
- package/dist/install-skills-QTWYVAOZ.js +20 -0
- package/dist/install-skills-bin.js +9 -5
- package/dist/install-skills-bin.js.map +1 -1
- package/dist/{list-ZS3UWOGJ.js → list-5MMNVGNN.js} +14 -11
- package/dist/{list-ZS3UWOGJ.js.map → list-5MMNVGNN.js.map} +1 -1
- package/dist/{move-ZTL7HAIU.js → move-DUYNTJP2.js} +42 -18
- package/dist/move-DUYNTJP2.js.map +1 -0
- package/dist/{note-B4FVZGJJ.js → note-SZCVRH4D.js} +15 -12
- package/dist/{note-B4FVZGJJ.js.map → note-SZCVRH4D.js.map} +1 -1
- package/dist/{overlaps-W3BLUG53.js → overlaps-QANRNFZC.js} +13 -10
- package/dist/{overlaps-W3BLUG53.js.map → overlaps-QANRNFZC.js.map} +1 -1
- package/dist/{pin-YYQV5OPS.js → pin-UZGC26LU.js} +15 -12
- package/dist/{pin-YYQV5OPS.js.map → pin-UZGC26LU.js.map} +1 -1
- package/dist/{pr-HQTMQOF5.js → pr-EKNBGR6X.js} +15 -12
- package/dist/{pr-HQTMQOF5.js.map → pr-EKNBGR6X.js.map} +1 -1
- package/dist/{prune-6BYOFOUR.js → prune-AOR4R3CT.js} +29 -26
- package/dist/{prune-6BYOFOUR.js.map → prune-AOR4R3CT.js.map} +1 -1
- package/dist/{pty-host-KSS45FVH.js → pty-host-LYE546KI.js} +142 -37
- package/dist/pty-host-LYE546KI.js.map +1 -0
- package/dist/{read-I5TGSBPC.js → read-APEM6NPD.js} +14 -11
- package/dist/{read-I5TGSBPC.js.map → read-APEM6NPD.js.map} +1 -1
- package/dist/{recent-GRKJEEKT.js → recent-N7JQCDRG.js} +22 -12
- package/dist/recent-N7JQCDRG.js.map +1 -0
- package/dist/{remove-64T6TMOE.js → remove-QM5CRMEG.js} +28 -25
- package/dist/{remove-64T6TMOE.js.map → remove-QM5CRMEG.js.map} +1 -1
- package/dist/{report-KAS2UEXO.js → report-J7TUQRJS.js} +3 -3
- package/dist/{restart-WJROWFMU.js → restart-O6DYGEMN.js} +15 -12
- package/dist/{restart-WJROWFMU.js.map → restart-O6DYGEMN.js.map} +1 -1
- package/dist/{resume-634R6KNE.js → resume-P5DQOZ2R.js} +16 -12
- package/dist/resume-P5DQOZ2R.js.map +1 -0
- package/dist/{run-57LGOBXQ.js → run-PSGYELSP.js} +11 -8
- package/dist/{run-57LGOBXQ.js.map → run-PSGYELSP.js.map} +1 -1
- package/dist/{screen-CX7WUVXM.js → screen-EBITKGXW.js} +15 -12
- package/dist/{screen-CX7WUVXM.js.map → screen-EBITKGXW.js.map} +1 -1
- package/dist/{search-JYAQWT6A.js → search-MM35D6P4.js} +11 -8
- package/dist/{search-JYAQWT6A.js.map → search-MM35D6P4.js.map} +1 -1
- package/dist/{section-4FICXE46.js → section-6C6N7KKF.js} +15 -12
- package/dist/{section-4FICXE46.js.map → section-6C6N7KKF.js.map} +1 -1
- package/dist/{send-RRTPY47A.js → send-ASTESOMV.js} +16 -13
- package/dist/{send-RRTPY47A.js.map → send-ASTESOMV.js.map} +1 -1
- package/dist/{sessions-UJNUCYND.js → sessions-JTZF776H.js} +21 -18
- package/dist/{sessions-UJNUCYND.js.map → sessions-JTZF776H.js.map} +1 -1
- package/dist/{snooze-DJEPOBT5.js → snooze-M2IOYZSD.js} +14 -11
- package/dist/{snooze-DJEPOBT5.js.map → snooze-M2IOYZSD.js.map} +1 -1
- package/dist/{start-YPEN5QI3.js → start-HIBG7DYS.js} +15 -12
- package/dist/{start-YPEN5QI3.js.map → start-HIBG7DYS.js.map} +1 -1
- package/dist/{state-UAW6DWWU.js → state-DC73V5TS.js} +6 -4
- package/dist/{state-UAW6DWWU.js.map → state-DC73V5TS.js.map} +1 -1
- package/dist/{status-4EOTN33T.js → status-JSM6FETL.js} +13 -10
- package/dist/{status-4EOTN33T.js.map → status-JSM6FETL.js.map} +1 -1
- package/dist/{statusline-EUT6VZLP.js → statusline-A2DTGLK5.js} +40 -28
- package/dist/statusline-A2DTGLK5.js.map +1 -0
- package/dist/statusline-hook-OVWHHFBV.js +63 -0
- package/dist/statusline-hook-OVWHHFBV.js.map +1 -0
- package/dist/{stop-3UNZ22YA.js → stop-IEMNFVGW.js} +15 -12
- package/dist/{stop-3UNZ22YA.js.map → stop-IEMNFVGW.js.map} +1 -1
- package/dist/{sync-XXZBP6PK.js → sync-FP4J5ODY.js} +29 -26
- package/dist/{sync-XXZBP6PK.js.map → sync-FP4J5ODY.js.map} +1 -1
- package/dist/{time-G5Z57AE5.js → time-QHLGCYPZ.js} +17 -14
- package/dist/{time-G5Z57AE5.js.map → time-QHLGCYPZ.js.map} +1 -1
- package/dist/time-actions-4YP5DZKQ.js +16 -0
- package/dist/{timesheet-NA7NQUVR.js → timesheet-LSUOCD6V.js} +19 -16
- package/dist/{timesheet-NA7NQUVR.js.map → timesheet-LSUOCD6V.js.map} +1 -1
- package/dist/{todo-V7EVWHF2.js → todo-4VTGOCKH.js} +7 -5
- package/dist/{todo-V7EVWHF2.js.map → todo-4VTGOCKH.js.map} +1 -1
- package/dist/{tree-R5YXQTP7.js → tree-VTQRBC7I.js} +41 -30
- package/dist/tree-VTQRBC7I.js.map +1 -0
- package/dist/{update-B3MQXQJ6.js → update-VL67LR6U.js} +16 -13
- package/dist/{update-B3MQXQJ6.js.map → update-VL67LR6U.js.map} +1 -1
- package/dist/{usage-2HE4RSVM.js → usage-EMZVZZEQ.js} +18 -13
- package/dist/usage-EMZVZZEQ.js.map +1 -0
- package/dist/{wait-2OPYJO3K.js → wait-HQTY7OW5.js} +15 -12
- package/dist/{wait-2OPYJO3K.js.map → wait-HQTY7OW5.js.map} +1 -1
- package/dist/wd-bin.js +8 -6
- package/dist/wd-bin.js.map +1 -1
- package/dist/web/assets/{PtyView-DgdSx6WG.js → PtyView-BMRi1NT9.js} +2 -2
- package/dist/web/assets/{PtyView-DgdSx6WG.js.map → PtyView-BMRi1NT9.js.map} +1 -1
- package/dist/web/assets/{index-C5JNhi3-.css → index-BCCeJjez.css} +1 -1
- package/dist/web/assets/index-By_qebb-.js +119 -0
- package/dist/web/assets/index-By_qebb-.js.map +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-QXQ4NGCJ.js → web-6QSSPH4I.js} +319 -253
- package/dist/web-6QSSPH4I.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/chunk-3Q5RZCQW.js +0 -9
- package/dist/chunk-3ZGZNZTY.js +0 -134
- package/dist/chunk-3ZGZNZTY.js.map +0 -1
- package/dist/chunk-4PRPDACI.js.map +0 -1
- package/dist/chunk-5GA3PFK5.js.map +0 -1
- package/dist/chunk-5XSY3C6E.js.map +0 -1
- package/dist/chunk-AFW7HREX.js.map +0 -1
- package/dist/chunk-BVJ2ZE7B.js.map +0 -1
- package/dist/chunk-CFLMBFBO.js.map +0 -1
- package/dist/chunk-DYJ4VJJD.js.map +0 -1
- package/dist/chunk-EPNYZJMM.js.map +0 -1
- package/dist/chunk-FUNZ7TOS.js.map +0 -1
- package/dist/chunk-KE2TFF7B.js.map +0 -1
- package/dist/chunk-MGQK6BWH.js.map +0 -1
- package/dist/chunk-QGKJXCEJ.js.map +0 -1
- package/dist/chunk-TUFQJXXO.js +0 -19
- package/dist/chunk-TUFQJXXO.js.map +0 -1
- package/dist/chunk-USUQYM6V.js.map +0 -1
- package/dist/chunk-VMBWCDBA.js +0 -186
- package/dist/chunk-VMBWCDBA.js.map +0 -1
- package/dist/chunk-ZGPWIBSZ.js.map +0 -1
- package/dist/chunk-ZMCU2PZN.js.map +0 -1
- package/dist/chunk-ZS6F6JLC.js.map +0 -1
- package/dist/cli-UTID323G.js +0 -17
- package/dist/command-hook-installer-RJH5QLCD.js.map +0 -1
- package/dist/install-skills-7EHZBANC.js +0 -16
- package/dist/move-ZTL7HAIU.js.map +0 -1
- package/dist/pty-host-KSS45FVH.js.map +0 -1
- package/dist/recent-GRKJEEKT.js.map +0 -1
- package/dist/resume-634R6KNE.js.map +0 -1
- package/dist/statusline-EUT6VZLP.js.map +0 -1
- package/dist/statusline-hook-TZ7M762P.js +0 -118
- package/dist/statusline-hook-TZ7M762P.js.map +0 -1
- package/dist/time-actions-H5WCOYZG.js +0 -14
- package/dist/tree-R5YXQTP7.js.map +0 -1
- package/dist/usage-2HE4RSVM.js.map +0 -1
- package/dist/web/assets/index-O8yTaaWX.js +0 -119
- package/dist/web/assets/index-O8yTaaWX.js.map +0 -1
- package/dist/web-QXQ4NGCJ.js.map +0 -1
- /package/dist/{chunk-TPPTL7LA.js.map → chunk-26MWJLDS.js.map} +0 -0
- /package/dist/{chunk-KUVL75PL.js.map → chunk-2MQWAQ2D.js.map} +0 -0
- /package/dist/{chunk-O34CKSE4.js.map → chunk-3N3UQEC4.js.map} +0 -0
- /package/dist/{chunk-SNRP2MC3.js.map → chunk-5QGCF3PS.js.map} +0 -0
- /package/dist/{chunk-MCSEYS2J.js.map → chunk-7GGIVYWP.js.map} +0 -0
- /package/dist/{chunk-WIWO3YWP.js.map → chunk-7NVEGPZT.js.map} +0 -0
- /package/dist/{chunk-JIYGGN2N.js.map → chunk-AU27USPZ.js.map} +0 -0
- /package/dist/{chunk-5BNNPXID.js.map → chunk-BUX66OI7.js.map} +0 -0
- /package/dist/{chunk-W4YWFAYC.js.map → chunk-C4T3F3XO.js.map} +0 -0
- /package/dist/{chunk-3Q5RZCQW.js.map → chunk-DJ2X4LKE.js.map} +0 -0
- /package/dist/{chunk-YNHIMOE7.js.map → chunk-GNGXYXBC.js.map} +0 -0
- /package/dist/{chunk-C5HPSURF.js.map → chunk-HN2QQMMX.js.map} +0 -0
- /package/dist/{chunk-KU63EHZO.js.map → chunk-ICJPVSRY.js.map} +0 -0
- /package/dist/{chunk-B2HUKRWX.js.map → chunk-IXC7JM35.js.map} +0 -0
- /package/dist/{chunk-UHYIB6AV.js.map → chunk-J2AZIO22.js.map} +0 -0
- /package/dist/{chunk-VEKEA3ER.js.map → chunk-J36ULZBO.js.map} +0 -0
- /package/dist/{chunk-3UHKPHTB.js.map → chunk-KH3TRWUV.js.map} +0 -0
- /package/dist/{chunk-TBY6ZFAV.js.map → chunk-KNRGVUW7.js.map} +0 -0
- /package/dist/{chunk-TTTIKTNR.js.map → chunk-LKZSPHAT.js.map} +0 -0
- /package/dist/{chunk-5WEDCEZG.js.map → chunk-LXU24GCM.js.map} +0 -0
- /package/dist/{chunk-3PLWNCRM.js.map → chunk-MMFXUIQQ.js.map} +0 -0
- /package/dist/{chunk-YJ4CAD3X.js.map → chunk-MXA2RZBC.js.map} +0 -0
- /package/dist/{chunk-OFCY7RCM.js.map → chunk-MZTPKKTO.js.map} +0 -0
- /package/dist/{chunk-2IKWNRMV.js.map → chunk-NMAJM3C5.js.map} +0 -0
- /package/dist/{chunk-W7WC7UA2.js.map → chunk-NPCBJV7T.js.map} +0 -0
- /package/dist/{chunk-46UTKL5L.js.map → chunk-OMIMK3LB.js.map} +0 -0
- /package/dist/{chunk-PUTZR6F5.js.map → chunk-P4EQWC5W.js.map} +0 -0
- /package/dist/{chunk-G2FE7HUB.js.map → chunk-RGUSVBGN.js.map} +0 -0
- /package/dist/{chunk-R3DASZQF.js.map → chunk-S3BAD4IR.js.map} +0 -0
- /package/dist/{chunk-LQXGNO5X.js.map → chunk-SDQI3QB3.js.map} +0 -0
- /package/dist/{chunk-B7C3RYSJ.js.map → chunk-SG5LUMGE.js.map} +0 -0
- /package/dist/{chunk-PIKOCEWX.js.map → chunk-WTF4CYHH.js.map} +0 -0
- /package/dist/{chunk-DO5NW46X.js.map → chunk-X4AXKO3A.js.map} +0 -0
- /package/dist/{chunk-LWKFZOCJ.js.map → chunk-YRW4YF4U.js.map} +0 -0
- /package/dist/{chunk-COKQPFLB.js.map → chunk-YYBXQBW2.js.map} +0 -0
- /package/dist/{chunk-3JY3QT4J.js.map → chunk-YZPP6354.js.map} +0 -0
- /package/dist/{cli-UTID323G.js.map → cli-OYO6OXNK.js.map} +0 -0
- /package/dist/{history-YX74IRQY.js.map → history-52MGO5V5.js.map} +0 -0
- /package/dist/{install-skills-7EHZBANC.js.map → install-skills-QTWYVAOZ.js.map} +0 -0
- /package/dist/{report-KAS2UEXO.js.map → report-J7TUQRJS.js.map} +0 -0
- /package/dist/{time-actions-H5WCOYZG.js.map → time-actions-4YP5DZKQ.js.map} +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
atomicWriteFile
|
|
3
|
+
atomicWriteFile
|
|
4
|
+
} from "./chunk-ZXHMC7UO.js";
|
|
5
|
+
import {
|
|
4
6
|
debugLog,
|
|
5
7
|
getConfigDir
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6THUVP6T.js";
|
|
7
9
|
|
|
8
10
|
// src/core/usage/usage-store.ts
|
|
9
11
|
import fs from "fs";
|
|
@@ -76,4 +78,4 @@ export {
|
|
|
76
78
|
recordReading,
|
|
77
79
|
readReadings
|
|
78
80
|
};
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-RCGFHJM7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/usage/usage-store.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { getConfigDir } from '../platform/config-dir.js';\nimport { atomicWriteFile } from '../platform/fs-safe.js';\nimport { debugLog } from '../platform/logger.js';\nimport type { UsageAccount, UsageWindow } from './usage.js';\n\n// Readings the agents' hooks leave behind, one file per agent and account. The status-line hook calls recordReading on every refresh, so it stays cheap.\n\n/** A reading that hasn't changed is rewritten only when its time is this old: the age stays honest without a write per refresh. */\nconst REFRESH_MS = 60_000;\n\ntype Stored = Omit<UsageAccount, 'account'>;\n\nexport const usageDir = () => path.join(getConfigDir(), 'usage');\n\nconst isRecord = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);\n\nfunction isWindow(v: unknown): v is UsageWindow {\n return (\n isRecord(v) &&\n typeof v.id === 'string' &&\n typeof v.label === 'string' &&\n typeof v.usedPercent === 'number' &&\n (v.resetsAt === null || typeof v.resetsAt === 'string') &&\n (v.reset === undefined || v.reset === true)\n );\n}\n\nfunction parseStored(text: string): Stored | null {\n let v: unknown;\n try {\n v = JSON.parse(text);\n } catch {\n return null;\n }\n if (!isRecord(v) || typeof v.at !== 'string' || !Array.isArray(v.windows) || !v.windows.every(isWindow)) return null;\n return { at: v.at, windows: v.windows };\n}\n\nconst fileFor = (agent: string, account: string) => path.join(usageDir(), `${agent}-${account}.json`);\n\n/**\n * Within one window (same id, same known reset) usage only grows: an idle agent's redraw can carry an older, lower figure\n * than another session just reported, and it mustn't win.\n */\nfunction keepHigher(stored: UsageWindow[], fresh: UsageWindow[]): UsageWindow[] {\n return fresh.map((w) => {\n const was = w.resetsAt === null ? undefined : stored.find((s) => s.id === w.id && s.resetsAt === w.resetsAt);\n return was && was.usedPercent > w.usedPercent ? { ...w, usedPercent: was.usedPercent } : w;\n });\n}\n\n/** Keep a reading. Writes only when it changed (or the stored time is over a minute old); returns whether it wrote. Never throws. */\nexport function recordReading(agent: string, account: string, windows: UsageWindow[], now = Date.now()): boolean {\n if (windows.length === 0) return false;\n try {\n const file = fileFor(agent, account);\n let stored: Stored | null = null;\n try {\n stored = parseStored(fs.readFileSync(file, 'utf-8'));\n } catch {\n /* nothing stored yet */\n }\n const kept = stored ? keepHigher(stored.windows, windows) : windows;\n if (stored && JSON.stringify(stored.windows) === JSON.stringify(kept) && now - Date.parse(stored.at) < REFRESH_MS) return false;\n fs.mkdirSync(usageDir(), { recursive: true });\n atomicWriteFile(file, JSON.stringify({ at: new Date(now).toISOString(), windows: kept }));\n return true;\n } catch (e) {\n // Only the log: this runs in an agent's hook (Claude's status line), which shows nothing of ours.\n const err = e as NodeJS.ErrnoException;\n debugLog('WARN', `[usage] reading not kept: ${err.code ? `${err.code} ` : ''}${err.message ?? String(e)}`);\n return false;\n }\n}\n\n/** Every account's last reading for an agent, by account name. A file that isn't a reading is skipped. */\nexport function readReadings(agent: string): UsageAccount[] {\n let names: string[];\n try {\n names = fs.readdirSync(usageDir());\n } catch {\n return [];\n }\n const prefix = `${agent}-`;\n const out: UsageAccount[] = [];\n for (const name of names) {\n if (!name.startsWith(prefix) || !name.endsWith('.json')) continue;\n try {\n const stored = parseStored(fs.readFileSync(path.join(usageDir(), name), 'utf-8'));\n if (stored) out.push({ account: name.slice(prefix.length, -'.json'.length), ...stored });\n } catch {\n /* unreadable: skipped */\n }\n }\n return out.sort((a, b) => a.account.localeCompare(b.account));\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AASjB,IAAM,aAAa;AAIZ,IAAM,WAAW,MAAM,KAAK,KAAK,aAAa,GAAG,OAAO;AAE/D,IAAM,WAAW,CAAC,MAA6C,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAEtH,SAAS,SAAS,GAA8B;AAC9C,SACE,SAAS,CAAC,KACV,OAAO,EAAE,OAAO,YAChB,OAAO,EAAE,UAAU,YACnB,OAAO,EAAE,gBAAgB,aACxB,EAAE,aAAa,QAAQ,OAAO,EAAE,aAAa,cAC7C,EAAE,UAAU,UAAa,EAAE,UAAU;AAE1C;AAEA,SAAS,YAAY,MAA6B;AAChD,MAAI;AACJ,MAAI;AACF,QAAI,KAAK,MAAM,IAAI;AAAA,EACrB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,CAAC,SAAS,CAAC,KAAK,OAAO,EAAE,OAAO,YAAY,CAAC,MAAM,QAAQ,EAAE,OAAO,KAAK,CAAC,EAAE,QAAQ,MAAM,QAAQ,EAAG,QAAO;AAChH,SAAO,EAAE,IAAI,EAAE,IAAI,SAAS,EAAE,QAAQ;AACxC;AAEA,IAAM,UAAU,CAAC,OAAe,YAAoB,KAAK,KAAK,SAAS,GAAG,GAAG,KAAK,IAAI,OAAO,OAAO;AAMpG,SAAS,WAAW,QAAuB,OAAqC;AAC9E,SAAO,MAAM,IAAI,CAAC,MAAM;AACtB,UAAM,MAAM,EAAE,aAAa,OAAO,SAAY,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ;AAC3G,WAAO,OAAO,IAAI,cAAc,EAAE,cAAc,EAAE,GAAG,GAAG,aAAa,IAAI,YAAY,IAAI;AAAA,EAC3F,CAAC;AACH;AAGO,SAAS,cAAc,OAAe,SAAiB,SAAwB,MAAM,KAAK,IAAI,GAAY;AAC/G,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,MAAI;AACF,UAAM,OAAO,QAAQ,OAAO,OAAO;AACnC,QAAI,SAAwB;AAC5B,QAAI;AACF,eAAS,YAAY,GAAG,aAAa,MAAM,OAAO,CAAC;AAAA,IACrD,QAAQ;AAAA,IAER;AACA,UAAM,OAAO,SAAS,WAAW,OAAO,SAAS,OAAO,IAAI;AAC5D,QAAI,UAAU,KAAK,UAAU,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,KAAK,MAAM,KAAK,MAAM,OAAO,EAAE,IAAI,WAAY,QAAO;AAC1H,OAAG,UAAU,SAAS,GAAG,EAAE,WAAW,KAAK,CAAC;AAC5C,oBAAgB,MAAM,KAAK,UAAU,EAAE,IAAI,IAAI,KAAK,GAAG,EAAE,YAAY,GAAG,SAAS,KAAK,CAAC,CAAC;AACxF,WAAO;AAAA,EACT,SAAS,GAAG;AAEV,UAAM,MAAM;AACZ,aAAS,QAAQ,6BAA6B,IAAI,OAAO,GAAG,IAAI,IAAI,MAAM,EAAE,GAAG,IAAI,WAAW,OAAO,CAAC,CAAC,EAAE;AACzG,WAAO;AAAA,EACT;AACF;AAGO,SAAS,aAAa,OAA+B;AAC1D,MAAI;AACJ,MAAI;AACF,YAAQ,GAAG,YAAY,SAAS,CAAC;AAAA,EACnC,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACA,QAAM,SAAS,GAAG,KAAK;AACvB,QAAM,MAAsB,CAAC;AAC7B,aAAW,QAAQ,OAAO;AACxB,QAAI,CAAC,KAAK,WAAW,MAAM,KAAK,CAAC,KAAK,SAAS,OAAO,EAAG;AACzD,QAAI;AACF,YAAM,SAAS,YAAY,GAAG,aAAa,KAAK,KAAK,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC;AAChF,UAAI,OAAQ,KAAI,KAAK,EAAE,SAAS,KAAK,MAAM,OAAO,QAAQ,CAAC,QAAQ,MAAM,GAAG,GAAG,OAAO,CAAC;AAAA,IACzF,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO,IAAI,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,cAAc,EAAE,OAAO,CAAC;AAC9D;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
sessionIdFor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YYBXQBW2.js";
|
|
5
5
|
|
|
6
6
|
// src/core/worktree/session-folder.ts
|
|
7
7
|
import path from "path";
|
|
@@ -30,4 +30,4 @@ export {
|
|
|
30
30
|
sessionFolderPath,
|
|
31
31
|
flatFolderOwner
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
//# sourceMappingURL=chunk-RGUSVBGN.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
json,
|
|
4
4
|
tx,
|
|
5
5
|
withDb
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YYBXQBW2.js";
|
|
7
7
|
|
|
8
8
|
// src/core/rail/rail-layout.ts
|
|
9
9
|
var MAX_SECTIONS = 30;
|
|
@@ -144,4 +144,4 @@ export {
|
|
|
144
144
|
changeRailSections,
|
|
145
145
|
placeSession
|
|
146
146
|
};
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
147
|
+
//# sourceMappingURL=chunk-S3BAD4IR.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
loadHistory
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QLAVWIDJ.js";
|
|
5
5
|
import {
|
|
6
6
|
json,
|
|
7
7
|
sessionIdFor,
|
|
8
8
|
tx,
|
|
9
9
|
withDb
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YYBXQBW2.js";
|
|
11
11
|
|
|
12
12
|
// src/core/rail/blocks.ts
|
|
13
13
|
var MAX_BLOCKERS = 10;
|
|
@@ -148,4 +148,4 @@ export {
|
|
|
148
148
|
sweepBlocks,
|
|
149
149
|
blockRefFrom
|
|
150
150
|
};
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-SDQI3QB3.js.map
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
isPidAlive,
|
|
7
7
|
killTreeAsync
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4NITDMDH.js";
|
|
9
9
|
import {
|
|
10
10
|
getConfigDir
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6THUVP6T.js";
|
|
12
12
|
|
|
13
13
|
// src/core/platform/running-from.ts
|
|
14
14
|
import fs from "fs";
|
|
@@ -247,4 +247,4 @@ export {
|
|
|
247
247
|
runningFromNames,
|
|
248
248
|
stopRunningFrom
|
|
249
249
|
};
|
|
250
|
-
//# sourceMappingURL=chunk-
|
|
250
|
+
//# sourceMappingURL=chunk-SG5LUMGE.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
report
|
|
4
|
-
} from "./chunk-JIYGGN2N.js";
|
|
5
2
|
import {
|
|
6
3
|
atomicWriteFile,
|
|
7
4
|
ensureFile,
|
|
8
5
|
resolveLinkTarget,
|
|
9
6
|
withFileLock,
|
|
10
7
|
withFileLockSync
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZXHMC7UO.js";
|
|
9
|
+
import {
|
|
10
|
+
report
|
|
11
|
+
} from "./chunk-AU27USPZ.js";
|
|
12
12
|
|
|
13
13
|
// src/core/platform/settings-editor.ts
|
|
14
14
|
import fs from "fs";
|
|
@@ -68,16 +68,16 @@ function applyEdit(file, mutate) {
|
|
|
68
68
|
`);
|
|
69
69
|
return true;
|
|
70
70
|
}
|
|
71
|
-
function target() {
|
|
72
|
-
const t = resolveLinkTarget(settingsPath());
|
|
71
|
+
function target(file) {
|
|
72
|
+
const t = resolveLinkTarget(file ?? settingsPath());
|
|
73
73
|
fs.mkdirSync(path.dirname(t), { recursive: true });
|
|
74
74
|
return t;
|
|
75
75
|
}
|
|
76
76
|
var editQueue = Promise.resolve();
|
|
77
|
-
function editSettings(mutate) {
|
|
77
|
+
function editSettings(mutate, settingsFile) {
|
|
78
78
|
const run = editQueue.then(async () => {
|
|
79
79
|
try {
|
|
80
|
-
const file = target();
|
|
80
|
+
const file = target(settingsFile);
|
|
81
81
|
if (!fs.existsSync(file)) ensureFile(file, "{}\n");
|
|
82
82
|
await withFileLock(file, () => applyEdit(file, mutate));
|
|
83
83
|
} catch (err) {
|
|
@@ -87,17 +87,17 @@ function editSettings(mutate) {
|
|
|
87
87
|
editQueue = run;
|
|
88
88
|
return run;
|
|
89
89
|
}
|
|
90
|
-
function editSettingsSync(mutate) {
|
|
90
|
+
function editSettingsSync(mutate, settingsFile) {
|
|
91
91
|
try {
|
|
92
|
-
const file = target();
|
|
92
|
+
const file = target(settingsFile);
|
|
93
93
|
if (!fs.existsSync(file)) ensureFile(file, "{}\n");
|
|
94
94
|
withFileLockSync(file, () => applyEdit(file, mutate));
|
|
95
95
|
} catch (err) {
|
|
96
96
|
report("error", `[work] could not update Claude settings: ${err.message}`);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function readSettingsFile() {
|
|
100
|
-
const read = readSettings(resolveLinkTarget(settingsPath()));
|
|
99
|
+
function readSettingsFile(settingsFile) {
|
|
100
|
+
const read = readSettings(resolveLinkTarget(settingsFile ?? settingsPath()));
|
|
101
101
|
return read.kind === "ok" ? read.settings : read.kind === "missing" ? {} : null;
|
|
102
102
|
}
|
|
103
103
|
function isOwnerEntry(h, owner) {
|
|
@@ -131,4 +131,4 @@ export {
|
|
|
131
131
|
isStaleEntry,
|
|
132
132
|
tag
|
|
133
133
|
};
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
//# sourceMappingURL=chunk-UBOKRHNV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/platform/settings-editor.ts"],"sourcesContent":["/**\n * Atomic read/edit/write helpers for `~/.claude/settings.json` — the user's\n * global Claude Code settings (or another account's `<config dir>/settings.json`).\n *\n * `installCommandHook` mutates this file at `work web` startup/shutdown.\n * (The retired `work dash` also installed http-type hooks here; any it left\n * behind are tagged with a dead PID and pruned as stale on the next\n * install.) Writes used to be a plain `fs.writeFileSync`. If two `work` processes started concurrently —\n * or one was killed mid-write — the user's global hooks would be silently\n * truncated. That breaks hooks for every project, not just `work`.\n *\n * Everything here writes through `editSettings`: a tmp-file + rename atomic\n * write, under an in-process queue and a cross-process file lock (§5.2).\n * The rename follows symlinks (`atomicWriteFile`) so a settings.json\n * symlinked into a dotfiles repo keeps being a symlink. A file that exists\n * but doesn't parse is never replaced, and the first edit keeps a\n * `settings.json.work-backup`.\n */\n\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\nimport { atomicWriteFile, ensureFile, resolveLinkTarget, withFileLock, withFileLockSync } from './fs-safe.js';\nimport { report } from './report.js';\n\n/** Resolved lazily (not at module load) so tests can stub `os.homedir`. */\nfunction settingsPath(): string {\n return path.join(os.homedir(), '.claude', 'settings.json');\n}\nconst OWNER_TAG = '_workHookOwner';\nconst PID_TAG = '_workHookPid';\n\nexport interface SettingsFile {\n hooks?: Record<string, HookEntry[] | undefined>;\n [k: string]: unknown;\n}\nexport interface HookEntry {\n hooks?: { type: string; url?: string; command?: string; timeout?: number }[];\n matcher?: string;\n [k: string]: unknown;\n}\n\nexport const HOOK_TAGS = {\n OWNER_TAG,\n PID_TAG,\n} as const;\n\ntype Read =\n | { kind: 'ok'; settings: SettingsFile }\n /** No file yet: start from an empty one. */\n | { kind: 'missing' }\n /** The file exists but isn't valid JSON (a hand edit in progress, another\n * tool mid-write). NOT the same as empty: writing now would replace the\n * user's permissions, env, model… with just our hooks. */\n | { kind: 'unreadable'; error: string };\n\nfunction readSettings(file: string): Read {\n let text: string;\n try {\n text = fs.readFileSync(file, 'utf8');\n } catch (err) {\n return (err as NodeJS.ErrnoException).code === 'ENOENT' ? { kind: 'missing' } : { kind: 'unreadable', error: (err as Error).message };\n }\n if (!text.trim()) return { kind: 'missing' };\n try {\n const parsed = JSON.parse(text) as unknown;\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return { kind: 'unreadable', error: 'not a JSON object' };\n return { kind: 'ok', settings: parsed as SettingsFile };\n } catch (err) {\n return { kind: 'unreadable', error: (err as Error).message };\n }\n}\n\n/** One backup per file per process, of the file as it was before this\n * process first edited it. */\nconst backedUp = new Set<string>();\nfunction backupOnce(file: string): void {\n if (backedUp.has(file) || !fs.existsSync(file)) return;\n try {\n fs.copyFileSync(file, `${file}.work-backup`);\n backedUp.add(file);\n } catch {\n /* best-effort */\n }\n}\n\n/**\n * The read-modify-write, under a cross-process lock on the real file (the\n * symlink target): Claude Code saving settings, a lean `work web` autostarted\n * by `wd` installing hooks and a full one shutting down can all edit this\n * file at once, and an unlocked rewrite drops one side's edit. Returns\n * false when the file couldn't be read and was left untouched.\n */\nfunction applyEdit(file: string, mutate: (s: SettingsFile) => void): boolean {\n const read = readSettings(file);\n if (read.kind === 'unreadable') {\n report(\n 'error',\n `[work] ${file} is not valid JSON (${read.error}) — left it alone; work's Claude hooks were not updated. Fix the file and restart work web.`,\n );\n return false;\n }\n const s = read.kind === 'ok' ? read.settings : {};\n const before = JSON.stringify(s);\n if (!s.hooks) s.hooks = {};\n mutate(s);\n if (s.hooks && Object.keys(s.hooks).length === 0) delete s.hooks;\n // Nothing changed (hooks already in, status line already wrapped): no write and no backup — the file is often synced\n // or in a dotfiles repo, and every work web start would otherwise touch it.\n if (JSON.stringify(s) === before) return true;\n backupOnce(file);\n // Trailing newline: this file is commonly symlinked into a dotfiles repo,\n // and a missing one shows up as a diff artefact on every edit.\n atomicWriteFile(file, `${JSON.stringify(s, null, 2)}\\n`);\n return true;\n}\n\nfunction target(file?: string): string {\n const t = resolveLinkTarget(file ?? settingsPath());\n fs.mkdirSync(path.dirname(t), { recursive: true });\n return t;\n}\n\n/**\n * Edit the settings file: atomic (tmp + rename, through a symlink to the\n * real file), serialised within this process AND locked across processes.\n * An unparsable file is never replaced.\n */\nlet editQueue: Promise<unknown> = Promise.resolve();\nexport function editSettings(mutate: (s: SettingsFile) => void, settingsFile?: string): Promise<void> {\n const run = editQueue.then(async () => {\n try {\n const file = target(settingsFile);\n if (!fs.existsSync(file)) ensureFile(file, '{}\\n');\n await withFileLock(file, () => applyEdit(file, mutate));\n } catch (err) {\n report('error', `[work] could not update Claude settings: ${(err as Error).message}`);\n }\n });\n editQueue = run;\n return run;\n}\n\n/** Synchronous variant — shutdown handlers, where there's no time to await.\n * Same lock and the same refusal to overwrite an unparsable file. */\nexport function editSettingsSync(mutate: (s: SettingsFile) => void, settingsFile?: string): void {\n try {\n const file = target(settingsFile);\n if (!fs.existsSync(file)) ensureFile(file, '{}\\n');\n withFileLockSync(file, () => applyEdit(file, mutate));\n } catch (err) {\n report('error', `[work] could not update Claude settings: ${(err as Error).message}`);\n }\n}\n\n/**\n * The settings as they are now, read only: `{}` when there is no file, null when it doesn't parse. `settingsFile`: another\n * Claude account's settings.json (default: ~/.claude/settings.json — every edit function takes it the same way).\n */\nexport function readSettingsFile(settingsFile?: string): SettingsFile | null {\n const read = readSettings(resolveLinkTarget(settingsFile ?? settingsPath()));\n return read.kind === 'ok' ? read.settings : read.kind === 'missing' ? {} : null;\n}\n\n/** Common predicate: is this entry tagged with our owner? */\nexport function isOwnerEntry(h: HookEntry, owner: string): boolean {\n return h[OWNER_TAG] === owner;\n}\n\n/** Common predicate: was this entry tagged by a `work` process that's no\n * longer running? Stale entries get pruned on every install. */\nexport function isStaleEntry(h: HookEntry): boolean {\n if (typeof h[OWNER_TAG] !== 'string') return false;\n const pid = h[PID_TAG];\n if (typeof pid !== 'number') return false;\n try {\n process.kill(pid, 0);\n return false;\n } catch {\n return true;\n }\n}\n\n/** Tag an entry so future installs can find/remove it. */\nexport function tag(entry: HookEntry, owner: string): HookEntry {\n return {\n ...entry,\n [OWNER_TAG]: owner,\n [PID_TAG]: process.pid,\n };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
findOnPath
|
|
4
|
+
} from "./chunk-ZDMJPEBO.js";
|
|
5
|
+
import {
|
|
6
|
+
agentsBySession
|
|
7
|
+
} from "./chunk-BOEAOIQT.js";
|
|
8
|
+
import {
|
|
9
|
+
LATER_TEXT,
|
|
10
|
+
restartCountsText
|
|
11
|
+
} from "./chunk-TNJF7T33.js";
|
|
12
|
+
import {
|
|
13
|
+
accountSwitchRefusal,
|
|
14
|
+
findSession,
|
|
15
|
+
haltPty,
|
|
16
|
+
peekPty,
|
|
17
|
+
ptyPid,
|
|
18
|
+
ptyPids,
|
|
19
|
+
resumePtyOnAccount
|
|
20
|
+
} from "./chunk-IRKYLDMX.js";
|
|
21
|
+
import {
|
|
22
|
+
isArchiving,
|
|
23
|
+
loadHistory,
|
|
24
|
+
setSessionAccount
|
|
25
|
+
} from "./chunk-QLAVWIDJ.js";
|
|
26
|
+
import {
|
|
27
|
+
agentOf,
|
|
28
|
+
liveAgents
|
|
29
|
+
} from "./chunk-F6M255O5.js";
|
|
30
|
+
|
|
31
|
+
// src/core/pty/agent-restart.ts
|
|
32
|
+
import fs from "fs";
|
|
33
|
+
var PACKED_MTIME_BEFORE = Date.parse("1990-01-01T00:00:00Z");
|
|
34
|
+
function installedAt(cmd, find = findOnPath) {
|
|
35
|
+
const file = find(cmd);
|
|
36
|
+
if (!file) return null;
|
|
37
|
+
try {
|
|
38
|
+
return installTime(fs.statSync(fs.realpathSync(file)));
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function installTime(st) {
|
|
44
|
+
const real = (ms) => ms >= PACKED_MTIME_BEFORE ? ms : null;
|
|
45
|
+
const known = [real(st.mtimeMs), real(st.birthtimeMs)].filter((x) => x !== null);
|
|
46
|
+
return known.length ? Math.max(...known) : st.ctimeMs;
|
|
47
|
+
}
|
|
48
|
+
function installedAtCache(ttlMs = 6e4, look = installedAt, now = Date.now) {
|
|
49
|
+
const cache = /* @__PURE__ */ new Map();
|
|
50
|
+
return (cmd) => {
|
|
51
|
+
const hit = cache.get(cmd);
|
|
52
|
+
if (hit && now() - hit.read < ttlMs) return hit.at;
|
|
53
|
+
const at = look(cmd);
|
|
54
|
+
cache.set(cmd, { at, read: now() });
|
|
55
|
+
return at;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function outdatedPtys(ptys, toolInstalledAt) {
|
|
59
|
+
return ptys.filter((p) => {
|
|
60
|
+
if (p.exited || !p.tool) return false;
|
|
61
|
+
const at = toolInstalledAt(p.tool);
|
|
62
|
+
const started = Date.parse(p.startedAt);
|
|
63
|
+
return at !== null && Number.isFinite(started) && started < at;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var PRINTING_MS = 1e4;
|
|
67
|
+
function busyForRestart(state, lastOutputMs, now = Date.now(), live = null) {
|
|
68
|
+
if (live === "busy" || live === "waiting") return true;
|
|
69
|
+
if (state === "working" || state === "needs_input") return true;
|
|
70
|
+
return lastOutputMs !== null && now - lastOutputMs < PRINTING_MS;
|
|
71
|
+
}
|
|
72
|
+
function restartPlan(ids, busy) {
|
|
73
|
+
const now = [];
|
|
74
|
+
const later = [];
|
|
75
|
+
for (const id of new Set(ids)) (busy(id) ? later : now).push(id);
|
|
76
|
+
return { now, later };
|
|
77
|
+
}
|
|
78
|
+
var RESTART_AT_ONCE = 3;
|
|
79
|
+
function restartNotesSummary(notes) {
|
|
80
|
+
const n = (level) => notes.filter((x) => x.level === level).length;
|
|
81
|
+
return restartCountsText({ restarted: n("action"), later: n("info"), failed: n("warn") });
|
|
82
|
+
}
|
|
83
|
+
var QUEUE_RECHECK_MS = 15e3;
|
|
84
|
+
var TURN_END_GRACE_MS = 1e4;
|
|
85
|
+
function createRestarter(deps) {
|
|
86
|
+
const queued = /* @__PURE__ */ new Set();
|
|
87
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
88
|
+
const later = deps.later ?? ((fn, ms) => void setTimeout(fn, ms).unref?.());
|
|
89
|
+
const one = (id) => {
|
|
90
|
+
const running = inFlight.get(id);
|
|
91
|
+
if (running) return running;
|
|
92
|
+
queued.delete(id);
|
|
93
|
+
const p = deps.restart(id).then(
|
|
94
|
+
(how) => ({ ok: true, how: how || "restarted its agent (its conversation goes on)" }),
|
|
95
|
+
(err) => ({ ok: false, error: err.message })
|
|
96
|
+
);
|
|
97
|
+
inFlight.set(id, p);
|
|
98
|
+
void p.finally(() => inFlight.delete(id));
|
|
99
|
+
return p;
|
|
100
|
+
};
|
|
101
|
+
const run = async (ids, notes) => {
|
|
102
|
+
const failed = [];
|
|
103
|
+
const ok = /* @__PURE__ */ new Set();
|
|
104
|
+
const queue = [...ids];
|
|
105
|
+
const worker = async () => {
|
|
106
|
+
for (let id = queue.shift(); id !== void 0; id = queue.shift()) {
|
|
107
|
+
const r = await one(id);
|
|
108
|
+
if (r.ok) {
|
|
109
|
+
ok.add(id);
|
|
110
|
+
notes.push({ id, text: r.how, level: "action" });
|
|
111
|
+
} else {
|
|
112
|
+
failed.push({ id, error: r.error });
|
|
113
|
+
notes.push({ id, text: `couldn't restart its agent: ${r.error}`, level: "warn" });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
await Promise.all(Array.from({ length: Math.min(RESTART_AT_ONCE, queue.length) }, worker));
|
|
118
|
+
return { done: ids.filter((id) => ok.has(id)), failed };
|
|
119
|
+
};
|
|
120
|
+
const finish = (notes) => {
|
|
121
|
+
if (!notes.length) return;
|
|
122
|
+
deps.report?.(notes);
|
|
123
|
+
deps.changed?.();
|
|
124
|
+
};
|
|
125
|
+
const request = async (ids) => {
|
|
126
|
+
const notes = [];
|
|
127
|
+
const folded = [];
|
|
128
|
+
for (const id of ids) {
|
|
129
|
+
const into = deps.foldedInto?.(id);
|
|
130
|
+
if (!into) continue;
|
|
131
|
+
folded.push(id);
|
|
132
|
+
notes.push({ id, text: `restarts with ${into} (no second restart)`, level: "info" });
|
|
133
|
+
}
|
|
134
|
+
const plan = restartPlan(
|
|
135
|
+
ids.filter((id) => !folded.includes(id)),
|
|
136
|
+
(id) => deps.busy(id)
|
|
137
|
+
);
|
|
138
|
+
for (const id of plan.later) {
|
|
139
|
+
queued.add(id);
|
|
140
|
+
notes.push({ id, text: `${LATER_TEXT} (it is working or waiting on you)`, level: "info" });
|
|
141
|
+
}
|
|
142
|
+
const { done, failed } = await run(plan.now, notes);
|
|
143
|
+
finish(notes);
|
|
144
|
+
tick();
|
|
145
|
+
return { now: done, later: [...folded, ...plan.later], failed };
|
|
146
|
+
};
|
|
147
|
+
let ticking = false;
|
|
148
|
+
const tick = () => {
|
|
149
|
+
if (ticking) return;
|
|
150
|
+
if (queued.size === 0) {
|
|
151
|
+
deps.scheduled?.(null);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
ticking = true;
|
|
155
|
+
deps.scheduled?.(Date.now() + QUEUE_RECHECK_MS);
|
|
156
|
+
later(() => {
|
|
157
|
+
ticking = false;
|
|
158
|
+
void retry().catch(() => {
|
|
159
|
+
}).finally(tick);
|
|
160
|
+
}, QUEUE_RECHECK_MS);
|
|
161
|
+
};
|
|
162
|
+
const retry = async (only, opts) => {
|
|
163
|
+
const notes = [];
|
|
164
|
+
const ready = [];
|
|
165
|
+
for (const id of [...queued]) {
|
|
166
|
+
if (only !== void 0 && id !== only) continue;
|
|
167
|
+
if (!deps.running(id)) {
|
|
168
|
+
queued.delete(id);
|
|
169
|
+
notes.push({ id, text: "no longer waits to restart: it was stopped meanwhile (it starts on the new version)", level: "info" });
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const into = deps.foldedInto?.(id);
|
|
173
|
+
if (into) {
|
|
174
|
+
queued.delete(id);
|
|
175
|
+
notes.push({ id, text: `no longer waits to restart: ${into} restarts it`, level: "info" });
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!deps.busy(id, opts)) ready.push(id);
|
|
179
|
+
}
|
|
180
|
+
await run(ready, notes);
|
|
181
|
+
finish(notes);
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
request,
|
|
185
|
+
retry: () => retry(),
|
|
186
|
+
/** A session's turn ended: restart it if it was waiting for that — and if it still reads as busy, look again shortly. */
|
|
187
|
+
turnEnded: (id) => {
|
|
188
|
+
if (!queued.has(id)) return;
|
|
189
|
+
later(() => void retry(id, { turnEnded: true }).catch(() => {
|
|
190
|
+
}), TURN_END_GRACE_MS);
|
|
191
|
+
},
|
|
192
|
+
queued: () => [...queued],
|
|
193
|
+
/** Take one off the queue (it no longer waits for its turn); false when it wasn't waiting (not queued, or running now). */
|
|
194
|
+
cancel: (id) => {
|
|
195
|
+
if (!queued.delete(id)) return false;
|
|
196
|
+
if (queued.size === 0) deps.scheduled?.(null);
|
|
197
|
+
deps.changed?.();
|
|
198
|
+
return true;
|
|
199
|
+
},
|
|
200
|
+
/** Being restarted now (the host lists them as exited meanwhile: still this session's). */
|
|
201
|
+
restarting: () => [...inFlight.keys()]
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/core/sessions/account-switch-rules.ts
|
|
206
|
+
function switchRefusal(to, f) {
|
|
207
|
+
if (f.archived) return { status: 409, error: "it is archived: restore it first" };
|
|
208
|
+
if (!f.accounts) return { status: 409, error: "its agent doesn't have accounts" };
|
|
209
|
+
const target = f.accounts.list.find((a) => a.name === to);
|
|
210
|
+
if (!target) return { status: 400, error: `no account \u201C${to}\u201D (see \`work account list\`)` };
|
|
211
|
+
if (target.loggedIn === false)
|
|
212
|
+
return { status: 409, error: `nobody is logged in on \u201C${to}\u201D: run \`work account add ${to}\` again to log in, or /login on it` };
|
|
213
|
+
if (f.pendingTo !== null)
|
|
214
|
+
return { status: 409, error: `a switch is already waiting for its turn to end (to ${f.pendingTo || "another account"})` };
|
|
215
|
+
if (f.accounts.current === to) return { status: 409, error: `it already runs on \u201C${to}\u201D` };
|
|
216
|
+
if (!f.inHost && f.runningOutside)
|
|
217
|
+
return {
|
|
218
|
+
status: 409,
|
|
219
|
+
error: "its Claude runs in a terminal outside work: stop it there first (its conversation would be moved from under it)"
|
|
220
|
+
};
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/core/sessions/account-switch.ts
|
|
225
|
+
var msg = (err) => err instanceof Error ? err.message : String(err);
|
|
226
|
+
function createAccountSwitcher(deps) {
|
|
227
|
+
const targets = /* @__PURE__ */ new Map();
|
|
228
|
+
const movedBy = /* @__PURE__ */ new Map();
|
|
229
|
+
const name = (s) => `${s.target} ${s.branch}`;
|
|
230
|
+
const moveAndRecord = async (s, to, from) => {
|
|
231
|
+
const { moved } = await deps.switchFiles(s, to);
|
|
232
|
+
try {
|
|
233
|
+
await deps.record(s, to);
|
|
234
|
+
} catch (err) {
|
|
235
|
+
const back = await deps.switchFiles({ ...s, account: to }, from).then(
|
|
236
|
+
() => "",
|
|
237
|
+
(e2) => `; and its conversations couldn't all be moved back: ${msg(e2)}`
|
|
238
|
+
);
|
|
239
|
+
throw new Error(`${msg(err)}${back}`, { cause: err });
|
|
240
|
+
}
|
|
241
|
+
return moved.length;
|
|
242
|
+
};
|
|
243
|
+
const perform = async (id) => {
|
|
244
|
+
const to = targets.get(id);
|
|
245
|
+
const s = deps.session(id);
|
|
246
|
+
try {
|
|
247
|
+
if (!to || !s) throw new Error("the session is gone");
|
|
248
|
+
if (s.archivedAt || deps.beingArchived(id)) throw new Error("it was archived meanwhile");
|
|
249
|
+
const acc = deps.accounts(s);
|
|
250
|
+
if (!acc) throw new Error("its agent has no accounts");
|
|
251
|
+
const from = acc.current;
|
|
252
|
+
if (from === to) return `already on ${to}`;
|
|
253
|
+
const before = await refusalBeforeStop(s, id);
|
|
254
|
+
if (before) throw new Error(`stays on ${from}: ${before}`);
|
|
255
|
+
if (deps.cancelRestart?.(id)) deps.note?.(id, "its agent restart that waited for this turn is done by the switch instead", "info");
|
|
256
|
+
let halted = null;
|
|
257
|
+
if (deps.hostRuns(id)) {
|
|
258
|
+
let h;
|
|
259
|
+
try {
|
|
260
|
+
h = await deps.halt(id);
|
|
261
|
+
} catch (err) {
|
|
262
|
+
throw new Error(`stays on ${from}: couldn't stop its Claude: ${msg(err)}`, { cause: err });
|
|
263
|
+
}
|
|
264
|
+
if (h !== "gone") halted = h;
|
|
265
|
+
}
|
|
266
|
+
const resume = async () => halted ? deps.resume(id, halted) : void 0;
|
|
267
|
+
let moved;
|
|
268
|
+
try {
|
|
269
|
+
moved = await moveAndRecord(s, to, from);
|
|
270
|
+
} catch (err) {
|
|
271
|
+
const back = await resume().then(
|
|
272
|
+
() => "",
|
|
273
|
+
(e2) => ` (and couldn't start its Claude again: ${msg(e2)}; opening the session starts it)`
|
|
274
|
+
);
|
|
275
|
+
throw new Error(`stays on ${from}: ${msg(err)}${back}`, { cause: err });
|
|
276
|
+
}
|
|
277
|
+
movedBy.set(id, moved);
|
|
278
|
+
if (!halted) {
|
|
279
|
+
deps.note?.(id, `moved to the ${to} account (${moved} entries moved; its next start uses it)`, "action");
|
|
280
|
+
return `moved to the ${to} account`;
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
const how = await resume();
|
|
284
|
+
deps.note?.(id, `moved to the ${to} account: its Claude restarted on it${how ? ` (${how})` : ""}`, "action");
|
|
285
|
+
return how || `moved to the ${to} account: its Claude restarted on it`;
|
|
286
|
+
} catch (err) {
|
|
287
|
+
const why = `moved to the ${to} account, but its Claude couldn't be restarted: ${msg(err)} (opening the session starts it on ${to})`;
|
|
288
|
+
deps.note?.(id, why, "warn");
|
|
289
|
+
throw new Error(why, { cause: err });
|
|
290
|
+
}
|
|
291
|
+
} catch (err) {
|
|
292
|
+
if (s && !String(msg(err)).startsWith("moved to")) deps.note?.(id, `couldn't switch: ${msg(err)}`, "warn");
|
|
293
|
+
throw err;
|
|
294
|
+
} finally {
|
|
295
|
+
targets.delete(id);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const restarter = createRestarter({
|
|
299
|
+
restart: perform,
|
|
300
|
+
busy: deps.busy,
|
|
301
|
+
// A queued switch is never dropped as "stopped meanwhile": perform handles a Claude no longer running (it records the account).
|
|
302
|
+
running: () => true,
|
|
303
|
+
changed: deps.changed,
|
|
304
|
+
scheduled: deps.scheduled,
|
|
305
|
+
later: deps.later
|
|
306
|
+
});
|
|
307
|
+
const refusalBeforeStop = async (s, id) => {
|
|
308
|
+
const other = deps.othersRunningIn?.(s, id);
|
|
309
|
+
if (other) return `a Claude outside this session runs in ${other}`;
|
|
310
|
+
return deps.hostRuns(id) ? await deps.hostRefusal?.() ?? null : null;
|
|
311
|
+
};
|
|
312
|
+
const pending = (id) => restarter.queued().includes(id) || restarter.restarting().includes(id);
|
|
313
|
+
async function switchAccount(id, to) {
|
|
314
|
+
const s = deps.session(id);
|
|
315
|
+
if (!s) return { ok: false, status: 404, error: "unknown session" };
|
|
316
|
+
const acc = deps.accounts(s);
|
|
317
|
+
const inHost = deps.hostRuns(id);
|
|
318
|
+
const refused = switchRefusal(to, {
|
|
319
|
+
archived: !!s.archivedAt || deps.beingArchived(id),
|
|
320
|
+
accounts: acc,
|
|
321
|
+
pendingTo: pending(id) ? targets.get(id) ?? "" : null,
|
|
322
|
+
inHost,
|
|
323
|
+
runningOutside: !inHost && deps.runningOutside(id)
|
|
324
|
+
});
|
|
325
|
+
if (refused) return { ok: false, ...refused };
|
|
326
|
+
if (!acc) return { ok: false, status: 409, error: "its agent doesn't have accounts" };
|
|
327
|
+
const before = await refusalBeforeStop(s, id);
|
|
328
|
+
if (before) return { ok: false, status: 409, error: `stays on ${acc.current}: ${before}` };
|
|
329
|
+
if (!inHost) {
|
|
330
|
+
try {
|
|
331
|
+
const moved = await moveAndRecord(s, to, acc.current);
|
|
332
|
+
deps.note?.(id, `${name(s)}: moved to the ${to} account (${moved} entries moved; its next start uses it)`, "action");
|
|
333
|
+
deps.changed?.();
|
|
334
|
+
return { ok: true, outcome: "recorded", moved };
|
|
335
|
+
} catch (err) {
|
|
336
|
+
deps.note?.(id, `couldn't switch: ${msg(err)}`, "warn");
|
|
337
|
+
return { ok: false, status: 502, error: `stays on ${acc.current}: ${msg(err)}` };
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
targets.set(id, to);
|
|
341
|
+
movedBy.delete(id);
|
|
342
|
+
const r = await restarter.request([id]);
|
|
343
|
+
if (r.later.includes(id)) {
|
|
344
|
+
deps.note?.(id, `will move to the ${to} account when its turn ends (it is working or waiting on you)`, "info");
|
|
345
|
+
return { ok: true, outcome: "queued" };
|
|
346
|
+
}
|
|
347
|
+
const failed = r.failed.find((f) => f.id === id);
|
|
348
|
+
if (failed) return { ok: false, status: 502, error: failed.error };
|
|
349
|
+
return { ok: true, outcome: "switched", moved: movedBy.get(id) };
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
switchAccount,
|
|
353
|
+
/** Its turn ended: do the switch that waited for it. */
|
|
354
|
+
turnEnded: (id) => restarter.turnEnded(id),
|
|
355
|
+
/** Do the waiting switches that can go now (a turn whose end no hook reported). */
|
|
356
|
+
retry: () => restarter.retry(),
|
|
357
|
+
/** Sessions waiting for their turn to end, and where each goes. */
|
|
358
|
+
waiting: () => restarter.queued().map((id) => ({ id, to: targets.get(id) ?? "" })),
|
|
359
|
+
/** The account a switch waiting for its turn, or being done now, moves it to; null: none. Either way its agent restarts. */
|
|
360
|
+
restartsAnyway: (id) => pending(id) ? targets.get(id) ?? "" : null,
|
|
361
|
+
/** The account a session is waiting to move to (its turn first), or null. Kept in memory: a work web restart drops it. */
|
|
362
|
+
pendingFor: (id) => restarter.queued().includes(id) ? targets.get(id) ?? null : null,
|
|
363
|
+
/**
|
|
364
|
+
* Drop the switch waiting for its turn to end. `running`: it is being done right now (too late to cancel); `none`:
|
|
365
|
+
* nothing waits for it.
|
|
366
|
+
*/
|
|
367
|
+
cancel: (id) => {
|
|
368
|
+
if (restarter.restarting().includes(id)) return "running";
|
|
369
|
+
const to = targets.get(id);
|
|
370
|
+
if (!restarter.cancel(id)) return "none";
|
|
371
|
+
targets.delete(id);
|
|
372
|
+
deps.note?.(id, `no longer moves to the ${to ?? "other"} account: the switch was cancelled`, "info");
|
|
373
|
+
return "cancelled";
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function accountSwitchNote(activity, label) {
|
|
378
|
+
return (id, text, level) => {
|
|
379
|
+
const name = label(id);
|
|
380
|
+
const run = activity.start("accounts", "Switching a Claude account");
|
|
381
|
+
run.note(`${name ?? id}: ${text}`, { level, sessionId: name ? id : void 0 });
|
|
382
|
+
if (level === "warn") run.fail(text);
|
|
383
|
+
else run.done(text);
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/core/sessions/account-switch-deps.ts
|
|
388
|
+
import path from "path";
|
|
389
|
+
function defaultAccountSwitchDeps(opts) {
|
|
390
|
+
return {
|
|
391
|
+
session: findSession,
|
|
392
|
+
beingArchived: isArchiving,
|
|
393
|
+
accounts: (s) => {
|
|
394
|
+
const accounts = agentOf(s).accounts;
|
|
395
|
+
return accounts ? { list: accounts.list(), current: accounts.current(s) } : null;
|
|
396
|
+
},
|
|
397
|
+
switchFiles: (s, to) => {
|
|
398
|
+
const accounts = agentOf(s).accounts;
|
|
399
|
+
if (!accounts) throw new Error("its agent has no accounts");
|
|
400
|
+
return accounts.switchFiles(s, to);
|
|
401
|
+
},
|
|
402
|
+
record: async (s, to) => {
|
|
403
|
+
if (!await setSessionAccount(s.target, s.branch, to)) throw new Error("unknown session");
|
|
404
|
+
},
|
|
405
|
+
hostRuns: peekPty,
|
|
406
|
+
// Claude Code's process files say one runs for it that isn't the host's (terminal-ws.ts, session-control-routes.ts).
|
|
407
|
+
runningOutside: (id) => {
|
|
408
|
+
const hostPids = ptyPids();
|
|
409
|
+
return (agentsBySession(liveAgents(), loadHistory()).get(id) ?? []).some((c) => !hostPids.has(c.pid));
|
|
410
|
+
},
|
|
411
|
+
othersRunningIn: (s, id) => {
|
|
412
|
+
const folders = agentOf(s).accounts?.folders(s) ?? [];
|
|
413
|
+
if (!folders.length) return null;
|
|
414
|
+
const own = ptyPid(id);
|
|
415
|
+
const key = (p) => {
|
|
416
|
+
const r = path.resolve(p).replace(/[\\/]+$/, "");
|
|
417
|
+
return process.platform === "win32" ? r.toLowerCase() : r;
|
|
418
|
+
};
|
|
419
|
+
const wanted = new Map(folders.map((f) => [key(f), f]));
|
|
420
|
+
const other = liveAgents().find((a) => a.pid !== own && wanted.has(key(a.cwd)));
|
|
421
|
+
return other ? wanted.get(key(other.cwd)) ?? other.cwd : null;
|
|
422
|
+
},
|
|
423
|
+
hostRefusal: accountSwitchRefusal,
|
|
424
|
+
halt: haltPty,
|
|
425
|
+
resume: resumePtyOnAccount,
|
|
426
|
+
...opts
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export {
|
|
431
|
+
installedAtCache,
|
|
432
|
+
outdatedPtys,
|
|
433
|
+
busyForRestart,
|
|
434
|
+
restartNotesSummary,
|
|
435
|
+
QUEUE_RECHECK_MS,
|
|
436
|
+
createRestarter,
|
|
437
|
+
switchRefusal,
|
|
438
|
+
createAccountSwitcher,
|
|
439
|
+
accountSwitchNote,
|
|
440
|
+
defaultAccountSwitchDeps
|
|
441
|
+
};
|
|
442
|
+
//# sourceMappingURL=chunk-UESDYZG3.js.map
|