@madarco/agentbox 0.28.1 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +146 -0
- package/dist/_cloud-attach-EUO2OL7W.js +30 -0
- package/dist/chunk-2JHPGPLE.js +71 -0
- package/dist/chunk-2JHPGPLE.js.map +1 -0
- package/dist/{chunk-JQLOGVZK.js → chunk-4KYP775X.js} +85 -21
- package/dist/chunk-4KYP775X.js.map +1 -0
- package/dist/{chunk-V5NWSLWD.js → chunk-4NUETVTR.js} +14 -14
- package/dist/{chunk-OXKW4GWD.js → chunk-53OTEDBS.js} +4 -70
- package/dist/chunk-53OTEDBS.js.map +1 -0
- package/dist/{chunk-FGQFVUMH.js → chunk-6YSYQZRH.js} +3 -3
- package/dist/{chunk-KFLGXE3R.js → chunk-73D2HKA3.js} +138 -24
- package/dist/chunk-73D2HKA3.js.map +1 -0
- package/dist/{chunk-HYXCH4GA.js → chunk-7LC5IG5K.js} +7 -7
- package/dist/{chunk-NHVGKFVY.js → chunk-7LNXTPEE.js} +340 -22
- package/dist/chunk-7LNXTPEE.js.map +1 -0
- package/dist/{chunk-74VIUGY6.js → chunk-A2TATHHJ.js} +6 -9
- package/dist/chunk-A2TATHHJ.js.map +1 -0
- package/dist/{chunk-YI4GHC2E.js → chunk-AC3HU25W.js} +12 -15
- package/dist/chunk-AC3HU25W.js.map +1 -0
- package/dist/{chunk-7ABO7OIF.js → chunk-AUHYXXCA.js} +4 -4
- package/dist/{chunk-FPMRFMVK.js → chunk-B4YFG5TB.js} +9 -9
- package/dist/{chunk-OUF3YTQO.js → chunk-BIKWXLX7.js} +14 -17
- package/dist/chunk-BIKWXLX7.js.map +1 -0
- package/dist/{chunk-CKD3PRON.js → chunk-CZPVVFCF.js} +12 -9
- package/dist/{chunk-CKD3PRON.js.map → chunk-CZPVVFCF.js.map} +1 -1
- package/dist/chunk-F4PPZ4SI.js +17 -0
- package/dist/chunk-F4PPZ4SI.js.map +1 -0
- package/dist/{chunk-BWM56FKY.js → chunk-FEFLAITR.js} +11 -11
- package/dist/{chunk-EVT2SNF2.js → chunk-FELVUIIM.js} +3 -3
- package/dist/{chunk-46NNZMZT.js → chunk-I2DEYQLZ.js} +372 -72
- package/dist/chunk-I2DEYQLZ.js.map +1 -0
- package/dist/{chunk-OUWVN2F2.js → chunk-I7BSBUPC.js} +16 -13
- package/dist/chunk-I7BSBUPC.js.map +1 -0
- package/dist/{chunk-G3H2L3O2.js → chunk-MNDKP4VS.js} +23 -3
- package/dist/chunk-MNDKP4VS.js.map +1 -0
- package/dist/{chunk-BUMKBUXS.js → chunk-PAWAGULH.js} +3 -3
- package/dist/{chunk-4PR3KJ5X.js → chunk-PFEBKXFD.js} +20 -20
- package/dist/{chunk-JDSYMTMS.js → chunk-QDU7YDME.js} +130 -66
- package/dist/chunk-QDU7YDME.js.map +1 -0
- package/dist/{chunk-JNC7MCWJ.js → chunk-S32GHLVU.js} +10 -10
- package/dist/chunk-S32GHLVU.js.map +1 -0
- package/dist/{chunk-WB6S4W7O.js → chunk-THKVKVRF.js} +2413 -1012
- package/dist/chunk-THKVKVRF.js.map +1 -0
- package/dist/{chunk-7RSE7ESY.js → chunk-UEEW5TW7.js} +27 -18
- package/dist/chunk-UEEW5TW7.js.map +1 -0
- package/dist/{chunk-B4DAH2F2.js → chunk-UTOC2NHC.js} +3 -3
- package/dist/{chunk-NHTRTST5.js → chunk-WDBDFLH3.js} +38 -15
- package/dist/chunk-WDBDFLH3.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-WJUKN4L4.js} +7 -6
- package/dist/chunk-WJUKN4L4.js.map +1 -0
- package/dist/{chunk-GFOWBXV7.js → chunk-XENTK32L.js} +463 -253
- package/dist/chunk-XENTK32L.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-YQFX2ILX.js} +19 -18
- package/dist/cp-hub-upload-RMJ3XJ65.js +81 -0
- package/dist/cp-hub-upload-RMJ3XJ65.js.map +1 -0
- package/dist/{custody-client-PNCC2HBJ.js → custody-client-L4FEFW4C.js} +5 -4
- package/dist/{deploy-hetzner-SSGSXAKA.js → deploy-hetzner-EECQ4JCM.js} +10 -10
- package/dist/{dist-RN6JOAG4.js → dist-3BKIPZR3.js} +81 -45
- package/dist/{dist-K5M4HKG7.js → dist-C5B6NGBO.js} +21 -9
- package/dist/{dist-6PYXFREL.js → dist-E5EXDZG4.js} +61 -16
- package/dist/dist-E5EXDZG4.js.map +1 -0
- package/dist/{dist-XATN4ZIR.js → dist-FBM2WS5S.js} +22 -4
- package/dist/{dist-XQLKK7H3.js → dist-NFF2KEMB.js} +54 -28
- package/dist/dist-NFF2KEMB.js.map +1 -0
- package/dist/{dist-5OR4QTQW.js → dist-NTUHJOK3.js} +9 -9
- package/dist/{dist-ZNQZHTUN.js → dist-PTYASENV.js} +35 -6
- package/dist/{dist-POILUDVJ.js → dist-Q4UDCSZQ.js} +9 -9
- package/dist/{dist-M4O5MU5K.js → dist-TXFTYNNE.js} +8 -8
- package/dist/{dist-EPFS5PRI.js → dist-XUOHE22G.js} +10 -10
- package/dist/{dist-SN2TCRZ5.js → dist-Z2TPC3EN.js} +9 -9
- package/dist/host-reach-drainer-N4JSFUBY.js +9 -0
- package/dist/hub-3HPYOV5O.js +37 -0
- package/dist/{hub-adopt-I44VGSBL.js → hub-adopt-NCCCMMXL.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-ZKAWXVPH.js} +16 -16
- package/dist/index.js +1321 -882
- package/dist/index.js.map +1 -1
- package/dist/prepare-KIVDQRMN.js +41 -0
- package/dist/prepared-custody-EFSOOAIQ.js +36 -0
- package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js → prepared-state-LNQ7DYSU-2YFSDOCV.js} +4 -3
- package/dist/{publish-credentials-BPHUO5VL.js → publish-credentials-F2A5OVCO.js} +11 -11
- package/dist/registry-O3X2CDDU.js +18 -0
- package/dist/relay-3T57T4RI.js +20 -0
- package/dist/relay-3T57T4RI.js.map +1 -0
- package/dist/{remote-docker-share-RX5ARK45.js → remote-docker-share-QDCBM5UM.js} +11 -11
- package/dist/remote-docker-share-QDCBM5UM.js.map +1 -0
- package/dist/tool-grant-push-6ISDIJKH.js +90 -0
- package/dist/tool-grant-push-6ISDIJKH.js.map +1 -0
- package/package.json +1 -2
- package/runtime/_shared/agentbox-tool-shim +21 -0
- package/runtime/_shared/ctl.cjs +6760 -5299
- package/runtime/_shared/gh-shim +103 -228
- package/runtime/digitalocean/agentbox-tool-shim +21 -0
- package/runtime/digitalocean/ctl.cjs +6760 -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 +6760 -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 +6760 -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 +6760 -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-QU3FFGJY.js → chunk-2WB3A5IN.js} +11 -14
- package/runtime/hub/apps/hub/{chunk-LPYK2354.js → chunk-5ABFGGPT.js} +339 -21
- package/runtime/hub/apps/hub/{chunk-VKOCY6SX.js → chunk-BI4MPGQT.js} +49 -14
- package/runtime/hub/apps/hub/{chunk-UMPTTQBE.js → chunk-G6FJR7TN.js} +461 -251
- package/runtime/hub/apps/hub/{chunk-KTVETF3F.js → chunk-QGAP34GN.js} +11 -8
- package/runtime/hub/apps/hub/{chunk-5TM7XXLT.js → chunk-QWSP6WJ2.js} +2833 -1277
- package/runtime/hub/apps/hub/{chunk-EZUK53CC.js → chunk-RPPOFMPA.js} +85 -21
- package/runtime/hub/apps/hub/{chunk-3LAHFDJF.js → chunk-VWQNSZGI.js} +22 -2
- 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-JVEDVVVG.js → dist-4F6XEJHK.js} +7 -7
- package/runtime/hub/apps/hub/{dist-2YP57GMB.js → dist-A3JOKKYG.js} +13 -13
- package/runtime/hub/apps/hub/{dist-D265LCAN.js → dist-CGH7PEMZ.js} +21 -3
- package/runtime/hub/apps/hub/{dist-SYWTB6RD.js → dist-F547YSBE.js} +15 -18
- package/runtime/hub/apps/hub/{dist-YK5FFPXZ.js → dist-FEHV4PC7.js} +62 -20
- package/runtime/hub/apps/hub/{dist-NKCXH5DW.js → dist-P7NT6VLK.js} +6 -6
- package/runtime/hub/apps/hub/{dist-E2FTSTCY.js → dist-W2YXTEQN.js} +34 -5
- package/runtime/hub/apps/hub/{dist-ELZHBQEM.js → dist-W5SGEJLA.js} +11 -11
- package/runtime/hub/apps/hub/{dist-N3E5YAYY.js → dist-YB3Y2XDK.js} +53 -26
- package/runtime/hub/apps/hub/{dist-5HTJSOHS.js → dist-ZTJMZLED.js} +19 -7
- 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-I5QBLSRU.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-4I7FNNNS.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 +16626 -14688
- package/runtime/vercel/agentbox-tool-shim +21 -0
- package/runtime/vercel/ctl.cjs +6760 -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-EUO2OL7W.js.map} +0 -0
- /package/dist/{chunk-V5NWSLWD.js.map → chunk-4NUETVTR.js.map} +0 -0
- /package/dist/{chunk-FGQFVUMH.js.map → chunk-6YSYQZRH.js.map} +0 -0
- /package/dist/{chunk-HYXCH4GA.js.map → chunk-7LC5IG5K.js.map} +0 -0
- /package/dist/{chunk-7ABO7OIF.js.map → chunk-AUHYXXCA.js.map} +0 -0
- /package/dist/{chunk-FPMRFMVK.js.map → chunk-B4YFG5TB.js.map} +0 -0
- /package/dist/{chunk-BWM56FKY.js.map → chunk-FEFLAITR.js.map} +0 -0
- /package/dist/{chunk-EVT2SNF2.js.map → chunk-FELVUIIM.js.map} +0 -0
- /package/dist/{chunk-BUMKBUXS.js.map → chunk-PAWAGULH.js.map} +0 -0
- /package/dist/{chunk-4PR3KJ5X.js.map → chunk-PFEBKXFD.js.map} +0 -0
- /package/dist/{chunk-B4DAH2F2.js.map → chunk-UTOC2NHC.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-YQFX2ILX.js.map} +0 -0
- /package/dist/{custody-client-PNCC2HBJ.js.map → custody-client-L4FEFW4C.js.map} +0 -0
- /package/dist/{deploy-hetzner-SSGSXAKA.js.map → deploy-hetzner-EECQ4JCM.js.map} +0 -0
- /package/dist/{dist-5OR4QTQW.js.map → dist-3BKIPZR3.js.map} +0 -0
- /package/dist/{dist-EPFS5PRI.js.map → dist-C5B6NGBO.js.map} +0 -0
- /package/dist/{dist-K5M4HKG7.js.map → dist-FBM2WS5S.js.map} +0 -0
- /package/dist/{dist-M4O5MU5K.js.map → dist-NTUHJOK3.js.map} +0 -0
- /package/dist/{dist-POILUDVJ.js.map → dist-PTYASENV.js.map} +0 -0
- /package/dist/{dist-RN6JOAG4.js.map → dist-Q4UDCSZQ.js.map} +0 -0
- /package/dist/{dist-SN2TCRZ5.js.map → dist-TXFTYNNE.js.map} +0 -0
- /package/dist/{dist-XATN4ZIR.js.map → dist-XUOHE22G.js.map} +0 -0
- /package/dist/{dist-ZNQZHTUN.js.map → dist-Z2TPC3EN.js.map} +0 -0
- /package/dist/{hub-MJ7O4WXW.js.map → host-reach-drainer-N4JSFUBY.js.map} +0 -0
- /package/dist/{hub-adopt-I44VGSBL.js.map → hub-3HPYOV5O.js.map} +0 -0
- /package/dist/{hub-api-client-WJPBXZAZ.js.map → hub-adopt-NCCCMMXL.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-ZKAWXVPH.js.map} +0 -0
- /package/dist/{prepared-custody-QIXW7MJM.js.map → prepare-KIVDQRMN.js.map} +0 -0
- /package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js.map → prepared-custody-EFSOOAIQ.js.map} +0 -0
- /package/dist/{relay-DRDELF6B.js.map → prepared-state-LNQ7DYSU-2YFSDOCV.js.map} +0 -0
- /package/dist/{publish-credentials-BPHUO5VL.js.map → publish-credentials-F2A5OVCO.js.map} +0 -0
- /package/dist/{remote-docker-share-RX5ARK45.js.map → registry-O3X2CDDU.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → nDHi_1342DzyGDC14ocQo}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → nDHi_1342DzyGDC14ocQo}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → nDHi_1342DzyGDC14ocQo}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/sandbox-e2b/src/env-loader.ts","../../../packages/sandbox-e2b/src/sdk.ts","../../../packages/sandbox-e2b/src/credentials.ts","../../../packages/sandbox-e2b/src/runtime-assets.ts","../../../packages/sandbox-e2b/src/prepared-state.ts"],"sourcesContent":["/**\n * E2B env auto-loader. The `e2b` SDK reads `E2B_API_KEY` (and optionally\n * `E2B_DOMAIN` for non-default deployments) from `process.env`. We seed those\n * from `~/.agentbox/secrets.env` (written by `agentbox e2b login`) so the SDK\n * Just Works after a one-time login — same pattern as the daytona / hetzner /\n * vercel env-loaders.\n *\n * Lookup order (first wins; process.env is never overwritten):\n * 1. `process.env` (already set in the shell).\n * 2. `~/.agentbox/secrets.env` — written by `agentbox e2b login`.\n *\n * Project-level `.env` / `.env.local` are intentionally NOT consulted: those\n * files belong to the app code being developed. Put host credentials in\n * `~/.agentbox/secrets.env` (or the shell env).\n *\n * Only E2B-prefixed keys are imported; the rest of the file is left alone.\n * Idempotent and side-effect-free after the first call.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { resolve } from 'node:path';\n\nconst E2B_KEYS = ['E2B_API_KEY', 'E2B_DOMAIN'] as const;\n\nlet loaded = false;\n\nexport function ensureE2bEnvLoaded(): void {\n if (loaded) return;\n loaded = true;\n importE2bFromFile(resolve(homedir(), '.agentbox', 'secrets.env'), E2B_KEYS);\n}\n\n/**\n * Force a re-read of `~/.agentbox/secrets.env`. Used by the interactive\n * `agentbox e2b login` flow after it persists the API key, so the same process\n * can pick it up without a restart.\n */\nexport function reloadE2bEnv(): void {\n loaded = false;\n ensureE2bEnvLoaded();\n}\n\nfunction importE2bFromFile(path: string, keys: readonly string[]): void {\n if (!existsSync(path)) return;\n let body: string;\n try {\n body = readFileSync(path, 'utf8');\n } catch {\n return;\n }\n const parsed = parseEnvFile(body);\n for (const key of keys) {\n if (process.env[key] !== undefined) continue;\n const value = parsed[key];\n if (typeof value === 'string') {\n process.env[key] = value;\n }\n }\n}\n\n/**\n * Minimal `.env` parser: handles `KEY=value`, `KEY=\"value\"`, `KEY='value'`,\n * `export KEY=value`, blank lines, and `#` comments. No variable interpolation\n * — predictable over feature-complete (matches the daytona / vercel loaders).\n */\nexport function parseEnvFile(body: string): Record<string, string> {\n const out: Record<string, string> = {};\n for (const rawLine of body.split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith('#')) continue;\n const stripped = line.startsWith('export ') ? line.slice('export '.length) : line;\n const eq = stripped.indexOf('=');\n if (eq <= 0) continue;\n const key = stripped.slice(0, eq).trim();\n let value = stripped.slice(eq + 1).trim();\n if (\n value.length >= 2 &&\n ((value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\")))\n ) {\n value = value.slice(1, -1);\n }\n out[key] = value;\n }\n return out;\n}\n","/**\n * Thin wrapper around the `e2b` SDK. Resolves the API key once and re-exports\n * the SDK surface the rest of the package uses from a single place (so tests\n * can mock `./sdk.js` instead of the package).\n *\n * E2B only ships one auth mode for first-party use: a single API key. The SDK\n * already reads `process.env.E2B_API_KEY` on each call, but we still expose\n * `resolveApiKey()` so callers can fail loud with an actionable error before\n * the SDK throws a generic \"401 unauthorized\" deep inside an op.\n */\n\nimport { Sandbox, Template } from 'e2b';\nimport { ensureE2bEnvLoaded } from './env-loader.js';\n\nexport { Sandbox, Template };\nexport type { SandboxOpts, SandboxInfo, SandboxState, SandboxListOpts, LogEntry, BuildInfo } from 'e2b';\n\n/**\n * Return the configured E2B API key. Throws an actionable error when nothing\n * is configured. Idempotent — env-loader caches itself after first call.\n */\nexport function resolveApiKey(): string {\n ensureE2bEnvLoaded();\n const k = process.env.E2B_API_KEY;\n if (!k) {\n throw new Error(\n 'E2B credentials not configured.\\n' +\n 'Run `agentbox e2b login` to paste your API key (from https://e2b.dev/dashboard?tab=keys), ' +\n 'or set E2B_API_KEY in the environment / ~/.agentbox/secrets.env.',\n );\n }\n return k;\n}\n\n/** True when an API key is configured. Used by the credential gate. */\nexport function hasUsableCredentials(): boolean {\n ensureE2bEnvLoaded();\n return Boolean(process.env.E2B_API_KEY);\n}\n","/**\n * Interactive E2B credential setup. Single mode — paste an API key from\n * https://e2b.dev/dashboard?tab=keys — much simpler than vercel's three-mode\n * flow. Persists to `~/.agentbox/secrets.env` (the canonical store, matching\n * daytona / hetzner / vercel).\n *\n * Non-interactive callers (no TTY): silent no-op, so scripted/CI runs surface\n * the SDK's own \"not configured\" error instead of hanging on a prompt.\n */\n\nimport { homedir } from 'node:os';\nimport { resolve } from 'node:path';\nimport {\n hostOpenCommand,\n publishManagedCredentials,\n writeManagedSecrets,\n type CredSetResult,\n} from '@agentbox/sandbox-core';\nimport {\n cancel,\n confirm,\n intro,\n isCancel,\n log,\n note,\n outro,\n password,\n} from '@clack/prompts';\nimport { ensureE2bEnvLoaded, reloadE2bEnv } from './env-loader.js';\nimport { hasUsableCredentials } from './sdk.js';\n\n// Ctrl+C at a prompt resolves with the cancel symbol; turn that into a real\n// quit so the command never silently continues as if the user answered \"No\".\nfunction exitOnCancel<T>(v: T | symbol): T {\n if (isCancel(v)) {\n cancel('Cancelled.');\n process.exit(130);\n }\n return v as T;\n}\n\nconst DASHBOARD_KEYS_URL = 'https://e2b.dev/dashboard?tab=keys';\n\n/**\n * Keys we manage in `~/.agentbox/secrets.env`. On reconfigure we strip prior\n * values for these before appending so the file never accumulates duplicates.\n */\nconst MANAGED_KEYS = ['E2B_API_KEY'] as const;\n\nexport interface EnsureE2bCredentialsOptions {\n /** Re-prompt even when valid credentials are already present (`agentbox e2b login`). */\n force?: boolean;\n}\n\nexport async function ensureE2bCredentials(\n opts: EnsureE2bCredentialsOptions = {},\n): Promise<void> {\n ensureE2bEnvLoaded();\n\n if (!opts.force && hasUsableCredentials()) return;\n if (!process.stdin.isTTY) return;\n\n intro('E2B setup');\n note(\n `AgentBox needs an E2B API key to provision sandboxes.\\n` +\n `Get one from ${DASHBOARD_KEYS_URL} (free tier available), then paste it below.\\n` +\n `The key is stored in \\`~/.agentbox/secrets.env\\` (mode 0600) — no .env.local harvesting.`,\n 'Credentials required',\n );\n\n const openIt = exitOnCancel(\n await confirm({\n message: `Open ${DASHBOARD_KEYS_URL} to create a key?`,\n initialValue: true,\n }),\n );\n if (openIt) openDashboard();\n\n const key = exitOnCancel(\n await password({\n message: 'Paste your E2B API key',\n validate: (v) => (v && v.trim().length > 0 ? undefined : 'Cannot be empty'),\n }),\n );\n\n persistCredentials({ apiKey: key.trim() });\n reloadE2bEnv();\n log.success(`E2B credentials saved to ${secretsPath()}`);\n // Also push to the hub (validates against the cloud + persists on the hub's\n // machine). The local write above stays because the direct IO plane still\n // needs it — see publishManagedCredentials. Intentional + temporary dual write.\n await publishManagedCredentials('e2b', { apiKey: key.trim() });\n outro('Setup complete.');\n}\n\nfunction persistCredentials(creds: { apiKey: string }): void {\n writeManagedSecrets(MANAGED_KEYS, { E2B_API_KEY: creds.apiKey });\n}\n\n/**\n * Non-interactive credential set (the headless path the hub drives). Takes an\n * `{ apiKey }`, persists it to `~/.agentbox/secrets.env`, and reports status.\n * E2B has no cheap read-only auth probe, so — like the interactive flow — we\n * only require a non-empty key; a bad key surfaces on first sandbox create.\n */\nexport function setE2bCredentials(fields: Record<string, string>): CredSetResult {\n const apiKey = (fields.apiKey ?? '').trim();\n if (!apiKey) {\n return { ok: false, error: 'apiKey is required', status: { configured: false } };\n }\n persistCredentials({ apiKey });\n const cred = readE2bCredStatus();\n return { ok: true, status: { configured: cred.auth !== 'none', label: cred.auth } };\n}\n\nfunction openDashboard(): void {\n import('node:child_process')\n .then(({ spawnSync }) => {\n const r = spawnSync(hostOpenCommand(), [DASHBOARD_KEYS_URL], { stdio: 'ignore' });\n if (r.status !== 0) {\n log.warn(`Could not auto-open the browser — visit ${DASHBOARD_KEYS_URL} manually.`);\n }\n })\n .catch(() => {\n log.warn(`Could not auto-open the browser — visit ${DASHBOARD_KEYS_URL} manually.`);\n });\n}\n\nexport function secretsPath(): string {\n return resolve(homedir(), '.agentbox', 'secrets.env');\n}\n\nexport interface E2bCredStatus {\n auth: 'key' | 'none';\n token?: string;\n source: 'env' | 'secrets.env' | 'none';\n}\n\nexport function readE2bCredStatus(): E2bCredStatus {\n const shellHad = process.env.E2B_API_KEY !== undefined;\n ensureE2bEnvLoaded();\n const key = process.env.E2B_API_KEY;\n if (!key) return { auth: 'none', source: 'none' };\n return { auth: 'key', token: key, source: shellHad ? 'env' : 'secrets.env' };\n}\n\nexport function maskKey(value: string): string {\n if (value.length <= 8) return '*'.repeat(value.length);\n return `${value.slice(0, 4)}…${'*'.repeat(8)}${value.slice(-4)}`;\n}\n","/**\n * Resolver for the runtime payload baked into the E2B base template during\n * `prepareE2b()`. Same idea as the vercel resolver: a flat list of files to\n * `template.copy` into the build context, each resolved from either the\n * staged CLI runtime tree or the monorepo source tree.\n *\n * Lookup order per file:\n * 1. The CLI's staged runtime tree: `<cliRoot>/e2b/...`.\n * 2. The monorepo source tree (dev fallback) under `packages/`.\n *\n * Any missing file throws a clear error naming the paths tried. Includes the\n * shared dockerd launch helper — E2B microVMs DO support nested containers, so\n * the base template bakes the docker engine (in-box DinD).\n */\n\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { resolveStagedRuntimeRoot } from '@agentbox/sandbox-core';\n\nconst SELF = dirname(fileURLToPath(import.meta.url));\n\nexport function findStagedCliRuntimeRoot(): string | undefined {\n return resolveStagedRuntimeRoot(SELF, 'e2b/scripts/build-template.sh');\n}\n\nexport interface RuntimeAsset {\n /** Logical name (used in error messages + log lines). */\n name: string;\n /** Absolute path inside the template's build filesystem (Template.copy target). */\n remotePath: string;\n /** File mode to apply after upload. */\n remoteMode: number;\n}\n\n/**\n * Where each asset lands inside the sandbox during template build. build-template.sh\n * reads them from these fixed paths. The agent/runtime helpers go straight to\n * /usr/local/bin via the script; baked config files to /tmp for the script to\n * `install` into place.\n */\nexport const RUNTIME_ASSETS: readonly RuntimeAsset[] = [\n { name: 'build-template.sh', remotePath: '/tmp/agentbox-build-template.sh', remoteMode: 0o755 },\n { name: 'agentbox-ctl', remotePath: '/tmp/agentbox-ctl', remoteMode: 0o755 },\n { name: 'agentbox-dockerd-start', remotePath: '/tmp/agentbox-dockerd-start', remoteMode: 0o755 },\n { name: 'agentbox-vnc-start', remotePath: '/tmp/agentbox-vnc-start', remoteMode: 0o755 },\n { name: 'agentbox-checkpoint-cleanup', remotePath: '/tmp/agentbox-checkpoint-cleanup', remoteMode: 0o755 },\n { name: 'agentbox-open', remotePath: '/tmp/agentbox-open', remoteMode: 0o755 },\n { name: 'gh-shim', remotePath: '/tmp/agentbox-gh-shim', remoteMode: 0o755 },\n { name: 'git-shim', remotePath: '/tmp/agentbox-git-shim', remoteMode: 0o755 },\n { name: 'ntn-shim', remotePath: '/tmp/agentbox-ntn-shim', remoteMode: 0o755 },\n { name: 'linear-shim', remotePath: '/tmp/agentbox-linear-shim', remoteMode: 0o755 },\n { name: 'custom-system-CLAUDE.md', remotePath: '/tmp/agentbox-custom-CLAUDE.md', remoteMode: 0o644 },\n { name: 'claude-managed-settings.json', remotePath: '/tmp/agentbox-managed-settings.json', remoteMode: 0o644 },\n { name: 'agentbox-codex-hooks.json', remotePath: '/tmp/agentbox-codex-hooks.json', remoteMode: 0o644 },\n { name: 'agentbox-setup-skill.md', remotePath: '/tmp/agentbox-setup-skill.md', remoteMode: 0o644 },\n] as const;\n\nexport interface ResolvedAsset extends RuntimeAsset {\n localPath: string;\n}\n\nexport function candidatesFor(\n name: string,\n opts: { cliRuntimeRoot?: string; repoRoot?: string } = {},\n): string[] {\n const cliRoot = opts.cliRuntimeRoot;\n const monorepo = opts.repoRoot ?? guessRepoRoot();\n\n const monorepoRelative: Record<string, string[]> = {\n 'build-template.sh': ['packages/sandbox-e2b/scripts/build-template.sh'],\n 'agentbox-ctl': ['packages/ctl/dist/bin.cjs'],\n 'agentbox-dockerd-start': ['packages/sandbox-docker/scripts/agentbox-dockerd-start'],\n 'agentbox-vnc-start': ['packages/sandbox-docker/scripts/agentbox-vnc-start'],\n 'agentbox-checkpoint-cleanup': ['packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup'],\n 'agentbox-open': ['packages/sandbox-docker/scripts/agentbox-open'],\n 'gh-shim': ['packages/sandbox-docker/scripts/gh-shim'],\n 'git-shim': ['packages/sandbox-docker/scripts/git-shim'],\n 'ntn-shim': ['packages/sandbox-docker/scripts/ntn-shim'],\n 'linear-shim': ['packages/sandbox-docker/scripts/linear-shim'],\n 'custom-system-CLAUDE.md': ['packages/sandbox-e2b/scripts/custom-system-CLAUDE.md'],\n 'claude-managed-settings.json': ['packages/sandbox-docker/scripts/claude-managed-settings.json'],\n 'agentbox-codex-hooks.json': ['packages/sandbox-docker/scripts/agentbox-codex-hooks.json'],\n 'agentbox-setup-skill.md': ['apps/cli/share/agentbox-setup/SKILL.md'],\n };\n\n const cliRelative: Record<string, string[]> = {\n 'build-template.sh': ['e2b/scripts/build-template.sh'],\n 'agentbox-ctl': ['e2b/ctl.cjs'],\n 'agentbox-dockerd-start': ['e2b/agentbox-dockerd-start', 'docker/packages/sandbox-docker/scripts/agentbox-dockerd-start'],\n 'agentbox-vnc-start': ['e2b/agentbox-vnc-start', 'docker/packages/sandbox-docker/scripts/agentbox-vnc-start'],\n 'agentbox-checkpoint-cleanup': ['e2b/agentbox-checkpoint-cleanup', 'docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup'],\n 'agentbox-open': ['e2b/agentbox-open', 'docker/packages/sandbox-docker/scripts/agentbox-open'],\n 'gh-shim': ['e2b/gh-shim', 'docker/packages/sandbox-docker/scripts/gh-shim'],\n 'git-shim': ['e2b/git-shim', 'docker/packages/sandbox-docker/scripts/git-shim'],\n 'ntn-shim': ['e2b/ntn-shim', 'docker/packages/sandbox-docker/scripts/ntn-shim'],\n 'linear-shim': ['e2b/linear-shim', 'docker/packages/sandbox-docker/scripts/linear-shim'],\n 'custom-system-CLAUDE.md': ['e2b/custom-system-CLAUDE.md'],\n 'claude-managed-settings.json': ['e2b/claude-managed-settings.json', 'docker/packages/sandbox-docker/scripts/claude-managed-settings.json'],\n 'agentbox-codex-hooks.json': ['e2b/agentbox-codex-hooks.json', 'docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json'],\n 'agentbox-setup-skill.md': ['e2b/agentbox-setup-skill.md', 'docker/apps/cli/share/agentbox-setup/SKILL.md'],\n };\n\n const out: string[] = [];\n if (cliRoot) {\n for (const rel of cliRelative[name] ?? []) out.push(resolve(cliRoot, rel));\n }\n for (const rel of monorepoRelative[name] ?? []) out.push(resolve(monorepo, rel));\n return out;\n}\n\nexport function resolveRuntimeAssets(\n opts: { cliRuntimeRoot?: string; repoRoot?: string } = {},\n): ResolvedAsset[] {\n const out: ResolvedAsset[] = [];\n const missing: Array<{ name: string; tried: string[] }> = [];\n for (const asset of RUNTIME_ASSETS) {\n const cands = candidatesFor(asset.name, opts);\n const hit = cands.find((p) => existsSync(p));\n if (!hit) {\n missing.push({ name: asset.name, tried: cands });\n continue;\n }\n out.push({ ...asset, localPath: hit });\n }\n if (missing.length > 0) {\n const lines = missing.flatMap((m) => [` - ${m.name}: tried`, ...m.tried.map((p) => ` ${p}`)]);\n throw new Error(\n `e2b: could not resolve runtime assets needed to bake the base template:\\n` +\n lines.join('\\n') +\n `\\n\\nIf running from the monorepo, ensure \\`pnpm -w build\\` has run so packages/ctl/dist/bin.cjs exists.`,\n );\n }\n return out;\n}\n\nfunction guessRepoRoot(): string {\n let cur = SELF;\n for (let i = 0; i < 8; i++) {\n if (existsSync(resolve(cur, 'pnpm-workspace.yaml'))) return cur;\n const parent = dirname(cur);\n if (parent === cur) break;\n cur = parent;\n }\n return SELF;\n}\n","/**\n * Persisted record of what `agentbox prepare --provider e2b` has built.\n * Lives at `~/.agentbox/e2b-prepared.json` so the auto-prepare gate\n * (`ensureE2bBaseTemplate()`) and `backend.provision` can resolve the base\n * template every box boots from.\n *\n * Single tier for now — the shared base template (Debian + agentbox-ctl +\n * agents). Templates on E2B are id+tag-addressed reusable resources, so unlike\n * Vercel snapshots we don't worry about per-box snapshot eviction; one template\n * is reused for every create.\n *\n * Schema versioned so future shape changes can migrate; only `schema: 1` is\n * accepted today.\n */\n\nimport { claudeInstallFingerprint, computeContextManifest,\n computeContextSha256, readPreparedStateRaw, writePreparedStateRaw, preparedStatePathFor,\n type FileManifest,\n} from '@agentbox/sandbox-core';\nimport { UserFacingError } from '@agentbox/core';\nimport { findStagedCliRuntimeRoot, resolveRuntimeAssets } from './runtime-assets.js';\n\nconst SCHEMA = 1 as const;\n\nexport interface PreparedE2bBase {\n /** Opaque E2B template id (e.g. `tmpl_xxxx` or `name:tag`). Sandbox.create({ template }) boots from this. */\n templateId: string;\n /** Human-friendly template name passed to Template.build (e.g. `agentbox-base:latest`). */\n templateName?: string;\n /** Deterministic SHA-256 of the build context (build script + assets). */\n contextSha256?: string;\n /**\n * Per-file digests of that context (relpath → sha256), so a later `stale`\n * verdict can name the files that changed. Optional: bases baked before\n * manifests existed simply lack it.\n */\n files?: FileManifest;\n /** Normalized `cpu-memory` GB size the template was baked with (absent = default resources). */\n size?: string;\n /** CLI version that produced this template (informational). */\n cliVersion?: string;\n /** Git short SHA of the CLI build (informational). */\n cliCommit?: string;\n /** ISO timestamp of bake completion. */\n createdAt: string;\n}\n\nexport interface PreparedE2bState {\n schema: typeof SCHEMA;\n /** The shared base template. Absent until first `agentbox prepare`. */\n base?: PreparedE2bBase;\n}\n\nexport function preparedStatePath(): string {\n return preparedStatePathFor('e2b');\n}\n\nexport function readPreparedState(): PreparedE2bState {\n const raw = readPreparedStateRaw('e2b');\n if (raw === null || typeof raw !== 'object') return { schema: SCHEMA };\n const parsed = raw as Partial<PreparedE2bState>;\n if (parsed.schema !== SCHEMA) {\n // Unknown/missing schema: refuse to read — the next prepare overwrites it.\n return { schema: SCHEMA };\n }\n return { schema: SCHEMA, base: parsed.base };\n}\n\nexport function writePreparedState(state: PreparedE2bState): void {\n writePreparedStateRaw('e2b', state);\n}\n\n/** Update one field of the state without forcing callers to read/merge/write. */\nexport function updatePreparedState(mutate: (s: PreparedE2bState) => void): void {\n const s = readPreparedState();\n mutate(s);\n writePreparedState(s);\n}\n\n/**\n * Compute the CURRENT build-context fingerprint for the e2b base template\n * (the SHA over every file `prepare` would copy into the Template build).\n * Side-effect-free — never builds. Returns `undefined` when the runtime\n * assets can't be resolved (dev tree without `pnpm -w build`) so the CLI\n * can degrade to \"can't tell, don't nag\" rather than flag a false stale.\n *\n * Used by `evaluateBaseFreshness` to compare against the stored value in\n * `e2b-prepared.json.base.contextSha256`. Must produce a byte-identical\n * hash to the one `prepare` writes — both go through the same\n * `resolveRuntimeAssets` + `computeContextSha256` chain.\n */\nexport async function currentE2bBaseFingerprintLive(\n claudeInstall: 'native' | 'npm' = 'native',\n): Promise<string | undefined> {\n try {\n const assets = resolveRuntimeAssets({ cliRuntimeRoot: findStagedCliRuntimeRoot() });\n // Fold in claudeInstall exactly as `prepare` does — otherwise an npm-baked\n // base never matches the stored (npm-folded) fingerprint.\n return claudeInstallFingerprint(\n await computeContextSha256(assets.map((a) => ({ rel: a.name, abs: a.localPath }))),\n claudeInstall,\n );\n } catch {\n return undefined;\n }\n}\n\n/**\n * First-use gate. If no base template is recorded, throw an actionable error\n * pointing at `agentbox prepare --provider e2b`. Called by `backend.provision`\n * (so `create` / `claude` trip it but `prepare` itself does not — same shape\n * as the hetzner/vercel gates).\n */\nexport function ensureE2bBaseTemplate(): void {\n const state = readPreparedState();\n if (state.base !== undefined) return;\n throw new UserFacingError(\n 'no E2B base template found.\\n' +\n 'Run `agentbox prepare --provider e2b` first — it bakes a custom template ' +\n 'with the agentbox runtime (agentbox-ctl, vscode user, claude/codex/opencode, tmux) ' +\n 'so per-box `create` boots ready in seconds.',\n );\n}\n\n/**\n * Per-file digests of the CURRENT runtime assets, for diffing against the\n * manifest stored at bake time so a `stale` verdict can name the changed files.\n * Same asset list the fingerprint uses — each provider resolves its own, so this\n * must live beside it rather than in a shared helper.\n *\n * `undefined` when the assets can't be resolved (dev tree without a build): the\n * caller then has nothing to compare and must not claim a diff.\n */\nexport async function currentE2bBaseFileHashes(): Promise<FileManifest | undefined> {\n try {\n const assets = resolveRuntimeAssets({ cliRuntimeRoot: findStagedCliRuntimeRoot() });\n return (\n await computeContextManifest(assets.map((a) => ({ rel: a.name, abs: a.localPath })))\n ).files;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,SAAS,eAAe;ACVxB,SAAS,SAAS,gBAAgB;ACDlC,SAAS,WAAAA,gBAAe;AACxB,SAAS,WAAAC,gBAAe;AAOxB;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;OACK;ACZP,SAAS,cAAAC,mBAAkB;AAC3B,SAAS,SAAS,WAAAC,gBAAe;AACjC,SAAS,qBAAqB;AHM9B,IAAM,WAAW,CAAC,eAAe,YAAY;AAE7C,IAAI,SAAS;AAEN,SAAS,qBAA2B;AACzC,MAAI,OAAQ;AACZ,WAAS;AACT,oBAAkB,QAAQ,QAAQ,GAAG,aAAa,aAAa,GAAG,QAAQ;AAC5E;AAOO,SAAS,eAAqB;AACnC,WAAS;AACT,qBAAmB;AACrB;AAEA,SAAS,kBAAkB,MAAc,MAA+B;AACtE,MAAI,CAAC,WAAW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ve","existsSync","resolve","resolve","homedir","existsSync"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/hub.ts","../src/commands/install-portless.ts","../src/portless-prompt.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { readFile } from 'node:fs/promises';\nimport { log, spinner } from '@clack/prompts';\nimport { loadEffectiveConfig } from '@agentbox/config';\nimport {\n ensureHub,\n getHubStatus,\n stopHub,\n controlPlaneDeployPath,\n hostOpenCommand,\n type HubStatus,\n type ControlPlaneDeployRecord,\n} from '@agentbox/sandbox-core';\nimport { Command } from 'commander';\nimport { handleLifecycleError } from './_errors.js';\nimport { rehydrateFromState } from './relay.js';\nimport { ensurePortlessProxyQuietly, resolvePortlessEnabled } from '../portless-prompt.js';\nimport {\n resolveCustodyApiTarget,\n resolveHubApiTarget,\n controlPlaneSubcommands,\n probeControlPlaneStatus,\n localExposedLoopbackUrl,\n} from './control-plane.js';\nimport { restoreTunnelIfExposed, stopTunnelIfExposed } from '../control-plane/expose.js';\nimport { loadControlPlaneEnv } from '../control-plane/env-file.js';\nimport { channelOfVersion } from '../lib/channel.js';\nimport { AGENTBOX_VERSION } from '../version.js';\nimport { CustodyClient } from '../control-plane/custody-client.js';\nimport { HubApiClient } from '../control-plane/hub-api-client.js';\nimport type { HubApiBox } from '../control-plane/hub-api-client.js';\nimport { pullBoxSshKeys } from '../control-plane/hub-pull.js';\nimport { adoptHubBox, HubBoxNotFoundError } from '../control-plane/hub-adopt.js';\n\n/**\n * Resolve `portless.enabled` and, when the user has opted in, make sure a proxy\n * is actually up before the hub reports its URL — a proxy does not survive a\n * reboot, so \"the hub is on agentbox.localhost\" was regularly a lie. Only\n * `true` starts one: an unset preference still registers the alias (that costs\n * nothing) but must not spawn a daemon nobody asked for.\n */\nasync function resolvePortlessForHub(): Promise<boolean | undefined> {\n const enabled = await resolvePortlessEnabled();\n if (enabled === true) await ensurePortlessProxyQuietly();\n return enabled;\n}\n\n/** Best-effort: open the hub URL in the host browser (never throws). */\nfunction openInBrowser(url: string): void {\n try {\n const child = spawn(hostOpenCommand(), [url], { detached: true, stdio: 'ignore' });\n child.unref();\n } catch {\n /* the caller has already printed the URL */\n }\n}\n\n/**\n * The client-facing hub the CLI + tray talk to. `mode` is `remote` when a control\n * box is configured, else `local`. `token` is the single Bearer that authorizes\n * both `/api/v1` and the `/api/events` SSE stream (the local hub token, or\n * `AGENTBOX_HUB_API_KEY` for the remote control box).\n */\nexport interface HubTarget {\n mode: 'local' | 'remote';\n url: string;\n token: string;\n /**\n * Whether that hub is a process on THIS machine. `mode` alone can't answer it:\n * a `hub expose`-d machine is its own control box, so it is `remote`-shaped\n * (password profile, keyed by `AGENTBOX_HUB_API_KEY`) while still running\n * here. Callers that need to *start* or *stop* the hub — rather than merely\n * call it — have to branch on this, not on `mode`.\n */\n onThisMachine: boolean;\n}\n\n/**\n * Resolve the hub the CLI should talk to: the remote control box when one is\n * configured (`--url` > `relay.controlPlaneUrl`, with `AGENTBOX_HUB_API_KEY`),\n * else the local hub (`127.0.0.1:<port>` + `~/.agentbox/hub/token`). Surfaced to\n * the macOS tray via `agentbox hub target --json` so it follows the same config\n * (it can't parse the layered config itself). One Bearer authorizes both surfaces\n * in either mode (see `apps/hub/proxy.ts`).\n *\n * `preferLocal` prefers the hub on THIS machine even when a remote control box is\n * configured — the \"which hub\" knob for callers that have decided an operation\n * belongs here (e.g. a `cloud.viaHub=false` bake, or a base whose artifact lands\n * here). It skips only the configured REMOTE control-plane URL; it does NOT skip\n * the loopback branch, because a `hub expose`-d machine's hub IS on this machine\n * yet runs the password profile (its `/api/v1` wants `AGENTBOX_HUB_API_KEY` over\n * loopback, not the plain `~/.agentbox/hub/token`). Same precedence ladder as the\n * default, minus the remote URL — never a second resolver that could disagree.\n */\nexport async function resolveHubTarget(\n urlFlag?: string,\n opts: { preferLocal?: boolean } = {},\n): Promise<HubTarget> {\n const cfg = await loadEffectiveConfig(process.cwd());\n const url = (urlFlag ?? cfg.effective.relay.controlPlaneUrl ?? '').replace(/\\/$/, '');\n // A control box that IS this machine (`hub expose`) is reached over loopback,\n // not the box-facing LAN/tunnel URL — but it's still the `remote`-shaped API\n // (password profile, /api/v1 keyed by AGENTBOX_HUB_API_KEY). This is ALSO the\n // `preferLocal` answer for an exposed machine: the hub is right here, so the\n // plain local-hub token below would 401 against its password profile.\n //\n // Checked BEFORE the configured URL is required, because the two can disagree:\n // `hub unset-url` clears the config but leaves the exposed record, and the hub\n // keeps running the password profile. Falling through to local mode then\n // handed out the localhost token — which that hub does not accept — so\n // `hub target`, and the tray that follows it, pointed at the wrong credential.\n const loopback = urlFlag ? null : await localExposedLoopbackUrl();\n if (loopback) {\n loadControlPlaneEnv();\n return {\n mode: 'remote',\n url: loopback,\n token: process.env.AGENTBOX_HUB_API_KEY ?? '',\n onThisMachine: true,\n };\n }\n // The configured REMOTE control box — skipped under preferLocal so the caller\n // gets this machine's plain local hub instead (the not-exposed local case).\n if (url && !opts.preferLocal) {\n loadControlPlaneEnv();\n return {\n mode: 'remote',\n url,\n token: process.env.AGENTBOX_HUB_API_KEY ?? '',\n onThisMachine: false,\n };\n }\n const s = await getHubStatus();\n return {\n mode: 'local',\n url: `http://127.0.0.1:${String(s.port)}`,\n token: s.token ?? '',\n onThisMachine: true,\n };\n}\n\ninterface StatusOpts {\n url?: string;\n json?: boolean;\n}\n\nfunction renderStatus(s: HubStatus, exposed?: ControlPlaneDeployRecord | null): string {\n // The exposed CONFIG is a property of the machine, not of the running process,\n // so it is reported whether or not the hub is up. Reporting it only while\n // running made a stopped control box look like a plain local hub — with\n // autostart still installed and boxes still pointed at it.\n const exposedLines = exposed\n ? [\n ...(exposed.publicUrl ? [` box-facing url: ${exposed.publicUrl}`] : []),\n ...(exposed.tunnel ? [` tunnel: ${exposed.tunnel}`] : []),\n ...(exposed.autostart ? [' autostart: on'] : []),\n ]\n : [];\n if (s.running) {\n // `mode` describes the PROCESS, so it stays keyed on the live profile: a hub\n // running plain on a machine that is configured exposed is exactly the\n // mismatch worth seeing.\n const mode =\n s.profile === 'hetzner'\n ? [` mode: exposed (control box${s.worker ? ', worker on' : ''})`]\n : exposed\n ? [' mode: NOT exposed yet (configured, but this process is the plain hub)']\n : [];\n return [\n `hub: running${s.ui ? '' : ' (bare relay on the port — no UI; run `agentbox hub start`)'}`,\n ` pid: ${s.pid === null ? '?' : String(s.pid)}`,\n ` port: ${String(s.port)}`,\n ` url: ${s.openUrl}`,\n ...mode,\n ...exposedLines,\n ` log: ${s.logFile}`,\n ].join('\\n');\n }\n const stoppedExposed = exposed ? [' mode: exposed (configured; the hub is not running)'] : [];\n if (s.pidAlive) {\n return [\n `hub: not responding (pid ${String(s.pid)} alive but /healthz silent)`,\n ...stoppedExposed,\n ...exposedLines,\n ` log: ${s.logFile}`,\n ].join('\\n');\n }\n return ['hub: not running', ...stoppedExposed, ...exposedLines, ` log: ${s.logFile}`].join(\n '\\n',\n );\n}\n\n/**\n * What `hub deploy` recorded for the control box at `url` — the only trace of\n * which build a remote hub is running (the VPS keeps no version marker, and in\n * package mode not even a git checkout to `rev-parse`). Matched on URL so a\n * `--url` probe of somebody else's hub doesn't get this machine's record.\n * Best-effort: an absent or unreadable record just omits the line.\n */\nasync function readDeployRecordFor(url: string): Promise<ControlPlaneDeployRecord | null> {\n try {\n const rec = JSON.parse(\n await readFile(controlPlaneDeployPath(), 'utf8'),\n ) as ControlPlaneDeployRecord;\n return rec.url === url ? rec : null;\n } catch {\n return null;\n }\n}\n\n/** The deploy record for a control box that IS this machine (`hub expose`), or null. */\nasync function readLocalDeployRecord(): Promise<ControlPlaneDeployRecord | null> {\n try {\n const rec = JSON.parse(\n await readFile(controlPlaneDeployPath(), 'utf8'),\n ) as ControlPlaneDeployRecord;\n return rec.provider === 'local' ? rec : null;\n } catch {\n return null;\n }\n}\n\nexport interface RemoteHubBuild {\n /** The version the hub reports, else the version that was deployed. */\n version: string | null;\n /** Where `version` came from — a live probe beats a local record. */\n versionSource: 'live' | 'deployed' | null;\n /** `nightly` / `stable`, or `source (<ref>)` for a build-from-source box. */\n channel: string | null;\n /** The deploy record's build line, e.g. `@madarco/agentbox@0.28.0 (npm)`. */\n build: string | null;\n /** Set when the control box runs a different version than this CLI. */\n drift: string | null;\n}\n\n/**\n * Reconcile what the hub reports with what this machine deployed.\n *\n * The live version wins: the record only says what was last *deployed*, which is\n * wrong after a failed update, and is absent entirely for a hub someone else set\n * up. A control box built before the images exported `AGENTBOX_CLI_VERSION`\n * reports nothing, so the record is the fallback rather than the source.\n *\n * Pure so the precedence is unit-testable.\n */\nexport function describeRemoteHubBuild(input: {\n liveVersion?: string | undefined;\n record: ControlPlaneDeployRecord | null;\n cliVersion: string;\n}): RemoteHubBuild {\n const source = input.record?.source ?? null;\n const build = source\n ? source.kind === 'package'\n ? `@madarco/agentbox@${source.spec} (npm)`\n : `${source.repoUrl}@${source.repoRef} (built from source)`\n : null;\n // A spec may be a dist-tag or a range (`--package nightly`), not a version.\n // Treating one as a version would print `version: nightly` and, worse, classify\n // it `stable` — `channelOfVersion` only looks for a `-nightly.` suffix. Until\n // the hub reports what it actually installed, we simply don't know.\n const deployedVersion =\n source?.kind === 'package' && /^\\d+\\.\\d+\\.\\d+/.test(source.spec) ? source.spec : null;\n const version = input.liveVersion ?? deployedVersion;\n const versionSource = input.liveVersion ? 'live' : deployedVersion ? 'deployed' : null;\n // A source build's \"channel\" is the ref itself — which is the branch the user\n // actually cares about (`nightly`, `main`, a feature branch).\n const channel =\n source?.kind === 'source'\n ? `source (${source.repoRef})`\n : version\n ? channelOfVersion(version)\n : null;\n // Only meaningful for a version we know is live; a stale record would nag forever.\n const drift =\n input.liveVersion && input.liveVersion !== input.cliVersion\n ? `this CLI is ${input.cliVersion} — run \\`agentbox hub update\\` to match`\n : null;\n return { version, versionSource, channel, build, drift };\n}\n\nconst statusSub = new Command('status')\n .description(\n 'Show hub status — the remote control box (reachability + box/event counts) when one is configured, else the local hub process',\n )\n .option(\n '--url <url>',\n 'probe this control-plane URL as the remote hub (default: relay.controlPlaneUrl)',\n )\n .option('--json', 'emit status as JSON')\n .action(async (opts: StatusOpts) => {\n try {\n // A control box that IS this machine (`hub expose`): show the exposed\n // detail (profile, worker, box-facing URL, tunnel) that a plain remote\n // probe of its loopback can't. Skipped when `--url` targets another hub.\n const localExposed = opts.url ? null : await readLocalDeployRecord();\n if (localExposed) {\n const s = await getHubStatus();\n if (opts.json) {\n process.stdout.write(JSON.stringify({ ...s, exposed: localExposed }, null, 2) + '\\n');\n return;\n }\n process.stdout.write(renderStatus(s, localExposed) + '\\n');\n return;\n }\n const target = await resolveHubTarget(opts.url);\n // Remote (a control box is configured, or --url given): probe its /healthz.\n if (target.mode === 'remote') {\n const st = await probeControlPlaneStatus(target.url);\n const record = await readDeployRecordFor(st.url);\n const b = describeRemoteHubBuild({\n liveVersion: st.version,\n record,\n cliVersion: AGENTBOX_VERSION,\n });\n if (opts.json) {\n process.stdout.write(\n JSON.stringify({\n ...st,\n ...(b.version ? { version: b.version, versionSource: b.versionSource } : {}),\n ...(b.channel ? { channel: b.channel } : {}),\n ...(b.build ? { deployed: b.build } : {}),\n }) + '\\n',\n );\n return;\n }\n process.stdout.write(\n [\n `hub: remote (${st.healthy ? 'reachable' : 'UNREACHABLE'})`,\n ` url: ${st.url}`,\n ` health: ${st.detail}`,\n ...(b.version\n ? [` version: ${b.version}${b.versionSource === 'deployed' ? ' (as deployed)' : ''}`]\n : []),\n ...(b.channel ? [` channel: ${b.channel}`] : []),\n ...(b.build ? [` build: ${b.build}`] : []),\n ...(b.drift ? [` update: ${b.drift}`] : []),\n ].join('\\n') + '\\n',\n );\n return;\n }\n // Local: introspect the hub daemon process on this machine.\n const s = await getHubStatus();\n // When exposed, the deploy record carries the box-facing URL / tunnel /\n // autostart that /healthz doesn't.\n const exposed = s.profile === 'hetzner' ? await readLocalDeployRecord() : null;\n if (opts.json) {\n process.stdout.write(\n JSON.stringify({ ...s, ...(exposed ? { exposed } : {}) }, null, 2) + '\\n',\n );\n return;\n }\n process.stdout.write(renderStatus(s, exposed) + '\\n');\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\nconst targetSub = new Command('target')\n .description(\n 'Print the hub the CLI talks to — the remote control box when configured, else the local hub — with its API token. The seam the macOS tray follows to point at the same hub.',\n )\n .option('--url <url>', 'override the control-plane URL (default: relay.controlPlaneUrl)')\n .option('--json', 'emit { mode, url, token } as JSON (consumed by the tray)')\n .action(async (opts: { url?: string; json?: boolean }) => {\n try {\n const t = await resolveHubTarget(opts.url);\n if (opts.json) {\n process.stdout.write(JSON.stringify(t) + '\\n');\n return;\n }\n const tokenNote = t.token\n ? 'present'\n : t.mode === 'remote'\n ? '(none — set AGENTBOX_HUB_API_KEY, or run `agentbox hub setup`)'\n : '(none — start the hub with `agentbox hub`)';\n process.stdout.write(\n [`hub: ${t.mode}`, ` url: ${t.url}`, ` token: ${tokenNote}`].join('\\n') + '\\n',\n );\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\ninterface StartOpts {\n open?: boolean;\n local?: boolean;\n}\n\n/**\n * With a remote control box configured, `agentbox hub` opens THAT hub instead of\n * starting one here: it is the hub this CLI already talks to, it holds the boxes,\n * and booting a second empty UI on 127.0.0.1 only invites acting on the wrong\n * one. Nothing is lost by not starting it — every local operation that needs the\n * hub on this machine auto-starts it (`resolveHubApiClient`), and `--local`\n * forces it explicitly.\n *\n * A `hub expose`-d machine is excluded: it *is* the control box, so the hub to\n * open is the one to start (hence `onThisMachine`, not `mode`).\n */\nasync function openRemoteHub(target: HubTarget, opts: StartOpts): Promise<void> {\n const s = spinner();\n s.start(`reaching the control box at ${target.url}`);\n const st = await probeControlPlaneStatus(target.url);\n s.stop(\n st.healthy ? `control box reachable — ${st.detail}` : `control box UNREACHABLE (${st.detail})`,\n );\n process.stdout.write(`\\n Open: ${target.url}\\n\\n`);\n if (!st.healthy) {\n log.warn(\n 'Opening it anyway. `agentbox hub status` has the detail; ' +\n '`agentbox hub start --local` runs a hub on this machine instead.',\n );\n }\n if (opts.open !== false) openInBrowser(target.url);\n}\n\nconst startSub = new Command('start')\n .description(\n 'Open the hub — the remote control box when one is configured, else start the local hub (relay + Web UI on port 8787) and open it',\n )\n .option('--no-open', \"don't open the browser, just print the URL\")\n .option('--local', 'start the hub on this machine even when a control box is configured')\n .action(async (opts: StartOpts) => {\n try {\n if (opts.local !== true) {\n const target = await resolveHubTarget();\n if (!target.onThisMachine) {\n await openRemoteHub(target, opts);\n return;\n }\n }\n const s = spinner();\n s.start('starting hub');\n // If this machine is an exposed control box with a tunnel, (re)establish it\n // first so the hub boots knowing its public URL (autostart path).\n await restoreTunnelIfExposed((line) => s.message(line));\n const ep = await ensureHub({\n onLog: (line) => s.message(line),\n portlessEnabled: await resolvePortlessForHub(),\n });\n await rehydrateFromState();\n s.stop(`hub running on ${ep.hostUrl}`);\n process.stdout.write(`\\n Open: ${ep.openUrl}\\n\\n`);\n if (opts.open !== false) openInBrowser(ep.openUrl);\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\nconst stopSub = new Command('stop')\n .description('Stop the hub process (idempotent)')\n .action(async () => {\n try {\n const s = spinner();\n s.start('stopping hub');\n const result = await stopHub();\n // A tunnel outliving the hub serves nothing and, worse, the next\n // `hub start` would spawn a second one over it. Idempotent + no-op when\n // this machine isn't exposed.\n await stopTunnelIfExposed((line) => s.message(line));\n s.stop(result.stopped ? `stopped hub (pid ${String(result.pid)})` : 'hub was not running');\n } catch (err) {\n handleLifecycleError(err);\n }\n });\n\nconst restartSub = new Command('restart')\n .description('Stop then start the hub')\n .option('--no-open', \"don't open the browser, just print the URL\")\n .action(async (opts: StartOpts) => {\n try {\n const s = spinner();\n s.start('stopping hub');\n const stopped = await stopHub();\n s.stop(stopped.stopped ? `stopped hub (pid ${String(stopped.pid)})` : 'hub was not running');\n const s2 = spinner();\n s2.start('starting hub');\n try {\n await restoreTunnelIfExposed((line) => s2.message(line));\n const ep = await ensureHub({\n onLog: (line) => s2.message(line),\n portlessEnabled: await resolvePortlessForHub(),\n });\n await rehydrateFromState();\n s2.stop(`hub running on ${ep.hostUrl}`);\n process.stdout.write(`\\n Open: ${ep.openUrl}\\n\\n`);\n if (opts.open !== false) openInBrowser(ep.openUrl);\n } catch (err) {\n s2.stop('hub 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\n/**\n * Resolve a box ref through the hub's `/api/v1` (server-side `findBox`) for the\n * `hub pull` / `hub adopt` commands. Returns the unique match + the hub API URL\n * (persisted on the adopted record), or null after printing an actionable error\n * — an ambiguous prefix lists the candidates, a total miss throws\n * {@link HubBoxNotFoundError} for the caller's catch to render.\n */\nasync function resolveHubBox(\n ref: string,\n urlFlag: string | undefined,\n): Promise<{ box: HubApiBox; url: string } | null> {\n const target = await resolveHubApiTarget(urlFlag);\n if (!target) {\n process.exitCode = 1;\n return null;\n }\n const matches = await new HubApiClient(target).resolveBox(ref);\n if (matches.length === 0) throw new HubBoxNotFoundError(ref);\n if (matches.length > 1) {\n log.error(`'${ref}' matches multiple boxes on the control box — pick one:`);\n for (const b of matches) process.stderr.write(` ${b.name ?? b.id} (id ${b.id})\\n`);\n log.info('retry with a longer id prefix, the full name, or the sandbox id');\n process.exitCode = 1;\n return null;\n }\n return { box: matches[0]!, url: target.url };\n}\n\nconst pullSub = new Command('pull')\n .description(\n \"Download a control-box-created box's SSH keys so this PC can attach / port-forward / cp to it\",\n )\n .argument('<box>', 'box id or name as shown by `agentbox hub boxes list`')\n .option('--url <url>', 'override the control-plane URL (default: relay.controlPlaneUrl)')\n .action(async (box: string, opts: { url?: string }) => {\n try {\n const resolved = await resolveHubBox(box, opts.url);\n if (!resolved) return;\n // SSH keys live in custody, over the hub's /api/v1: the byte-read needs the\n // admin token (elevated), so this only works from a machine that ran\n // `hub setup`/`expose`. remoteOnly — a control-box box has no keys on a\n // plain local hub.\n const custodyTarget = await resolveCustodyApiTarget(opts.url, { remoteOnly: true });\n if (!custodyTarget) {\n process.exitCode = 1;\n return;\n }\n const res = await pullBoxSshKeys({\n custody: new CustodyClient(custodyTarget),\n box: resolved.box,\n });\n if (res.files.length === 0) {\n log.warn(\n `No SSH key material in custody for '${box}' (boxes/${res.key}/ssh). ` +\n 'The box may mint no keypair (e2b/vercel).',\n );\n process.exitCode = 1;\n return;\n }\n log.success(\n `Pulled ${String(res.files.length)} key file(s) to ${res.dest} — attach / cp / port-forward now work.`,\n );\n } catch (err) {\n if (err instanceof HubBoxNotFoundError) {\n log.error(`${err.message}. Run \\`agentbox hub boxes list\\` to see what's there.`);\n process.exitCode = 1;\n return;\n }\n handleLifecycleError(err);\n }\n });\n\nconst adoptSub = new Command('adopt')\n .description(\n 'Rebuild local state for a control-box-created box so it resolves by name here: writes its BoxRecord and downloads its SSH keys. After this it shows in `agentbox ls` and works with attach / cp / url / screen.',\n )\n .argument('<box>', 'box id, name, or sandbox id as shown by `agentbox hub boxes list`')\n .option('--url <url>', 'override the control-plane URL (default: relay.controlPlaneUrl)')\n .action(async (box: string, opts: { url?: string }) => {\n try {\n const resolved = await resolveHubBox(box, opts.url);\n if (!resolved) return;\n // SSH keys come from custody over /api/v1 (best-effort): a thin client with\n // no admin token adopts the record and warns for SSH providers (the byte-read\n // is refused). remoteOnly — adoption is a control-box concern.\n const custodyTarget = await resolveCustodyApiTarget(opts.url, {\n quiet: true,\n remoteOnly: true,\n });\n const custody = custodyTarget ? new CustodyClient(custodyTarget) : undefined;\n const res = await adoptHubBox({\n box: resolved.box,\n custody,\n controlPlaneUrl: resolved.url,\n log: (line) => log.info(line),\n });\n const where = res.projectRoot\n ? `linked to ${res.projectRoot}`\n : 'no local clone of its repo — it shows under `agentbox ls -g` only';\n log.success(\n `${res.refreshed ? 'Refreshed' : 'Adopted'} ${res.record.name} (${res.record.provider} ${res.record.cloud?.sandboxId ?? ''}) — ${where}.`,\n );\n if (res.sshKeysMissing) {\n log.warn(\n `But the control box has no SSH key for it, so attach / cp / port-forward won't work yet. ` +\n `The key is uploaded by the host that created the box — check that it ran with a control box configured.`,\n );\n }\n } catch (err) {\n if (err instanceof HubBoxNotFoundError) {\n log.error(`${err.message}. Run \\`agentbox hub boxes list\\` to see what's there.`);\n process.exitCode = 1;\n return;\n }\n handleLifecycleError(err);\n }\n });\n\nexport const hubCommand = new Command('hub')\n .description(\n 'Run + manage the AgentBox hub — the local relay + Web UI on http://127.0.0.1:8787 ' +\n '(also https://agentbox.localhost when Portless is installed), and the remote control box ' +\n '(setup, deploy, boxes, approvals, credentials, custody)',\n )\n .addCommand(startSub, { isDefault: true })\n .addCommand(statusSub)\n .addCommand(targetSub)\n .addCommand(stopSub)\n .addCommand(restartSub)\n .addCommand(pullSub)\n .addCommand(adoptSub);\n\n// Fold the remote-hub admin subcommands (setup/deploy/set-url/add/worker/\n// credentials/secrets/project/custody/boxes/approvals) into the one `hub` group —\n// there is no separate `control-plane` command. All surfaced (not hidden).\nfor (const sub of controlPlaneSubcommands) hubCommand.addCommand(sub);\n","/**\n * `agentbox install portless` — set up Portless properly, once, so box URLs\n * keep working across reboots.\n *\n * Portless (https://portless.sh) is what turns a box's published port into\n * `https://<box>.localhost`. AgentBox can install the CLI and start a proxy on\n * demand, but a proxy started that way is just a process: it dies with the\n * machine, while the route registry it serves survives on disk. The result is\n * the failure this command exists to remove — `portless get` keeps answering\n * with a URL, `agentbox hub` keeps printing it, and nothing is listening.\n *\n * Portless ships the fix (`portless service install`: a root LaunchDaemon on\n * macOS, systemd on Linux, a startup task on Windows), so this command drives\n * that rather than hand-rolling autostart, and pairs it with the CA trust the\n * HTTPS proxy needs.\n */\n\nimport { confirm, intro, log, note, outro, spinner } from '../lib/prompt.js';\nimport { Command } from 'commander';\nimport {\n detectPortless,\n ensurePortlessProxy,\n installPortless,\n installPortlessService,\n portlessGetUrl,\n portlessInstallHint,\n portlessServiceStatus,\n resetPortlessCache,\n uninstallPortlessService,\n} from '@agentbox/sandbox-docker';\n\ninterface InstallPortlessOptions {\n uninstall?: boolean;\n yes?: boolean;\n}\n\n/**\n * Offer to make an already-running proxy permanent. Interactive-only and\n * best-effort: called from the first-run opt-in and from this command, never\n * from a background path. A \"no\" is simply not repeated in that session — the\n * `doctor` row keeps the nudge visible without another prompt.\n */\nexport async function offerPortlessService(): Promise<void> {\n if (!process.stdin.isTTY) return;\n const service = await portlessServiceStatus();\n if (service.installed) return;\n\n const yes = await confirm({\n message:\n 'Start the Portless proxy automatically at boot? ' +\n '(otherwise box URLs stop working after every restart)',\n initialValue: true,\n });\n if (!yes) {\n log.info('Skipped — run `agentbox install portless` later to set it up.');\n return;\n }\n await runServiceInstall();\n}\n\n/**\n * Install the OS service, reporting what happened. Shared by the interactive\n * offer and the command itself.\n */\nasync function runServiceInstall(): Promise<boolean> {\n // The service runs Portless's default mode — HTTPS on :443 — so a host that\n // was on the no-root :1355 proxy moves to clean, port-less URLs. That is the\n // mode the rest of AgentBox is written against (a cloud box mirrors it\n // internally, and `{{AGENTBOX_BOX_HOST}}` templates spell `https://…` by\n // hand), but it *does* change existing box URLs, so say so before prompting.\n log.info(\n 'Installing the Portless startup service (HTTPS on port 443) — ' +\n 'you may be asked for your password. Box URLs become https://<box>.localhost ' +\n '(the same URL that works inside a box).',\n );\n const res = await installPortlessService();\n resetPortlessCache();\n if (res === 'cancelled') {\n log.warn('Password prompt dismissed — the proxy will not start at boot.');\n return false;\n }\n if (res === 'failed') {\n log.warn('Could not install the Portless startup service — run `portless service install`.');\n return false;\n }\n const service = await portlessServiceStatus();\n if (!service.installed) {\n log.warn(\n 'Portless reported success but the service is not registered — check `portless service status`.',\n );\n return false;\n }\n log.success('Portless starts at boot now.');\n return true;\n}\n\nexport const installPortlessCommand = new Command('portless')\n .description(\n 'Install Portless and start its proxy at boot, so https://<box>.localhost URLs survive a reboot.',\n )\n .option('--uninstall', 'remove the Portless startup service (leaves the CLI installed)')\n .option('-y, --yes', 'no prompts: install the CLI and the startup service')\n .action(async (opts: InstallPortlessOptions) => {\n intro('agentbox install portless');\n\n if (opts.uninstall === true) {\n const ok = await uninstallPortlessService();\n if (ok) outro('Portless startup service removed.');\n else {\n log.warn('Could not remove the service — run `portless service uninstall`.');\n outro('nothing changed');\n }\n return;\n }\n\n let state = await detectPortless();\n if (!state.installed) {\n const s = spinner();\n s.start(`installing portless (${portlessInstallHint()})`);\n const ok = await installPortless();\n resetPortlessCache();\n s.stop(ok ? 'portless installed' : 'portless install failed');\n if (!ok) {\n log.warn(`Run \\`${portlessInstallHint()}\\` yourself, then re-run this command.`);\n outro('nothing changed');\n return;\n }\n state = await detectPortless();\n }\n\n const service = await portlessServiceStatus();\n if (service.installed) {\n log.info('Portless startup service already installed.');\n } else if (opts.yes === true) {\n await runServiceInstall();\n } else if (process.stdin.isTTY) {\n await offerPortlessService();\n } else {\n // Installing the service raises a password dialog. Never do that from a\n // script or a hook that nobody is watching — say what to run instead.\n log.info('Startup service not installed — run `agentbox install portless -y` to add it.');\n }\n\n // Whether or not the service went in, leave the host with a live proxy —\n // the service starts one at *boot*, not retroactively for this session.\n state = await ensurePortlessProxy({ allowRootPrompt: false });\n if (!state.proxyRunning) {\n log.warn('No Portless proxy is running — box URLs fall back to loopback ports.');\n outro('done, with warnings');\n return;\n }\n\n // Show the real URL rather than an assumed one: whether it carries a port\n // and which scheme it uses is decided by whichever proxy actually answered.\n const hubUrl = await portlessGetUrl('agentbox');\n const boxUrl = hubUrl.replace('//agentbox.', '//<box>.');\n note([`hub: ${hubUrl}`, `boxes: ${boxUrl}`].join('\\n'), 'URLs served by this proxy');\n outro('portless ready');\n });\n","import { confirm, log, spinner } from './lib/prompt.js';\nimport { loadEffectiveConfig, setConfigValue } from '@agentbox/config';\nimport {\n detectPortless,\n type DockerEngine,\n ensurePortlessProxy,\n installPortless,\n portlessInstallHint,\n portlessServiceHint,\n portlessStartHint,\n resetPortlessCache,\n} from '@agentbox/sandbox-docker';\nimport { offerPortlessService } from './commands/install-portless.js';\n\nexport interface PortlessPromptArgs {\n engine: DockerEngine;\n /** Effective `portless.enabled` — `undefined` means \"never prompted\". */\n enabled: boolean | undefined;\n yes: boolean;\n /** cwd for the config write (global scope resolves a fixed path regardless). */\n cwd: string;\n}\n\n/**\n * Bring the host Portless into a usable state after the user opts in: install\n * the CLI if missing, then start a proxy if none is running. We start the\n * default HTTPS proxy on :443 so box web apps get the clean\n * `https://<box>.localhost` (no port). Portless self-elevates via `sudo`, so\n * this asks for the host password once — a native GUI dialog on macOS. If the\n * user dismisses that prompt (or elevation fails) we fall back to the no-root\n * proxy (`--no-tls -p 1355`, `http://<box>.localhost:1355`) so create still\n * works. Best-effort — any failure degrades to a printed hint, never throws.\n *\n * `allowRootPrompt` gates the :443 attempt: the Docker path only reaches here\n * after an interactive \"yes\", but the Hetzner path calls this directly, so it\n * passes `false` for non-interactive / `--yes` runs to avoid a surprise\n * password dialog (falling straight through to the no-root :1355 proxy).\n *\n * The :443 preference is not cosmetic. `https://<box>.localhost` is the URL a\n * cloud box mirrors internally and the one users hand-write against\n * `{{AGENTBOX_BOX_HOST}}`, so host and box only agree while the host proxy\n * serves that exact scheme and port.\n */\nexport async function setupPortlessHost(opts: { allowRootPrompt?: boolean } = {}): Promise<void> {\n const allowRootPrompt = opts.allowRootPrompt ?? true;\n let state = await detectPortless();\n\n if (!state.installed) {\n const s = spinner();\n s.start('installing portless (npm install -g portless)');\n const ok = await installPortless();\n resetPortlessCache();\n s.stop(ok ? 'portless installed' : 'portless install failed');\n if (!ok) {\n log.warn(`Could not install Portless — run \\`${portlessInstallHint()}\\` yourself.`);\n return;\n }\n state = await detectPortless();\n }\n\n if (state.proxyRunning) {\n log.info('Portless proxy already running — boxes will use it.');\n // Running now, but a manually started proxy is gone after the next reboot.\n if (allowRootPrompt) await offerPortlessService();\n return;\n }\n\n // `ensurePortlessProxy` runs the ladder: the clean :443 proxy when we may ask\n // for a password, the no-root port when that is refused or already the mode\n // this host uses. No spinner around the root attempt — the elevation prompt is\n // modal and shouldn't race one.\n if (allowRootPrompt) {\n log.info(\n 'Starting the Portless proxy on https://<box>.localhost — you may be asked for your password.',\n );\n state = await ensurePortlessProxy({ allowRootPrompt: true });\n } else {\n const s = spinner();\n s.start('starting portless proxy');\n state = await ensurePortlessProxy({ allowRootPrompt: false });\n // No port asserted here: which port comes back is whichever one this host is\n // already configured for. The real URL is resolved via `portless get`.\n s.stop(state.proxyRunning ? 'portless proxy started' : 'portless proxy did not start');\n }\n\n if (!state.proxyRunning) {\n log.warn(\n `Could not start the Portless proxy — run \\`${portlessServiceHint()}\\` (starts it at boot) ` +\n `or \\`${portlessStartHint()}\\` for a one-off.`,\n );\n return;\n }\n if (allowRootPrompt) {\n log.success('Portless proxy started');\n await offerPortlessService();\n }\n}\n\n/**\n * Effective `portless.enabled`, resolved against the cwd so the global layer is\n * picked up. Best effort — a config read failure leaves it `undefined`, which\n * every caller treats as \"never decided\", not as an opt-out.\n */\nexport async function resolvePortlessEnabled(): Promise<boolean | undefined> {\n try {\n const cfg = await loadEffectiveConfig(process.cwd());\n return cfg.effective.portless.enabled;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Bring an already-opted-in host back to a working state without asking\n * anything. A proxy dies on reboot while its route registry survives, so\n * `portless get` keeps answering with URLs that resolve to nothing until\n * something restarts it — and before this, nothing did. Every entry point that\n * is about to hand out a `<box>.localhost` URL calls this.\n *\n * Silent by design: it never prompts for a password (the tray app, the queue\n * worker and `self-update` all reach here). It restarts the mode this host is\n * already configured for and never switches modes, so a host on the clean\n * HTTPS :443 proxy — which needs root — gets a pointer to the one-time fix\n * rather than a silently different URL. Warns once, at most.\n */\nexport async function ensurePortlessProxyQuietly(): Promise<void> {\n const state = await ensurePortlessProxy({ allowRootPrompt: false });\n if (!state.installed || state.proxyRunning) return;\n log.warn(\n `Portless proxy is not running — box URLs fall back to loopback ports. ` +\n `Start it at boot with \\`${portlessServiceHint()}\\`.`,\n );\n}\n\n/**\n * First-run opt-in for Portless. On Docker Desktop there is no per-container\n * DNS, so we offer to give box web apps a friendly `<box>.localhost` URL. The\n * answer — yes or no — is persisted to the *global* config so the prompt fires\n * exactly once per machine; a \"yes\" also installs the CLI and starts the proxy\n * (see `setupPortlessHost`). Returns the resolved enabled flag.\n *\n * Silent no-op (returns the effective value) when: already decided in any\n * config layer or via --portless/--no-portless; non-interactive or --yes; or\n * the engine is OrbStack (which already has .orb.local).\n */\nexport async function maybePromptPortless(args: PortlessPromptArgs): Promise<boolean> {\n if (args.enabled !== undefined) {\n // Already decided — but \"decided\" only ever meant the *preference* was\n // stored. The proxy itself is not durable (a reboot kills it), so an\n // opted-in host used to sit here with dead `<box>.localhost` URLs forever.\n if (args.enabled) await ensurePortlessProxyQuietly();\n return args.enabled;\n }\n if (args.engine === 'orbstack') return false;\n // Non-interactive (`--yes`, CI, no TTY): can't prompt — adopt a running proxy\n // instead of forcing the user to opt in from a terminal first.\n if (!process.stdin.isTTY || args.yes) return resolvePortlessNonInteractive(args);\n\n const answer = await confirm({\n message:\n 'Use Portless to give box web apps a friendly local URL? ' +\n '(installs the portless CLI and starts a local proxy if needed)',\n initialValue: true,\n });\n\n try {\n await setConfigValue('global', 'portless.enabled', answer, args.cwd, { raw: false });\n } catch (err) {\n log.warn(\n `Could not save the Portless preference: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n\n if (answer) await setupPortlessHost();\n return answer;\n}\n\n/**\n * Resolve `portless.enabled` when we can't prompt — background queue jobs, the\n * tray app's hub-create path, `--yes`, CI. Honors an already-decided value\n * (config or `--portless`/`--no-portless`). Otherwise, on Docker Desktop, it\n * adopts an already-running Portless proxy — and persists the choice so later\n * runs skip re-detection, mirroring an interactive \"yes\" for a user who already\n * has Portless up. Without this, the first box started from the tray app never\n * uses Portless even though the proxy is live on :443, until the user happens to\n * run `agentbox` once from a real terminal. Never installs or starts a proxy\n * unasked; OrbStack needs no Portless (it has `.orb.local`).\n */\nexport async function resolvePortlessNonInteractive(args: {\n engine: DockerEngine;\n enabled: boolean | undefined;\n cwd: string;\n}): Promise<boolean> {\n if (args.enabled !== undefined) {\n if (args.enabled) await ensurePortlessProxyQuietly();\n return args.enabled;\n }\n if (args.engine === 'orbstack') return false;\n const state = await detectPortless();\n if (state.proxyRunning) {\n try {\n await setConfigValue('global', 'portless.enabled', true, args.cwd, { raw: false });\n } catch {\n // Best-effort persist; still use the running proxy for this run.\n }\n }\n return state.proxyRunning;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,OAAAA,MAAK,WAAAC,gBAAe;AAW7B,SAAS,WAAAC,gBAAe;;;ACKxB,SAAS,eAAe;AAwBxB,eAAsB,uBAAsC;AAC1D,MAAI,CAAC,QAAQ,MAAM,MAAO;AAC1B,QAAM,UAAU,MAAM,sBAAsB;AAC5C,MAAI,QAAQ,UAAW;AAEvB,QAAM,MAAM,MAAM,QAAQ;AAAA,IACxB,SACE;AAAA,IAEF,cAAc;AAAA,EAChB,CAAC;AACD,MAAI,CAAC,KAAK;AACR,uBAAI,KAAK,oEAA+D;AACxE;AAAA,EACF;AACA,QAAM,kBAAkB;AAC1B;AAMA,eAAe,oBAAsC;AAMnD,qBAAI;AAAA,IACF;AAAA,EAGF;AACA,QAAM,MAAM,MAAM,uBAAuB;AACzC,qBAAmB;AACnB,MAAI,QAAQ,aAAa;AACvB,uBAAI,KAAK,oEAA+D;AACxE,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,UAAU;AACpB,uBAAI,KAAK,uFAAkF;AAC3F,WAAO;AAAA,EACT;AACA,QAAM,UAAU,MAAM,sBAAsB;AAC5C,MAAI,CAAC,QAAQ,WAAW;AACtB,uBAAI;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,qBAAI,QAAQ,8BAA8B;AAC1C,SAAO;AACT;AAEO,IAAM,yBAAyB,IAAI,QAAQ,UAAU,EACzD;AAAA,EACC;AACF,EACC,OAAO,eAAe,gEAAgE,EACtF,OAAO,aAAa,qDAAqD,EACzE,OAAO,OAA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M,YAAY;AAAA,MAC5B,KAAK,SAAS;AAAA,MACd;AAAA,MACA,iBAAiB,SAAS;AAAA,MAC1B,KAAK,CAAC,SAASG,KAAI,KAAK,IAAI;AAAA,IAC9B,CAAC;AACD,UAAM,QAAQ,IAAI,cACd,aAAa,IAAI,WAAW,KAC5B;AACJ,IAAAA,KAAI;AAAA,MACF,GAAG,IAAI,YAAY,cAAc,SAAS,IAAI,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,QAAQ,IAAI,IAAI,OAAO,OAAO,aAAa,EAAE,YAAO,KAAK;AAAA,IACxI;AACA,QAAI,IAAI,gBAAgB;AACtB,MAAAA,KAAI;AAAA,QACF;AAAA,MAEF;AAAA,IACF;AAAA,EACF,SAAS,KAAK;AACZ,QAAI,eAAe,qBAAqB;AACtC,MAAAA,KAAI,MAAM,GAAG,IAAI,OAAO,wDAAwD;AAChF,cAAQ,WAAW;AACnB;AAAA,IACF;AACA,yBAAqB,GAAG;AAAA,EAC1B;AACF,CAAC;AAEI,IAAM,aAAa,IAAIH,SAAQ,KAAK,EACxC;AAAA,EACC;AAGF,EACC,WAAW,UAAU,EAAE,WAAW,KAAK,CAAC,EACxC,WAAW,SAAS,EACpB,WAAW,SAAS,EACpB,WAAW,OAAO,EAClB,WAAW,UAAU,EACrB,WAAW,OAAO,EAClB,WAAW,QAAQ;AAKtB,WAAW,OAAO,wBAAyB,YAAW,WAAW,GAAG;","names":["log","spinner","Command","Command","s","spinner","log"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/relay/src/cloud-poller.ts"],"sourcesContent":["/**\n * `CloudBoxPoller` — host-resident loop that drains a cloud box's in-sandbox\n * relay over its Daytona preview URL. One poller per cloud box, owned by the\n * host relay process (so status / autopause behave the same whether or not a\n * CLI is attached, matching the Docker model).\n *\n * v0 responsibility: pull `/bridge/poll`, forward events + status into the\n * host relay's stores. Executing drained `HostAction`s (real `git push` on\n * the host, with `askPrompt` gating) and posting results back is the next\n * layer, tracked alongside Phase 4's host-RPC execution.\n */\n\nimport { request as httpRequest } from 'node:http';\nimport { request as httpsRequest } from 'node:https';\nimport { setTimeout as delay } from 'node:timers/promises';\nimport type {\n BridgeActionResultBody,\n BridgePollResponse,\n HostAction,\n HostActionResult,\n RelayEvent,\n} from './types.js';\n\nexport interface CloudBoxPollerDeps {\n boxId: string;\n /** Preview URL of the in-sandbox relay's `/bridge/*` surface. */\n previewUrl: string;\n /** Bearer for `/bridge/*` auth (Daytona's `x-daytona-preview-token` is added separately when known). */\n bridgeToken: string;\n /** Optional Daytona preview token header for the proxy layer. */\n previewToken?: string;\n /** Fired for each batch of new events drained from the box. */\n onEvents?: (events: RelayEvent[]) => void;\n /** Fired when a new box-status snapshot is observed. */\n onStatus?: (status: unknown) => void;\n /**\n * Fired for each parked host action the box wants the host to execute.\n * The `respond` callback POSTs back to `/bridge/action-result` and\n * unblocks the in-box `/rpc` caller — the handler MUST call it (with a\n * non-zero exitCode and stderr message even when the host can't execute\n * the action) so the box never hangs.\n */\n onAction?: (\n action: HostAction,\n respond: (result: HostActionResult) => Promise<void>,\n ) => Promise<void> | void;\n /**\n * Optional: called when the poller observes a connection-level failure\n * (ECONNREFUSED, ENOTFOUND, etc.) on `previewUrl`. Should re-establish\n * whatever underlying transport powers the URL (e.g. reopen an SSH\n * ControlMaster + re-mint its `-L` forward) and return the (possibly new)\n * URL the poller should use from here on. Return `null`/`undefined` to\n * keep the current URL.\n *\n * Use case: Hetzner's preview URLs are SSH `-L` forwards. If the\n * ControlMaster dies (host sleep/wake, network blip), the local port\n * stops listening — without this callback the poller would back off\n * forever against a dead `127.0.0.1:<localPort>`. Daytona's preview is a\n * permanent CloudFront alias and doesn't need this.\n */\n recoverPreviewUrl?: () => Promise<string | null | undefined>;\n logger?: (line: string) => void;\n}\n\nconst BACKOFF_BASE_MS = 1500;\nconst BACKOFF_MAX_MS = 30_000;\n/**\n * Default request timeout. Daytona's CloudFront edge sits in front of the\n * in-sandbox relay and 504s once its idle window expires (~25-30s in\n * practice). Keep the default a hair below that so the poller's timer\n * fires before CloudFront's does, then short-cycle aggressively when we\n * actually see a 504 — see {@link FAST_REQUEST_TIMEOUT_MS}.\n */\nconst REQUEST_TIMEOUT_MS = 25_000;\n/**\n * Faster timeout used after a recent 504 response. Cuts the request short\n * enough that we round-trip multiple times in the same window where the\n * edge proxy would otherwise wedge — recovers throughput quickly when the\n * box is healthy but the edge is flaky.\n */\nconst FAST_REQUEST_TIMEOUT_MS = 8_000;\n/**\n * Number of consecutive non-504 polls before reverting from the fast\n * timeout back to the default. Decays naturally; no separate timer.\n */\nconst FAST_MODE_DECAY_POLLS = 5;\nconst STOPPED_TICK_MS = 250;\n\n/**\n * True for connection-level failures — the local transport behind\n * `previewUrl` is dead (refused, no route, no DNS, host unreachable),\n * not a remote 5xx or a logical error. These are the cases where calling\n * `recoverPreviewUrl` (e.g. Hetzner's SSH tunnel reopen) has a chance of\n * actually fixing anything.\n */\nfunction isConnectionLevelError(err: unknown): boolean {\n const code = (err as NodeJS.ErrnoException | undefined)?.code;\n if (code && CONNECTION_LEVEL_CODES.has(code)) return true;\n const msg = err instanceof Error ? err.message : String(err);\n // node:http surfaces the underlying error message rather than a code on\n // some failure paths — match the well-known signatures too.\n return /\\b(ECONNREFUSED|ENOTFOUND|EHOSTUNREACH|ECONNRESET|EPIPE)\\b/.test(msg);\n}\nconst CONNECTION_LEVEL_CODES = new Set([\n 'ECONNREFUSED',\n 'ENOTFOUND',\n 'EHOSTUNREACH',\n 'ECONNRESET',\n 'EPIPE',\n]);\n\nexport class CloudBoxPoller {\n private stopped = false;\n private cursor = 0;\n private currentBackoffMs = 0;\n private loopPromise: Promise<void> | null = null;\n /**\n * Counts down from {@link FAST_MODE_DECAY_POLLS} after each 504. While > 0\n * the next poll uses {@link FAST_REQUEST_TIMEOUT_MS}. Successful polls\n * decrement, so a flaky edge converges back to the default timeout\n * within ~5 successful round-trips.\n */\n private fastModePolls = 0;\n /**\n * Mutable copy of `deps.previewUrl`. We don't read `deps.previewUrl`\n * directly after construction because `recoverPreviewUrl` may hand us a\n * new URL (e.g. Hetzner reopens its SSH ControlMaster and the `-L`\n * forward gets a new ephemeral local port).\n */\n private currentPreviewUrl: string;\n /** Guards against recovery storms — at most one recovery attempt in flight. */\n private recovering: Promise<void> | null = null;\n\n constructor(private readonly deps: CloudBoxPollerDeps) {\n this.currentPreviewUrl = deps.previewUrl;\n }\n\n start(): void {\n if (this.loopPromise) return;\n this.loopPromise = this.run().catch((err) => {\n this.log(`poller crashed: ${err instanceof Error ? err.message : String(err)}`);\n });\n }\n\n async stop(): Promise<void> {\n this.stopped = true;\n if (this.loopPromise) await this.loopPromise;\n }\n\n /**\n * Post a `HostActionResult` back to the in-sandbox relay's\n * `/bridge/action-result`. The matching parked `/rpc` Promise resolves\n * and the in-box agent finally sees the answer.\n */\n async respond(actionId: string, result: HostActionResult): Promise<void> {\n const base = this.currentPreviewUrl.replace(/\\/+$/, '');\n const url = new URL(`${base}/bridge/action-result`);\n const isHttps = url.protocol === 'https:';\n const transport = isHttps ? httpsRequest : httpRequest;\n const port = url.port.length > 0 ? Number.parseInt(url.port, 10) : isHttps ? 443 : 80;\n const body: BridgeActionResultBody = {\n id: actionId,\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n };\n const payload = JSON.stringify(body);\n await new Promise<void>((resolve, reject) => {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'Content-Length': Buffer.byteLength(payload).toString(),\n Authorization: `Bearer ${this.deps.bridgeToken}`,\n };\n if (this.deps.previewToken) {\n headers['x-daytona-preview-token'] = this.deps.previewToken;\n }\n const req = transport(\n {\n host: url.hostname,\n port,\n method: 'POST',\n path: url.pathname,\n headers,\n timeout: REQUEST_TIMEOUT_MS,\n },\n (res) => {\n res.resume();\n if ((res.statusCode ?? 0) >= 200 && (res.statusCode ?? 0) < 300) resolve();\n else reject(new Error(`bridge/action-result → ${String(res.statusCode)}`));\n },\n );\n req.on('error', reject);\n req.on('timeout', () => {\n req.destroy();\n reject(new Error('bridge/action-result timeout'));\n });\n req.write(payload);\n req.end();\n });\n }\n\n private log(line: string): void {\n this.deps.logger?.(`[cloud-poller ${this.deps.boxId}] ${line}`);\n }\n\n private async run(): Promise<void> {\n while (!this.stopped) {\n try {\n const body = await this.pollOnce();\n this.currentBackoffMs = 0;\n if (body.events.length > 0) this.deps.onEvents?.(body.events);\n if (body.status != null) this.deps.onStatus?.(body.status);\n for (const action of body.actions) {\n // Fire-and-forget — the action executor either runs inline (v0) or\n // hands the action to its own queue (Phase 4 executor). Failures\n // there are not the poller's concern (but they MUST still respond\n // so the in-box RPC unblocks, hence the fallback below).\n try {\n const respond = (r: HostActionResult): Promise<void> => this.respond(action.id, r);\n if (this.deps.onAction) {\n await this.deps.onAction(action, respond);\n } else {\n await respond({\n exitCode: 1,\n stdout: '',\n stderr: `host has no executor for action '${action.method}'\\n`,\n });\n }\n } catch (err) {\n this.log(`action handler error: ${err instanceof Error ? err.message : String(err)}`);\n // Best-effort: tell the box we failed so its /rpc unblocks.\n try {\n await this.respond(action.id, {\n exitCode: 1,\n stdout: '',\n stderr: `host action handler crashed: ${err instanceof Error ? err.message : String(err)}\\n`,\n });\n } catch {\n // ignore\n }\n }\n }\n if (typeof body.cursor === 'number' && body.cursor > this.cursor) {\n this.cursor = body.cursor;\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n if (msg.includes('→ 504') || msg.includes('504:')) {\n // Edge proxy timeout — the box is likely fine; arm fast-mode so the\n // next polls clip the request short of the next 504 window.\n this.fastModePolls = FAST_MODE_DECAY_POLLS;\n }\n this.log(`poll error: ${msg}`);\n // A connection-level failure (`ECONNREFUSED`/`ENOTFOUND`/`EHOSTUNREACH`)\n // usually means the transport behind `currentPreviewUrl` is dead, not\n // that the box went away. Hetzner's SSH `-L` forward stops listening\n // when the ControlMaster dies (host sleep/wake, network blip); the\n // recovery hook reopens it and hands us a fresh URL.\n if (this.deps.recoverPreviewUrl && isConnectionLevelError(err)) {\n await this.tryRecoverPreviewUrl();\n }\n await this.backoff();\n }\n // Successful poll decays fast-mode toward the default timeout.\n if (this.currentBackoffMs === 0 && this.fastModePolls > 0) {\n this.fastModePolls -= 1;\n }\n // Tight loop only when we got something fresh — otherwise yield briefly\n // so we don't spin under a misbehaving preview proxy.\n if (this.currentBackoffMs === 0) await delay(STOPPED_TICK_MS);\n }\n }\n\n private async backoff(): Promise<void> {\n this.currentBackoffMs =\n this.currentBackoffMs === 0\n ? BACKOFF_BASE_MS\n : Math.min(this.currentBackoffMs * 2, BACKOFF_MAX_MS);\n await delay(this.currentBackoffMs);\n }\n\n private async tryRecoverPreviewUrl(): Promise<void> {\n if (!this.deps.recoverPreviewUrl) return;\n // De-dupe: a poll storm shouldn't spawn N parallel recoveries.\n if (this.recovering) {\n await this.recovering;\n return;\n }\n this.recovering = (async () => {\n try {\n const next = await this.deps.recoverPreviewUrl!();\n if (typeof next === 'string' && next.length > 0 && next !== this.currentPreviewUrl) {\n this.log(`preview URL recovered: ${this.currentPreviewUrl} → ${next}`);\n this.currentPreviewUrl = next;\n // Drop the backoff so the next loop iteration retries immediately\n // against the fresh URL.\n this.currentBackoffMs = 0;\n } else if (typeof next === 'string' && next === this.currentPreviewUrl) {\n this.log('preview URL recovered (unchanged)');\n this.currentBackoffMs = 0;\n }\n } catch (err) {\n this.log(`preview URL recover failed: ${err instanceof Error ? err.message : String(err)}`);\n } finally {\n this.recovering = null;\n }\n })();\n await this.recovering;\n }\n\n private async pollOnce(): Promise<BridgePollResponse> {\n const base = this.currentPreviewUrl.replace(/\\/+$/, '');\n const url = new URL(`${base}/bridge/poll?since=${String(this.cursor)}`);\n const isHttps = url.protocol === 'https:';\n const transport = isHttps ? httpsRequest : httpRequest;\n const port = url.port.length > 0 ? Number.parseInt(url.port, 10) : isHttps ? 443 : 80;\n const timeoutMs = this.fastModePolls > 0 ? FAST_REQUEST_TIMEOUT_MS : REQUEST_TIMEOUT_MS;\n\n return new Promise<BridgePollResponse>((resolve, reject) => {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.deps.bridgeToken}`,\n Accept: 'application/json',\n };\n if (this.deps.previewToken) {\n headers['x-daytona-preview-token'] = this.deps.previewToken;\n }\n const req = transport(\n {\n host: url.hostname,\n port,\n method: 'GET',\n path: `${url.pathname}${url.search}`,\n headers,\n timeout: timeoutMs,\n },\n (res) => {\n const status = res.statusCode ?? 0;\n const chunks: Buffer[] = [];\n res.on('data', (c: Buffer) => chunks.push(c));\n res.on('end', () => {\n const text = Buffer.concat(chunks).toString('utf8');\n if (status < 200 || status >= 300) {\n reject(new Error(`bridge/poll → ${String(status)}: ${text.slice(0, 200)}`));\n return;\n }\n try {\n const parsed = JSON.parse(text) as Partial<BridgePollResponse>;\n resolve({\n actions: Array.isArray(parsed.actions) ? (parsed.actions as HostAction[]) : [],\n events: Array.isArray(parsed.events) ? (parsed.events as RelayEvent[]) : [],\n status: parsed.status ?? null,\n cursor: typeof parsed.cursor === 'number' ? parsed.cursor : this.cursor,\n });\n } catch (err) {\n reject(err instanceof Error ? err : new Error(String(err)));\n }\n });\n res.on('error', reject);\n },\n );\n req.on('error', reject);\n req.on('timeout', () => {\n req.destroy();\n reject(new Error('bridge/poll timeout'));\n });\n req.end();\n });\n }\n}\n\n/**\n * Lifecycle helper: keep one poller per cloud box, start on register, stop on\n * forget. The host relay's `BoxRegistry` knows nothing about pollers; this\n * type sits alongside it.\n */\nexport class CloudBoxPollers {\n private readonly map = new Map<string, CloudBoxPoller>();\n\n /** Idempotent: replacing an existing poller for a box stops the old one first. */\n start(boxId: string, deps: CloudBoxPollerDeps): void {\n const existing = this.map.get(boxId);\n if (existing) {\n void existing.stop();\n }\n const poller = new CloudBoxPoller(deps);\n this.map.set(boxId, poller);\n poller.start();\n }\n\n async stop(boxId: string): Promise<void> {\n const p = this.map.get(boxId);\n if (!p) return;\n this.map.delete(boxId);\n await p.stop();\n }\n\n async stopAll(): Promise<void> {\n const ps = [...this.map.values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