@madarco/agentbox 0.31.3 → 0.32.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/CHANGELOG.md +47 -0
- package/README.md +2 -0
- package/dist/_cloud-attach-6RKS3MAP.js +31 -0
- package/dist/{chunk-E2RPG54S.js → chunk-27S7QLDF.js} +3 -3
- package/dist/{chunk-EZPCCJPE.js → chunk-2APGFWEU.js} +24 -24
- package/dist/{chunk-7PDYVJ2Q.js → chunk-3AYSA62C.js} +3 -3
- package/dist/{chunk-SHFU2KSY.js → chunk-3ISG5THX.js} +3 -3
- package/dist/{chunk-D67Q5MNA.js → chunk-3L2DIPRM.js} +2 -2
- package/dist/{chunk-GYUOXSUX.js → chunk-4FOXMGJ7.js} +4 -4
- package/dist/{chunk-VIB2FMJJ.js → chunk-5OKDSI6M.js} +44 -44
- package/dist/{chunk-QWUZJCF5.js → chunk-66GAYIJZ.js} +3253 -937
- package/dist/chunk-66GAYIJZ.js.map +1 -0
- package/dist/{chunk-Q3BHXL47.js → chunk-6XMOBI5V.js} +4 -4
- package/dist/{chunk-VNXWOWQ7.js → chunk-7QTBRHB7.js} +4 -4
- package/dist/{chunk-UWKJ3HIA.js → chunk-ANSPBIYG.js} +4 -4
- package/dist/{chunk-7N3CJNR5.js → chunk-AWFTAHGF.js} +20 -7
- package/dist/chunk-AWFTAHGF.js.map +1 -0
- package/dist/{chunk-EHLPIWRR.js → chunk-AWI2TSWS.js} +2 -2
- package/dist/{chunk-GZHJVCBG.js → chunk-CDRKQ5BH.js} +9 -9
- package/dist/{chunk-W7P2HHFI.js → chunk-CXAWPWGZ.js} +6 -6
- package/dist/{chunk-V5IMDVV5.js → chunk-EDJ6O6CI.js} +6 -6
- package/dist/{chunk-PYPIECDD.js → chunk-GSMQL4IJ.js} +17 -17
- package/dist/chunk-GVNKIACA.js +223 -0
- package/dist/chunk-GVNKIACA.js.map +1 -0
- package/dist/{chunk-DKUSSE5G.js → chunk-JWQYZ6V4.js} +2 -2
- package/dist/{chunk-WMILLMJZ.js → chunk-KOTW7QQW.js} +5 -5
- package/dist/{chunk-XHCGVCSA.js → chunk-L4KBYI3I.js} +5 -5
- package/dist/{chunk-BMZOMC6X.js → chunk-M2DWTQRF.js} +3 -3
- package/dist/{chunk-XLFQXROC.js → chunk-MB2K74BI.js} +165 -3
- package/dist/chunk-MB2K74BI.js.map +1 -0
- package/dist/{chunk-MKZHCLFJ.js → chunk-MI3V2MAE.js} +4 -4
- package/dist/{chunk-ZMNLEZJB.js → chunk-MO3QJTVS.js} +7 -7
- package/dist/{chunk-MBFN2XNU.js → chunk-MPTE57BZ.js} +6 -6
- package/dist/{chunk-ZK6KD7ME.js → chunk-PE5LPD23.js} +68 -25
- package/dist/chunk-PE5LPD23.js.map +1 -0
- package/dist/{chunk-RNYH5465.js → chunk-QBVRWGXD.js} +3 -3
- package/dist/{chunk-VEO6ZYQY.js → chunk-RIXW4HSE.js} +6 -6
- package/dist/{chunk-QER5WHBC.js → chunk-S7LPQXR5.js} +6 -6
- package/dist/{chunk-JS5DLUUX.js → chunk-TAZYSVLT.js} +26 -22
- package/dist/{chunk-JS5DLUUX.js.map → chunk-TAZYSVLT.js.map} +1 -1
- package/dist/{chunk-QTMUJETE.js → chunk-TDPHZWJI.js} +4 -4
- package/dist/{chunk-M42UQWVO.js → chunk-WLEGSKKE.js} +4 -4
- package/dist/{chunk-UENVVGWE.js → chunk-WTOG3CC6.js} +4 -4
- package/dist/{chunk-QB7XVOYW.js → chunk-X6CO4WIX.js} +4 -4
- package/dist/{chunk-744IB5WM.js → chunk-XLJ4D4FI.js} +4 -4
- package/dist/{chunk-FVBEUPVM.js → chunk-XNZ6UHTM.js} +27 -5
- package/dist/chunk-XNZ6UHTM.js.map +1 -0
- package/dist/{chunk-SZTHLJ5J.js → chunk-XTNAIM7X.js} +6 -6
- package/dist/{chunk-S3SJIWSU.js → chunk-YNAJUTYC.js} +7 -7
- package/dist/{chunk-6GJDU3FN.js → chunk-YSACCMUB.js} +13 -13
- package/dist/{chunk-6RREIUAE.js → chunk-ZKOLV4ZN.js} +39 -4
- package/dist/chunk-ZKOLV4ZN.js.map +1 -0
- package/dist/{cli-JNOPYAUM.js → cli-IFXU5XNZ.js} +9 -9
- package/dist/{cli-I6TXLNRQ.js → cli-MZSWFSTW.js} +9 -9
- package/dist/{cli-VU2ALT6L.js → cli-O3WXOFNS.js} +8 -8
- package/dist/{cli-YYXO4WX5.js → cli-RQJUQJEP.js} +8 -8
- package/dist/{cli-W2WNV64V.js → cli-ZGYSHJP7.js} +9 -9
- package/dist/cloud-backends.js +5 -5
- package/dist/{control-plane-JUAINN2X.js → control-plane-3TII2JGM.js} +20 -20
- package/dist/{cp-hub-upload-VHU5TBHQ.js → cp-hub-upload-3W7Z4BMT.js} +7 -7
- package/dist/{custody-client-5OHF3SEX.js → custody-client-KYEZET6C.js} +5 -5
- package/dist/{deploy-hetzner-RTQW3B7P.js → deploy-hetzner-EO5PFKBG.js} +9 -9
- package/dist/{dist-H4FFY5TX.js → dist-3AR6L5MF.js} +8 -8
- package/dist/{dist-5HJBDLJP.js → dist-4GHNQ2AK.js} +8 -8
- package/dist/{dist-H72NQCKO.js → dist-BFH537FO.js} +9 -9
- package/dist/{dist-MBPDLQUR.js → dist-BUCKUE4V.js} +2 -2
- package/dist/{dist-64YIP2AZ.js → dist-ETGTZQUT.js} +256 -6
- package/dist/{dist-UGI5L7BN.js → dist-H2CSUDEI.js} +8 -8
- package/dist/{dist-7IANPBF4.js → dist-IABCQB5D.js} +8 -8
- package/dist/{dist-EDCGUXVI.js → dist-JJZ3NZRO.js} +10 -6
- package/dist/{dist-7RMVQOWJ.js → dist-RPBA2EL5.js} +8 -8
- package/dist/{dist-NJOKYHDI.js → dist-URWWHI3X.js} +9 -3
- package/dist/{dist-XWDFVTFR.js → dist-V224SH3Z.js} +7 -7
- package/dist/{host-reach-drainer-GTNLQWWM.js → host-reach-drainer-NYN3YXHG.js} +2 -2
- package/dist/host-session-YP5RKV6T.js +29 -0
- package/dist/hub-OWUC4IGW.js +39 -0
- package/dist/{hub-adopt-TVDMOZSP.js → hub-adopt-HYXFUPPO.js} +7 -7
- package/dist/{hub-api-client-RISAC6GB.js → hub-api-client-BI3E37CF.js} +4 -4
- package/dist/{hub-docker-target-QEALUMIZ.js → hub-docker-target-6ODSK7ZE.js} +14 -14
- package/dist/index.js +1224 -230
- package/dist/index.js.map +1 -1
- package/dist/{plugin-update-LG45ZFCU.js → plugin-update-LI3QDA4K.js} +5 -5
- package/dist/prepare-MYFNDJPP.js +45 -0
- package/dist/prepared-custody-WSHX6XTQ.js +39 -0
- package/dist/{prepared-state-FO74QUCP-SW3QMBW5.js → prepared-state-FO74QUCP-M4Q2X3KN.js} +4 -4
- package/dist/{publish-credentials-T7DDJVC4.js → publish-credentials-FCEQSIPE.js} +9 -9
- package/dist/{registry-UCFNYOAU.js → registry-GG23NEBF.js} +5 -5
- package/dist/relay-YUOIK3HN.js +22 -0
- package/dist/{remote-docker-share-SY7CWW5R.js → remote-docker-share-4Z4VVUPG.js} +11 -11
- package/dist/remote-docker-share-4Z4VVUPG.js.map +1 -0
- package/dist/{tool-grant-push-OJHLVAPZ.js → tool-grant-push-A2JYLJVF.js} +3 -3
- package/package.json +1 -1
- package/runtime/_shared/ctl.cjs +1046 -316
- package/runtime/digitalocean/ctl.cjs +1046 -316
- package/runtime/docker/packages/ctl/dist/bin.cjs +1046 -316
- package/runtime/e2b/ctl.cjs +1046 -316
- package/runtime/hetzner/ctl.cjs +1046 -316
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +24 -0
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/routes-manifest.json +188 -0
- package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js +4 -4
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/agent/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/backup/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/backup/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/checkpoint/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/checkpoint/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/clone/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/clone/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js +4 -4
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/logs/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/upload/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/upload/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/web/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js +4 -4
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/checkpoints/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/[...path]/route.js +3 -3
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/attach/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/attach/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/attach/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/attach/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/attach/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/attach/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/attach/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/message/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/message/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/message/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/message/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/message/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/message/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/message/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/notes/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/notes/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/notes/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/notes/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/notes/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/notes/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/notes/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/resume/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/resume/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/resume/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/resume/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/resume/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/resume/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/resume/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/stop/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/stop/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/stop/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/stop/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/stop/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/stop/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/[id]/stop/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/detect/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/detect/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/detect/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/detect/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/detect/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/detect/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/detect/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/managers/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/bots/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/create-preflight/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/create-preflight/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/restore/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/restore/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/seed/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/size-check/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/size-check/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/prune/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/prune/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/system/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/tasks/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/tasks/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/tasks/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/tasks/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/tasks/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/tasks/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/tasks/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rename/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rename/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rename/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rename/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rename/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rename/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rename/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rescan/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rescan/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rescan/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rescan/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rescan/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rescan/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/rescan/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/tasks/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/timeline/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/timeline/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/timeline/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/timeline/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/timeline/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/timeline/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/[id]/timeline/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/route.js +10 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/workspaces/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/web/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/custody/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/custody/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/system/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/system/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +24 -0
- package/runtime/hub/apps/hub/.next/server/chunks/00je_(dashboard)_api_v1_workspaces_[id]_tasks_[taskId]_assign_route_actions_1sufsej.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/00je_(dashboard)_api_v1_workspaces_[id]_tasks_[taskId]_done_route_actions_216dixx.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_api_v1_managers_route_actions_1_vtgih.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_api_v1_tasks_route_actions_1h8tg_m.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/05v5_app_(dashboard)_api_v1_workspaces_[id]_managers_sessions_route_actions_16dksub.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/05v5_app_(dashboard)_api_v1_workspaces_[id]_managers_start_route_actions_1g-vmis.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/05v5_app_(dashboard)_api_v1_workspaces_[id]_tasks_[taskId]_route_actions_03oih6y.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/05v5_app_(dashboard)_api_v1_workspaces_[id]_tasks_assign_route_actions_196zwo9.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/05v5_app_(dashboard)_api_v1_workspaces_[id]_tasks_reorder_route_actions_1zkcfk-.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_workspaces_route_actions_12a7_y8.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/0web_next-internal_server_app_(dashboard)_api_v1_managers_[id]_route_actions_07cpyb_.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_managers_[id]_attach_route_actions_0o-khw8.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_managers_[id]_message_route_actions_0rjcqe5.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_managers_[id]_notes_route_actions_1-mf4r_.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_managers_[id]_resume_route_actions_0-cm1mu.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_managers_[id]_stop_route_actions_16nrl1r.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_managers_detect_route_actions_1sdbs-_.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_workspaces_[id]_managers_route_actions_1sxymv0.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_workspaces_[id]_rename_route_actions_0df5zi2.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_workspaces_[id]_rescan_route_actions_1yra_w8.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_workspaces_[id]_route_actions_1f56n_0.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_workspaces_[id]_tasks_route_actions_1t-6quw.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_workspaces_[id]_timeline_route_actions_0pbxblt.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1viy_api_v1_workspaces_[id]_tasks_[taskId]_unassign_route_actions_18a1p_r.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0-c97gb._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0spnud2._.js → [root-of-the-server]__0-kl55b._.js} +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__074mxl5._.js → [root-of-the-server]__0-xlf9z._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__028ifqb._.js → [root-of-the-server]__0004tsz._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__00bupbc._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1cpr4qy._.js → [root-of-the-server]__0126167._.js} +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__01fy5q0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__02c077x._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1ta1gr1._.js → [root-of-the-server]__02sueng._.js} +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0nndlre._.js → [root-of-the-server]__04-gm8c._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__05uinnp._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__06wy8zz._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__071c-t4._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__08jg8w8._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__09059m-._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__092y7_z._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__09ti2-t._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__09y4pdw._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0_mog_h._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0a689u5._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0a8ere2._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0bzqrje._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c_r3oe._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0cdoz9i._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0cmu4sk._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0cxjxz0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d27tlu._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d3fx1z._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0dm5oqm._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0dy5g2k._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0e1uaxg._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0e6_t-d._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ets4cd._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0f2u0ul._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0f9p_4f._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0f_jmq2._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0fksz_r._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0fpygqn._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0gym-rp._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0hhlb2_._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0i9phow._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ikyoac._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0j72bti._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0jb371p._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0jq6cdw._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0jt1d2s._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0kcw8t0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0kdt9-i._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0l27vs0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0lc-j_n._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0lna-vq._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0m5woxc._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0mi9xib._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0muy7eg._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0nn0_b5._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0no30or._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0o3sjtx._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0onk5r0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0pik2ie._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0qde3vr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0qt_r6a._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ry8baf._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0sg4y_2._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0sgjn2j._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0st6oln._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0t0p64l._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0tbl11-._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ve_tqz._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w4smfx._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0wo4sqj._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0wujjkl._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0xbu3yj._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0xl1-w6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yct1tu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yg67t0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ykw5oe._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1c1rcl-._.js → [root-of-the-server]__0zznyx2._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1--u2xl._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-8sj4i._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__10kmcrt._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__10l_-cd._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__10yfcvu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__112hqrh._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11c-21i._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11qbpq8._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11s1mrd._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__128w1nz._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__12b2kuv._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__12gbq5m._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13nfpq5._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13vl4-h._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__153b7kv._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__157kmse._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16695dw._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__166_uek._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16o0ij7._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__175lucf._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__17p53e3._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__17y9pmx._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__18ec5_t._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__18xpvkc._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1925hyw._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__19ew1r2._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__19grunx._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_4v0mh._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_cbcl1._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_wb2uh._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_xgm2e._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1an6-yb._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1c0ex8m._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1c1e08-._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1c9f4uu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ci8hc2._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1cs6d52._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d60scp._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dicjoc._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1diipl4._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dp2exz._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1epnstn._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1fjnz2l._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1g5wnt2._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1g9v7bq._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1gon0_4._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h_59cs._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h_q3sn._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hlugb4._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hux-70._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1i-7bnu._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1i_el2y._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1j6clag._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1k6q17t._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1khvg39._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1lx9lyn._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1m36v6k._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mgu19x._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mhyrr5._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mk_lpu._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mt32fu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1n1_2tw._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1na4sdw._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ntihlm._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1odu62n._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q6xrlt._.js +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1r4x1-y._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1rjs_x0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1rxud0j._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1s5app0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1sjz59l._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1slo4q_._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thrazp._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1twtnwr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1txvsbk._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1uch-60._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1um2jum._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1vnnuo1._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1wegvep._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1wi5roz._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1xa9oiv._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ypmy86._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1zml9me._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1zrf_a6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__2019yzl._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20jyxyo._.js +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20ybhif._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20zl5fr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__212dyoi._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__218oup-._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__21abvx9._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/_0907rw0._.js +2 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0mcxq5g._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0vg6gvw._.js +41 -41
- package/runtime/hub/apps/hub/.next/server/chunks/apps_hub_app_(dashboard)_api_v1_lib_openapi_ts_1yokmzt._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/apps_hub_app_(dashboard)_api_v1_lib_validate_ts_16dhbzz._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/packages_agent-registry_dist_index_1ze3mqq.js +28 -19
- package/runtime/hub/apps/hub/.next/server/chunks/packages_relay_dist_control-plane_03a-9aj.js +6 -6
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__03-x9xy._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1jqga8h._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0r2xlss._.js +2 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_14-qzbg._.js +26 -26
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/packages_agent-registry_dist_index_0z476w4.js +26 -17
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/packages_relay_dist_control-plane_0ve-wz4.js +1 -1
- package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +24 -0
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/{31e1wjin30i__.css → 03_fxfc3849ms.css} +1 -1
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/boxes/[id]/[action]/route.ts +4 -2
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.ts +6 -4
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/boxes/route.ts +2 -1
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/actor.ts +48 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/envelope.ts +5 -2
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/openapi.ts +1687 -52
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/validate.ts +527 -1
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/[id]/attach/route.ts +26 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/[id]/message/route.ts +34 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/[id]/notes/route.ts +26 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/[id]/resume/route.ts +26 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/[id]/route.ts +34 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/[id]/stop/route.ts +23 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/detect/route.ts +33 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/managers/route.ts +27 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/tasks/route.ts +30 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/managers/route.ts +19 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/managers/sessions/route.ts +22 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/managers/start/route.ts +61 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/rename/route.ts +25 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/rescan/route.ts +20 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/route.ts +34 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/assign/route.ts +33 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/done/route.ts +23 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/route.ts +54 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/tasks/[taskId]/unassign/route.ts +25 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/tasks/assign/route.ts +34 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/tasks/reorder/route.ts +33 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/tasks/route.ts +59 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/[id]/timeline/route.ts +25 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/workspaces/route.ts +31 -0
- package/runtime/hub/apps/hub/{chunk-FQY5OEWX.js → chunk-2LE76CT3.js} +19 -6
- package/runtime/hub/apps/hub/{chunk-MIETKCV4.js → chunk-BR4WVGWJ.js} +3 -3
- package/runtime/hub/apps/hub/{chunk-KTWFE5BB.js → chunk-EVB2OTLU.js} +3312 -1032
- package/runtime/hub/apps/hub/{chunk-IDL7RJBP.js → chunk-FBNAIUXZ.js} +38 -3
- package/runtime/hub/apps/hub/{chunk-ORTYCJ2U.js → chunk-G2AEPH7C.js} +4 -4
- package/runtime/hub/apps/hub/{chunk-VNLPJ45F.js → chunk-JX5JUFSR.js} +9 -9
- package/runtime/hub/apps/hub/{chunk-PM2365RW.js → chunk-MD2UNTZR.js} +6 -6
- package/runtime/hub/apps/hub/{dist-4DVVLHK2.js → dist-3LDUYWPK.js} +8 -2
- package/runtime/hub/apps/hub/{dist-RWN4Z57N.js → dist-CJ6QFUFV.js} +5 -5
- package/runtime/hub/apps/hub/{dist-FM26NQ4V.js → dist-D36FTGG6.js} +1 -1
- package/runtime/hub/apps/hub/{dist-VF56FSKH.js → dist-GGLWLMY6.js} +6 -6
- package/runtime/hub/apps/hub/{dist-WA2LO2DU.js → dist-HLLYJGIT.js} +6 -6
- package/runtime/hub/apps/hub/{dist-OAS6A7E4.js → dist-IIQU4I42.js} +5 -5
- package/runtime/hub/apps/hub/{dist-3IYYT3II.js → dist-UFMCOK3W.js} +5 -5
- package/runtime/hub/apps/hub/{dist-LMXU56B2.js → dist-XUNBQ4WM.js} +5 -5
- package/runtime/hub/apps/hub/{dist-LOZYEDXA.js → dist-Y2263LMY.js} +8 -4
- package/runtime/hub/apps/hub/{dist-UPKSCLZ2.js → dist-YV4M6NJO.js} +5 -5
- package/runtime/hub/apps/hub/{hub-worker-6JAWRLP2.js → hub-worker-LJYEEAJL.js} +7 -7
- package/runtime/hub/apps/hub/lib/backend/background.ts +19 -0
- package/runtime/hub/apps/hub/lib/backend/box-facts.ts +97 -0
- package/runtime/hub/apps/hub/lib/backend/box-prs.ts +213 -0
- package/runtime/hub/apps/hub/lib/backend/deps.ts +99 -0
- package/runtime/hub/apps/hub/lib/backend/errors.ts +7 -0
- package/runtime/hub/apps/hub/lib/backend/github-prs.ts +302 -0
- package/runtime/hub/apps/hub/lib/backend/managers.ts +748 -0
- package/runtime/hub/apps/hub/lib/backend/timeline-lanes.ts +150 -0
- package/runtime/hub/apps/hub/lib/backend/timeline.ts +611 -0
- package/runtime/hub/apps/hub/lib/backend/workspaces.ts +439 -0
- package/runtime/hub/apps/hub/lib/boxes/backend-types.ts +355 -10
- package/runtime/hub/apps/hub/lib/boxes/postgres-source.ts +3 -0
- package/runtime/hub/apps/hub/lib/boxes/source.ts +18 -1
- package/runtime/hub/apps/hub/lib/boxes/types.ts +66 -0
- package/runtime/hub/apps/hub/lib/hub-backend.ts +114 -7
- package/runtime/hub/apps/hub/{prepared-state-FO74QUCP-QR6ZNI3Q.js → prepared-state-FO74QUCP-75UBPW5I.js} +3 -3
- package/runtime/hub/apps/hub/server.js +2033 -164
- package/runtime/hub/apps/hub/test/backend-managers-background.test.ts +336 -0
- package/runtime/hub/apps/hub/test/backend-managers.test.ts +493 -0
- package/runtime/hub/apps/hub/test/backend-workspaces.test.ts +208 -0
- package/runtime/hub/apps/hub/test/box-prs.test.ts +198 -0
- package/runtime/hub/apps/hub/test/timeline-lanes.test.ts +261 -0
- package/runtime/hub/apps/hub/test/timeline.test.ts +1185 -0
- package/runtime/hub/apps/hub/test/validate.test.ts +252 -0
- package/runtime/hub/apps/hub/tsconfig.tsbuildinfo +1 -1
- package/runtime/relay/bin.cjs +1419 -623
- package/runtime/vercel/ctl.cjs +1046 -316
- package/share/host-skills/agentbox-info/SKILL.md +25 -4
- package/dist/_cloud-attach-QB72ZV7T.js +0 -31
- package/dist/chunk-6RREIUAE.js.map +0 -1
- package/dist/chunk-7N3CJNR5.js.map +0 -1
- package/dist/chunk-FVBEUPVM.js.map +0 -1
- package/dist/chunk-QWUZJCF5.js.map +0 -1
- package/dist/chunk-XLFQXROC.js.map +0 -1
- package/dist/chunk-ZK6KD7ME.js.map +0 -1
- package/dist/hub-C5B3CRP6.js +0 -39
- package/dist/prepare-6JLTXX65.js +0 -45
- package/dist/prepared-custody-YVVTL2ZM.js +0 -39
- package/dist/relay-W73AIA35.js +0 -22
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__00o_3sf._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__08xwxyo._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-mtsr6._.js +0 -3
- /package/dist/{_cloud-attach-QB72ZV7T.js.map → _cloud-attach-6RKS3MAP.js.map} +0 -0
- /package/dist/{chunk-E2RPG54S.js.map → chunk-27S7QLDF.js.map} +0 -0
- /package/dist/{chunk-EZPCCJPE.js.map → chunk-2APGFWEU.js.map} +0 -0
- /package/dist/{chunk-7PDYVJ2Q.js.map → chunk-3AYSA62C.js.map} +0 -0
- /package/dist/{chunk-SHFU2KSY.js.map → chunk-3ISG5THX.js.map} +0 -0
- /package/dist/{chunk-D67Q5MNA.js.map → chunk-3L2DIPRM.js.map} +0 -0
- /package/dist/{chunk-GYUOXSUX.js.map → chunk-4FOXMGJ7.js.map} +0 -0
- /package/dist/{chunk-VIB2FMJJ.js.map → chunk-5OKDSI6M.js.map} +0 -0
- /package/dist/{chunk-Q3BHXL47.js.map → chunk-6XMOBI5V.js.map} +0 -0
- /package/dist/{chunk-VNXWOWQ7.js.map → chunk-7QTBRHB7.js.map} +0 -0
- /package/dist/{chunk-UWKJ3HIA.js.map → chunk-ANSPBIYG.js.map} +0 -0
- /package/dist/{chunk-EHLPIWRR.js.map → chunk-AWI2TSWS.js.map} +0 -0
- /package/dist/{chunk-GZHJVCBG.js.map → chunk-CDRKQ5BH.js.map} +0 -0
- /package/dist/{chunk-W7P2HHFI.js.map → chunk-CXAWPWGZ.js.map} +0 -0
- /package/dist/{chunk-V5IMDVV5.js.map → chunk-EDJ6O6CI.js.map} +0 -0
- /package/dist/{chunk-PYPIECDD.js.map → chunk-GSMQL4IJ.js.map} +0 -0
- /package/dist/{chunk-DKUSSE5G.js.map → chunk-JWQYZ6V4.js.map} +0 -0
- /package/dist/{chunk-WMILLMJZ.js.map → chunk-KOTW7QQW.js.map} +0 -0
- /package/dist/{chunk-XHCGVCSA.js.map → chunk-L4KBYI3I.js.map} +0 -0
- /package/dist/{chunk-BMZOMC6X.js.map → chunk-M2DWTQRF.js.map} +0 -0
- /package/dist/{chunk-MKZHCLFJ.js.map → chunk-MI3V2MAE.js.map} +0 -0
- /package/dist/{chunk-ZMNLEZJB.js.map → chunk-MO3QJTVS.js.map} +0 -0
- /package/dist/{chunk-MBFN2XNU.js.map → chunk-MPTE57BZ.js.map} +0 -0
- /package/dist/{chunk-RNYH5465.js.map → chunk-QBVRWGXD.js.map} +0 -0
- /package/dist/{chunk-VEO6ZYQY.js.map → chunk-RIXW4HSE.js.map} +0 -0
- /package/dist/{chunk-QER5WHBC.js.map → chunk-S7LPQXR5.js.map} +0 -0
- /package/dist/{chunk-QTMUJETE.js.map → chunk-TDPHZWJI.js.map} +0 -0
- /package/dist/{chunk-M42UQWVO.js.map → chunk-WLEGSKKE.js.map} +0 -0
- /package/dist/{chunk-UENVVGWE.js.map → chunk-WTOG3CC6.js.map} +0 -0
- /package/dist/{chunk-QB7XVOYW.js.map → chunk-X6CO4WIX.js.map} +0 -0
- /package/dist/{chunk-744IB5WM.js.map → chunk-XLJ4D4FI.js.map} +0 -0
- /package/dist/{chunk-SZTHLJ5J.js.map → chunk-XTNAIM7X.js.map} +0 -0
- /package/dist/{chunk-S3SJIWSU.js.map → chunk-YNAJUTYC.js.map} +0 -0
- /package/dist/{chunk-6GJDU3FN.js.map → chunk-YSACCMUB.js.map} +0 -0
- /package/dist/{cli-I6TXLNRQ.js.map → cli-IFXU5XNZ.js.map} +0 -0
- /package/dist/{cli-JNOPYAUM.js.map → cli-MZSWFSTW.js.map} +0 -0
- /package/dist/{cli-VU2ALT6L.js.map → cli-O3WXOFNS.js.map} +0 -0
- /package/dist/{cli-W2WNV64V.js.map → cli-RQJUQJEP.js.map} +0 -0
- /package/dist/{cli-YYXO4WX5.js.map → cli-ZGYSHJP7.js.map} +0 -0
- /package/dist/{control-plane-JUAINN2X.js.map → control-plane-3TII2JGM.js.map} +0 -0
- /package/dist/{cp-hub-upload-VHU5TBHQ.js.map → cp-hub-upload-3W7Z4BMT.js.map} +0 -0
- /package/dist/{custody-client-5OHF3SEX.js.map → custody-client-KYEZET6C.js.map} +0 -0
- /package/dist/{deploy-hetzner-RTQW3B7P.js.map → deploy-hetzner-EO5PFKBG.js.map} +0 -0
- /package/dist/{dist-64YIP2AZ.js.map → dist-3AR6L5MF.js.map} +0 -0
- /package/dist/{dist-5HJBDLJP.js.map → dist-4GHNQ2AK.js.map} +0 -0
- /package/dist/{dist-7IANPBF4.js.map → dist-BFH537FO.js.map} +0 -0
- /package/dist/{dist-EDCGUXVI.js.map → dist-BUCKUE4V.js.map} +0 -0
- /package/dist/{dist-H4FFY5TX.js.map → dist-ETGTZQUT.js.map} +0 -0
- /package/dist/{dist-H72NQCKO.js.map → dist-H2CSUDEI.js.map} +0 -0
- /package/dist/{dist-MBPDLQUR.js.map → dist-IABCQB5D.js.map} +0 -0
- /package/dist/{dist-NJOKYHDI.js.map → dist-JJZ3NZRO.js.map} +0 -0
- /package/dist/{dist-7RMVQOWJ.js.map → dist-RPBA2EL5.js.map} +0 -0
- /package/dist/{dist-UGI5L7BN.js.map → dist-URWWHI3X.js.map} +0 -0
- /package/dist/{dist-XWDFVTFR.js.map → dist-V224SH3Z.js.map} +0 -0
- /package/dist/{host-reach-drainer-GTNLQWWM.js.map → host-reach-drainer-NYN3YXHG.js.map} +0 -0
- /package/dist/{hub-C5B3CRP6.js.map → host-session-YP5RKV6T.js.map} +0 -0
- /package/dist/{hub-adopt-TVDMOZSP.js.map → hub-OWUC4IGW.js.map} +0 -0
- /package/dist/{hub-api-client-RISAC6GB.js.map → hub-adopt-HYXFUPPO.js.map} +0 -0
- /package/dist/{prepare-6JLTXX65.js.map → hub-api-client-BI3E37CF.js.map} +0 -0
- /package/dist/{hub-docker-target-QEALUMIZ.js.map → hub-docker-target-6ODSK7ZE.js.map} +0 -0
- /package/dist/{plugin-update-LG45ZFCU.js.map → plugin-update-LI3QDA4K.js.map} +0 -0
- /package/dist/{prepared-custody-YVVTL2ZM.js.map → prepare-MYFNDJPP.js.map} +0 -0
- /package/dist/{prepared-state-FO74QUCP-SW3QMBW5.js.map → prepared-custody-WSHX6XTQ.js.map} +0 -0
- /package/dist/{registry-UCFNYOAU.js.map → prepared-state-FO74QUCP-M4Q2X3KN.js.map} +0 -0
- /package/dist/{publish-credentials-T7DDJVC4.js.map → publish-credentials-FCEQSIPE.js.map} +0 -0
- /package/dist/{relay-W73AIA35.js.map → registry-GG23NEBF.js.map} +0 -0
- /package/dist/{remote-docker-share-SY7CWW5R.js.map → relay-YUOIK3HN.js.map} +0 -0
- /package/dist/{tool-grant-push-OJHLVAPZ.js.map → tool-grant-push-A2JYLJVF.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{kg0mtyaaNMvU3P8p7nLPa → QDhlg7V_fEVGv_NfM2cEJ}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{kg0mtyaaNMvU3P8p7nLPa → QDhlg7V_fEVGv_NfM2cEJ}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{kg0mtyaaNMvU3P8p7nLPa → QDhlg7V_fEVGv_NfM2cEJ}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
AGENT_SESSION_ENV_VARS,
|
|
3
4
|
STATE_DIR as STATE_DIR2,
|
|
4
5
|
STATE_FILE,
|
|
5
6
|
agentIds,
|
|
6
7
|
boxSshDirForProvider,
|
|
7
8
|
buildAgentDescriptors,
|
|
9
|
+
encodeClaudeProjectsKey,
|
|
8
10
|
findBox,
|
|
9
11
|
isSupportedApiVersion,
|
|
10
12
|
openOnHost,
|
|
@@ -16,9 +18,10 @@ import {
|
|
|
16
18
|
recordBox,
|
|
17
19
|
resolveAgentSpec,
|
|
18
20
|
resolveSshConfigTarget,
|
|
21
|
+
scrubAgentSessionEnv,
|
|
19
22
|
shouldAcceptCredentialUpdate,
|
|
20
23
|
writeCredentialBackup
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-ZKOLV4ZN.js";
|
|
22
25
|
import {
|
|
23
26
|
isContainedInWorkspace,
|
|
24
27
|
isResolvedBranch,
|
|
@@ -36,16 +39,20 @@ import {
|
|
|
36
39
|
resolveRemote,
|
|
37
40
|
sanitizeGitArgs,
|
|
38
41
|
upstreamRef
|
|
39
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-AWFTAHGF.js";
|
|
40
43
|
import {
|
|
41
44
|
BUILT_IN_DEFAULTS,
|
|
42
45
|
GLOBAL_CONFIG_FILE,
|
|
43
46
|
STATE_DIR,
|
|
47
|
+
hashProjectPath,
|
|
44
48
|
isValidToolName,
|
|
45
49
|
loadEffectiveConfig,
|
|
46
50
|
loadGrantedTools,
|
|
47
51
|
parseUserConfig,
|
|
52
|
+
projectDirSegment,
|
|
53
|
+
registerProject,
|
|
48
54
|
resolveProjectToolsFile,
|
|
55
|
+
withFileLock,
|
|
49
56
|
writeToolGrant
|
|
50
57
|
} from "./chunk-ES6DXNUA.js";
|
|
51
58
|
import {
|
|
@@ -74,7 +81,7 @@ import {
|
|
|
74
81
|
timestamp
|
|
75
82
|
} from "./chunk-6V366IZC.js";
|
|
76
83
|
|
|
77
|
-
// ../../packages/relay/dist/chunk-
|
|
84
|
+
// ../../packages/relay/dist/chunk-JONRP7IU.js
|
|
78
85
|
import { mkdir, rename, rm, writeFile } from "fs/promises";
|
|
79
86
|
import { homedir } from "os";
|
|
80
87
|
import { join } from "path";
|
|
@@ -90,10 +97,35 @@ import { dirname } from "path";
|
|
|
90
97
|
import { timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
91
98
|
import { createSign } from "crypto";
|
|
92
99
|
import { spawn } from "child_process";
|
|
93
|
-
import {
|
|
94
|
-
import {
|
|
95
|
-
import { closeSync, existsSync as existsSync2, openSync } from "fs";
|
|
100
|
+
import { existsSync as existsSync2 } from "fs";
|
|
101
|
+
import { tmpdir } from "os";
|
|
96
102
|
import { join as join2 } from "path";
|
|
103
|
+
import { mkdir as mkdir2, readdir, readFile, realpath, rename as rename2, rm as rm3, stat, writeFile as writeFile2 } from "fs/promises";
|
|
104
|
+
import { basename, join as join3 } from "path";
|
|
105
|
+
import { randomBytes } from "crypto";
|
|
106
|
+
import {
|
|
107
|
+
open,
|
|
108
|
+
readdir as readdir2,
|
|
109
|
+
readFile as readFile2,
|
|
110
|
+
realpath as realpath2,
|
|
111
|
+
rename as rename3,
|
|
112
|
+
rm as rm4,
|
|
113
|
+
stat as stat2,
|
|
114
|
+
writeFile as writeFile3,
|
|
115
|
+
mkdir as mkdir3
|
|
116
|
+
} from "fs/promises";
|
|
117
|
+
import { homedir as homedir2, hostname as osHostname } from "os";
|
|
118
|
+
import { basename as basename2, dirname as dirname2, join as join4 } from "path";
|
|
119
|
+
import { execa } from "execa";
|
|
120
|
+
import { execa as execa2 } from "execa";
|
|
121
|
+
import { mkdir as mkdir4, readFile as readFile3, rename as rename4, writeFile as writeFile4 } from "fs/promises";
|
|
122
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
123
|
+
import { appendFile, open as open2, readFile as readFile4, rename as rename5, stat as stat3, writeFile as writeFile5 } from "fs/promises";
|
|
124
|
+
import { spawn as spawn2 } from "child_process";
|
|
125
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
126
|
+
import { mkdir as mkdir5, readdir as readdir3, readFile as readFile5, rename as rename6, unlink, writeFile as writeFile6 } from "fs/promises";
|
|
127
|
+
import { closeSync, existsSync as existsSync3, openSync } from "fs";
|
|
128
|
+
import { join as join5 } from "path";
|
|
97
129
|
import { setTimeout as delay } from "timers/promises";
|
|
98
130
|
var DEFAULT_RELAY_PORT = 8787;
|
|
99
131
|
var DEFAULT_BOX_RELAY_PORT = 8788;
|
|
@@ -1149,8 +1181,8 @@ async function handleRemoteBoxesRequest(req, deps) {
|
|
|
1149
1181
|
async function reapLocalBoxState(boxId, sandboxId, log) {
|
|
1150
1182
|
let removed = false;
|
|
1151
1183
|
try {
|
|
1152
|
-
const { mutateState, readState:
|
|
1153
|
-
const state = await
|
|
1184
|
+
const { mutateState, readState: readState3, boxSshDirForProvider: boxSshDirForProvider2 } = await import("./dist-URWWHI3X.js");
|
|
1185
|
+
const state = await readState3();
|
|
1154
1186
|
const record = state.boxes.find((b) => b.id === boxId);
|
|
1155
1187
|
if (record) {
|
|
1156
1188
|
await mutateState((s) => ({ ...s, boxes: s.boxes.filter((b) => b.id !== boxId) }));
|
|
@@ -1399,186 +1431,2610 @@ var GitHubAppLeaser = class {
|
|
|
1399
1431
|
return { token: body.token, expiresAt: body.expires_at };
|
|
1400
1432
|
}
|
|
1401
1433
|
};
|
|
1402
|
-
var
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
const ceiling = typeof input.maxRunningOverride === "number" && input.maxRunningOverride > 0 ? input.maxRunningOverride : cfg.maxConcurrent;
|
|
1429
|
-
const maxWorking = typeof input.maxWorkingOverride === "number" && input.maxWorkingOverride > 0 ? input.maxWorkingOverride : void 0;
|
|
1430
|
-
const id = randomBytes(9).toString("hex");
|
|
1431
|
-
const job = {
|
|
1432
|
-
id,
|
|
1433
|
-
agent: input.agent,
|
|
1434
|
-
status: "queued",
|
|
1435
|
-
boxName: input.boxName,
|
|
1436
|
-
providerName: input.providerName,
|
|
1437
|
-
prompt: input.prompt,
|
|
1438
|
-
agentArgs: input.agentArgs,
|
|
1439
|
-
...input.noAgent ? { noAgent: true } : {},
|
|
1440
|
-
...input.setupWizard ? { setupWizard: true } : {},
|
|
1441
|
-
...input.foreground ? { foreground: true } : {},
|
|
1442
|
-
createOpts: input.createOpts,
|
|
1443
|
-
maxConcurrent: ceiling,
|
|
1444
|
-
...maxWorking !== void 0 ? { maxWorking } : {},
|
|
1445
|
-
...input.openTerminal !== void 0 ? { openTerminal: input.openTerminal } : {},
|
|
1446
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1447
|
-
logPath: queueLogPath(id)
|
|
1448
|
-
};
|
|
1449
|
-
await writeJob(job);
|
|
1450
|
-
let runningCount = 0;
|
|
1451
|
-
try {
|
|
1452
|
-
runningCount = await defaultCountRunningBoxes();
|
|
1453
|
-
} catch {
|
|
1454
|
-
runningCount = 0;
|
|
1434
|
+
var GH_BLOCKED = [
|
|
1435
|
+
{
|
|
1436
|
+
pattern: /^auth\s+(token|refresh)\b/i,
|
|
1437
|
+
why: "prints or rotates the host credential"
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
pattern: /^auth\s+(login|logout|switch|setup-git)\b/i,
|
|
1441
|
+
why: "changes the host's GitHub auth state, which the host owns"
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
pattern: /^config\s+set\b/i,
|
|
1445
|
+
why: "rewrites the host's gh configuration"
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
// `gh alias set x '!sh -c ...'` defines a shell escape that later runs on
|
|
1449
|
+
// the host under the host's credentials.
|
|
1450
|
+
pattern: /^alias\s+(set|delete|import)\b/i,
|
|
1451
|
+
why: "defines host-side command aliases that later run with host credentials"
|
|
1452
|
+
},
|
|
1453
|
+
{
|
|
1454
|
+
pattern: /^extension\s+(install|remove|upgrade|exec)\b/i,
|
|
1455
|
+
why: "installs or runs third-party code on the host"
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
pattern: /^(ssh-key|gpg-key)\s+(add|delete)\b/i,
|
|
1459
|
+
why: "changes the host account's keys"
|
|
1455
1460
|
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1483
|
-
logPath: queueLogPath(id)
|
|
1484
|
-
};
|
|
1485
|
-
await writeJob(job);
|
|
1486
|
-
return { job };
|
|
1487
|
-
}
|
|
1488
|
-
async function readJob(id) {
|
|
1489
|
-
try {
|
|
1490
|
-
const raw = await readFile(join2(QUEUE_DIR, `${id}.json`), "utf8");
|
|
1491
|
-
return JSON.parse(raw);
|
|
1492
|
-
} catch (err2) {
|
|
1493
|
-
if (err2.code === "ENOENT") return null;
|
|
1494
|
-
throw err2;
|
|
1461
|
+
];
|
|
1462
|
+
var GH_DESTRUCTIVE = [
|
|
1463
|
+
{ pattern: /^repo\s+(delete|archive|rename|transfer)\b/i, what: "repository" },
|
|
1464
|
+
{ pattern: /^release\s+delete(-asset)?\b/i, what: "release" },
|
|
1465
|
+
{ pattern: /^secret\s+(set|delete)\b/i, what: "repository secret" },
|
|
1466
|
+
{ pattern: /^variable\s+delete\b/i, what: "repository variable" },
|
|
1467
|
+
{ pattern: /^cache\s+delete\b/i, what: "Actions cache" },
|
|
1468
|
+
{ pattern: /^ruleset\b.*\b(delete|edit)\b/i, what: "repository ruleset" },
|
|
1469
|
+
{ pattern: /^org\s+\S*\b(delete|remove)\b/i, what: "organization" },
|
|
1470
|
+
{ pattern: /^gist\s+delete\b/i, what: "gist" },
|
|
1471
|
+
{ pattern: /^label\s+delete\b/i, what: "label" },
|
|
1472
|
+
{ pattern: /^project\s+(delete|item-delete|field-delete)\b/i, what: "project" },
|
|
1473
|
+
// `gh api -X DELETE` reaches all of the above through the raw API. gh
|
|
1474
|
+
// accepts `-X DELETE`, `-X=DELETE`, `-XDELETE` and `--method[= ]DELETE`,
|
|
1475
|
+
// so match every spelling — a missed one is a silent hole, not a typo.
|
|
1476
|
+
{ pattern: /(^|\s)(-X=?\s*|--method[=\s]+)(DELETE|PUT|PATCH)\b/i, what: "raw API write" },
|
|
1477
|
+
// `gh api graphql -f query='mutation { deleteRepository ... }'` is a POST,
|
|
1478
|
+
// so no method flag betrays it. GraphQL is a raw write channel with the same
|
|
1479
|
+
// reach as the REST verbs above; agents rarely need it, so confirming every
|
|
1480
|
+
// mutation is a cheap way to keep the hole shut.
|
|
1481
|
+
// Lookaheads rather than adjacency: the endpoint may be spelled `/graphql`,
|
|
1482
|
+
// and cobra accepts flags before it (`gh api --paginate graphql …`), so
|
|
1483
|
+
// requiring `api graphql` side by side left the hole open.
|
|
1484
|
+
{
|
|
1485
|
+
pattern: /^api\b(?=[\s\S]*\bgraphql\b)(?=[\s\S]*\bmutation\b)/i,
|
|
1486
|
+
what: "raw GraphQL mutation"
|
|
1495
1487
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1488
|
+
];
|
|
1489
|
+
var GH_GLOBAL_VALUE_FLAGS = /* @__PURE__ */ new Set(["-R", "--repo", "--hostname"]);
|
|
1490
|
+
function ghVerbArgv(args) {
|
|
1491
|
+
let i = 0;
|
|
1492
|
+
while (i < args.length) {
|
|
1493
|
+
const arg = args[i] ?? "";
|
|
1494
|
+
if (!arg.startsWith("-")) break;
|
|
1495
|
+
if (GH_GLOBAL_VALUE_FLAGS.has(arg)) i += 2;
|
|
1496
|
+
else i += 1;
|
|
1502
1497
|
}
|
|
1498
|
+
return args.slice(i);
|
|
1503
1499
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
if (!name.endsWith(".json")) continue;
|
|
1515
|
-
try {
|
|
1516
|
-
const raw = await readFile(join2(QUEUE_DIR, name), "utf8");
|
|
1517
|
-
out.push(JSON.parse(raw));
|
|
1518
|
-
} catch {
|
|
1500
|
+
function refuseBlockedGhCall(args) {
|
|
1501
|
+
const joined = ghVerbArgv(args).join(" ");
|
|
1502
|
+
for (const { pattern, why } of GH_BLOCKED) {
|
|
1503
|
+
if (pattern.test(joined)) {
|
|
1504
|
+
return {
|
|
1505
|
+
exitCode: 65,
|
|
1506
|
+
stdout: "",
|
|
1507
|
+
stderr: `gh ${joined}: refused \u2014 ${why}. The host runs gh with its own credentials, so the box never needs them.
|
|
1508
|
+
`
|
|
1509
|
+
};
|
|
1519
1510
|
}
|
|
1520
1511
|
}
|
|
1521
|
-
|
|
1522
|
-
return out;
|
|
1512
|
+
return null;
|
|
1523
1513
|
}
|
|
1524
|
-
function
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
if (
|
|
1528
|
-
if (j.foreground) continue;
|
|
1529
|
-
if (runningCount < j.maxConcurrent) return j;
|
|
1514
|
+
function ghDestructiveTarget(args) {
|
|
1515
|
+
const joined = ghVerbArgv(args).join(" ");
|
|
1516
|
+
for (const { pattern, what } of GH_DESTRUCTIVE) {
|
|
1517
|
+
if (pattern.test(joined)) return what;
|
|
1530
1518
|
}
|
|
1531
1519
|
return null;
|
|
1532
1520
|
}
|
|
1533
|
-
function
|
|
1534
|
-
for (const
|
|
1535
|
-
if (
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1521
|
+
function refuseGhApiInput(args) {
|
|
1522
|
+
for (const arg of args) {
|
|
1523
|
+
if (arg === "--input" || arg.startsWith("--input=")) {
|
|
1524
|
+
return {
|
|
1525
|
+
exitCode: 65,
|
|
1526
|
+
stdout: "",
|
|
1527
|
+
stderr: "gh api: '--input' (stdin/file body) isn't supported through the relay (the host gh runs with stdin ignored); use -f/-F fields\n"
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1539
1530
|
}
|
|
1540
1531
|
return null;
|
|
1541
1532
|
}
|
|
1542
|
-
function
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
if (typeof j.pid === "number" && !processAlive(j.pid)) continue;
|
|
1548
|
-
byProvider.set(j.providerName, (byProvider.get(j.providerName) ?? 0) + 1);
|
|
1549
|
-
}
|
|
1550
|
-
return byProvider;
|
|
1533
|
+
function injectPrCreateHead(op, branch, args) {
|
|
1534
|
+
if (op !== "create") return args;
|
|
1535
|
+
if (!branch || branch === "HEAD") return args;
|
|
1536
|
+
if (hasHeadArg(args)) return args;
|
|
1537
|
+
return ["--head", branch, ...args];
|
|
1551
1538
|
}
|
|
1552
|
-
function
|
|
1553
|
-
|
|
1554
|
-
if (j.kind !== "prepare") continue;
|
|
1555
|
-
if (j.status !== "queued") continue;
|
|
1556
|
-
const running = runningByProvider.get(j.providerName) ?? 0;
|
|
1557
|
-
if (running >= PREPARE_MAX_CONCURRENT_PER_PROVIDER) continue;
|
|
1558
|
-
return j;
|
|
1559
|
-
}
|
|
1560
|
-
return null;
|
|
1539
|
+
function hasHeadArg(args) {
|
|
1540
|
+
return args.some((a) => a === "--head" || a.startsWith("--head=") || a.startsWith("-H"));
|
|
1561
1541
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
if (e.agentState === "working" || e.agentState === "compacting") return true;
|
|
1565
|
-
if ((e.agentState === null || e.agentState === "unknown") && e.sinceCreateMs !== null && e.sinceCreateMs < STARTUP_GRACE_MS) {
|
|
1566
|
-
return true;
|
|
1567
|
-
}
|
|
1568
|
-
if ((e.agentState === "idle" || e.agentState === "waiting" || e.agentState === "end-plan" || e.agentState === "question") && e.sinceUpdateMs !== null && e.sinceUpdateMs < idleGraceMs) {
|
|
1569
|
-
return true;
|
|
1570
|
-
}
|
|
1571
|
-
return false;
|
|
1542
|
+
function prCreateHasExplicitHead(op, args) {
|
|
1543
|
+
return op === "create" && hasHeadArg(args);
|
|
1572
1544
|
}
|
|
1573
|
-
function
|
|
1574
|
-
return
|
|
1545
|
+
function prCreateNeedsHead(op, args) {
|
|
1546
|
+
return op === "create" && !hasHeadArg(args);
|
|
1575
1547
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1548
|
+
var PR_CREATE_NO_HEAD_REFUSAL = {
|
|
1549
|
+
exitCode: 65,
|
|
1550
|
+
stdout: "",
|
|
1551
|
+
stderr: "gh pr create: refusing to run without --head \u2014 could not resolve this box's branch, and falling back to the host repo's checked-out branch would open a PR for the wrong branch. Ensure the box branch is pushed, or pass --head <branch> explicitly.\n"
|
|
1552
|
+
};
|
|
1553
|
+
var GH_RPC_TIMEOUT_MS = 12e4;
|
|
1554
|
+
var GH_READY_CACHE_TTL_MS = 6e4;
|
|
1555
|
+
var ghReadyCache = /* @__PURE__ */ new Map();
|
|
1556
|
+
var ghInstalledCache;
|
|
1557
|
+
var sshHostCache = /* @__PURE__ */ new Map();
|
|
1558
|
+
async function resolveGhTarget(originUrl) {
|
|
1559
|
+
const derived = ghHostFromRemote(originUrl);
|
|
1560
|
+
if (!derived) return { host: null, error: await assertGhReady(null) };
|
|
1561
|
+
const expanded = derived.aliasable ? await expandSshHost(derived.host) : derived.host;
|
|
1562
|
+
if (expanded === "github.com") return { host: null, error: await assertGhReady(null) };
|
|
1563
|
+
const host = expanded ?? derived.host;
|
|
1564
|
+
const scoped = await assertGhReady(host);
|
|
1565
|
+
if (!scoped) return { host, error: null };
|
|
1566
|
+
if (scoped.exitCode !== 4) return { host: null, error: scoped };
|
|
1567
|
+
if (expanded === null) {
|
|
1568
|
+
const generic = await assertGhReady(null);
|
|
1569
|
+
return { host: null, error: generic ? scoped : null };
|
|
1570
|
+
}
|
|
1571
|
+
return { host: null, error: scoped };
|
|
1572
|
+
}
|
|
1573
|
+
async function expandSshHost(host) {
|
|
1574
|
+
const now = Date.now();
|
|
1575
|
+
const cached = sshHostCache.get(host);
|
|
1576
|
+
if (cached && cached.expiresAt > now) return cached.host;
|
|
1577
|
+
let resolved = null;
|
|
1578
|
+
try {
|
|
1579
|
+
const target = await resolveSshConfigTarget(host);
|
|
1580
|
+
const value = target?.host.trim().toLowerCase() ?? "";
|
|
1581
|
+
resolved = value.length > 0 ? value : null;
|
|
1582
|
+
} catch {
|
|
1583
|
+
resolved = null;
|
|
1584
|
+
}
|
|
1585
|
+
sshHostCache.set(host, { host: resolved, expiresAt: now + GH_READY_CACHE_TTL_MS });
|
|
1586
|
+
return resolved;
|
|
1587
|
+
}
|
|
1588
|
+
async function assertGhReady(host) {
|
|
1589
|
+
const key = host ?? "";
|
|
1590
|
+
const now = Date.now();
|
|
1591
|
+
const cached = ghReadyCache.get(key);
|
|
1592
|
+
if (cached && cached.expiresAt > now) return cached.result;
|
|
1593
|
+
const result = await probeGh(host ?? null);
|
|
1594
|
+
ghReadyCache.set(key, { result, expiresAt: now + GH_READY_CACHE_TTL_MS });
|
|
1595
|
+
return result;
|
|
1596
|
+
}
|
|
1597
|
+
function _resetGhReadyCacheForTests() {
|
|
1598
|
+
ghReadyCache.clear();
|
|
1599
|
+
ghInstalledCache = void 0;
|
|
1600
|
+
sshHostCache.clear();
|
|
1601
|
+
}
|
|
1602
|
+
async function probeGh(host) {
|
|
1603
|
+
const installed = await probeGhInstalled();
|
|
1604
|
+
if (installed) return installed;
|
|
1605
|
+
if (firstNonEmptyEnv(ghTokenEnvNames(host))) return null;
|
|
1606
|
+
const auth = await runHostGh(
|
|
1607
|
+
host ? ["auth", "status", "--hostname", host] : ["auth", "status"],
|
|
1608
|
+
process.cwd(),
|
|
1609
|
+
{ timeoutMs: 15e3 }
|
|
1610
|
+
);
|
|
1611
|
+
if (auth.exitCode !== 0) {
|
|
1612
|
+
return {
|
|
1613
|
+
exitCode: 4,
|
|
1614
|
+
stdout: "",
|
|
1615
|
+
stderr: host ? `gh not authenticated on host for ${host} (run \`gh auth login --hostname ${host}\`)
|
|
1616
|
+
` : "gh not authenticated on host (run `gh auth login`)\n"
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
return null;
|
|
1620
|
+
}
|
|
1621
|
+
async function probeGhInstalled() {
|
|
1622
|
+
const now = Date.now();
|
|
1623
|
+
if (ghInstalledCache && ghInstalledCache.expiresAt > now) return ghInstalledCache.result;
|
|
1624
|
+
const result = await probeGhVersion();
|
|
1625
|
+
ghInstalledCache = { result, expiresAt: now + GH_READY_CACHE_TTL_MS };
|
|
1626
|
+
return result;
|
|
1627
|
+
}
|
|
1628
|
+
async function probeGhVersion() {
|
|
1629
|
+
const version = await runHostGh(["--version"], process.cwd(), { timeoutMs: 1e4 });
|
|
1630
|
+
if (version.exitCode === 127 || /ENOENT/.test(version.stderr)) {
|
|
1631
|
+
return {
|
|
1632
|
+
exitCode: 127,
|
|
1633
|
+
stdout: "",
|
|
1634
|
+
stderr: "gh not installed on host (https://cli.github.com)\n"
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
if (version.exitCode !== 0) {
|
|
1638
|
+
return {
|
|
1639
|
+
exitCode: version.exitCode,
|
|
1640
|
+
stdout: "",
|
|
1641
|
+
stderr: `gh --version failed: ${version.stderr || version.stdout}`.trimEnd() + "\n"
|
|
1642
|
+
};
|
|
1643
|
+
}
|
|
1644
|
+
return null;
|
|
1645
|
+
}
|
|
1646
|
+
function ghTokenEnvNames(host) {
|
|
1647
|
+
if (host === null) return ["GH_TOKEN", "GITHUB_TOKEN"];
|
|
1648
|
+
const enterprise = ["GH_ENTERPRISE_TOKEN", "GITHUB_ENTERPRISE_TOKEN"];
|
|
1649
|
+
return host.endsWith(".ghe.com") ? [...enterprise, "GH_TOKEN", "GITHUB_TOKEN"] : enterprise;
|
|
1650
|
+
}
|
|
1651
|
+
function firstNonEmptyEnv(names) {
|
|
1652
|
+
for (const name of names) {
|
|
1653
|
+
const value = process.env[name];
|
|
1654
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
1655
|
+
}
|
|
1656
|
+
return null;
|
|
1657
|
+
}
|
|
1658
|
+
function ghRunContext(workspacePath, originUrl, args) {
|
|
1659
|
+
if (workspacePath.length > 0 && existsSync2(workspacePath)) {
|
|
1660
|
+
return { cwd: workspacePath, args };
|
|
1661
|
+
}
|
|
1662
|
+
const origin = originUrl?.trim() ?? "";
|
|
1663
|
+
const alreadyScoped = args.some((a) => a === "--repo" || a === "-R" || a.startsWith("--repo="));
|
|
1664
|
+
if (origin.length === 0 || alreadyScoped) return { cwd: tmpdir(), args };
|
|
1665
|
+
try {
|
|
1666
|
+
return { cwd: tmpdir(), args: ["--repo", repoSlugFromRemote(origin), ...args] };
|
|
1667
|
+
} catch {
|
|
1668
|
+
return { cwd: tmpdir(), args };
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
function runHostGh(args, cwd, opts = {}) {
|
|
1672
|
+
const timeoutMs = opts.timeoutMs ?? GH_RPC_TIMEOUT_MS;
|
|
1673
|
+
return new Promise((resolve) => {
|
|
1674
|
+
const child = spawn("gh", args, {
|
|
1675
|
+
cwd,
|
|
1676
|
+
// GH_HOST is what points gh at a GitHub Enterprise Server instance; without
|
|
1677
|
+
// it gh targets github.com no matter what the repo's remote says.
|
|
1678
|
+
env: opts.host ? { ...process.env, GH_HOST: opts.host } : process.env,
|
|
1679
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1680
|
+
});
|
|
1681
|
+
let stdout = "";
|
|
1682
|
+
let stderr = "";
|
|
1683
|
+
let settled = false;
|
|
1684
|
+
const finish = (exitCode) => {
|
|
1685
|
+
if (settled) return;
|
|
1686
|
+
settled = true;
|
|
1687
|
+
resolve({ exitCode, stdout, stderr });
|
|
1688
|
+
};
|
|
1689
|
+
const timer = setTimeout(() => {
|
|
1690
|
+
child.kill("SIGTERM");
|
|
1691
|
+
stderr += `
|
|
1692
|
+
relay: gh command timed out after ${String(timeoutMs)}ms
|
|
1693
|
+
`;
|
|
1694
|
+
finish(124);
|
|
1695
|
+
}, timeoutMs);
|
|
1696
|
+
child.stdout?.on("data", (chunk) => {
|
|
1697
|
+
stdout += chunk.toString("utf8");
|
|
1698
|
+
});
|
|
1699
|
+
child.stderr?.on("data", (chunk) => {
|
|
1700
|
+
stderr += chunk.toString("utf8");
|
|
1701
|
+
});
|
|
1702
|
+
child.on("error", (err2) => {
|
|
1703
|
+
clearTimeout(timer);
|
|
1704
|
+
const code = err2.code;
|
|
1705
|
+
stderr += String(err2.message ?? err2);
|
|
1706
|
+
finish(code === "ENOENT" ? 127 : 1);
|
|
1707
|
+
});
|
|
1708
|
+
child.on("close", (code) => {
|
|
1709
|
+
clearTimeout(timer);
|
|
1710
|
+
finish(code ?? -1);
|
|
1711
|
+
});
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
async function checkoutGuards(hostMainRepo, registeredBranches) {
|
|
1715
|
+
const status = await runGitProbe(["-C", hostMainRepo, "status", "--porcelain"]);
|
|
1716
|
+
if (status.exitCode !== 0) {
|
|
1717
|
+
return {
|
|
1718
|
+
exitCode: status.exitCode,
|
|
1719
|
+
stdout: "",
|
|
1720
|
+
stderr: `gh pr checkout: failed to inspect host repo: ${status.stderr || status.stdout}`.trimEnd() + "\n"
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
if (status.stdout.trim().length > 0) {
|
|
1724
|
+
return {
|
|
1725
|
+
exitCode: 12,
|
|
1726
|
+
stdout: "",
|
|
1727
|
+
stderr: `gh pr checkout: ${hostMainRepo} has uncommitted changes; refusing to switch branches
|
|
1728
|
+
`
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
const head = await runGitProbe(["-C", hostMainRepo, "rev-parse", "--abbrev-ref", "HEAD"]);
|
|
1732
|
+
if (head.exitCode !== 0) {
|
|
1733
|
+
return {
|
|
1734
|
+
exitCode: head.exitCode,
|
|
1735
|
+
stdout: "",
|
|
1736
|
+
stderr: `gh pr checkout: failed to resolve HEAD: ${head.stderr || head.stdout}`.trimEnd() + "\n"
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
const currentBranch = head.stdout.trim();
|
|
1740
|
+
if (registeredBranches.includes(currentBranch)) {
|
|
1741
|
+
return {
|
|
1742
|
+
exitCode: 12,
|
|
1743
|
+
stdout: "",
|
|
1744
|
+
stderr: `gh pr checkout: ${hostMainRepo} is on registered box branch ${currentBranch}; refusing (would corrupt the bind-mounted box HEAD)
|
|
1745
|
+
`
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
function runGitProbe(args) {
|
|
1751
|
+
return new Promise((resolve) => {
|
|
1752
|
+
const child = spawn("git", args, { env: process.env, stdio: ["ignore", "pipe", "pipe"] });
|
|
1753
|
+
let stdout = "";
|
|
1754
|
+
let stderr = "";
|
|
1755
|
+
child.stdout?.on("data", (c) => {
|
|
1756
|
+
stdout += c.toString("utf8");
|
|
1757
|
+
});
|
|
1758
|
+
child.stderr?.on("data", (c) => {
|
|
1759
|
+
stderr += c.toString("utf8");
|
|
1760
|
+
});
|
|
1761
|
+
child.on("error", (err2) => {
|
|
1762
|
+
resolve({ exitCode: 127, stdout, stderr: stderr + String(err2.message ?? err2) });
|
|
1763
|
+
});
|
|
1764
|
+
child.on("close", (code) => {
|
|
1765
|
+
resolve({ exitCode: code ?? -1, stdout, stderr });
|
|
1766
|
+
});
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
function refuseCheckoutByDefault(op) {
|
|
1770
|
+
if (op !== "checkout") return null;
|
|
1771
|
+
if (process.env["AGENTBOX_GH_PR_CHECKOUT"] === "allow") return null;
|
|
1772
|
+
return {
|
|
1773
|
+
exitCode: 13,
|
|
1774
|
+
stdout: "",
|
|
1775
|
+
stderr: "gh pr checkout: disabled by default; set AGENTBOX_GH_PR_CHECKOUT=allow to enable\n"
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
var WORKSPACES_DIR = join2(STATE_DIR2, "workspaces");
|
|
1779
|
+
var WORK_TASK_STATUSES = [
|
|
1780
|
+
"todo",
|
|
1781
|
+
"in_progress",
|
|
1782
|
+
"blocked",
|
|
1783
|
+
"done"
|
|
1784
|
+
];
|
|
1785
|
+
var WORKSPACE_LOCK = { staleMs: 2e3, acquireTimeoutMs: 5e3 };
|
|
1786
|
+
var SCAN_SKIP = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "target", "vendor"]);
|
|
1787
|
+
function workspaceDir(id, root) {
|
|
1788
|
+
return join3(WORKSPACES_DIR, root ? projectDirSegment(root) : id);
|
|
1789
|
+
}
|
|
1790
|
+
function workspaceFile(dir) {
|
|
1791
|
+
return join3(dir, "workspace.json");
|
|
1792
|
+
}
|
|
1793
|
+
function tasksFile(dir) {
|
|
1794
|
+
return join3(dir, "tasks.json");
|
|
1795
|
+
}
|
|
1796
|
+
function timelineFile(dir) {
|
|
1797
|
+
return join3(dir, "timeline.jsonl");
|
|
1798
|
+
}
|
|
1799
|
+
function managersFile(dir) {
|
|
1800
|
+
return join3(dir, "managers.json");
|
|
1801
|
+
}
|
|
1802
|
+
function managerExitFile(dir, managerId) {
|
|
1803
|
+
return join3(dir, "managers", `${managerId}.exit`);
|
|
1804
|
+
}
|
|
1805
|
+
function legacyManagerFiles(dir) {
|
|
1806
|
+
return { rec: join3(dir, "manager.json"), exit: join3(dir, "manager.exit") };
|
|
1807
|
+
}
|
|
1808
|
+
async function resolveWorkspaceDir(id) {
|
|
1809
|
+
let entries;
|
|
1810
|
+
try {
|
|
1811
|
+
entries = await readdir(WORKSPACES_DIR);
|
|
1812
|
+
} catch (err2) {
|
|
1813
|
+
if (err2.code === "ENOENT") return null;
|
|
1814
|
+
throw err2;
|
|
1815
|
+
}
|
|
1816
|
+
for (const name of entries) {
|
|
1817
|
+
const m = /^([0-9a-f]{16})(?:-.+)?$/.exec(name);
|
|
1818
|
+
if (m && m[1] === id) return join3(WORKSPACES_DIR, name);
|
|
1819
|
+
}
|
|
1820
|
+
return null;
|
|
1821
|
+
}
|
|
1822
|
+
async function canonicalWorkspaceRoot(absPath) {
|
|
1823
|
+
const resolved = await realpath(absPath).catch(() => absPath);
|
|
1824
|
+
return resolved.length > 1 && resolved.endsWith("/") ? resolved.slice(0, -1) : resolved;
|
|
1825
|
+
}
|
|
1826
|
+
async function looksLikeProject(dir) {
|
|
1827
|
+
const [git, yaml] = await Promise.all([
|
|
1828
|
+
stat(join3(dir, ".git")).catch(() => null),
|
|
1829
|
+
stat(join3(dir, "agentbox.yaml")).catch(() => null)
|
|
1830
|
+
]);
|
|
1831
|
+
return git !== null || yaml !== null;
|
|
1832
|
+
}
|
|
1833
|
+
async function scanWorkspaceProjects(root) {
|
|
1834
|
+
const out = [];
|
|
1835
|
+
if (await looksLikeProject(root)) out.push(root);
|
|
1836
|
+
let entries;
|
|
1837
|
+
try {
|
|
1838
|
+
entries = await readdir(root, { withFileTypes: true });
|
|
1839
|
+
} catch {
|
|
1840
|
+
return out;
|
|
1841
|
+
}
|
|
1842
|
+
const subs = [];
|
|
1843
|
+
for (const e of entries) {
|
|
1844
|
+
if (!e.isDirectory() && !e.isSymbolicLink()) continue;
|
|
1845
|
+
if (e.name.startsWith(".") || SCAN_SKIP.has(e.name)) continue;
|
|
1846
|
+
const dir = join3(root, e.name);
|
|
1847
|
+
if (await looksLikeProject(dir)) subs.push(dir);
|
|
1848
|
+
}
|
|
1849
|
+
subs.sort((a, b) => a.localeCompare(b));
|
|
1850
|
+
out.push(...subs);
|
|
1851
|
+
return out;
|
|
1852
|
+
}
|
|
1853
|
+
async function readWorkspace(id) {
|
|
1854
|
+
const dir = await resolveWorkspaceDir(id);
|
|
1855
|
+
if (!dir) return null;
|
|
1856
|
+
try {
|
|
1857
|
+
const raw = await readFile(workspaceFile(dir), "utf8");
|
|
1858
|
+
return JSON.parse(raw);
|
|
1859
|
+
} catch (err2) {
|
|
1860
|
+
if (err2.code === "ENOENT") return null;
|
|
1861
|
+
return null;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
async function listWorkspaces() {
|
|
1865
|
+
let entries;
|
|
1866
|
+
try {
|
|
1867
|
+
entries = await readdir(WORKSPACES_DIR);
|
|
1868
|
+
} catch (err2) {
|
|
1869
|
+
if (err2.code === "ENOENT") return [];
|
|
1870
|
+
throw err2;
|
|
1871
|
+
}
|
|
1872
|
+
const out = [];
|
|
1873
|
+
for (const name of entries) {
|
|
1874
|
+
if (!/^[0-9a-f]{16}(?:-.+)?$/.test(name)) continue;
|
|
1875
|
+
try {
|
|
1876
|
+
const raw = await readFile(workspaceFile(join3(WORKSPACES_DIR, name)), "utf8");
|
|
1877
|
+
out.push(JSON.parse(raw));
|
|
1878
|
+
} catch {
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
out.sort((a, b) => a.name.localeCompare(b.name));
|
|
1882
|
+
return out;
|
|
1883
|
+
}
|
|
1884
|
+
async function writeWorkspace(rec) {
|
|
1885
|
+
const dir = await resolveWorkspaceDir(rec.id) ?? workspaceDir(rec.id, rec.root);
|
|
1886
|
+
await mkdir2(dir, { recursive: true });
|
|
1887
|
+
const final = workspaceFile(dir);
|
|
1888
|
+
const tmp = `${final}.tmp.${String(process.pid)}.${Date.now().toString(36)}`;
|
|
1889
|
+
await writeFile2(tmp, JSON.stringify(rec, null, 2) + "\n", "utf8");
|
|
1890
|
+
await rename2(tmp, final);
|
|
1891
|
+
}
|
|
1892
|
+
async function updateWorkspace(id, fn) {
|
|
1893
|
+
const dir = await resolveWorkspaceDir(id);
|
|
1894
|
+
if (!dir) return null;
|
|
1895
|
+
return withFileLock(
|
|
1896
|
+
workspaceFile(dir),
|
|
1897
|
+
async () => {
|
|
1898
|
+
const current = await readWorkspace(id);
|
|
1899
|
+
if (!current) return null;
|
|
1900
|
+
const next = { ...await fn(current), updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1901
|
+
await writeWorkspace(next);
|
|
1902
|
+
return next;
|
|
1903
|
+
},
|
|
1904
|
+
WORKSPACE_LOCK
|
|
1905
|
+
);
|
|
1906
|
+
}
|
|
1907
|
+
var defaultAddDeps = {
|
|
1908
|
+
register: (p) => registerProject(p)
|
|
1909
|
+
};
|
|
1910
|
+
async function addWorkspace(absPath, opts = {}, deps = {}) {
|
|
1911
|
+
const register = deps.register ?? defaultAddDeps.register;
|
|
1912
|
+
const root = await canonicalWorkspaceRoot(absPath);
|
|
1913
|
+
const id = hashProjectPath(root);
|
|
1914
|
+
const projectPaths = await scanWorkspaceProjects(root);
|
|
1915
|
+
await Promise.all(projectPaths.map((p) => register(p).catch(() => {
|
|
1916
|
+
})));
|
|
1917
|
+
const projectIds = projectPaths.map((p) => hashProjectPath(p));
|
|
1918
|
+
const dir = await resolveWorkspaceDir(id) ?? workspaceDir(id, root);
|
|
1919
|
+
return withFileLock(
|
|
1920
|
+
workspaceFile(dir),
|
|
1921
|
+
async () => {
|
|
1922
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1923
|
+
const existing = await readWorkspace(id);
|
|
1924
|
+
const rec = {
|
|
1925
|
+
id,
|
|
1926
|
+
name: opts.name ?? existing?.name ?? basename(root),
|
|
1927
|
+
root,
|
|
1928
|
+
projectIds,
|
|
1929
|
+
taskCounter: existing?.taskCounter ?? 0,
|
|
1930
|
+
createdAt: existing?.createdAt ?? now,
|
|
1931
|
+
updatedAt: now
|
|
1932
|
+
};
|
|
1933
|
+
await writeWorkspace(rec);
|
|
1934
|
+
return rec;
|
|
1935
|
+
},
|
|
1936
|
+
WORKSPACE_LOCK
|
|
1937
|
+
);
|
|
1938
|
+
}
|
|
1939
|
+
async function rescanWorkspace(id, deps = {}) {
|
|
1940
|
+
const current = await readWorkspace(id);
|
|
1941
|
+
if (!current) return null;
|
|
1942
|
+
return addWorkspace(current.root, { name: current.name }, deps);
|
|
1943
|
+
}
|
|
1944
|
+
async function renameWorkspace(id, name) {
|
|
1945
|
+
return updateWorkspace(id, (rec) => ({ ...rec, name }));
|
|
1946
|
+
}
|
|
1947
|
+
async function removeWorkspace(id) {
|
|
1948
|
+
const dir = await resolveWorkspaceDir(id);
|
|
1949
|
+
if (!dir) return false;
|
|
1950
|
+
await rm3(dir, { recursive: true, force: true });
|
|
1951
|
+
return true;
|
|
1952
|
+
}
|
|
1953
|
+
function toWorkspaceView(rec) {
|
|
1954
|
+
return {
|
|
1955
|
+
id: rec.id,
|
|
1956
|
+
name: rec.name,
|
|
1957
|
+
root: rec.root,
|
|
1958
|
+
projectIds: rec.projectIds,
|
|
1959
|
+
createdAt: rec.createdAt,
|
|
1960
|
+
updatedAt: rec.updatedAt
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
function findWorkspaceContaining(records, absPath) {
|
|
1964
|
+
const target = absPath.length > 1 && absPath.endsWith("/") ? absPath.slice(0, -1) : absPath;
|
|
1965
|
+
let best = null;
|
|
1966
|
+
for (const rec of records) {
|
|
1967
|
+
if (target !== rec.root && !target.startsWith(`${rec.root}/`)) continue;
|
|
1968
|
+
if (!best || rec.root.length > best.root.length) best = rec;
|
|
1969
|
+
}
|
|
1970
|
+
return best;
|
|
1971
|
+
}
|
|
1972
|
+
var defaultExec = (file, args, opts) => execa(file, args, opts);
|
|
1973
|
+
var SESSION_HEAD_BYTES = 256 * 1024;
|
|
1974
|
+
var SESSION_FIRST_LINE_MAX = 4 * 1024 * 1024;
|
|
1975
|
+
var SESSION_TITLE_MAX = 120;
|
|
1976
|
+
var SESSION_LIST_MAX = 50;
|
|
1977
|
+
var UNTITLED_SESSION = "(untitled)";
|
|
1978
|
+
var SESSION_INDEX_BYTES = 1024 * 1024;
|
|
1979
|
+
var ROLLOUT_SCAN_MAX = 200;
|
|
1980
|
+
var ROLLOUT_STAT_MAX = 2e3;
|
|
1981
|
+
var ROLLOUT_UUID_RE = /-([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\.jsonl$/u;
|
|
1982
|
+
var RESUME_ARGV = {
|
|
1983
|
+
claude: (id) => ["--resume", id],
|
|
1984
|
+
codex: (id) => ["resume", id]
|
|
1985
|
+
};
|
|
1986
|
+
var RESUMABLE_MANAGER_AGENTS = Object.keys(RESUME_ARGV);
|
|
1987
|
+
function isResumableManagerAgent(agent) {
|
|
1988
|
+
return RESUMABLE_MANAGER_AGENTS.includes(agent);
|
|
1989
|
+
}
|
|
1990
|
+
var DEFAULT_RESUMABLE_AGENT = RESUMABLE_MANAGER_AGENTS[0] ?? "claude";
|
|
1991
|
+
var MANAGER_ID_RE = /^[0-9a-f]{16}$/u;
|
|
1992
|
+
function newManagerId() {
|
|
1993
|
+
return randomBytes(8).toString("hex");
|
|
1994
|
+
}
|
|
1995
|
+
var MANAGER_SESSION_PREFIX = "agentbox-manager-";
|
|
1996
|
+
function managerSessionName(managerId) {
|
|
1997
|
+
return `${MANAGER_SESSION_PREFIX}${managerId}`;
|
|
1998
|
+
}
|
|
1999
|
+
var MANAGER_SESSION_RE = /^agentbox-manager-[0-9a-f]{16}$/u;
|
|
2000
|
+
function exactTarget(session) {
|
|
2001
|
+
return `=${session}`;
|
|
2002
|
+
}
|
|
2003
|
+
function managerAttachCommand(tmuxSession) {
|
|
2004
|
+
return `tmux attach -t ${exactTarget(tmuxSession)}`;
|
|
2005
|
+
}
|
|
2006
|
+
function buildManagerArgv(agent, sessionId, prompt) {
|
|
2007
|
+
if (!sessionId) return [agent];
|
|
2008
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/u.test(sessionId)) return [agent];
|
|
2009
|
+
const resume = RESUME_ARGV[agent];
|
|
2010
|
+
if (!resume) return [agent];
|
|
2011
|
+
const text3 = prompt?.trim();
|
|
2012
|
+
return text3 ? [agent, ...resume(sessionId), text3.startsWith("-") ? ` ${text3}` : text3] : [agent, ...resume(sessionId)];
|
|
2013
|
+
}
|
|
2014
|
+
function shellQuote(arg) {
|
|
2015
|
+
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
2016
|
+
}
|
|
2017
|
+
function shellJoin(argv) {
|
|
2018
|
+
return argv.map(shellQuote).join(" ");
|
|
2019
|
+
}
|
|
2020
|
+
function unsetAgentSessionEnv() {
|
|
2021
|
+
return `unset ${AGENT_SESSION_ENV_VARS.join(" ")}`;
|
|
2022
|
+
}
|
|
2023
|
+
function buildManagerShellScript(opts) {
|
|
2024
|
+
const exports = Object.entries(opts.env).map(([k, v]) => `export ${k}=${shellQuote(v)}`).join("; ");
|
|
2025
|
+
return `${unsetAgentSessionEnv()}; ${exports}; ${shellJoin(opts.argv)}; __agentbox_rc=$?; printf %s "$__agentbox_rc" > ${shellQuote(opts.exitFile)}; exit $__agentbox_rc`;
|
|
2026
|
+
}
|
|
2027
|
+
function loginShell(env = process.env) {
|
|
2028
|
+
if (env["SHELL"]) return env["SHELL"];
|
|
2029
|
+
return process.platform === "darwin" ? "/bin/zsh" : "/bin/bash";
|
|
2030
|
+
}
|
|
2031
|
+
async function tmuxAvailable(exec = defaultExec) {
|
|
2032
|
+
try {
|
|
2033
|
+
await exec("tmux", ["-V"]);
|
|
2034
|
+
return true;
|
|
2035
|
+
} catch {
|
|
2036
|
+
return false;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
async function tmuxSessionExists(session, exec = defaultExec) {
|
|
2040
|
+
try {
|
|
2041
|
+
await exec("tmux", ["has-session", "-t", exactTarget(session)]);
|
|
2042
|
+
return true;
|
|
2043
|
+
} catch {
|
|
2044
|
+
return false;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
async function dirFor(wsId) {
|
|
2048
|
+
return await resolveWorkspaceDir(wsId) ?? workspaceDir(wsId);
|
|
2049
|
+
}
|
|
2050
|
+
async function readManagerFile(dir) {
|
|
2051
|
+
try {
|
|
2052
|
+
const parsed = JSON.parse(await readFile2(managersFile(dir), "utf8"));
|
|
2053
|
+
return Array.isArray(parsed.managers) ? parsed.managers : [];
|
|
2054
|
+
} catch (err2) {
|
|
2055
|
+
if (err2.code === "ENOENT") return null;
|
|
2056
|
+
return [];
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
async function readLegacyManager(dir, wsId) {
|
|
2060
|
+
const files = legacyManagerFiles(dir);
|
|
2061
|
+
let legacy;
|
|
2062
|
+
try {
|
|
2063
|
+
legacy = JSON.parse(await readFile2(files.rec, "utf8"));
|
|
2064
|
+
} catch {
|
|
2065
|
+
return null;
|
|
2066
|
+
}
|
|
2067
|
+
if (typeof legacy.agent !== "string" || typeof legacy.cwd !== "string") return null;
|
|
2068
|
+
let lastExit = legacy.lastExit;
|
|
2069
|
+
let exitConsumed = false;
|
|
2070
|
+
if (lastExit === void 0) {
|
|
2071
|
+
lastExit = await readExitFile(files.exit);
|
|
2072
|
+
exitConsumed = lastExit !== void 0;
|
|
2073
|
+
}
|
|
2074
|
+
const at = legacy.startedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
2075
|
+
const record = {
|
|
2076
|
+
id: newManagerId(),
|
|
2077
|
+
workspaceId: wsId,
|
|
2078
|
+
agent: legacy.agent,
|
|
2079
|
+
kind: "hub",
|
|
2080
|
+
cwd: legacy.cwd,
|
|
2081
|
+
tmuxSession: legacy.tmuxSession ?? `agentbox-manager-${wsId}`,
|
|
2082
|
+
...legacy.argv ? { argv: legacy.argv } : {},
|
|
2083
|
+
...legacy.sessionId ? { sessionId: legacy.sessionId } : {},
|
|
2084
|
+
boxIds: [],
|
|
2085
|
+
boxJobIds: [],
|
|
2086
|
+
createdAt: at,
|
|
2087
|
+
lastSeenAt: legacy.stoppedAt ?? at,
|
|
2088
|
+
startedAt: at,
|
|
2089
|
+
...legacy.stoppedAt ? { stoppedAt: legacy.stoppedAt } : {},
|
|
2090
|
+
...lastExit === void 0 ? {} : { lastExit }
|
|
2091
|
+
};
|
|
2092
|
+
return { record, exitConsumed };
|
|
2093
|
+
}
|
|
2094
|
+
async function readExitFile(file) {
|
|
2095
|
+
const raw = await readFile2(file, "utf8").catch(() => "");
|
|
2096
|
+
const n = Number.parseInt(raw.trim(), 10);
|
|
2097
|
+
return Number.isNaN(n) ? void 0 : n;
|
|
2098
|
+
}
|
|
2099
|
+
function usesLegacySession(rec) {
|
|
2100
|
+
return rec.kind === "hub" && rec.tmuxSession !== void 0 && rec.tmuxSession !== managerSessionName(rec.id);
|
|
2101
|
+
}
|
|
2102
|
+
async function writeManagerFile(dir, managers) {
|
|
2103
|
+
const final = managersFile(dir);
|
|
2104
|
+
await mkdir3(dir, { recursive: true });
|
|
2105
|
+
const tmp = `${final}.tmp.${String(process.pid)}.${Date.now().toString(36)}`;
|
|
2106
|
+
const doc = { version: 1, managers };
|
|
2107
|
+
await writeFile3(tmp, JSON.stringify(doc, null, 2) + "\n", "utf8");
|
|
2108
|
+
await rename3(tmp, final);
|
|
2109
|
+
}
|
|
2110
|
+
async function updateManagers(wsId, fn) {
|
|
2111
|
+
const dir = await dirFor(wsId);
|
|
2112
|
+
return withFileLock(
|
|
2113
|
+
managersFile(dir),
|
|
2114
|
+
async () => {
|
|
2115
|
+
const current = await readManagerFile(dir);
|
|
2116
|
+
const legacy = current === null ? await readLegacyManager(dir, wsId) : null;
|
|
2117
|
+
const { managers, result } = await fn(current ?? (legacy ? [legacy.record] : []));
|
|
2118
|
+
await writeManagerFile(dir, managers);
|
|
2119
|
+
if (legacy) {
|
|
2120
|
+
const files = legacyManagerFiles(dir);
|
|
2121
|
+
await rm4(files.rec, { force: true }).catch(() => {
|
|
2122
|
+
});
|
|
2123
|
+
if (legacy.exitConsumed) await rm4(files.exit, { force: true }).catch(() => {
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
return result;
|
|
2127
|
+
},
|
|
2128
|
+
WORKSPACE_LOCK
|
|
2129
|
+
);
|
|
2130
|
+
}
|
|
2131
|
+
async function readManagers(wsId) {
|
|
2132
|
+
const dir = await resolveWorkspaceDir(wsId);
|
|
2133
|
+
if (!dir) return [];
|
|
2134
|
+
const current = await readManagerFile(dir);
|
|
2135
|
+
if (current !== null) return current;
|
|
2136
|
+
if (await stat2(legacyManagerFiles(dir).rec).catch(() => null) === null) return [];
|
|
2137
|
+
return updateManagers(wsId, (managers) => ({ managers, result: managers }));
|
|
2138
|
+
}
|
|
2139
|
+
async function allManagers() {
|
|
2140
|
+
const out = [];
|
|
2141
|
+
for (const ws of await listWorkspaces()) out.push(...await readManagers(ws.id));
|
|
2142
|
+
return out;
|
|
2143
|
+
}
|
|
2144
|
+
async function findManager(id) {
|
|
2145
|
+
return (await allManagers()).find((m) => m.id === id) ?? null;
|
|
2146
|
+
}
|
|
2147
|
+
async function findManagerBySession(agent, sessionId) {
|
|
2148
|
+
return (await allManagers()).find((m) => m.agent === agent && m.sessionId === sessionId) ?? null;
|
|
2149
|
+
}
|
|
2150
|
+
async function managerIdForTarget(target, opts = {}) {
|
|
2151
|
+
const hit = (await allManagers()).find(
|
|
2152
|
+
(m) => (opts.workspaceId === void 0 || m.workspaceId === opts.workspaceId) && ("boxId" in target ? m.boxIds.includes(target.boxId) : m.boxJobIds.includes(target.boxJobId))
|
|
2153
|
+
);
|
|
2154
|
+
return hit?.id;
|
|
2155
|
+
}
|
|
2156
|
+
async function patchManager(wsId, id, fn) {
|
|
2157
|
+
return updateManagers(wsId, (managers) => {
|
|
2158
|
+
const idx = managers.findIndex((m) => m.id === id);
|
|
2159
|
+
if (idx === -1) return { managers, result: null };
|
|
2160
|
+
const next = fn(managers[idx]);
|
|
2161
|
+
const out = [...managers];
|
|
2162
|
+
out[idx] = next;
|
|
2163
|
+
return { managers: out, result: next };
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
async function removeManagerRecord(wsId, id) {
|
|
2167
|
+
const removed = await updateManagers(wsId, (managers) => {
|
|
2168
|
+
const out = managers.filter((m) => m.id !== id);
|
|
2169
|
+
return { managers: out, result: out.length !== managers.length };
|
|
2170
|
+
});
|
|
2171
|
+
if (removed) await rm4(managerExitFile(await dirFor(wsId), id), { force: true }).catch(() => {
|
|
2172
|
+
});
|
|
2173
|
+
return removed;
|
|
2174
|
+
}
|
|
2175
|
+
var MANAGER_SEEN_WINDOW_MS = 30 * 60 * 1e3;
|
|
2176
|
+
function isPidAlive(pid) {
|
|
2177
|
+
try {
|
|
2178
|
+
process.kill(pid, 0);
|
|
2179
|
+
return true;
|
|
2180
|
+
} catch (err2) {
|
|
2181
|
+
return err2.code === "EPERM";
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
async function processStartTime(pid) {
|
|
2185
|
+
try {
|
|
2186
|
+
const r = await execa("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
2187
|
+
// lstart is locale-formatted: pin it so two reads compare equal.
|
|
2188
|
+
env: { ...process.env, LC_ALL: "C" },
|
|
2189
|
+
timeout: 2e3,
|
|
2190
|
+
reject: false
|
|
2191
|
+
});
|
|
2192
|
+
const out = r.exitCode === 0 ? r.stdout.trim() : "";
|
|
2193
|
+
return out || void 0;
|
|
2194
|
+
} catch {
|
|
2195
|
+
return void 0;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
async function managerStatus(rec, probe = {}) {
|
|
2199
|
+
if (rec.kind === "hub") {
|
|
2200
|
+
const session = rec.tmuxSession ?? managerSessionName(rec.id);
|
|
2201
|
+
return await tmuxSessionExists(session, probe.exec ?? defaultExec) ? "running" : "stopped";
|
|
2202
|
+
}
|
|
2203
|
+
const host = (probe.hostname ?? osHostname)();
|
|
2204
|
+
if (rec.pid !== void 0 && rec.host !== void 0 && rec.host === host) {
|
|
2205
|
+
if (!(probe.isPidAlive ?? isPidAlive)(rec.pid)) return "stopped";
|
|
2206
|
+
if (rec.pidStartedAt) {
|
|
2207
|
+
const started = await (probe.processStartTime ?? processStartTime)(rec.pid);
|
|
2208
|
+
if (started !== void 0 && started !== rec.pidStartedAt) return "stopped";
|
|
2209
|
+
}
|
|
2210
|
+
return "running";
|
|
2211
|
+
}
|
|
2212
|
+
const now = (probe.now ?? Date.now)();
|
|
2213
|
+
const seen = Date.parse(rec.lastSeenAt);
|
|
2214
|
+
return !Number.isNaN(seen) && now - seen < MANAGER_SEEN_WINDOW_MS ? "running" : "stopped";
|
|
2215
|
+
}
|
|
2216
|
+
async function readManagerExit(wsId, id, opts = {}) {
|
|
2217
|
+
const dir = await dirFor(wsId);
|
|
2218
|
+
const current = await readExitFile(managerExitFile(dir, id));
|
|
2219
|
+
if (current !== void 0 || !opts.legacy) return current;
|
|
2220
|
+
return readExitFile(legacyManagerFiles(dir).exit);
|
|
2221
|
+
}
|
|
2222
|
+
function ranElsewhere(rec, host) {
|
|
2223
|
+
return rec.kind === "external" && Boolean(rec.host) && rec.host !== host;
|
|
2224
|
+
}
|
|
2225
|
+
function managerResumeBlock(rec, status, host = osHostname()) {
|
|
2226
|
+
if (ranElsewhere(rec, host)) return "other-host";
|
|
2227
|
+
if (status === "running") return "running";
|
|
2228
|
+
if (!rec.sessionId) return "no-session";
|
|
2229
|
+
if (!isResumableManagerAgent(rec.agent)) return "unsupported-agent";
|
|
2230
|
+
return void 0;
|
|
2231
|
+
}
|
|
2232
|
+
function isManagerResumable(rec, status, host = osHostname()) {
|
|
2233
|
+
return managerResumeBlock(rec, status, host) === void 0;
|
|
2234
|
+
}
|
|
2235
|
+
function toManagerView(rec, ctx) {
|
|
2236
|
+
const block = managerResumeBlock(rec, ctx.status, ctx.hostname);
|
|
2237
|
+
const view = {
|
|
2238
|
+
...rec,
|
|
2239
|
+
status: ctx.status,
|
|
2240
|
+
resumable: block === void 0,
|
|
2241
|
+
...block ? { resumeBlockedBy: block } : {},
|
|
2242
|
+
workspaceName: ctx.workspaceName,
|
|
2243
|
+
taskCounts: {
|
|
2244
|
+
open: ctx.tasks.filter((t) => t.managerId === rec.id && t.status !== "done").length,
|
|
2245
|
+
done: ctx.tasks.filter((t) => t.managerId === rec.id && t.status === "done").length
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
delete view.argv;
|
|
2249
|
+
if (ctx.terminalSession) view.terminalSession = ctx.terminalSession;
|
|
2250
|
+
if (ctx.background) {
|
|
2251
|
+
view.background = ctx.background;
|
|
2252
|
+
if (ctx.attachSession) view.attachCommand = managerAttachCommand(ctx.attachSession);
|
|
2253
|
+
else if (rec.kind === "external") delete view.tmuxSession;
|
|
2254
|
+
}
|
|
2255
|
+
if (ctx.status === "running") {
|
|
2256
|
+
delete view.stoppedAt;
|
|
2257
|
+
delete view.lastExit;
|
|
2258
|
+
if (rec.kind === "hub" && !ctx.background) {
|
|
2259
|
+
view.attachCommand = managerAttachCommand(rec.tmuxSession ?? managerSessionName(rec.id));
|
|
2260
|
+
}
|
|
2261
|
+
} else if (view.lastExit === void 0 && ctx.lastExit !== void 0) {
|
|
2262
|
+
view.lastExit = ctx.lastExit;
|
|
2263
|
+
}
|
|
2264
|
+
return view;
|
|
2265
|
+
}
|
|
2266
|
+
async function upsertDetectedManager(wsId, input, now = /* @__PURE__ */ new Date()) {
|
|
2267
|
+
return updateManagers(
|
|
2268
|
+
wsId,
|
|
2269
|
+
(managers) => {
|
|
2270
|
+
const at = now.toISOString();
|
|
2271
|
+
let idx = managers.findIndex(
|
|
2272
|
+
(m) => m.agent === input.agent && m.sessionId === input.sessionId
|
|
2273
|
+
);
|
|
2274
|
+
if (idx === -1 && input.managerId) idx = managers.findIndex((m) => m.id === input.managerId);
|
|
2275
|
+
if (idx === -1) {
|
|
2276
|
+
const manager = input.tmuxSession ? {
|
|
2277
|
+
id: newManagerId(),
|
|
2278
|
+
workspaceId: wsId,
|
|
2279
|
+
agent: input.agent,
|
|
2280
|
+
kind: "hub",
|
|
2281
|
+
cwd: input.cwd,
|
|
2282
|
+
sessionId: input.sessionId,
|
|
2283
|
+
...input.host ? { host: input.host } : {},
|
|
2284
|
+
tmuxSession: input.tmuxSession,
|
|
2285
|
+
boxIds: [],
|
|
2286
|
+
boxJobIds: [],
|
|
2287
|
+
createdAt: at,
|
|
2288
|
+
lastSeenAt: at
|
|
2289
|
+
} : {
|
|
2290
|
+
id: newManagerId(),
|
|
2291
|
+
workspaceId: wsId,
|
|
2292
|
+
agent: input.agent,
|
|
2293
|
+
kind: "external",
|
|
2294
|
+
cwd: input.cwd,
|
|
2295
|
+
sessionId: input.sessionId,
|
|
2296
|
+
...input.host ? { host: input.host } : {},
|
|
2297
|
+
...input.pid !== void 0 ? { pid: input.pid } : {},
|
|
2298
|
+
...input.pid !== void 0 && input.pidStartedAt ? { pidStartedAt: input.pidStartedAt } : {},
|
|
2299
|
+
...input.tmuxPane ? { tmuxPane: input.tmuxPane } : {},
|
|
2300
|
+
boxIds: [],
|
|
2301
|
+
boxJobIds: [],
|
|
2302
|
+
createdAt: at,
|
|
2303
|
+
lastSeenAt: at
|
|
2304
|
+
};
|
|
2305
|
+
return {
|
|
2306
|
+
managers: [...managers, manager],
|
|
2307
|
+
result: { manager, created: true, sessionChanged: false }
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
const prev = managers[idx];
|
|
2311
|
+
const next = { ...prev, sessionId: input.sessionId, lastSeenAt: at };
|
|
2312
|
+
if (prev.sessionId !== input.sessionId) delete next.title;
|
|
2313
|
+
const fromOwnSession = input.managerId !== void 0 && input.managerId === prev.id;
|
|
2314
|
+
if (input.tmuxSession) {
|
|
2315
|
+
next.kind = "hub";
|
|
2316
|
+
next.tmuxSession = input.tmuxSession;
|
|
2317
|
+
delete next.pid;
|
|
2318
|
+
delete next.pidStartedAt;
|
|
2319
|
+
delete next.tmuxPane;
|
|
2320
|
+
delete next.stoppedAt;
|
|
2321
|
+
delete next.lastExit;
|
|
2322
|
+
} else if (prev.kind === "hub" && !fromOwnSession && input.pid !== void 0) {
|
|
2323
|
+
next.kind = "external";
|
|
2324
|
+
delete next.tmuxSession;
|
|
2325
|
+
delete next.argv;
|
|
2326
|
+
delete next.startedAt;
|
|
2327
|
+
delete next.stoppedAt;
|
|
2328
|
+
delete next.lastExit;
|
|
2329
|
+
}
|
|
2330
|
+
if (next.kind === "external") {
|
|
2331
|
+
if (input.pid !== void 0) next.pid = input.pid;
|
|
2332
|
+
else delete next.pid;
|
|
2333
|
+
if (input.pid !== void 0 && input.pidStartedAt) next.pidStartedAt = input.pidStartedAt;
|
|
2334
|
+
else delete next.pidStartedAt;
|
|
2335
|
+
if (input.host) next.host = input.host;
|
|
2336
|
+
if (input.tmuxPane) next.tmuxPane = input.tmuxPane;
|
|
2337
|
+
else delete next.tmuxPane;
|
|
2338
|
+
}
|
|
2339
|
+
const out = [...managers];
|
|
2340
|
+
out[idx] = next;
|
|
2341
|
+
return {
|
|
2342
|
+
managers: out,
|
|
2343
|
+
result: {
|
|
2344
|
+
manager: next,
|
|
2345
|
+
created: false,
|
|
2346
|
+
sessionChanged: prev.sessionId !== input.sessionId
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
);
|
|
2351
|
+
}
|
|
2352
|
+
async function attachBoxToManager(wsId, id, target) {
|
|
2353
|
+
return patchManager(wsId, id, (rec) => {
|
|
2354
|
+
if ("boxId" in target) {
|
|
2355
|
+
return rec.boxIds.includes(target.boxId) ? rec : { ...rec, boxIds: [...rec.boxIds, target.boxId] };
|
|
2356
|
+
}
|
|
2357
|
+
return rec.boxJobIds.includes(target.boxJobId) ? rec : { ...rec, boxJobIds: [...rec.boxJobIds, target.boxJobId] };
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
var FAILED_JOB_STATUSES = /* @__PURE__ */ new Set(["failed", "cancelled"]);
|
|
2361
|
+
function reconcileManagers(managers, ctx) {
|
|
2362
|
+
const jobById = new Map(ctx.jobs.map((j) => [j.id, j]));
|
|
2363
|
+
let changed = false;
|
|
2364
|
+
const out = managers.map((m) => {
|
|
2365
|
+
const boxIds = [...m.boxIds];
|
|
2366
|
+
const boxJobIds = [];
|
|
2367
|
+
for (const jobId of m.boxJobIds) {
|
|
2368
|
+
const job = jobById.get(jobId);
|
|
2369
|
+
if (job?.boxId) {
|
|
2370
|
+
if (!boxIds.includes(job.boxId)) boxIds.push(job.boxId);
|
|
2371
|
+
continue;
|
|
2372
|
+
}
|
|
2373
|
+
if (job && FAILED_JOB_STATUSES.has(job.status)) continue;
|
|
2374
|
+
boxJobIds.push(jobId);
|
|
2375
|
+
}
|
|
2376
|
+
const kept = boxIds.filter(
|
|
2377
|
+
(boxId) => ctx.liveBoxIds.has(boxId) || ctx.jobs.some(
|
|
2378
|
+
(j) => j.boxId === boxId && !FAILED_JOB_STATUSES.has(j.status) && j.status !== "done"
|
|
2379
|
+
)
|
|
2380
|
+
);
|
|
2381
|
+
const same = kept.length === m.boxIds.length && kept.every((b, i) => b === m.boxIds[i]) && boxJobIds.length === m.boxJobIds.length;
|
|
2382
|
+
if (same) return m;
|
|
2383
|
+
changed = true;
|
|
2384
|
+
return { ...m, boxIds: kept, boxJobIds };
|
|
2385
|
+
});
|
|
2386
|
+
return { managers: out, changed };
|
|
2387
|
+
}
|
|
2388
|
+
async function readReconciledManagers(wsId, ctx) {
|
|
2389
|
+
const current = await readManagers(wsId);
|
|
2390
|
+
if (current.length === 0 || !reconcileManagers(current, ctx).changed) return current;
|
|
2391
|
+
return updateManagers(wsId, (managers) => {
|
|
2392
|
+
const { managers: healed } = reconcileManagers(managers, ctx);
|
|
2393
|
+
return { managers: healed, result: healed };
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
var ManagerConflictError = class extends Error {
|
|
2397
|
+
};
|
|
2398
|
+
var FOOTER_BAR_STYLE = "bg=#303030,fg=colour250";
|
|
2399
|
+
function tmuxFormatText(text3) {
|
|
2400
|
+
return text3.replace(/#/gu, "##").replace(/%/gu, "%%");
|
|
2401
|
+
}
|
|
2402
|
+
function managerStatusFormat(input) {
|
|
2403
|
+
const hint = (key, label2) => `#[fg=colour255]${key}#[fg=colour245]: ${label2}`;
|
|
2404
|
+
const hints = [hint("#{prefix} d", "detach"), hint("wheel", "scroll")].join(" \u2502 ");
|
|
2405
|
+
const label = `manager ${tmuxFormatText(input.agent)} \xB7 ${tmuxFormatText(input.shortId)}`;
|
|
2406
|
+
const ws = input.workspaceName ? ` ${tmuxFormatText(input.workspaceName)}` : "";
|
|
2407
|
+
return `#[bg=colour39,fg=colour16] agentbox \u25B8 #[bold]${label} #[nobold]#[${FOOTER_BAR_STYLE}]${ws}#[align=right]${hints} `;
|
|
2408
|
+
}
|
|
2409
|
+
function managerSessionOptionsArgv(session, footer) {
|
|
2410
|
+
const target = `${exactTarget(session)}:`;
|
|
2411
|
+
const set = (name, value) => ["set-option", "-t", target, name, value];
|
|
2412
|
+
return [
|
|
2413
|
+
set("mouse", "on"),
|
|
2414
|
+
set("status", "on"),
|
|
2415
|
+
set("status-position", "bottom"),
|
|
2416
|
+
set("status-style", FOOTER_BAR_STYLE),
|
|
2417
|
+
set("status-format[0]", managerStatusFormat(footer))
|
|
2418
|
+
];
|
|
2419
|
+
}
|
|
2420
|
+
async function startManagerSession(input) {
|
|
2421
|
+
const exec = input.exec ?? defaultExec;
|
|
2422
|
+
const rec = input.manager;
|
|
2423
|
+
const session = managerSessionName(rec.id);
|
|
2424
|
+
const exit = managerExitFile(await dirFor(input.wsId), rec.id);
|
|
2425
|
+
await mkdir3(dirname2(exit), { recursive: true });
|
|
2426
|
+
await rm4(exit, { force: true }).catch(() => {
|
|
2427
|
+
});
|
|
2428
|
+
const script = buildManagerShellScript({
|
|
2429
|
+
argv: input.argv,
|
|
2430
|
+
// AGENTBOX_MANAGER carries the id so the agent's own `agentbox` calls are
|
|
2431
|
+
// attributed to THIS record rather than registering a second manager.
|
|
2432
|
+
env: { AGENTBOX_WORKSPACE: input.wsId, AGENTBOX_MANAGER: rec.id },
|
|
2433
|
+
exitFile: exit
|
|
2434
|
+
});
|
|
2435
|
+
const workspaceName = await readWorkspace(input.wsId).then((ws) => ws?.name).catch(() => void 0);
|
|
2436
|
+
await openManagerTmuxSession({
|
|
2437
|
+
session,
|
|
2438
|
+
cwd: rec.cwd,
|
|
2439
|
+
script,
|
|
2440
|
+
footer: {
|
|
2441
|
+
agent: rec.agent,
|
|
2442
|
+
shortId: (rec.sessionId ?? rec.id).slice(0, 8),
|
|
2443
|
+
...workspaceName ? { workspaceName } : {}
|
|
2444
|
+
},
|
|
2445
|
+
exec,
|
|
2446
|
+
...input.env ? { env: input.env } : {}
|
|
2447
|
+
});
|
|
2448
|
+
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
2449
|
+
const next = {
|
|
2450
|
+
...rec,
|
|
2451
|
+
kind: "hub",
|
|
2452
|
+
tmuxSession: session,
|
|
2453
|
+
argv: input.argv,
|
|
2454
|
+
startedAt: at,
|
|
2455
|
+
lastSeenAt: at
|
|
2456
|
+
};
|
|
2457
|
+
delete next.pid;
|
|
2458
|
+
delete next.pidStartedAt;
|
|
2459
|
+
delete next.tmuxPane;
|
|
2460
|
+
delete next.stoppedAt;
|
|
2461
|
+
delete next.lastExit;
|
|
2462
|
+
return updateManagers(input.wsId, (managers) => {
|
|
2463
|
+
const idx = managers.findIndex((m) => m.id === rec.id);
|
|
2464
|
+
const out = [...managers];
|
|
2465
|
+
if (idx === -1) out.push(next);
|
|
2466
|
+
else out[idx] = next;
|
|
2467
|
+
return { managers: out, result: next };
|
|
2468
|
+
});
|
|
2469
|
+
}
|
|
2470
|
+
async function openManagerTmuxSession(input) {
|
|
2471
|
+
const { session, exec } = input;
|
|
2472
|
+
const env = scrubAgentSessionEnv(input.env ?? process.env);
|
|
2473
|
+
await exec(
|
|
2474
|
+
"tmux",
|
|
2475
|
+
[
|
|
2476
|
+
"new-session",
|
|
2477
|
+
"-d",
|
|
2478
|
+
"-s",
|
|
2479
|
+
session,
|
|
2480
|
+
"-c",
|
|
2481
|
+
input.cwd,
|
|
2482
|
+
"--",
|
|
2483
|
+
loginShell(env),
|
|
2484
|
+
"-lc",
|
|
2485
|
+
input.script
|
|
2486
|
+
],
|
|
2487
|
+
{ env }
|
|
2488
|
+
);
|
|
2489
|
+
await exec(
|
|
2490
|
+
"tmux",
|
|
2491
|
+
["set-option", "-w", "-t", `${exactTarget(session)}:`, "window-size", "latest"],
|
|
2492
|
+
{ env }
|
|
2493
|
+
).catch((err2) => {
|
|
2494
|
+
console.warn(
|
|
2495
|
+
`[manager] could not pin the tmux window size: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
2496
|
+
);
|
|
2497
|
+
});
|
|
2498
|
+
for (const argv of managerSessionOptionsArgv(session, input.footer)) {
|
|
2499
|
+
await exec("tmux", argv, { env }).catch((err2) => {
|
|
2500
|
+
console.warn(
|
|
2501
|
+
`[manager] could not set tmux ${argv[3] ?? "option"}: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
2502
|
+
);
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
async function listTmuxSessions(exec = defaultExec) {
|
|
2507
|
+
try {
|
|
2508
|
+
const r = await exec("tmux", ["list-sessions", "-F", "#{session_name} #{session_path}"], {
|
|
2509
|
+
timeout: 3e3
|
|
2510
|
+
});
|
|
2511
|
+
return (r.stdout ?? "").split("\n").map((line) => line.split(" ")).filter((cols) => cols.length >= 2 && cols[0]).map(([session, path]) => ({ session, path }));
|
|
2512
|
+
} catch {
|
|
2513
|
+
return [];
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
function parseBackgroundSessions(stdout) {
|
|
2517
|
+
let rows;
|
|
2518
|
+
try {
|
|
2519
|
+
rows = JSON.parse(stdout);
|
|
2520
|
+
} catch {
|
|
2521
|
+
return [];
|
|
2522
|
+
}
|
|
2523
|
+
if (!Array.isArray(rows)) return [];
|
|
2524
|
+
const out = [];
|
|
2525
|
+
for (const row of rows) {
|
|
2526
|
+
if (row?.["kind"] !== "background") continue;
|
|
2527
|
+
const { id, sessionId, pid, status, state, name, cwd } = row;
|
|
2528
|
+
if (typeof id !== "string" || typeof sessionId !== "string") continue;
|
|
2529
|
+
out.push({
|
|
2530
|
+
id,
|
|
2531
|
+
sessionId,
|
|
2532
|
+
...typeof pid === "number" ? { pid } : {},
|
|
2533
|
+
...typeof status === "string" ? { status } : {},
|
|
2534
|
+
...typeof state === "string" ? { state } : {},
|
|
2535
|
+
...typeof name === "string" ? { name } : {},
|
|
2536
|
+
...typeof cwd === "string" ? { cwd } : {}
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
return out;
|
|
2540
|
+
}
|
|
2541
|
+
function isLiveBackgroundSession(s) {
|
|
2542
|
+
return typeof s.pid === "number" && s.status !== "completed";
|
|
2543
|
+
}
|
|
2544
|
+
var ATTACH_CLIENT_RE = /(?:^|\/)claude attach ([A-Za-z0-9_-]+)\s*$/u;
|
|
2545
|
+
function emptySnapshot() {
|
|
2546
|
+
return { sessions: /* @__PURE__ */ new Map(), managerTmux: [], attachClients: /* @__PURE__ */ new Map() };
|
|
2547
|
+
}
|
|
2548
|
+
function createBackgroundSessionLookup(opts = {}) {
|
|
2549
|
+
const exec = opts.exec ?? defaultExec;
|
|
2550
|
+
const ttl = opts.ttlMs ?? 15e3;
|
|
2551
|
+
const timeout = opts.timeoutMs ?? 3e3;
|
|
2552
|
+
const missingRetry = opts.missingRetryMs ?? 10 * 6e4;
|
|
2553
|
+
const now = opts.now ?? Date.now;
|
|
2554
|
+
let cached;
|
|
2555
|
+
let inflight;
|
|
2556
|
+
let missingUntil = 0;
|
|
2557
|
+
async function readSessions(value) {
|
|
2558
|
+
if (now() < missingUntil) return;
|
|
2559
|
+
try {
|
|
2560
|
+
const r = await exec("claude", ["agents", "--json", "--all"], { timeout });
|
|
2561
|
+
for (const s of parseBackgroundSessions(r.stdout ?? "")) {
|
|
2562
|
+
if (isLiveBackgroundSession(s)) value.sessions.set(s.sessionId, s);
|
|
2563
|
+
}
|
|
2564
|
+
} catch (err2) {
|
|
2565
|
+
if (err2.code === "ENOENT") missingUntil = now() + missingRetry;
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
async function read() {
|
|
2569
|
+
const value = emptySnapshot();
|
|
2570
|
+
const [, tmux] = await Promise.all([readSessions(value), listTmuxSessions(exec)]);
|
|
2571
|
+
value.managerTmux = tmux.filter((t) => MANAGER_SESSION_RE.test(t.session));
|
|
2572
|
+
if (value.sessions.size > 0) {
|
|
2573
|
+
const ps = await exec("ps", ["-Ao", "command="], { timeout }).catch(() => ({ stdout: "" }));
|
|
2574
|
+
for (const line of (ps.stdout ?? "").split("\n")) {
|
|
2575
|
+
const id = ATTACH_CLIENT_RE.exec(line.trim())?.[1];
|
|
2576
|
+
if (id) value.attachClients.set(id, (value.attachClients.get(id) ?? 0) + 1);
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
cached = { until: now() + ttl, value };
|
|
2580
|
+
return value;
|
|
2581
|
+
}
|
|
2582
|
+
return (o = {}) => {
|
|
2583
|
+
if (!o.fresh && cached && now() < cached.until) return Promise.resolve(cached.value);
|
|
2584
|
+
inflight ??= read().finally(() => {
|
|
2585
|
+
inflight = void 0;
|
|
2586
|
+
});
|
|
2587
|
+
return inflight;
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
function liveBackgroundSession(rec, snap) {
|
|
2591
|
+
if (rec.agent !== "claude" || !rec.sessionId) return void 0;
|
|
2592
|
+
return snap.sessions.get(rec.sessionId);
|
|
2593
|
+
}
|
|
2594
|
+
function backgroundFor(rec, snap) {
|
|
2595
|
+
const s = liveBackgroundSession(rec, snap);
|
|
2596
|
+
if (!s) return void 0;
|
|
2597
|
+
const own = managerSessionName(rec.id);
|
|
2598
|
+
const ownLive = snap.managerTmux.some((t) => t.session === own);
|
|
2599
|
+
const hubSession = rec.kind === "hub" ? rec.tmuxSession ?? own : void 0;
|
|
2600
|
+
if (hubSession && hubSession !== own && snap.managerTmux.some((t) => t.session === hubSession)) {
|
|
2601
|
+
return void 0;
|
|
2602
|
+
}
|
|
2603
|
+
const others = snap.managerTmux.filter((t) => t.session !== own && t.path === rec.cwd);
|
|
2604
|
+
if (others.length > 0) return void 0;
|
|
2605
|
+
const clients = snap.attachClients.get(s.id) ?? 0;
|
|
2606
|
+
if (clients > (ownLive ? 1 : 0)) return void 0;
|
|
2607
|
+
return {
|
|
2608
|
+
id: s.id,
|
|
2609
|
+
...s.status ? { status: s.status } : {},
|
|
2610
|
+
...s.state ? { state: s.state } : {},
|
|
2611
|
+
...s.name ? { name: s.name } : {}
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
function terminalSessionFor(rec, snap, claimed) {
|
|
2615
|
+
const candidates = snap.managerTmux.filter(
|
|
2616
|
+
(t) => t.path === rec.cwd && t.session !== managerSessionName(rec.id) && !claimed.has(t.session)
|
|
2617
|
+
);
|
|
2618
|
+
return candidates.length === 1 ? candidates[0].session : void 0;
|
|
2619
|
+
}
|
|
2620
|
+
var BACKGROUND_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u;
|
|
2621
|
+
async function attachBackgroundSession(input) {
|
|
2622
|
+
const exec = input.exec ?? defaultExec;
|
|
2623
|
+
const rec = input.manager;
|
|
2624
|
+
if (!BACKGROUND_ID_RE.test(input.backgroundId)) {
|
|
2625
|
+
throw new Error(`not a background session id: ${input.backgroundId}`);
|
|
2626
|
+
}
|
|
2627
|
+
const session = managerSessionName(rec.id);
|
|
2628
|
+
if (!await tmuxSessionExists(session, exec)) {
|
|
2629
|
+
const workspaceName = await readWorkspace(input.wsId).then((ws) => ws?.name).catch(() => void 0);
|
|
2630
|
+
await openManagerTmuxSession({
|
|
2631
|
+
session,
|
|
2632
|
+
cwd: rec.cwd,
|
|
2633
|
+
script: `${unsetAgentSessionEnv()}; exec ${shellJoin(["claude", "attach", input.backgroundId])}`,
|
|
2634
|
+
footer: {
|
|
2635
|
+
agent: rec.agent,
|
|
2636
|
+
shortId: (rec.sessionId ?? rec.id).slice(0, 8),
|
|
2637
|
+
...workspaceName ? { workspaceName } : {}
|
|
2638
|
+
},
|
|
2639
|
+
exec,
|
|
2640
|
+
...input.env ? { env: input.env } : {}
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
const next = await patchManager(
|
|
2644
|
+
input.wsId,
|
|
2645
|
+
rec.id,
|
|
2646
|
+
(cur) => cur.tmuxSession === session ? cur : { ...cur, tmuxSession: session }
|
|
2647
|
+
);
|
|
2648
|
+
if (!next) throw new Error(`unknown manager ${rec.id}`);
|
|
2649
|
+
return next;
|
|
2650
|
+
}
|
|
2651
|
+
async function detachBackgroundSession(wsId, id, exec = defaultExec) {
|
|
2652
|
+
const rec = (await readManagers(wsId)).find((m) => m.id === id);
|
|
2653
|
+
if (!rec) return null;
|
|
2654
|
+
const session = managerSessionName(rec.id);
|
|
2655
|
+
await exec("tmux", ["kill-session", "-t", exactTarget(session)]).catch(() => {
|
|
2656
|
+
});
|
|
2657
|
+
if (rec.tmuxSession !== session || rec.kind === "hub") return rec;
|
|
2658
|
+
return patchManager(wsId, id, (cur) => {
|
|
2659
|
+
const next = { ...cur };
|
|
2660
|
+
delete next.tmuxSession;
|
|
2661
|
+
return next;
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
async function resumeManagerSession(wsId, id, probe = {}, opts = {}) {
|
|
2665
|
+
const rec = (await readManagers(wsId)).find((m) => m.id === id);
|
|
2666
|
+
if (!rec) throw new Error(`unknown manager ${id}`);
|
|
2667
|
+
const host = (probe.hostname ?? osHostname)();
|
|
2668
|
+
if (ranElsewhere(rec, host)) {
|
|
2669
|
+
throw new ManagerConflictError(
|
|
2670
|
+
`manager ${id} ran on ${rec.host ?? ""}; its transcript is not on this machine (${host}), so it cannot be resumed here`
|
|
2671
|
+
);
|
|
2672
|
+
}
|
|
2673
|
+
if (await managerStatus(rec, probe) === "running") {
|
|
2674
|
+
throw new ManagerConflictError(
|
|
2675
|
+
rec.kind === "external" ? `manager ${id} is still running in a terminal${rec.pid !== void 0 ? ` (pid ${String(rec.pid)})` : ""}; exit it there before resuming it here` : `manager ${id} is already running; attach to it instead`
|
|
2676
|
+
);
|
|
2677
|
+
}
|
|
2678
|
+
if (!rec.sessionId) {
|
|
2679
|
+
throw new ManagerConflictError(
|
|
2680
|
+
`manager ${id} has no session id to resume; start a new manager instead`
|
|
2681
|
+
);
|
|
2682
|
+
}
|
|
2683
|
+
if (!isResumableManagerAgent(rec.agent)) {
|
|
2684
|
+
throw new ManagerConflictError(
|
|
2685
|
+
`session resume is only supported for ${RESUMABLE_MANAGER_AGENTS.join(", ")}, not ${rec.agent}`
|
|
2686
|
+
);
|
|
2687
|
+
}
|
|
2688
|
+
return startManagerSession({
|
|
2689
|
+
wsId,
|
|
2690
|
+
manager: rec,
|
|
2691
|
+
argv: buildManagerArgv(rec.agent, rec.sessionId, opts.prompt),
|
|
2692
|
+
...probe.exec ? { exec: probe.exec } : {},
|
|
2693
|
+
...probe.env ? { env: probe.env } : {}
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
var TMUX_PANE_RE = /^%\d+$/u;
|
|
2697
|
+
var SUBMIT_DELAY_MS = 400;
|
|
2698
|
+
function sendKeysLiteralArgv(target, text3) {
|
|
2699
|
+
const flat = text3.replace(/\s*[\r\n]+\s*/gu, " ").trim();
|
|
2700
|
+
const literal = flat.endsWith(";") ? `${flat.slice(0, -1)}\\;` : flat;
|
|
2701
|
+
return ["send-keys", "-t", target, "-l", "--", literal];
|
|
2702
|
+
}
|
|
2703
|
+
async function sendKeysToManager(target, text3, exec = defaultExec, sleep = (ms) => new Promise((r) => setTimeout(r, ms))) {
|
|
2704
|
+
const t = "session" in target ? `${exactTarget(target.session)}:` : target.pane;
|
|
2705
|
+
if ("pane" in target && !TMUX_PANE_RE.test(target.pane)) {
|
|
2706
|
+
throw new Error(`not a tmux pane id: ${target.pane}`);
|
|
2707
|
+
}
|
|
2708
|
+
await exec("tmux", sendKeysLiteralArgv(t, text3));
|
|
2709
|
+
await sleep(SUBMIT_DELAY_MS);
|
|
2710
|
+
await exec("tmux", ["send-keys", "-t", t, "Enter"]);
|
|
2711
|
+
}
|
|
2712
|
+
async function stopManagerSession(wsId, id, probe = {}) {
|
|
2713
|
+
const rec = (await readManagers(wsId)).find((m) => m.id === id);
|
|
2714
|
+
if (!rec) return null;
|
|
2715
|
+
if (rec.kind === "external") {
|
|
2716
|
+
if (await managerStatus(rec, probe) === "running") {
|
|
2717
|
+
throw new ManagerConflictError(
|
|
2718
|
+
`manager ${id} runs in your terminal; the hub does not stop a process it did not start`
|
|
2719
|
+
);
|
|
2720
|
+
}
|
|
2721
|
+
return rec;
|
|
2722
|
+
}
|
|
2723
|
+
const exec = probe.exec ?? defaultExec;
|
|
2724
|
+
const session = rec.tmuxSession ?? managerSessionName(rec.id);
|
|
2725
|
+
await exec("tmux", ["kill-session", "-t", exactTarget(session)]).catch(() => {
|
|
2726
|
+
});
|
|
2727
|
+
const legacy = usesLegacySession(rec);
|
|
2728
|
+
const lastExit = await readManagerExit(wsId, id, { legacy });
|
|
2729
|
+
const stopped = await patchManager(wsId, id, (current) => ({
|
|
2730
|
+
...current,
|
|
2731
|
+
stoppedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2732
|
+
...lastExit === void 0 ? {} : { lastExit }
|
|
2733
|
+
}));
|
|
2734
|
+
if (legacy) {
|
|
2735
|
+
await rm4(legacyManagerFiles(await dirFor(wsId)).exit, { force: true }).catch(() => {
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
return stopped;
|
|
2739
|
+
}
|
|
2740
|
+
var turnCaches = /* @__PURE__ */ new Map();
|
|
2741
|
+
var turnReads = /* @__PURE__ */ new Map();
|
|
2742
|
+
var rolloutPaths = /* @__PURE__ */ new Map();
|
|
2743
|
+
var TURN_READ_CHUNK = 4 * 1024 * 1024;
|
|
2744
|
+
function claudeTurnRow(row) {
|
|
2745
|
+
const rec = row;
|
|
2746
|
+
if (rec.type !== "user" || rec.isMeta || rec.isSidechain) return null;
|
|
2747
|
+
const content = rec.message?.content;
|
|
2748
|
+
if (Array.isArray(content)) {
|
|
2749
|
+
const blocks = content;
|
|
2750
|
+
if (blocks.length === 0 || blocks.every((b) => b?.type === "tool_result")) return null;
|
|
2751
|
+
} else if (typeof content !== "string") {
|
|
2752
|
+
return null;
|
|
2753
|
+
}
|
|
2754
|
+
const text3 = firstTextBlock(content);
|
|
2755
|
+
return {
|
|
2756
|
+
...typeof rec.promptId === "string" ? { promptId: rec.promptId } : {},
|
|
2757
|
+
prompt: text3 === null ? null : asTitle(text3)
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
function absorbTurnLine(agent, cache, line) {
|
|
2761
|
+
if (agent === "claude") {
|
|
2762
|
+
if (!line.includes('"user"')) return;
|
|
2763
|
+
let row;
|
|
2764
|
+
try {
|
|
2765
|
+
row = JSON.parse(line);
|
|
2766
|
+
} catch {
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2769
|
+
const hit = claudeTurnRow(row);
|
|
2770
|
+
if (!hit) return;
|
|
2771
|
+
if (hit.promptId !== void 0) {
|
|
2772
|
+
if (cache.promptIds.has(hit.promptId)) return;
|
|
2773
|
+
cache.promptIds.add(hit.promptId);
|
|
2774
|
+
} else if (hit.prompt === null) {
|
|
2775
|
+
return;
|
|
2776
|
+
}
|
|
2777
|
+
cache.turns += 1;
|
|
2778
|
+
if (hit.prompt) cache.lastPrompt = hit.prompt;
|
|
2779
|
+
return;
|
|
2780
|
+
}
|
|
2781
|
+
if (!line.includes("turn_context") && !line.includes("user_message")) return;
|
|
2782
|
+
let rec;
|
|
2783
|
+
try {
|
|
2784
|
+
rec = JSON.parse(line);
|
|
2785
|
+
} catch {
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2788
|
+
if (rec.type === "turn_context") cache.turns += 1;
|
|
2789
|
+
else if (rec.type === "event_msg" && rec.payload?.type === "user_message" && typeof rec.payload.message === "string") {
|
|
2790
|
+
const prompt = asTitle(rec.payload.message);
|
|
2791
|
+
if (prompt) cache.lastPrompt = prompt;
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
async function transcriptFor(agent, cwd, sessionId, home) {
|
|
2795
|
+
if (agent === "claude") {
|
|
2796
|
+
return join4(home, ".claude", "projects", encodeClaudeProjectsKey(cwd), `${sessionId}.jsonl`);
|
|
2797
|
+
}
|
|
2798
|
+
if (agent !== "codex") return null;
|
|
2799
|
+
const known = rolloutPaths.get(sessionId);
|
|
2800
|
+
if (known && await stat2(known).catch(() => null)) return known;
|
|
2801
|
+
const hit = (await findRolloutFiles(join4(home, ".codex", "sessions"))).find(
|
|
2802
|
+
(f) => f.id === sessionId
|
|
2803
|
+
);
|
|
2804
|
+
if (!hit) return null;
|
|
2805
|
+
rolloutPaths.set(sessionId, hit.file);
|
|
2806
|
+
return hit.file;
|
|
2807
|
+
}
|
|
2808
|
+
async function sessionTurn(agent, cwd, sessionId, home = homedir2()) {
|
|
2809
|
+
const file = await transcriptFor(agent, cwd, sessionId, home);
|
|
2810
|
+
if (!file) return void 0;
|
|
2811
|
+
const prev = turnReads.get(file) ?? Promise.resolve(void 0);
|
|
2812
|
+
const next = prev.then(
|
|
2813
|
+
() => readSessionTurn(agent, file),
|
|
2814
|
+
() => readSessionTurn(agent, file)
|
|
2815
|
+
);
|
|
2816
|
+
turnReads.set(file, next);
|
|
2817
|
+
try {
|
|
2818
|
+
return await next;
|
|
2819
|
+
} finally {
|
|
2820
|
+
if (turnReads.get(file) === next) turnReads.delete(file);
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
async function readSessionTurn(agent, file) {
|
|
2824
|
+
let fh;
|
|
2825
|
+
try {
|
|
2826
|
+
fh = await open(file, "r");
|
|
2827
|
+
} catch {
|
|
2828
|
+
turnCaches.delete(file);
|
|
2829
|
+
return void 0;
|
|
2830
|
+
}
|
|
2831
|
+
try {
|
|
2832
|
+
const st = await fh.stat();
|
|
2833
|
+
let cache = turnCaches.get(file);
|
|
2834
|
+
if (!cache || cache.ino !== st.ino || st.size < cache.offset) {
|
|
2835
|
+
cache = { ino: st.ino, offset: 0, turns: 0, promptIds: /* @__PURE__ */ new Set() };
|
|
2836
|
+
turnCaches.set(file, cache);
|
|
2837
|
+
}
|
|
2838
|
+
let tail = "";
|
|
2839
|
+
let pos = cache.offset;
|
|
2840
|
+
const chunk = Buffer.alloc(Math.min(TURN_READ_CHUNK, Math.max(1, st.size - cache.offset)));
|
|
2841
|
+
while (pos < st.size) {
|
|
2842
|
+
const { bytesRead } = await fh.read(chunk, 0, Math.min(chunk.length, st.size - pos), pos);
|
|
2843
|
+
if (bytesRead === 0) break;
|
|
2844
|
+
pos += bytesRead;
|
|
2845
|
+
const text3 = tail + chunk.subarray(0, bytesRead).toString("utf8");
|
|
2846
|
+
const end = text3.lastIndexOf("\n");
|
|
2847
|
+
if (end === -1) {
|
|
2848
|
+
tail = text3;
|
|
2849
|
+
continue;
|
|
2850
|
+
}
|
|
2851
|
+
for (const line of text3.slice(0, end).split("\n")) absorbTurnLine(agent, cache, line);
|
|
2852
|
+
tail = text3.slice(end + 1);
|
|
2853
|
+
}
|
|
2854
|
+
cache.offset = pos - Buffer.byteLength(tail, "utf8");
|
|
2855
|
+
if (cache.turns === 0) return void 0;
|
|
2856
|
+
return { turn: cache.turns, ...cache.lastPrompt ? { prompt: cache.lastPrompt } : {} };
|
|
2857
|
+
} catch {
|
|
2858
|
+
return void 0;
|
|
2859
|
+
} finally {
|
|
2860
|
+
await fh.close();
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
async function sessionTitle(agent, cwd, sessionId, home = homedir2()) {
|
|
2864
|
+
if (agent === "claude") {
|
|
2865
|
+
const file = join4(
|
|
2866
|
+
home,
|
|
2867
|
+
".claude",
|
|
2868
|
+
"projects",
|
|
2869
|
+
encodeClaudeProjectsKey(cwd),
|
|
2870
|
+
`${sessionId}.jsonl`
|
|
2871
|
+
);
|
|
2872
|
+
const head = await readHead(file, SESSION_HEAD_BYTES);
|
|
2873
|
+
return head === null ? null : titleFromTranscript(head);
|
|
2874
|
+
}
|
|
2875
|
+
if (agent === "codex") {
|
|
2876
|
+
const indexed = (await readThreadNames(join4(home, ".codex", "session_index.jsonl"))).get(
|
|
2877
|
+
sessionId
|
|
2878
|
+
);
|
|
2879
|
+
const title = indexed === void 0 ? null : asTitle(indexed, { skipSlash: true });
|
|
2880
|
+
if (title) return title;
|
|
2881
|
+
const listed = await listRolloutSessions(cwd, agent, home);
|
|
2882
|
+
return listed.find((s) => s.id === sessionId)?.title ?? null;
|
|
2883
|
+
}
|
|
2884
|
+
return null;
|
|
2885
|
+
}
|
|
2886
|
+
async function readFirstLine(file) {
|
|
2887
|
+
try {
|
|
2888
|
+
const fh = await open(file, "r");
|
|
2889
|
+
try {
|
|
2890
|
+
const chunk = Buffer.alloc(64 * 1024);
|
|
2891
|
+
let text3 = "";
|
|
2892
|
+
let pos = 0;
|
|
2893
|
+
while (pos < SESSION_FIRST_LINE_MAX) {
|
|
2894
|
+
const { bytesRead } = await fh.read(chunk, 0, chunk.length, pos);
|
|
2895
|
+
if (bytesRead === 0) return text3;
|
|
2896
|
+
pos += bytesRead;
|
|
2897
|
+
text3 += chunk.subarray(0, bytesRead).toString("utf8");
|
|
2898
|
+
const nl = text3.indexOf("\n");
|
|
2899
|
+
if (nl !== -1) return text3.slice(0, nl);
|
|
2900
|
+
}
|
|
2901
|
+
return null;
|
|
2902
|
+
} finally {
|
|
2903
|
+
await fh.close();
|
|
2904
|
+
}
|
|
2905
|
+
} catch {
|
|
2906
|
+
return null;
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
async function readTail(file, bytes) {
|
|
2910
|
+
try {
|
|
2911
|
+
const fh = await open(file, "r");
|
|
2912
|
+
try {
|
|
2913
|
+
const { size } = await fh.stat();
|
|
2914
|
+
const start = Math.max(0, size - bytes);
|
|
2915
|
+
const buf = Buffer.alloc(size - start);
|
|
2916
|
+
const { bytesRead } = await fh.read(buf, 0, buf.length, start);
|
|
2917
|
+
const text3 = buf.subarray(0, bytesRead).toString("utf8");
|
|
2918
|
+
if (start === 0) return text3;
|
|
2919
|
+
const nl = text3.indexOf("\n");
|
|
2920
|
+
return nl === -1 ? "" : text3.slice(nl + 1);
|
|
2921
|
+
} finally {
|
|
2922
|
+
await fh.close();
|
|
2923
|
+
}
|
|
2924
|
+
} catch {
|
|
2925
|
+
return null;
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
async function readHead(file, bytes, start = 0) {
|
|
2929
|
+
try {
|
|
2930
|
+
const fh = await open(file, "r");
|
|
2931
|
+
try {
|
|
2932
|
+
const buf = Buffer.alloc(bytes);
|
|
2933
|
+
const { bytesRead } = await fh.read(buf, 0, bytes, start);
|
|
2934
|
+
return buf.subarray(0, bytesRead).toString("utf8");
|
|
2935
|
+
} finally {
|
|
2936
|
+
await fh.close();
|
|
2937
|
+
}
|
|
2938
|
+
} catch {
|
|
2939
|
+
return null;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
function asTitle(text3, opts = {}) {
|
|
2943
|
+
const flat = text3.replace(/\s+/g, " ").trim();
|
|
2944
|
+
if (!flat || flat.startsWith("<")) return null;
|
|
2945
|
+
if (opts.skipSlash && flat.startsWith("/")) return null;
|
|
2946
|
+
if (opts.skipInjected && isInjectedContext(flat)) return null;
|
|
2947
|
+
return flat.length > SESSION_TITLE_MAX ? `${flat.slice(0, SESSION_TITLE_MAX - 1)}\u2026` : flat;
|
|
2948
|
+
}
|
|
2949
|
+
function isInjectedContext(flat) {
|
|
2950
|
+
if (flat.startsWith("#")) return true;
|
|
2951
|
+
return INJECTED_PREFIXES.some((p) => flat.startsWith(p));
|
|
2952
|
+
}
|
|
2953
|
+
var INJECTED_PREFIXES = [
|
|
2954
|
+
"The following is the",
|
|
2955
|
+
"AGENTS.md",
|
|
2956
|
+
"You are ",
|
|
2957
|
+
"Caveat:",
|
|
2958
|
+
"This session is being continued"
|
|
2959
|
+
];
|
|
2960
|
+
function firstTextBlock(content) {
|
|
2961
|
+
if (typeof content === "string") return content;
|
|
2962
|
+
if (!Array.isArray(content)) return null;
|
|
2963
|
+
for (const block of content) {
|
|
2964
|
+
if (typeof block !== "object" || block === null) continue;
|
|
2965
|
+
const { text: text3 } = block;
|
|
2966
|
+
if (typeof text3 === "string" && text3) return text3;
|
|
2967
|
+
}
|
|
2968
|
+
return null;
|
|
2969
|
+
}
|
|
2970
|
+
function* jsonlRows(head) {
|
|
2971
|
+
for (const line of head.split("\n")) {
|
|
2972
|
+
if (!line.trim()) continue;
|
|
2973
|
+
try {
|
|
2974
|
+
yield JSON.parse(line);
|
|
2975
|
+
} catch {
|
|
2976
|
+
continue;
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
function titleFromTranscript(head) {
|
|
2981
|
+
for (const row of jsonlRows(head)) {
|
|
2982
|
+
const rec = row;
|
|
2983
|
+
if (rec.type !== "user") continue;
|
|
2984
|
+
const text3 = firstTextBlock(rec.message?.content);
|
|
2985
|
+
const title = text3 === null ? null : asTitle(text3, { skipInjected: true });
|
|
2986
|
+
if (title) return title;
|
|
2987
|
+
}
|
|
2988
|
+
return UNTITLED_SESSION;
|
|
2989
|
+
}
|
|
2990
|
+
function titleFromRollout(head) {
|
|
2991
|
+
for (const row of jsonlRows(head)) {
|
|
2992
|
+
const rec = row;
|
|
2993
|
+
const payload = rec.payload;
|
|
2994
|
+
if (!payload) continue;
|
|
2995
|
+
let text3 = null;
|
|
2996
|
+
if (payload.role === "user") text3 = firstTextBlock(payload.content);
|
|
2997
|
+
else if (payload.type === "user_message" && typeof payload.message === "string") {
|
|
2998
|
+
text3 = payload.message;
|
|
2999
|
+
}
|
|
3000
|
+
const title = text3 === null ? null : asTitle(text3, { skipInjected: true });
|
|
3001
|
+
if (title) return title;
|
|
3002
|
+
}
|
|
3003
|
+
return UNTITLED_SESSION;
|
|
3004
|
+
}
|
|
3005
|
+
async function listProjectTranscripts(root, agent, home) {
|
|
3006
|
+
const dir = join4(home, ".claude", "projects", encodeClaudeProjectsKey(root));
|
|
3007
|
+
let names;
|
|
3008
|
+
try {
|
|
3009
|
+
names = await readdir2(dir);
|
|
3010
|
+
} catch {
|
|
3011
|
+
return [];
|
|
3012
|
+
}
|
|
3013
|
+
const rows = [];
|
|
3014
|
+
for (const name of names) {
|
|
3015
|
+
if (!name.endsWith(".jsonl") || name.startsWith("agent-")) continue;
|
|
3016
|
+
const file = join4(dir, name);
|
|
3017
|
+
let mtime;
|
|
3018
|
+
try {
|
|
3019
|
+
mtime = (await stat2(file)).mtimeMs;
|
|
3020
|
+
} catch {
|
|
3021
|
+
continue;
|
|
3022
|
+
}
|
|
3023
|
+
const head = await readHead(file, SESSION_HEAD_BYTES);
|
|
3024
|
+
if (head === null) continue;
|
|
3025
|
+
rows.push({
|
|
3026
|
+
session: {
|
|
3027
|
+
id: basename2(name, ".jsonl"),
|
|
3028
|
+
agent,
|
|
3029
|
+
title: titleFromTranscript(head),
|
|
3030
|
+
updatedAt: new Date(mtime).toISOString()
|
|
3031
|
+
},
|
|
3032
|
+
mtime
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
return sortAndCap(rows);
|
|
3036
|
+
}
|
|
3037
|
+
async function listRolloutSessions(root, agent, home) {
|
|
3038
|
+
const candidates = await rolloutCandidates(join4(home, ".codex", "sessions"));
|
|
3039
|
+
if (candidates.length === 0) return [];
|
|
3040
|
+
const wanted = await canonicalPath(root);
|
|
3041
|
+
const titles = await readThreadNames(join4(home, ".codex", "session_index.jsonl"));
|
|
3042
|
+
const rows = [];
|
|
3043
|
+
for (const { file, id, mtime } of candidates) {
|
|
3044
|
+
const first = await readFirstLine(file);
|
|
3045
|
+
if (first === null) continue;
|
|
3046
|
+
const cwd = cwdFromRollout(first);
|
|
3047
|
+
if (cwd === null) continue;
|
|
3048
|
+
if (cwd !== root && await canonicalPath(cwd) !== wanted) continue;
|
|
3049
|
+
const indexed = titles.get(id);
|
|
3050
|
+
const indexedTitle = indexed === void 0 ? null : asTitle(indexed, { skipSlash: true });
|
|
3051
|
+
const title = indexedTitle ?? titleFromRollout(
|
|
3052
|
+
await readHead(file, SESSION_HEAD_BYTES, Buffer.byteLength(first, "utf8") + 1) ?? ""
|
|
3053
|
+
);
|
|
3054
|
+
rows.push({
|
|
3055
|
+
session: { id, agent, title, updatedAt: new Date(mtime).toISOString() },
|
|
3056
|
+
mtime
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
return sortAndCap(rows);
|
|
3060
|
+
}
|
|
3061
|
+
async function rolloutCandidates(sessionsRoot) {
|
|
3062
|
+
const files = await findRolloutFiles(sessionsRoot);
|
|
3063
|
+
const dated = [];
|
|
3064
|
+
for (const { file, id } of files) {
|
|
3065
|
+
try {
|
|
3066
|
+
dated.push({ file, id, mtime: (await stat2(file)).mtimeMs });
|
|
3067
|
+
} catch {
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
dated.sort((a, b) => b.mtime - a.mtime);
|
|
3071
|
+
return dated.slice(0, ROLLOUT_SCAN_MAX);
|
|
3072
|
+
}
|
|
3073
|
+
function sortAndCap(rows) {
|
|
3074
|
+
rows.sort((a, b) => b.mtime - a.mtime);
|
|
3075
|
+
return rows.slice(0, SESSION_LIST_MAX).map((r) => r.session);
|
|
3076
|
+
}
|
|
3077
|
+
async function canonicalPath(p) {
|
|
3078
|
+
try {
|
|
3079
|
+
return await realpath2(p);
|
|
3080
|
+
} catch {
|
|
3081
|
+
return p;
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
async function safeReaddir(dir) {
|
|
3085
|
+
try {
|
|
3086
|
+
return await readdir2(dir);
|
|
3087
|
+
} catch {
|
|
3088
|
+
return [];
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
async function findRolloutFiles(sessionsRoot) {
|
|
3092
|
+
const out = [];
|
|
3093
|
+
const desc2 = (a, b) => a < b ? 1 : a > b ? -1 : 0;
|
|
3094
|
+
for (const y of (await safeReaddir(sessionsRoot)).filter((n) => /^\d{4}$/u.test(n)).sort(desc2)) {
|
|
3095
|
+
const yDir = join4(sessionsRoot, y);
|
|
3096
|
+
for (const m of (await safeReaddir(yDir)).filter((n) => /^\d{2}$/u.test(n)).sort(desc2)) {
|
|
3097
|
+
const mDir = join4(yDir, m);
|
|
3098
|
+
for (const d of (await safeReaddir(mDir)).filter((n) => /^\d{2}$/u.test(n)).sort(desc2)) {
|
|
3099
|
+
const dDir = join4(mDir, d);
|
|
3100
|
+
for (const name of (await safeReaddir(dDir)).sort(desc2)) {
|
|
3101
|
+
if (!name.startsWith("rollout-") || !name.endsWith(".jsonl")) continue;
|
|
3102
|
+
const id = ROLLOUT_UUID_RE.exec(name)?.[1];
|
|
3103
|
+
if (id === void 0) continue;
|
|
3104
|
+
out.push({ file: join4(dDir, name), id });
|
|
3105
|
+
if (out.length >= ROLLOUT_STAT_MAX) return out;
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
return out;
|
|
3111
|
+
}
|
|
3112
|
+
function cwdFromRollout(head) {
|
|
3113
|
+
const nl = head.indexOf("\n");
|
|
3114
|
+
const first = nl === -1 ? head : head.slice(0, nl);
|
|
3115
|
+
try {
|
|
3116
|
+
const parsed = JSON.parse(first);
|
|
3117
|
+
if (parsed.type !== "session_meta" || typeof parsed.payload?.cwd !== "string") return null;
|
|
3118
|
+
const source = parsed.payload.thread_source;
|
|
3119
|
+
if (typeof source === "string" && source !== "user") return null;
|
|
3120
|
+
return parsed.payload.cwd;
|
|
3121
|
+
} catch {
|
|
3122
|
+
}
|
|
3123
|
+
return null;
|
|
3124
|
+
}
|
|
3125
|
+
async function readThreadNames(file) {
|
|
3126
|
+
const out = /* @__PURE__ */ new Map();
|
|
3127
|
+
const tail = await readTail(file, SESSION_INDEX_BYTES);
|
|
3128
|
+
if (tail === null) return out;
|
|
3129
|
+
for (const row of jsonlRows(tail)) {
|
|
3130
|
+
const rec = row;
|
|
3131
|
+
if (typeof rec.id === "string" && typeof rec.thread_name === "string") {
|
|
3132
|
+
out.set(rec.id, rec.thread_name);
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
return out;
|
|
3136
|
+
}
|
|
3137
|
+
async function listResumableHostSessions(root, agent = DEFAULT_RESUMABLE_AGENT, home = homedir2()) {
|
|
3138
|
+
if (!isResumableManagerAgent(agent)) return { agent, supported: false, sessions: [] };
|
|
3139
|
+
const sessions = agent === "codex" ? await listRolloutSessions(root, agent, home) : await listProjectTranscripts(root, agent, home);
|
|
3140
|
+
return { agent, supported: true, sessions };
|
|
3141
|
+
}
|
|
3142
|
+
var PUSH_STAT_TIMEOUT_MS = 2e3;
|
|
3143
|
+
var DEFAULT_BRANCH_REFS = [
|
|
3144
|
+
"refs/remotes/origin/main",
|
|
3145
|
+
"refs/remotes/origin/master",
|
|
3146
|
+
"refs/heads/main",
|
|
3147
|
+
"refs/heads/master"
|
|
3148
|
+
];
|
|
3149
|
+
function parseShortstat(out) {
|
|
3150
|
+
const num = (re) => Number(re.exec(out)?.[1] ?? 0);
|
|
3151
|
+
return {
|
|
3152
|
+
filesChanged: num(/(\d+) files? changed/u),
|
|
3153
|
+
additions: num(/(\d+) insertions?\(\+\)/u),
|
|
3154
|
+
deletions: num(/(\d+) deletions?\(-\)/u)
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
function pushedRef(branch, opts) {
|
|
3158
|
+
const remote = opts.remote ?? "origin";
|
|
3159
|
+
if (opts.hostOnly || !/^[A-Za-z0-9._-]+$/u.test(remote)) return `refs/heads/${branch}`;
|
|
3160
|
+
return `refs/remotes/${remote}/${branch}`;
|
|
3161
|
+
}
|
|
3162
|
+
function gitWithin(repo, deadline) {
|
|
3163
|
+
return async (args) => {
|
|
3164
|
+
const left = deadline - Date.now();
|
|
3165
|
+
if (left <= 0) return void 0;
|
|
3166
|
+
try {
|
|
3167
|
+
const r = await execa2("git", ["-C", repo, ...args], { reject: false, timeout: left });
|
|
3168
|
+
return r.exitCode === 0 ? r.stdout.trim() : void 0;
|
|
3169
|
+
} catch {
|
|
3170
|
+
return void 0;
|
|
3171
|
+
}
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
function tipWith(git, ref) {
|
|
3175
|
+
return git(["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]).then((s) => s || void 0);
|
|
3176
|
+
}
|
|
3177
|
+
function readRefTip(repo, ref, timeoutMs = PUSH_STAT_TIMEOUT_MS) {
|
|
3178
|
+
return tipWith(gitWithin(repo, Date.now() + timeoutMs), ref);
|
|
3179
|
+
}
|
|
3180
|
+
function readCurrentBranch(repo, timeoutMs = 1e3) {
|
|
3181
|
+
const git = gitWithin(repo, Date.now() + timeoutMs);
|
|
3182
|
+
return git(["symbolic-ref", "--quiet", "--short", "HEAD"]).then((s) => s || void 0);
|
|
3183
|
+
}
|
|
3184
|
+
async function defaultBranchBase(git, tip) {
|
|
3185
|
+
const head = await git(["symbolic-ref", "--quiet", "refs/remotes/origin/HEAD"]);
|
|
3186
|
+
for (const ref of [...head ? [head] : [], ...DEFAULT_BRANCH_REFS]) {
|
|
3187
|
+
if (!await tipWith(git, ref)) continue;
|
|
3188
|
+
return git(["merge-base", ref, tip]);
|
|
3189
|
+
}
|
|
3190
|
+
return void 0;
|
|
3191
|
+
}
|
|
3192
|
+
async function isAncestor(git, before, after) {
|
|
3193
|
+
return await git(["merge-base", "--is-ancestor", before, after]) !== void 0;
|
|
3194
|
+
}
|
|
3195
|
+
async function pushLineStat(input) {
|
|
3196
|
+
const git = gitWithin(input.repo, Date.now() + (input.timeoutMs ?? PUSH_STAT_TIMEOUT_MS));
|
|
3197
|
+
const after = await tipWith(git, input.ref) ?? await tipWith(git, `refs/heads/${input.branch}`);
|
|
3198
|
+
if (!after) return void 0;
|
|
3199
|
+
const base = input.before && (input.before === after || await isAncestor(git, input.before, after)) ? input.before : await defaultBranchBase(git, after);
|
|
3200
|
+
if (!base || base === after) return void 0;
|
|
3201
|
+
const out = await git(["diff", "--shortstat", `${base}..${after}`]);
|
|
3202
|
+
if (out === void 0) return void 0;
|
|
3203
|
+
const { additions, deletions } = parseShortstat(out);
|
|
3204
|
+
return additions + deletions > 0 ? { additions, deletions } : void 0;
|
|
3205
|
+
}
|
|
3206
|
+
function nextTaskId(counter) {
|
|
3207
|
+
return `T-${String(counter + 1)}`;
|
|
3208
|
+
}
|
|
3209
|
+
async function tasksPathFor(wsId, root) {
|
|
3210
|
+
const dir = await resolveWorkspaceDir(wsId) ?? workspaceDir(wsId, root);
|
|
3211
|
+
return tasksFile(dir);
|
|
3212
|
+
}
|
|
3213
|
+
async function readTasks(wsId) {
|
|
3214
|
+
try {
|
|
3215
|
+
const raw = await readFile3(await tasksPathFor(wsId), "utf8");
|
|
3216
|
+
const parsed = JSON.parse(raw);
|
|
3217
|
+
return Array.isArray(parsed.tasks) ? parsed.tasks : [];
|
|
3218
|
+
} catch {
|
|
3219
|
+
return [];
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
async function writeTasks(wsId, tasks) {
|
|
3223
|
+
const final = await tasksPathFor(wsId);
|
|
3224
|
+
await mkdir4(final.slice(0, final.lastIndexOf("/")), { recursive: true });
|
|
3225
|
+
const tmp = `${final}.tmp.${String(process.pid)}.${Date.now().toString(36)}`;
|
|
3226
|
+
const doc = { version: 1, tasks };
|
|
3227
|
+
await writeFile4(tmp, JSON.stringify(doc, null, 2) + "\n", "utf8");
|
|
3228
|
+
await rename4(tmp, final);
|
|
3229
|
+
}
|
|
3230
|
+
async function updateTasks(wsId, fn) {
|
|
3231
|
+
const path = await tasksPathFor(wsId);
|
|
3232
|
+
return withFileLock(
|
|
3233
|
+
path,
|
|
3234
|
+
async () => {
|
|
3235
|
+
const current = await readTasks(wsId);
|
|
3236
|
+
const { tasks, result } = await fn(current);
|
|
3237
|
+
await writeTasks(wsId, tasks);
|
|
3238
|
+
return result;
|
|
3239
|
+
},
|
|
3240
|
+
WORKSPACE_LOCK
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
function sortTasksByOrder(tasks) {
|
|
3244
|
+
return [...tasks].sort((a, b) => a.order - b.order);
|
|
3245
|
+
}
|
|
3246
|
+
function filterTasks(tasks, f = {}) {
|
|
3247
|
+
return sortTasksByOrder(tasks).filter((t) => {
|
|
3248
|
+
if (f.projectId !== void 0 && t.projectId !== f.projectId) return false;
|
|
3249
|
+
if (f.boxId !== void 0 && t.boxId !== f.boxId) return false;
|
|
3250
|
+
if (f.status !== void 0 && t.status !== f.status) return false;
|
|
3251
|
+
if (f.managerId !== void 0 && t.managerId !== f.managerId) return false;
|
|
3252
|
+
return true;
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
function validateDependsOn(tasks, taskId, dependsOn) {
|
|
3256
|
+
const known = new Set(tasks.map((t) => t.id));
|
|
3257
|
+
for (const dep of dependsOn) {
|
|
3258
|
+
if (dep === taskId) return `task ${taskId} cannot depend on itself`;
|
|
3259
|
+
if (!known.has(dep)) return `unknown task ${dep}`;
|
|
3260
|
+
}
|
|
3261
|
+
return null;
|
|
3262
|
+
}
|
|
3263
|
+
async function addTask(wsId, input) {
|
|
3264
|
+
const target = input.boxId ? { boxId: input.boxId } : input.boxJobId ? { boxJobId: input.boxJobId } : null;
|
|
3265
|
+
const managerId = input.managerId ?? (target ? await managerIdForTarget(target, { workspaceId: wsId }) : void 0);
|
|
3266
|
+
return updateTasks(wsId, async (tasks) => {
|
|
3267
|
+
if (input.dependsOn?.length) {
|
|
3268
|
+
const err2 = validateDependsOn(tasks, "", input.dependsOn);
|
|
3269
|
+
if (err2) throw new Error(err2);
|
|
3270
|
+
}
|
|
3271
|
+
const bumped = await updateWorkspace(wsId, (rec) => ({
|
|
3272
|
+
...rec,
|
|
3273
|
+
taskCounter: rec.taskCounter + 1
|
|
3274
|
+
}));
|
|
3275
|
+
if (!bumped) throw new Error(`unknown workspace ${wsId}`);
|
|
3276
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3277
|
+
const task = {
|
|
3278
|
+
id: nextTaskId(bumped.taskCounter - 1),
|
|
3279
|
+
workspaceId: wsId,
|
|
3280
|
+
title: input.title,
|
|
3281
|
+
status: "todo",
|
|
3282
|
+
order: tasks.reduce((max, t) => Math.max(max, t.order), 0) + 1,
|
|
3283
|
+
createdBy: input.createdBy ?? "human",
|
|
3284
|
+
createdAt: now,
|
|
3285
|
+
updatedAt: now,
|
|
3286
|
+
...input.description ? { description: input.description } : {},
|
|
3287
|
+
...input.projectId ? { projectId: input.projectId } : {},
|
|
3288
|
+
...input.dependsOn?.length ? { dependsOn: input.dependsOn } : {},
|
|
3289
|
+
...input.externalRef ? { externalRef: input.externalRef } : {},
|
|
3290
|
+
...managerId ? { managerId } : {},
|
|
3291
|
+
...input.boxId ? { boxId: input.boxId, status: "in_progress" } : {},
|
|
3292
|
+
...input.boxJobId ? { boxJobId: input.boxJobId, status: "in_progress" } : {}
|
|
3293
|
+
};
|
|
3294
|
+
return { tasks: [...tasks, task], result: task };
|
|
3295
|
+
});
|
|
3296
|
+
}
|
|
3297
|
+
async function patchTask(wsId, taskId, patch) {
|
|
3298
|
+
return updateTasks(wsId, (tasks) => {
|
|
3299
|
+
const idx = tasks.findIndex((t) => t.id === taskId);
|
|
3300
|
+
if (idx === -1) return { tasks, result: null };
|
|
3301
|
+
if (patch.dependsOn) {
|
|
3302
|
+
const err2 = validateDependsOn(tasks, taskId, patch.dependsOn);
|
|
3303
|
+
if (err2) throw new Error(err2);
|
|
3304
|
+
}
|
|
3305
|
+
const prev = tasks[idx];
|
|
3306
|
+
const next = { ...prev, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3307
|
+
if (patch.title !== void 0) next.title = patch.title;
|
|
3308
|
+
if (patch.description !== void 0) {
|
|
3309
|
+
if (patch.description === "") delete next.description;
|
|
3310
|
+
else next.description = patch.description;
|
|
3311
|
+
}
|
|
3312
|
+
if (patch.projectId !== void 0) {
|
|
3313
|
+
if (patch.projectId === null) delete next.projectId;
|
|
3314
|
+
else next.projectId = patch.projectId;
|
|
3315
|
+
}
|
|
3316
|
+
if (patch.dependsOn !== void 0) {
|
|
3317
|
+
if (patch.dependsOn.length === 0) delete next.dependsOn;
|
|
3318
|
+
else next.dependsOn = patch.dependsOn;
|
|
3319
|
+
}
|
|
3320
|
+
if (patch.externalRef !== void 0) next.externalRef = patch.externalRef;
|
|
3321
|
+
if (patch.managerId !== void 0) {
|
|
3322
|
+
if (patch.managerId === null) delete next.managerId;
|
|
3323
|
+
else next.managerId = patch.managerId;
|
|
3324
|
+
}
|
|
3325
|
+
if (patch.status !== void 0) applyStatus(next, patch.status);
|
|
3326
|
+
const out = [...tasks];
|
|
3327
|
+
out[idx] = next;
|
|
3328
|
+
return { tasks: out, result: next };
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
function applyStatus(task, status) {
|
|
3332
|
+
task.status = status;
|
|
3333
|
+
if (status === "done") task.doneAt = task.doneAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
3334
|
+
else delete task.doneAt;
|
|
3335
|
+
}
|
|
3336
|
+
async function setTaskDone(wsId, taskId) {
|
|
3337
|
+
return patchTask(wsId, taskId, { status: "done" });
|
|
3338
|
+
}
|
|
3339
|
+
async function removeTask(wsId, taskId) {
|
|
3340
|
+
return updateTasks(wsId, (tasks) => {
|
|
3341
|
+
if (!tasks.some((t) => t.id === taskId)) return { tasks, result: false };
|
|
3342
|
+
const out = tasks.filter((t) => t.id !== taskId).map((t) => {
|
|
3343
|
+
if (!t.dependsOn?.includes(taskId)) return t;
|
|
3344
|
+
const deps = t.dependsOn.filter((d) => d !== taskId);
|
|
3345
|
+
const next = { ...t, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3346
|
+
if (deps.length) next.dependsOn = deps;
|
|
3347
|
+
else delete next.dependsOn;
|
|
3348
|
+
return next;
|
|
3349
|
+
});
|
|
3350
|
+
return { tasks: out, result: true };
|
|
3351
|
+
});
|
|
3352
|
+
}
|
|
3353
|
+
async function assignTasks(wsId, ids, target) {
|
|
3354
|
+
const inherited = target ? await managerIdForTarget(target, { workspaceId: wsId }) : void 0;
|
|
3355
|
+
return updateTasks(wsId, (tasks) => {
|
|
3356
|
+
const wanted = new Set(ids);
|
|
3357
|
+
const missing = ids.filter((id) => !tasks.some((t) => t.id === id));
|
|
3358
|
+
if (missing.length) throw new Error(`unknown task ${missing.join(", ")}`);
|
|
3359
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3360
|
+
const out = tasks.map((t) => {
|
|
3361
|
+
if (!wanted.has(t.id)) return t;
|
|
3362
|
+
const next = { ...t, updatedAt: now };
|
|
3363
|
+
delete next.boxId;
|
|
3364
|
+
delete next.boxJobId;
|
|
3365
|
+
if (target && "boxId" in target) next.boxId = target.boxId;
|
|
3366
|
+
else if (target) next.boxJobId = target.boxJobId;
|
|
3367
|
+
if (inherited && !next.managerId) next.managerId = inherited;
|
|
3368
|
+
if (target && next.status === "todo") next.status = "in_progress";
|
|
3369
|
+
if (!target && next.status === "in_progress") next.status = "todo";
|
|
3370
|
+
return next;
|
|
3371
|
+
});
|
|
3372
|
+
return { tasks: out, result: out.filter((t) => wanted.has(t.id)) };
|
|
3373
|
+
});
|
|
3374
|
+
}
|
|
3375
|
+
async function unassignTasks(wsId, ids) {
|
|
3376
|
+
return assignTasks(wsId, ids, null);
|
|
3377
|
+
}
|
|
3378
|
+
async function reorderTasks(wsId, ids) {
|
|
3379
|
+
return updateTasks(wsId, (tasks) => {
|
|
3380
|
+
const known = new Set(tasks.map((t) => t.id));
|
|
3381
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3382
|
+
for (const id of ids) {
|
|
3383
|
+
if (!known.has(id)) throw new Error(`unknown task ${id}`);
|
|
3384
|
+
if (seen.has(id)) throw new Error(`duplicate task ${id}`);
|
|
3385
|
+
seen.add(id);
|
|
3386
|
+
}
|
|
3387
|
+
const missing = [...known].filter((id) => !seen.has(id));
|
|
3388
|
+
if (missing.length)
|
|
3389
|
+
throw new Error(`reorder must list every task; missing ${missing.join(", ")}`);
|
|
3390
|
+
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
3391
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3392
|
+
const out = ids.map((id, i) => ({ ...byId.get(id), order: i + 1, updatedAt: now }));
|
|
3393
|
+
return { tasks: out, result: out };
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
var FAILED_JOB_STATUSES2 = /* @__PURE__ */ new Set(["failed", "cancelled"]);
|
|
3397
|
+
function reconcileTasks(tasks, ctx) {
|
|
3398
|
+
const jobById = new Map(ctx.jobs.map((j) => [j.id, j]));
|
|
3399
|
+
let changed = false;
|
|
3400
|
+
const out = tasks.map((t) => {
|
|
3401
|
+
if (t.boxJobId) {
|
|
3402
|
+
const job = jobById.get(t.boxJobId);
|
|
3403
|
+
if (job?.boxId) {
|
|
3404
|
+
changed = true;
|
|
3405
|
+
const next = { ...t, boxId: job.boxId };
|
|
3406
|
+
delete next.boxJobId;
|
|
3407
|
+
return next;
|
|
3408
|
+
}
|
|
3409
|
+
if (job && FAILED_JOB_STATUSES2.has(job.status)) {
|
|
3410
|
+
changed = true;
|
|
3411
|
+
const next = { ...t };
|
|
3412
|
+
delete next.boxJobId;
|
|
3413
|
+
return next;
|
|
3414
|
+
}
|
|
3415
|
+
return t;
|
|
3416
|
+
}
|
|
3417
|
+
if (t.boxId && !ctx.liveBoxIds.has(t.boxId)) {
|
|
3418
|
+
const pending = ctx.jobs.some(
|
|
3419
|
+
(j) => j.boxId === t.boxId && !FAILED_JOB_STATUSES2.has(j.status) && j.status !== "done"
|
|
3420
|
+
);
|
|
3421
|
+
if (pending) return t;
|
|
3422
|
+
changed = true;
|
|
3423
|
+
const next = { ...t };
|
|
3424
|
+
delete next.boxId;
|
|
3425
|
+
return next;
|
|
3426
|
+
}
|
|
3427
|
+
return t;
|
|
3428
|
+
});
|
|
3429
|
+
return { tasks: out, changed };
|
|
3430
|
+
}
|
|
3431
|
+
function taskSummaryForBox(tasks, key) {
|
|
3432
|
+
const mine = sortTasksByOrder(
|
|
3433
|
+
tasks.filter(
|
|
3434
|
+
(t) => key.boxId !== void 0 ? t.boxId === key.boxId : t.boxJobId === key.boxJobId
|
|
3435
|
+
)
|
|
3436
|
+
);
|
|
3437
|
+
if (mine.length === 0) return void 0;
|
|
3438
|
+
const done = mine.filter((t) => t.status === "done").length;
|
|
3439
|
+
const current = mine.find((t) => t.status === "in_progress") ?? mine.find((t) => t.status !== "done");
|
|
3440
|
+
return {
|
|
3441
|
+
total: mine.length,
|
|
3442
|
+
done,
|
|
3443
|
+
current: current ? { id: current.id, title: current.title } : null
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
async function readReconciledTasks(wsId, ctx) {
|
|
3447
|
+
const current = await readTasks(wsId);
|
|
3448
|
+
if (current.length === 0) return current;
|
|
3449
|
+
if (!reconcileTasks(current, ctx).changed) return current;
|
|
3450
|
+
return updateTasks(wsId, (tasks) => {
|
|
3451
|
+
const { tasks: healed } = reconcileTasks(tasks, ctx);
|
|
3452
|
+
return { tasks: healed, result: healed };
|
|
3453
|
+
});
|
|
3454
|
+
}
|
|
3455
|
+
var GH_PR_JSON_FIELDS = [
|
|
3456
|
+
"number",
|
|
3457
|
+
"title",
|
|
3458
|
+
"url",
|
|
3459
|
+
"headRefName",
|
|
3460
|
+
"baseRefName",
|
|
3461
|
+
"state",
|
|
3462
|
+
"mergedAt",
|
|
3463
|
+
"closedAt",
|
|
3464
|
+
"createdAt",
|
|
3465
|
+
"additions",
|
|
3466
|
+
"deletions",
|
|
3467
|
+
"statusCheckRollup",
|
|
3468
|
+
"mergeStateStatus",
|
|
3469
|
+
"autoMergeRequest",
|
|
3470
|
+
"mergedBy",
|
|
3471
|
+
"author"
|
|
3472
|
+
].join(",");
|
|
3473
|
+
function prEventKey(repo, number, kind) {
|
|
3474
|
+
return `pr:${repo}#${String(number)}:${kind}`;
|
|
3475
|
+
}
|
|
3476
|
+
function parsePrUrl(url) {
|
|
3477
|
+
const m = /https?:\/\/[^/\s]+\/([^/\s]+)\/([^/\s]+)\/pull\/(\d+)/u.exec(url);
|
|
3478
|
+
if (!m) return null;
|
|
3479
|
+
return { repo: `${m[1]}/${m[2]}`, number: Number(m[3]), url: m[0] };
|
|
3480
|
+
}
|
|
3481
|
+
var FAILED = /* @__PURE__ */ new Set([
|
|
3482
|
+
"FAILURE",
|
|
3483
|
+
"ERROR",
|
|
3484
|
+
"TIMED_OUT",
|
|
3485
|
+
"CANCELLED",
|
|
3486
|
+
"ACTION_REQUIRED",
|
|
3487
|
+
"STARTUP_FAILURE"
|
|
3488
|
+
]);
|
|
3489
|
+
var PASSED = /* @__PURE__ */ new Set(["SUCCESS", "NEUTRAL", "SKIPPED"]);
|
|
3490
|
+
function checksOf(rollup) {
|
|
3491
|
+
if (!rollup || rollup.length === 0) return "none";
|
|
3492
|
+
let pending = false;
|
|
3493
|
+
for (const c of rollup) {
|
|
3494
|
+
const verdict = (c.conclusion ?? c.state ?? "").toUpperCase();
|
|
3495
|
+
if (FAILED.has(verdict)) return "fail";
|
|
3496
|
+
if (c.status && c.status.toUpperCase() !== "COMPLETED") pending = true;
|
|
3497
|
+
else if (!PASSED.has(verdict)) pending = true;
|
|
3498
|
+
}
|
|
3499
|
+
return pending ? "pending" : "pass";
|
|
3500
|
+
}
|
|
3501
|
+
function isPrReady(pr) {
|
|
3502
|
+
if (pr.state !== "OPEN") return false;
|
|
3503
|
+
if (checksOf(pr.statusCheckRollup) !== "pass") return false;
|
|
3504
|
+
return pr.mergeStateStatus === "CLEAN" || pr.mergeStateStatus === "HAS_HOOKS";
|
|
3505
|
+
}
|
|
3506
|
+
function timelinePrOf(pr, repo) {
|
|
3507
|
+
return {
|
|
3508
|
+
repo,
|
|
3509
|
+
number: pr.number,
|
|
3510
|
+
title: pr.title,
|
|
3511
|
+
url: pr.url,
|
|
3512
|
+
base: pr.baseRefName,
|
|
3513
|
+
head: pr.headRefName,
|
|
3514
|
+
...typeof pr.additions === "number" ? { additions: pr.additions } : {},
|
|
3515
|
+
...typeof pr.deletions === "number" ? { deletions: pr.deletions } : {},
|
|
3516
|
+
checks: checksOf(pr.statusCheckRollup),
|
|
3517
|
+
...pr.mergeStateStatus ? { mergeState: pr.mergeStateStatus } : {},
|
|
3518
|
+
autoMerge: Boolean(pr.autoMergeRequest),
|
|
3519
|
+
...pr.mergedBy?.login ? { mergedBy: pr.mergedBy.login } : {}
|
|
3520
|
+
};
|
|
3521
|
+
}
|
|
3522
|
+
function prTimelineEvents(pr, repo, base, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
3523
|
+
const tpr = timelinePrOf(pr, repo);
|
|
3524
|
+
const common = { ...base, branch: base.branch ?? pr.headRefName, pr: tpr };
|
|
3525
|
+
const out = [
|
|
3526
|
+
{
|
|
3527
|
+
...common,
|
|
3528
|
+
type: "pr.opened",
|
|
3529
|
+
at: pr.createdAt ?? nowIso,
|
|
3530
|
+
key: prEventKey(repo, pr.number, "opened")
|
|
3531
|
+
}
|
|
3532
|
+
];
|
|
3533
|
+
if (pr.state === "MERGED") {
|
|
3534
|
+
out.push({
|
|
3535
|
+
...common,
|
|
3536
|
+
type: "pr.merged",
|
|
3537
|
+
at: pr.mergedAt ?? nowIso,
|
|
3538
|
+
key: prEventKey(repo, pr.number, "merged")
|
|
3539
|
+
});
|
|
3540
|
+
} else if (pr.state === "CLOSED") {
|
|
3541
|
+
out.push({
|
|
3542
|
+
...common,
|
|
3543
|
+
type: "pr.closed",
|
|
3544
|
+
at: pr.closedAt ?? nowIso,
|
|
3545
|
+
key: prEventKey(repo, pr.number, "closed")
|
|
3546
|
+
});
|
|
3547
|
+
} else if (isPrReady(pr)) {
|
|
3548
|
+
out.push({
|
|
3549
|
+
...common,
|
|
3550
|
+
type: "pr.ready",
|
|
3551
|
+
at: nowIso,
|
|
3552
|
+
key: prEventKey(repo, pr.number, "ready")
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
return out;
|
|
3556
|
+
}
|
|
3557
|
+
var TIMELINE_MAX_LINES = 5e3;
|
|
3558
|
+
var TIMELINE_KEEP_LINES = 4e3;
|
|
3559
|
+
var TIMELINE_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
3560
|
+
function newTimelineEventId(ms = Date.now()) {
|
|
3561
|
+
return `${ms.toString(36).padStart(9, "0")}-${randomBytes2(3).toString("hex")}`;
|
|
3562
|
+
}
|
|
3563
|
+
function stampFields(stamp, fallback = "human") {
|
|
3564
|
+
if (!stamp) return { actor: fallback };
|
|
3565
|
+
return {
|
|
3566
|
+
actor: stamp.actor,
|
|
3567
|
+
...stamp.managerId ? { managerId: stamp.managerId } : {},
|
|
3568
|
+
...stamp.turn !== void 0 ? { turn: stamp.turn } : {},
|
|
3569
|
+
...stamp.prompt ? { prompt: stamp.prompt } : {}
|
|
3570
|
+
};
|
|
3571
|
+
}
|
|
3572
|
+
var indexes = /* @__PURE__ */ new Map();
|
|
3573
|
+
function emptyIndex(ino = 0) {
|
|
3574
|
+
return { ino, offset: 0, lines: 0, oldestMs: Number.POSITIVE_INFINITY, keys: /* @__PURE__ */ new Set() };
|
|
3575
|
+
}
|
|
3576
|
+
function absorb(idx, line) {
|
|
3577
|
+
if (!line.trim()) return;
|
|
3578
|
+
try {
|
|
3579
|
+
const ev = JSON.parse(line);
|
|
3580
|
+
idx.lines += 1;
|
|
3581
|
+
const at = typeof ev.at === "string" ? Date.parse(ev.at) : Number.NaN;
|
|
3582
|
+
if (!Number.isNaN(at) && at < idx.oldestMs) idx.oldestMs = at;
|
|
3583
|
+
if (typeof ev.key === "string") idx.keys.add(ev.key);
|
|
3584
|
+
} catch {
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
async function indexOf(file) {
|
|
3588
|
+
let st;
|
|
3589
|
+
try {
|
|
3590
|
+
st = await stat3(file);
|
|
3591
|
+
} catch {
|
|
3592
|
+
indexes.delete(file);
|
|
3593
|
+
return emptyIndex();
|
|
3594
|
+
}
|
|
3595
|
+
let idx = indexes.get(file);
|
|
3596
|
+
if (!idx || idx.ino !== st.ino || st.size < idx.offset) {
|
|
3597
|
+
idx = emptyIndex(st.ino);
|
|
3598
|
+
indexes.set(file, idx);
|
|
3599
|
+
}
|
|
3600
|
+
if (st.size === idx.offset) return idx;
|
|
3601
|
+
const fh = await open2(file, "r");
|
|
3602
|
+
try {
|
|
3603
|
+
const buf = Buffer.alloc(st.size - idx.offset);
|
|
3604
|
+
const { bytesRead } = await fh.read(buf, 0, buf.length, idx.offset);
|
|
3605
|
+
const text3 = buf.subarray(0, bytesRead).toString("utf8");
|
|
3606
|
+
const end = text3.lastIndexOf("\n");
|
|
3607
|
+
if (end === -1) return idx;
|
|
3608
|
+
for (const line of text3.slice(0, end).split("\n")) absorb(idx, line);
|
|
3609
|
+
idx.offset += Buffer.byteLength(text3.slice(0, end + 1), "utf8");
|
|
3610
|
+
} finally {
|
|
3611
|
+
await fh.close();
|
|
3612
|
+
}
|
|
3613
|
+
return idx;
|
|
3614
|
+
}
|
|
3615
|
+
function parseLines(raw) {
|
|
3616
|
+
const out = [];
|
|
3617
|
+
for (const line of raw.split("\n")) {
|
|
3618
|
+
if (!line.trim()) continue;
|
|
3619
|
+
try {
|
|
3620
|
+
const ev = JSON.parse(line);
|
|
3621
|
+
if (typeof ev.id === "string" && typeof ev.at === "string" && typeof ev.type === "string") {
|
|
3622
|
+
out.push(ev);
|
|
3623
|
+
}
|
|
3624
|
+
} catch {
|
|
3625
|
+
continue;
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
return out;
|
|
3629
|
+
}
|
|
3630
|
+
function byTime(a, b) {
|
|
3631
|
+
if (a.at !== b.at) return a.at < b.at ? -1 : 1;
|
|
3632
|
+
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
3633
|
+
}
|
|
3634
|
+
async function compact(file, now) {
|
|
3635
|
+
const raw = await readFile4(file, "utf8").catch(() => "");
|
|
3636
|
+
const kept = parseLines(raw).filter((ev) => {
|
|
3637
|
+
const at = Date.parse(ev.at);
|
|
3638
|
+
return Number.isNaN(at) || now - at <= TIMELINE_RETENTION_MS;
|
|
3639
|
+
}).sort(byTime).slice(-TIMELINE_KEEP_LINES);
|
|
3640
|
+
const tmp = `${file}.tmp.${String(process.pid)}.${Date.now().toString(36)}`;
|
|
3641
|
+
await writeFile5(tmp, kept.map((ev) => JSON.stringify(ev)).join("\n") + (kept.length ? "\n" : ""));
|
|
3642
|
+
await rename5(tmp, file);
|
|
3643
|
+
indexes.delete(file);
|
|
3644
|
+
}
|
|
3645
|
+
async function fileFor(wsId) {
|
|
3646
|
+
const dir = await resolveWorkspaceDir(wsId);
|
|
3647
|
+
return dir ? timelineFile(dir) : null;
|
|
3648
|
+
}
|
|
3649
|
+
async function appendTimelineEvent(wsId, input, now = Date.now) {
|
|
3650
|
+
const file = await fileFor(wsId);
|
|
3651
|
+
if (!file) return null;
|
|
3652
|
+
return withFileLock(
|
|
3653
|
+
file,
|
|
3654
|
+
async () => {
|
|
3655
|
+
const idx = await indexOf(file);
|
|
3656
|
+
if (input.key && idx.keys.has(input.key)) return null;
|
|
3657
|
+
const ms = now();
|
|
3658
|
+
const ev = {
|
|
3659
|
+
...input,
|
|
3660
|
+
id: input.id ?? newTimelineEventId(ms),
|
|
3661
|
+
at: input.at ?? new Date(ms).toISOString()
|
|
3662
|
+
};
|
|
3663
|
+
await appendFile(file, JSON.stringify(ev) + "\n", "utf8");
|
|
3664
|
+
const after = await indexOf(file);
|
|
3665
|
+
if (after.lines > TIMELINE_MAX_LINES || Number.isFinite(after.oldestMs) && ms - after.oldestMs > TIMELINE_RETENTION_MS) {
|
|
3666
|
+
await compact(file, ms);
|
|
3667
|
+
}
|
|
3668
|
+
return ev;
|
|
3669
|
+
},
|
|
3670
|
+
WORKSPACE_LOCK
|
|
3671
|
+
);
|
|
3672
|
+
}
|
|
3673
|
+
async function recordTimelineEvent(wsId, input) {
|
|
3674
|
+
try {
|
|
3675
|
+
return await appendTimelineEvent(wsId, input);
|
|
3676
|
+
} catch (err2) {
|
|
3677
|
+
console.warn(
|
|
3678
|
+
`[timeline] could not record ${input.type} in ${wsId}: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
3679
|
+
);
|
|
3680
|
+
return null;
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
async function readTimeline(wsId, opts = {}) {
|
|
3684
|
+
const file = await fileFor(wsId);
|
|
3685
|
+
if (!file) return [];
|
|
3686
|
+
const raw = await readFile4(file, "utf8").catch(() => "");
|
|
3687
|
+
let events = parseLines(raw).sort(byTime).reverse();
|
|
3688
|
+
if (opts.before) events = events.filter((ev) => ev.at < opts.before);
|
|
3689
|
+
if (opts.since) events = events.filter((ev) => ev.at >= opts.since);
|
|
3690
|
+
return opts.limit !== void 0 ? events.slice(0, opts.limit) : events;
|
|
3691
|
+
}
|
|
3692
|
+
async function hasTimelineKey(wsId, key) {
|
|
3693
|
+
const file = await fileFor(wsId);
|
|
3694
|
+
if (!file) return false;
|
|
3695
|
+
return (await indexOf(file)).keys.has(key);
|
|
3696
|
+
}
|
|
3697
|
+
async function workspaceForPath(path) {
|
|
3698
|
+
if (!path) return null;
|
|
3699
|
+
const records = await listWorkspaces();
|
|
3700
|
+
if (records.length === 0) return null;
|
|
3701
|
+
return findWorkspaceContaining(records, await canonicalWorkspaceRoot(path));
|
|
3702
|
+
}
|
|
3703
|
+
async function recordTimelineForPath(path, input) {
|
|
3704
|
+
try {
|
|
3705
|
+
const ws = await workspaceForPath(path);
|
|
3706
|
+
return ws ? await recordTimelineEvent(ws.id, input) : null;
|
|
3707
|
+
} catch {
|
|
3708
|
+
return null;
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
async function boxTaskIds(wsId, boxId) {
|
|
3712
|
+
const tasks = await readTasks(wsId).catch(() => []);
|
|
3713
|
+
return tasks.filter((t) => t.boxId === boxId).map((t) => t.id);
|
|
3714
|
+
}
|
|
3715
|
+
async function recordBoxGitPush(ctx, origin, result, stat42) {
|
|
3716
|
+
if (result.exitCode !== 0 || origin.hostInitiated || origin.hostOnly) return;
|
|
3717
|
+
try {
|
|
3718
|
+
const ws = await workspaceForPath(ctx.hostPath);
|
|
3719
|
+
if (!ws) return;
|
|
3720
|
+
const [taskIds, managerId, diff] = await Promise.all([
|
|
3721
|
+
boxTaskIds(ws.id, ctx.boxId),
|
|
3722
|
+
managerIdForTarget({ boxId: ctx.boxId }, { workspaceId: ws.id }),
|
|
3723
|
+
stat42 ? pushLineStat(stat42) : void 0
|
|
3724
|
+
]);
|
|
3725
|
+
await recordTimelineEvent(ws.id, {
|
|
3726
|
+
type: "git.push",
|
|
3727
|
+
actor: "box",
|
|
3728
|
+
boxId: ctx.boxId,
|
|
3729
|
+
...ctx.boxName ? { boxName: ctx.boxName } : {},
|
|
3730
|
+
...ctx.branch ? { branch: ctx.branch } : {},
|
|
3731
|
+
...managerId ? { managerId } : {},
|
|
3732
|
+
...taskIds.length ? { taskIds } : {},
|
|
3733
|
+
...diff ?? {}
|
|
3734
|
+
});
|
|
3735
|
+
} catch {
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3738
|
+
var MERGE_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
3739
|
+
"-b",
|
|
3740
|
+
"--body",
|
|
3741
|
+
"-F",
|
|
3742
|
+
"--body-file",
|
|
3743
|
+
"-t",
|
|
3744
|
+
"--subject",
|
|
3745
|
+
"-A",
|
|
3746
|
+
"--author-email",
|
|
3747
|
+
"--match-head-commit",
|
|
3748
|
+
"-R",
|
|
3749
|
+
"--repo"
|
|
3750
|
+
]);
|
|
3751
|
+
function prMergeTarget(rest) {
|
|
3752
|
+
for (let i = 0; i < rest.length; i++) {
|
|
3753
|
+
const arg = rest[i] ?? "";
|
|
3754
|
+
if (MERGE_VALUE_FLAGS.has(arg)) {
|
|
3755
|
+
i++;
|
|
3756
|
+
continue;
|
|
3757
|
+
}
|
|
3758
|
+
if (!arg.startsWith("-")) return arg;
|
|
3759
|
+
}
|
|
3760
|
+
return void 0;
|
|
3761
|
+
}
|
|
3762
|
+
function prMergeRepo(rest) {
|
|
3763
|
+
for (let i = 0; i < rest.length; i++) {
|
|
3764
|
+
const arg = rest[i] ?? "";
|
|
3765
|
+
if (arg === "-R" || arg === "--repo") return rest[i + 1] || void 0;
|
|
3766
|
+
if (arg.startsWith("--repo=")) return arg.slice("--repo=".length) || void 0;
|
|
3767
|
+
if (arg.startsWith("-R") && arg.length > 2) return arg.slice(2);
|
|
3768
|
+
if (MERGE_VALUE_FLAGS.has(arg)) i++;
|
|
3769
|
+
}
|
|
3770
|
+
return void 0;
|
|
3771
|
+
}
|
|
3772
|
+
function prViewArgs(lead, target, repo) {
|
|
3773
|
+
return [
|
|
3774
|
+
...lead,
|
|
3775
|
+
"pr",
|
|
3776
|
+
"view",
|
|
3777
|
+
target,
|
|
3778
|
+
...repo ? ["--repo", repo] : [],
|
|
3779
|
+
"--json",
|
|
3780
|
+
GH_PR_JSON_FIELDS
|
|
3781
|
+
];
|
|
3782
|
+
}
|
|
3783
|
+
async function recordBoxGhResult(ctx, args, result) {
|
|
3784
|
+
if (result.exitCode !== 0) return;
|
|
3785
|
+
const verb = ghVerbArgv(args);
|
|
3786
|
+
if (verb[0] !== "pr" || verb[1] !== "create" && verb[1] !== "merge") return;
|
|
3787
|
+
try {
|
|
3788
|
+
const ws = await workspaceForPath(ctx.hostPath);
|
|
3789
|
+
if (!ws) return;
|
|
3790
|
+
const target = verb[1] === "create" ? parsePrUrl(result.stdout)?.url : prMergeTarget(verb.slice(2)) ?? ctx.branch;
|
|
3791
|
+
if (!target) return;
|
|
3792
|
+
const lead = args.slice(0, args.length - verb.length);
|
|
3793
|
+
const ghTarget = await resolveGhTarget(ctx.originUrl);
|
|
3794
|
+
if (ghTarget.error) return;
|
|
3795
|
+
const repo = verb[1] === "merge" ? prMergeRepo(verb.slice(2)) : void 0;
|
|
3796
|
+
const run4 = ghRunContext(ctx.hostPath, ctx.originUrl, prViewArgs(lead, target, repo));
|
|
3797
|
+
const view = await runHostGh(run4.args, run4.cwd, { host: ghTarget.host, timeoutMs: 2e4 });
|
|
3798
|
+
if (view.exitCode !== 0) return;
|
|
3799
|
+
const pr = JSON.parse(view.stdout);
|
|
3800
|
+
const parsed = parsePrUrl(pr.url);
|
|
3801
|
+
if (!parsed) return;
|
|
3802
|
+
const [taskIds, managerId] = await Promise.all([
|
|
3803
|
+
boxTaskIds(ws.id, ctx.boxId),
|
|
3804
|
+
managerIdForTarget({ boxId: ctx.boxId }, { workspaceId: ws.id })
|
|
3805
|
+
]);
|
|
3806
|
+
const events = prTimelineEvents(pr, parsed.repo, {
|
|
3807
|
+
actor: "box",
|
|
3808
|
+
boxId: ctx.boxId,
|
|
3809
|
+
...ctx.boxName ? { boxName: ctx.boxName } : {},
|
|
3810
|
+
...managerId ? { managerId } : {},
|
|
3811
|
+
...taskIds.length ? { taskIds } : {}
|
|
3812
|
+
});
|
|
3813
|
+
for (const ev of events) {
|
|
3814
|
+
if (ev.type === "pr.ready") continue;
|
|
3815
|
+
await recordTimelineEvent(ws.id, ev);
|
|
3816
|
+
}
|
|
3817
|
+
} catch {
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
function jobAgent(job) {
|
|
3821
|
+
if (job.noAgent) return void 0;
|
|
3822
|
+
return job.agent === "claude-code" ? "claude" : job.agent;
|
|
3823
|
+
}
|
|
3824
|
+
async function recordCreateJobTimeline(job) {
|
|
3825
|
+
if (job.kind === "prepare") return;
|
|
3826
|
+
if (job.status !== "done" && job.status !== "failed") return;
|
|
3827
|
+
try {
|
|
3828
|
+
const ws = await workspaceForPath(job.createOpts.workspace);
|
|
3829
|
+
if (!ws) return;
|
|
3830
|
+
const box = job.boxId ? (await readState().catch(() => null))?.boxes.find((b) => b.id === job.boxId) : void 0;
|
|
3831
|
+
const [tasks, byJob, byBox] = await Promise.all([
|
|
3832
|
+
readTasks(ws.id).catch(() => []),
|
|
3833
|
+
managerIdForTarget({ boxJobId: job.id }, { workspaceId: ws.id }),
|
|
3834
|
+
job.boxId ? managerIdForTarget({ boxId: job.boxId }, { workspaceId: ws.id }) : Promise.resolve(void 0)
|
|
3835
|
+
]);
|
|
3836
|
+
const taskIds = tasks.filter((t) => t.boxJobId === job.id || job.boxId !== void 0 && t.boxId === job.boxId).map((t) => t.id);
|
|
3837
|
+
const managerId = byJob ?? byBox;
|
|
3838
|
+
const name = box?.name ?? (job.boxName || job.createOpts.name);
|
|
3839
|
+
const branch = box?.gitWorktrees?.[0]?.branch ?? box?.cloud?.workspaceBranch;
|
|
3840
|
+
const agent = jobAgent(job);
|
|
3841
|
+
const ready = job.status === "done";
|
|
3842
|
+
await recordTimelineEvent(ws.id, {
|
|
3843
|
+
type: ready ? "box.ready" : "box.failed",
|
|
3844
|
+
actor: "hub",
|
|
3845
|
+
key: `job:${job.id}:${ready ? "ready" : "failed"}`,
|
|
3846
|
+
...job.boxId ? { boxId: job.boxId } : {},
|
|
3847
|
+
...name ? { boxName: name } : {},
|
|
3848
|
+
...agent ? { agent } : {},
|
|
3849
|
+
...branch ? { branch } : {},
|
|
3850
|
+
...job.createOpts.fromBranch ? { base: job.createOpts.fromBranch } : {},
|
|
3851
|
+
...managerId ? { managerId } : {},
|
|
3852
|
+
...taskIds.length ? { taskIds } : {},
|
|
3853
|
+
...!ready && job.reason ? { text: job.reason.slice(0, 500) } : {}
|
|
3854
|
+
});
|
|
3855
|
+
} catch {
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
var QUEUE_DIR = join5(STATE_DIR2, "queue");
|
|
3859
|
+
var PREPARE_MAX_CONCURRENT_PER_PROVIDER = 1;
|
|
3860
|
+
async function loadQueueConfig() {
|
|
3861
|
+
const d = BUILT_IN_DEFAULTS.queue;
|
|
3862
|
+
let global = {};
|
|
3863
|
+
try {
|
|
3864
|
+
global = parseUserConfig(await readFile5(GLOBAL_CONFIG_FILE, "utf8"), GLOBAL_CONFIG_FILE);
|
|
3865
|
+
} catch {
|
|
3866
|
+
}
|
|
3867
|
+
const q = global.queue ?? {};
|
|
3868
|
+
return {
|
|
3869
|
+
enabled: q.enabled ?? d.enabled,
|
|
3870
|
+
maxConcurrent: q.maxConcurrent ?? d.maxConcurrent,
|
|
3871
|
+
maxWorking: q.maxWorking ?? d.maxWorking,
|
|
3872
|
+
idleGraceMs: (q.idleGraceSeconds ?? d.idleGraceSeconds) * 1e3
|
|
3873
|
+
};
|
|
3874
|
+
}
|
|
3875
|
+
async function writeJob(job) {
|
|
3876
|
+
await mkdir5(QUEUE_DIR, { recursive: true });
|
|
3877
|
+
const final = join5(QUEUE_DIR, `${job.id}.json`);
|
|
3878
|
+
const tmp = `${final}.tmp.${String(process.pid)}.${String(Date.now())}`;
|
|
3879
|
+
await writeFile6(tmp, JSON.stringify(job, null, 2) + "\n", "utf8");
|
|
3880
|
+
await rename6(tmp, final);
|
|
3881
|
+
}
|
|
3882
|
+
async function enqueueQueueJob(input) {
|
|
3883
|
+
const cfg = await loadQueueConfig();
|
|
3884
|
+
const ceiling = typeof input.maxRunningOverride === "number" && input.maxRunningOverride > 0 ? input.maxRunningOverride : cfg.maxConcurrent;
|
|
3885
|
+
const maxWorking = typeof input.maxWorkingOverride === "number" && input.maxWorkingOverride > 0 ? input.maxWorkingOverride : void 0;
|
|
3886
|
+
const id = randomBytes3(9).toString("hex");
|
|
3887
|
+
const job = {
|
|
3888
|
+
id,
|
|
3889
|
+
agent: input.agent,
|
|
3890
|
+
status: "queued",
|
|
3891
|
+
boxName: input.boxName,
|
|
3892
|
+
providerName: input.providerName,
|
|
3893
|
+
prompt: input.prompt,
|
|
3894
|
+
agentArgs: input.agentArgs,
|
|
3895
|
+
...input.noAgent ? { noAgent: true } : {},
|
|
3896
|
+
...input.setupWizard ? { setupWizard: true } : {},
|
|
3897
|
+
...input.foreground ? { foreground: true } : {},
|
|
3898
|
+
createOpts: input.createOpts,
|
|
3899
|
+
maxConcurrent: ceiling,
|
|
3900
|
+
...maxWorking !== void 0 ? { maxWorking } : {},
|
|
3901
|
+
...input.openTerminal !== void 0 ? { openTerminal: input.openTerminal } : {},
|
|
3902
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3903
|
+
logPath: queueLogPath(id)
|
|
3904
|
+
};
|
|
3905
|
+
await writeJob(job);
|
|
3906
|
+
let runningCount = 0;
|
|
3907
|
+
try {
|
|
3908
|
+
runningCount = await defaultCountRunningBoxes();
|
|
3909
|
+
} catch {
|
|
3910
|
+
runningCount = 0;
|
|
3911
|
+
}
|
|
3912
|
+
return { job, runningCount, maxConcurrent: ceiling };
|
|
3913
|
+
}
|
|
3914
|
+
async function enqueuePrepareJob(input) {
|
|
3915
|
+
const id = randomBytes3(9).toString("hex");
|
|
3916
|
+
const prepare = {
|
|
3917
|
+
...input.force ? { force: true } : {},
|
|
3918
|
+
...input.agentSettings ? { agentSettings: input.agentSettings } : {},
|
|
3919
|
+
...input.agents ? { agents: input.agents } : {},
|
|
3920
|
+
...input.build ? { build: true } : {},
|
|
3921
|
+
...input.size ? { size: input.size } : {},
|
|
3922
|
+
...input.location ? { location: input.location } : {},
|
|
3923
|
+
...input.name ? { name: input.name } : {}
|
|
3924
|
+
};
|
|
3925
|
+
const job = {
|
|
3926
|
+
id,
|
|
3927
|
+
kind: "prepare",
|
|
3928
|
+
agent: "claude-code",
|
|
3929
|
+
// placeholder — ignored for prepare
|
|
3930
|
+
status: "queued",
|
|
3931
|
+
boxName: "",
|
|
3932
|
+
providerName: input.providerName,
|
|
3933
|
+
prompt: "",
|
|
3934
|
+
agentArgs: [],
|
|
3935
|
+
createOpts: { workspace: input.workspace ?? process.cwd() },
|
|
3936
|
+
prepare,
|
|
3937
|
+
maxConcurrent: PREPARE_MAX_CONCURRENT_PER_PROVIDER,
|
|
3938
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3939
|
+
logPath: queueLogPath(id)
|
|
3940
|
+
};
|
|
3941
|
+
await writeJob(job);
|
|
3942
|
+
return { job };
|
|
3943
|
+
}
|
|
3944
|
+
async function readJob(id) {
|
|
3945
|
+
try {
|
|
3946
|
+
const raw = await readFile5(join5(QUEUE_DIR, `${id}.json`), "utf8");
|
|
3947
|
+
return JSON.parse(raw);
|
|
3948
|
+
} catch (err2) {
|
|
3949
|
+
if (err2.code === "ENOENT") return null;
|
|
3950
|
+
throw err2;
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
async function deleteJob(id) {
|
|
3954
|
+
try {
|
|
3955
|
+
await unlink(join5(QUEUE_DIR, `${id}.json`));
|
|
3956
|
+
} catch (err2) {
|
|
3957
|
+
if (err2.code !== "ENOENT") throw err2;
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
async function loadQueue() {
|
|
3961
|
+
let entries;
|
|
3962
|
+
try {
|
|
3963
|
+
entries = await readdir3(QUEUE_DIR);
|
|
3964
|
+
} catch (err2) {
|
|
3965
|
+
if (err2.code === "ENOENT") return [];
|
|
3966
|
+
throw err2;
|
|
3967
|
+
}
|
|
3968
|
+
const out = [];
|
|
3969
|
+
for (const name of entries) {
|
|
3970
|
+
if (!name.endsWith(".json")) continue;
|
|
3971
|
+
try {
|
|
3972
|
+
const raw = await readFile5(join5(QUEUE_DIR, name), "utf8");
|
|
3973
|
+
out.push(JSON.parse(raw));
|
|
3974
|
+
} catch {
|
|
3975
|
+
}
|
|
3976
|
+
}
|
|
3977
|
+
out.sort((a, b) => a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : 0);
|
|
3978
|
+
return out;
|
|
3979
|
+
}
|
|
3980
|
+
function selectNextRunnable(jobs, runningCount) {
|
|
3981
|
+
for (const j of jobs) {
|
|
3982
|
+
if (j.status !== "queued") continue;
|
|
3983
|
+
if (j.kind === "prepare") continue;
|
|
3984
|
+
if (j.foreground) continue;
|
|
3985
|
+
if (runningCount < j.maxConcurrent) return j;
|
|
3986
|
+
}
|
|
3987
|
+
return null;
|
|
3988
|
+
}
|
|
3989
|
+
function selectNextRunnableForeground(jobs) {
|
|
3990
|
+
for (const j of jobs) {
|
|
3991
|
+
if (j.status !== "queued") continue;
|
|
3992
|
+
if (j.kind === "prepare") continue;
|
|
3993
|
+
if (!j.foreground) continue;
|
|
3994
|
+
return j;
|
|
3995
|
+
}
|
|
3996
|
+
return null;
|
|
3997
|
+
}
|
|
3998
|
+
function countRunningPrepareJobsByProvider(jobs) {
|
|
3999
|
+
const byProvider = /* @__PURE__ */ new Map();
|
|
4000
|
+
for (const j of jobs) {
|
|
4001
|
+
if (j.kind !== "prepare") continue;
|
|
4002
|
+
if (j.status !== "running") continue;
|
|
4003
|
+
if (typeof j.pid === "number" && !processAlive(j.pid)) continue;
|
|
4004
|
+
byProvider.set(j.providerName, (byProvider.get(j.providerName) ?? 0) + 1);
|
|
4005
|
+
}
|
|
4006
|
+
return byProvider;
|
|
4007
|
+
}
|
|
4008
|
+
function selectNextRunnablePrepare(jobs, runningByProvider) {
|
|
4009
|
+
for (const j of jobs) {
|
|
4010
|
+
if (j.kind !== "prepare") continue;
|
|
4011
|
+
if (j.status !== "queued") continue;
|
|
4012
|
+
const running = runningByProvider.get(j.providerName) ?? 0;
|
|
4013
|
+
if (running >= PREPARE_MAX_CONCURRENT_PER_PROVIDER) continue;
|
|
4014
|
+
return j;
|
|
4015
|
+
}
|
|
4016
|
+
return null;
|
|
4017
|
+
}
|
|
4018
|
+
var STARTUP_GRACE_MS = 9e4;
|
|
4019
|
+
function occupiesWorkingSlot(e, idleGraceMs) {
|
|
4020
|
+
if (e.agentState === "working" || e.agentState === "compacting") return true;
|
|
4021
|
+
if ((e.agentState === null || e.agentState === "unknown") && e.sinceCreateMs !== null && e.sinceCreateMs < STARTUP_GRACE_MS) {
|
|
4022
|
+
return true;
|
|
4023
|
+
}
|
|
4024
|
+
if ((e.agentState === "idle" || e.agentState === "waiting" || e.agentState === "end-plan" || e.agentState === "question") && e.sinceUpdateMs !== null && e.sinceUpdateMs < idleGraceMs) {
|
|
4025
|
+
return true;
|
|
4026
|
+
}
|
|
4027
|
+
return false;
|
|
4028
|
+
}
|
|
4029
|
+
function countWorkingSlots(entries, idleGraceMs) {
|
|
4030
|
+
return entries.reduce((n, e) => occupiesWorkingSlot(e, idleGraceMs) ? n + 1 : n, 0);
|
|
4031
|
+
}
|
|
4032
|
+
function selectNextRunnableByWorking(jobs, workingCount, globalMaxWorking) {
|
|
4033
|
+
for (const j of jobs) {
|
|
4034
|
+
if (j.status !== "queued") continue;
|
|
4035
|
+
if (j.kind === "prepare") continue;
|
|
4036
|
+
if (j.foreground) continue;
|
|
4037
|
+
const ceil = typeof j.maxWorking === "number" && j.maxWorking > 0 ? j.maxWorking : globalMaxWorking;
|
|
1582
4038
|
if (workingCount < ceil) return j;
|
|
1583
4039
|
}
|
|
1584
4040
|
return null;
|
|
@@ -1679,6 +4135,7 @@ function startQueueLoop(deps) {
|
|
|
1679
4135
|
};
|
|
1680
4136
|
await writeJob(failed);
|
|
1681
4137
|
onStatusChange?.(failed);
|
|
4138
|
+
void recordCreateJobTimeline(failed);
|
|
1682
4139
|
log(`queue: spawn for job ${updated.id} failed: ${msg}`);
|
|
1683
4140
|
}
|
|
1684
4141
|
}
|
|
@@ -1717,6 +4174,7 @@ function startQueueLoop(deps) {
|
|
|
1717
4174
|
};
|
|
1718
4175
|
await writeJob(failed);
|
|
1719
4176
|
onStatusChange?.(failed);
|
|
4177
|
+
void recordCreateJobTimeline(failed);
|
|
1720
4178
|
log(`queue: spawn for foreground job ${updated.id} failed: ${msg}`);
|
|
1721
4179
|
}
|
|
1722
4180
|
}
|
|
@@ -1756,6 +4214,7 @@ function startQueueLoop(deps) {
|
|
|
1756
4214
|
};
|
|
1757
4215
|
await writeJob(failed);
|
|
1758
4216
|
onStatusChange?.(failed);
|
|
4217
|
+
void recordCreateJobTimeline(failed);
|
|
1759
4218
|
log(`queue: spawn for prepare job ${updated.id} failed: ${msg}`);
|
|
1760
4219
|
}
|
|
1761
4220
|
}
|
|
@@ -1799,6 +4258,7 @@ async function recoverOrphanedWorkers(log, onChange, requirePid = false) {
|
|
|
1799
4258
|
};
|
|
1800
4259
|
await writeJob(failed);
|
|
1801
4260
|
onChange?.(failed);
|
|
4261
|
+
void recordCreateJobTimeline(failed);
|
|
1802
4262
|
log(`queue: recovered orphan job ${j.id} (pid ${String(j.pid ?? "?")} not alive) -> failed`);
|
|
1803
4263
|
}
|
|
1804
4264
|
}
|
|
@@ -1910,7 +4370,7 @@ function cloudBoxCountsAsRunning(box) {
|
|
|
1910
4370
|
}
|
|
1911
4371
|
function inspectDockerState(containerName) {
|
|
1912
4372
|
return new Promise((resolveP) => {
|
|
1913
|
-
const child =
|
|
4373
|
+
const child = spawn2("docker", ["inspect", "--format", "{{.State.Status}}", containerName], {
|
|
1914
4374
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1915
4375
|
});
|
|
1916
4376
|
let out = "";
|
|
@@ -1939,15 +4399,15 @@ function inspectDockerState(containerName) {
|
|
|
1939
4399
|
}
|
|
1940
4400
|
async function defaultSpawnWorker(job) {
|
|
1941
4401
|
const entry = process.env.AGENTBOX_CLI_ENTRY;
|
|
1942
|
-
if (!entry || !
|
|
4402
|
+
if (!entry || !existsSync3(entry)) {
|
|
1943
4403
|
throw new Error(
|
|
1944
4404
|
`AGENTBOX_CLI_ENTRY not set or missing (${String(entry)}); cannot spawn queue worker`
|
|
1945
4405
|
);
|
|
1946
4406
|
}
|
|
1947
|
-
await
|
|
4407
|
+
await mkdir5(join5(STATE_DIR2, "logs"), { recursive: true });
|
|
1948
4408
|
const fd = openSync(job.logPath, "a");
|
|
1949
4409
|
const command = job.kind === "prepare" ? "_run-queued-prepare" : "_run-queued-job";
|
|
1950
|
-
const child =
|
|
4410
|
+
const child = spawn2(process.execPath, [entry, command, job.id], {
|
|
1951
4411
|
detached: true,
|
|
1952
4412
|
stdio: ["ignore", fd, fd],
|
|
1953
4413
|
env: process.env,
|
|
@@ -1960,23 +4420,23 @@ async function defaultSpawnWorker(job) {
|
|
|
1960
4420
|
}
|
|
1961
4421
|
return typeof child.pid === "number" ? child.pid : null;
|
|
1962
4422
|
}
|
|
1963
|
-
var QUEUE_LOGS_DIR =
|
|
4423
|
+
var QUEUE_LOGS_DIR = join5(STATE_DIR2, "logs");
|
|
1964
4424
|
function queueLogPath(id) {
|
|
1965
|
-
return
|
|
4425
|
+
return join5(QUEUE_LOGS_DIR, `queue-${id}.log`);
|
|
1966
4426
|
}
|
|
1967
4427
|
function queueLoginCodePath(id) {
|
|
1968
|
-
return
|
|
4428
|
+
return join5(QUEUE_DIR, `${id}.login-code`);
|
|
1969
4429
|
}
|
|
1970
4430
|
async function writeQueueLoginCode(id, code) {
|
|
1971
|
-
await
|
|
4431
|
+
await mkdir5(QUEUE_DIR, { recursive: true });
|
|
1972
4432
|
const final = queueLoginCodePath(id);
|
|
1973
4433
|
const tmp = `${final}.tmp.${String(process.pid)}.${String(Date.now())}`;
|
|
1974
|
-
await
|
|
1975
|
-
await
|
|
4434
|
+
await writeFile6(tmp, code.trim(), { mode: 384 });
|
|
4435
|
+
await rename6(tmp, final);
|
|
1976
4436
|
}
|
|
1977
4437
|
async function takeQueueLoginCode(id) {
|
|
1978
4438
|
try {
|
|
1979
|
-
const code = (await
|
|
4439
|
+
const code = (await readFile5(queueLoginCodePath(id), "utf8")).trim();
|
|
1980
4440
|
await unlink(queueLoginCodePath(id)).catch(() => {
|
|
1981
4441
|
});
|
|
1982
4442
|
return code.length > 0 ? code : null;
|
|
@@ -1987,21 +4447,21 @@ async function takeQueueLoginCode(id) {
|
|
|
1987
4447
|
async function waitForFile(path, timeoutMs = 1e3) {
|
|
1988
4448
|
const deadline = Date.now() + timeoutMs;
|
|
1989
4449
|
while (Date.now() < deadline) {
|
|
1990
|
-
if (
|
|
4450
|
+
if (existsSync3(path)) return true;
|
|
1991
4451
|
await delay(25);
|
|
1992
4452
|
}
|
|
1993
|
-
return
|
|
4453
|
+
return existsSync3(path);
|
|
1994
4454
|
}
|
|
1995
4455
|
|
|
1996
|
-
// ../../packages/relay/dist/chunk-
|
|
4456
|
+
// ../../packages/relay/dist/chunk-2F65LVQC.js
|
|
1997
4457
|
import { timingSafeEqual as timingSafeEqual4 } from "crypto";
|
|
1998
4458
|
import { mkdirSync } from "fs";
|
|
1999
4459
|
import { createRequire } from "module";
|
|
2000
|
-
import { dirname as
|
|
4460
|
+
import { dirname as dirname3, join as join6 } from "path";
|
|
2001
4461
|
import { createReadStream, createWriteStream } from "fs";
|
|
2002
|
-
import { chmod, mkdir as
|
|
4462
|
+
import { chmod, mkdir as mkdir6, readFile as readFile6, readdir as readdir4, rename as rename7, rm as rm5, stat as stat4, writeFile as writeFile7 } from "fs/promises";
|
|
2003
4463
|
import { dirname as dirname22, join as join22, relative, sep } from "path";
|
|
2004
|
-
import { createHash as createHash2, randomBytes as
|
|
4464
|
+
import { createHash as createHash2, randomBytes as randomBytes4 } from "crypto";
|
|
2005
4465
|
import { pipeline } from "stream/promises";
|
|
2006
4466
|
import { Transform } from "stream";
|
|
2007
4467
|
function lfsEndpointFor(cloneUrl) {
|
|
@@ -2875,7 +5335,7 @@ var PostgresStore = class {
|
|
|
2875
5335
|
}
|
|
2876
5336
|
};
|
|
2877
5337
|
var DEFAULT_EVENT_CAP2 = RELAY_EVENT_RING_SIZE;
|
|
2878
|
-
var DEFAULT_SQLITE_STORE_PATH =
|
|
5338
|
+
var DEFAULT_SQLITE_STORE_PATH = join6(STATE_DIR, "hub", "store.db");
|
|
2879
5339
|
var MIN_NODE_SQLITE = [22, 5];
|
|
2880
5340
|
function loadNodeSqlite() {
|
|
2881
5341
|
const require2 = createRequire(import.meta.url);
|
|
@@ -2909,7 +5369,7 @@ var SqliteStore = class {
|
|
|
2909
5369
|
assertNodeSupportsSqlite();
|
|
2910
5370
|
const { DatabaseSync } = loadNodeSqlite();
|
|
2911
5371
|
const { drizzle } = await import("./sqlite-proxy-44UHG7CT.js");
|
|
2912
|
-
if (this.path !== ":memory:") mkdirSync(
|
|
5372
|
+
if (this.path !== ":memory:") mkdirSync(dirname3(this.path), { recursive: true });
|
|
2913
5373
|
const raw = new DatabaseSync(this.path);
|
|
2914
5374
|
raw.exec("PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 5000;");
|
|
2915
5375
|
raw.exec(SQLITE_SCHEMA_SQL);
|
|
@@ -3048,700 +5508,353 @@ var SqliteStore = class {
|
|
|
3048
5508
|
ev: row.ev,
|
|
3049
5509
|
method: row.method,
|
|
3050
5510
|
params: row.params ?? null,
|
|
3051
|
-
status: row.status,
|
|
3052
|
-
answer: row.answer ?? null,
|
|
3053
|
-
cancelled: row.cancelled ?? null,
|
|
3054
|
-
result: row.result ?? null,
|
|
3055
|
-
createdAt: row.createdAt,
|
|
3056
|
-
expiresAt: row.expiresAt ?? null
|
|
3057
|
-
}).onConflictDoNothing({ target: sqlitePrompts.id });
|
|
3058
|
-
}
|
|
3059
|
-
async getPrompt(promptId) {
|
|
3060
|
-
const db = await this.db();
|
|
3061
|
-
const rows = await db.select().from(sqlitePrompts).where(eq(sqlitePrompts.id, promptId));
|
|
3062
|
-
return rows[0] ? rowToPrompt(rows[0]) : null;
|
|
3063
|
-
}
|
|
3064
|
-
async answerPrompt(promptId, answer, cancelled) {
|
|
3065
|
-
const db = await this.db();
|
|
3066
|
-
const rows = await db.update(sqlitePrompts).set({ status: "answered", answer, cancelled: cancelled ?? null }).where(and(eq(sqlitePrompts.id, promptId), eq(sqlitePrompts.status, "pending"))).returning({ id: sqlitePrompts.id });
|
|
3067
|
-
return rows.length > 0;
|
|
3068
|
-
}
|
|
3069
|
-
async listPendingPrompts(boxId) {
|
|
3070
|
-
const db = await this.db();
|
|
3071
|
-
const rows = await db.select().from(sqlitePrompts).where(and(eq(sqlitePrompts.boxId, boxId), eq(sqlitePrompts.status, "pending"))).orderBy(asc(sqlitePrompts.createdAt));
|
|
3072
|
-
return rows.map(rowToPrompt);
|
|
3073
|
-
}
|
|
3074
|
-
async setPromptResult(promptId, result) {
|
|
3075
|
-
const db = await this.db();
|
|
3076
|
-
await db.update(sqlitePrompts).set({ result }).where(eq(sqlitePrompts.id, promptId));
|
|
3077
|
-
}
|
|
3078
|
-
// --- box-create job queue ---
|
|
3079
|
-
async enqueueCreateJob(job) {
|
|
3080
|
-
const db = await this.db();
|
|
3081
|
-
await db.insert(sqliteCreateJobs).values({
|
|
3082
|
-
id: job.id,
|
|
3083
|
-
status: job.status,
|
|
3084
|
-
request: job.request,
|
|
3085
|
-
result: job.result ?? null,
|
|
3086
|
-
claimedBy: job.claimedBy ?? null,
|
|
3087
|
-
createdAt: job.createdAt,
|
|
3088
|
-
startedAt: job.startedAt ?? null,
|
|
3089
|
-
finishedAt: job.finishedAt ?? null
|
|
3090
|
-
}).onConflictDoNothing({ target: sqliteCreateJobs.id });
|
|
3091
|
-
}
|
|
3092
|
-
async getCreateJob(id) {
|
|
3093
|
-
const db = await this.db();
|
|
3094
|
-
const rows = await db.select().from(sqliteCreateJobs).where(eq(sqliteCreateJobs.id, id));
|
|
3095
|
-
return rows[0] ? rowToJob(rows[0]) : null;
|
|
3096
|
-
}
|
|
3097
|
-
async listCreateJobs(opts) {
|
|
3098
|
-
const db = await this.db();
|
|
3099
|
-
const base = db.select().from(sqliteCreateJobs);
|
|
3100
|
-
const filtered = opts?.status?.length ? base.where(inArray(sqliteCreateJobs.status, opts.status)) : base;
|
|
3101
|
-
const rows = await filtered.orderBy(desc(sqliteCreateJobs.createdAt)).limit(opts?.limit ?? 100);
|
|
3102
|
-
return rows.map(rowToJob);
|
|
3103
|
-
}
|
|
3104
|
-
async claimNextCreateJob(workerId) {
|
|
3105
|
-
const db = await this.db();
|
|
3106
|
-
const oldestQueued = db.select({ id: sqliteCreateJobs.id }).from(sqliteCreateJobs).where(eq(sqliteCreateJobs.status, "queued")).orderBy(asc(sqliteCreateJobs.createdAt)).limit(1);
|
|
3107
|
-
const rows = await db.update(sqliteCreateJobs).set({ status: "running", claimedBy: workerId, startedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(
|
|
3108
|
-
and(inArray(sqliteCreateJobs.id, oldestQueued), eq(sqliteCreateJobs.status, "queued"))
|
|
3109
|
-
).returning();
|
|
3110
|
-
return rows[0] ? rowToJob(rows[0]) : null;
|
|
3111
|
-
}
|
|
3112
|
-
async completeCreateJob(id, status, result) {
|
|
3113
|
-
const db = await this.db();
|
|
3114
|
-
await db.update(sqliteCreateJobs).set({ status, result, finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(sqliteCreateJobs.id, id));
|
|
3115
|
-
}
|
|
3116
|
-
// --- retention (ISO strings compare lexicographically, matching the columns) ---
|
|
3117
|
-
async prunePrompts(beforeIso) {
|
|
3118
|
-
const db = await this.db();
|
|
3119
|
-
const rows = await db.delete(sqlitePrompts).where(
|
|
3120
|
-
or(
|
|
3121
|
-
and(eq(sqlitePrompts.status, "answered"), lt(sqlitePrompts.createdAt, beforeIso)),
|
|
3122
|
-
and(isNotNull(sqlitePrompts.expiresAt), lt(sqlitePrompts.expiresAt, beforeIso))
|
|
3123
|
-
)
|
|
3124
|
-
).returning({ id: sqlitePrompts.id });
|
|
3125
|
-
return rows.length;
|
|
3126
|
-
}
|
|
3127
|
-
async pruneCreateJobs(beforeIso) {
|
|
3128
|
-
const db = await this.db();
|
|
3129
|
-
const rows = await db.delete(sqliteCreateJobs).where(
|
|
3130
|
-
and(
|
|
3131
|
-
inArray(sqliteCreateJobs.status, ["done", "failed"]),
|
|
3132
|
-
isNotNull(sqliteCreateJobs.finishedAt),
|
|
3133
|
-
lt(sqliteCreateJobs.finishedAt, beforeIso)
|
|
3134
|
-
)
|
|
3135
|
-
).returning({ id: sqliteCreateJobs.id });
|
|
3136
|
-
return rows.length;
|
|
3137
|
-
}
|
|
3138
|
-
};
|
|
3139
|
-
function makeStore(spec) {
|
|
3140
|
-
if (!spec || spec === "memory") return new MemoryStore();
|
|
3141
|
-
if (spec.startsWith("postgres://") || spec.startsWith("postgresql://")) {
|
|
3142
|
-
return new PostgresStore({ connectionString: spec });
|
|
3143
|
-
}
|
|
3144
|
-
if (spec.startsWith("sqlite:")) {
|
|
3145
|
-
const path = spec.slice("sqlite:".length).replace(/^\/\//, "");
|
|
3146
|
-
if (!path) throw new Error(`store spec has no path: ${spec}`);
|
|
3147
|
-
return new SqliteStore({ path });
|
|
3148
|
-
}
|
|
3149
|
-
if (spec === ":memory:" || spec.startsWith("/") || spec.startsWith(".") || spec.endsWith(".db")) {
|
|
3150
|
-
return new SqliteStore({ path: spec });
|
|
3151
|
-
}
|
|
3152
|
-
throw new Error(`unknown store spec: ${spec}`);
|
|
3153
|
-
}
|
|
3154
|
-
var DEFAULT_CUSTODY_DIR = join22(STATE_DIR, "hub", "custody");
|
|
3155
|
-
var DIR_MODE = 448;
|
|
3156
|
-
var FILE_MODE = 384;
|
|
3157
|
-
var FsCustodyStore = class {
|
|
3158
|
-
root;
|
|
3159
|
-
constructor(opts = {}) {
|
|
3160
|
-
this.root = opts.root ?? DEFAULT_CUSTODY_DIR;
|
|
3161
|
-
}
|
|
3162
|
-
async put(path, data) {
|
|
3163
|
-
const rel = normalizeCustodyPath(path);
|
|
3164
|
-
const abs = join22(this.root, rel);
|
|
3165
|
-
const sha256 = custodyDigest(data);
|
|
3166
|
-
const existing = await this.readEntry(rel);
|
|
3167
|
-
if (existing && existing.entry.sha256 === sha256) {
|
|
3168
|
-
return { ...existing.entry, changed: false };
|
|
3169
|
-
}
|
|
3170
|
-
await mkdir3(dirname22(abs), { recursive: true, mode: DIR_MODE });
|
|
3171
|
-
const tmp = `${abs}.${randomBytes2(6).toString("hex")}.tmp`;
|
|
3172
|
-
try {
|
|
3173
|
-
await writeFile3(tmp, data, { mode: FILE_MODE });
|
|
3174
|
-
await chmod(tmp, FILE_MODE);
|
|
3175
|
-
await rename3(tmp, abs);
|
|
3176
|
-
} catch (err2) {
|
|
3177
|
-
await rm3(tmp, { force: true });
|
|
3178
|
-
throw err2;
|
|
3179
|
-
}
|
|
3180
|
-
const st = await stat(abs);
|
|
3181
|
-
return {
|
|
3182
|
-
path: rel,
|
|
3183
|
-
size: data.length,
|
|
3184
|
-
sha256,
|
|
3185
|
-
mode: st.mode & 511,
|
|
3186
|
-
updatedAt: st.mtime.toISOString(),
|
|
3187
|
-
changed: true
|
|
3188
|
-
};
|
|
3189
|
-
}
|
|
3190
|
-
async get(path) {
|
|
3191
|
-
return this.readEntry(normalizeCustodyPath(path));
|
|
3192
|
-
}
|
|
3193
|
-
async stat(path) {
|
|
3194
|
-
const found = await this.readEntry(normalizeCustodyPath(path));
|
|
3195
|
-
return found ? found.entry : null;
|
|
3196
|
-
}
|
|
3197
|
-
async list(prefix) {
|
|
3198
|
-
const rel = prefix === void 0 ? "" : normalizeCustodyPrefix(prefix);
|
|
3199
|
-
const entries = [];
|
|
3200
|
-
for (const found of await this.walk(this.root)) {
|
|
3201
|
-
if (rel.length > 0 && found !== rel && !found.startsWith(`${rel}/`)) continue;
|
|
3202
|
-
const e = await this.readEntry(found);
|
|
3203
|
-
if (e) entries.push(e.entry);
|
|
3204
|
-
}
|
|
3205
|
-
entries.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
3206
|
-
return entries;
|
|
3207
|
-
}
|
|
3208
|
-
async delete(path) {
|
|
3209
|
-
const rel = normalizeCustodyPath(path);
|
|
3210
|
-
const abs = join22(this.root, rel);
|
|
3211
|
-
try {
|
|
3212
|
-
await rm3(abs);
|
|
3213
|
-
return true;
|
|
3214
|
-
} catch (err2) {
|
|
3215
|
-
if (err2.code === "ENOENT") return false;
|
|
3216
|
-
throw err2;
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
async putStream(path, body, opts = {}) {
|
|
3220
|
-
const rel = normalizeCustodyPath(path);
|
|
3221
|
-
const abs = join22(this.root, rel);
|
|
3222
|
-
await mkdir3(dirname22(abs), { recursive: true, mode: DIR_MODE });
|
|
3223
|
-
const tmp = `${abs}.${randomBytes2(6).toString("hex")}.tmp`;
|
|
3224
|
-
const hash = createHash2("sha256");
|
|
3225
|
-
let size = 0;
|
|
3226
|
-
const meter = new Transform({
|
|
3227
|
-
transform(chunk, _enc, cb) {
|
|
3228
|
-
size += chunk.length;
|
|
3229
|
-
if (opts.maxBytes !== void 0 && size > opts.maxBytes) {
|
|
3230
|
-
cb(new CustodyTooLargeError(opts.maxBytes));
|
|
3231
|
-
return;
|
|
3232
|
-
}
|
|
3233
|
-
hash.update(chunk);
|
|
3234
|
-
cb(null, chunk);
|
|
3235
|
-
}
|
|
3236
|
-
});
|
|
3237
|
-
try {
|
|
3238
|
-
await pipeline(body, meter, createWriteStream(tmp, { mode: FILE_MODE }));
|
|
3239
|
-
} catch (err2) {
|
|
3240
|
-
await rm3(tmp, { force: true });
|
|
3241
|
-
throw err2;
|
|
3242
|
-
}
|
|
3243
|
-
const sha256 = hash.digest("hex");
|
|
3244
|
-
const existing = await this.readEntryMeta(rel);
|
|
3245
|
-
if (existing && existing.sha256 === sha256) {
|
|
3246
|
-
await rm3(tmp, { force: true });
|
|
3247
|
-
return { ...existing, changed: false };
|
|
3248
|
-
}
|
|
3249
|
-
try {
|
|
3250
|
-
await chmod(tmp, FILE_MODE);
|
|
3251
|
-
await rename3(tmp, abs);
|
|
3252
|
-
} catch (err2) {
|
|
3253
|
-
await rm3(tmp, { force: true });
|
|
3254
|
-
throw err2;
|
|
3255
|
-
}
|
|
3256
|
-
const st = await stat(abs);
|
|
3257
|
-
return {
|
|
3258
|
-
path: rel,
|
|
3259
|
-
size,
|
|
3260
|
-
sha256,
|
|
3261
|
-
mode: st.mode & 511,
|
|
3262
|
-
updatedAt: st.mtime.toISOString(),
|
|
3263
|
-
changed: true
|
|
3264
|
-
};
|
|
5511
|
+
status: row.status,
|
|
5512
|
+
answer: row.answer ?? null,
|
|
5513
|
+
cancelled: row.cancelled ?? null,
|
|
5514
|
+
result: row.result ?? null,
|
|
5515
|
+
createdAt: row.createdAt,
|
|
5516
|
+
expiresAt: row.expiresAt ?? null
|
|
5517
|
+
}).onConflictDoNothing({ target: sqlitePrompts.id });
|
|
3265
5518
|
}
|
|
3266
|
-
async
|
|
3267
|
-
const
|
|
3268
|
-
const
|
|
3269
|
-
|
|
3270
|
-
return { entry, data: createReadStream(join22(this.root, rel)) };
|
|
5519
|
+
async getPrompt(promptId) {
|
|
5520
|
+
const db = await this.db();
|
|
5521
|
+
const rows = await db.select().from(sqlitePrompts).where(eq(sqlitePrompts.id, promptId));
|
|
5522
|
+
return rows[0] ? rowToPrompt(rows[0]) : null;
|
|
3271
5523
|
}
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
*/
|
|
3277
|
-
async readEntryMeta(rel) {
|
|
3278
|
-
const abs = join22(this.root, rel);
|
|
3279
|
-
try {
|
|
3280
|
-
const st = await stat(abs);
|
|
3281
|
-
if (!st.isFile()) return null;
|
|
3282
|
-
const hash = createHash2("sha256");
|
|
3283
|
-
await pipeline(
|
|
3284
|
-
createReadStream(abs),
|
|
3285
|
-
new Transform({
|
|
3286
|
-
transform(chunk, _enc, cb) {
|
|
3287
|
-
hash.update(chunk);
|
|
3288
|
-
cb();
|
|
3289
|
-
}
|
|
3290
|
-
})
|
|
3291
|
-
);
|
|
3292
|
-
return {
|
|
3293
|
-
path: rel,
|
|
3294
|
-
size: st.size,
|
|
3295
|
-
sha256: hash.digest("hex"),
|
|
3296
|
-
mode: st.mode & 511,
|
|
3297
|
-
updatedAt: st.mtime.toISOString()
|
|
3298
|
-
};
|
|
3299
|
-
} catch (err2) {
|
|
3300
|
-
if (err2.code === "ENOENT") return null;
|
|
3301
|
-
throw err2;
|
|
3302
|
-
}
|
|
5524
|
+
async answerPrompt(promptId, answer, cancelled) {
|
|
5525
|
+
const db = await this.db();
|
|
5526
|
+
const rows = await db.update(sqlitePrompts).set({ status: "answered", answer, cancelled: cancelled ?? null }).where(and(eq(sqlitePrompts.id, promptId), eq(sqlitePrompts.status, "pending"))).returning({ id: sqlitePrompts.id });
|
|
5527
|
+
return rows.length > 0;
|
|
3303
5528
|
}
|
|
3304
|
-
async
|
|
3305
|
-
const
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
return {
|
|
3309
|
-
entry: {
|
|
3310
|
-
path: rel,
|
|
3311
|
-
size: data.length,
|
|
3312
|
-
sha256: custodyDigest(data),
|
|
3313
|
-
mode: st.mode & 511,
|
|
3314
|
-
updatedAt: st.mtime.toISOString()
|
|
3315
|
-
},
|
|
3316
|
-
data
|
|
3317
|
-
};
|
|
3318
|
-
} catch (err2) {
|
|
3319
|
-
const code = err2.code;
|
|
3320
|
-
if (code === "ENOENT" || code === "EISDIR") return null;
|
|
3321
|
-
throw err2;
|
|
3322
|
-
}
|
|
5529
|
+
async listPendingPrompts(boxId) {
|
|
5530
|
+
const db = await this.db();
|
|
5531
|
+
const rows = await db.select().from(sqlitePrompts).where(and(eq(sqlitePrompts.boxId, boxId), eq(sqlitePrompts.status, "pending"))).orderBy(asc(sqlitePrompts.createdAt));
|
|
5532
|
+
return rows.map(rowToPrompt);
|
|
3323
5533
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
try {
|
|
3328
|
-
dirents = await readdir2(dir, { withFileTypes: true });
|
|
3329
|
-
} catch (err2) {
|
|
3330
|
-
if (err2.code === "ENOENT") return [];
|
|
3331
|
-
throw err2;
|
|
3332
|
-
}
|
|
3333
|
-
const out = [];
|
|
3334
|
-
for (const d of dirents) {
|
|
3335
|
-
const abs = join22(dir, d.name);
|
|
3336
|
-
if (d.isDirectory()) {
|
|
3337
|
-
out.push(...await this.walk(abs));
|
|
3338
|
-
} else if (d.isFile() && !d.name.endsWith(".tmp")) {
|
|
3339
|
-
out.push(relative(this.root, abs).split(sep).join("/"));
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
return out;
|
|
5534
|
+
async setPromptResult(promptId, result) {
|
|
5535
|
+
const db = await this.db();
|
|
5536
|
+
await db.update(sqlitePrompts).set({ result }).where(eq(sqlitePrompts.id, promptId));
|
|
3343
5537
|
}
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
import { existsSync as existsSync3 } from "fs";
|
|
3358
|
-
import { tmpdir } from "os";
|
|
3359
|
-
import { createHash as createHash3, randomBytes as randomBytes3 } from "crypto";
|
|
3360
|
-
import { execFile } from "child_process";
|
|
3361
|
-
import { createReadStream as createReadStream2 } from "fs";
|
|
3362
|
-
import { mkdtemp, rm as rm4, stat as stat2 } from "fs/promises";
|
|
3363
|
-
import { hostname, tmpdir as tmpdir2 } from "os";
|
|
3364
|
-
import { basename, dirname as dirname3, join as join4 } from "path";
|
|
3365
|
-
import { request as httpRequest } from "http";
|
|
3366
|
-
import { request as httpsRequest } from "https";
|
|
3367
|
-
import { createHash as createHash22 } from "crypto";
|
|
3368
|
-
import { basename as basename2 } from "path";
|
|
3369
|
-
import { spawn as spawn22 } from "child_process";
|
|
3370
|
-
import { randomUUID as randomUUID4 } from "crypto";
|
|
3371
|
-
import { randomUUID as randomUUID22 } from "crypto";
|
|
3372
|
-
import { randomUUID as randomUUID32 } from "crypto";
|
|
3373
|
-
import { execFile as execFile2 } from "child_process";
|
|
3374
|
-
import { createWriteStream as createWriteStream2, existsSync as existsSync32 } from "fs";
|
|
3375
|
-
import { mkdtemp as mkdtemp3, rm as rm32 } from "fs/promises";
|
|
3376
|
-
import { tmpdir as tmpdir4 } from "os";
|
|
3377
|
-
import { basename as basename3, join as join32 } from "path";
|
|
3378
|
-
import { pipeline as pipeline2 } from "stream/promises";
|
|
3379
|
-
import { randomUUID as randomUUID42 } from "crypto";
|
|
3380
|
-
import { execFile as execFile3 } from "child_process";
|
|
3381
|
-
import { createReadStream as createReadStream22, createWriteStream as createWriteStream22, existsSync as existsSync4 } from "fs";
|
|
3382
|
-
import { mkdtemp as mkdtemp4, readdir as readdir3, rename as rename4, rm as rm42, stat as stat22 } from "fs/promises";
|
|
3383
|
-
import { tmpdir as tmpdir5 } from "os";
|
|
3384
|
-
import { dirname as dirname23, join as join42 } from "path";
|
|
3385
|
-
import { pipeline as pipeline22 } from "stream/promises";
|
|
3386
|
-
import { randomUUID as randomUUID5 } from "crypto";
|
|
3387
|
-
import { timingSafeEqual as timingSafeEqual5 } from "crypto";
|
|
3388
|
-
import { open, stat as stat3 } from "fs/promises";
|
|
3389
|
-
import { execa as execa2 } from "execa";
|
|
3390
|
-
import { spawn as spawn4 } from "child_process";
|
|
3391
|
-
import { readFile as readFile3 } from "fs/promises";
|
|
3392
|
-
import { readFile as readFile22 } from "fs/promises";
|
|
3393
|
-
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
3394
|
-
import { randomUUID as randomUUID6 } from "crypto";
|
|
3395
|
-
import { request as httpRequest2 } from "http";
|
|
3396
|
-
import { request as httpsRequest2 } from "https";
|
|
3397
|
-
import { setTimeout as delay2 } from "timers/promises";
|
|
3398
|
-
import { rm as rm5 } from "fs/promises";
|
|
3399
|
-
import { request as httpRequest3 } from "http";
|
|
3400
|
-
import { request as httpsRequest3 } from "https";
|
|
3401
|
-
var GH_BLOCKED = [
|
|
3402
|
-
{
|
|
3403
|
-
pattern: /^auth\s+(token|refresh)\b/i,
|
|
3404
|
-
why: "prints or rotates the host credential"
|
|
3405
|
-
},
|
|
3406
|
-
{
|
|
3407
|
-
pattern: /^auth\s+(login|logout|switch|setup-git)\b/i,
|
|
3408
|
-
why: "changes the host's GitHub auth state, which the host owns"
|
|
3409
|
-
},
|
|
3410
|
-
{
|
|
3411
|
-
pattern: /^config\s+set\b/i,
|
|
3412
|
-
why: "rewrites the host's gh configuration"
|
|
3413
|
-
},
|
|
3414
|
-
{
|
|
3415
|
-
// `gh alias set x '!sh -c ...'` defines a shell escape that later runs on
|
|
3416
|
-
// the host under the host's credentials.
|
|
3417
|
-
pattern: /^alias\s+(set|delete|import)\b/i,
|
|
3418
|
-
why: "defines host-side command aliases that later run with host credentials"
|
|
3419
|
-
},
|
|
3420
|
-
{
|
|
3421
|
-
pattern: /^extension\s+(install|remove|upgrade|exec)\b/i,
|
|
3422
|
-
why: "installs or runs third-party code on the host"
|
|
3423
|
-
},
|
|
3424
|
-
{
|
|
3425
|
-
pattern: /^(ssh-key|gpg-key)\s+(add|delete)\b/i,
|
|
3426
|
-
why: "changes the host account's keys"
|
|
5538
|
+
// --- box-create job queue ---
|
|
5539
|
+
async enqueueCreateJob(job) {
|
|
5540
|
+
const db = await this.db();
|
|
5541
|
+
await db.insert(sqliteCreateJobs).values({
|
|
5542
|
+
id: job.id,
|
|
5543
|
+
status: job.status,
|
|
5544
|
+
request: job.request,
|
|
5545
|
+
result: job.result ?? null,
|
|
5546
|
+
claimedBy: job.claimedBy ?? null,
|
|
5547
|
+
createdAt: job.createdAt,
|
|
5548
|
+
startedAt: job.startedAt ?? null,
|
|
5549
|
+
finishedAt: job.finishedAt ?? null
|
|
5550
|
+
}).onConflictDoNothing({ target: sqliteCreateJobs.id });
|
|
3427
5551
|
}
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
{ pattern: /^secret\s+(set|delete)\b/i, what: "repository secret" },
|
|
3433
|
-
{ pattern: /^variable\s+delete\b/i, what: "repository variable" },
|
|
3434
|
-
{ pattern: /^cache\s+delete\b/i, what: "Actions cache" },
|
|
3435
|
-
{ pattern: /^ruleset\b.*\b(delete|edit)\b/i, what: "repository ruleset" },
|
|
3436
|
-
{ pattern: /^org\s+\S*\b(delete|remove)\b/i, what: "organization" },
|
|
3437
|
-
{ pattern: /^gist\s+delete\b/i, what: "gist" },
|
|
3438
|
-
{ pattern: /^label\s+delete\b/i, what: "label" },
|
|
3439
|
-
{ pattern: /^project\s+(delete|item-delete|field-delete)\b/i, what: "project" },
|
|
3440
|
-
// `gh api -X DELETE` reaches all of the above through the raw API. gh
|
|
3441
|
-
// accepts `-X DELETE`, `-X=DELETE`, `-XDELETE` and `--method[= ]DELETE`,
|
|
3442
|
-
// so match every spelling — a missed one is a silent hole, not a typo.
|
|
3443
|
-
{ pattern: /(^|\s)(-X=?\s*|--method[=\s]+)(DELETE|PUT|PATCH)\b/i, what: "raw API write" },
|
|
3444
|
-
// `gh api graphql -f query='mutation { deleteRepository ... }'` is a POST,
|
|
3445
|
-
// so no method flag betrays it. GraphQL is a raw write channel with the same
|
|
3446
|
-
// reach as the REST verbs above; agents rarely need it, so confirming every
|
|
3447
|
-
// mutation is a cheap way to keep the hole shut.
|
|
3448
|
-
// Lookaheads rather than adjacency: the endpoint may be spelled `/graphql`,
|
|
3449
|
-
// and cobra accepts flags before it (`gh api --paginate graphql …`), so
|
|
3450
|
-
// requiring `api graphql` side by side left the hole open.
|
|
3451
|
-
{
|
|
3452
|
-
pattern: /^api\b(?=[\s\S]*\bgraphql\b)(?=[\s\S]*\bmutation\b)/i,
|
|
3453
|
-
what: "raw GraphQL mutation"
|
|
5552
|
+
async getCreateJob(id) {
|
|
5553
|
+
const db = await this.db();
|
|
5554
|
+
const rows = await db.select().from(sqliteCreateJobs).where(eq(sqliteCreateJobs.id, id));
|
|
5555
|
+
return rows[0] ? rowToJob(rows[0]) : null;
|
|
3454
5556
|
}
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
if (!arg.startsWith("-")) break;
|
|
3462
|
-
if (GH_GLOBAL_VALUE_FLAGS.has(arg)) i += 2;
|
|
3463
|
-
else i += 1;
|
|
5557
|
+
async listCreateJobs(opts) {
|
|
5558
|
+
const db = await this.db();
|
|
5559
|
+
const base = db.select().from(sqliteCreateJobs);
|
|
5560
|
+
const filtered = opts?.status?.length ? base.where(inArray(sqliteCreateJobs.status, opts.status)) : base;
|
|
5561
|
+
const rows = await filtered.orderBy(desc(sqliteCreateJobs.createdAt)).limit(opts?.limit ?? 100);
|
|
5562
|
+
return rows.map(rowToJob);
|
|
3464
5563
|
}
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
exitCode: 65,
|
|
3473
|
-
stdout: "",
|
|
3474
|
-
stderr: `gh ${joined}: refused \u2014 ${why}. The host runs gh with its own credentials, so the box never needs them.
|
|
3475
|
-
`
|
|
3476
|
-
};
|
|
3477
|
-
}
|
|
5564
|
+
async claimNextCreateJob(workerId) {
|
|
5565
|
+
const db = await this.db();
|
|
5566
|
+
const oldestQueued = db.select({ id: sqliteCreateJobs.id }).from(sqliteCreateJobs).where(eq(sqliteCreateJobs.status, "queued")).orderBy(asc(sqliteCreateJobs.createdAt)).limit(1);
|
|
5567
|
+
const rows = await db.update(sqliteCreateJobs).set({ status: "running", claimedBy: workerId, startedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(
|
|
5568
|
+
and(inArray(sqliteCreateJobs.id, oldestQueued), eq(sqliteCreateJobs.status, "queued"))
|
|
5569
|
+
).returning();
|
|
5570
|
+
return rows[0] ? rowToJob(rows[0]) : null;
|
|
3478
5571
|
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
5572
|
+
async completeCreateJob(id, status, result) {
|
|
5573
|
+
const db = await this.db();
|
|
5574
|
+
await db.update(sqliteCreateJobs).set({ status, result, finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(sqliteCreateJobs.id, id));
|
|
5575
|
+
}
|
|
5576
|
+
// --- retention (ISO strings compare lexicographically, matching the columns) ---
|
|
5577
|
+
async prunePrompts(beforeIso) {
|
|
5578
|
+
const db = await this.db();
|
|
5579
|
+
const rows = await db.delete(sqlitePrompts).where(
|
|
5580
|
+
or(
|
|
5581
|
+
and(eq(sqlitePrompts.status, "answered"), lt(sqlitePrompts.createdAt, beforeIso)),
|
|
5582
|
+
and(isNotNull(sqlitePrompts.expiresAt), lt(sqlitePrompts.expiresAt, beforeIso))
|
|
5583
|
+
)
|
|
5584
|
+
).returning({ id: sqlitePrompts.id });
|
|
5585
|
+
return rows.length;
|
|
3485
5586
|
}
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
}
|
|
5587
|
+
async pruneCreateJobs(beforeIso) {
|
|
5588
|
+
const db = await this.db();
|
|
5589
|
+
const rows = await db.delete(sqliteCreateJobs).where(
|
|
5590
|
+
and(
|
|
5591
|
+
inArray(sqliteCreateJobs.status, ["done", "failed"]),
|
|
5592
|
+
isNotNull(sqliteCreateJobs.finishedAt),
|
|
5593
|
+
lt(sqliteCreateJobs.finishedAt, beforeIso)
|
|
5594
|
+
)
|
|
5595
|
+
).returning({ id: sqliteCreateJobs.id });
|
|
5596
|
+
return rows.length;
|
|
3497
5597
|
}
|
|
3498
|
-
return null;
|
|
3499
|
-
}
|
|
3500
|
-
function injectPrCreateHead(op, branch, args) {
|
|
3501
|
-
if (op !== "create") return args;
|
|
3502
|
-
if (!branch || branch === "HEAD") return args;
|
|
3503
|
-
if (hasHeadArg(args)) return args;
|
|
3504
|
-
return ["--head", branch, ...args];
|
|
3505
|
-
}
|
|
3506
|
-
function hasHeadArg(args) {
|
|
3507
|
-
return args.some((a) => a === "--head" || a.startsWith("--head=") || a.startsWith("-H"));
|
|
3508
|
-
}
|
|
3509
|
-
function prCreateHasExplicitHead(op, args) {
|
|
3510
|
-
return op === "create" && hasHeadArg(args);
|
|
3511
|
-
}
|
|
3512
|
-
function prCreateNeedsHead(op, args) {
|
|
3513
|
-
return op === "create" && !hasHeadArg(args);
|
|
3514
|
-
}
|
|
3515
|
-
var PR_CREATE_NO_HEAD_REFUSAL = {
|
|
3516
|
-
exitCode: 65,
|
|
3517
|
-
stdout: "",
|
|
3518
|
-
stderr: "gh pr create: refusing to run without --head \u2014 could not resolve this box's branch, and falling back to the host repo's checked-out branch would open a PR for the wrong branch. Ensure the box branch is pushed, or pass --head <branch> explicitly.\n"
|
|
3519
5598
|
};
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
var sshHostCache = /* @__PURE__ */ new Map();
|
|
3525
|
-
async function resolveGhTarget(originUrl) {
|
|
3526
|
-
const derived = ghHostFromRemote(originUrl);
|
|
3527
|
-
if (!derived) return { host: null, error: await assertGhReady(null) };
|
|
3528
|
-
const expanded = derived.aliasable ? await expandSshHost(derived.host) : derived.host;
|
|
3529
|
-
if (expanded === "github.com") return { host: null, error: await assertGhReady(null) };
|
|
3530
|
-
const host = expanded ?? derived.host;
|
|
3531
|
-
const scoped = await assertGhReady(host);
|
|
3532
|
-
if (!scoped) return { host, error: null };
|
|
3533
|
-
if (scoped.exitCode !== 4) return { host: null, error: scoped };
|
|
3534
|
-
if (expanded === null) {
|
|
3535
|
-
const generic = await assertGhReady(null);
|
|
3536
|
-
return { host: null, error: generic ? scoped : null };
|
|
5599
|
+
function makeStore(spec) {
|
|
5600
|
+
if (!spec || spec === "memory") return new MemoryStore();
|
|
5601
|
+
if (spec.startsWith("postgres://") || spec.startsWith("postgresql://")) {
|
|
5602
|
+
return new PostgresStore({ connectionString: spec });
|
|
3537
5603
|
}
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
const cached = sshHostCache.get(host);
|
|
3543
|
-
if (cached && cached.expiresAt > now) return cached.host;
|
|
3544
|
-
let resolved = null;
|
|
3545
|
-
try {
|
|
3546
|
-
const target = await resolveSshConfigTarget(host);
|
|
3547
|
-
const value = target?.host.trim().toLowerCase() ?? "";
|
|
3548
|
-
resolved = value.length > 0 ? value : null;
|
|
3549
|
-
} catch {
|
|
3550
|
-
resolved = null;
|
|
5604
|
+
if (spec.startsWith("sqlite:")) {
|
|
5605
|
+
const path = spec.slice("sqlite:".length).replace(/^\/\//, "");
|
|
5606
|
+
if (!path) throw new Error(`store spec has no path: ${spec}`);
|
|
5607
|
+
return new SqliteStore({ path });
|
|
3551
5608
|
}
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
}
|
|
3555
|
-
async function assertGhReady(host) {
|
|
3556
|
-
const key = host ?? "";
|
|
3557
|
-
const now = Date.now();
|
|
3558
|
-
const cached = ghReadyCache.get(key);
|
|
3559
|
-
if (cached && cached.expiresAt > now) return cached.result;
|
|
3560
|
-
const result = await probeGh(host ?? null);
|
|
3561
|
-
ghReadyCache.set(key, { result, expiresAt: now + GH_READY_CACHE_TTL_MS });
|
|
3562
|
-
return result;
|
|
3563
|
-
}
|
|
3564
|
-
function _resetGhReadyCacheForTests() {
|
|
3565
|
-
ghReadyCache.clear();
|
|
3566
|
-
ghInstalledCache = void 0;
|
|
3567
|
-
sshHostCache.clear();
|
|
3568
|
-
}
|
|
3569
|
-
async function probeGh(host) {
|
|
3570
|
-
const installed = await probeGhInstalled();
|
|
3571
|
-
if (installed) return installed;
|
|
3572
|
-
if (firstNonEmptyEnv(ghTokenEnvNames(host))) return null;
|
|
3573
|
-
const auth = await runHostGh(
|
|
3574
|
-
host ? ["auth", "status", "--hostname", host] : ["auth", "status"],
|
|
3575
|
-
process.cwd(),
|
|
3576
|
-
{ timeoutMs: 15e3 }
|
|
3577
|
-
);
|
|
3578
|
-
if (auth.exitCode !== 0) {
|
|
3579
|
-
return {
|
|
3580
|
-
exitCode: 4,
|
|
3581
|
-
stdout: "",
|
|
3582
|
-
stderr: host ? `gh not authenticated on host for ${host} (run \`gh auth login --hostname ${host}\`)
|
|
3583
|
-
` : "gh not authenticated on host (run `gh auth login`)\n"
|
|
3584
|
-
};
|
|
5609
|
+
if (spec === ":memory:" || spec.startsWith("/") || spec.startsWith(".") || spec.endsWith(".db")) {
|
|
5610
|
+
return new SqliteStore({ path: spec });
|
|
3585
5611
|
}
|
|
3586
|
-
|
|
3587
|
-
}
|
|
3588
|
-
async function probeGhInstalled() {
|
|
3589
|
-
const now = Date.now();
|
|
3590
|
-
if (ghInstalledCache && ghInstalledCache.expiresAt > now) return ghInstalledCache.result;
|
|
3591
|
-
const result = await probeGhVersion();
|
|
3592
|
-
ghInstalledCache = { result, expiresAt: now + GH_READY_CACHE_TTL_MS };
|
|
3593
|
-
return result;
|
|
5612
|
+
throw new Error(`unknown store spec: ${spec}`);
|
|
3594
5613
|
}
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
};
|
|
5614
|
+
var DEFAULT_CUSTODY_DIR = join22(STATE_DIR, "hub", "custody");
|
|
5615
|
+
var DIR_MODE = 448;
|
|
5616
|
+
var FILE_MODE = 384;
|
|
5617
|
+
var FsCustodyStore = class {
|
|
5618
|
+
root;
|
|
5619
|
+
constructor(opts = {}) {
|
|
5620
|
+
this.root = opts.root ?? DEFAULT_CUSTODY_DIR;
|
|
3603
5621
|
}
|
|
3604
|
-
|
|
5622
|
+
async put(path, data) {
|
|
5623
|
+
const rel = normalizeCustodyPath(path);
|
|
5624
|
+
const abs = join22(this.root, rel);
|
|
5625
|
+
const sha256 = custodyDigest(data);
|
|
5626
|
+
const existing = await this.readEntry(rel);
|
|
5627
|
+
if (existing && existing.entry.sha256 === sha256) {
|
|
5628
|
+
return { ...existing.entry, changed: false };
|
|
5629
|
+
}
|
|
5630
|
+
await mkdir6(dirname22(abs), { recursive: true, mode: DIR_MODE });
|
|
5631
|
+
const tmp = `${abs}.${randomBytes4(6).toString("hex")}.tmp`;
|
|
5632
|
+
try {
|
|
5633
|
+
await writeFile7(tmp, data, { mode: FILE_MODE });
|
|
5634
|
+
await chmod(tmp, FILE_MODE);
|
|
5635
|
+
await rename7(tmp, abs);
|
|
5636
|
+
} catch (err2) {
|
|
5637
|
+
await rm5(tmp, { force: true });
|
|
5638
|
+
throw err2;
|
|
5639
|
+
}
|
|
5640
|
+
const st = await stat4(abs);
|
|
3605
5641
|
return {
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
5642
|
+
path: rel,
|
|
5643
|
+
size: data.length,
|
|
5644
|
+
sha256,
|
|
5645
|
+
mode: st.mode & 511,
|
|
5646
|
+
updatedAt: st.mtime.toISOString(),
|
|
5647
|
+
changed: true
|
|
3609
5648
|
};
|
|
3610
5649
|
}
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
function ghTokenEnvNames(host) {
|
|
3614
|
-
if (host === null) return ["GH_TOKEN", "GITHUB_TOKEN"];
|
|
3615
|
-
const enterprise = ["GH_ENTERPRISE_TOKEN", "GITHUB_ENTERPRISE_TOKEN"];
|
|
3616
|
-
return host.endsWith(".ghe.com") ? [...enterprise, "GH_TOKEN", "GITHUB_TOKEN"] : enterprise;
|
|
3617
|
-
}
|
|
3618
|
-
function firstNonEmptyEnv(names) {
|
|
3619
|
-
for (const name of names) {
|
|
3620
|
-
const value = process.env[name];
|
|
3621
|
-
if (typeof value === "string" && value.length > 0) return value;
|
|
5650
|
+
async get(path) {
|
|
5651
|
+
return this.readEntry(normalizeCustodyPath(path));
|
|
3622
5652
|
}
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
if (workspacePath.length > 0 && existsSync3(workspacePath)) {
|
|
3627
|
-
return { cwd: workspacePath, args };
|
|
5653
|
+
async stat(path) {
|
|
5654
|
+
const found = await this.readEntry(normalizeCustodyPath(path));
|
|
5655
|
+
return found ? found.entry : null;
|
|
3628
5656
|
}
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
5657
|
+
async list(prefix) {
|
|
5658
|
+
const rel = prefix === void 0 ? "" : normalizeCustodyPrefix(prefix);
|
|
5659
|
+
const entries = [];
|
|
5660
|
+
for (const found of await this.walk(this.root)) {
|
|
5661
|
+
if (rel.length > 0 && found !== rel && !found.startsWith(`${rel}/`)) continue;
|
|
5662
|
+
const e = await this.readEntry(found);
|
|
5663
|
+
if (e) entries.push(e.entry);
|
|
5664
|
+
}
|
|
5665
|
+
entries.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
5666
|
+
return entries;
|
|
3636
5667
|
}
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
});
|
|
3666
|
-
child.stderr?.on("data", (chunk) => {
|
|
3667
|
-
stderr += chunk.toString("utf8");
|
|
3668
|
-
});
|
|
3669
|
-
child.on("error", (err2) => {
|
|
3670
|
-
clearTimeout(timer);
|
|
3671
|
-
const code = err2.code;
|
|
3672
|
-
stderr += String(err2.message ?? err2);
|
|
3673
|
-
finish(code === "ENOENT" ? 127 : 1);
|
|
3674
|
-
});
|
|
3675
|
-
child.on("close", (code) => {
|
|
3676
|
-
clearTimeout(timer);
|
|
3677
|
-
finish(code ?? -1);
|
|
5668
|
+
async delete(path) {
|
|
5669
|
+
const rel = normalizeCustodyPath(path);
|
|
5670
|
+
const abs = join22(this.root, rel);
|
|
5671
|
+
try {
|
|
5672
|
+
await rm5(abs);
|
|
5673
|
+
return true;
|
|
5674
|
+
} catch (err2) {
|
|
5675
|
+
if (err2.code === "ENOENT") return false;
|
|
5676
|
+
throw err2;
|
|
5677
|
+
}
|
|
5678
|
+
}
|
|
5679
|
+
async putStream(path, body, opts = {}) {
|
|
5680
|
+
const rel = normalizeCustodyPath(path);
|
|
5681
|
+
const abs = join22(this.root, rel);
|
|
5682
|
+
await mkdir6(dirname22(abs), { recursive: true, mode: DIR_MODE });
|
|
5683
|
+
const tmp = `${abs}.${randomBytes4(6).toString("hex")}.tmp`;
|
|
5684
|
+
const hash = createHash2("sha256");
|
|
5685
|
+
let size = 0;
|
|
5686
|
+
const meter = new Transform({
|
|
5687
|
+
transform(chunk, _enc, cb) {
|
|
5688
|
+
size += chunk.length;
|
|
5689
|
+
if (opts.maxBytes !== void 0 && size > opts.maxBytes) {
|
|
5690
|
+
cb(new CustodyTooLargeError(opts.maxBytes));
|
|
5691
|
+
return;
|
|
5692
|
+
}
|
|
5693
|
+
hash.update(chunk);
|
|
5694
|
+
cb(null, chunk);
|
|
5695
|
+
}
|
|
3678
5696
|
});
|
|
3679
|
-
|
|
3680
|
-
}
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
5697
|
+
try {
|
|
5698
|
+
await pipeline(body, meter, createWriteStream(tmp, { mode: FILE_MODE }));
|
|
5699
|
+
} catch (err2) {
|
|
5700
|
+
await rm5(tmp, { force: true });
|
|
5701
|
+
throw err2;
|
|
5702
|
+
}
|
|
5703
|
+
const sha256 = hash.digest("hex");
|
|
5704
|
+
const existing = await this.readEntryMeta(rel);
|
|
5705
|
+
if (existing && existing.sha256 === sha256) {
|
|
5706
|
+
await rm5(tmp, { force: true });
|
|
5707
|
+
return { ...existing, changed: false };
|
|
5708
|
+
}
|
|
5709
|
+
try {
|
|
5710
|
+
await chmod(tmp, FILE_MODE);
|
|
5711
|
+
await rename7(tmp, abs);
|
|
5712
|
+
} catch (err2) {
|
|
5713
|
+
await rm5(tmp, { force: true });
|
|
5714
|
+
throw err2;
|
|
5715
|
+
}
|
|
5716
|
+
const st = await stat4(abs);
|
|
3684
5717
|
return {
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
5718
|
+
path: rel,
|
|
5719
|
+
size,
|
|
5720
|
+
sha256,
|
|
5721
|
+
mode: st.mode & 511,
|
|
5722
|
+
updatedAt: st.mtime.toISOString(),
|
|
5723
|
+
changed: true
|
|
3688
5724
|
};
|
|
3689
5725
|
}
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
`
|
|
3696
|
-
};
|
|
5726
|
+
async getStream(path) {
|
|
5727
|
+
const rel = normalizeCustodyPath(path);
|
|
5728
|
+
const entry = await this.readEntryMeta(rel);
|
|
5729
|
+
if (!entry) return null;
|
|
5730
|
+
return { entry, data: createReadStream(join22(this.root, rel)) };
|
|
3697
5731
|
}
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
5732
|
+
/**
|
|
5733
|
+
* Metadata without holding the value. Digest still comes from the bytes (no
|
|
5734
|
+
* sidecar to drift), but they are hashed in a streaming pass and discarded,
|
|
5735
|
+
* so a 100 MiB entry costs a buffer's worth of memory rather than 100 MiB.
|
|
5736
|
+
*/
|
|
5737
|
+
async readEntryMeta(rel) {
|
|
5738
|
+
const abs = join22(this.root, rel);
|
|
5739
|
+
try {
|
|
5740
|
+
const st = await stat4(abs);
|
|
5741
|
+
if (!st.isFile()) return null;
|
|
5742
|
+
const hash = createHash2("sha256");
|
|
5743
|
+
await pipeline(
|
|
5744
|
+
createReadStream(abs),
|
|
5745
|
+
new Transform({
|
|
5746
|
+
transform(chunk, _enc, cb) {
|
|
5747
|
+
hash.update(chunk);
|
|
5748
|
+
cb();
|
|
5749
|
+
}
|
|
5750
|
+
})
|
|
5751
|
+
);
|
|
5752
|
+
return {
|
|
5753
|
+
path: rel,
|
|
5754
|
+
size: st.size,
|
|
5755
|
+
sha256: hash.digest("hex"),
|
|
5756
|
+
mode: st.mode & 511,
|
|
5757
|
+
updatedAt: st.mtime.toISOString()
|
|
5758
|
+
};
|
|
5759
|
+
} catch (err2) {
|
|
5760
|
+
if (err2.code === "ENOENT") return null;
|
|
5761
|
+
throw err2;
|
|
5762
|
+
}
|
|
3705
5763
|
}
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
5764
|
+
async readEntry(rel) {
|
|
5765
|
+
const abs = join22(this.root, rel);
|
|
5766
|
+
try {
|
|
5767
|
+
const [data, st] = await Promise.all([readFile6(abs), stat4(abs)]);
|
|
5768
|
+
return {
|
|
5769
|
+
entry: {
|
|
5770
|
+
path: rel,
|
|
5771
|
+
size: data.length,
|
|
5772
|
+
sha256: custodyDigest(data),
|
|
5773
|
+
mode: st.mode & 511,
|
|
5774
|
+
updatedAt: st.mtime.toISOString()
|
|
5775
|
+
},
|
|
5776
|
+
data
|
|
5777
|
+
};
|
|
5778
|
+
} catch (err2) {
|
|
5779
|
+
const code = err2.code;
|
|
5780
|
+
if (code === "ENOENT" || code === "EISDIR") return null;
|
|
5781
|
+
throw err2;
|
|
5782
|
+
}
|
|
3714
5783
|
}
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
}
|
|
3735
|
-
}
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
}
|
|
5784
|
+
/** Custody-relative paths of every regular file under `dir` (tmp files skipped). */
|
|
5785
|
+
async walk(dir) {
|
|
5786
|
+
let dirents;
|
|
5787
|
+
try {
|
|
5788
|
+
dirents = await readdir4(dir, { withFileTypes: true });
|
|
5789
|
+
} catch (err2) {
|
|
5790
|
+
if (err2.code === "ENOENT") return [];
|
|
5791
|
+
throw err2;
|
|
5792
|
+
}
|
|
5793
|
+
const out = [];
|
|
5794
|
+
for (const d of dirents) {
|
|
5795
|
+
const abs = join22(dir, d.name);
|
|
5796
|
+
if (d.isDirectory()) {
|
|
5797
|
+
out.push(...await this.walk(abs));
|
|
5798
|
+
} else if (d.isFile() && !d.name.endsWith(".tmp")) {
|
|
5799
|
+
out.push(relative(this.root, abs).split(sep).join("/"));
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5802
|
+
return out;
|
|
5803
|
+
}
|
|
5804
|
+
};
|
|
5805
|
+
|
|
5806
|
+
// ../../packages/relay/dist/chunk-TPGEMVLM.js
|
|
5807
|
+
import { spawn as spawn22 } from "child_process";
|
|
5808
|
+
import { existsSync as existsSync4 } from "fs";
|
|
5809
|
+
import { createServer } from "http";
|
|
5810
|
+
import { execa as execa3 } from "execa";
|
|
5811
|
+
import { existsSync as existsSync5 } from "fs";
|
|
5812
|
+
import { mkdtemp as mkdtemp2, rm as rm22 } from "fs/promises";
|
|
5813
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
5814
|
+
import { join as join23 } from "path";
|
|
5815
|
+
import { pathToFileURL } from "url";
|
|
5816
|
+
import { createHash as createHash3, randomBytes as randomBytes5 } from "crypto";
|
|
5817
|
+
import { execFile } from "child_process";
|
|
5818
|
+
import { createReadStream as createReadStream2 } from "fs";
|
|
5819
|
+
import { mkdtemp, rm as rm6, stat as stat5 } from "fs/promises";
|
|
5820
|
+
import { hostname, tmpdir as tmpdir3 } from "os";
|
|
5821
|
+
import { basename as basename3, dirname as dirname4, join as join7 } from "path";
|
|
5822
|
+
import { request as httpRequest } from "http";
|
|
5823
|
+
import { request as httpsRequest } from "https";
|
|
5824
|
+
import { createHash as createHash22 } from "crypto";
|
|
5825
|
+
import { basename as basename22 } from "path";
|
|
5826
|
+
import { spawn as spawn3 } from "child_process";
|
|
5827
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
5828
|
+
import { randomUUID as randomUUID22 } from "crypto";
|
|
5829
|
+
import { randomUUID as randomUUID32 } from "crypto";
|
|
5830
|
+
import { execFile as execFile2 } from "child_process";
|
|
5831
|
+
import { createWriteStream as createWriteStream2, existsSync as existsSync22 } from "fs";
|
|
5832
|
+
import { mkdtemp as mkdtemp3, rm as rm32 } from "fs/promises";
|
|
5833
|
+
import { tmpdir as tmpdir32 } from "os";
|
|
5834
|
+
import { basename as basename32, join as join32 } from "path";
|
|
5835
|
+
import { pipeline as pipeline2 } from "stream/promises";
|
|
5836
|
+
import { randomUUID as randomUUID42 } from "crypto";
|
|
5837
|
+
import { execFile as execFile3 } from "child_process";
|
|
5838
|
+
import { createReadStream as createReadStream22, createWriteStream as createWriteStream22, existsSync as existsSync32 } from "fs";
|
|
5839
|
+
import { mkdtemp as mkdtemp4, readdir as readdir5, rename as rename8, rm as rm42, stat as stat22 } from "fs/promises";
|
|
5840
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
5841
|
+
import { dirname as dirname23, join as join42 } from "path";
|
|
5842
|
+
import { pipeline as pipeline22 } from "stream/promises";
|
|
5843
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
5844
|
+
import { timingSafeEqual as timingSafeEqual5 } from "crypto";
|
|
5845
|
+
import { open as open3, stat as stat32 } from "fs/promises";
|
|
5846
|
+
import { execa as execa22 } from "execa";
|
|
5847
|
+
import { spawn as spawn32 } from "child_process";
|
|
5848
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
5849
|
+
import { readFile as readFile22 } from "fs/promises";
|
|
5850
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
5851
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
5852
|
+
import { request as httpRequest2 } from "http";
|
|
5853
|
+
import { request as httpsRequest2 } from "https";
|
|
5854
|
+
import { setTimeout as delay2 } from "timers/promises";
|
|
5855
|
+
import { rm as rm52 } from "fs/promises";
|
|
5856
|
+
import { request as httpRequest3 } from "http";
|
|
5857
|
+
import { request as httpsRequest3 } from "https";
|
|
3745
5858
|
var DEFAULT_TTL_MS = 12e4;
|
|
3746
5859
|
function hashRpcParams(params) {
|
|
3747
5860
|
return createHash3("sha256").update(canonicalJson(params)).digest("hex");
|
|
@@ -3768,7 +5881,7 @@ var HostInitiatedTokens = class {
|
|
|
3768
5881
|
* params (no current call sites use this).
|
|
3769
5882
|
*/
|
|
3770
5883
|
mint(boxId, method, paramsHash, ttlMs = DEFAULT_TTL_MS) {
|
|
3771
|
-
const token =
|
|
5884
|
+
const token = randomBytes5(32).toString("hex");
|
|
3772
5885
|
this.store.set(token, { boxId, method, paramsHash, expiresAt: Date.now() + ttlMs });
|
|
3773
5886
|
return token;
|
|
3774
5887
|
}
|
|
@@ -3910,12 +6023,12 @@ async function captureCpCacheEntry(absPath, prefix, deps, requestPath = absPath)
|
|
|
3910
6023
|
const maxBytes = deps.maxBytes ?? DEFAULT_MAX_CACHE_BYTES;
|
|
3911
6024
|
let workDir;
|
|
3912
6025
|
try {
|
|
3913
|
-
const info = await
|
|
3914
|
-
const dir = await mkdtemp(
|
|
6026
|
+
const info = await stat5(absPath);
|
|
6027
|
+
const dir = await mkdtemp(join7(tmpdir3(), "agentbox-cp-cache-"));
|
|
3915
6028
|
workDir = dir;
|
|
3916
|
-
const tarPath =
|
|
3917
|
-
await run("tar", ["-cf", tarPath, "-C",
|
|
3918
|
-
const tarInfo = await
|
|
6029
|
+
const tarPath = join7(dir, "entry.tar");
|
|
6030
|
+
await run("tar", ["-cf", tarPath, "-C", dirname4(absPath), basename3(absPath)], TAR_TIMEOUT_MS);
|
|
6031
|
+
const tarInfo = await stat5(tarPath);
|
|
3919
6032
|
if (tarInfo.size > maxBytes) {
|
|
3920
6033
|
log(
|
|
3921
6034
|
`cp cache: skipping ${absPath} \u2014 ${String(tarInfo.size)} bytes exceeds the hub's ${String(maxBytes)}-byte limit`
|
|
@@ -3948,7 +6061,7 @@ async function captureCpCacheEntry(absPath, prefix, deps, requestPath = absPath)
|
|
|
3948
6061
|
);
|
|
3949
6062
|
return false;
|
|
3950
6063
|
} finally {
|
|
3951
|
-
if (workDir) await
|
|
6064
|
+
if (workDir) await rm6(workDir, { recursive: true, force: true }).catch(() => {
|
|
3952
6065
|
});
|
|
3953
6066
|
}
|
|
3954
6067
|
}
|
|
@@ -4028,7 +6141,7 @@ var HOST_EXEC_DEFAULT_TIMEOUT_MS = 12e4;
|
|
|
4028
6141
|
var READY_CACHE_TTL_MS = 6e4;
|
|
4029
6142
|
function runHostBinary(bin, argv, cwd, timeoutMs = HOST_EXEC_DEFAULT_TIMEOUT_MS) {
|
|
4030
6143
|
return new Promise((resolve) => {
|
|
4031
|
-
const child =
|
|
6144
|
+
const child = spawn3(bin, [...argv], {
|
|
4032
6145
|
cwd,
|
|
4033
6146
|
env: process.env,
|
|
4034
6147
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -4110,7 +6223,7 @@ var CREDENTIAL_ARGV_PATTERNS = [
|
|
|
4110
6223
|
function refuseCredentialArgv(name, args, bin) {
|
|
4111
6224
|
const joined = args.join(" ");
|
|
4112
6225
|
const candidates = [`${name} ${joined}`];
|
|
4113
|
-
const binName = bin ?
|
|
6226
|
+
const binName = bin ? basename22(bin) : void 0;
|
|
4114
6227
|
if (binName && binName !== name) candidates.push(`${binName} ${joined}`);
|
|
4115
6228
|
for (const re of CREDENTIAL_ARGV_PATTERNS) {
|
|
4116
6229
|
if (candidates.some((c) => re.test(c))) {
|
|
@@ -4387,7 +6500,7 @@ var browserOpenBudget = new BrowserOpenBudget();
|
|
|
4387
6500
|
var OPEN_LINK_TTL_MS = 9e4;
|
|
4388
6501
|
async function offerBrowserOpen(deps, url) {
|
|
4389
6502
|
const budget = deps.budget ?? browserOpenBudget;
|
|
4390
|
-
const
|
|
6503
|
+
const open22 = deps.openHost ?? openOnHost;
|
|
4391
6504
|
const decision = budget.decide(deps.boxId, url, deps.autoApproveSafe);
|
|
4392
6505
|
if (decision.action === "drop") return "dropped";
|
|
4393
6506
|
if (decision.action === "open") budget.record(deps.boxId, url);
|
|
@@ -4402,7 +6515,7 @@ async function offerBrowserOpen(deps, url) {
|
|
|
4402
6515
|
};
|
|
4403
6516
|
if (decision.action === "open" && !deps.controlPlane && deps.subscribers.count(deps.boxId) === 0) {
|
|
4404
6517
|
deps.prompts.noteAutoApprove(deps.boxId, promptEvent, decision.reason);
|
|
4405
|
-
|
|
6518
|
+
open22(url);
|
|
4406
6519
|
return "opened-locally";
|
|
4407
6520
|
}
|
|
4408
6521
|
if (decision.action !== "open" && deps.prompts.consumeAutoApprove(deps.boxId, promptEvent)) {
|
|
@@ -4411,7 +6524,7 @@ async function offerBrowserOpen(deps, url) {
|
|
|
4411
6524
|
deps.log?.(`browser.open: auto-approved but nothing here can open it (control box): ${url}`);
|
|
4412
6525
|
return "unclaimed";
|
|
4413
6526
|
}
|
|
4414
|
-
|
|
6527
|
+
open22(url);
|
|
4415
6528
|
return "opened-locally";
|
|
4416
6529
|
}
|
|
4417
6530
|
const ev = { id: randomUUID4(), ...promptEvent };
|
|
@@ -4436,7 +6549,7 @@ async function offerBrowserOpen(deps, url) {
|
|
|
4436
6549
|
deps.log?.(`browser.open: approved but no client opened it (control box): ${url}`);
|
|
4437
6550
|
return "unclaimed";
|
|
4438
6551
|
}
|
|
4439
|
-
|
|
6552
|
+
open22(url);
|
|
4440
6553
|
return "opened-after-answer";
|
|
4441
6554
|
}
|
|
4442
6555
|
var cloudBackendLoader;
|
|
@@ -4556,7 +6669,21 @@ async function executeCloudAction(action, deps) {
|
|
|
4556
6669
|
};
|
|
4557
6670
|
}
|
|
4558
6671
|
if (action.method === "git.push" || action.method === "git.fetch") {
|
|
4559
|
-
|
|
6672
|
+
const push = { hostInitiated: false };
|
|
6673
|
+
return runGitRpc(action, deps, push).then((result) => {
|
|
6674
|
+
if (action.method === "git.push" && result.exitCode === 0) {
|
|
6675
|
+
const hostOnly = Boolean(action.params?.hostOnly);
|
|
6676
|
+
void cloudTimelineContext(deps).then(
|
|
6677
|
+
(ctx) => ctx ? recordBoxGitPush(
|
|
6678
|
+
ctx,
|
|
6679
|
+
{ hostInitiated: push.hostInitiated, hostOnly },
|
|
6680
|
+
result,
|
|
6681
|
+
push.stat
|
|
6682
|
+
) : void 0
|
|
6683
|
+
);
|
|
6684
|
+
}
|
|
6685
|
+
return result;
|
|
6686
|
+
});
|
|
4560
6687
|
}
|
|
4561
6688
|
if (action.method === "cp.toHost" || action.method === "cp.fromHost") {
|
|
4562
6689
|
return runCpRpc(action, deps);
|
|
@@ -4571,7 +6698,16 @@ async function executeCloudAction(action, deps) {
|
|
|
4571
6698
|
return runBrowserOpenMirror(action, deps);
|
|
4572
6699
|
}
|
|
4573
6700
|
if (action.method === "gh.exec") {
|
|
4574
|
-
return runGhExecRpc(action, deps)
|
|
6701
|
+
return runGhExecRpc(action, deps).then((result) => {
|
|
6702
|
+
if (result.exitCode === 0) {
|
|
6703
|
+
const raw = action.params?.args;
|
|
6704
|
+
const args = Array.isArray(raw) ? raw.filter((a) => typeof a === "string") : [];
|
|
6705
|
+
void cloudTimelineContext(deps).then(
|
|
6706
|
+
(ctx) => ctx ? recordBoxGhResult(ctx, args, result) : void 0
|
|
6707
|
+
);
|
|
6708
|
+
}
|
|
6709
|
+
return result;
|
|
6710
|
+
});
|
|
4575
6711
|
}
|
|
4576
6712
|
if (action.method.startsWith("tool.")) {
|
|
4577
6713
|
return runToolRpc(action, deps);
|
|
@@ -4791,6 +6927,20 @@ function cloudHandleOf(lookup) {
|
|
|
4791
6927
|
...lookup.sandboxClass ? { sandboxClass: lookup.sandboxClass } : {}
|
|
4792
6928
|
};
|
|
4793
6929
|
}
|
|
6930
|
+
async function cloudTimelineContext(deps) {
|
|
6931
|
+
try {
|
|
6932
|
+
const lookup = await lookupCloudBox(deps.boxId);
|
|
6933
|
+
return {
|
|
6934
|
+
boxId: deps.boxId,
|
|
6935
|
+
...deps.boxName ? { boxName: deps.boxName } : {},
|
|
6936
|
+
hostPath: lookup.workspacePath,
|
|
6937
|
+
...lookup.sanctionedBranch ? { branch: lookup.sanctionedBranch } : {},
|
|
6938
|
+
...deps.originUrl ? { originUrl: deps.originUrl } : {}
|
|
6939
|
+
};
|
|
6940
|
+
} catch {
|
|
6941
|
+
return null;
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
4794
6944
|
async function lookupCloudBox(boxId) {
|
|
4795
6945
|
const state = await readState();
|
|
4796
6946
|
const hit = findBox(boxId, state);
|
|
@@ -4945,7 +7095,7 @@ async function runCpRpc(action, deps) {
|
|
|
4945
7095
|
}
|
|
4946
7096
|
}
|
|
4947
7097
|
const argv = [process.execPath, entry, ...cpArgs];
|
|
4948
|
-
const result = await
|
|
7098
|
+
const result = await execa3(argv[0], argv.slice(1), {
|
|
4949
7099
|
reject: false,
|
|
4950
7100
|
cwd: lookup.workspacePath
|
|
4951
7101
|
});
|
|
@@ -4993,7 +7143,7 @@ async function runCheckpointRpc(action, deps) {
|
|
|
4993
7143
|
if (params.merged === true) argv.push("--merged");
|
|
4994
7144
|
if (params.setDefault === true) argv.push("--set-default");
|
|
4995
7145
|
if (params.replace === true) argv.push("--replace");
|
|
4996
|
-
const result = await
|
|
7146
|
+
const result = await execa3(argv[0], argv.slice(1), { reject: false });
|
|
4997
7147
|
return {
|
|
4998
7148
|
exitCode: result.exitCode ?? 1,
|
|
4999
7149
|
stdout: result.stdout ?? "",
|
|
@@ -5070,7 +7220,7 @@ function httpsOriginForScratchPush(origin) {
|
|
|
5070
7220
|
}
|
|
5071
7221
|
}
|
|
5072
7222
|
async function resolveHostGitRepo(workspacePath, deps, remoteName) {
|
|
5073
|
-
if (workspacePath.length > 0 &&
|
|
7223
|
+
if (workspacePath.length > 0 && existsSync5(workspacePath)) {
|
|
5074
7224
|
return {
|
|
5075
7225
|
dir: workspacePath,
|
|
5076
7226
|
remote: remoteName,
|
|
@@ -5085,8 +7235,8 @@ async function resolveHostGitRepo(workspacePath, deps, remoteName) {
|
|
|
5085
7235
|
);
|
|
5086
7236
|
}
|
|
5087
7237
|
const origin = httpsOriginForScratchPush(rawOrigin);
|
|
5088
|
-
const dir = await mkdtemp2(join23(
|
|
5089
|
-
const init = await
|
|
7238
|
+
const dir = await mkdtemp2(join23(tmpdir2(), "agentbox-git-scratch-"));
|
|
7239
|
+
const init = await execa3("git", ["-C", dir, "init", "--quiet"], { reject: false });
|
|
5090
7240
|
if ((init.exitCode ?? 1) !== 0) {
|
|
5091
7241
|
await rm22(dir, { recursive: true, force: true });
|
|
5092
7242
|
throw new Error(`could not initialize a scratch git repo: ${init.stderr ?? ""}`);
|
|
@@ -5098,7 +7248,7 @@ async function resolveHostGitRepo(workspacePath, deps, remoteName) {
|
|
|
5098
7248
|
cleanup: () => rm22(dir, { recursive: true, force: true })
|
|
5099
7249
|
};
|
|
5100
7250
|
}
|
|
5101
|
-
async function runGitRpc(action, deps) {
|
|
7251
|
+
async function runGitRpc(action, deps, trace = { hostInitiated: false }) {
|
|
5102
7252
|
const params = action.params ?? {};
|
|
5103
7253
|
const lookup = await lookupCloudBox(deps.boxId);
|
|
5104
7254
|
const backend = await resolveCloudBackend(deps.backendName);
|
|
@@ -5107,13 +7257,13 @@ async function runGitRpc(action, deps) {
|
|
|
5107
7257
|
if (containerPath !== "/workspace") {
|
|
5108
7258
|
const probe = await backend.exec(
|
|
5109
7259
|
handle,
|
|
5110
|
-
`git -C ${
|
|
7260
|
+
`git -C ${shellQuote2(containerPath)} rev-parse --git-dir`
|
|
5111
7261
|
);
|
|
5112
7262
|
if (probe.exitCode !== 0) containerPath = "/workspace";
|
|
5113
7263
|
}
|
|
5114
7264
|
const branchProbe = await backend.exec(
|
|
5115
7265
|
handle,
|
|
5116
|
-
`git -C ${
|
|
7266
|
+
`git -C ${shellQuote2(containerPath)} rev-parse --abbrev-ref HEAD`
|
|
5117
7267
|
);
|
|
5118
7268
|
const branch = (branchProbe.stdout ?? "").trim();
|
|
5119
7269
|
if (branchProbe.exitCode !== 0 || !isResolvedBranch(branch)) {
|
|
@@ -5124,7 +7274,7 @@ async function runGitRpc(action, deps) {
|
|
|
5124
7274
|
};
|
|
5125
7275
|
}
|
|
5126
7276
|
if (params.hostOnly) {
|
|
5127
|
-
if (lookup.workspacePath.length === 0 || !
|
|
7277
|
+
if (lookup.workspacePath.length === 0 || !existsSync5(lookup.workspacePath)) {
|
|
5128
7278
|
return {
|
|
5129
7279
|
exitCode: 64,
|
|
5130
7280
|
stdout: "",
|
|
@@ -5133,13 +7283,13 @@ async function runGitRpc(action, deps) {
|
|
|
5133
7283
|
};
|
|
5134
7284
|
}
|
|
5135
7285
|
const dest = resolveLandDest(branch, params.as);
|
|
5136
|
-
const stageSave = await mkdtemp2(join23(
|
|
7286
|
+
const stageSave = await mkdtemp2(join23(tmpdir2(), "agentbox-git-save-"));
|
|
5137
7287
|
const hostBundleSave = join23(stageSave, "op.bundle");
|
|
5138
7288
|
const remoteBundleSave = "/tmp/agentbox-rpc-save.bundle";
|
|
5139
7289
|
try {
|
|
5140
7290
|
const make = await backend.exec(
|
|
5141
7291
|
handle,
|
|
5142
|
-
`git -C ${
|
|
7292
|
+
`git -C ${shellQuote2(containerPath)} bundle create ${shellQuote2(remoteBundleSave)} ${shellQuote2(branch)}`
|
|
5143
7293
|
);
|
|
5144
7294
|
if (make.exitCode !== 0) {
|
|
5145
7295
|
return {
|
|
@@ -5150,7 +7300,7 @@ async function runGitRpc(action, deps) {
|
|
|
5150
7300
|
}
|
|
5151
7301
|
await backend.downloadFile(handle, remoteBundleSave, hostBundleSave);
|
|
5152
7302
|
const refspec = landRefspec(branch, dest, params.force);
|
|
5153
|
-
const landed = await
|
|
7303
|
+
const landed = await execa3(
|
|
5154
7304
|
"git",
|
|
5155
7305
|
["-C", lookup.workspacePath, "fetch", hostBundleSave, refspec],
|
|
5156
7306
|
{ reject: false }
|
|
@@ -5170,7 +7320,7 @@ ${landed.stdout ?? ""}`,
|
|
|
5170
7320
|
};
|
|
5171
7321
|
} finally {
|
|
5172
7322
|
await rm22(stageSave, { recursive: true, force: true });
|
|
5173
|
-
await backend.exec(handle, `rm -f ${
|
|
7323
|
+
await backend.exec(handle, `rm -f ${shellQuote2(remoteBundleSave)}`).catch(() => {
|
|
5174
7324
|
});
|
|
5175
7325
|
}
|
|
5176
7326
|
}
|
|
@@ -5197,6 +7347,7 @@ ${landed.stdout ?? ""}`,
|
|
|
5197
7347
|
"git.push",
|
|
5198
7348
|
incomingHashGit
|
|
5199
7349
|
) ?? false);
|
|
7350
|
+
trace.hostInitiated = hostInitiatedOk;
|
|
5200
7351
|
if (action.method === "git.push" && !bypassPushGate && tokenClaimedGit && !hostInitiatedOk) {
|
|
5201
7352
|
return {
|
|
5202
7353
|
exitCode: 10,
|
|
@@ -5265,14 +7416,14 @@ ${landed.stdout ?? ""}`,
|
|
|
5265
7416
|
`git.${action.method === "git.push" ? "push" : "fetch"}: no host checkout for box ${deps.boxId}; using a scratch repo against ${repo.remote}`
|
|
5266
7417
|
);
|
|
5267
7418
|
}
|
|
5268
|
-
const stage = await mkdtemp2(join23(
|
|
7419
|
+
const stage = await mkdtemp2(join23(tmpdir2(), "agentbox-git-rpc-"));
|
|
5269
7420
|
const hostBundle = join23(stage, "op.bundle");
|
|
5270
7421
|
const remoteBundle = "/tmp/agentbox-rpc.bundle";
|
|
5271
7422
|
try {
|
|
5272
7423
|
if (action.method === "git.push") {
|
|
5273
7424
|
const make = await backend.exec(
|
|
5274
7425
|
handle,
|
|
5275
|
-
`git -C ${
|
|
7426
|
+
`git -C ${shellQuote2(containerPath)} bundle create ${shellQuote2(remoteBundle)} ${shellQuote2(branch)}`
|
|
5276
7427
|
);
|
|
5277
7428
|
if (make.exitCode !== 0) {
|
|
5278
7429
|
return {
|
|
@@ -5281,8 +7432,13 @@ ${landed.stdout ?? ""}`,
|
|
|
5281
7432
|
stderr: `bundle create failed: ${make.stderr || make.stdout}`
|
|
5282
7433
|
};
|
|
5283
7434
|
}
|
|
7435
|
+
if (!repo.scratch && !trace.hostInitiated) {
|
|
7436
|
+
const ref = pushedRef(branch, { remote: remoteName });
|
|
7437
|
+
const before = await readRefTip(repo.dir, ref);
|
|
7438
|
+
trace.stat = { repo: repo.dir, ref, branch, ...before ? { before } : {} };
|
|
7439
|
+
}
|
|
5284
7440
|
await backend.downloadFile(handle, remoteBundle, hostBundle);
|
|
5285
|
-
const fetch2 = await
|
|
7441
|
+
const fetch2 = await execa3(
|
|
5286
7442
|
"git",
|
|
5287
7443
|
["-C", repo.dir, "fetch", hostBundle, `${branch}:${branch}`],
|
|
5288
7444
|
{ reject: false }
|
|
@@ -5297,16 +7453,16 @@ ${landed.stdout ?? ""}`,
|
|
|
5297
7453
|
const remote = repo.remote;
|
|
5298
7454
|
const argv = ["-C", repo.dir, "push", remote, branch];
|
|
5299
7455
|
argv.push(...sanitizeGitArgs(params.args));
|
|
5300
|
-
const push = await
|
|
7456
|
+
const push = await execa3("git", argv, { reject: false });
|
|
5301
7457
|
let pushStderr = push.stderr ?? "";
|
|
5302
7458
|
if ((push.exitCode ?? 1) === 0 && !isScratchBranch(branch)) {
|
|
5303
7459
|
try {
|
|
5304
|
-
const sha = await
|
|
7460
|
+
const sha = await execa3("git", ["-C", repo.dir, "rev-parse", branch], { reject: false });
|
|
5305
7461
|
const shaText = (sha.stdout ?? "").trim();
|
|
5306
7462
|
if (sha.exitCode === 0 && shaText.length > 0) {
|
|
5307
7463
|
const updateRef = await backend.exec(
|
|
5308
7464
|
handle,
|
|
5309
|
-
`git -C ${
|
|
7465
|
+
`git -C ${shellQuote2(containerPath)} update-ref ${remoteTrackingRef(remoteName, branch)} ${shellQuote2(shaText)}`
|
|
5310
7466
|
);
|
|
5311
7467
|
if (updateRef.exitCode !== 0) {
|
|
5312
7468
|
pushStderr += `
|
|
@@ -5314,7 +7470,7 @@ relay: post-push in-box update-ref ${remoteTrackingRef(remoteName, branch)} fail
|
|
|
5314
7470
|
}
|
|
5315
7471
|
const setUpstream = await backend.exec(
|
|
5316
7472
|
handle,
|
|
5317
|
-
`git -C ${
|
|
7473
|
+
`git -C ${shellQuote2(containerPath)} branch --set-upstream-to=${upstreamRef(remoteName, branch)} ${shellQuote2(branch)}`
|
|
5318
7474
|
);
|
|
5319
7475
|
if (setUpstream.exitCode !== 0) {
|
|
5320
7476
|
pushStderr += `
|
|
@@ -5336,7 +7492,7 @@ relay: post-push in-box origin/upstream sync threw: ${err2 instanceof Error ? er
|
|
|
5336
7492
|
};
|
|
5337
7493
|
}
|
|
5338
7494
|
const fetchArgs = repo.scratch ? ["-C", repo.dir, "fetch", repo.remote, "+refs/heads/*:refs/remotes/origin/*", "--tags"] : ["-C", repo.dir, "fetch", repo.remote];
|
|
5339
|
-
const hostFetch = await
|
|
7495
|
+
const hostFetch = await execa3("git", fetchArgs, { reject: false });
|
|
5340
7496
|
if (hostFetch.exitCode !== 0) {
|
|
5341
7497
|
return {
|
|
5342
7498
|
exitCode: hostFetch.exitCode ?? 1,
|
|
@@ -5344,7 +7500,7 @@ relay: post-push in-box origin/upstream sync threw: ${err2 instanceof Error ? er
|
|
|
5344
7500
|
stderr: `host git fetch failed: ${hostFetch.stderr ?? ""}`
|
|
5345
7501
|
};
|
|
5346
7502
|
}
|
|
5347
|
-
const bundle = await
|
|
7503
|
+
const bundle = await execa3("git", ["-C", repo.dir, "bundle", "create", hostBundle, `--all`], {
|
|
5348
7504
|
reject: false
|
|
5349
7505
|
});
|
|
5350
7506
|
if (bundle.exitCode !== 0) {
|
|
@@ -5357,7 +7513,7 @@ relay: post-push in-box origin/upstream sync threw: ${err2 instanceof Error ? er
|
|
|
5357
7513
|
await backend.uploadFile(handle, hostBundle, remoteBundle);
|
|
5358
7514
|
const sandboxFetch = await backend.exec(
|
|
5359
7515
|
handle,
|
|
5360
|
-
`git -C ${
|
|
7516
|
+
`git -C ${shellQuote2(containerPath)} fetch ${shellQuote2(remoteBundle)} '+refs/heads/*:refs/remotes/origin/*' --tags`
|
|
5361
7517
|
);
|
|
5362
7518
|
return {
|
|
5363
7519
|
exitCode: sandboxFetch.exitCode,
|
|
@@ -5368,11 +7524,11 @@ relay: post-push in-box origin/upstream sync threw: ${err2 instanceof Error ? er
|
|
|
5368
7524
|
await rm22(stage, { recursive: true, force: true });
|
|
5369
7525
|
await repo.cleanup().catch(() => {
|
|
5370
7526
|
});
|
|
5371
|
-
await backend.exec(handle, `rm -f ${
|
|
7527
|
+
await backend.exec(handle, `rm -f ${shellQuote2(remoteBundle)}`).catch(() => {
|
|
5372
7528
|
});
|
|
5373
7529
|
}
|
|
5374
7530
|
}
|
|
5375
|
-
function
|
|
7531
|
+
function shellQuote2(arg) {
|
|
5376
7532
|
if (arg.length === 0) return "''";
|
|
5377
7533
|
if (/^[A-Za-z0-9_@%+=:,./-]+$/.test(arg)) return arg;
|
|
5378
7534
|
return "'" + arg.replace(/'/g, "'\\''") + "'";
|
|
@@ -5792,7 +7948,7 @@ async function serveCpFromCache(params, resolved, deps) {
|
|
|
5792
7948
|
}
|
|
5793
7949
|
let workDir;
|
|
5794
7950
|
try {
|
|
5795
|
-
const dir = await mkdtemp3(join32(
|
|
7951
|
+
const dir = await mkdtemp3(join32(tmpdir32(), "agentbox-cp-serve-"));
|
|
5796
7952
|
workDir = dir;
|
|
5797
7953
|
const names = [];
|
|
5798
7954
|
for (const entry of lookup.entries) {
|
|
@@ -5804,10 +7960,10 @@ async function serveCpFromCache(params, resolved, deps) {
|
|
|
5804
7960
|
await pipeline2(found.data, createWriteStream2(tarPath));
|
|
5805
7961
|
await run2("tar", ["-xf", tarPath, "-C", dir], UNTAR_TIMEOUT_MS);
|
|
5806
7962
|
await rm32(tarPath, { force: true });
|
|
5807
|
-
names.push(
|
|
7963
|
+
names.push(basename32(entry.sourcePath));
|
|
5808
7964
|
}
|
|
5809
7965
|
const staged = names.map((n) => join32(dir, n));
|
|
5810
|
-
const absent = staged.filter((p) => !
|
|
7966
|
+
const absent = staged.filter((p) => !existsSync22(p));
|
|
5811
7967
|
if (absent.length > 0) {
|
|
5812
7968
|
return {
|
|
5813
7969
|
exitCode: 1,
|
|
@@ -5906,7 +8062,7 @@ async function parkCpOutbox(sources, dest, deps) {
|
|
|
5906
8062
|
if (!deps.custody || !deps.cliEntry) return null;
|
|
5907
8063
|
let workDir;
|
|
5908
8064
|
try {
|
|
5909
|
-
const dir = await mkdtemp4(join42(
|
|
8065
|
+
const dir = await mkdtemp4(join42(tmpdir4(), "agentbox-cp-outbox-"));
|
|
5910
8066
|
workDir = dir;
|
|
5911
8067
|
const stage = join42(dir, "payload");
|
|
5912
8068
|
await run3("mkdir", ["-p", stage], TAR_TIMEOUT_MS2);
|
|
@@ -5917,7 +8073,7 @@ async function parkCpOutbox(sources, dest, deps) {
|
|
|
5917
8073
|
PULL_TIMEOUT_MS
|
|
5918
8074
|
);
|
|
5919
8075
|
}
|
|
5920
|
-
const names = await
|
|
8076
|
+
const names = await readdir5(stage);
|
|
5921
8077
|
if (names.length === 0) return null;
|
|
5922
8078
|
const tarPath = join42(dir, "outbox.tar");
|
|
5923
8079
|
await run3("tar", ["-cf", tarPath, "-C", stage, ...names], TAR_TIMEOUT_MS2);
|
|
@@ -5959,7 +8115,7 @@ It will land them at ${dest} \u2014 behind the usual approval \u2014 the next ti
|
|
|
5959
8115
|
}
|
|
5960
8116
|
}
|
|
5961
8117
|
async function landCpOutboxTar(tarFile, destAbs, opts) {
|
|
5962
|
-
const asDirectory = opts.destEndsWithSlash ||
|
|
8118
|
+
const asDirectory = opts.destEndsWithSlash || existsSync32(destAbs) && (await stat22(destAbs)).isDirectory();
|
|
5963
8119
|
if (asDirectory) {
|
|
5964
8120
|
await run3("mkdir", ["-p", destAbs], TAR_TIMEOUT_MS2);
|
|
5965
8121
|
await run3("tar", ["-xf", tarFile, "-C", destAbs], TAR_TIMEOUT_MS2);
|
|
@@ -5969,21 +8125,21 @@ async function landCpOutboxTar(tarFile, destAbs, opts) {
|
|
|
5969
8125
|
const staging = await mkdtemp4(join42(dirname23(destAbs), ".agentbox-cp-"));
|
|
5970
8126
|
try {
|
|
5971
8127
|
await run3("tar", ["-xf", tarFile, "-C", staging], TAR_TIMEOUT_MS2);
|
|
5972
|
-
const members = await
|
|
8128
|
+
const members = await readdir5(staging);
|
|
5973
8129
|
if (members.length === 1) {
|
|
5974
|
-
if (
|
|
8130
|
+
if (existsSync32(destAbs) && (await stat22(destAbs)).isDirectory()) {
|
|
5975
8131
|
await rm42(destAbs, { recursive: true, force: true });
|
|
5976
8132
|
}
|
|
5977
|
-
await
|
|
8133
|
+
await rename8(join42(staging, members[0]), destAbs);
|
|
5978
8134
|
return;
|
|
5979
8135
|
}
|
|
5980
8136
|
await run3("mkdir", ["-p", destAbs], TAR_TIMEOUT_MS2);
|
|
5981
8137
|
for (const m of members) {
|
|
5982
8138
|
const target = join42(destAbs, m);
|
|
5983
|
-
if (
|
|
8139
|
+
if (existsSync32(target) && (await stat22(target)).isDirectory()) {
|
|
5984
8140
|
await rm42(target, { recursive: true, force: true });
|
|
5985
8141
|
}
|
|
5986
|
-
await
|
|
8142
|
+
await rename8(join42(staging, m), target);
|
|
5987
8143
|
}
|
|
5988
8144
|
} finally {
|
|
5989
8145
|
await rm42(staging, { recursive: true, force: true }).catch(() => {
|
|
@@ -5991,7 +8147,7 @@ async function landCpOutboxTar(tarFile, destAbs, opts) {
|
|
|
5991
8147
|
}
|
|
5992
8148
|
}
|
|
5993
8149
|
async function stageOutboxTar(data) {
|
|
5994
|
-
const dir = await mkdtemp4(join42(
|
|
8150
|
+
const dir = await mkdtemp4(join42(tmpdir4(), "agentbox-cp-land-"));
|
|
5995
8151
|
const tarPath = join42(dir, "payload.tar");
|
|
5996
8152
|
await pipeline22(data, createWriteStream22(tarPath));
|
|
5997
8153
|
return { dir, tarPath };
|
|
@@ -6099,7 +8255,7 @@ async function readCreateJobLog(id, offset) {
|
|
|
6099
8255
|
const path = queueLogPath(id);
|
|
6100
8256
|
let size;
|
|
6101
8257
|
try {
|
|
6102
|
-
size = (await
|
|
8258
|
+
size = (await stat32(path)).size;
|
|
6103
8259
|
} catch {
|
|
6104
8260
|
return { lines: [], offset: from };
|
|
6105
8261
|
}
|
|
@@ -6107,7 +8263,7 @@ async function readCreateJobLog(id, offset) {
|
|
|
6107
8263
|
if (size <= start) return { lines: [], offset: start };
|
|
6108
8264
|
const len = Math.min(size - start, MAX_BYTES_PER_READ);
|
|
6109
8265
|
const buf = Buffer.alloc(len);
|
|
6110
|
-
const fh = await
|
|
8266
|
+
const fh = await open3(path, "r");
|
|
6111
8267
|
try {
|
|
6112
8268
|
await fh.read(buf, 0, len, start);
|
|
6113
8269
|
} finally {
|
|
@@ -6221,7 +8377,7 @@ async function defaultRunPropagate(agent, sourceBoxId) {
|
|
|
6221
8377
|
if (!entry) {
|
|
6222
8378
|
throw new Error("AGENTBOX_CLI_ENTRY not set; cannot run credential propagate host-side");
|
|
6223
8379
|
}
|
|
6224
|
-
const result = await
|
|
8380
|
+
const result = await execa22(
|
|
6225
8381
|
process.execPath,
|
|
6226
8382
|
[entry, "credentials", "propagate", "--agent", agent, "--source-box", sourceBoxId],
|
|
6227
8383
|
{ reject: false, timeout: 3e5 }
|
|
@@ -6753,6 +8909,7 @@ data: {"ts":"${(/* @__PURE__ */ new Date()).toISOString()}"}
|
|
|
6753
8909
|
send(res, result2.exitCode === 0 ? 200 : 500, result2);
|
|
6754
8910
|
return;
|
|
6755
8911
|
}
|
|
8912
|
+
let pushHostInitiated = false;
|
|
6756
8913
|
if (body.method === "git.push") {
|
|
6757
8914
|
const hostOnlyParams = body.params;
|
|
6758
8915
|
if (hostOnlyParams?.hostOnly) {
|
|
@@ -6781,6 +8938,7 @@ data: {"ts":"${(/* @__PURE__ */ new Date()).toISOString()}"}
|
|
|
6781
8938
|
const tokenClaimed = typeof params?.hostInitiated === "string";
|
|
6782
8939
|
const incomingHash = hashRpcParams(params);
|
|
6783
8940
|
const hostInitiatedOk = !bypassPushGate && tokenClaimed && hostInitiatedTokens.consume(params?.hostInitiated, reg.boxId, "git.push", incomingHash);
|
|
8941
|
+
pushHostInitiated = hostInitiatedOk;
|
|
6784
8942
|
if (!bypassPushGate && tokenClaimed && !hostInitiatedOk) {
|
|
6785
8943
|
send(res, 500, {
|
|
6786
8944
|
exitCode: 10,
|
|
@@ -6811,11 +8969,29 @@ data: {"ts":"${(/* @__PURE__ */ new Date()).toISOString()}"}
|
|
|
6811
8969
|
}
|
|
6812
8970
|
}
|
|
6813
8971
|
}
|
|
6814
|
-
const
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
8972
|
+
const pushParams = body.params;
|
|
8973
|
+
const pushTree = body.method === "git.push" ? resolveWorktree(reg, pushParams?.path ?? "/workspace") : void 0;
|
|
8974
|
+
const pushBranch = pushTree ? pushTree.sanctionedBranch ?? pushTree.branch : void 0;
|
|
8975
|
+
const pushStat = pushTree && pushBranch && !pushHostInitiated ? {
|
|
8976
|
+
repo: pushTree.hostMainRepo,
|
|
8977
|
+
ref: pushedRef(pushBranch, { remote: resolveRemote(pushParams?.remote) }),
|
|
8978
|
+
branch: pushBranch
|
|
8979
|
+
} : void 0;
|
|
8980
|
+
const pushBefore = pushStat ? await readRefTip(pushStat.repo, pushStat.ref) : void 0;
|
|
8981
|
+
const result = await handleGitRpc(reg, body.method, pushParams);
|
|
8982
|
+
if (body.method === "git.push" && result.exitCode === 0 && pushTree) {
|
|
8983
|
+
void recordBoxGitPush(
|
|
8984
|
+
{
|
|
8985
|
+
boxId: reg.boxId,
|
|
8986
|
+
boxName: reg.name,
|
|
8987
|
+
hostPath: pushTree.hostMainRepo,
|
|
8988
|
+
...pushBranch ? { branch: pushBranch } : {}
|
|
8989
|
+
},
|
|
8990
|
+
{ hostInitiated: pushHostInitiated, hostOnly: Boolean(pushParams?.hostOnly) },
|
|
8991
|
+
result,
|
|
8992
|
+
pushStat ? { ...pushStat, ...pushBefore ? { before: pushBefore } : {} } : void 0
|
|
8993
|
+
);
|
|
8994
|
+
}
|
|
6819
8995
|
const status = result.exitCode === 0 ? 200 : 500;
|
|
6820
8996
|
send(res, status, result);
|
|
6821
8997
|
return;
|
|
@@ -6976,13 +9152,28 @@ data: {"ts":"${(/* @__PURE__ */ new Date()).toISOString()}"}
|
|
|
6976
9152
|
return;
|
|
6977
9153
|
}
|
|
6978
9154
|
if (body.method === "gh.exec") {
|
|
9155
|
+
const ghParams = body.params;
|
|
6979
9156
|
const result = await handleGhExecRpc(
|
|
6980
9157
|
reg,
|
|
6981
|
-
|
|
9158
|
+
ghParams,
|
|
6982
9159
|
prompts,
|
|
6983
9160
|
subscribers,
|
|
6984
9161
|
hostInitiatedTokens
|
|
6985
9162
|
);
|
|
9163
|
+
const ghTree = result.exitCode === 0 ? resolveWorktree(reg, ghParams?.path ?? "/workspace") : void 0;
|
|
9164
|
+
if (ghTree) {
|
|
9165
|
+
void recordBoxGhResult(
|
|
9166
|
+
{
|
|
9167
|
+
boxId: reg.boxId,
|
|
9168
|
+
boxName: reg.name,
|
|
9169
|
+
hostPath: ghTree.hostMainRepo,
|
|
9170
|
+
branch: ghTree.sanctionedBranch ?? ghTree.branch,
|
|
9171
|
+
...reg.originUrl ? { originUrl: reg.originUrl } : {}
|
|
9172
|
+
},
|
|
9173
|
+
Array.isArray(ghParams?.args) ? ghParams.args.filter((a) => typeof a === "string") : [],
|
|
9174
|
+
result
|
|
9175
|
+
);
|
|
9176
|
+
}
|
|
6986
9177
|
const status = result.exitCode === 0 ? 200 : 500;
|
|
6987
9178
|
send(res, status, result);
|
|
6988
9179
|
return;
|
|
@@ -7798,7 +9989,7 @@ async function parkOutboundCp(args) {
|
|
|
7798
9989
|
async function boxWorkspaceExistsHere(boxId) {
|
|
7799
9990
|
try {
|
|
7800
9991
|
const path = await boxWorkspacePath(boxId);
|
|
7801
|
-
return typeof path === "string" && path.length > 0 &&
|
|
9992
|
+
return typeof path === "string" && path.length > 0 && existsSync4(path);
|
|
7802
9993
|
} catch {
|
|
7803
9994
|
return false;
|
|
7804
9995
|
}
|
|
@@ -7933,7 +10124,7 @@ function runHostCommand(argv, timeoutMs = GIT_RPC_TIMEOUT_MS, cwd) {
|
|
|
7933
10124
|
resolve({ exitCode: 64, stdout: "", stderr: "empty command" });
|
|
7934
10125
|
return;
|
|
7935
10126
|
}
|
|
7936
|
-
const child =
|
|
10127
|
+
const child = spawn22(cmd, rest, {
|
|
7937
10128
|
env: process.env,
|
|
7938
10129
|
stdio: ["ignore", "pipe", "pipe"],
|
|
7939
10130
|
// Default to the relay daemon's CWD when unset (legacy behaviour); callers
|
|
@@ -8003,7 +10194,7 @@ async function loadAutopauseConfig() {
|
|
|
8003
10194
|
const d = BUILT_IN_DEFAULTS.autopause;
|
|
8004
10195
|
let global = {};
|
|
8005
10196
|
try {
|
|
8006
|
-
global = parseUserConfig(await
|
|
10197
|
+
global = parseUserConfig(await readFile7(GLOBAL_CONFIG_FILE, "utf8"), GLOBAL_CONFIG_FILE);
|
|
8007
10198
|
} catch {
|
|
8008
10199
|
}
|
|
8009
10200
|
const a = global.autopause ?? {};
|
|
@@ -8142,7 +10333,7 @@ var INSPECT_TIMEOUT_MS = 15e3;
|
|
|
8142
10333
|
var PAUSE_TIMEOUT_MS = 3e4;
|
|
8143
10334
|
function runDocker(args, timeoutMs) {
|
|
8144
10335
|
return new Promise((resolve) => {
|
|
8145
|
-
const child =
|
|
10336
|
+
const child = spawn32("docker", args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
8146
10337
|
let stdout = "";
|
|
8147
10338
|
let stderr = "";
|
|
8148
10339
|
let settled = false;
|
|
@@ -9042,7 +11233,7 @@ async function drainCpOutbox(deps) {
|
|
|
9042
11233
|
`host-reach: could not land the parked copy from ${owner.name} (left on the hub): ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
9043
11234
|
);
|
|
9044
11235
|
} finally {
|
|
9045
|
-
if (stagedDir) await
|
|
11236
|
+
if (stagedDir) await rm52(stagedDir, { recursive: true, force: true }).catch(() => {
|
|
9046
11237
|
});
|
|
9047
11238
|
}
|
|
9048
11239
|
}
|
|
@@ -9374,6 +11565,147 @@ export {
|
|
|
9374
11565
|
loadGitHubAppConfig,
|
|
9375
11566
|
appJwt,
|
|
9376
11567
|
GitHubAppLeaser,
|
|
11568
|
+
GH_BLOCKED,
|
|
11569
|
+
GH_DESTRUCTIVE,
|
|
11570
|
+
refuseBlockedGhCall,
|
|
11571
|
+
ghDestructiveTarget,
|
|
11572
|
+
refuseGhApiInput,
|
|
11573
|
+
injectPrCreateHead,
|
|
11574
|
+
prCreateHasExplicitHead,
|
|
11575
|
+
prCreateNeedsHead,
|
|
11576
|
+
PR_CREATE_NO_HEAD_REFUSAL,
|
|
11577
|
+
resolveGhTarget,
|
|
11578
|
+
assertGhReady,
|
|
11579
|
+
_resetGhReadyCacheForTests,
|
|
11580
|
+
ghRunContext,
|
|
11581
|
+
runHostGh,
|
|
11582
|
+
checkoutGuards,
|
|
11583
|
+
refuseCheckoutByDefault,
|
|
11584
|
+
WORKSPACES_DIR,
|
|
11585
|
+
WORK_TASK_STATUSES,
|
|
11586
|
+
WORKSPACE_LOCK,
|
|
11587
|
+
workspaceDir,
|
|
11588
|
+
workspaceFile,
|
|
11589
|
+
tasksFile,
|
|
11590
|
+
timelineFile,
|
|
11591
|
+
managersFile,
|
|
11592
|
+
managerExitFile,
|
|
11593
|
+
legacyManagerFiles,
|
|
11594
|
+
resolveWorkspaceDir,
|
|
11595
|
+
canonicalWorkspaceRoot,
|
|
11596
|
+
scanWorkspaceProjects,
|
|
11597
|
+
readWorkspace,
|
|
11598
|
+
listWorkspaces,
|
|
11599
|
+
writeWorkspace,
|
|
11600
|
+
updateWorkspace,
|
|
11601
|
+
addWorkspace,
|
|
11602
|
+
rescanWorkspace,
|
|
11603
|
+
renameWorkspace,
|
|
11604
|
+
removeWorkspace,
|
|
11605
|
+
toWorkspaceView,
|
|
11606
|
+
findWorkspaceContaining,
|
|
11607
|
+
UNTITLED_SESSION,
|
|
11608
|
+
RESUMABLE_MANAGER_AGENTS,
|
|
11609
|
+
isResumableManagerAgent,
|
|
11610
|
+
MANAGER_ID_RE,
|
|
11611
|
+
newManagerId,
|
|
11612
|
+
managerSessionName,
|
|
11613
|
+
MANAGER_SESSION_RE,
|
|
11614
|
+
managerAttachCommand,
|
|
11615
|
+
buildManagerArgv,
|
|
11616
|
+
shellJoin,
|
|
11617
|
+
buildManagerShellScript,
|
|
11618
|
+
loginShell,
|
|
11619
|
+
tmuxAvailable,
|
|
11620
|
+
tmuxSessionExists,
|
|
11621
|
+
usesLegacySession,
|
|
11622
|
+
updateManagers,
|
|
11623
|
+
readManagers,
|
|
11624
|
+
findManager,
|
|
11625
|
+
findManagerBySession,
|
|
11626
|
+
managerIdForTarget,
|
|
11627
|
+
patchManager,
|
|
11628
|
+
removeManagerRecord,
|
|
11629
|
+
MANAGER_SEEN_WINDOW_MS,
|
|
11630
|
+
isPidAlive,
|
|
11631
|
+
processStartTime,
|
|
11632
|
+
managerStatus,
|
|
11633
|
+
readManagerExit,
|
|
11634
|
+
managerResumeBlock,
|
|
11635
|
+
isManagerResumable,
|
|
11636
|
+
toManagerView,
|
|
11637
|
+
upsertDetectedManager,
|
|
11638
|
+
attachBoxToManager,
|
|
11639
|
+
reconcileManagers,
|
|
11640
|
+
readReconciledManagers,
|
|
11641
|
+
ManagerConflictError,
|
|
11642
|
+
managerStatusFormat,
|
|
11643
|
+
managerSessionOptionsArgv,
|
|
11644
|
+
startManagerSession,
|
|
11645
|
+
listTmuxSessions,
|
|
11646
|
+
parseBackgroundSessions,
|
|
11647
|
+
isLiveBackgroundSession,
|
|
11648
|
+
createBackgroundSessionLookup,
|
|
11649
|
+
liveBackgroundSession,
|
|
11650
|
+
backgroundFor,
|
|
11651
|
+
terminalSessionFor,
|
|
11652
|
+
attachBackgroundSession,
|
|
11653
|
+
detachBackgroundSession,
|
|
11654
|
+
resumeManagerSession,
|
|
11655
|
+
TMUX_PANE_RE,
|
|
11656
|
+
sendKeysLiteralArgv,
|
|
11657
|
+
sendKeysToManager,
|
|
11658
|
+
stopManagerSession,
|
|
11659
|
+
sessionTurn,
|
|
11660
|
+
sessionTitle,
|
|
11661
|
+
listResumableHostSessions,
|
|
11662
|
+
PUSH_STAT_TIMEOUT_MS,
|
|
11663
|
+
parseShortstat,
|
|
11664
|
+
pushedRef,
|
|
11665
|
+
readRefTip,
|
|
11666
|
+
readCurrentBranch,
|
|
11667
|
+
pushLineStat,
|
|
11668
|
+
nextTaskId,
|
|
11669
|
+
readTasks,
|
|
11670
|
+
writeTasks,
|
|
11671
|
+
updateTasks,
|
|
11672
|
+
sortTasksByOrder,
|
|
11673
|
+
filterTasks,
|
|
11674
|
+
validateDependsOn,
|
|
11675
|
+
addTask,
|
|
11676
|
+
patchTask,
|
|
11677
|
+
setTaskDone,
|
|
11678
|
+
removeTask,
|
|
11679
|
+
assignTasks,
|
|
11680
|
+
unassignTasks,
|
|
11681
|
+
reorderTasks,
|
|
11682
|
+
reconcileTasks,
|
|
11683
|
+
taskSummaryForBox,
|
|
11684
|
+
readReconciledTasks,
|
|
11685
|
+
GH_PR_JSON_FIELDS,
|
|
11686
|
+
prEventKey,
|
|
11687
|
+
parsePrUrl,
|
|
11688
|
+
checksOf,
|
|
11689
|
+
isPrReady,
|
|
11690
|
+
timelinePrOf,
|
|
11691
|
+
prTimelineEvents,
|
|
11692
|
+
TIMELINE_MAX_LINES,
|
|
11693
|
+
TIMELINE_KEEP_LINES,
|
|
11694
|
+
TIMELINE_RETENTION_MS,
|
|
11695
|
+
newTimelineEventId,
|
|
11696
|
+
stampFields,
|
|
11697
|
+
appendTimelineEvent,
|
|
11698
|
+
recordTimelineEvent,
|
|
11699
|
+
readTimeline,
|
|
11700
|
+
hasTimelineKey,
|
|
11701
|
+
workspaceForPath,
|
|
11702
|
+
recordTimelineForPath,
|
|
11703
|
+
recordBoxGitPush,
|
|
11704
|
+
prMergeTarget,
|
|
11705
|
+
prMergeRepo,
|
|
11706
|
+
prViewArgs,
|
|
11707
|
+
recordBoxGhResult,
|
|
11708
|
+
recordCreateJobTimeline,
|
|
9377
11709
|
QUEUE_DIR,
|
|
9378
11710
|
PREPARE_MAX_CONCURRENT_PER_PROVIDER,
|
|
9379
11711
|
loadQueueConfig,
|
|
@@ -9414,22 +11746,6 @@ export {
|
|
|
9414
11746
|
makeStore,
|
|
9415
11747
|
DEFAULT_CUSTODY_DIR,
|
|
9416
11748
|
FsCustodyStore,
|
|
9417
|
-
GH_BLOCKED,
|
|
9418
|
-
GH_DESTRUCTIVE,
|
|
9419
|
-
refuseBlockedGhCall,
|
|
9420
|
-
ghDestructiveTarget,
|
|
9421
|
-
refuseGhApiInput,
|
|
9422
|
-
injectPrCreateHead,
|
|
9423
|
-
prCreateHasExplicitHead,
|
|
9424
|
-
prCreateNeedsHead,
|
|
9425
|
-
PR_CREATE_NO_HEAD_REFUSAL,
|
|
9426
|
-
resolveGhTarget,
|
|
9427
|
-
assertGhReady,
|
|
9428
|
-
_resetGhReadyCacheForTests,
|
|
9429
|
-
ghRunContext,
|
|
9430
|
-
runHostGh,
|
|
9431
|
-
checkoutGuards,
|
|
9432
|
-
refuseCheckoutByDefault,
|
|
9433
11749
|
hashRpcParams,
|
|
9434
11750
|
HostInitiatedTokens,
|
|
9435
11751
|
cpCachePrefix,
|
|
@@ -9482,4 +11798,4 @@ export {
|
|
|
9482
11798
|
startRelayDaemon,
|
|
9483
11799
|
RemoteStore
|
|
9484
11800
|
};
|
|
9485
|
-
//# sourceMappingURL=chunk-
|
|
11801
|
+
//# sourceMappingURL=chunk-66GAYIJZ.js.map
|