@madarco/agentbox 0.27.1 → 0.28.0-nightly.202607251721
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 +87 -4
- package/README.md +7 -3
- package/dist/_cloud-attach-XZYF324R.js +26 -0
- package/dist/admin-client-NOZ5CCAH.js +15 -0
- package/dist/chunk-2VW37PW4.js +1694 -0
- package/dist/chunk-2VW37PW4.js.map +1 -0
- package/dist/{chunk-HR7NHH5J.js → chunk-3UMM4VJH.js} +808 -57
- package/dist/chunk-3UMM4VJH.js.map +1 -0
- package/dist/chunk-5U5QOFL5.js +20 -0
- package/dist/chunk-5U5QOFL5.js.map +1 -0
- package/dist/chunk-6P6D77QP.js +285 -0
- package/dist/chunk-6P6D77QP.js.map +1 -0
- package/dist/chunk-6V366IZC.js +2892 -0
- package/dist/chunk-6V366IZC.js.map +1 -0
- package/dist/{chunk-KWOEUFVA.js → chunk-7J6G526Q.js} +6 -14
- package/dist/{chunk-KWOEUFVA.js.map → chunk-7J6G526Q.js.map} +1 -1
- package/dist/{chunk-IDH5A4RR.js → chunk-AYPAYY5R.js} +17 -4
- package/dist/chunk-AYPAYY5R.js.map +1 -0
- package/dist/{chunk-JGZSA5ZI.js → chunk-BHJCMTHP.js} +58 -15
- package/dist/chunk-BHJCMTHP.js.map +1 -0
- package/dist/{chunk-26IKZRTT.js → chunk-BLWAWGFX.js} +297 -1217
- package/dist/chunk-BLWAWGFX.js.map +1 -0
- package/dist/chunk-CGPUFXET.js +95 -0
- package/dist/chunk-CGPUFXET.js.map +1 -0
- package/dist/{chunk-SJ75AIA2.js → chunk-D6AODRNA.js} +12 -9
- package/dist/{chunk-SJ75AIA2.js.map → chunk-D6AODRNA.js.map} +1 -1
- package/dist/chunk-DPJMEG7U.js +11 -0
- package/dist/chunk-DPJMEG7U.js.map +1 -0
- package/dist/chunk-E2ITEZAQ.js +148 -0
- package/dist/chunk-E2ITEZAQ.js.map +1 -0
- package/dist/{chunk-JE6UI5YR.js → chunk-NKVCIH6N.js} +89 -223
- package/dist/chunk-NKVCIH6N.js.map +1 -0
- package/dist/chunk-OEYAVBA6.js +120 -0
- package/dist/chunk-OEYAVBA6.js.map +1 -0
- package/dist/{chunk-UJEH2NJT.js → chunk-PXYPQ5BO.js} +64 -264
- package/dist/chunk-PXYPQ5BO.js.map +1 -0
- package/dist/chunk-QESXSSO6.js +670 -0
- package/dist/chunk-QESXSSO6.js.map +1 -0
- package/dist/{chunk-NEF6MDJO.js → chunk-QJCK2AFX.js} +128 -26
- package/dist/chunk-QJCK2AFX.js.map +1 -0
- package/dist/chunk-RUJJY23M.js +84 -0
- package/dist/chunk-RUJJY23M.js.map +1 -0
- package/dist/{chunk-LL7NCMUU.js → chunk-SKNJRYM5.js} +7 -13
- package/dist/chunk-SKNJRYM5.js.map +1 -0
- package/dist/chunk-WFGAMJ5Q.js +689 -0
- package/dist/chunk-WFGAMJ5Q.js.map +1 -0
- package/dist/chunk-ZJL56TJD.js +1444 -0
- package/dist/chunk-ZJL56TJD.js.map +1 -0
- package/dist/{chunk-V5XXJH63.js → chunk-ZXOP4LBG.js} +5 -8
- package/dist/chunk-ZXOP4LBG.js.map +1 -0
- package/dist/control-plane-2VEM2KCL.js +31 -0
- package/dist/custody-client-P6XIXHRG.js +16 -0
- package/dist/{dist-TSFVB7AI.js → dist-2SYQI5S2.js} +11 -7
- package/dist/dist-2SYQI5S2.js.map +1 -0
- package/dist/{dist-KQTMCVME.js → dist-6QZMZEL7.js} +18 -11
- package/dist/dist-6QZMZEL7.js.map +1 -0
- package/dist/{dist-FTKS2GI4.js → dist-JHMILJUT.js} +10 -6
- package/dist/{dist-OO52HARR.js → dist-JOFZOZCY.js} +41 -25
- package/dist/{dist-O3LKOIE7.js → dist-KZ2GEEEX.js} +11 -7
- package/dist/dist-KZ2GEEEX.js.map +1 -0
- package/dist/{dist-Z6L5MM5D.js → dist-Q5NY4CF6.js} +10 -6
- package/dist/{dist-U2SVLJUQ.js → dist-SKMNEDVW.js} +8 -2
- package/dist/dist-SKMNEDVW.js.map +1 -0
- package/dist/dist-SRCKO7ZV.js +197 -0
- package/dist/dist-SRCKO7ZV.js.map +1 -0
- package/dist/{dist-WVYAURMF.js → dist-UXZQWKY6.js} +10 -6
- package/dist/dist-UXZQWKY6.js.map +1 -0
- package/dist/env-file-UDUDQMP4.js +11 -0
- package/dist/env-file-UDUDQMP4.js.map +1 -0
- package/dist/hub-adopt-ZS5CREYF.js +21 -0
- package/dist/hub-adopt-ZS5CREYF.js.map +1 -0
- package/dist/index.js +2461 -1905
- package/dist/index.js.map +1 -1
- package/dist/node-postgres-6JUOVUN5.js +3584 -0
- package/dist/node-postgres-6JUOVUN5.js.map +1 -0
- package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js → prepared-state-75DIZ55S-P6LE4N64.js} +3 -2
- package/dist/prepared-state-75DIZ55S-P6LE4N64.js.map +1 -0
- package/dist/remote-hub-SJ4XWBA5.js +9 -0
- package/dist/remote-hub-SJ4XWBA5.js.map +1 -0
- package/dist/sqlite-proxy-53E5D2VM.js +2882 -0
- package/dist/sqlite-proxy-53E5D2VM.js.map +1 -0
- package/package.json +1 -1
- package/runtime/_shared/ctl.cjs +29199 -16813
- package/runtime/digitalocean/ctl.cjs +29199 -16813
- package/runtime/docker/packages/ctl/dist/bin.cjs +29199 -16813
- package/runtime/e2b/ctl.cjs +29199 -16813
- package/runtime/hetzner/ctl.cjs +29199 -16813
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- 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]/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]/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]/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 +4 -4
- 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/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/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/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/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)/approvals/page.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js +2 -2
- 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)/page.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js +2 -2
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js +2 -2
- 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/[...path]/route.js +4 -2
- 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/chunks/0-fj_better-auth_dist_adapters_kysely-adapter_index_mjs_0btft52._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_0gvv4ct._.js +4 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_0pn9b49._.js +4 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_145bz8z._.js +9 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_14y990b._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_1nl4l3q._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_sqlite-proxy_index_05v_j5r.js +15 -0
- package/runtime/hub/apps/hub/.next/server/chunks/{[externals]__12m3qoa._.js → [externals]__0f3aqcx._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0-9g1s8._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0-pvfxg._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__01amzh6._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__02q799_._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__03k22rl._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04tqk-j._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__05ovf1y._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__05s-_x7._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07dnyfi._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07zk6qo._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0_59yi6._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ajlo3d._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0b5s54n._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c4fiez._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c9iff1._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +5 -5
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0dh6lzr._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ey83ai._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0h6vdvr._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0lup7p4._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0luxuu4._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0nl2u6u._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0nonp-6._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0oplozy._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0p-6wgd._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0rcnwbw._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0tuz1am._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-9g0ae._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__10ry4ss._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11hv164._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__154_i13._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__17676rc._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bg1alc._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1cvqb1d._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d60gbz._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dm0jmw._.js +6 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dv_b1t._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1fzxip4._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4oj-e._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1i4gq_2._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v1p7in._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9_her._.js +4 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1x1jkpb._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1yd8n5l._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20t_rs8._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/_033w048._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/{_0760z6y._.js → _0907rw0._.js} +15 -15
- package/runtime/hub/apps/hub/.next/server/chunks/_0f3molr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0lgs9kd._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0pyhcqe._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_1-42ili._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_11__3wi._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_12flzuh._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_1bng7w9._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_1rpkqst._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_1wt72m1._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_1x3l5t8._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/packages_relay_dist_control-plane_03a-9aj.js +62 -31
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0xy-j7z._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_1uccfbf._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_010858m.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_04zwxnx.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_06exuc7.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2ldrt.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2tzep.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_116nh32.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_11dyjcb.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_1_4knli.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0ebuy19._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0wxhi0-._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0xe4ick._.js +9 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_14oaveu._.js +4 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_sqlite-proxy_index_1a6wfdg.js +15 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0-pm2yl._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__08-1wwu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0c9mbcn._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0gdfxj4._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0kc-hwp._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0lu73p6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0m1yf2b._.js +4 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0wv-3zo._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__10bfmwi._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__18qvdzb._.js +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1l2urlw._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/{_0ro6vh6._.js → _0r2xlss._.js} +3 -3
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/packages_relay_dist_control-plane_0ve-wz4.js +2 -25
- 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/{2xc1sm79a6tsb.js → 2gsrna76i1d80.js} +1 -1
- package/runtime/hub/apps/hub/attach-helper.cjs +191 -0
- package/runtime/hub/apps/hub/{auth-DC44GQZY.js → auth-IRNNO3IK.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-LALRDYDO.js → auth-config-WJHIMGUE.js} +4 -2
- package/runtime/hub/apps/hub/{chunk-YJ5MJOXK.js → chunk-4LYVBRBC.js} +2094 -220
- package/runtime/hub/apps/hub/chunk-6AVSKCZJ.js +669 -0
- package/runtime/hub/apps/hub/{chunk-QSMPSV5Z.js → chunk-A5Y7LJMU.js} +57 -14
- package/runtime/hub/apps/hub/chunk-EDRFXO2M.js +35 -0
- package/runtime/hub/apps/hub/chunk-F2JI4GMX.js +2891 -0
- package/runtime/hub/apps/hub/{chunk-EHBJKZCL.js → chunk-O3K3ZGFF.js} +500 -35
- package/runtime/hub/apps/hub/chunk-RII6IKNJ.js +688 -0
- package/runtime/hub/apps/hub/{chunk-RXYOWSSN.js → chunk-RMEUA6PA.js} +120 -14
- package/runtime/hub/apps/hub/{chunk-3FJNKSNZ.js → chunk-SCHQR5KR.js} +3 -1
- package/runtime/hub/apps/hub/{dist-6FPPUSWZ.js → dist-2GEAA7QA.js} +15 -3
- package/runtime/hub/apps/hub/{dist-JG45OFT2.js → dist-36O6F6M3.js} +39 -24
- package/runtime/hub/apps/hub/{dist-3I7KUI6W.js → dist-IWLEL2TO.js} +21 -24
- package/runtime/hub/apps/hub/{dist-G6TXUSPZ.js → dist-NYKIT5W5.js} +10 -11
- package/runtime/hub/apps/hub/{dist-EQV4L7KP.js → dist-QB2IJ7OD.js} +7 -1
- package/runtime/hub/apps/hub/{dist-LYDHYTP2.js → dist-RBBXXGLI.js} +129 -26
- package/runtime/hub/apps/hub/{dist-GTVVXCBP.js → dist-RRJN2U5P.js} +10 -14
- package/runtime/hub/apps/hub/{dist-DX6IYMAH.js → dist-UWXGDCK4.js} +14 -11
- package/runtime/hub/apps/hub/{hub-token-COBZGSLS.js → hub-token-6USIMBPQ.js} +2 -2
- package/runtime/hub/apps/hub/hub-worker-SOFWVTWU.js +215 -0
- package/runtime/hub/apps/hub/node-postgres-DIU2H5VP.js +3583 -0
- package/runtime/hub/apps/hub/package.json +5 -2
- package/runtime/hub/apps/hub/{prepared-state-75DIZ55S-2IFNUHHM.js → prepared-state-75DIZ55S-P5FHEORG.js} +1 -1
- package/runtime/hub/apps/hub/server.js +247 -66
- package/runtime/hub/apps/hub/sqlite-proxy-VJS3HIOV.js +2881 -0
- package/runtime/relay/bin.cjs +694 -13
- package/runtime/vercel/ctl.cjs +29199 -16813
- package/dist/_cloud-attach-WDGM6FL5.js +0 -19
- package/dist/chunk-26IKZRTT.js.map +0 -1
- package/dist/chunk-HR7NHH5J.js.map +0 -1
- package/dist/chunk-IDH5A4RR.js.map +0 -1
- package/dist/chunk-JE6UI5YR.js.map +0 -1
- package/dist/chunk-JGZSA5ZI.js.map +0 -1
- package/dist/chunk-LL7NCMUU.js.map +0 -1
- package/dist/chunk-NEF6MDJO.js.map +0 -1
- package/dist/chunk-UJEH2NJT.js.map +0 -1
- package/dist/chunk-V5XXJH63.js.map +0 -1
- package/dist/dist-KQTMCVME.js.map +0 -1
- package/dist/dist-O3LKOIE7.js.map +0 -1
- package/dist/dist-TSFVB7AI.js.map +0 -1
- package/runtime/hub/apps/hub/.next/server/chunks/0zhp_better-auth_dist_adapters_kysely-adapter_index_mjs_1rl4qnh._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04h15ml._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04jgk9x._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07ednlo._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0a7djvw._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ig1bot._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ql4fjo._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0t7o5ed._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vs8fma._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w9ud8u._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0xh14bo._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yhb0gc._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-0flwc._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13ioh5z._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13jwk_k._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16_uteg._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16p2m-g._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__19pc87s._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_gu2yk._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1a50b07._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ai-945._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bu2zio._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ctczev._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d6mtlk._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dn_3i1._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1e4z_-v._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f2sueq._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f9zctr._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4xycg._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1js2jdv._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1md9kdw._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mttufy._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1nepkp-._.js +0 -6
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1pp5oib._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q5bqse._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qwhzmi._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thipug._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9om6g._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1xeczo7._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20503l7._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[externals]_pg_20c820g._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0j0tjwn._.js +0 -3
- /package/dist/{_cloud-attach-WDGM6FL5.js.map → _cloud-attach-XZYF324R.js.map} +0 -0
- /package/dist/{dist-FTKS2GI4.js.map → admin-client-NOZ5CCAH.js.map} +0 -0
- /package/dist/{dist-OO52HARR.js.map → control-plane-2VEM2KCL.js.map} +0 -0
- /package/dist/{dist-U2SVLJUQ.js.map → custody-client-P6XIXHRG.js.map} +0 -0
- /package/dist/{dist-WVYAURMF.js.map → dist-JHMILJUT.js.map} +0 -0
- /package/dist/{dist-Z6L5MM5D.js.map → dist-JOFZOZCY.js.map} +0 -0
- /package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js.map → dist-Q5NY4CF6.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_ssgManifest.js +0 -0
|
@@ -22,24 +22,28 @@ import {
|
|
|
22
22
|
readBoxStatus,
|
|
23
23
|
registerBoxWithRelay,
|
|
24
24
|
syncClaudeCredentials
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-BLWAWGFX.js";
|
|
26
26
|
import {
|
|
27
27
|
hashProjectPath,
|
|
28
28
|
loadEffectiveConfig,
|
|
29
29
|
projectDirSegment,
|
|
30
30
|
sanitizeMnemonic
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-BHJCMTHP.js";
|
|
32
|
+
import {
|
|
33
|
+
DEFAULT_BOX_IMAGE
|
|
34
|
+
} from "./chunk-6P6D77QP.js";
|
|
32
35
|
import {
|
|
33
36
|
AGENT_SYNC_SPECS,
|
|
34
37
|
BOX_DYNAMIC_SYNC_MANIFEST,
|
|
35
38
|
BOX_HOME,
|
|
36
39
|
BOX_MEMORY_DIR,
|
|
37
40
|
BOX_WORKFLOWS_DIR,
|
|
38
|
-
|
|
41
|
+
DEFAULT_ENV_PATTERNS,
|
|
39
42
|
SEED_MARKER,
|
|
40
43
|
SYNC_DRYRUN_ENV,
|
|
41
44
|
UserFacingError,
|
|
42
45
|
allocateProjectIndex,
|
|
46
|
+
boxSshDirForProvider,
|
|
43
47
|
buildHostSyncManifest,
|
|
44
48
|
computeSyncDelta,
|
|
45
49
|
describeInbound,
|
|
@@ -54,6 +58,7 @@ import {
|
|
|
54
58
|
makeSyncContext,
|
|
55
59
|
parseInboundSpec,
|
|
56
60
|
planCarryEntry,
|
|
61
|
+
projectSlugFromOriginUrl,
|
|
57
62
|
pushCredentialToBox,
|
|
58
63
|
pushEnvFiles,
|
|
59
64
|
readCliStamp,
|
|
@@ -65,6 +70,7 @@ import {
|
|
|
65
70
|
renderCarryEntries,
|
|
66
71
|
resolveSyncTopology,
|
|
67
72
|
resyncWorkspace,
|
|
73
|
+
scanHostEnvFiles,
|
|
68
74
|
shouldAcceptCredentialUpdate,
|
|
69
75
|
stageAllAgentStatic,
|
|
70
76
|
stageClaudeCredentialsForUpload,
|
|
@@ -76,8 +82,9 @@ import {
|
|
|
76
82
|
stageOpencodeCredentialsForUpload,
|
|
77
83
|
stageOpencodeStateForUpload,
|
|
78
84
|
stageOpencodeStaticForUpload,
|
|
79
|
-
writeCredentialBackup
|
|
80
|
-
|
|
85
|
+
writeCredentialBackup,
|
|
86
|
+
writePreparedStateRaw
|
|
87
|
+
} from "./chunk-PXYPQ5BO.js";
|
|
81
88
|
|
|
82
89
|
// ../../packages/sandbox-cloud/dist/index.js
|
|
83
90
|
import { basename as basename2, resolve } from "path";
|
|
@@ -115,10 +122,20 @@ import {
|
|
|
115
122
|
} from "path";
|
|
116
123
|
import { posix } from "path";
|
|
117
124
|
import { execa as execa6 } from "execa";
|
|
118
|
-
import {
|
|
119
|
-
import {
|
|
125
|
+
import { readdir as readdir2, readFile as readFile3 } from "fs/promises";
|
|
126
|
+
import { join as join7 } from "path";
|
|
127
|
+
import { createHash } from "crypto";
|
|
128
|
+
import { rm as rm7, writeFile as writeFile4 } from "fs/promises";
|
|
120
129
|
import { tmpdir as tmpdir6 } from "os";
|
|
121
|
-
import {
|
|
130
|
+
import { join as join8 } from "path";
|
|
131
|
+
import { gzipSync } from "zlib";
|
|
132
|
+
import { execa as execa7 } from "execa";
|
|
133
|
+
import { connect } from "net";
|
|
134
|
+
import { execa as execa8 } from "execa";
|
|
135
|
+
import { copyFile, mkdir as mkdir2, mkdtemp as mkdtemp6, rm as rm8, stat } from "fs/promises";
|
|
136
|
+
import { tmpdir as tmpdir7 } from "os";
|
|
137
|
+
import { dirname as dirname2, join as join9 } from "path";
|
|
138
|
+
import { spawn } from "child_process";
|
|
122
139
|
function quoteShellArgv(argv) {
|
|
123
140
|
return argv.map(quoteShellArg).join(" ");
|
|
124
141
|
}
|
|
@@ -1466,14 +1483,21 @@ async function registerBoxWithPlane(args) {
|
|
|
1466
1483
|
name: args.name,
|
|
1467
1484
|
kind: "cloud",
|
|
1468
1485
|
backend: args.backend,
|
|
1486
|
+
sandboxId: args.sandboxId,
|
|
1469
1487
|
originUrl: args.originUrl,
|
|
1488
|
+
worktrees: args.worktrees,
|
|
1470
1489
|
bridgeToken: args.bridgeToken,
|
|
1471
1490
|
previewUrl: args.previewUrl,
|
|
1472
1491
|
previewToken: args.previewToken,
|
|
1473
1492
|
createdAt: args.createdAt,
|
|
1474
1493
|
projectIndex: args.projectIndex,
|
|
1475
1494
|
autoApproveHostActions: args.autoApproveHostActions,
|
|
1476
|
-
autoApproveSafeHostActions: args.autoApproveSafeHostActions
|
|
1495
|
+
autoApproveSafeHostActions: args.autoApproveSafeHostActions,
|
|
1496
|
+
publicHost: args.publicHost,
|
|
1497
|
+
image: args.image,
|
|
1498
|
+
webPort: args.webPort,
|
|
1499
|
+
agent: args.agent,
|
|
1500
|
+
projectSlug: args.projectSlug
|
|
1477
1501
|
})
|
|
1478
1502
|
});
|
|
1479
1503
|
if (!res.ok) {
|
|
@@ -1481,6 +1505,256 @@ async function registerBoxWithPlane(args) {
|
|
|
1481
1505
|
throw new Error(`plane register-box \u2192 ${String(res.status)}: ${text}`);
|
|
1482
1506
|
}
|
|
1483
1507
|
}
|
|
1508
|
+
async function pushBoxSshToCustody(args) {
|
|
1509
|
+
const log = args.log ?? (() => {
|
|
1510
|
+
});
|
|
1511
|
+
const sshDir = boxSshDirForProvider(args.provider, args.sandboxId);
|
|
1512
|
+
if (!sshDir) return 0;
|
|
1513
|
+
const entries = await readdir2(sshDir, { withFileTypes: true }).catch(() => []);
|
|
1514
|
+
const files = entries.filter((e) => e.isFile());
|
|
1515
|
+
if (files.length === 0) return 0;
|
|
1516
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
1517
|
+
const base = args.controlPlaneUrl.replace(/\/+$/, "");
|
|
1518
|
+
let pushed = 0;
|
|
1519
|
+
for (const f of files) {
|
|
1520
|
+
try {
|
|
1521
|
+
const data = await readFile3(join7(sshDir, f.name));
|
|
1522
|
+
const path = `boxes/${args.sandboxId}/ssh/${f.name}`;
|
|
1523
|
+
const res = await fetchImpl(`${base}/admin/custody/${path}`, {
|
|
1524
|
+
method: "PUT",
|
|
1525
|
+
headers: {
|
|
1526
|
+
"Content-Type": "application/json",
|
|
1527
|
+
Authorization: `Bearer ${args.adminToken}`
|
|
1528
|
+
},
|
|
1529
|
+
body: JSON.stringify({ data: data.toString("base64") })
|
|
1530
|
+
});
|
|
1531
|
+
if (res.ok) {
|
|
1532
|
+
pushed += 1;
|
|
1533
|
+
} else {
|
|
1534
|
+
log(`custody push ${f.name} \u2192 ${String(res.status)} (continuing)`);
|
|
1535
|
+
}
|
|
1536
|
+
} catch (err) {
|
|
1537
|
+
log(`custody push ${f.name} failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return pushed;
|
|
1541
|
+
}
|
|
1542
|
+
var DEFAULT_REACHABLE_PROBE_MS = 1500;
|
|
1543
|
+
async function hostReachable(url, ms = DEFAULT_REACHABLE_PROBE_MS) {
|
|
1544
|
+
let parsed;
|
|
1545
|
+
try {
|
|
1546
|
+
parsed = new URL(url);
|
|
1547
|
+
} catch {
|
|
1548
|
+
return false;
|
|
1549
|
+
}
|
|
1550
|
+
const port = parsed.port ? Number(parsed.port) : parsed.protocol === "http:" ? 80 : 443;
|
|
1551
|
+
return new Promise((resolve2) => {
|
|
1552
|
+
const socket = connect({ host: parsed.hostname, port });
|
|
1553
|
+
const done = (ok) => {
|
|
1554
|
+
socket.destroy();
|
|
1555
|
+
resolve2(ok);
|
|
1556
|
+
};
|
|
1557
|
+
socket.setTimeout(ms, () => done(false));
|
|
1558
|
+
socket.once("connect", () => done(true));
|
|
1559
|
+
socket.once("error", () => done(false));
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
function deadlineFetch(signal, impl = fetch) {
|
|
1563
|
+
return ((url, init) => impl(url, { ...init, signal }));
|
|
1564
|
+
}
|
|
1565
|
+
var SEED_PUSH_MS = 12e4;
|
|
1566
|
+
var DEFAULT_MAX_BODY_BYTES = 32 * 1024 * 1024;
|
|
1567
|
+
function maxBlobBytes(maxBodyBytes) {
|
|
1568
|
+
return Math.floor(maxBodyBytes * 0.7);
|
|
1569
|
+
}
|
|
1570
|
+
function sha256Hex(data) {
|
|
1571
|
+
return createHash("sha256").update(data).digest("hex");
|
|
1572
|
+
}
|
|
1573
|
+
async function buildProjectSeed(args) {
|
|
1574
|
+
const log = args.log ?? (() => {
|
|
1575
|
+
});
|
|
1576
|
+
const maxTarBytes = maxBlobBytes(args.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES);
|
|
1577
|
+
const items = [];
|
|
1578
|
+
let skippedTarBytes;
|
|
1579
|
+
const tar = await buildUntrackedTar(args.projectRoot);
|
|
1580
|
+
if (tar) {
|
|
1581
|
+
if (tar.length > maxTarBytes) {
|
|
1582
|
+
skippedTarBytes = tar.length;
|
|
1583
|
+
log(
|
|
1584
|
+
`seed: untracked tar is ${formatBytes(tar.length)} (> ${formatBytes(maxTarBytes)}) \u2014 skipping it; env files still pushed. Raise \`relay.custodyMaxBodyBytes\` to include it.`
|
|
1585
|
+
);
|
|
1586
|
+
} else {
|
|
1587
|
+
items.push({ relPath: "untracked.tar.gz", data: tar });
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
const envRelPaths = args.envPatterns?.length ? await scanHostEnvFiles(args.projectRoot, args.envPatterns) : [];
|
|
1591
|
+
const envTar = await buildTarOf(args.projectRoot, envRelPaths);
|
|
1592
|
+
if (envTar) items.push({ relPath: "env.tar.gz", data: envTar });
|
|
1593
|
+
const manifest = {
|
|
1594
|
+
...await readSeedRepoMeta(args.projectRoot),
|
|
1595
|
+
files: items.map((i) => ({ path: i.relPath, sha256: sha256Hex(i.data), bytes: i.data.length }))
|
|
1596
|
+
};
|
|
1597
|
+
return { items, manifest, skippedTarBytes, envFiles: envRelPaths };
|
|
1598
|
+
}
|
|
1599
|
+
async function readSeedRepoMeta(projectRoot) {
|
|
1600
|
+
return {
|
|
1601
|
+
version: 1,
|
|
1602
|
+
originUrl: await gitOut(projectRoot, ["remote", "get-url", "origin"]) ?? void 0,
|
|
1603
|
+
baseBranch: await gitOut(projectRoot, ["branch", "--show-current"]) ?? void 0,
|
|
1604
|
+
repoHeadSha: await gitOut(projectRoot, ["rev-parse", "HEAD"]) ?? void 0,
|
|
1605
|
+
files: [],
|
|
1606
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
async function gitOut(dir, argv) {
|
|
1610
|
+
const r = await execa7("git", ["-C", dir, ...argv], { reject: false });
|
|
1611
|
+
const out = (r.stdout ?? "").trim();
|
|
1612
|
+
return r.exitCode === 0 && out.length > 0 ? out : null;
|
|
1613
|
+
}
|
|
1614
|
+
async function buildUntrackedTar(repo) {
|
|
1615
|
+
const list = await execa7("git", ["-C", repo, "ls-files", "--others", "--exclude-standard", "-z"], {
|
|
1616
|
+
reject: false
|
|
1617
|
+
});
|
|
1618
|
+
if (list.exitCode !== 0 || list.stdout.length === 0) return null;
|
|
1619
|
+
return tarNulList(repo, list.stdout);
|
|
1620
|
+
}
|
|
1621
|
+
async function buildTarOf(repo, relPaths) {
|
|
1622
|
+
if (relPaths.length === 0) return null;
|
|
1623
|
+
return tarNulList(repo, relPaths.join("\0") + "\0");
|
|
1624
|
+
}
|
|
1625
|
+
async function tarNulList(dir, nulList) {
|
|
1626
|
+
const tar = await execa7("tar", ["-C", dir, "--null", "-T", "-", "-cf", "-"], {
|
|
1627
|
+
input: nulList,
|
|
1628
|
+
env: { ...process.env, COPYFILE_DISABLE: "1" },
|
|
1629
|
+
encoding: "buffer",
|
|
1630
|
+
reject: false,
|
|
1631
|
+
// Normally small (ignored dirs are excluded), but don't let a pathological
|
|
1632
|
+
// tree blow up the host process.
|
|
1633
|
+
maxBuffer: 256 * 1024 * 1024
|
|
1634
|
+
});
|
|
1635
|
+
if (tar.exitCode !== 0) return null;
|
|
1636
|
+
const raw = tar.stdout;
|
|
1637
|
+
if (!raw || raw.length === 0) return null;
|
|
1638
|
+
return gzipSync(raw);
|
|
1639
|
+
}
|
|
1640
|
+
async function pushProjectSeedToCustody(args) {
|
|
1641
|
+
const log = args.log ?? (() => {
|
|
1642
|
+
});
|
|
1643
|
+
const fetchImpl = args.fetchImpl ?? (await hostReachable(args.controlPlaneUrl) ? deadlineFetch(AbortSignal.timeout(SEED_PUSH_MS)) : null);
|
|
1644
|
+
if (!fetchImpl) {
|
|
1645
|
+
log("seed: control box unreachable \u2014 skipping the seed push");
|
|
1646
|
+
const manifest2 = await readSeedRepoMeta(args.projectRoot);
|
|
1647
|
+
return { uploaded: 0, skipped: 0, manifest: manifest2, envFiles: [], dropped: [], unreachable: true };
|
|
1648
|
+
}
|
|
1649
|
+
const built = await buildProjectSeed(args);
|
|
1650
|
+
const prefix = `projects/${args.slug}/seed`;
|
|
1651
|
+
const base = args.controlPlaneUrl.replace(/\/+$/, "");
|
|
1652
|
+
const headers = {
|
|
1653
|
+
"Content-Type": "application/json",
|
|
1654
|
+
Authorization: `Bearer ${args.adminToken}`
|
|
1655
|
+
};
|
|
1656
|
+
const existing = /* @__PURE__ */ new Map();
|
|
1657
|
+
if (!args.force) {
|
|
1658
|
+
try {
|
|
1659
|
+
const res = await fetchImpl(`${base}/admin/custody?prefix=${encodeURIComponent(prefix)}`, {
|
|
1660
|
+
headers
|
|
1661
|
+
});
|
|
1662
|
+
if (res.ok) {
|
|
1663
|
+
const body = await res.json();
|
|
1664
|
+
for (const e of body.entries) existing.set(e.path, e.sha256);
|
|
1665
|
+
}
|
|
1666
|
+
} catch {
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
let uploaded = 0;
|
|
1670
|
+
let skipped = 0;
|
|
1671
|
+
const put = async (relPath, data) => {
|
|
1672
|
+
const path = `${prefix}/${relPath}`;
|
|
1673
|
+
if (!args.force && existing.get(path) === sha256Hex(data)) {
|
|
1674
|
+
skipped += 1;
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
const res = await fetchImpl(`${base}/admin/custody/${encodeCustodyPath(path)}`, {
|
|
1678
|
+
method: "PUT",
|
|
1679
|
+
headers,
|
|
1680
|
+
body: JSON.stringify({ data: data.toString("base64") })
|
|
1681
|
+
});
|
|
1682
|
+
if (!res.ok) {
|
|
1683
|
+
throw new Error(`custody put ${path} \u2192 ${String(res.status)}`);
|
|
1684
|
+
}
|
|
1685
|
+
uploaded += 1;
|
|
1686
|
+
};
|
|
1687
|
+
const dropped = [];
|
|
1688
|
+
for (const item of built.items) {
|
|
1689
|
+
try {
|
|
1690
|
+
await put(item.relPath, item.data);
|
|
1691
|
+
} catch (err) {
|
|
1692
|
+
dropped.push(item.relPath);
|
|
1693
|
+
log(
|
|
1694
|
+
`seed: the control box refused ${item.relPath} (${formatBytes(item.data.length)}): ${err instanceof Error ? err.message : String(err)} \u2014 continuing without it. If it is a size limit, raise AGENTBOX_CUSTODY_MAX_BODY_BYTES on the control box.`
|
|
1695
|
+
);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
const manifest = {
|
|
1699
|
+
...built.manifest,
|
|
1700
|
+
files: built.manifest.files.filter((f) => !dropped.includes(f.path))
|
|
1701
|
+
};
|
|
1702
|
+
await put("manifest.json", Buffer.from(JSON.stringify(manifest, null, 2), "utf8"));
|
|
1703
|
+
log(`seed: ${String(uploaded)} uploaded, ${String(skipped)} unchanged \u2192 custody ${prefix}`);
|
|
1704
|
+
return {
|
|
1705
|
+
uploaded,
|
|
1706
|
+
skipped,
|
|
1707
|
+
manifest,
|
|
1708
|
+
skippedTarBytes: built.skippedTarBytes,
|
|
1709
|
+
envFiles: built.envFiles,
|
|
1710
|
+
dropped
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
var keepExistingFlagCache = null;
|
|
1714
|
+
async function keepExistingFlag() {
|
|
1715
|
+
if (keepExistingFlagCache) return keepExistingFlagCache;
|
|
1716
|
+
const v = await execa7("tar", ["--version"], { reject: false });
|
|
1717
|
+
const isGnu = /GNU tar/i.test(`${v.stdout ?? ""}${v.stderr ?? ""}`);
|
|
1718
|
+
keepExistingFlagCache = isGnu ? "--skip-old-files" : "-k";
|
|
1719
|
+
return keepExistingFlagCache;
|
|
1720
|
+
}
|
|
1721
|
+
async function applyProjectSeed(args) {
|
|
1722
|
+
const log = args.log ?? (() => {
|
|
1723
|
+
});
|
|
1724
|
+
const manifestBlob = await args.source.get("manifest.json").catch(() => null);
|
|
1725
|
+
if (!manifestBlob) return null;
|
|
1726
|
+
let manifest = {};
|
|
1727
|
+
try {
|
|
1728
|
+
manifest = JSON.parse(manifestBlob.toString("utf8"));
|
|
1729
|
+
} catch {
|
|
1730
|
+
}
|
|
1731
|
+
const skipFlag = await keepExistingFlag();
|
|
1732
|
+
let files = 0;
|
|
1733
|
+
for (const name of ["untracked.tar.gz", "env.tar.gz"]) {
|
|
1734
|
+
const blob = await args.source.get(name).catch(() => null);
|
|
1735
|
+
if (!blob) continue;
|
|
1736
|
+
const tmp = join8(tmpdir6(), `agentbox-seed-${process.pid}-${Date.now().toString(36)}-${name}`);
|
|
1737
|
+
try {
|
|
1738
|
+
await writeFile4(tmp, blob);
|
|
1739
|
+
await execa7("tar", ["-C", args.dest, "-xzf", tmp, skipFlag]);
|
|
1740
|
+
files += 1;
|
|
1741
|
+
} catch (err) {
|
|
1742
|
+
log(`seed: ${name} could not be applied: ${err instanceof Error ? err.message : String(err)}`);
|
|
1743
|
+
} finally {
|
|
1744
|
+
await rm7(tmp, { force: true }).catch(() => {
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
return { files, capturedAt: manifest.createdAt, repoHeadSha: manifest.repoHeadSha };
|
|
1749
|
+
}
|
|
1750
|
+
function encodeCustodyPath(path) {
|
|
1751
|
+
return path.split("/").map((s) => encodeURIComponent(s)).join("/");
|
|
1752
|
+
}
|
|
1753
|
+
function formatBytes(n) {
|
|
1754
|
+
if (n < 1024) return `${String(n)}B`;
|
|
1755
|
+
if (n < 1024 * 1024) return `${(n / 1024).toFixed(0)}KB`;
|
|
1756
|
+
return `${(n / (1024 * 1024)).toFixed(1)}MB`;
|
|
1757
|
+
}
|
|
1484
1758
|
var WORKSPACE_DIR_DEFAULT = "/workspace";
|
|
1485
1759
|
async function seedCloudWorkspace(args) {
|
|
1486
1760
|
const workspaceDir = args.workspaceDir ?? WORKSPACE_DIR_DEFAULT;
|
|
@@ -1599,16 +1873,16 @@ async function seedFromGitClone(args) {
|
|
|
1599
1873
|
const log = args.onLog ?? (() => {
|
|
1600
1874
|
});
|
|
1601
1875
|
let conflicts = { mergeConflicts: [], overlaySkipped: [] };
|
|
1602
|
-
const stage = await mkdtemp6(
|
|
1603
|
-
const cloneDir =
|
|
1604
|
-
const tarPath =
|
|
1605
|
-
const untrackedTarPath =
|
|
1876
|
+
const stage = await mkdtemp6(join9(tmpdir7(), "agentbox-clone-"));
|
|
1877
|
+
const cloneDir = join9(stage, "clone");
|
|
1878
|
+
const tarPath = join9(stage, "workspace.tar.gz");
|
|
1879
|
+
const untrackedTarPath = join9(stage, "untracked.tar.gz");
|
|
1606
1880
|
const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
|
|
1607
1881
|
const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
|
|
1608
1882
|
let stashRefCreated = false;
|
|
1609
1883
|
try {
|
|
1610
1884
|
if (stashSha) {
|
|
1611
|
-
const ref = await
|
|
1885
|
+
const ref = await execa8(
|
|
1612
1886
|
"git",
|
|
1613
1887
|
["-C", args.hostRepo, "update-ref", STASH_CARRYOVER_REF, stashSha],
|
|
1614
1888
|
{ reject: false }
|
|
@@ -1633,8 +1907,8 @@ async function seedFromGitClone(args) {
|
|
|
1633
1907
|
log(
|
|
1634
1908
|
`clone tar exceeded ${String(LARGE_BUNDLE_THRESHOLD_BYTES / (1024 * 1024))} MB at depth ${String(DEFAULT_BUNDLE_DEPTH)} (${mb} MB), rebuilding at depth ${String(LARGE_BUNDLE_DEPTH)}`
|
|
1635
1909
|
);
|
|
1636
|
-
await
|
|
1637
|
-
await
|
|
1910
|
+
await rm8(cloneDir, { recursive: true, force: true });
|
|
1911
|
+
await rm8(tarPath, { force: true });
|
|
1638
1912
|
await runShallowClone(args.hostRepo, cloneDir, LARGE_BUNDLE_DEPTH, stashRefCreated, cloneBranch);
|
|
1639
1913
|
await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
|
|
1640
1914
|
await tarCloneDir(cloneDir, tarPath);
|
|
@@ -1702,11 +1976,11 @@ async function seedFromGitClone(args) {
|
|
|
1702
1976
|
if (args.overlay) conflicts = parseSeedConflicts(r.stdout);
|
|
1703
1977
|
} finally {
|
|
1704
1978
|
if (stashRefCreated) {
|
|
1705
|
-
await
|
|
1979
|
+
await execa8("git", ["-C", args.hostRepo, "update-ref", "-d", STASH_CARRYOVER_REF], {
|
|
1706
1980
|
reject: false
|
|
1707
1981
|
});
|
|
1708
1982
|
}
|
|
1709
|
-
await
|
|
1983
|
+
await rm8(stage, { recursive: true, force: true });
|
|
1710
1984
|
}
|
|
1711
1985
|
return conflicts;
|
|
1712
1986
|
}
|
|
@@ -1725,33 +1999,33 @@ async function tryReseedRepoDelta(args) {
|
|
|
1725
1999
|
const checkpointTip = tipRes.stdout.trim();
|
|
1726
2000
|
if (!SHA_RE2.test(checkpointTip)) return null;
|
|
1727
2001
|
const baseRef = args.useBranch ?? args.fromBranch ?? "HEAD";
|
|
1728
|
-
const targetRes = await
|
|
2002
|
+
const targetRes = await execa8("git", ["-C", args.hostRepo, "rev-parse", baseRef], {
|
|
1729
2003
|
reject: false
|
|
1730
2004
|
});
|
|
1731
2005
|
const target = targetRes.stdout.trim();
|
|
1732
2006
|
if (targetRes.exitCode !== 0 || !SHA_RE2.test(target)) return null;
|
|
1733
|
-
const hasTip = await
|
|
2007
|
+
const hasTip = await execa8(
|
|
1734
2008
|
"git",
|
|
1735
2009
|
["-C", args.hostRepo, "cat-file", "-e", `${checkpointTip}^{commit}`],
|
|
1736
2010
|
{ reject: false }
|
|
1737
2011
|
);
|
|
1738
2012
|
if (hasTip.exitCode !== 0) return null;
|
|
1739
|
-
const ancestor = await
|
|
2013
|
+
const ancestor = await execa8(
|
|
1740
2014
|
"git",
|
|
1741
2015
|
["-C", args.hostRepo, "merge-base", "--is-ancestor", checkpointTip, target],
|
|
1742
2016
|
{ reject: false }
|
|
1743
2017
|
);
|
|
1744
2018
|
if (ancestor.exitCode !== 0) return null;
|
|
1745
|
-
const stage = await mkdtemp6(
|
|
1746
|
-
const bundlePath =
|
|
1747
|
-
const untrackedTarPath =
|
|
1748
|
-
const deltaLfsTarPath =
|
|
2019
|
+
const stage = await mkdtemp6(join9(tmpdir7(), "agentbox-delta-"));
|
|
2020
|
+
const bundlePath = join9(stage, "delta.bundle");
|
|
2021
|
+
const untrackedTarPath = join9(stage, "untracked.tar.gz");
|
|
2022
|
+
const deltaLfsTarPath = join9(stage, "delta-lfs.tar.gz");
|
|
1749
2023
|
const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
|
|
1750
2024
|
const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
|
|
1751
2025
|
let stashRefCreated = false;
|
|
1752
2026
|
try {
|
|
1753
2027
|
if (stashSha) {
|
|
1754
|
-
const ref = await
|
|
2028
|
+
const ref = await execa8(
|
|
1755
2029
|
"git",
|
|
1756
2030
|
["-C", args.hostRepo, "update-ref", STASH_CARRYOVER_REF, stashSha],
|
|
1757
2031
|
{ reject: false }
|
|
@@ -1760,7 +2034,7 @@ async function tryReseedRepoDelta(args) {
|
|
|
1760
2034
|
}
|
|
1761
2035
|
const needTarget = target !== checkpointTip;
|
|
1762
2036
|
if (needTarget) {
|
|
1763
|
-
await
|
|
2037
|
+
await execa8("git", ["-C", args.hostRepo, "update-ref", DELTA_TARGET_REF, target], {
|
|
1764
2038
|
reject: false
|
|
1765
2039
|
});
|
|
1766
2040
|
}
|
|
@@ -1769,7 +2043,7 @@ async function tryReseedRepoDelta(args) {
|
|
|
1769
2043
|
if (stashRefCreated) bundleRefs.push(STASH_CARRYOVER_REF);
|
|
1770
2044
|
let haveBundle = false;
|
|
1771
2045
|
if (bundleRefs.length > 0) {
|
|
1772
|
-
const b = await
|
|
2046
|
+
const b = await execa8(
|
|
1773
2047
|
"git",
|
|
1774
2048
|
["-C", args.hostRepo, "bundle", "create", bundlePath, ...bundleRefs, `^${checkpointTip}`],
|
|
1775
2049
|
{ reject: false }
|
|
@@ -1833,14 +2107,14 @@ async function tryReseedRepoDelta(args) {
|
|
|
1833
2107
|
return parseSeedConflicts(r.stdout);
|
|
1834
2108
|
} finally {
|
|
1835
2109
|
if (stashRefCreated) {
|
|
1836
|
-
await
|
|
2110
|
+
await execa8("git", ["-C", args.hostRepo, "update-ref", "-d", STASH_CARRYOVER_REF], {
|
|
1837
2111
|
reject: false
|
|
1838
2112
|
});
|
|
1839
2113
|
}
|
|
1840
|
-
await
|
|
2114
|
+
await execa8("git", ["-C", args.hostRepo, "update-ref", "-d", DELTA_TARGET_REF], {
|
|
1841
2115
|
reject: false
|
|
1842
2116
|
});
|
|
1843
|
-
await
|
|
2117
|
+
await rm8(stage, { recursive: true, force: true });
|
|
1844
2118
|
}
|
|
1845
2119
|
}
|
|
1846
2120
|
async function runShallowClone(hostRepo, cloneDir, depth, includeStashRef, fromBranch) {
|
|
@@ -1848,7 +2122,7 @@ async function runShallowClone(hostRepo, cloneDir, depth, includeStashRef, fromB
|
|
|
1848
2122
|
if (depth !== null) cloneArgs.push(`--depth=${String(depth)}`);
|
|
1849
2123
|
if (fromBranch) cloneArgs.push("--branch", fromBranch);
|
|
1850
2124
|
cloneArgs.push(`file://${hostRepo}`, cloneDir);
|
|
1851
|
-
await
|
|
2125
|
+
await execa8("git", cloneArgs);
|
|
1852
2126
|
if (includeStashRef) {
|
|
1853
2127
|
const fetchArgs = ["-C", cloneDir, "fetch", "--quiet"];
|
|
1854
2128
|
if (depth !== null) fetchArgs.push(`--depth=${String(depth)}`);
|
|
@@ -1856,20 +2130,20 @@ async function runShallowClone(hostRepo, cloneDir, depth, includeStashRef, fromB
|
|
|
1856
2130
|
`file://${hostRepo}`,
|
|
1857
2131
|
`+${STASH_CARRYOVER_REF}:refs/remotes/origin/agentbox-carryover/stash`
|
|
1858
2132
|
);
|
|
1859
|
-
await
|
|
2133
|
+
await execa8("git", fetchArgs, { reject: false });
|
|
1860
2134
|
}
|
|
1861
2135
|
}
|
|
1862
2136
|
async function tarCloneDir(cloneDir, outPath) {
|
|
1863
|
-
await
|
|
2137
|
+
await execa8("tar", ["-C", cloneDir, "-czf", outPath, "."], {
|
|
1864
2138
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
1865
2139
|
});
|
|
1866
2140
|
}
|
|
1867
2141
|
var LFS_OID_RE = /^[0-9a-f]{64}$/;
|
|
1868
2142
|
function lfsObjectRelPath(oid) {
|
|
1869
|
-
return
|
|
2143
|
+
return join9("lfs", "objects", oid.slice(0, 2), oid.slice(2, 4), oid);
|
|
1870
2144
|
}
|
|
1871
2145
|
async function lfsOidsForRef(hostRepo, ref) {
|
|
1872
|
-
const listed = await
|
|
2146
|
+
const listed = await execa8("git", ["-C", hostRepo, "lfs", "ls-files", "--long", ref], {
|
|
1873
2147
|
reject: false
|
|
1874
2148
|
});
|
|
1875
2149
|
if (listed.exitCode !== 0) return [];
|
|
@@ -1877,11 +2151,11 @@ async function lfsOidsForRef(hostRepo, ref) {
|
|
|
1877
2151
|
return [...new Set(oids)];
|
|
1878
2152
|
}
|
|
1879
2153
|
async function seedCloneLfsObjects(hostRepo, cloneDir, ref, log) {
|
|
1880
|
-
const tracked = await
|
|
2154
|
+
const tracked = await execa8("git", ["-C", hostRepo, "lfs", "ls-files", "-n", ref], {
|
|
1881
2155
|
reject: false
|
|
1882
2156
|
});
|
|
1883
2157
|
if (tracked.exitCode !== 0 || tracked.stdout.trim().length === 0) return;
|
|
1884
|
-
const fetched = await
|
|
2158
|
+
const fetched = await execa8("git", ["-C", hostRepo, "lfs", "fetch", "origin", ref], {
|
|
1885
2159
|
reject: false
|
|
1886
2160
|
});
|
|
1887
2161
|
if (fetched.exitCode !== 0) {
|
|
@@ -1892,10 +2166,10 @@ async function seedCloneLfsObjects(hostRepo, cloneDir, ref, log) {
|
|
|
1892
2166
|
let copied = 0;
|
|
1893
2167
|
for (const oid of oids) {
|
|
1894
2168
|
const rel = lfsObjectRelPath(oid);
|
|
1895
|
-
const dst =
|
|
2169
|
+
const dst = join9(cloneDir, ".git", rel);
|
|
1896
2170
|
try {
|
|
1897
2171
|
await mkdir2(dirname2(dst), { recursive: true });
|
|
1898
|
-
await copyFile(
|
|
2172
|
+
await copyFile(join9(hostRepo, ".git", rel), dst);
|
|
1899
2173
|
copied++;
|
|
1900
2174
|
} catch {
|
|
1901
2175
|
}
|
|
@@ -1908,19 +2182,19 @@ async function maybeBuildDeltaLfsTar(hostRepo, target, checkpointTip, outPath) {
|
|
|
1908
2182
|
const have = new Set(await lfsOidsForRef(hostRepo, checkpointTip));
|
|
1909
2183
|
const deltaOids = targetOids.filter((o) => !have.has(o));
|
|
1910
2184
|
if (deltaOids.length === 0) return 0;
|
|
1911
|
-
await
|
|
1912
|
-
const gitDir =
|
|
2185
|
+
await execa8("git", ["-C", hostRepo, "lfs", "fetch", "origin", target], { reject: false });
|
|
2186
|
+
const gitDir = join9(hostRepo, ".git");
|
|
1913
2187
|
const relPaths = [];
|
|
1914
2188
|
for (const oid of deltaOids) {
|
|
1915
2189
|
const rel = lfsObjectRelPath(oid);
|
|
1916
2190
|
try {
|
|
1917
|
-
await stat(
|
|
2191
|
+
await stat(join9(gitDir, rel));
|
|
1918
2192
|
relPaths.push(rel);
|
|
1919
2193
|
} catch {
|
|
1920
2194
|
}
|
|
1921
2195
|
}
|
|
1922
2196
|
if (relPaths.length === 0) return 0;
|
|
1923
|
-
const tar = await
|
|
2197
|
+
const tar = await execa8("tar", ["-C", gitDir, "-czf", outPath, ...relPaths], {
|
|
1924
2198
|
env: { ...process.env, COPYFILE_DISABLE: "1" },
|
|
1925
2199
|
reject: false
|
|
1926
2200
|
});
|
|
@@ -1935,19 +2209,19 @@ async function safeFileSize(path) {
|
|
|
1935
2209
|
}
|
|
1936
2210
|
}
|
|
1937
2211
|
async function safeStashCreate(hostRepo) {
|
|
1938
|
-
const r = await
|
|
2212
|
+
const r = await execa8("git", ["-C", hostRepo, "stash", "create"], { reject: false });
|
|
1939
2213
|
if (r.exitCode !== 0) return null;
|
|
1940
2214
|
const sha = r.stdout.trim();
|
|
1941
2215
|
return sha.length > 0 ? sha : null;
|
|
1942
2216
|
}
|
|
1943
2217
|
async function maybeBuildUntrackedTar(hostRepo, outPath) {
|
|
1944
|
-
const list = await
|
|
2218
|
+
const list = await execa8(
|
|
1945
2219
|
"git",
|
|
1946
2220
|
["-C", hostRepo, "ls-files", "--others", "--exclude-standard", "-z"],
|
|
1947
2221
|
{ reject: false }
|
|
1948
2222
|
);
|
|
1949
2223
|
if (list.exitCode !== 0 || list.stdout.length === 0) return 0;
|
|
1950
|
-
const tar = await
|
|
2224
|
+
const tar = await execa8(
|
|
1951
2225
|
"tar",
|
|
1952
2226
|
["-C", hostRepo, "--null", "-T", "-", "-czf", outPath],
|
|
1953
2227
|
{
|
|
@@ -1966,7 +2240,7 @@ async function maybeBuildUntrackedTar(hostRepo, outPath) {
|
|
|
1966
2240
|
}
|
|
1967
2241
|
}
|
|
1968
2242
|
async function readOriginUrl(hostRepo) {
|
|
1969
|
-
const r = await
|
|
2243
|
+
const r = await execa8("git", ["-C", hostRepo, "remote", "get-url", "origin"], { reject: false });
|
|
1970
2244
|
if (r.exitCode !== 0) return null;
|
|
1971
2245
|
const out = (r.stdout ?? "").trim();
|
|
1972
2246
|
return out.length > 0 ? out : null;
|
|
@@ -1976,10 +2250,10 @@ function wipeDirSteps(dir) {
|
|
|
1976
2250
|
return [`$SUDO mkdir -p ${q}`, `$SUDO find ${q} -mindepth 1 -maxdepth 1 -exec rm -rf {} +`];
|
|
1977
2251
|
}
|
|
1978
2252
|
async function seedFromTar(args) {
|
|
1979
|
-
const stage = await mkdtemp6(
|
|
1980
|
-
const tarPath =
|
|
2253
|
+
const stage = await mkdtemp6(join9(tmpdir7(), "agentbox-tar-"));
|
|
2254
|
+
const tarPath = join9(stage, "workspace.tar.gz");
|
|
1981
2255
|
try {
|
|
1982
|
-
await
|
|
2256
|
+
await execa8("tar", ["-C", args.hostDir, "-czf", tarPath, "."]);
|
|
1983
2257
|
const remoteTar = "/tmp/agentbox-workspace.tar.gz";
|
|
1984
2258
|
await args.backend.uploadFile(args.handle, tarPath, remoteTar);
|
|
1985
2259
|
const SUDO = `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`;
|
|
@@ -2002,9 +2276,16 @@ async function seedFromTar(args) {
|
|
|
2002
2276
|
throw new Error(`workspace seed (tar) failed: ${r.stderr || r.stdout}`);
|
|
2003
2277
|
}
|
|
2004
2278
|
} finally {
|
|
2005
|
-
await
|
|
2279
|
+
await rm8(stage, { recursive: true, force: true });
|
|
2006
2280
|
}
|
|
2007
2281
|
}
|
|
2282
|
+
function seedEnvPatterns(req) {
|
|
2283
|
+
const patterns = [
|
|
2284
|
+
...req.envFilesToImport ?? [],
|
|
2285
|
+
...req.withEnv ? DEFAULT_ENV_PATTERNS : []
|
|
2286
|
+
];
|
|
2287
|
+
return patterns.length > 0 ? patterns : void 0;
|
|
2288
|
+
}
|
|
2008
2289
|
var CLOUD_WORKSPACE_DIR = "/workspace";
|
|
2009
2290
|
var CLOUD_WEB_PROXY_PORT = 80;
|
|
2010
2291
|
var CLOUD_VNC_PORT = 6080;
|
|
@@ -2203,6 +2484,9 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2203
2484
|
previewUrls: Object.keys(mergedPreviews).length > 0 ? mergedPreviews : void 0,
|
|
2204
2485
|
relayPreviewUrl: relayPreview?.url ?? box.cloud?.relayPreviewUrl,
|
|
2205
2486
|
relayPreviewToken: relayPreview?.token ?? box.cloud?.relayPreviewToken,
|
|
2487
|
+
// A VPS IP can change across stop/start — take the live handle's value
|
|
2488
|
+
// when the backend reports one, so the record + the plane stay accurate.
|
|
2489
|
+
publicHost: h.publicHost ?? box.cloud?.publicHost,
|
|
2206
2490
|
// reEnsureCloudBox only runs on a freshly-woken box (start/resume), so
|
|
2207
2491
|
// the box is now running — persist it for the fast `agentbox list` path.
|
|
2208
2492
|
lastState: "running"
|
|
@@ -2237,13 +2521,30 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2237
2521
|
name: box.name,
|
|
2238
2522
|
originUrl,
|
|
2239
2523
|
backend: backend.name,
|
|
2524
|
+
sandboxId: box.cloud.sandboxId,
|
|
2525
|
+
worktrees: [
|
|
2526
|
+
{
|
|
2527
|
+
containerPath: "/workspace",
|
|
2528
|
+
hostMainRepo: box.workspacePath,
|
|
2529
|
+
branch: box.cloud.workspaceBranch ?? `agentbox/${box.name}`,
|
|
2530
|
+
sanctionedBranch: box.cloud.workspaceBranch ?? `agentbox/${box.name}`
|
|
2531
|
+
}
|
|
2532
|
+
],
|
|
2240
2533
|
bridgeToken: box.cloud.bridgeToken,
|
|
2241
2534
|
previewUrl: relayPreview?.url,
|
|
2242
2535
|
previewToken: relayPreview?.token,
|
|
2243
2536
|
createdAt: box.createdAt,
|
|
2244
2537
|
projectIndex: box.projectIndex,
|
|
2245
2538
|
autoApproveHostActions: box.autoApproveHostActions,
|
|
2246
|
-
autoApproveSafeHostActions: box.autoApproveSafeHostActions
|
|
2539
|
+
autoApproveSafeHostActions: box.autoApproveSafeHostActions,
|
|
2540
|
+
// Keep the adoption material fresh across resumes. The VM's public
|
|
2541
|
+
// IP can change on a stop/start, so prefer the live handle's value
|
|
2542
|
+
// over the persisted one.
|
|
2543
|
+
publicHost: h.publicHost ?? box.cloud.publicHost,
|
|
2544
|
+
image: box.cloud.image,
|
|
2545
|
+
webPort: box.cloud.webPort,
|
|
2546
|
+
agent: box.lastAgent,
|
|
2547
|
+
projectSlug: projectSlugFromOriginUrl(originUrl) ?? void 0
|
|
2247
2548
|
});
|
|
2248
2549
|
} catch {
|
|
2249
2550
|
}
|
|
@@ -2296,6 +2597,8 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2296
2597
|
const location = typeof locationOpt === "string" && locationOpt.trim() !== "" ? locationOpt.trim() : void 0;
|
|
2297
2598
|
const inboundOpt = req.providerOptions?.["inbound"];
|
|
2298
2599
|
const inbound = typeof inboundOpt === "string" && inboundOpt.trim() !== "" ? inboundOpt.trim() : void 0;
|
|
2600
|
+
const extraCidrsOpt = req.providerOptions?.["extraInboundCidrs"];
|
|
2601
|
+
const extraInboundCidrs = req.controlPlaneUrl && Array.isArray(extraCidrsOpt) ? extraCidrsOpt.filter((c) => typeof c === "string" && c.trim() !== "") : void 0;
|
|
2299
2602
|
const projectOpt = req.providerOptions?.["project"];
|
|
2300
2603
|
const project = typeof projectOpt === "string" && projectOpt.trim() !== "" ? projectOpt.trim() : void 0;
|
|
2301
2604
|
const hostOpt = req.providerOptions?.["remoteHost"];
|
|
@@ -2365,6 +2668,7 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2365
2668
|
project,
|
|
2366
2669
|
host,
|
|
2367
2670
|
inbound,
|
|
2671
|
+
...extraInboundCidrs && extraInboundCidrs.length > 0 ? { extraInboundCidrs } : {},
|
|
2368
2672
|
sandboxClass,
|
|
2369
2673
|
timeoutMs,
|
|
2370
2674
|
exposePorts: exposeServicePorts,
|
|
@@ -2548,7 +2852,8 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2548
2852
|
}
|
|
2549
2853
|
const state = await readState();
|
|
2550
2854
|
const projectIndex = req.projectRoot ? allocateProjectIndex(state, req.projectRoot) : void 0;
|
|
2551
|
-
const
|
|
2855
|
+
const effectiveForCreate = (await loadEffectiveConfig(req.projectRoot ?? req.workspacePath)).effective;
|
|
2856
|
+
const effectiveBoxForApprove = effectiveForCreate.box;
|
|
2552
2857
|
const autoApproveHostActions = effectiveBoxForApprove.autoApproveHostActions;
|
|
2553
2858
|
const autoApproveSafeHostActions = effectiveBoxForApprove.autoApproveSafeHostActions;
|
|
2554
2859
|
if (req.controlPlaneUrl) {
|
|
@@ -2572,14 +2877,73 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2572
2877
|
name,
|
|
2573
2878
|
originUrl,
|
|
2574
2879
|
backend: backend.name,
|
|
2880
|
+
sandboxId: handle.sandboxId,
|
|
2881
|
+
// hostMainRepo is the create-time seed checkout; on a hub
|
|
2882
|
+
// worker it is a temp clone that gets deleted after create, so
|
|
2883
|
+
// host-side git RPCs won't work against it — but the lease
|
|
2884
|
+
// gate's sanctioned-branch auto-allow reads `branch` from this
|
|
2885
|
+
// registration, which is what a control-plane box pushes with.
|
|
2886
|
+
worktrees: [
|
|
2887
|
+
{
|
|
2888
|
+
containerPath: "/workspace",
|
|
2889
|
+
hostMainRepo: req.workspacePath,
|
|
2890
|
+
branch,
|
|
2891
|
+
sanctionedBranch: branch
|
|
2892
|
+
}
|
|
2893
|
+
],
|
|
2575
2894
|
bridgeToken,
|
|
2576
2895
|
previewUrl: relayPreview?.url,
|
|
2577
2896
|
previewToken: relayPreview?.token,
|
|
2578
2897
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2579
2898
|
projectIndex,
|
|
2580
2899
|
autoApproveHostActions,
|
|
2581
|
-
autoApproveSafeHostActions
|
|
2900
|
+
autoApproveSafeHostActions,
|
|
2901
|
+
// Adoption material: everything a PC needs to rebuild this
|
|
2902
|
+
// box's BoxRecord from the registration alone (`hub adopt`).
|
|
2903
|
+
publicHost: handle.publicHost,
|
|
2904
|
+
image,
|
|
2905
|
+
webPort: wp,
|
|
2906
|
+
agent: req.agent,
|
|
2907
|
+
projectSlug: projectSlugFromOriginUrl(originUrl) ?? void 0
|
|
2582
2908
|
});
|
|
2909
|
+
await pushBoxSshToCustody({
|
|
2910
|
+
controlPlaneUrl: req.controlPlaneUrl,
|
|
2911
|
+
adminToken,
|
|
2912
|
+
provider: backend.name,
|
|
2913
|
+
sandboxId: handle.sandboxId,
|
|
2914
|
+
log
|
|
2915
|
+
}).catch(() => 0);
|
|
2916
|
+
if (!req.inBoxClone) {
|
|
2917
|
+
const slug = projectSlugFromOriginUrl(originUrl);
|
|
2918
|
+
if (slug) {
|
|
2919
|
+
const seed = await pushProjectSeedToCustody({
|
|
2920
|
+
controlPlaneUrl: req.controlPlaneUrl,
|
|
2921
|
+
adminToken,
|
|
2922
|
+
slug,
|
|
2923
|
+
projectRoot: req.workspacePath,
|
|
2924
|
+
// Capture exactly the env set THIS box received — the
|
|
2925
|
+
// wizard's picks plus `--with-env`'s defaults — so a
|
|
2926
|
+
// hub-created box gets what a PC-created one got. Not
|
|
2927
|
+
// DEFAULT_ENV_PATTERNS unconditionally: that would ship
|
|
2928
|
+
// secrets the user deliberately declined to import.
|
|
2929
|
+
envPatterns: seedEnvPatterns(req),
|
|
2930
|
+
// Honour the configured cap, so raising it actually admits a
|
|
2931
|
+
// bigger seed instead of silently dropping the tar.
|
|
2932
|
+
maxBodyBytes: effectiveForCreate.relay.custodyMaxBodyBytes,
|
|
2933
|
+
log
|
|
2934
|
+
}).catch((err) => {
|
|
2935
|
+
log(
|
|
2936
|
+
`seed push to custody failed (continuing): ${err instanceof Error ? err.message : String(err)}`
|
|
2937
|
+
);
|
|
2938
|
+
return null;
|
|
2939
|
+
});
|
|
2940
|
+
if (seed?.unreachable) {
|
|
2941
|
+
log(
|
|
2942
|
+
"WARN: control box unreachable \u2014 this project's seed material (untracked files + env) was NOT stored. Boxes created from the hub will miss them until you run `agentbox hub project push`."
|
|
2943
|
+
);
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2583
2947
|
} catch (err) {
|
|
2584
2948
|
log(
|
|
2585
2949
|
`register with control plane failed (continuing): ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -2661,6 +3025,9 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2661
3025
|
// Real resources the backend reported (Hetzner: the plan's actual
|
|
2662
3026
|
// cores/memory/disk). Absent → readers fall back to defaultResources.
|
|
2663
3027
|
resources: handle.resources,
|
|
3028
|
+
// Public VM IP (direct-SSH backends), so the resume re-registration
|
|
3029
|
+
// and a PC's `hub adopt` can rebuild the SSH target without an API call.
|
|
3030
|
+
publicHost: handle.publicHost,
|
|
2664
3031
|
// Inbound-access policy the backend applied to the per-box firewall
|
|
2665
3032
|
// (VPS providers). Persisted so drift re-syncs preserve the whitelist.
|
|
2666
3033
|
inbound: handle.inbound,
|
|
@@ -3087,6 +3454,196 @@ function defaultCommand(kind, opts) {
|
|
|
3087
3454
|
function shellSingle(s) {
|
|
3088
3455
|
return "'" + s.replace(/'/g, "'\\''") + "'";
|
|
3089
3456
|
}
|
|
3457
|
+
function emptyCloudStats(provider) {
|
|
3458
|
+
return {
|
|
3459
|
+
source: provider,
|
|
3460
|
+
live: false,
|
|
3461
|
+
cpuPercent: null,
|
|
3462
|
+
memUsedBytes: null,
|
|
3463
|
+
memLimitBytes: null,
|
|
3464
|
+
memPercent: null,
|
|
3465
|
+
pids: null,
|
|
3466
|
+
diskUsedBytes: null,
|
|
3467
|
+
snapshotDiskBytes: null,
|
|
3468
|
+
checkpointVolumeBytes: null,
|
|
3469
|
+
netRxBytes: null,
|
|
3470
|
+
netTxBytes: null,
|
|
3471
|
+
blockReadBytes: null,
|
|
3472
|
+
blockWriteBytes: null,
|
|
3473
|
+
limits: { memoryBytes: null, cpus: null, pidsLimit: null, disk: null },
|
|
3474
|
+
warnings: []
|
|
3475
|
+
};
|
|
3476
|
+
}
|
|
3477
|
+
function agentStartBanner(binary) {
|
|
3478
|
+
return `printf " agentbox: starting ${binary} (first paint may take a few seconds)...\\r\\n"; `;
|
|
3479
|
+
}
|
|
3480
|
+
function buildCloudAttachInnerCommand(binary, extraArgs) {
|
|
3481
|
+
if (!extraArgs || extraArgs.length === 0) {
|
|
3482
|
+
return `bash -lc '${agentStartBanner(binary)}exec ${binary}'`;
|
|
3483
|
+
}
|
|
3484
|
+
const blob = Buffer.from(
|
|
3485
|
+
extraArgs.map((a) => Buffer.from(a, "utf8").toString("base64")).join("\n"),
|
|
3486
|
+
"utf8"
|
|
3487
|
+
).toString("base64");
|
|
3488
|
+
return `bash -lc '${agentStartBanner(binary)}A=(); while IFS= read -r t; do A+=("$(printf %s "$t" | base64 -d)"); done <<< "$(echo ${blob} | base64 -d)"; exec ${binary} "\${A[@]}"'`;
|
|
3489
|
+
}
|
|
3490
|
+
async function startDetachedSession(provider, box, sessionName, command) {
|
|
3491
|
+
if (!provider.buildAttach) {
|
|
3492
|
+
throw new Error(`provider '${provider.name}' does not support detached sessions`);
|
|
3493
|
+
}
|
|
3494
|
+
const spec = await provider.buildAttach(box, "agent", {
|
|
3495
|
+
sessionName,
|
|
3496
|
+
command,
|
|
3497
|
+
detached: true
|
|
3498
|
+
});
|
|
3499
|
+
try {
|
|
3500
|
+
return await runDetached(spec.argv, spec.env);
|
|
3501
|
+
} finally {
|
|
3502
|
+
if (spec.cleanup) await spec.cleanup();
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
var AGENT_AUTH_FAILURE = /Please run \/login|Invalid authentication credentials|API Error: 401|Invalid API key|\bUnauthorized\b/i;
|
|
3506
|
+
function sleep(ms) {
|
|
3507
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
3508
|
+
}
|
|
3509
|
+
async function verifyDetachedSession(provider, box, sessionName, binary, opts = {}) {
|
|
3510
|
+
const windowMs = opts.windowMs ?? 1e4;
|
|
3511
|
+
const pollMs = opts.pollMs ?? 2e3;
|
|
3512
|
+
const q = `'${sessionName.replace(/'/g, `'\\''`)}'`;
|
|
3513
|
+
const probe = `tmux has-session -t ${q} 2>/dev/null || exit 7; tmux capture-pane -p -t ${q} 2>/dev/null`;
|
|
3514
|
+
const deadline = Date.now() + windowMs;
|
|
3515
|
+
for (; ; ) {
|
|
3516
|
+
let pane = "";
|
|
3517
|
+
try {
|
|
3518
|
+
const r = await provider.exec(box, ["bash", "-lc", probe], { user: "vscode" });
|
|
3519
|
+
if (r.exitCode === 7) {
|
|
3520
|
+
throw new Error(
|
|
3521
|
+
`agent '${binary}' exited immediately after launch in box ${box.name} \u2014 the session did not stay up. Attach to inspect: agentbox ${binary} attach ${box.name}`
|
|
3522
|
+
);
|
|
3523
|
+
}
|
|
3524
|
+
pane = r.stdout;
|
|
3525
|
+
} catch (err) {
|
|
3526
|
+
if (err instanceof Error && err.message.startsWith(`agent '${binary}'`)) throw err;
|
|
3527
|
+
}
|
|
3528
|
+
if (AGENT_AUTH_FAILURE.test(pane)) {
|
|
3529
|
+
throw new Error(
|
|
3530
|
+
`box ${binary} credentials were rejected \u2014 the agent launched but printed an auth error, so no work will run. Refresh them with \`agentbox ${binary} login\`, then re-run.`
|
|
3531
|
+
);
|
|
3532
|
+
}
|
|
3533
|
+
if (Date.now() >= deadline) break;
|
|
3534
|
+
await sleep(pollMs);
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
function runDetached(argv, env) {
|
|
3538
|
+
return new Promise((resolve2) => {
|
|
3539
|
+
const child = spawn(argv[0], argv.slice(1), {
|
|
3540
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
3541
|
+
env: env ? { ...process.env, ...env } : process.env
|
|
3542
|
+
});
|
|
3543
|
+
let stderr = "";
|
|
3544
|
+
child.stderr?.on("data", (c) => {
|
|
3545
|
+
stderr += c.toString("utf8");
|
|
3546
|
+
});
|
|
3547
|
+
child.on("error", (err) => resolve2({ exitCode: 1, stderr: stderr + String(err.message ?? err) }));
|
|
3548
|
+
child.on("exit", (code) => resolve2({ exitCode: code ?? 0, stderr }));
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3551
|
+
async function startDetachedCloudAgent(args) {
|
|
3552
|
+
const { provider, binary, sessionName } = args;
|
|
3553
|
+
let box = args.box;
|
|
3554
|
+
const state = await provider.probeState(box);
|
|
3555
|
+
if (state === "missing") {
|
|
3556
|
+
throw new Error(`cloud sandbox for ${box.name} is missing; was it destroyed?`);
|
|
3557
|
+
}
|
|
3558
|
+
if (state !== "running") {
|
|
3559
|
+
box = await provider.start(box);
|
|
3560
|
+
}
|
|
3561
|
+
let extraArgs = args.extraArgs;
|
|
3562
|
+
if ((!extraArgs || extraArgs.length === 0) && args.resolveResumeArgs) {
|
|
3563
|
+
const resume = await args.resolveResumeArgs(box);
|
|
3564
|
+
if (resume) extraArgs = resume;
|
|
3565
|
+
}
|
|
3566
|
+
const command = buildCloudAttachInnerCommand(binary, extraArgs);
|
|
3567
|
+
const { exitCode, stderr } = await startDetachedSession(provider, box, sessionName, command);
|
|
3568
|
+
if (exitCode !== 0) {
|
|
3569
|
+
const detail = stderr.trim().slice(0, 500);
|
|
3570
|
+
throw new Error(
|
|
3571
|
+
`failed to start the ${binary} session in box ${box.name} (exit ${String(exitCode)})` + (detail ? `: ${detail}` : "")
|
|
3572
|
+
);
|
|
3573
|
+
}
|
|
3574
|
+
await verifyDetachedSession(provider, box, sessionName, binary, args.verify);
|
|
3575
|
+
return box;
|
|
3576
|
+
}
|
|
3577
|
+
var PREPARED_FETCH_MS = 1e4;
|
|
3578
|
+
function preparedCustodyPath(provider) {
|
|
3579
|
+
return `prepared/${provider}.json`;
|
|
3580
|
+
}
|
|
3581
|
+
async function reachableFetch(target) {
|
|
3582
|
+
if (target.fetchImpl) return target.fetchImpl;
|
|
3583
|
+
if (!await hostReachable(target.controlPlaneUrl)) return null;
|
|
3584
|
+
return deadlineFetch(AbortSignal.timeout(PREPARED_FETCH_MS));
|
|
3585
|
+
}
|
|
3586
|
+
async function pushPreparedToCustody(provider, target) {
|
|
3587
|
+
const log = target.log ?? (() => {
|
|
3588
|
+
});
|
|
3589
|
+
const local = readPreparedStateRaw(provider);
|
|
3590
|
+
if (!local?.base) return false;
|
|
3591
|
+
const fetchImpl = await reachableFetch(target);
|
|
3592
|
+
if (!fetchImpl) return false;
|
|
3593
|
+
const url = `${target.controlPlaneUrl.replace(/\/+$/, "")}/admin/custody/${preparedCustodyPath(provider)}`;
|
|
3594
|
+
try {
|
|
3595
|
+
const res = await fetchImpl(url, {
|
|
3596
|
+
method: "PUT",
|
|
3597
|
+
headers: {
|
|
3598
|
+
"Content-Type": "application/json",
|
|
3599
|
+
Authorization: `Bearer ${target.adminToken}`
|
|
3600
|
+
},
|
|
3601
|
+
body: JSON.stringify({
|
|
3602
|
+
data: Buffer.from(JSON.stringify(local), "utf8").toString("base64")
|
|
3603
|
+
})
|
|
3604
|
+
});
|
|
3605
|
+
if (!res.ok) {
|
|
3606
|
+
log(`prepared: could not share the ${provider} bake with the control box (${String(res.status)})`);
|
|
3607
|
+
return false;
|
|
3608
|
+
}
|
|
3609
|
+
log(`prepared: shared the ${provider} bake with the control box`);
|
|
3610
|
+
return true;
|
|
3611
|
+
} catch (err) {
|
|
3612
|
+
log(`prepared: could not share the ${provider} bake (${err instanceof Error ? err.message : String(err)})`);
|
|
3613
|
+
return false;
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
async function pullPreparedFromCustody(provider, currentFingerprint, target) {
|
|
3617
|
+
const log = target.log ?? (() => {
|
|
3618
|
+
});
|
|
3619
|
+
if (!currentFingerprint) return { adopted: false };
|
|
3620
|
+
const fetchImpl = await reachableFetch(target);
|
|
3621
|
+
if (!fetchImpl) return { adopted: false };
|
|
3622
|
+
const url = `${target.controlPlaneUrl.replace(/\/+$/, "")}/admin/custody/${preparedCustodyPath(provider)}`;
|
|
3623
|
+
try {
|
|
3624
|
+
const res = await fetchImpl(url, {
|
|
3625
|
+
headers: { Authorization: `Bearer ${target.adminToken}` }
|
|
3626
|
+
});
|
|
3627
|
+
if (res.status === 404 || res.status === 400) return { adopted: false };
|
|
3628
|
+
if (!res.ok) return { adopted: false };
|
|
3629
|
+
const body = await res.json();
|
|
3630
|
+
if (typeof body.data !== "string") return { adopted: false };
|
|
3631
|
+
const record = JSON.parse(Buffer.from(body.data, "base64").toString("utf8"));
|
|
3632
|
+
const stored = record.base?.contextSha256;
|
|
3633
|
+
if (!stored) return { adopted: false };
|
|
3634
|
+
if (stored !== currentFingerprint) {
|
|
3635
|
+
log(
|
|
3636
|
+
`prepared: the control box's ${provider} bake is from a different build context \u2014 ignoring it and baking locally`
|
|
3637
|
+
);
|
|
3638
|
+
return { adopted: false, mismatch: { stored, current: currentFingerprint } };
|
|
3639
|
+
}
|
|
3640
|
+
writePreparedStateRaw(provider, record);
|
|
3641
|
+
log(`prepared: adopted the control box's ${provider} base (build context matches \u2014 no re-bake needed)`);
|
|
3642
|
+
return { adopted: true };
|
|
3643
|
+
} catch {
|
|
3644
|
+
return { adopted: false };
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3090
3647
|
function remoteTarFor(kind) {
|
|
3091
3648
|
return `/tmp/agentbox-seed-${kind}.tar.gz`;
|
|
3092
3649
|
}
|
|
@@ -3163,14 +3720,183 @@ async function openWebAppOnVncScreen(box, provider) {
|
|
|
3163
3720
|
return { opened: false, reason: err instanceof Error ? err.message : String(err) };
|
|
3164
3721
|
}
|
|
3165
3722
|
}
|
|
3723
|
+
function makeMockCloudBackend(opts = {}) {
|
|
3724
|
+
const name = opts.name ?? "mock";
|
|
3725
|
+
const calls = [];
|
|
3726
|
+
const sandboxes = /* @__PURE__ */ new Map();
|
|
3727
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
3728
|
+
for (const pre of opts.preloaded ?? []) {
|
|
3729
|
+
sandboxes.set(pre.id, {
|
|
3730
|
+
id: pre.id,
|
|
3731
|
+
name: pre.name ?? pre.id,
|
|
3732
|
+
state: pre.state ?? "running",
|
|
3733
|
+
createdAt: pre.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
3734
|
+
image: "mock/preloaded",
|
|
3735
|
+
files: /* @__PURE__ */ new Map()
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3738
|
+
const record = async (method, args) => {
|
|
3739
|
+
calls.push({ method, args });
|
|
3740
|
+
if (opts.beforeCall) await opts.beforeCall(method, args);
|
|
3741
|
+
};
|
|
3742
|
+
const requireSandbox = (id) => {
|
|
3743
|
+
const sb = sandboxes.get(id);
|
|
3744
|
+
if (!sb) throw new Error(`mock backend: sandbox ${id} not found`);
|
|
3745
|
+
return sb;
|
|
3746
|
+
};
|
|
3747
|
+
const backend = {
|
|
3748
|
+
name,
|
|
3749
|
+
get calls() {
|
|
3750
|
+
return calls;
|
|
3751
|
+
},
|
|
3752
|
+
get sandboxes() {
|
|
3753
|
+
return Array.from(sandboxes.values());
|
|
3754
|
+
},
|
|
3755
|
+
clearCalls() {
|
|
3756
|
+
calls.length = 0;
|
|
3757
|
+
},
|
|
3758
|
+
async provision(req) {
|
|
3759
|
+
await record("provision", [req]);
|
|
3760
|
+
const id = `mock-${String(sandboxes.size + 1)}-${req.name}`;
|
|
3761
|
+
sandboxes.set(id, {
|
|
3762
|
+
id,
|
|
3763
|
+
name: req.name,
|
|
3764
|
+
state: "running",
|
|
3765
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3766
|
+
image: req.snapshot ?? req.image,
|
|
3767
|
+
files: /* @__PURE__ */ new Map()
|
|
3768
|
+
});
|
|
3769
|
+
return { sandboxId: id };
|
|
3770
|
+
},
|
|
3771
|
+
async get(sandboxId) {
|
|
3772
|
+
await record("get", [sandboxId]);
|
|
3773
|
+
return sandboxes.has(sandboxId) ? { sandboxId } : null;
|
|
3774
|
+
},
|
|
3775
|
+
async list() {
|
|
3776
|
+
await record("list", []);
|
|
3777
|
+
return Array.from(sandboxes.values()).map((sb) => ({
|
|
3778
|
+
sandboxId: sb.id,
|
|
3779
|
+
name: sb.name,
|
|
3780
|
+
createdAt: sb.createdAt,
|
|
3781
|
+
state: sb.state
|
|
3782
|
+
}));
|
|
3783
|
+
},
|
|
3784
|
+
async start(h) {
|
|
3785
|
+
await record("start", [h]);
|
|
3786
|
+
const sb = requireSandbox(h.sandboxId);
|
|
3787
|
+
sb.state = "running";
|
|
3788
|
+
},
|
|
3789
|
+
async stop(h) {
|
|
3790
|
+
await record("stop", [h]);
|
|
3791
|
+
const sb = requireSandbox(h.sandboxId);
|
|
3792
|
+
sb.state = "stopped";
|
|
3793
|
+
},
|
|
3794
|
+
async pause(h) {
|
|
3795
|
+
await record("pause", [h]);
|
|
3796
|
+
const sb = requireSandbox(h.sandboxId);
|
|
3797
|
+
sb.state = "paused";
|
|
3798
|
+
},
|
|
3799
|
+
async resume(h) {
|
|
3800
|
+
await record("resume", [h]);
|
|
3801
|
+
const sb = requireSandbox(h.sandboxId);
|
|
3802
|
+
sb.state = "running";
|
|
3803
|
+
},
|
|
3804
|
+
async destroy(h) {
|
|
3805
|
+
await record("destroy", [h]);
|
|
3806
|
+
sandboxes.delete(h.sandboxId);
|
|
3807
|
+
},
|
|
3808
|
+
async state(h) {
|
|
3809
|
+
await record("state", [h]);
|
|
3810
|
+
const sb = sandboxes.get(h.sandboxId);
|
|
3811
|
+
return sb ? sb.state : "missing";
|
|
3812
|
+
},
|
|
3813
|
+
async exec(h, cmd, opts2) {
|
|
3814
|
+
await record("exec", [h, cmd, opts2]);
|
|
3815
|
+
requireSandbox(h.sandboxId);
|
|
3816
|
+
return { exitCode: 0, stdout: "", stderr: "" };
|
|
3817
|
+
},
|
|
3818
|
+
async uploadFile(h, localPath, remotePath) {
|
|
3819
|
+
await record("uploadFile", [h, localPath, remotePath]);
|
|
3820
|
+
const sb = requireSandbox(h.sandboxId);
|
|
3821
|
+
sb.files.set(remotePath, new Uint8Array([0]));
|
|
3822
|
+
},
|
|
3823
|
+
async downloadFile(h, remotePath, localPath) {
|
|
3824
|
+
await record("downloadFile", [h, remotePath, localPath]);
|
|
3825
|
+
const sb = requireSandbox(h.sandboxId);
|
|
3826
|
+
if (!sb.files.has(remotePath)) {
|
|
3827
|
+
throw new Error(`mock backend: ${remotePath} not in sandbox ${h.sandboxId}`);
|
|
3828
|
+
}
|
|
3829
|
+
},
|
|
3830
|
+
async listFiles(h, remoteDir) {
|
|
3831
|
+
await record("listFiles", [h, remoteDir]);
|
|
3832
|
+
const sb = requireSandbox(h.sandboxId);
|
|
3833
|
+
const prefix = remoteDir.endsWith("/") ? remoteDir : `${remoteDir}/`;
|
|
3834
|
+
const out = [];
|
|
3835
|
+
for (const p of sb.files.keys()) {
|
|
3836
|
+
if (p.startsWith(prefix)) {
|
|
3837
|
+
out.push({ name: p.slice(prefix.length), isDir: false });
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
return out;
|
|
3841
|
+
},
|
|
3842
|
+
async previewUrl(h, port) {
|
|
3843
|
+
await record("previewUrl", [h, port]);
|
|
3844
|
+
requireSandbox(h.sandboxId);
|
|
3845
|
+
return { url: `https://${String(port)}-${h.sandboxId}.mock.preview`, token: "mock-token" };
|
|
3846
|
+
},
|
|
3847
|
+
async signedPreviewUrl(h, port, expiresInSeconds) {
|
|
3848
|
+
await record("signedPreviewUrl", [h, port, expiresInSeconds]);
|
|
3849
|
+
requireSandbox(h.sandboxId);
|
|
3850
|
+
return {
|
|
3851
|
+
url: `https://${String(port)}-${h.sandboxId}-signed${String(expiresInSeconds)}.mock.preview`
|
|
3852
|
+
};
|
|
3853
|
+
},
|
|
3854
|
+
async attachArgv(h) {
|
|
3855
|
+
await record("attachArgv", [h]);
|
|
3856
|
+
requireSandbox(h.sandboxId);
|
|
3857
|
+
return ["ssh", "-o", "StrictHostKeyChecking=no", `mock-token@${h.sandboxId}.mock.ssh`];
|
|
3858
|
+
},
|
|
3859
|
+
async revokeAttachToken(h, argv) {
|
|
3860
|
+
await record("revokeAttachToken", [h, argv]);
|
|
3861
|
+
},
|
|
3862
|
+
async ensureVolume(volumeName) {
|
|
3863
|
+
await record("ensureVolume", [volumeName]);
|
|
3864
|
+
return { volumeId: `vol-${volumeName}` };
|
|
3865
|
+
},
|
|
3866
|
+
async createSnapshot(h, snapshotName) {
|
|
3867
|
+
await record("createSnapshot", [h, snapshotName]);
|
|
3868
|
+
requireSandbox(h.sandboxId);
|
|
3869
|
+
snapshots.set(snapshotName, { id: snapshotName });
|
|
3870
|
+
},
|
|
3871
|
+
async deleteSnapshot(snapshotName) {
|
|
3872
|
+
await record("deleteSnapshot", [snapshotName]);
|
|
3873
|
+
snapshots.delete(snapshotName);
|
|
3874
|
+
}
|
|
3875
|
+
};
|
|
3876
|
+
return backend;
|
|
3877
|
+
}
|
|
3166
3878
|
|
|
3167
3879
|
export {
|
|
3168
3880
|
quoteShellArgv,
|
|
3169
3881
|
quoteShellArg,
|
|
3170
3882
|
bashScript,
|
|
3883
|
+
createCloudSyncTransport,
|
|
3171
3884
|
ensureAgentVolumesForCloud,
|
|
3172
3885
|
seedAgentVolumesIfFresh,
|
|
3886
|
+
ensureAgentHomeDirsOwned,
|
|
3887
|
+
seedOpencodeModelState,
|
|
3173
3888
|
agentSpecsForCloud,
|
|
3889
|
+
extractCloudAgentCredentials,
|
|
3890
|
+
reconcileAgentCredentials,
|
|
3891
|
+
reconcileAgentCredentialsViaTransport,
|
|
3892
|
+
seedDynamicConfig,
|
|
3893
|
+
seedClaudeJsonAtCreate,
|
|
3894
|
+
seedGitIdentity,
|
|
3895
|
+
seedGitCredentials,
|
|
3896
|
+
uploadEnvFiles,
|
|
3897
|
+
makeCloudSync,
|
|
3898
|
+
CLOUD_CHECKPOINTS_ROOT,
|
|
3899
|
+
CLOUD_SNAPSHOT_NAME_PREFIX,
|
|
3174
3900
|
cloudSnapshotName,
|
|
3175
3901
|
listCloudBackendDirs,
|
|
3176
3902
|
listCloudCheckpoints,
|
|
@@ -3181,12 +3907,37 @@ export {
|
|
|
3181
3907
|
baseFreshnessFromFingerprints,
|
|
3182
3908
|
removeCloudCheckpointDir,
|
|
3183
3909
|
probeCloudCheckpoint,
|
|
3910
|
+
pullCloudDirContents,
|
|
3911
|
+
uploadToCloudBox,
|
|
3912
|
+
downloadFromCloudBox,
|
|
3913
|
+
kickCloudBootstrap,
|
|
3914
|
+
readGitOriginUrl,
|
|
3915
|
+
registerBoxWithPlane,
|
|
3916
|
+
pushBoxSshToCustody,
|
|
3917
|
+
DEFAULT_REACHABLE_PROBE_MS,
|
|
3918
|
+
hostReachable,
|
|
3919
|
+
deadlineFetch,
|
|
3920
|
+
buildProjectSeed,
|
|
3921
|
+
pushProjectSeedToCustody,
|
|
3922
|
+
applyProjectSeed,
|
|
3923
|
+
seedCloudWorkspace,
|
|
3924
|
+
CLOUD_WORKSPACE_DIR,
|
|
3184
3925
|
CLOUD_WEB_PROXY_PORT,
|
|
3185
3926
|
CLOUD_VNC_PORT,
|
|
3186
3927
|
createCloudProvider,
|
|
3187
3928
|
hostTermForCloud,
|
|
3188
3929
|
renderInnerCommand,
|
|
3930
|
+
emptyCloudStats,
|
|
3931
|
+
buildCloudAttachInnerCommand,
|
|
3932
|
+
startDetachedSession,
|
|
3933
|
+
verifyDetachedSession,
|
|
3934
|
+
startDetachedCloudAgent,
|
|
3935
|
+
preparedCustodyPath,
|
|
3936
|
+
pushPreparedToCustody,
|
|
3937
|
+
pullPreparedFromCustody,
|
|
3938
|
+
buildAgentStaticSeedCommands,
|
|
3189
3939
|
seedAgentStaticIntoCloudBox,
|
|
3190
|
-
openWebAppOnVncScreen
|
|
3940
|
+
openWebAppOnVncScreen,
|
|
3941
|
+
makeMockCloudBackend
|
|
3191
3942
|
};
|
|
3192
|
-
//# sourceMappingURL=chunk-
|
|
3943
|
+
//# sourceMappingURL=chunk-3UMM4VJH.js.map
|