@madarco/agentbox 0.28.1 → 0.29.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 +124 -0
- package/dist/_cloud-attach-HKRHYCY7.js +30 -0
- package/dist/{chunk-JNC7MCWJ.js → chunk-3INUZQTR.js} +10 -10
- package/dist/chunk-3INUZQTR.js.map +1 -0
- package/dist/{chunk-4PR3KJ5X.js → chunk-6PIGTR4D.js} +20 -20
- package/dist/{chunk-NHVGKFVY.js → chunk-7LNXTPEE.js} +340 -22
- package/dist/chunk-7LNXTPEE.js.map +1 -0
- package/dist/{chunk-WB6S4W7O.js → chunk-7Q6BG5AN.js} +2413 -1012
- package/dist/chunk-7Q6BG5AN.js.map +1 -0
- package/dist/{chunk-BUMKBUXS.js → chunk-7QU6XENE.js} +3 -3
- package/dist/chunk-BWE2I5QG.js +17 -0
- package/dist/chunk-BWE2I5QG.js.map +1 -0
- package/dist/{chunk-7ABO7OIF.js → chunk-CO2I3CQI.js} +4 -4
- package/dist/{chunk-OUF3YTQO.js → chunk-DBXCFLAR.js} +14 -17
- package/dist/chunk-DBXCFLAR.js.map +1 -0
- package/dist/{chunk-74VIUGY6.js → chunk-DYETLPUT.js} +6 -9
- package/dist/chunk-DYETLPUT.js.map +1 -0
- package/dist/{chunk-HYXCH4GA.js → chunk-EFVTQ7YB.js} +7 -7
- package/dist/{chunk-46NNZMZT.js → chunk-EPFXLXCW.js} +372 -72
- package/dist/chunk-EPFXLXCW.js.map +1 -0
- package/dist/chunk-GWKGSXDC.js +71 -0
- package/dist/chunk-GWKGSXDC.js.map +1 -0
- package/dist/{chunk-CKD3PRON.js → chunk-GWYD7YBK.js} +12 -9
- package/dist/{chunk-CKD3PRON.js.map → chunk-GWYD7YBK.js.map} +1 -1
- package/dist/{chunk-NHTRTST5.js → chunk-HNWZO2XU.js} +38 -15
- package/dist/chunk-HNWZO2XU.js.map +1 -0
- package/dist/{chunk-EVT2SNF2.js → chunk-HO2ACZES.js} +3 -3
- package/dist/{chunk-V5NWSLWD.js → chunk-HP4L45LW.js} +14 -14
- package/dist/{chunk-B4DAH2F2.js → chunk-LHOKRCNF.js} +3 -3
- package/dist/{chunk-G3H2L3O2.js → chunk-MNDKP4VS.js} +23 -3
- package/dist/chunk-MNDKP4VS.js.map +1 -0
- package/dist/{chunk-JDSYMTMS.js → chunk-NAT2H7J4.js} +110 -66
- package/dist/chunk-NAT2H7J4.js.map +1 -0
- package/dist/{chunk-KFLGXE3R.js → chunk-NGERWFSA.js} +133 -22
- package/dist/chunk-NGERWFSA.js.map +1 -0
- package/dist/{chunk-GFOWBXV7.js → chunk-OKLEPEWZ.js} +460 -253
- package/dist/chunk-OKLEPEWZ.js.map +1 -0
- package/dist/{chunk-YI4GHC2E.js → chunk-QU5BI2HC.js} +12 -15
- package/dist/chunk-QU5BI2HC.js.map +1 -0
- package/dist/{chunk-BWM56FKY.js → chunk-RQURMAPA.js} +11 -11
- package/dist/{chunk-FPMRFMVK.js → chunk-RZCLRWNY.js} +9 -9
- package/dist/{chunk-JQLOGVZK.js → chunk-THUST2QK.js} +85 -21
- package/dist/chunk-THUST2QK.js.map +1 -0
- package/dist/{chunk-OXKW4GWD.js → chunk-UPVP6YGJ.js} +4 -70
- package/dist/chunk-UPVP6YGJ.js.map +1 -0
- package/dist/{chunk-7RSE7ESY.js → chunk-VVNXQ4XS.js} +27 -18
- package/dist/chunk-VVNXQ4XS.js.map +1 -0
- package/dist/{chunk-FGQFVUMH.js → chunk-VY54AX4T.js} +3 -3
- package/dist/{chunk-OUWVN2F2.js → chunk-WGNI24H2.js} +16 -13
- package/dist/chunk-WGNI24H2.js.map +1 -0
- package/dist/{chunk-PSA6GADQ.js → chunk-WHFCJBMO.js} +14 -1
- package/dist/chunk-WHFCJBMO.js.map +1 -0
- package/dist/{chunk-KJ5TCYNI.js → chunk-WHJYOO5H.js} +7 -6
- package/dist/chunk-WHJYOO5H.js.map +1 -0
- package/dist/cloud-backends.js +5 -5
- package/dist/{cloud-poller-SUNA6ZQC-7M5LJHHE.js → cloud-poller-QJRZXB4W-LJ2BRB3L.js} +2 -2
- package/dist/{control-plane-5R7PYRQ6.js → control-plane-UKKYXHIQ.js} +19 -18
- package/dist/cp-hub-upload-BM2OLTOS.js +81 -0
- package/dist/cp-hub-upload-BM2OLTOS.js.map +1 -0
- package/dist/{custody-client-PNCC2HBJ.js → custody-client-NPXJ46TB.js} +5 -4
- package/dist/{deploy-hetzner-SSGSXAKA.js → deploy-hetzner-Y3ILCDRF.js} +10 -10
- package/dist/{dist-RN6JOAG4.js → dist-5OGQ3CJQ.js} +81 -45
- package/dist/{dist-5OR4QTQW.js → dist-7B3VCLZI.js} +9 -9
- package/dist/{dist-EPFS5PRI.js → dist-A5ZEIVAW.js} +10 -10
- package/dist/{dist-6PYXFREL.js → dist-DOEGENNW.js} +61 -16
- package/dist/dist-DOEGENNW.js.map +1 -0
- package/dist/{dist-XQLKK7H3.js → dist-EOGD7KD6.js} +54 -28
- package/dist/dist-EOGD7KD6.js.map +1 -0
- package/dist/{dist-XATN4ZIR.js → dist-FBM2WS5S.js} +22 -4
- package/dist/{dist-POILUDVJ.js → dist-MUTFY7FA.js} +9 -9
- package/dist/{dist-ZNQZHTUN.js → dist-SMDXLPZO.js} +35 -6
- package/dist/{dist-M4O5MU5K.js → dist-VTLQKZ2E.js} +8 -8
- package/dist/{dist-SN2TCRZ5.js → dist-ZJIJHCZB.js} +9 -9
- package/dist/{dist-K5M4HKG7.js → dist-ZNYS7CVF.js} +21 -9
- package/dist/host-reach-drainer-ZJU2STQQ.js +9 -0
- package/dist/hub-Q4VOF4WN.js +37 -0
- package/dist/{hub-adopt-I44VGSBL.js → hub-adopt-OA336ZXZ.js} +8 -8
- package/dist/{hub-api-client-WJPBXZAZ.js → hub-api-client-5U6WOTZ3.js} +2 -2
- package/dist/{hub-docker-target-REEEWUG2.js → hub-docker-target-JKFCABK4.js} +16 -16
- package/dist/index.js +1321 -882
- package/dist/index.js.map +1 -1
- package/dist/prepare-GFWWKWGF.js +41 -0
- package/dist/prepared-custody-KU4PDVBT.js +36 -0
- package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js → prepared-state-LNQ7DYSU-AR5RMXAO.js} +4 -3
- package/dist/{publish-credentials-BPHUO5VL.js → publish-credentials-3SQXX45P.js} +11 -11
- package/dist/registry-AFKV3EO2.js +18 -0
- package/dist/relay-QH6OEY2V.js +20 -0
- package/dist/relay-QH6OEY2V.js.map +1 -0
- package/dist/{remote-docker-share-RX5ARK45.js → remote-docker-share-RMS6IB5X.js} +11 -11
- package/dist/remote-docker-share-RMS6IB5X.js.map +1 -0
- package/dist/tool-grant-push-T6DRBY3W.js +90 -0
- package/dist/tool-grant-push-T6DRBY3W.js.map +1 -0
- package/package.json +1 -2
- package/runtime/_shared/agentbox-tool-shim +21 -0
- package/runtime/_shared/ctl.cjs +6757 -5299
- package/runtime/_shared/gh-shim +103 -228
- package/runtime/digitalocean/agentbox-tool-shim +21 -0
- package/runtime/digitalocean/ctl.cjs +6757 -5299
- package/runtime/digitalocean/gh-shim +103 -228
- package/runtime/digitalocean/scripts/install-box.sh +9 -15
- package/runtime/docker/Dockerfile.box +8 -18
- package/runtime/docker/packages/ctl/dist/bin.cjs +6757 -5299
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-tool-shim +21 -0
- package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +103 -228
- package/runtime/e2b/agentbox-tool-shim +21 -0
- package/runtime/e2b/ctl.cjs +6757 -5299
- package/runtime/e2b/gh-shim +103 -228
- package/runtime/e2b/scripts/build-template.sh +5 -9
- package/runtime/hetzner/agentbox-tool-shim +21 -0
- package/runtime/hetzner/ctl.cjs +6757 -5299
- package/runtime/hetzner/gh-shim +103 -228
- package/runtime/hetzner/scripts/install-box.sh +9 -15
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +2 -0
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/routes-manifest.json +16 -0
- package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js +5 -5
- package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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]/branches/route.js +2 -2
- 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]/git/[op]/route.js +2 -2
- 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 +2 -2
- 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 +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 +2 -2
- 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 +2 -2
- 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]/vnc/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route.js +8 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js +2 -2
- 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 +2 -2
- 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 +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/[...path]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/blob/[...path]/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/blob/[...path]/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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/open-targets/route.js +2 -2
- 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]/branches/route.js +2 -2
- 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]/route.js +2 -2
- 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 +2 -2
- 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/route.js +2 -2
- 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 +2 -2
- 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)/approvals/page.js +1 -1
- 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)/boxes/[id]/page.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/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route.js +8 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/custody/page.js +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)/page.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)/projects/[id]/page.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)/settings/page.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 +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/[...path]/route.js +4 -4
- 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.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-paths-manifest.json +2 -0
- package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_boxes_[id]_vnc_route_actions_1cy1392.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_vnc_route_actions_10y_e83.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/{[externals]__1nj4awx._.js → [externals]__02a249v._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__00f9v4p._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__01nppdu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__02f8rwr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__068_052._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__06ma5m4._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07kp2fu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1yi-2wa._.js → [root-of-the-server]__08u01ud._.js} +3 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__098bkh3._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1hxo1tv._.js → [root-of-the-server]__09hbkgm._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__09tmbom._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0_3m9sf._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0aotdzg._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0bn6-pu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0cpt9f9._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +15 -15
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0dom248._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0f0bb7o._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0gb04bp._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0glplq7._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0xrdbh9._.js → [root-of-the-server]__0gxfyol._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0hsb2ak._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0joqm8t._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0jp-895._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1leda2s._.js → [root-of-the-server]__0jpqg_t._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__17bhgkz._.js → [root-of-the-server]__0lgnu00._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0lsv9-6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0pzgufc._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0qfv7z6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0qlr61y._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0s8srqi._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0urn9j5._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vb8mk2._.js +4 -0
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__17w5eaa._.js → [root-of-the-server]__0x27ifo._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0y7rvy1._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0zsgjre._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-bqa8a._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11uspjg._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0zvr6ul._.js → [root-of-the-server]__15tgdh6._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1ek7nxv._.js → [root-of-the-server]__16bz_kz._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1w7jw4q._.js → [root-of-the-server]__18tehjj._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1ds8g0e._.js → [root-of-the-server]__1_hzv4s._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0cgpsh8._.js → [root-of-the-server]__1b5f5h4._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__10-aihp._.js → [root-of-the-server]__1dv80yf._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1eanlxn._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__16lcb2d._.js → [root-of-the-server]__1fc-nvn._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4iahl._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0f-c-eh._.js → [root-of-the-server]__1j0vnh3._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1lgrtx6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1unqgd7._.js → [root-of-the-server]__1lz7931._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1oclxlx._.js → [root-of-the-server]__1n3u6-5._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qky5cd._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1r2quye._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1rb_nc5._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0cv16py._.js → [root-of-the-server]__1spr8ss._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1t_juqb._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0t8kwy3._.js → [root-of-the-server]__1tct9rj._.js} +3 -3
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0gfa1jg._.js → [root-of-the-server]__1tjtt06._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__09cigc7._.js → [root-of-the-server]__1whjno0._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1wn4-iv._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1x6zxrf._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0tyixgg._.js → [root-of-the-server]__1xfxc6i._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1m1_gm_._.js → [root-of-the-server]__1xqcvi4._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__207d30i._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_07icdxf._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0907rw0._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0adm87k._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0g01mkg._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0l_klgd._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0lfm81x._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0tbg83f._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0tms_au._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0zhli27._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_10yfoq5._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_12uhpbp._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_17a9v8y._.js +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/_1c7x9ee._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_1n-c443._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_1y80vfg._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_214_q-1._.js +1 -1
- 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/{packages_relay_dist_0eg7ay1._.js → packages_relay_dist_0p8dnf4._.js} +4 -4
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/{[root-of-the-server]__1plrs94._.js → [root-of-the-server]__0-c5j6l._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0r2xlss._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_19vy9ni._.js +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_[id]_page_tsx_1-j_972._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_settings_page_tsx_0hv6n82._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/{packages_relay_dist_1z9j3g0._.js → packages_relay_dist_0sap-2l._.js} +4 -4
- package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +3 -1
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/middleware.js +1 -1
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/{328ny-3zs_h7m.js → 0jefm3re1-2jv.js} +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/{30h8mz040b5-l.js → 3u4odx1_-dy6b.js} +1 -1
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/boxes/[id]/vnc/route.ts +45 -0
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/openapi.ts +45 -1
- package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/validate.ts +14 -3
- package/runtime/hub/apps/hub/app/(dashboard)/boxes/[id]/vnc/route.ts +58 -0
- package/runtime/hub/apps/hub/app/(dashboard)/boxes/components/access.tsx +26 -9
- package/runtime/hub/apps/hub/app/(dashboard)/settings/components/provider-actions.tsx +34 -26
- package/runtime/hub/apps/hub/{auth-JMVHQKWY.js → auth-V7KPRWPS.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-5IFRWOK4.js → auth-config-B3Y3BT2I.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-VKOCY6SX.js → chunk-3AD3MYNV.js} +49 -14
- package/runtime/hub/apps/hub/{chunk-KTVETF3F.js → chunk-3ZDBZYOY.js} +11 -8
- package/runtime/hub/apps/hub/{chunk-LPYK2354.js → chunk-5ABFGGPT.js} +339 -21
- package/runtime/hub/apps/hub/{chunk-UMPTTQBE.js → chunk-GBYD2ODL.js} +458 -251
- package/runtime/hub/apps/hub/{chunk-5TM7XXLT.js → chunk-H5SUXDZA.js} +2833 -1277
- package/runtime/hub/apps/hub/{chunk-QU3FFGJY.js → chunk-UQ5XNPOF.js} +11 -14
- package/runtime/hub/apps/hub/{chunk-3LAHFDJF.js → chunk-VWQNSZGI.js} +22 -2
- package/runtime/hub/apps/hub/{chunk-EZUK53CC.js → chunk-WHGY7HOC.js} +85 -21
- package/runtime/hub/apps/hub/{chunk-D33EV4YZ.js → chunk-ZP4RYI4U.js} +1 -1
- package/runtime/hub/apps/hub/{cloud-poller-SUNA6ZQC-VSKVMYHL.js → cloud-poller-QJRZXB4W-G7ECKNKQ.js} +1 -1
- package/runtime/hub/apps/hub/{dist-ELZHBQEM.js → dist-37EKQ6RZ.js} +11 -11
- package/runtime/hub/apps/hub/{dist-D265LCAN.js → dist-CGH7PEMZ.js} +21 -3
- package/runtime/hub/apps/hub/{dist-SYWTB6RD.js → dist-CMVSARW5.js} +15 -18
- package/runtime/hub/apps/hub/{dist-5HTJSOHS.js → dist-EGXZRZH2.js} +19 -7
- package/runtime/hub/apps/hub/{dist-YK5FFPXZ.js → dist-EOGGFZZS.js} +62 -20
- package/runtime/hub/apps/hub/{dist-E2FTSTCY.js → dist-LJBHOO3K.js} +34 -5
- package/runtime/hub/apps/hub/{dist-N3E5YAYY.js → dist-R77W6WJ5.js} +53 -26
- package/runtime/hub/apps/hub/{dist-JVEDVVVG.js → dist-TH2JZYZY.js} +7 -7
- package/runtime/hub/apps/hub/{dist-2YP57GMB.js → dist-XPRGHQH2.js} +13 -13
- package/runtime/hub/apps/hub/{dist-NKCXH5DW.js → dist-Z2Y5F7AF.js} +6 -6
- package/runtime/hub/apps/hub/docker-compose.yml +1 -0
- package/runtime/hub/apps/hub/{hub-token-MDOBY7MZ.js → hub-token-DDJ5Z6RS.js} +2 -2
- package/runtime/hub/apps/hub/{hub-worker-UFFLF37F.js → hub-worker-DXVMUQWF.js} +16 -16
- package/runtime/hub/apps/hub/lib/boxes/backend-types.ts +11 -0
- package/runtime/hub/apps/hub/lib/boxes/types.ts +43 -0
- package/runtime/hub/apps/hub/lib/boxes/vnc-link.ts +51 -0
- package/runtime/hub/apps/hub/lib/hub-backend.ts +127 -54
- package/runtime/hub/apps/hub/lib/hub-worker.ts +4 -4
- package/runtime/hub/apps/hub/lib/provider-importers.ts +66 -1
- package/runtime/hub/apps/hub/{prepared-state-PV3GUBHO-PPRQDYFR.js → prepared-state-LNQ7DYSU-ABC2EQVI.js} +3 -2
- package/runtime/hub/apps/hub/server.js +130 -72
- package/runtime/hub/apps/hub/server.ts +18 -0
- package/runtime/hub/apps/hub/test/vnc-link.test.ts +61 -0
- package/runtime/hub/apps/hub/tsconfig.tsbuildinfo +1 -1
- package/runtime/hub-deploy/docker-compose.yml +1 -0
- package/runtime/relay/bin.cjs +16623 -14688
- package/runtime/vercel/agentbox-tool-shim +21 -0
- package/runtime/vercel/ctl.cjs +6757 -5299
- package/runtime/vercel/gh-shim +103 -228
- package/runtime/vercel/scripts/provision.sh +5 -9
- package/share/host-skills/agentbox-info/SKILL.md +24 -14
- package/dist/_cloud-attach-Y5HIQ373.js +0 -28
- package/dist/chunk-46NNZMZT.js.map +0 -1
- package/dist/chunk-74VIUGY6.js.map +0 -1
- package/dist/chunk-7RSE7ESY.js.map +0 -1
- package/dist/chunk-G3H2L3O2.js.map +0 -1
- package/dist/chunk-GFOWBXV7.js.map +0 -1
- package/dist/chunk-JDSYMTMS.js.map +0 -1
- package/dist/chunk-JNC7MCWJ.js.map +0 -1
- package/dist/chunk-JQLOGVZK.js.map +0 -1
- package/dist/chunk-KFLGXE3R.js.map +0 -1
- package/dist/chunk-KJ5TCYNI.js.map +0 -1
- package/dist/chunk-NHTRTST5.js.map +0 -1
- package/dist/chunk-NHVGKFVY.js.map +0 -1
- package/dist/chunk-OUF3YTQO.js.map +0 -1
- package/dist/chunk-OUWVN2F2.js.map +0 -1
- package/dist/chunk-OXKW4GWD.js.map +0 -1
- package/dist/chunk-PSA6GADQ.js.map +0 -1
- package/dist/chunk-WB6S4W7O.js.map +0 -1
- package/dist/chunk-YI4GHC2E.js.map +0 -1
- package/dist/dist-6PYXFREL.js.map +0 -1
- package/dist/dist-XQLKK7H3.js.map +0 -1
- package/dist/hub-MJ7O4WXW.js +0 -36
- package/dist/prepare-V4U5HVJU.js +0 -40
- package/dist/prepared-custody-QIXW7MJM.js +0 -35
- package/dist/relay-DRDELF6B.js +0 -20
- package/runtime/_shared/linear-shim +0 -181
- package/runtime/_shared/ntn-shim +0 -95
- package/runtime/digitalocean/linear-shim +0 -181
- package/runtime/digitalocean/ntn-shim +0 -95
- package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -181
- package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -95
- package/runtime/e2b/linear-shim +0 -181
- package/runtime/e2b/ntn-shim +0 -95
- package/runtime/hetzner/linear-shim +0 -181
- package/runtime/hetzner/ntn-shim +0 -95
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__039tc0m._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c_3x8u._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ty7ew1._.js +0 -3
- package/runtime/vercel/linear-shim +0 -181
- package/runtime/vercel/ntn-shim +0 -95
- /package/dist/{_cloud-attach-Y5HIQ373.js.map → _cloud-attach-HKRHYCY7.js.map} +0 -0
- /package/dist/{chunk-4PR3KJ5X.js.map → chunk-6PIGTR4D.js.map} +0 -0
- /package/dist/{chunk-BUMKBUXS.js.map → chunk-7QU6XENE.js.map} +0 -0
- /package/dist/{chunk-7ABO7OIF.js.map → chunk-CO2I3CQI.js.map} +0 -0
- /package/dist/{chunk-HYXCH4GA.js.map → chunk-EFVTQ7YB.js.map} +0 -0
- /package/dist/{chunk-EVT2SNF2.js.map → chunk-HO2ACZES.js.map} +0 -0
- /package/dist/{chunk-V5NWSLWD.js.map → chunk-HP4L45LW.js.map} +0 -0
- /package/dist/{chunk-B4DAH2F2.js.map → chunk-LHOKRCNF.js.map} +0 -0
- /package/dist/{chunk-BWM56FKY.js.map → chunk-RQURMAPA.js.map} +0 -0
- /package/dist/{chunk-FPMRFMVK.js.map → chunk-RZCLRWNY.js.map} +0 -0
- /package/dist/{chunk-FGQFVUMH.js.map → chunk-VY54AX4T.js.map} +0 -0
- /package/dist/{cloud-poller-SUNA6ZQC-7M5LJHHE.js.map → cloud-poller-QJRZXB4W-LJ2BRB3L.js.map} +0 -0
- /package/dist/{control-plane-5R7PYRQ6.js.map → control-plane-UKKYXHIQ.js.map} +0 -0
- /package/dist/{custody-client-PNCC2HBJ.js.map → custody-client-NPXJ46TB.js.map} +0 -0
- /package/dist/{deploy-hetzner-SSGSXAKA.js.map → deploy-hetzner-Y3ILCDRF.js.map} +0 -0
- /package/dist/{dist-5OR4QTQW.js.map → dist-5OGQ3CJQ.js.map} +0 -0
- /package/dist/{dist-EPFS5PRI.js.map → dist-7B3VCLZI.js.map} +0 -0
- /package/dist/{dist-K5M4HKG7.js.map → dist-A5ZEIVAW.js.map} +0 -0
- /package/dist/{dist-M4O5MU5K.js.map → dist-FBM2WS5S.js.map} +0 -0
- /package/dist/{dist-POILUDVJ.js.map → dist-MUTFY7FA.js.map} +0 -0
- /package/dist/{dist-RN6JOAG4.js.map → dist-SMDXLPZO.js.map} +0 -0
- /package/dist/{dist-SN2TCRZ5.js.map → dist-VTLQKZ2E.js.map} +0 -0
- /package/dist/{dist-XATN4ZIR.js.map → dist-ZJIJHCZB.js.map} +0 -0
- /package/dist/{dist-ZNQZHTUN.js.map → dist-ZNYS7CVF.js.map} +0 -0
- /package/dist/{hub-MJ7O4WXW.js.map → host-reach-drainer-ZJU2STQQ.js.map} +0 -0
- /package/dist/{hub-adopt-I44VGSBL.js.map → hub-Q4VOF4WN.js.map} +0 -0
- /package/dist/{hub-api-client-WJPBXZAZ.js.map → hub-adopt-OA336ZXZ.js.map} +0 -0
- /package/dist/{prepare-V4U5HVJU.js.map → hub-api-client-5U6WOTZ3.js.map} +0 -0
- /package/dist/{hub-docker-target-REEEWUG2.js.map → hub-docker-target-JKFCABK4.js.map} +0 -0
- /package/dist/{prepared-custody-QIXW7MJM.js.map → prepare-GFWWKWGF.js.map} +0 -0
- /package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js.map → prepared-custody-KU4PDVBT.js.map} +0 -0
- /package/dist/{relay-DRDELF6B.js.map → prepared-state-LNQ7DYSU-AR5RMXAO.js.map} +0 -0
- /package/dist/{publish-credentials-BPHUO5VL.js.map → publish-credentials-3SQXX45P.js.map} +0 -0
- /package/dist/{remote-docker-share-RX5ARK45.js.map → registry-AFKV3EO2.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → XIx10ozuCZRzwSsiCF_5t}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → XIx10ozuCZRzwSsiCF_5t}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → XIx10ozuCZRzwSsiCF_5t}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getRuntimeProviderNames,
|
|
4
|
+
isRuntimeProvider,
|
|
5
|
+
loadProviderModule
|
|
6
|
+
} from "./chunk-WGNI24H2.js";
|
|
7
|
+
import {
|
|
8
|
+
REMOTE_DOCKER,
|
|
9
|
+
parseProviderSpec
|
|
10
|
+
} from "./chunk-7LNXTPEE.js";
|
|
11
|
+
|
|
12
|
+
// src/provider/spec.ts
|
|
13
|
+
function resolveCreateProviderSpec(providerName, remoteHost) {
|
|
14
|
+
const raw = providerName && providerName.trim() || "docker";
|
|
15
|
+
if (remoteHost && parseProviderSpec(raw).name === "docker") return `docker:${remoteHost}`;
|
|
16
|
+
return raw;
|
|
17
|
+
}
|
|
18
|
+
function resolveProviderChoice(cfg, opts = {}) {
|
|
19
|
+
const { name: providerName, remoteHost: specHost } = parseProviderSpec(
|
|
20
|
+
opts.provider?.trim() || cfg.box.provider || "docker"
|
|
21
|
+
);
|
|
22
|
+
const host = opts.remoteHost?.trim() || specHost || (cfg.box.remoteDockerHost || "").trim() || void 0;
|
|
23
|
+
const remoteHost = providerName === REMOTE_DOCKER ? host : void 0;
|
|
24
|
+
return { providerName, remoteHost, spec: providerSpecFor(providerName, remoteHost) };
|
|
25
|
+
}
|
|
26
|
+
function providerSpecFor(providerName, remoteHost) {
|
|
27
|
+
return providerName === REMOTE_DOCKER && remoteHost ? `docker:${remoteHost}` : providerName;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/provider/registry.ts
|
|
31
|
+
function isKnownProvider(name) {
|
|
32
|
+
try {
|
|
33
|
+
return isRuntimeProvider(parseProviderSpec(name).name);
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function getProvider(name) {
|
|
39
|
+
const mod = await loadProviderModule(parseProviderSpec(name).name);
|
|
40
|
+
if (mod.ensureCredentials) await mod.ensureCredentials();
|
|
41
|
+
return mod.provider;
|
|
42
|
+
}
|
|
43
|
+
async function providerForBox(box) {
|
|
44
|
+
return getProvider(box.provider ?? "docker");
|
|
45
|
+
}
|
|
46
|
+
async function loadControlPlaneEnvLazily() {
|
|
47
|
+
const { loadControlPlaneEnv } = await import("./env-file-XT7SDXSX.js");
|
|
48
|
+
loadControlPlaneEnv();
|
|
49
|
+
}
|
|
50
|
+
async function providerForCreate(choice) {
|
|
51
|
+
const flag = choice.flag?.trim();
|
|
52
|
+
const spec = flag && flag.length > 0 ? flag : choice.config.box.provider;
|
|
53
|
+
if (typeof spec !== "string" || spec.length === 0 || !isKnownProvider(spec)) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`unknown sandbox provider "${String(spec)}" (known: ${getRuntimeProviderNames().join(", ")})`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (choice.config.relay?.controlPlaneUrl) await loadControlPlaneEnvLazily();
|
|
59
|
+
return getProvider(spec);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
resolveCreateProviderSpec,
|
|
64
|
+
resolveProviderChoice,
|
|
65
|
+
providerSpecFor,
|
|
66
|
+
isKnownProvider,
|
|
67
|
+
getProvider,
|
|
68
|
+
providerForBox,
|
|
69
|
+
providerForCreate
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=chunk-GWKGSXDC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider/spec.ts","../src/provider/registry.ts"],"sourcesContent":["/**\n * `--provider` accepts a *spec*, not just a name — see\n * `@agentbox/config`'s `provider-spec.ts`, which owns the parser so the CLI and\n * the hub cannot drift on what `docker:<host>` means.\n *\n * Everything that takes a `--provider` runs its value through `parseProviderSpec`,\n * so a spec works anywhere a bare name does. A name with no `:` parses to\n * itself, which keeps every existing call site's behavior exactly as it was.\n */\n\nexport {\n parseProviderSpec,\n providerNameOf,\n REMOTE_DOCKER,\n type ProviderSpec,\n} from '@agentbox/config';\n\nimport type { EffectiveConfig } from '@agentbox/config';\nimport { parseProviderSpec, REMOTE_DOCKER } from '@agentbox/config';\n\n/**\n * The effective provider spec for a queued create job, folding a `remoteHost`\n * (the `--remote-host` flag) into the spec. A `--remote-host` on an otherwise-bare\n * `docker` job IS a remote-docker box — encode it as `docker:<host>` so the worker\n * resolves the REMOTE engine, not the local one (a bare `docker` job would build\n * on this machine, silently ignoring the host the submitter asked for). A cloud\n * name, or an explicit `docker:<host>` spec (which already carries its host), pass\n * through unchanged.\n */\nexport function resolveCreateProviderSpec(\n providerName: string | undefined,\n remoteHost: string | undefined,\n): string {\n const raw = (providerName && providerName.trim()) || 'docker';\n if (remoteHost && parseProviderSpec(raw).name === 'docker') return `docker:${remoteHost}`;\n return raw;\n}\n\n/**\n * Resolve the provider + engine for a command, in one place.\n *\n * `box.provider` is stored as a bare provider NAME (the parser splits a\n * `docker:<host>` spec into `box.provider` + `box.remoteDockerHost`), so a\n * command can no longer get the host out of the config value itself. It has to\n * read the second key — and it must, because `dockerProviderRefusal` decides\n * whether a remote-docker create is allowed by whether the control box can\n * reach that host: a dropped host reads as \"no engine\" and refuses the create.\n *\n * Precedence, unchanged from when the spec carried the host: an explicit\n * `--remote-host` beats the host inside `--provider docker:<host>`, which beats\n * the configured `box.remoteDockerHost`.\n */\nexport function resolveProviderChoice(\n cfg: EffectiveConfig,\n opts: { provider?: string; remoteHost?: string } = {},\n): { providerName: string; remoteHost: string | undefined; spec: string } {\n const { name: providerName, remoteHost: specHost } = parseProviderSpec(\n opts.provider?.trim() || cfg.box.provider || 'docker',\n );\n const host =\n opts.remoteHost?.trim() || specHost || (cfg.box.remoteDockerHost || '').trim() || undefined;\n // Only remote-docker has an engine; carrying a stray host onto a cloud\n // provider would make `--remote-host` look honoured when it is ignored.\n const remoteHost = providerName === REMOTE_DOCKER ? host : undefined;\n return { providerName, remoteHost, spec: providerSpecFor(providerName, remoteHost) };\n}\n\n/**\n * The wire form for the hub API, which still speaks the spec: the hub worker\n * splits it again on its side (`parseProviderSpec` in `hub-worker.ts`). Only\n * remote-docker re-sugars; every other name is already the whole story.\n */\nexport function providerSpecFor(providerName: string, remoteHost: string | undefined): string {\n return providerName === REMOTE_DOCKER && remoteHost ? `docker:${remoteHost}` : providerName;\n}\n","/**\n * Provider registry — resolves a `Provider` for either an existing box (from\n * its `provider` discriminator) or a fresh `create` (from --provider flag /\n * config / default). Lazy `import()` keeps the Daytona SDK out of the Docker\n * hot path.\n */\n\nimport type { EffectiveConfig } from '@agentbox/config';\nimport type { ProviderKind } from '@agentbox/config';\nimport type { BoxRecord, Provider, ProviderName } from '@agentbox/core';\nimport { getRuntimeProviderNames, isRuntimeProvider, loadProviderModule } from './loaders.js';\nimport { parseProviderSpec } from './spec.js';\n\n/** A built-in `ProviderKind` OR a registered plugin provider name. */\nexport type KnownProviderName = ProviderKind | (string & {});\n\n/**\n * True for a built-in provider, a registered plugin provider, or a\n * host-qualified spec (`docker:<host>`). Every `--provider` validation goes\n * through here, so a spec is accepted everywhere a bare name is.\n */\nexport function isKnownProvider(name: string): boolean {\n try {\n return isRuntimeProvider(parseProviderSpec(name).name);\n } catch {\n // A malformed spec (`docker:` with no host) is not a known provider; the\n // caller's error message names it.\n return false;\n }\n}\n\n/**\n * Resolve a `Provider` by name or spec, running its first-run credential gate\n * first. Each provider package's `providerModule.ensureCredentials` walks the\n * user through `agentbox <provider> login` on first use (a no-op for docker and\n * remote-docker, which have no credential, and for non-TTY callers). The\n * base-snapshot gate lives inside `backend.provision`, not here, so `agentbox\n * prepare` can build the snapshot without tripping it. Built-ins load through\n * the bundle-inlined map; unknown names fall back to the plugin registry.\n */\nexport async function getProvider(name: ProviderName): Promise<Provider> {\n const mod = await loadProviderModule(parseProviderSpec(name).name);\n if (mod.ensureCredentials) await mod.ensureCredentials();\n return mod.provider;\n}\n\n/** Provider for an existing box record. Defaults to 'docker' for legacy records. */\nexport async function providerForBox(box: BoxRecord): Promise<Provider> {\n return getProvider(box.provider ?? 'docker');\n}\n\nexport interface CreateProviderChoice {\n /** Explicit --provider flag, if the command exposed one. */\n flag?: string;\n /** Effective config (carries box.provider for the layered default). */\n config: EffectiveConfig;\n}\n\n/**\n * Provider for a fresh `agentbox create`. Precedence: --provider flag >\n * box.provider config > 'docker'. Throws if the resolved name isn't registered.\n */\n/** Lazy: keeps the env-file read off every `getProvider` call. */\nasync function loadControlPlaneEnvLazily(): Promise<void> {\n const { loadControlPlaneEnv } = await import('../control-plane/env-file.js');\n loadControlPlaneEnv();\n}\n\nexport async function providerForCreate(choice: CreateProviderChoice): Promise<Provider> {\n const flag = choice.flag?.trim();\n const spec = (flag && flag.length > 0 ? flag : choice.config.box.provider) as ProviderName;\n if (typeof spec !== 'string' || spec.length === 0 || !isKnownProvider(spec)) {\n throw new Error(\n `unknown sandbox provider \"${String(spec)}\" (known: ${getRuntimeProviderNames().join(', ')})`,\n );\n }\n // A control-plane create needs the admin bearer in `process.env` — the\n // provider registers the box on the plane and pushes seed material with it.\n // The token lives in the setup-written env file, and nothing on the create\n // path was loading it, so in an ordinary shell (where the user has not\n // sourced it) every PC create silently skipped registration: the box came up\n // with `topology: control-plane` but the plane never heard of it, its seed was\n // never stored, and its `git push` had no token to lease with.\n //\n // Every create path resolves its provider through here, so this is the one\n // place that covers create / claude / codex / opencode / queued jobs.\n // Optional-chained: a real EffectiveConfig always carries `relay` (defaults\n // fill it), but callers/tests hand this a narrower object.\n if (choice.config.relay?.controlPlaneUrl) await loadControlPlaneEnvLazily();\n return getProvider(spec);\n}\n"],"mappings":";;;;;;;;;;;;AA6BO,SAAS,0BACd,cACA,YACQ;AACR,QAAM,MAAO,gBAAgB,aAAa,KAAK,KAAM;AACrD,MAAI,cAAc,kBAAkB,GAAG,EAAE,SAAS,SAAU,QAAO,UAAU,UAAU;AACvF,SAAO;AACT;AAgBO,SAAS,sBACd,KACA,OAAmD,CAAC,GACoB;AACxE,QAAM,EAAE,MAAM,cAAc,YAAY,SAAS,IAAI;AAAA,IACnD,KAAK,UAAU,KAAK,KAAK,IAAI,IAAI,YAAY;AAAA,EAC/C;AACA,QAAM,OACJ,KAAK,YAAY,KAAK,KAAK,aAAa,IAAI,IAAI,oBAAoB,IAAI,KAAK,KAAK;AAGpF,QAAM,aAAa,iBAAiB,gBAAgB,OAAO;AAC3D,SAAO,EAAE,cAAc,YAAY,MAAM,gBAAgB,cAAc,UAAU,EAAE;AACrF;AAOO,SAAS,gBAAgB,cAAsB,YAAwC;AAC5F,SAAO,iBAAiB,iBAAiB,aAAa,UAAU,UAAU,KAAK;AACjF;;;ACrDO,SAAS,gBAAgB,MAAuB;AACrD,MAAI;AACF,WAAO,kBAAkB,kBAAkB,IAAI,EAAE,IAAI;AAAA,EACvD,QAAQ;AAGN,WAAO;AAAA,EACT;AACF;AAWA,eAAsB,YAAY,MAAuC;AACvE,QAAM,MAAM,MAAM,mBAAmB,kBAAkB,IAAI,EAAE,IAAI;AACjE,MAAI,IAAI,kBAAmB,OAAM,IAAI,kBAAkB;AACvD,SAAO,IAAI;AACb;AAGA,eAAsB,eAAe,KAAmC;AACtE,SAAO,YAAY,IAAI,YAAY,QAAQ;AAC7C;AAcA,eAAe,4BAA2C;AACxD,QAAM,EAAE,oBAAoB,IAAI,MAAM,OAAO,wBAA8B;AAC3E,sBAAoB;AACtB;AAEA,eAAsB,kBAAkB,QAAiD;AACvF,QAAM,OAAO,OAAO,MAAM,KAAK;AAC/B,QAAM,OAAQ,QAAQ,KAAK,SAAS,IAAI,OAAO,OAAO,OAAO,IAAI;AACjE,MAAI,OAAO,SAAS,YAAY,KAAK,WAAW,KAAK,CAAC,gBAAgB,IAAI,GAAG;AAC3E,UAAM,IAAI;AAAA,MACR,6BAA6B,OAAO,IAAI,CAAC,aAAa,wBAAwB,EAAE,KAAK,IAAI,CAAC;AAAA,IAC5F;AAAA,EACF;AAaA,MAAI,OAAO,OAAO,OAAO,gBAAiB,OAAM,0BAA0B;AAC1E,SAAO,YAAY,IAAI;AACzB;","names":[]}
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
registryRefForSha,
|
|
10
10
|
resolveContextFilesFrom,
|
|
11
11
|
writePreparedStateRaw
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OKLEPEWZ.js";
|
|
13
13
|
|
|
14
|
-
// ../../packages/sandbox-docker/dist/chunk-
|
|
14
|
+
// ../../packages/sandbox-docker/dist/chunk-EAAMZ4OS.js
|
|
15
15
|
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
16
16
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
17
17
|
import { execa as execa2 } from "execa";
|
|
@@ -58,10 +58,13 @@ var realRunner = async (file, args, opts) => {
|
|
|
58
58
|
};
|
|
59
59
|
async function loginToGhcrWithGh(opts = {}) {
|
|
60
60
|
const run = opts.run ?? realRunner;
|
|
61
|
-
const tok = await run("gh", ["auth", "token"]);
|
|
61
|
+
const tok = await run("gh", ["auth", "token", "--hostname", "github.com"]);
|
|
62
62
|
const token = tok.stdout.trim();
|
|
63
63
|
if (tok.exitCode !== 0 || token.length === 0) {
|
|
64
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
ok: false,
|
|
66
|
+
reason: "no github.com `gh` token on this machine (run `gh auth login --hostname github.com`)"
|
|
67
|
+
};
|
|
65
68
|
}
|
|
66
69
|
const scopes = await (opts.fetchScopes ?? fetchTokenScopes)(token);
|
|
67
70
|
if (scopes.length > 0 && !scopes.includes(PACKAGE_READ_SCOPE)) {
|
|
@@ -96,7 +99,7 @@ async function fetchTokenScopes(token) {
|
|
|
96
99
|
var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
|
|
97
100
|
async function resolveClaudeInstallMode() {
|
|
98
101
|
try {
|
|
99
|
-
const { loadEffectiveConfig } = await import("./dist-
|
|
102
|
+
const { loadEffectiveConfig } = await import("./dist-FBM2WS5S.js");
|
|
100
103
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
101
104
|
return cfg.effective.box.claudeInstall;
|
|
102
105
|
} catch {
|
|
@@ -211,7 +214,7 @@ async function buildImage(opts = {}) {
|
|
|
211
214
|
return ref;
|
|
212
215
|
}
|
|
213
216
|
async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
214
|
-
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-
|
|
217
|
+
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-LNQ7DYSU-AR5RMXAO.js");
|
|
215
218
|
const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
|
|
216
219
|
const allowPull = opts.allowPull !== false;
|
|
217
220
|
if (allowPull && registry && fingerprint) {
|
|
@@ -264,7 +267,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
|
264
267
|
return { source: "built" };
|
|
265
268
|
}
|
|
266
269
|
async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
|
|
267
|
-
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-
|
|
270
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-LNQ7DYSU-AR5RMXAO.js");
|
|
268
271
|
const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
|
|
269
272
|
const rawFingerprint = await computeDockerContextFingerprint2({
|
|
270
273
|
contextDir: opts.contextDir
|
|
@@ -318,7 +321,7 @@ function classifyDockerBaseFreshness(input) {
|
|
|
318
321
|
return { state: "fresh" };
|
|
319
322
|
}
|
|
320
323
|
async function evaluateDockerBaseFreshness(opts = {}) {
|
|
321
|
-
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-
|
|
324
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-LNQ7DYSU-AR5RMXAO.js");
|
|
322
325
|
const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
|
|
323
326
|
const imagePresent = await imageExists(ref);
|
|
324
327
|
if (!imagePresent) return { state: "unprepared" };
|
|
@@ -405,4 +408,4 @@ export {
|
|
|
405
408
|
writePreparedDockerState,
|
|
406
409
|
preparedMatches
|
|
407
410
|
};
|
|
408
|
-
//# sourceMappingURL=chunk-
|
|
411
|
+
//# sourceMappingURL=chunk-GWYD7YBK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/sandbox-docker/src/prepared-state.ts","../../../packages/sandbox-docker/src/image.ts","../../../packages/sandbox-docker/src/registry-auth.ts"],"sourcesContent":["/**\n * Docker provider's `~/.agentbox/docker-prepared.json` reader/writer + the\n * build-context fingerprint that drives base-image invalidation.\n *\n * The fingerprint is a SHA-256 over every file `docker build` would COPY\n * into the image — Dockerfile + scripts + baked config files. Two CLIs\n * with identical staged runtime trees produce the same hash; a one-byte\n * edit to any baked asset flips it, which is the signal `ensureImage()`\n * uses to rebuild instead of reusing the cached image.\n */\n\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n computeContextManifest,\n DOCKER_CONTEXT_FILE_MAP,\n readCliStamp,\n readPreparedStateRaw,\n resolveContextFilesFrom,\n writePreparedStateRaw,\n type ContextFile,\n type FileManifest,\n type PreparedBaseSnapshot,\n} from '@agentbox/sandbox-core';\nimport { BUILD_CONTEXT_DIR, DEFAULT_BOX_IMAGE, DOCKERFILE_PATH } from './image.js';\n\nconst SCHEMA = 1 as const;\n\nexport type PreparedDockerState = PreparedBaseSnapshot<string, never>;\n\n/**\n * Resolve every fingerprint input to an absolute path. The canonical file\n * list lives in `@agentbox/sandbox-core` (DOCKER_CONTEXT_FILE_MAP) so the\n * daytona provider can hash the same inputs without depending on this\n * package. Two layouts are tried in order, mirroring `resolveDockerBuild()`\n * in `image.ts`:\n * 1. Build context dir (staged runtime / env override).\n * 2. Sandbox-docker package root (dev fallback).\n *\n * Returns `null` when *any* required file is missing — callers treat that\n * as \"can't fingerprint\" and skip the cache-hit shortcut (always rebuild).\n */\nexport function resolveContextFiles(opts: { contextDir?: string } = {}): ContextFile[] | null {\n const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;\n const here = dirname(fileURLToPath(import.meta.url));\n // sandbox-docker's package root = parent of src/ or parent of dist/.\n const packageRoot = resolve(here, '..');\n return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {\n contextDir: ctx,\n devRoot: packageRoot,\n });\n}\n\nexport interface ResolvedFingerprint {\n contextSha256: string;\n /** Files that fed the hash (in canonical sorted order). */\n files: ContextFile[];\n /** Per-file digests, recorded at bake time so a later `stale` can be explained. */\n manifest: FileManifest;\n}\n\nexport async function computeDockerContextFingerprint(\n opts: {\n contextDir?: string;\n } = {},\n): Promise<ResolvedFingerprint | null> {\n const files = resolveContextFiles(opts);\n if (!files) return null;\n const m = await computeContextManifest(files);\n return { contextSha256: m.contextSha256, files, manifest: m.files };\n}\n\n/**\n * The per-file digests of the CURRENT docker build context, for diffing against\n * a baked manifest. Returns undefined when the context can't be resolved (a dev\n * tree with no staged runtime) — the caller then has nothing to compare and must\n * not claim a diff.\n */\nexport async function currentDockerBaseFileHashes(): Promise<FileManifest | undefined> {\n try {\n const files = resolveContextFiles();\n if (!files) return undefined;\n return (await computeContextManifest(files)).files;\n } catch {\n return undefined;\n }\n}\n\nexport function readPreparedDockerState(): PreparedDockerState | null {\n const raw = readPreparedStateRaw('docker');\n if (raw === null || typeof raw !== 'object') return null;\n const parsed = raw as Partial<PreparedDockerState>;\n if (parsed.schema !== SCHEMA) return null;\n return { schema: SCHEMA, base: parsed.base };\n}\n\nexport function writePreparedDockerState(opts: {\n imageRef?: string;\n contextSha256: string;\n /** Per-file digests of the context this image was built from, when known. */\n files?: FileManifest;\n}): void {\n const stamp = readCliStamp();\n const state: PreparedDockerState = {\n schema: SCHEMA,\n base: {\n imageRef: opts.imageRef ?? DEFAULT_BOX_IMAGE,\n contextSha256: opts.contextSha256,\n cliVersion: stamp.cliVersion,\n cliCommit: stamp.cliCommit,\n createdAt: new Date().toISOString(),\n ...(opts.files ? { files: opts.files } : {}),\n },\n };\n writePreparedStateRaw('docker', state);\n}\n\n/** Convenience for `ensureImage` and `prepare` — true when the stamped fingerprint matches. */\nexport function preparedMatches(state: PreparedDockerState | null, current: string): boolean {\n return state?.base?.contextSha256 === current;\n}\n\n/** Re-export so callers don't reach into image.ts just for the Dockerfile path. */\nexport { DOCKERFILE_PATH };\n","import { execa } from 'execa';\nimport {\n classifyPullFailure,\n isAuthRetryable,\n isGhcrTarget,\n loginToGhcrWithGh,\n type PullFailure,\n} from './registry-auth.js';\nimport { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, resolve } from 'node:path';\nimport {\n BOX_IMAGE_REGISTRY,\n claudeInstallFingerprint,\n registryRefForSha,\n type FileManifest,\n} from '@agentbox/sandbox-core';\n\nexport const DEFAULT_BOX_IMAGE = 'agentbox/box:dev';\n\n/**\n * Resolve the effective `box.claudeInstall` for the current project. Docker\n * builds its image lazily at create time, so every `ensureImage` path must\n * agree on the mode or a native rebuild would clobber an npm-baked image (and\n * vice-versa). Lazy-imported to keep the module load cheap; falls back to\n * `native` if config can't be read.\n */\nasync function resolveClaudeInstallMode(): Promise<'native' | 'npm'> {\n try {\n const { loadEffectiveConfig } = await import('@agentbox/config');\n const cfg = await loadEffectiveConfig(process.cwd());\n return cfg.effective.box.claudeInstall;\n } catch {\n return 'native';\n }\n}\n\n// The registry ref lives in @agentbox/sandbox-core: daytona's linux-vm bake\n// needs it too (a VM snapshot can only be built from a prebuilt registry image),\n// and importing it from here would drag execa into that import graph. Re-exported\n// so existing `@agentbox/sandbox-docker` consumers keep working.\nexport { BOX_IMAGE_REGISTRY, registryRefForSha };\n\nconst here = dirname(fileURLToPath(import.meta.url));\n\n// The Dockerfile's COPY lines reference monorepo-relative paths\n// (packages/ctl/dist/bin.cjs, apps/cli/share/..., packages/sandbox-docker/scripts/*),\n// so the build context must be a dir containing that tree.\n//\n// Resolution order:\n// 0. AGENTBOX_DOCKER_CONTEXT env override (dir holding Dockerfile.box).\n// 1. Staged context shipped with the bundled `agent-box` package: this\n// module is bundled into the CLI at <root>/dist, the stage step mirrors\n// the COPY tree at <root>/runtime/docker (sibling of dist/, uniform in\n// dev and when installed).\n// 2. Legacy monorepo: Dockerfile.box at the sandbox-docker package root,\n// build context = monorepo root.\nfunction resolveDockerBuild(): { dockerfile: string; context: string } {\n const override = process.env.AGENTBOX_DOCKER_CONTEXT;\n if (override && existsSync(resolve(override, 'Dockerfile.box'))) {\n return { dockerfile: resolve(override, 'Dockerfile.box'), context: override };\n }\n const staged = resolve(here, '..', 'runtime', 'docker');\n if (existsSync(resolve(staged, 'Dockerfile.box'))) {\n return { dockerfile: resolve(staged, 'Dockerfile.box'), context: staged };\n }\n // Legacy: src/ (or the unbundled package dist/) is one level under the\n // package root; the monorepo root is two more up.\n const packageRoot = resolve(here, '..');\n return {\n dockerfile: resolve(packageRoot, 'Dockerfile.box'),\n context: resolve(packageRoot, '..', '..'),\n };\n}\n\nconst { dockerfile: DOCKERFILE_PATH_RESOLVED, context: BUILD_CONTEXT_DIR_RESOLVED } =\n resolveDockerBuild();\nexport const DOCKERFILE_PATH = DOCKERFILE_PATH_RESOLVED;\nexport const BUILD_CONTEXT_DIR = BUILD_CONTEXT_DIR_RESOLVED;\n\nexport async function imageExists(ref: string): Promise<boolean> {\n const result = await execa('docker', ['image', 'inspect', ref], { reject: false });\n return result.exitCode === 0;\n}\n\n/**\n * Attempt `docker pull <target>`. Never throws.\n *\n * Reports WHY it failed, not just that it did: a rate-limited pull, a rejected\n * credential and an unpublished tag all exit 1, but only the first two can be\n * fixed by authenticating and only the third means \"build locally\". Returning a\n * bare boolean here is what made a throttled pull look identical to a missing\n * image — a silent ~10-minute rebuild of an image that was in the registry.\n */\nexport async function pullImage(\n target: string,\n opts: { onProgress?: (line: string) => void } = {},\n): Promise<{ ok: boolean; failure?: PullFailure }> {\n const subprocess = execa('docker', ['pull', target], {\n stderr: 'pipe',\n stdout: 'pipe',\n reject: false,\n });\n // Kept so a failure can be classified; docker writes the real reason to stderr.\n let stderrText = '';\n // Always capture stderr, even with no onProgress — the classification below\n // needs it regardless of whether anyone is watching the progress stream.\n subprocess.stderr?.on('data', (chunk: Buffer | string) => {\n stderrText += typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n });\n let heartbeat: NodeJS.Timeout | undefined;\n if (opts.onProgress) {\n let lastLineAt = Date.now();\n const forward = (chunk: Buffer | string): void => {\n lastLineAt = Date.now();\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n // Piped (non-TTY) `docker pull` prints nothing between the last\n // \"Download complete\" and each \"Pull complete\" — the entire extraction\n // phase is silent, which for a multi-GB image reads as a hang. Emit a\n // keepalive so the create spinner keeps moving.\n heartbeat = setInterval(() => {\n if (Date.now() - lastLineAt >= 20_000) {\n opts.onProgress?.(`still extracting ${target} — large layers can take a few minutes`);\n }\n }, 20_000);\n }\n try {\n const result = await subprocess;\n if (result.exitCode === 0) return { ok: true };\n return { ok: false, failure: classifyPullFailure(stderrText || (result.stderr ?? '')) };\n } finally {\n if (heartbeat) clearInterval(heartbeat);\n }\n}\n\nexport async function tagImage(source: string, target: string): Promise<void> {\n await execa('docker', ['tag', source, target]);\n}\n\nexport interface ImageInfo {\n /** Image ref (e.g. `agentbox/box:dev`). */\n ref: string;\n /** True when the engine has the image locally. */\n exists: boolean;\n /** Image size in bytes, when known. */\n sizeBytes?: number;\n /** ISO-8601 creation time, when known. */\n createdAt?: string;\n}\n\n/**\n * Read-only inspect of a Docker image. Used by `agentbox prepare` (no-args\n * status mode) to surface base-image state. Never throws — returns\n * `{ exists: false }` on any error so the status command works even when\n * the docker daemon is unreachable.\n */\nexport async function imageInfo(ref: string = DEFAULT_BOX_IMAGE): Promise<ImageInfo> {\n const result = await execa(\n 'docker',\n ['image', 'inspect', '--format', '{{.Size}}|{{.Created}}', ref],\n { reject: false },\n );\n if (result.exitCode !== 0) return { ref, exists: false };\n const [sizeStr, createdAt] = result.stdout.trim().split('|');\n const sizeBytes = sizeStr ? Number.parseInt(sizeStr, 10) : NaN;\n return {\n ref,\n exists: true,\n sizeBytes: Number.isFinite(sizeBytes) ? sizeBytes : undefined,\n createdAt: createdAt && createdAt.length > 0 ? createdAt : undefined,\n };\n}\n\nexport interface BuildImageOptions {\n ref?: string;\n dockerfile?: string;\n contextDir?: string;\n /** `--build-arg K=V` pairs forwarded to `docker build` (e.g. AGENTBOX_CLAUDE_INSTALL). */\n buildArgs?: Record<string, string>;\n onProgress?: (line: string) => void;\n}\n\nexport async function buildImage(opts: BuildImageOptions = {}): Promise<string> {\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const dockerfile = opts.dockerfile ?? DOCKERFILE_PATH;\n const contextDir = opts.contextDir ?? BUILD_CONTEXT_DIR;\n\n // Dogfood path: when building from inside an agentbox (docker-in-docker),\n // the default bridge network can't bind-mount /proc/<pid>/ns/net for the\n // build container, breaking any RUN that needs network (e.g. apt, curl).\n // Falling back to host networking sidesteps the missing capability.\n const args = ['build', '-t', ref, '-f', dockerfile];\n for (const [k, v] of Object.entries(opts.buildArgs ?? {})) {\n args.push('--build-arg', `${k}=${v}`);\n }\n args.push(contextDir);\n if (process.env.AGENTBOX === '1') {\n args.splice(1, 0, '--network=host');\n }\n\n const subprocess = execa('docker', args, {\n stderr: 'pipe',\n stdout: 'pipe',\n });\n\n if (opts.onProgress) {\n const forward = (chunk: Buffer | string): void => {\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n }\n\n await subprocess;\n return ref;\n}\n\nexport interface PullOrBuildOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the staged runtime / monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /** `--build-arg K=V` pairs forwarded to the local `docker build` (ignored on a registry pull). */\n buildArgs?: Record<string, string>;\n}\n\n/**\n * Make `ref` present locally, preferring a registry pull over a local build.\n *\n * When `fingerprint` is non-null and pulling is allowed, pull the\n * fingerprint-tagged image and retag it to `ref`; on a miss (or when pulling\n * is disabled / unfingerprintable) build from the staged context. Either way,\n * a known fingerprint is stamped into docker-prepared.json so the next\n * `ensureImage()` treats this as a cache hit.\n */\nexport async function pullOrBuild(\n ref: string,\n fingerprint: { contextSha256: string; manifest?: FileManifest } | null,\n opts: PullOrBuildOptions = {},\n): Promise<{ source: 'pulled' | 'built' }> {\n const { writePreparedDockerState } = await import('./prepared-state.js');\n const registry = opts.registry ?? BOX_IMAGE_REGISTRY;\n const allowPull = opts.allowPull !== false;\n\n if (allowPull && registry && fingerprint) {\n const target = registryRefForSha(fingerprint.contextSha256, registry);\n const succeed = async (): Promise<{ source: 'pulled' }> => {\n await tagImage(target, ref);\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n opts.onProgress?.(`[image] pulled ${target} -> ${ref}`);\n return { source: 'pulled' };\n };\n\n opts.onProgress?.(`[image] pulling ${target}`);\n const first = await pullImage(target, { onProgress: opts.onProgress });\n if (first.ok) return succeed();\n\n const failure = first.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] pull failed (${failure.kind}): ${failure.detail}`);\n\n // A throttle or a credential problem is not a missing image: the tag is\n // there and an authenticated pull gets it. GHCR's anonymous limit is per-IP\n // and a machine that just baked a few times trips it, so borrowing the\n // host's `gh` token here is the difference between a retag and a ~10-minute\n // rebuild of an image that was already published.\n if (isAuthRetryable(failure.kind) && isGhcrTarget(target)) {\n opts.onProgress?.('[image] retrying authenticated with your `gh` token');\n const login = await loginToGhcrWithGh();\n if (login.ok) {\n const second = await pullImage(target, { onProgress: opts.onProgress });\n if (second.ok) return succeed();\n const f2 = second.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] authenticated pull also failed (${f2.kind}): ${f2.detail}`);\n } else {\n opts.onProgress?.(\n `[image] could not authenticate to ghcr.io: ${login.reason ?? 'unknown'}`,\n );\n }\n }\n\n opts.onProgress?.(`[image] building ${ref} locally instead`);\n }\n\n await buildImage({\n ref,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n buildArgs: opts.buildArgs,\n onProgress: opts.onProgress,\n });\n if (fingerprint) {\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n }\n return { source: 'built' };\n}\n\nexport interface EnsureImageOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /**\n * How Claude Code is installed into the image. Folded into the build-context\n * fingerprint so a mode switch rebuilds (and an npm image isn't clobbered by\n * a native rebuild). Defaults to the resolved `box.claudeInstall`.\n */\n claudeInstall?: 'native' | 'npm';\n}\n\nexport async function ensureImage(\n ref: string = DEFAULT_BOX_IMAGE,\n opts: EnsureImageOptions = {},\n): Promise<{ ref: string; built: boolean; reason?: string }> {\n // Lazy import: prepared-state imports back into image.ts for the default\n // DOCKERFILE_PATH/BUILD_CONTEXT_DIR constants, so loading it at top-level\n // would create a circular ESM init order.\n const { computeDockerContextFingerprint, readPreparedDockerState, preparedMatches } =\n await import('./prepared-state.js');\n\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const rawFingerprint = await computeDockerContextFingerprint({\n contextDir: opts.contextDir,\n });\n // Fold the install mode into the sha so native↔npm are distinct cache\n // identities (`native` leaves the hash unchanged).\n const fingerprint = rawFingerprint\n ? {\n ...rawFingerprint,\n contextSha256: claudeInstallFingerprint(rawFingerprint.contextSha256, claudeInstall),\n }\n : null;\n const prepared = readPreparedDockerState();\n const exists = await imageExists(ref);\n\n let reason: string | undefined;\n if (!exists) {\n reason = `image ${ref} not present`;\n } else if (!fingerprint) {\n // Couldn't enumerate the context (partial dev rebuild?). Don't rebuild\n // unconditionally — that would surprise users mid-iteration. Trust the\n // image-exists check and leave the prepared file untouched.\n return { ref, built: false, reason: 'image present (fingerprint skipped)' };\n } else if (!prepared) {\n reason = 'no docker-prepared.json on disk';\n } else if (!preparedMatches(prepared, fingerprint.contextSha256)) {\n reason =\n `build context changed (was ${prepared.base?.contextSha256?.slice(0, 12) ?? '<none>'}, ` +\n `now ${fingerprint.contextSha256.slice(0, 12)})`;\n }\n\n if (!reason) {\n return { ref, built: false, reason: 'image up to date' };\n }\n\n opts.onProgress?.(`[image] ${ref}: ${reason}`);\n const npm = claudeInstall === 'npm';\n const { source } = await pullOrBuild(ref, fingerprint, {\n onProgress: opts.onProgress,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n // npm mode pulls too. CI publishes both install variants, and `fingerprint`\n // is already folded with the mode above — so the pull asks for the npm\n // image's own tag and hits. (It used to be native-only, which meant npm\n // users rebuilt the image locally on every first create, forever.) A tag\n // that genuinely isn't published still falls back to a local build.\n allowPull: opts.allowPull,\n registry: opts.registry,\n buildArgs: npm ? { AGENTBOX_CLAUDE_INSTALL: 'npm' } : undefined,\n });\n return { ref, built: source === 'built', reason };\n}\n\n/**\n * Read-only freshness classification of the docker base image, for surfaces\n * (hub API, tray) that want to announce an upcoming bake without triggering\n * it. `unknown` means \"couldn't fingerprint\" and MUST stay inert — the\n * matching `ensureImage` path trusts the existing image and does not rebuild.\n */\nexport type DockerBaseFreshness =\n | { state: 'fresh' }\n | { state: 'unknown' }\n | { state: 'unprepared' }\n | { state: 'stale'; reason: string };\n\n/**\n * Pure decision core shared by `evaluateDockerBaseFreshness`. Mirrors\n * `ensureImage`'s rebuild predicate exactly — if the two ever disagree, the\n * freshness surfaces would announce a bake that create then skips (or miss\n * one it performs). `stampedSha` is `docker-prepared.json`'s fingerprint,\n * null when the stamp is missing/invalid.\n */\nexport function classifyDockerBaseFreshness(input: {\n imagePresent: boolean;\n fingerprint: string | null;\n stampedSha: string | null;\n}): DockerBaseFreshness {\n if (!input.imagePresent) return { state: 'unprepared' };\n if (!input.fingerprint) return { state: 'unknown' };\n if (!input.stampedSha) return { state: 'stale', reason: 'no docker-prepared.json on disk' };\n if (input.stampedSha !== input.fingerprint) {\n return {\n state: 'stale',\n reason:\n `build context changed (was ${input.stampedSha.slice(0, 12)}, ` +\n `now ${input.fingerprint.slice(0, 12)})`,\n };\n }\n return { state: 'fresh' };\n}\n\n/**\n * Cheap live check: would `ensureImage` bake on the next create? The only\n * docker work is one `docker image inspect`; the rest hashes the ~15 build\n * context files. Never builds, pulls, or writes the prepared stamp.\n */\nexport async function evaluateDockerBaseFreshness(\n opts: { ref?: string; claudeInstall?: 'native' | 'npm'; contextDir?: string } = {},\n): Promise<DockerBaseFreshness> {\n // Lazy import for the same circular-init reason as in ensureImage above.\n const { computeDockerContextFingerprint, readPreparedDockerState } =\n await import('./prepared-state.js');\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const imagePresent = await imageExists(ref);\n if (!imagePresent) return { state: 'unprepared' };\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const raw = await computeDockerContextFingerprint({ contextDir: opts.contextDir });\n return classifyDockerBaseFreshness({\n imagePresent,\n fingerprint: raw ? claudeInstallFingerprint(raw.contextSha256, claudeInstall) : null,\n stampedSha: readPreparedDockerState()?.base?.contextSha256 ?? null,\n });\n}\n","/**\n * Why a `docker pull` of the box image failed, and how to retry it authenticated.\n *\n * The box image is published to a PUBLIC GHCR repo, so an anonymous pull works —\n * until it doesn't. GHCR rate-limits anonymous pulls per IP, and a machine that\n * has just baked a few times trips it. `docker pull` then exits non-zero and the\n * caller falls back to a ~10-minute local build of an image that was sitting in\n * the registry all along. Worse, the old code returned a bare boolean, so a\n * rate-limit, a 401 and a genuinely-unpublished tag were indistinguishable and\n * none of them reached the log.\n *\n * So: classify the failure, and when it is a throttle/auth problem on GHCR,\n * borrow the host's `gh` token and retry once.\n *\n * The load-bearing subtlety is the SCOPE. `gh auth token` returns whatever the\n * user's `gh auth login` negotiated — by default `repo`, `read:org`, `gist`,\n * `workflow` and *not* `read:packages`. Logging in to GHCR with such a token is\n * actively worse than staying anonymous: the registry then evaluates an\n * identity that lacks package-read and answers 403, turning a pull that would\n * have succeeded into one that cannot. So we check the scope first and skip the\n * login when it is absent, telling the user the one command that fixes it.\n */\nimport { execa } from 'execa';\n\n/** GHCR is the only registry we know how to authenticate from `gh`. */\nexport const GHCR_HOST = 'ghcr.io';\n\n/** The scope GHCR requires to read a package, public or not. */\nconst PACKAGE_READ_SCOPE = 'read:packages';\n\nexport type PullFailureKind =\n /** GHCR throttled us — the tag exists and an authenticated retry should work. */\n | 'rate-limit'\n /** Credentials rejected or absent where required. */\n | 'unauthorized'\n /** The tag genuinely is not published — a local build is the correct answer. */\n | 'not-found'\n /** DNS / TCP / TLS — nothing to do with the tag. */\n | 'network'\n | 'unknown';\n\nexport interface PullFailure {\n kind: PullFailureKind;\n /** The most useful line of docker's own stderr, for the log. */\n detail: string;\n}\n\n/**\n * Map `docker pull` stderr onto a {@link PullFailureKind}. Substring matching on\n * docker/registry error text rather than exit codes, which are always 1.\n */\nexport function classifyPullFailure(stderr: string): PullFailure {\n const text = stderr.toLowerCase();\n const detail = lastMeaningfulLine(stderr);\n // Order matters: a throttle response also says \"unauthorized\" on some\n // registries, and it is the throttle that decides whether a retry can help.\n if (\n text.includes('toomanyrequests') ||\n text.includes('too many requests') ||\n text.includes('429')\n ) {\n return { kind: 'rate-limit', detail };\n }\n if (\n text.includes('manifest unknown') ||\n text.includes('not found') ||\n text.includes('404') ||\n text.includes('no such manifest')\n ) {\n return { kind: 'not-found', detail };\n }\n if (\n text.includes('unauthorized') ||\n text.includes('authentication required') ||\n text.includes('denied') ||\n text.includes('403')\n ) {\n return { kind: 'unauthorized', detail };\n }\n if (\n text.includes('dial tcp') ||\n text.includes('no such host') ||\n text.includes('timeout') ||\n text.includes('temporary failure in name resolution') ||\n text.includes('connection refused') ||\n text.includes('tls handshake')\n ) {\n return { kind: 'network', detail };\n }\n return { kind: 'unknown', detail };\n}\n\n/** The last non-empty stderr line, trimmed — docker puts the real error last. */\nfunction lastMeaningfulLine(stderr: string): string {\n const lines = stderr\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .filter((l) => l.length > 0);\n return lines.length > 0 ? lines[lines.length - 1]! : 'no error output from docker';\n}\n\n/** Only a throttle or a credential problem can be improved by authenticating. */\nexport function isAuthRetryable(kind: PullFailureKind): boolean {\n return kind === 'rate-limit' || kind === 'unauthorized';\n}\n\n/** True when `target` lives on GHCR, the only host we can log into from `gh`. */\nexport function isGhcrTarget(target: string): boolean {\n return target.startsWith(`${GHCR_HOST}/`);\n}\n\nexport interface GhcrLoginResult {\n ok: boolean;\n /** Why we did not (or could not) log in — always safe to show the user. */\n reason?: string;\n}\n\ninterface Runner {\n (\n file: string,\n args: string[],\n opts?: { input?: string },\n ): Promise<{\n exitCode: number | undefined;\n stdout: string;\n stderr: string;\n }>;\n}\n\nconst realRunner: Runner = async (file, args, opts) => {\n const r = await execa(file, args, {\n reject: false,\n timeout: 30_000,\n ...(opts?.input !== undefined ? { input: opts.input } : {}),\n });\n return { exitCode: r.exitCode, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };\n};\n\n/**\n * Log the local docker engine into GHCR using the host's `gh` token, so the\n * retry is authenticated (and rate-limited far more generously).\n *\n * Refuses rather than risks it when the token lacks `read:packages` — see the\n * module comment. `fetchScopes` is injected so this is testable without network.\n */\nexport async function loginToGhcrWithGh(\n opts: {\n run?: Runner;\n fetchScopes?: (token: string) => Promise<string[]>;\n } = {},\n): Promise<GhcrLoginResult> {\n const run = opts.run ?? realRunner;\n\n const tok = await run('gh', ['auth', 'token']);\n const token = tok.stdout.trim();\n if (tok.exitCode !== 0 || token.length === 0) {\n return { ok: false, reason: 'no `gh` token on this machine (run `gh auth login`)' };\n }\n\n const scopes = await (opts.fetchScopes ?? fetchTokenScopes)(token);\n // An empty list means we could not read the header (offline, or a fine-grained\n // token that reports no classic scopes). Attempting the login is then the\n // lesser evil: a fine-grained PAT with package-read is a normal setup, and a\n // failed login leaves us exactly where we already are.\n if (scopes.length > 0 && !scopes.includes(PACKAGE_READ_SCOPE)) {\n return {\n ok: false,\n reason:\n `your \\`gh\\` token lacks the ${PACKAGE_READ_SCOPE} scope, so authenticating would be ` +\n `rejected by ${GHCR_HOST}. Add it with: gh auth refresh -h github.com -s ${PACKAGE_READ_SCOPE}`,\n };\n }\n\n // GHCR ignores the username when the password is a valid token, but docker\n // requires a non-empty one.\n const login = await run('docker', ['login', GHCR_HOST, '-u', 'agentbox', '--password-stdin'], {\n input: token,\n });\n if (login.exitCode !== 0) {\n return { ok: false, reason: lastMeaningfulLine(login.stderr || login.stdout) };\n }\n return { ok: true };\n}\n\n/** Classic OAuth scopes for `token`, from GitHub's `x-oauth-scopes` header. */\nasync function fetchTokenScopes(token: string): Promise<string[]> {\n try {\n const res = await fetch('https://api.github.com/user', {\n headers: {\n Authorization: `Bearer ${token}`,\n Accept: 'application/vnd.github+json',\n 'User-Agent': 'agentbox',\n },\n signal: AbortSignal.timeout(10_000),\n });\n return (res.headers.get('x-oauth-scopes') ?? '')\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,SAAS,WAAAA,UAAS,WAAAC,gBAAe;AACjC,SAAS,iBAAAC,sBAAqB;ACZ9B,SAAS,SAAAC,cAAa;ACsBtB,SAAS,aAAa;ADdtB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,eAAe;ACe1B,IAAM,YAAY;AAGzB,IAAM,qBAAqB;AAuBpB,SAAS,oBAAoB,QAA6B;AAC/D,QAAM,OAAO,OAAO,YAAY;AAChC,QAAM,SAAS,mBAAmB,MAAM;AAGxC,MACE,KAAK,SAAS,iBAAiB,KAC/B,KAAK,SAAS,mBAAmB,KACjC,KAAK,SAAS,KAAK,GACnB;AACA,WAAO,EAAE,MAAM,cAAc,OAAO;EACtC;AACA,MACE,KAAK,SAAS,kBAAkB,KAChC,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,KAAK,KACnB,KAAK,SAAS,kBAAkB,GAChC;AACA,WAAO,EAAE,MAAM,aAAa,OAAO;EACrC;AACA,MACE,KAAK,SAAS,cAAc,KAC5B,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,QAAQ,KACtB,KAAK,SAAS,KAAK,GACnB;AACA,WAAO,EAAE,MAAM,gBAAgB,OAAO;EACxC;AACA,MACE,KAA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;AAEO,SAAS,yBAAyB,MAKhC;AACP,QAAM,QAAQ,aAAa;AAC3B,QAAM,QAA6B;IACjC,QAAQ;IACR,MAAM;MACJ,UAAU,KAAK,YAAY;MAC3B,eAAe,KAAK;MACpB,YAAY,MAAM;MAClB,WAAW,MAAM;MACjB,YAAW,oBAAI,KAAK,GAAE,YAAY;MAClC,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;IAC5C;EACF;AACA,wBAAsB,UAAU,KAAK;AACvC;AAGO,SAAS,gBAAgB,OAAmC,SAA0B;AAC3F,SAAO,OAAO,MAAM,kBAAkB;AACxC;","names":["dirname","resolve","fileURLToPath","execa","execa","writePreparedDockerState","computeDockerContextFingerprint","readPreparedDockerState","preparedMatches","here","dirname","fileURLToPath","resolve"]}
|
|
1
|
+
{"version":3,"sources":["../../../packages/sandbox-docker/src/prepared-state.ts","../../../packages/sandbox-docker/src/image.ts","../../../packages/sandbox-docker/src/registry-auth.ts"],"sourcesContent":["/**\n * Docker provider's `~/.agentbox/docker-prepared.json` reader/writer + the\n * build-context fingerprint that drives base-image invalidation.\n *\n * The fingerprint is a SHA-256 over every file `docker build` would COPY\n * into the image — Dockerfile + scripts + baked config files. Two CLIs\n * with identical staged runtime trees produce the same hash; a one-byte\n * edit to any baked asset flips it, which is the signal `ensureImage()`\n * uses to rebuild instead of reusing the cached image.\n */\n\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n computeContextManifest,\n DOCKER_CONTEXT_FILE_MAP,\n readCliStamp,\n readPreparedStateRaw,\n resolveContextFilesFrom,\n writePreparedStateRaw,\n type ContextFile,\n type FileManifest,\n type PreparedBaseSnapshot,\n} from '@agentbox/sandbox-core';\nimport { BUILD_CONTEXT_DIR, DEFAULT_BOX_IMAGE, DOCKERFILE_PATH } from './image.js';\n\nconst SCHEMA = 1 as const;\n\nexport type PreparedDockerState = PreparedBaseSnapshot<string, never>;\n\n/**\n * Resolve every fingerprint input to an absolute path. The canonical file\n * list lives in `@agentbox/sandbox-core` (DOCKER_CONTEXT_FILE_MAP) so the\n * daytona provider can hash the same inputs without depending on this\n * package. Two layouts are tried in order, mirroring `resolveDockerBuild()`\n * in `image.ts`:\n * 1. Build context dir (staged runtime / env override).\n * 2. Sandbox-docker package root (dev fallback).\n *\n * Returns `null` when *any* required file is missing — callers treat that\n * as \"can't fingerprint\" and skip the cache-hit shortcut (always rebuild).\n */\nexport function resolveContextFiles(opts: { contextDir?: string } = {}): ContextFile[] | null {\n const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;\n const here = dirname(fileURLToPath(import.meta.url));\n // sandbox-docker's package root = parent of src/ or parent of dist/.\n const packageRoot = resolve(here, '..');\n return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {\n contextDir: ctx,\n devRoot: packageRoot,\n });\n}\n\nexport interface ResolvedFingerprint {\n contextSha256: string;\n /** Files that fed the hash (in canonical sorted order). */\n files: ContextFile[];\n /** Per-file digests, recorded at bake time so a later `stale` can be explained. */\n manifest: FileManifest;\n}\n\nexport async function computeDockerContextFingerprint(\n opts: {\n contextDir?: string;\n } = {},\n): Promise<ResolvedFingerprint | null> {\n const files = resolveContextFiles(opts);\n if (!files) return null;\n const m = await computeContextManifest(files);\n return { contextSha256: m.contextSha256, files, manifest: m.files };\n}\n\n/**\n * The per-file digests of the CURRENT docker build context, for diffing against\n * a baked manifest. Returns undefined when the context can't be resolved (a dev\n * tree with no staged runtime) — the caller then has nothing to compare and must\n * not claim a diff.\n */\nexport async function currentDockerBaseFileHashes(): Promise<FileManifest | undefined> {\n try {\n const files = resolveContextFiles();\n if (!files) return undefined;\n return (await computeContextManifest(files)).files;\n } catch {\n return undefined;\n }\n}\n\nexport function readPreparedDockerState(): PreparedDockerState | null {\n const raw = readPreparedStateRaw('docker');\n if (raw === null || typeof raw !== 'object') return null;\n const parsed = raw as Partial<PreparedDockerState>;\n if (parsed.schema !== SCHEMA) return null;\n return { schema: SCHEMA, base: parsed.base };\n}\n\nexport function writePreparedDockerState(opts: {\n imageRef?: string;\n contextSha256: string;\n /** Per-file digests of the context this image was built from, when known. */\n files?: FileManifest;\n}): void {\n const stamp = readCliStamp();\n const state: PreparedDockerState = {\n schema: SCHEMA,\n base: {\n imageRef: opts.imageRef ?? DEFAULT_BOX_IMAGE,\n contextSha256: opts.contextSha256,\n cliVersion: stamp.cliVersion,\n cliCommit: stamp.cliCommit,\n createdAt: new Date().toISOString(),\n ...(opts.files ? { files: opts.files } : {}),\n },\n };\n writePreparedStateRaw('docker', state);\n}\n\n/** Convenience for `ensureImage` and `prepare` — true when the stamped fingerprint matches. */\nexport function preparedMatches(state: PreparedDockerState | null, current: string): boolean {\n return state?.base?.contextSha256 === current;\n}\n\n/** Re-export so callers don't reach into image.ts just for the Dockerfile path. */\nexport { DOCKERFILE_PATH };\n","import { execa } from 'execa';\nimport {\n classifyPullFailure,\n isAuthRetryable,\n isGhcrTarget,\n loginToGhcrWithGh,\n type PullFailure,\n} from './registry-auth.js';\nimport { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, resolve } from 'node:path';\nimport {\n BOX_IMAGE_REGISTRY,\n claudeInstallFingerprint,\n registryRefForSha,\n type FileManifest,\n} from '@agentbox/sandbox-core';\n\nexport const DEFAULT_BOX_IMAGE = 'agentbox/box:dev';\n\n/**\n * Resolve the effective `box.claudeInstall` for the current project. Docker\n * builds its image lazily at create time, so every `ensureImage` path must\n * agree on the mode or a native rebuild would clobber an npm-baked image (and\n * vice-versa). Lazy-imported to keep the module load cheap; falls back to\n * `native` if config can't be read.\n */\nasync function resolveClaudeInstallMode(): Promise<'native' | 'npm'> {\n try {\n const { loadEffectiveConfig } = await import('@agentbox/config');\n const cfg = await loadEffectiveConfig(process.cwd());\n return cfg.effective.box.claudeInstall;\n } catch {\n return 'native';\n }\n}\n\n// The registry ref lives in @agentbox/sandbox-core: daytona's linux-vm bake\n// needs it too (a VM snapshot can only be built from a prebuilt registry image),\n// and importing it from here would drag execa into that import graph. Re-exported\n// so existing `@agentbox/sandbox-docker` consumers keep working.\nexport { BOX_IMAGE_REGISTRY, registryRefForSha };\n\nconst here = dirname(fileURLToPath(import.meta.url));\n\n// The Dockerfile's COPY lines reference monorepo-relative paths\n// (packages/ctl/dist/bin.cjs, apps/cli/share/..., packages/sandbox-docker/scripts/*),\n// so the build context must be a dir containing that tree.\n//\n// Resolution order:\n// 0. AGENTBOX_DOCKER_CONTEXT env override (dir holding Dockerfile.box).\n// 1. Staged context shipped with the bundled `agent-box` package: this\n// module is bundled into the CLI at <root>/dist, the stage step mirrors\n// the COPY tree at <root>/runtime/docker (sibling of dist/, uniform in\n// dev and when installed).\n// 2. Legacy monorepo: Dockerfile.box at the sandbox-docker package root,\n// build context = monorepo root.\nfunction resolveDockerBuild(): { dockerfile: string; context: string } {\n const override = process.env.AGENTBOX_DOCKER_CONTEXT;\n if (override && existsSync(resolve(override, 'Dockerfile.box'))) {\n return { dockerfile: resolve(override, 'Dockerfile.box'), context: override };\n }\n const staged = resolve(here, '..', 'runtime', 'docker');\n if (existsSync(resolve(staged, 'Dockerfile.box'))) {\n return { dockerfile: resolve(staged, 'Dockerfile.box'), context: staged };\n }\n // Legacy: src/ (or the unbundled package dist/) is one level under the\n // package root; the monorepo root is two more up.\n const packageRoot = resolve(here, '..');\n return {\n dockerfile: resolve(packageRoot, 'Dockerfile.box'),\n context: resolve(packageRoot, '..', '..'),\n };\n}\n\nconst { dockerfile: DOCKERFILE_PATH_RESOLVED, context: BUILD_CONTEXT_DIR_RESOLVED } =\n resolveDockerBuild();\nexport const DOCKERFILE_PATH = DOCKERFILE_PATH_RESOLVED;\nexport const BUILD_CONTEXT_DIR = BUILD_CONTEXT_DIR_RESOLVED;\n\nexport async function imageExists(ref: string): Promise<boolean> {\n const result = await execa('docker', ['image', 'inspect', ref], { reject: false });\n return result.exitCode === 0;\n}\n\n/**\n * Attempt `docker pull <target>`. Never throws.\n *\n * Reports WHY it failed, not just that it did: a rate-limited pull, a rejected\n * credential and an unpublished tag all exit 1, but only the first two can be\n * fixed by authenticating and only the third means \"build locally\". Returning a\n * bare boolean here is what made a throttled pull look identical to a missing\n * image — a silent ~10-minute rebuild of an image that was in the registry.\n */\nexport async function pullImage(\n target: string,\n opts: { onProgress?: (line: string) => void } = {},\n): Promise<{ ok: boolean; failure?: PullFailure }> {\n const subprocess = execa('docker', ['pull', target], {\n stderr: 'pipe',\n stdout: 'pipe',\n reject: false,\n });\n // Kept so a failure can be classified; docker writes the real reason to stderr.\n let stderrText = '';\n // Always capture stderr, even with no onProgress — the classification below\n // needs it regardless of whether anyone is watching the progress stream.\n subprocess.stderr?.on('data', (chunk: Buffer | string) => {\n stderrText += typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n });\n let heartbeat: NodeJS.Timeout | undefined;\n if (opts.onProgress) {\n let lastLineAt = Date.now();\n const forward = (chunk: Buffer | string): void => {\n lastLineAt = Date.now();\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n // Piped (non-TTY) `docker pull` prints nothing between the last\n // \"Download complete\" and each \"Pull complete\" — the entire extraction\n // phase is silent, which for a multi-GB image reads as a hang. Emit a\n // keepalive so the create spinner keeps moving.\n heartbeat = setInterval(() => {\n if (Date.now() - lastLineAt >= 20_000) {\n opts.onProgress?.(`still extracting ${target} — large layers can take a few minutes`);\n }\n }, 20_000);\n }\n try {\n const result = await subprocess;\n if (result.exitCode === 0) return { ok: true };\n return { ok: false, failure: classifyPullFailure(stderrText || (result.stderr ?? '')) };\n } finally {\n if (heartbeat) clearInterval(heartbeat);\n }\n}\n\nexport async function tagImage(source: string, target: string): Promise<void> {\n await execa('docker', ['tag', source, target]);\n}\n\nexport interface ImageInfo {\n /** Image ref (e.g. `agentbox/box:dev`). */\n ref: string;\n /** True when the engine has the image locally. */\n exists: boolean;\n /** Image size in bytes, when known. */\n sizeBytes?: number;\n /** ISO-8601 creation time, when known. */\n createdAt?: string;\n}\n\n/**\n * Read-only inspect of a Docker image. Used by `agentbox prepare` (no-args\n * status mode) to surface base-image state. Never throws — returns\n * `{ exists: false }` on any error so the status command works even when\n * the docker daemon is unreachable.\n */\nexport async function imageInfo(ref: string = DEFAULT_BOX_IMAGE): Promise<ImageInfo> {\n const result = await execa(\n 'docker',\n ['image', 'inspect', '--format', '{{.Size}}|{{.Created}}', ref],\n { reject: false },\n );\n if (result.exitCode !== 0) return { ref, exists: false };\n const [sizeStr, createdAt] = result.stdout.trim().split('|');\n const sizeBytes = sizeStr ? Number.parseInt(sizeStr, 10) : NaN;\n return {\n ref,\n exists: true,\n sizeBytes: Number.isFinite(sizeBytes) ? sizeBytes : undefined,\n createdAt: createdAt && createdAt.length > 0 ? createdAt : undefined,\n };\n}\n\nexport interface BuildImageOptions {\n ref?: string;\n dockerfile?: string;\n contextDir?: string;\n /** `--build-arg K=V` pairs forwarded to `docker build` (e.g. AGENTBOX_CLAUDE_INSTALL). */\n buildArgs?: Record<string, string>;\n onProgress?: (line: string) => void;\n}\n\nexport async function buildImage(opts: BuildImageOptions = {}): Promise<string> {\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const dockerfile = opts.dockerfile ?? DOCKERFILE_PATH;\n const contextDir = opts.contextDir ?? BUILD_CONTEXT_DIR;\n\n // Dogfood path: when building from inside an agentbox (docker-in-docker),\n // the default bridge network can't bind-mount /proc/<pid>/ns/net for the\n // build container, breaking any RUN that needs network (e.g. apt, curl).\n // Falling back to host networking sidesteps the missing capability.\n const args = ['build', '-t', ref, '-f', dockerfile];\n for (const [k, v] of Object.entries(opts.buildArgs ?? {})) {\n args.push('--build-arg', `${k}=${v}`);\n }\n args.push(contextDir);\n if (process.env.AGENTBOX === '1') {\n args.splice(1, 0, '--network=host');\n }\n\n const subprocess = execa('docker', args, {\n stderr: 'pipe',\n stdout: 'pipe',\n });\n\n if (opts.onProgress) {\n const forward = (chunk: Buffer | string): void => {\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n }\n\n await subprocess;\n return ref;\n}\n\nexport interface PullOrBuildOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the staged runtime / monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /** `--build-arg K=V` pairs forwarded to the local `docker build` (ignored on a registry pull). */\n buildArgs?: Record<string, string>;\n}\n\n/**\n * Make `ref` present locally, preferring a registry pull over a local build.\n *\n * When `fingerprint` is non-null and pulling is allowed, pull the\n * fingerprint-tagged image and retag it to `ref`; on a miss (or when pulling\n * is disabled / unfingerprintable) build from the staged context. Either way,\n * a known fingerprint is stamped into docker-prepared.json so the next\n * `ensureImage()` treats this as a cache hit.\n */\nexport async function pullOrBuild(\n ref: string,\n fingerprint: { contextSha256: string; manifest?: FileManifest } | null,\n opts: PullOrBuildOptions = {},\n): Promise<{ source: 'pulled' | 'built' }> {\n const { writePreparedDockerState } = await import('./prepared-state.js');\n const registry = opts.registry ?? BOX_IMAGE_REGISTRY;\n const allowPull = opts.allowPull !== false;\n\n if (allowPull && registry && fingerprint) {\n const target = registryRefForSha(fingerprint.contextSha256, registry);\n const succeed = async (): Promise<{ source: 'pulled' }> => {\n await tagImage(target, ref);\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n opts.onProgress?.(`[image] pulled ${target} -> ${ref}`);\n return { source: 'pulled' };\n };\n\n opts.onProgress?.(`[image] pulling ${target}`);\n const first = await pullImage(target, { onProgress: opts.onProgress });\n if (first.ok) return succeed();\n\n const failure = first.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] pull failed (${failure.kind}): ${failure.detail}`);\n\n // A throttle or a credential problem is not a missing image: the tag is\n // there and an authenticated pull gets it. GHCR's anonymous limit is per-IP\n // and a machine that just baked a few times trips it, so borrowing the\n // host's `gh` token here is the difference between a retag and a ~10-minute\n // rebuild of an image that was already published.\n if (isAuthRetryable(failure.kind) && isGhcrTarget(target)) {\n opts.onProgress?.('[image] retrying authenticated with your `gh` token');\n const login = await loginToGhcrWithGh();\n if (login.ok) {\n const second = await pullImage(target, { onProgress: opts.onProgress });\n if (second.ok) return succeed();\n const f2 = second.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] authenticated pull also failed (${f2.kind}): ${f2.detail}`);\n } else {\n opts.onProgress?.(\n `[image] could not authenticate to ghcr.io: ${login.reason ?? 'unknown'}`,\n );\n }\n }\n\n opts.onProgress?.(`[image] building ${ref} locally instead`);\n }\n\n await buildImage({\n ref,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n buildArgs: opts.buildArgs,\n onProgress: opts.onProgress,\n });\n if (fingerprint) {\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n }\n return { source: 'built' };\n}\n\nexport interface EnsureImageOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /**\n * How Claude Code is installed into the image. Folded into the build-context\n * fingerprint so a mode switch rebuilds (and an npm image isn't clobbered by\n * a native rebuild). Defaults to the resolved `box.claudeInstall`.\n */\n claudeInstall?: 'native' | 'npm';\n}\n\nexport async function ensureImage(\n ref: string = DEFAULT_BOX_IMAGE,\n opts: EnsureImageOptions = {},\n): Promise<{ ref: string; built: boolean; reason?: string }> {\n // Lazy import: prepared-state imports back into image.ts for the default\n // DOCKERFILE_PATH/BUILD_CONTEXT_DIR constants, so loading it at top-level\n // would create a circular ESM init order.\n const { computeDockerContextFingerprint, readPreparedDockerState, preparedMatches } =\n await import('./prepared-state.js');\n\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const rawFingerprint = await computeDockerContextFingerprint({\n contextDir: opts.contextDir,\n });\n // Fold the install mode into the sha so native↔npm are distinct cache\n // identities (`native` leaves the hash unchanged).\n const fingerprint = rawFingerprint\n ? {\n ...rawFingerprint,\n contextSha256: claudeInstallFingerprint(rawFingerprint.contextSha256, claudeInstall),\n }\n : null;\n const prepared = readPreparedDockerState();\n const exists = await imageExists(ref);\n\n let reason: string | undefined;\n if (!exists) {\n reason = `image ${ref} not present`;\n } else if (!fingerprint) {\n // Couldn't enumerate the context (partial dev rebuild?). Don't rebuild\n // unconditionally — that would surprise users mid-iteration. Trust the\n // image-exists check and leave the prepared file untouched.\n return { ref, built: false, reason: 'image present (fingerprint skipped)' };\n } else if (!prepared) {\n reason = 'no docker-prepared.json on disk';\n } else if (!preparedMatches(prepared, fingerprint.contextSha256)) {\n reason =\n `build context changed (was ${prepared.base?.contextSha256?.slice(0, 12) ?? '<none>'}, ` +\n `now ${fingerprint.contextSha256.slice(0, 12)})`;\n }\n\n if (!reason) {\n return { ref, built: false, reason: 'image up to date' };\n }\n\n opts.onProgress?.(`[image] ${ref}: ${reason}`);\n const npm = claudeInstall === 'npm';\n const { source } = await pullOrBuild(ref, fingerprint, {\n onProgress: opts.onProgress,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n // npm mode pulls too. CI publishes both install variants, and `fingerprint`\n // is already folded with the mode above — so the pull asks for the npm\n // image's own tag and hits. (It used to be native-only, which meant npm\n // users rebuilt the image locally on every first create, forever.) A tag\n // that genuinely isn't published still falls back to a local build.\n allowPull: opts.allowPull,\n registry: opts.registry,\n buildArgs: npm ? { AGENTBOX_CLAUDE_INSTALL: 'npm' } : undefined,\n });\n return { ref, built: source === 'built', reason };\n}\n\n/**\n * Read-only freshness classification of the docker base image, for surfaces\n * (hub API, tray) that want to announce an upcoming bake without triggering\n * it. `unknown` means \"couldn't fingerprint\" and MUST stay inert — the\n * matching `ensureImage` path trusts the existing image and does not rebuild.\n */\nexport type DockerBaseFreshness =\n | { state: 'fresh' }\n | { state: 'unknown' }\n | { state: 'unprepared' }\n | { state: 'stale'; reason: string };\n\n/**\n * Pure decision core shared by `evaluateDockerBaseFreshness`. Mirrors\n * `ensureImage`'s rebuild predicate exactly — if the two ever disagree, the\n * freshness surfaces would announce a bake that create then skips (or miss\n * one it performs). `stampedSha` is `docker-prepared.json`'s fingerprint,\n * null when the stamp is missing/invalid.\n */\nexport function classifyDockerBaseFreshness(input: {\n imagePresent: boolean;\n fingerprint: string | null;\n stampedSha: string | null;\n}): DockerBaseFreshness {\n if (!input.imagePresent) return { state: 'unprepared' };\n if (!input.fingerprint) return { state: 'unknown' };\n if (!input.stampedSha) return { state: 'stale', reason: 'no docker-prepared.json on disk' };\n if (input.stampedSha !== input.fingerprint) {\n return {\n state: 'stale',\n reason:\n `build context changed (was ${input.stampedSha.slice(0, 12)}, ` +\n `now ${input.fingerprint.slice(0, 12)})`,\n };\n }\n return { state: 'fresh' };\n}\n\n/**\n * Cheap live check: would `ensureImage` bake on the next create? The only\n * docker work is one `docker image inspect`; the rest hashes the ~15 build\n * context files. Never builds, pulls, or writes the prepared stamp.\n */\nexport async function evaluateDockerBaseFreshness(\n opts: { ref?: string; claudeInstall?: 'native' | 'npm'; contextDir?: string } = {},\n): Promise<DockerBaseFreshness> {\n // Lazy import for the same circular-init reason as in ensureImage above.\n const { computeDockerContextFingerprint, readPreparedDockerState } =\n await import('./prepared-state.js');\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const imagePresent = await imageExists(ref);\n if (!imagePresent) return { state: 'unprepared' };\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const raw = await computeDockerContextFingerprint({ contextDir: opts.contextDir });\n return classifyDockerBaseFreshness({\n imagePresent,\n fingerprint: raw ? claudeInstallFingerprint(raw.contextSha256, claudeInstall) : null,\n stampedSha: readPreparedDockerState()?.base?.contextSha256 ?? null,\n });\n}\n","/**\n * Why a `docker pull` of the box image failed, and how to retry it authenticated.\n *\n * The box image is published to a PUBLIC GHCR repo, so an anonymous pull works —\n * until it doesn't. GHCR rate-limits anonymous pulls per IP, and a machine that\n * has just baked a few times trips it. `docker pull` then exits non-zero and the\n * caller falls back to a ~10-minute local build of an image that was sitting in\n * the registry all along. Worse, the old code returned a bare boolean, so a\n * rate-limit, a 401 and a genuinely-unpublished tag were indistinguishable and\n * none of them reached the log.\n *\n * So: classify the failure, and when it is a throttle/auth problem on GHCR,\n * borrow the host's `gh` token and retry once.\n *\n * The load-bearing subtlety is the SCOPE. `gh auth token` returns whatever the\n * user's `gh auth login` negotiated — by default `repo`, `read:org`, `gist`,\n * `workflow` and *not* `read:packages`. Logging in to GHCR with such a token is\n * actively worse than staying anonymous: the registry then evaluates an\n * identity that lacks package-read and answers 403, turning a pull that would\n * have succeeded into one that cannot. So we check the scope first and skip the\n * login when it is absent, telling the user the one command that fixes it.\n */\nimport { execa } from 'execa';\n\n/** GHCR is the only registry we know how to authenticate from `gh`. */\nexport const GHCR_HOST = 'ghcr.io';\n\n/** The scope GHCR requires to read a package, public or not. */\nconst PACKAGE_READ_SCOPE = 'read:packages';\n\nexport type PullFailureKind =\n /** GHCR throttled us — the tag exists and an authenticated retry should work. */\n | 'rate-limit'\n /** Credentials rejected or absent where required. */\n | 'unauthorized'\n /** The tag genuinely is not published — a local build is the correct answer. */\n | 'not-found'\n /** DNS / TCP / TLS — nothing to do with the tag. */\n | 'network'\n | 'unknown';\n\nexport interface PullFailure {\n kind: PullFailureKind;\n /** The most useful line of docker's own stderr, for the log. */\n detail: string;\n}\n\n/**\n * Map `docker pull` stderr onto a {@link PullFailureKind}. Substring matching on\n * docker/registry error text rather than exit codes, which are always 1.\n */\nexport function classifyPullFailure(stderr: string): PullFailure {\n const text = stderr.toLowerCase();\n const detail = lastMeaningfulLine(stderr);\n // Order matters: a throttle response also says \"unauthorized\" on some\n // registries, and it is the throttle that decides whether a retry can help.\n if (\n text.includes('toomanyrequests') ||\n text.includes('too many requests') ||\n text.includes('429')\n ) {\n return { kind: 'rate-limit', detail };\n }\n if (\n text.includes('manifest unknown') ||\n text.includes('not found') ||\n text.includes('404') ||\n text.includes('no such manifest')\n ) {\n return { kind: 'not-found', detail };\n }\n if (\n text.includes('unauthorized') ||\n text.includes('authentication required') ||\n text.includes('denied') ||\n text.includes('403')\n ) {\n return { kind: 'unauthorized', detail };\n }\n if (\n text.includes('dial tcp') ||\n text.includes('no such host') ||\n text.includes('timeout') ||\n text.includes('temporary failure in name resolution') ||\n text.includes('connection refused') ||\n text.includes('tls handshake')\n ) {\n return { kind: 'network', detail };\n }\n return { kind: 'unknown', detail };\n}\n\n/** The last non-empty stderr line, trimmed — docker puts the real error last. */\nfunction lastMeaningfulLine(stderr: string): string {\n const lines = stderr\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .filter((l) => l.length > 0);\n return lines.length > 0 ? lines[lines.length - 1]! : 'no error output from docker';\n}\n\n/** Only a throttle or a credential problem can be improved by authenticating. */\nexport function isAuthRetryable(kind: PullFailureKind): boolean {\n return kind === 'rate-limit' || kind === 'unauthorized';\n}\n\n/** True when `target` lives on GHCR, the only host we can log into from `gh`. */\nexport function isGhcrTarget(target: string): boolean {\n return target.startsWith(`${GHCR_HOST}/`);\n}\n\nexport interface GhcrLoginResult {\n ok: boolean;\n /** Why we did not (or could not) log in — always safe to show the user. */\n reason?: string;\n}\n\ninterface Runner {\n (\n file: string,\n args: string[],\n opts?: { input?: string },\n ): Promise<{\n exitCode: number | undefined;\n stdout: string;\n stderr: string;\n }>;\n}\n\nconst realRunner: Runner = async (file, args, opts) => {\n const r = await execa(file, args, {\n reject: false,\n timeout: 30_000,\n ...(opts?.input !== undefined ? { input: opts.input } : {}),\n });\n return { exitCode: r.exitCode, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };\n};\n\n/**\n * Log the local docker engine into GHCR using the host's `gh` token, so the\n * retry is authenticated (and rate-limited far more generously).\n *\n * Refuses rather than risks it when the token lacks `read:packages` — see the\n * module comment. `fetchScopes` is injected so this is testable without network.\n */\nexport async function loginToGhcrWithGh(\n opts: {\n run?: Runner;\n fetchScopes?: (token: string) => Promise<string[]>;\n } = {},\n): Promise<GhcrLoginResult> {\n const run = opts.run ?? realRunner;\n\n // Pinned to github.com: GHCR only accepts github.com tokens, while a bare\n // `gh auth token` returns the DEFAULT host's token — which for someone whose\n // gh is set up against GitHub Enterprise Server is an enterprise credential\n // we would then hand to ghcr.io.\n const tok = await run('gh', ['auth', 'token', '--hostname', 'github.com']);\n const token = tok.stdout.trim();\n if (tok.exitCode !== 0 || token.length === 0) {\n return {\n ok: false,\n reason:\n 'no github.com `gh` token on this machine (run `gh auth login --hostname github.com`)',\n };\n }\n\n const scopes = await (opts.fetchScopes ?? fetchTokenScopes)(token);\n // An empty list means we could not read the header (offline, or a fine-grained\n // token that reports no classic scopes). Attempting the login is then the\n // lesser evil: a fine-grained PAT with package-read is a normal setup, and a\n // failed login leaves us exactly where we already are.\n if (scopes.length > 0 && !scopes.includes(PACKAGE_READ_SCOPE)) {\n return {\n ok: false,\n reason:\n `your \\`gh\\` token lacks the ${PACKAGE_READ_SCOPE} scope, so authenticating would be ` +\n `rejected by ${GHCR_HOST}. Add it with: gh auth refresh -h github.com -s ${PACKAGE_READ_SCOPE}`,\n };\n }\n\n // GHCR ignores the username when the password is a valid token, but docker\n // requires a non-empty one.\n const login = await run('docker', ['login', GHCR_HOST, '-u', 'agentbox', '--password-stdin'], {\n input: token,\n });\n if (login.exitCode !== 0) {\n return { ok: false, reason: lastMeaningfulLine(login.stderr || login.stdout) };\n }\n return { ok: true };\n}\n\n/** Classic OAuth scopes for `token`, from GitHub's `x-oauth-scopes` header. */\nasync function fetchTokenScopes(token: string): Promise<string[]> {\n try {\n const res = await fetch('https://api.github.com/user', {\n headers: {\n Authorization: `Bearer ${token}`,\n Accept: 'application/vnd.github+json',\n 'User-Agent': 'agentbox',\n },\n signal: AbortSignal.timeout(10_000),\n });\n return (res.headers.get('x-oauth-scopes') ?? '')\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,SAAS,WAAAA,UAAS,WAAAC,gBAAe;AACjC,SAAS,iBAAAC,sBAAqB;ACZ9B,SAAS,SAAAC,cAAa;ACsBtB,SAAS,aAAa;ADdtB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,eAAe;ACe1B,IAAM,YAAY;AAGzB,IAAM,qBAAqB;AAuBpB,SAAS,oBAAoB,QAA6B;AAC/D,QAAM,OAAO,OAAO,YAAY;AAChC,QAAM,SAAS,mBAAmB,MAAM;AAGxC,MACE,KAAK,SAAS,iBAAiB,KAC/B,KAAK,SAAS,mBAAmB,KACjC,KAAK,SAAS,KAAK,GACnB;AACA,WAAO,EAAE,MAAM,cAAc,OAAO;EACtC;AACA,MACE,KAAK,SAAS,kBAAkB,KAChC,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,KAAK,KACnB,KAAK,SAAS,kBAAkB,GAChC;AACA,WAAO,EAAE,MAAM,aAAa,OAAO;EACrC;AACA,MACE,KAAK,SAAS,cAAc,KAC5B,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,QAAQ,KACtB,KAAK,SAAS,KAAK,GACnB;AACA,WAAO,EAAE,MAAM,gBAAgB,OAAO;EACxC;AACA,MACE,KAAK,SAAS,UAAU,KACxB,KAAK,S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AKhC;AACP,QAAM,QAAQ,aAAa;AAC3B,QAAM,QAA6B;IACjC,QAAQ;IACR,MAAM;MACJ,UAAU,KAAK,YAAY;MAC3B,eAAe,KAAK;MACpB,YAAY,MAAM;MAClB,WAAW,MAAM;MACjB,YAAW,oBAAI,KAAK,GAAE,YAAY;MAClC,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;IAC5C;EACF;AACA,wBAAsB,UAAU,KAAK;AACvC;AAGO,SAAS,gBAAgB,OAAmC,SAA0B;AAC3F,SAAO,OAAO,MAAM,kBAAkB;AACxC;","names":["dirname","resolve","fileURLToPath","execa","execa","writePreparedDockerState","computeDockerContextFingerprint","readPreparedDockerState","preparedMatches","here","dirname","fileURLToPath","resolve"]}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
handleLifecycleError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VY54AX4T.js";
|
|
5
5
|
import {
|
|
6
6
|
ensureRelay,
|
|
7
7
|
getRelayStatus,
|
|
8
8
|
rehydrateRelayRegistry,
|
|
9
9
|
stopRelay
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
loadEffectiveConfig
|
|
13
|
-
} from "./chunk-NHVGKFVY.js";
|
|
10
|
+
} from "./chunk-EPFXLXCW.js";
|
|
14
11
|
import {
|
|
15
12
|
readState
|
|
16
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OKLEPEWZ.js";
|
|
14
|
+
import {
|
|
15
|
+
loadEffectiveConfig
|
|
16
|
+
} from "./chunk-7LNXTPEE.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/relay.ts
|
|
19
|
+
import { readFile } from "fs/promises";
|
|
19
20
|
import { log, spinner } from "@clack/prompts";
|
|
20
21
|
import { Command } from "commander";
|
|
21
22
|
async function probeControlPlane() {
|
|
@@ -40,7 +41,8 @@ async function probeControlPlane() {
|
|
|
40
41
|
function renderControlPlane(cp) {
|
|
41
42
|
const head = `control box: ${cp.reachable ? "reachable" : "UNREACHABLE"} (this PC operates through it)`;
|
|
42
43
|
const lines = [head, ` url: ${cp.url}`];
|
|
43
|
-
if (cp.reachable)
|
|
44
|
+
if (cp.reachable)
|
|
45
|
+
lines.push(` health: ${String(cp.boxes ?? 0)} box(es), ${String(cp.events ?? 0)} event(s)`);
|
|
44
46
|
return lines.join("\n");
|
|
45
47
|
}
|
|
46
48
|
async function rehydrateFromState() {
|
|
@@ -67,7 +69,9 @@ async function rehydrateFromState() {
|
|
|
67
69
|
function renderStatus(s) {
|
|
68
70
|
if (s.running && s.health) {
|
|
69
71
|
return [
|
|
70
|
-
|
|
72
|
+
// A hub answering here means no lean relay process exists at all — and no
|
|
73
|
+
// relay.pid, which is why `pid` falls back to the one /healthz reports.
|
|
74
|
+
s.health.ui === true ? "relay: running (served by the hub)" : "relay: running",
|
|
71
75
|
` pid: ${s.pid === null ? "?" : String(s.pid)}`,
|
|
72
76
|
` port: ${String(s.port)}`,
|
|
73
77
|
` url: ${s.endpoint.hostUrl}`,
|
|
@@ -111,13 +115,34 @@ var stopSub = new Command("stop").description("Stop the host relay process (idem
|
|
|
111
115
|
handleLifecycleError(err);
|
|
112
116
|
}
|
|
113
117
|
});
|
|
118
|
+
async function startAndReport(s) {
|
|
119
|
+
await ensureRelay();
|
|
120
|
+
await rehydrateFromState();
|
|
121
|
+
const status = await getRelayStatus();
|
|
122
|
+
if (!status.running) {
|
|
123
|
+
s.stop("relay failed to start");
|
|
124
|
+
log.error(`nothing is answering /healthz on ${status.endpoint.hostUrl}`);
|
|
125
|
+
const tail = await tailLog(status.logFile);
|
|
126
|
+
log.info(tail ? `last lines of ${status.logFile}:
|
|
127
|
+
${tail}` : `see ${status.logFile}`);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
const what = status.health?.ui === true ? "hub (serving the relay)" : "relay";
|
|
131
|
+
s.stop(`${what} running on ${status.endpoint.hostUrl}`);
|
|
132
|
+
}
|
|
133
|
+
async function tailLog(file) {
|
|
134
|
+
try {
|
|
135
|
+
const lines = (await readFile(file, "utf8")).split("\n").filter((l) => l.trim().length > 0);
|
|
136
|
+
return lines.slice(-10).join("\n");
|
|
137
|
+
} catch {
|
|
138
|
+
return "";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
114
141
|
var startSub = new Command("start").description("Start the host relay if not already running (idempotent)").action(async () => {
|
|
115
142
|
try {
|
|
116
143
|
const s = spinner();
|
|
117
144
|
s.start("starting relay");
|
|
118
|
-
|
|
119
|
-
await rehydrateFromState();
|
|
120
|
-
s.stop(`relay running on ${ep.hostUrl}`);
|
|
145
|
+
await startAndReport(s);
|
|
121
146
|
} catch (err) {
|
|
122
147
|
handleLifecycleError(err);
|
|
123
148
|
}
|
|
@@ -133,9 +158,7 @@ var restartSub = new Command("restart").description("Stop then start the host re
|
|
|
133
158
|
const s2 = spinner();
|
|
134
159
|
s2.start("starting relay");
|
|
135
160
|
try {
|
|
136
|
-
|
|
137
|
-
await rehydrateFromState();
|
|
138
|
-
s2.stop(`relay running on ${ep.hostUrl}`);
|
|
161
|
+
await startAndReport(s2);
|
|
139
162
|
} catch (err) {
|
|
140
163
|
s2.stop("relay start failed");
|
|
141
164
|
log.warn(err instanceof Error ? err.message : String(err));
|
|
@@ -151,4 +174,4 @@ export {
|
|
|
151
174
|
rehydrateFromState,
|
|
152
175
|
relayCommand
|
|
153
176
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
177
|
+
//# sourceMappingURL=chunk-HNWZO2XU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/relay.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { log, spinner } from '@clack/prompts';\nimport {\n ensureRelay,\n getRelayStatus,\n rehydrateRelayRegistry,\n stopRelay,\n type RelayStatus,\n} from '@agentbox/sandbox-docker';\nimport { readState } from '@agentbox/sandbox-core';\nimport { loadEffectiveConfig } from '@agentbox/config';\nimport { Command } from 'commander';\nimport { handleLifecycleError } from './_errors.js';\n\ninterface ControlPlaneInfo {\n url: string;\n reachable: boolean;\n boxes?: number;\n events?: number;\n}\n\n/**\n * Probe the configured control box (`relay.controlPlaneUrl`) `/healthz`, so\n * `relay status` shows the intermediary the PC operates through. Returns null\n * when no control box is configured. Never throws (an unreachable box is a\n * status line, not an error).\n */\nasync function probeControlPlane(): Promise<ControlPlaneInfo | null> {\n let url = '';\n try {\n const cfg = await loadEffectiveConfig(process.cwd());\n url = (cfg.effective.relay.controlPlaneUrl ?? '').replace(/\\/$/, '');\n } catch {\n return null;\n }\n if (!url) return null;\n try {\n const ctrl = AbortSignal.timeout(6000);\n const res = await fetch(`${url}/healthz`, { signal: ctrl });\n if (!res.ok) return { url, reachable: false };\n const body = (await res.json()) as { boxes?: number; events?: number };\n return { url, reachable: true, boxes: body.boxes, events: body.events };\n } catch {\n return { url, reachable: false };\n }\n}\n\nfunction renderControlPlane(cp: ControlPlaneInfo): string {\n const head = `control box: ${cp.reachable ? 'reachable' : 'UNREACHABLE'} (this PC operates through it)`;\n const lines = [head, ` url: ${cp.url}`];\n if (cp.reachable)\n lines.push(` health: ${String(cp.boxes ?? 0)} box(es), ${String(cp.events ?? 0)} event(s)`);\n return lines.join('\\n');\n}\n\n/**\n * After a fresh relay process starts (cold start or restart), it has no\n * in-memory box registry — and for cloud boxes that means no `CloudBoxPoller`\n * is running. Re-push every persisted (id, token, kind, preview…) so the\n * relay regains the same registry it had before the restart. Lifts the\n * cloud poller back up so status push + git push resume seamlessly.\n */\nexport async function rehydrateFromState(): Promise<void> {\n const state = await readState();\n await rehydrateRelayRegistry(\n state.boxes.map((b) => ({\n id: b.id,\n name: b.name,\n provider: b.provider,\n container: b.container,\n createdAt: b.createdAt,\n relayToken: b.relayToken,\n projectIndex: b.projectIndex,\n gitWorktrees: b.gitWorktrees,\n cloudBackend: b.cloud?.backend,\n relayPreviewUrl: b.cloud?.relayPreviewUrl,\n relayPreviewToken: b.cloud?.relayPreviewToken,\n bridgeToken: b.cloud?.bridgeToken,\n autoApproveHostActions: b.autoApproveHostActions,\n autoApproveSafeHostActions: b.autoApproveSafeHostActions,\n })),\n );\n}\n\ninterface StatusOpts {\n json?: boolean;\n}\n\nfunction renderStatus(s: RelayStatus): string {\n if (s.running && s.health) {\n return [\n // A hub answering here means no lean relay process exists at all — and no\n // relay.pid, which is why `pid` falls back to the one /healthz reports.\n s.health.ui === true ? 'relay: running (served by the hub)' : 'relay: running',\n ` pid: ${s.pid === null ? '?' : String(s.pid)}`,\n ` port: ${String(s.port)}`,\n ` url: ${s.endpoint.hostUrl}`,\n ` version: ${s.health.version ?? '(unknown — relay predates version field)'}`,\n ` commit: ${s.health.commit ?? '(unknown)'}`,\n ` boxes: ${String(s.health.boxes)}`,\n ` events: ${String(s.health.events)}`,\n ` log: ${s.logFile}`,\n ].join('\\n');\n }\n if (s.pidAlive) {\n return [\n `relay: not responding (pid ${String(s.pid)} alive but /healthz silent)`,\n ` log: ${s.logFile}`,\n ].join('\\n');\n }\n return ['relay: not running', ` log: ${s.logFile}`].join('\\n');\n}\n\nconst statusSub = new Command('status')\n .description('Show whether the host relay is running, with pid / port / box count')\n .option('--json', 'emit RelayStatus as JSON')\n .action(async (opts: StatusOpts) => {\n try {\n const [s, cp] = await Promise.all([getRelayStatus(), probeControlPlane()]);\n if (opts.json) {\n process.stdout.write(JSON.stringify({ ...s, controlPlane: cp }, null, 2) + '\\n');\n return;\n }\n process.stdout.write(renderStatus(s) + '\\n');\n if (cp) process.stdout.write('\\n' + renderControlPlane(cp) + '\\n');\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\nconst stopSub = new Command('stop')\n .description('Stop the host relay process (idempotent)')\n .action(async () => {\n try {\n const s = spinner();\n s.start('stopping relay');\n const result = await stopRelay();\n s.stop(\n result.stopped ? `stopped relay (pid ${String(result.pid)})` : 'relay was not running',\n );\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\n/**\n * Bring the relay up and REPORT WHAT IS ACTUALLY THERE.\n *\n * `ensureRelay()` returning an endpoint is not proof of liveness — it also\n * returns when it reused an incumbent, handed off to a hub, or gave up on a pid\n * whose /healthz stays silent. Printing its URL unconditionally is how a relay\n * that died on EADDRINUSE reported success while the box's RPCs went to whatever\n * else held the port. So: re-probe, and say `hub` when a hub is what answers\n * (there is no lean relay process in that case).\n */\nasync function startAndReport(s: ReturnType<typeof spinner>): Promise<void> {\n await ensureRelay();\n await rehydrateFromState();\n const status = await getRelayStatus();\n if (!status.running) {\n s.stop('relay failed to start');\n log.error(`nothing is answering /healthz on ${status.endpoint.hostUrl}`);\n const tail = await tailLog(status.logFile);\n log.info(tail ? `last lines of ${status.logFile}:\\n${tail}` : `see ${status.logFile}`);\n process.exit(1);\n }\n const what = status.health?.ui === true ? 'hub (serving the relay)' : 'relay';\n s.stop(`${what} running on ${status.endpoint.hostUrl}`);\n}\n\n/** Last few non-empty lines of the relay log, or '' when unreadable. */\nasync function tailLog(file: string): Promise<string> {\n try {\n const lines = (await readFile(file, 'utf8')).split('\\n').filter((l) => l.trim().length > 0);\n return lines.slice(-10).join('\\n');\n } catch {\n return '';\n }\n}\n\nconst startSub = new Command('start')\n .description('Start the host relay if not already running (idempotent)')\n .action(async () => {\n try {\n const s = spinner();\n s.start('starting relay');\n await startAndReport(s);\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\nconst restartSub = new Command('restart')\n .description('Stop then start the host relay')\n .action(async () => {\n try {\n const s = spinner();\n s.start('stopping relay');\n const stopped = await stopRelay();\n s.stop(\n stopped.stopped ? `stopped relay (pid ${String(stopped.pid)})` : 'relay was not running',\n );\n const s2 = spinner();\n s2.start('starting relay');\n try {\n await startAndReport(s2);\n } catch (err) {\n s2.stop('relay start failed');\n log.warn(err instanceof Error ? err.message : String(err));\n throw err;\n }\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\nexport const relayCommand = new Command('relay')\n .description('Manage the host relay process (status / stop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bin/env node
|
|
2
2
|
import {
|
|
3
3
|
loadProviderModule
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WGNI24H2.js";
|
|
5
5
|
import {
|
|
6
6
|
isProviderKind
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7LNXTPEE.js";
|
|
8
8
|
|
|
9
9
|
// src/provider/cloud-backend.ts
|
|
10
10
|
async function cloudBackendForProvider(provider) {
|
|
@@ -21,4 +21,4 @@ export {
|
|
|
21
21
|
cloudBackendForProvider,
|
|
22
22
|
currentCloudBaseFingerprintLive
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-HO2ACZES.js.map
|
|
@@ -7,21 +7,21 @@ import {
|
|
|
7
7
|
hostKeyDir,
|
|
8
8
|
listHostAliases,
|
|
9
9
|
parseRemoteTarget
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RQURMAPA.js";
|
|
11
11
|
import {
|
|
12
12
|
HubApiError
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WHFCJBMO.js";
|
|
14
14
|
import {
|
|
15
15
|
quoteShellArg
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import {
|
|
18
|
-
loadEffectiveConfig
|
|
19
|
-
} from "./chunk-NHVGKFVY.js";
|
|
16
|
+
} from "./chunk-THUST2QK.js";
|
|
20
17
|
import {
|
|
21
18
|
mintSshKey,
|
|
22
19
|
resolveSshConfigTarget,
|
|
23
20
|
sshExec
|
|
24
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-OKLEPEWZ.js";
|
|
22
|
+
import {
|
|
23
|
+
loadEffectiveConfig
|
|
24
|
+
} from "./chunk-7LNXTPEE.js";
|
|
25
25
|
|
|
26
26
|
// src/control-plane/remote-docker-share.ts
|
|
27
27
|
import { readFile, rm } from "fs/promises";
|
|
@@ -164,7 +164,7 @@ async function locallySharedAliases() {
|
|
|
164
164
|
return out;
|
|
165
165
|
}
|
|
166
166
|
async function shareAfterAdd(alias) {
|
|
167
|
-
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-
|
|
167
|
+
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-UKKYXHIQ.js");
|
|
168
168
|
const cfg = await loadEffectiveConfig(process.cwd()).catch(() => null);
|
|
169
169
|
const url = cfg?.effective.relay.controlPlaneUrl;
|
|
170
170
|
if (!url) return;
|
|
@@ -192,7 +192,7 @@ The host is registered here, so \`agentbox docker:${alias} \u2026\` still works
|
|
|
192
192
|
async function syncSharedHosts(urlFlag, onLog) {
|
|
193
193
|
const aliases = await locallySharedAliases();
|
|
194
194
|
if (aliases.length === 0) return;
|
|
195
|
-
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-
|
|
195
|
+
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-UKKYXHIQ.js");
|
|
196
196
|
if (await localExposedLoopbackUrl().catch(() => null) !== null) return;
|
|
197
197
|
const client = await resolveHubApiClient(urlFlag, { quiet: true });
|
|
198
198
|
if (!client) {
|
|
@@ -210,9 +210,9 @@ var CONTROL_BOX_STATUS_MS = 5e3;
|
|
|
210
210
|
async function controlBoxKnowsHost(alias, effective) {
|
|
211
211
|
if (!alias || !effective.relay?.controlPlaneUrl) return false;
|
|
212
212
|
const [{ resolveHubApiTarget }, { HubApiClient }, { deadlineFetch, hostReachable }] = await Promise.all([
|
|
213
|
-
import("./control-plane-
|
|
214
|
-
import("./hub-api-client-
|
|
215
|
-
import("./dist-
|
|
213
|
+
import("./control-plane-UKKYXHIQ.js"),
|
|
214
|
+
import("./hub-api-client-5U6WOTZ3.js"),
|
|
215
|
+
import("./dist-VTLQKZ2E.js")
|
|
216
216
|
]);
|
|
217
217
|
const target = await resolveHubApiTarget(void 0, { quiet: true }).catch(() => null);
|
|
218
218
|
if (!target) return false;
|
|
@@ -225,7 +225,7 @@ async function controlBoxKnowsHost(alias, effective) {
|
|
|
225
225
|
return !!hosts?.some((h) => h.alias === alias);
|
|
226
226
|
}
|
|
227
227
|
async function hubCanRunEngine(providerName, remoteHost, effective) {
|
|
228
|
-
const { isHubRoutableProvider } = await import("./dist-
|
|
228
|
+
const { isHubRoutableProvider } = await import("./dist-FBM2WS5S.js");
|
|
229
229
|
if (isHubRoutableProvider(providerName)) return true;
|
|
230
230
|
if (providerName !== "remote-docker" || !remoteHost) return false;
|
|
231
231
|
if ((await locallySharedAliases()).includes(remoteHost)) return true;
|
|
@@ -246,4 +246,4 @@ export {
|
|
|
246
246
|
hubCanRunEngine,
|
|
247
247
|
unsharedHostReason
|
|
248
248
|
};
|
|
249
|
-
//# sourceMappingURL=chunk-
|
|
249
|
+
//# sourceMappingURL=chunk-HP4L45LW.js.map
|
|
@@ -26,7 +26,7 @@ async function controlBoxIsThisMachine() {
|
|
|
26
26
|
try {
|
|
27
27
|
const [{ readFile }, { controlPlaneDeployPath }] = await Promise.all([
|
|
28
28
|
import("fs/promises"),
|
|
29
|
-
import("./dist-
|
|
29
|
+
import("./dist-SMDXLPZO.js")
|
|
30
30
|
]);
|
|
31
31
|
const raw = await readFile(controlPlaneDeployPath(), "utf8");
|
|
32
32
|
return JSON.parse(raw).provider === "local";
|
|
@@ -39,7 +39,7 @@ async function dockerProviderRefusal(effective, providerName, remoteHost, contex
|
|
|
39
39
|
if (!dockerProvidersHidden(effective)) return null;
|
|
40
40
|
if (await controlBoxIsThisMachine()) return null;
|
|
41
41
|
if (providerName === "remote-docker") {
|
|
42
|
-
const { hubCanRunEngine } = await import("./remote-docker-share-
|
|
42
|
+
const { hubCanRunEngine } = await import("./remote-docker-share-RMS6IB5X.js");
|
|
43
43
|
if (await hubCanRunEngine(providerName, remoteHost, effective)) return null;
|
|
44
44
|
}
|
|
45
45
|
return dockerHiddenMessage(effective, context, remoteHost);
|
|
@@ -54,4 +54,4 @@ export {
|
|
|
54
54
|
controlBoxIsThisMachine,
|
|
55
55
|
dockerProviderRefusal
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-LHOKRCNF.js.map
|