@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
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
DEFAULT_RELAY_PORT,
|
|
4
|
+
RELAY_CONTAINER_NAME,
|
|
5
|
+
RELAY_IMAGE_REF,
|
|
6
|
+
RELAY_NETWORK_NAME
|
|
7
|
+
} from "./chunk-ZJL56TJD.js";
|
|
8
|
+
import {
|
|
5
9
|
hashProjectPath,
|
|
6
10
|
loadEffectiveConfig,
|
|
7
|
-
parseUserConfig,
|
|
8
11
|
projectDirSegment,
|
|
9
12
|
sanitizeMnemonic,
|
|
10
13
|
setConfigValue
|
|
11
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BHJCMTHP.js";
|
|
15
|
+
import {
|
|
16
|
+
BUILD_CONTEXT_DIR,
|
|
17
|
+
DEFAULT_BOX_IMAGE,
|
|
18
|
+
computeDockerContextFingerprint,
|
|
19
|
+
ensureImage,
|
|
20
|
+
imageExists,
|
|
21
|
+
imageInfo,
|
|
22
|
+
preparedMatches,
|
|
23
|
+
pullOrBuild,
|
|
24
|
+
readPreparedDockerState
|
|
25
|
+
} from "./chunk-6P6D77QP.js";
|
|
12
26
|
import {
|
|
13
27
|
AmbiguousBoxError,
|
|
14
28
|
BOX_HOME,
|
|
15
|
-
BUILD_CONTEXT_DIR,
|
|
16
29
|
BoxNotFoundError,
|
|
17
30
|
CODEX_PULL_ITEMS,
|
|
18
|
-
DEFAULT_BOX_IMAGE,
|
|
19
31
|
DEFAULT_ENV_PATTERNS,
|
|
20
32
|
ENV_PRUNE_DIRS,
|
|
21
33
|
GitWorktreeError,
|
|
@@ -24,25 +36,20 @@ import {
|
|
|
24
36
|
OPENCODE_PULL_DATA_ITEMS,
|
|
25
37
|
ReplaceError,
|
|
26
38
|
STATE_DIR,
|
|
27
|
-
STATE_FILE,
|
|
28
39
|
SYNC_DRYRUN_ENV,
|
|
29
40
|
addProjectAlias,
|
|
30
41
|
claudeInstallFingerprint,
|
|
31
42
|
claudeInventoryScript,
|
|
32
43
|
computeClaudePullPlan,
|
|
33
|
-
computeDockerContextFingerprint,
|
|
34
44
|
detectGitRepos,
|
|
35
45
|
dryRunProviderSync,
|
|
36
46
|
encodeClaudeProjectsKey,
|
|
37
|
-
ensureImage,
|
|
38
47
|
errSummary,
|
|
39
48
|
filterHostHooks,
|
|
40
49
|
findBox,
|
|
41
50
|
findUnsyncableSymlinks,
|
|
42
51
|
generateBoxId,
|
|
43
52
|
hostOpenCommand,
|
|
44
|
-
imageExists,
|
|
45
|
-
imageInfo,
|
|
46
53
|
makeHostGitPorts,
|
|
47
54
|
makeSyncContext,
|
|
48
55
|
mergeCodexConfigForBox,
|
|
@@ -52,11 +59,8 @@ import {
|
|
|
52
59
|
parseReplacements,
|
|
53
60
|
pickFreshBranch,
|
|
54
61
|
planCarryEntry,
|
|
55
|
-
preparedMatches,
|
|
56
|
-
pullOrBuild,
|
|
57
62
|
pushEnvFiles,
|
|
58
63
|
readCliStamp,
|
|
59
|
-
readPreparedDockerState,
|
|
60
64
|
readState,
|
|
61
65
|
recordBox,
|
|
62
66
|
referencedPluginVersionKeys,
|
|
@@ -70,30 +74,30 @@ import {
|
|
|
70
74
|
syncAgentboxSshConfig,
|
|
71
75
|
trustWorkspace,
|
|
72
76
|
writeClaudeMergedRegistries
|
|
73
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-PXYPQ5BO.js";
|
|
74
78
|
|
|
75
79
|
// ../../packages/sandbox-docker/dist/index.js
|
|
76
80
|
import { spawnSync } from "child_process";
|
|
77
|
-
import { mkdtemp as mkdtemp2, readdir as readdir2, readFile as readFile22, rm as rm2, stat as stat2, writeFile
|
|
81
|
+
import { mkdtemp as mkdtemp2, readdir as readdir2, readFile as readFile22, rm as rm2, stat as stat2, writeFile } from "fs/promises";
|
|
78
82
|
import { homedir as homedir2, tmpdir as tmpdir2 } from "os";
|
|
79
83
|
import { join as join3 } from "path";
|
|
80
84
|
import { setTimeout as delay } from "timers/promises";
|
|
81
85
|
import { execa as execa5 } from "execa";
|
|
82
|
-
import { execa
|
|
83
|
-
import { mkdir
|
|
84
|
-
import { createHash
|
|
86
|
+
import { execa } from "execa";
|
|
87
|
+
import { mkdir, readFile, readdir, stat } from "fs/promises";
|
|
88
|
+
import { createHash } from "crypto";
|
|
85
89
|
import { homedir } from "os";
|
|
86
|
-
import { dirname as dirname2, join as
|
|
90
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
87
91
|
import { execa as execa4 } from "execa";
|
|
88
92
|
import { existsSync, mkdirSync, renameSync, statSync } from "fs";
|
|
89
93
|
import { basename, dirname, posix, resolve } from "path";
|
|
90
|
-
import { execa as
|
|
94
|
+
import { execa as execa2 } from "execa";
|
|
91
95
|
import { createReadStream } from "fs";
|
|
92
96
|
import { mkdtemp, rm } from "fs/promises";
|
|
93
97
|
import { tmpdir } from "os";
|
|
94
98
|
import { join } from "path";
|
|
95
|
-
import { execa as
|
|
96
|
-
import { chmod, mkdir as
|
|
99
|
+
import { execa as execa3 } from "execa";
|
|
100
|
+
import { chmod, mkdir as mkdir2 } from "fs/promises";
|
|
97
101
|
import { basename as basename2, join as join4 } from "path";
|
|
98
102
|
import { execa as execa6 } from "execa";
|
|
99
103
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
@@ -1001,18 +1005,19 @@ async function loadCarrySection(path) {
|
|
|
1001
1005
|
}
|
|
1002
1006
|
|
|
1003
1007
|
// ../../packages/sandbox-docker/dist/index.js
|
|
1004
|
-
import { randomBytes
|
|
1008
|
+
import { randomBytes } from "crypto";
|
|
1005
1009
|
import { execa as execa10 } from "execa";
|
|
1006
1010
|
import { existsSync as existsSync2 } from "fs";
|
|
1007
|
-
import { readFile as
|
|
1011
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
1008
1012
|
import { homedir as homedir6 } from "os";
|
|
1009
1013
|
import { join as join8 } from "path";
|
|
1014
|
+
import { connect } from "net";
|
|
1010
1015
|
import { execa as execa11 } from "execa";
|
|
1011
1016
|
import { execa as execa12 } from "execa";
|
|
1012
|
-
import { mkdir as mkdir3, readdir as
|
|
1017
|
+
import { mkdir as mkdir3, readdir as readdir3, rm as rm3, stat as stat5 } from "fs/promises";
|
|
1013
1018
|
import { homedir as homedir7, platform } from "os";
|
|
1014
1019
|
import { join as join9, resolve as resolve2 } from "path";
|
|
1015
|
-
import { mkdir as mkdir4, mkdtemp as mkdtemp3, readFile as readFile5, readdir as readdir4, rm as rm4, writeFile as
|
|
1020
|
+
import { mkdir as mkdir4, mkdtemp as mkdtemp3, readFile as readFile5, readdir as readdir4, rm as rm4, writeFile as writeFile2 } from "fs/promises";
|
|
1016
1021
|
import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
|
|
1017
1022
|
import { basename as basename3, join as join10 } from "path";
|
|
1018
1023
|
import { execa as execa13 } from "execa";
|
|
@@ -1020,1060 +1025,15 @@ import { stat as stat6 } from "fs/promises";
|
|
|
1020
1025
|
import { execa as execa14 } from "execa";
|
|
1021
1026
|
import { execa as execa15 } from "execa";
|
|
1022
1027
|
import { spawn } from "child_process";
|
|
1023
|
-
import { randomBytes as
|
|
1028
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
1024
1029
|
import { existsSync as existsSync3, openSync } from "fs";
|
|
1025
|
-
import { cp, mkdir as mkdir5, readFile as readFile6, readdir as readdir5, rename
|
|
1030
|
+
import { cp, mkdir as mkdir5, readFile as readFile6, readdir as readdir5, rename, rm as rm5, unlink, writeFile as writeFile3 } from "fs/promises";
|
|
1026
1031
|
import { request as httpRequest } from "http";
|
|
1027
1032
|
import { createRequire } from "module";
|
|
1028
1033
|
import { homedir as homedir9 } from "os";
|
|
1029
1034
|
import { dirname as dirname3, join as join11, resolve as resolve3, sep } from "path";
|
|
1030
1035
|
import { setTimeout as delay2 } from "timers/promises";
|
|
1031
1036
|
import { fileURLToPath } from "url";
|
|
1032
|
-
|
|
1033
|
-
// ../../packages/relay/dist/chunk-KNZCE7J6.js
|
|
1034
|
-
import { createSign } from "crypto";
|
|
1035
|
-
var DEFAULT_RELAY_PORT = 8787;
|
|
1036
|
-
var RELAY_CONTAINER_NAME = "agentbox-relay";
|
|
1037
|
-
var RELAY_NETWORK_NAME = "agentbox-net";
|
|
1038
|
-
var RELAY_IMAGE_REF = "agentbox/relay:dev";
|
|
1039
|
-
var RELAY_EVENT_RING_SIZE = 1e3;
|
|
1040
|
-
function parseGitRemote(origin) {
|
|
1041
|
-
const trimmed = origin.trim();
|
|
1042
|
-
if (trimmed.length === 0) throw new Error("empty git remote URL");
|
|
1043
|
-
const urlForm = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/i.exec(trimmed);
|
|
1044
|
-
const scpForm = /^(?:[^@/]+@)?([^/:]+):(.+)$/.exec(trimmed);
|
|
1045
|
-
let host;
|
|
1046
|
-
let path;
|
|
1047
|
-
if (urlForm) {
|
|
1048
|
-
host = urlForm[1];
|
|
1049
|
-
path = urlForm[2];
|
|
1050
|
-
} else if (scpForm && !/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) {
|
|
1051
|
-
host = scpForm[1];
|
|
1052
|
-
path = scpForm[2];
|
|
1053
|
-
} else {
|
|
1054
|
-
throw new Error(`unrecognized git remote URL: ${origin}`);
|
|
1055
|
-
}
|
|
1056
|
-
return { host, path: path.replace(/^\/+/, "") };
|
|
1057
|
-
}
|
|
1058
|
-
function toAuthedHttpsUrl(origin, token) {
|
|
1059
|
-
const { host, path } = parseGitRemote(origin);
|
|
1060
|
-
return `https://x-access-token:${token}@${host}/${path}`;
|
|
1061
|
-
}
|
|
1062
|
-
function loadGitHubAppConfig() {
|
|
1063
|
-
const appId = process.env.GITHUB_APP_ID;
|
|
1064
|
-
let key = process.env.GITHUB_APP_PRIVATE_KEY;
|
|
1065
|
-
if (!appId || !key) return null;
|
|
1066
|
-
if (!key.includes("BEGIN")) {
|
|
1067
|
-
try {
|
|
1068
|
-
key = Buffer.from(key, "base64").toString("utf8");
|
|
1069
|
-
} catch {
|
|
1070
|
-
return null;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
const apiBaseUrl = process.env.GITHUB_API_URL || void 0;
|
|
1074
|
-
return { appId, privateKeyPem: key, apiBaseUrl };
|
|
1075
|
-
}
|
|
1076
|
-
function b64url(input) {
|
|
1077
|
-
return Buffer.from(input).toString("base64url");
|
|
1078
|
-
}
|
|
1079
|
-
function appJwt(cfg, nowMs = Date.now()) {
|
|
1080
|
-
const now = Math.floor(nowMs / 1e3);
|
|
1081
|
-
const header = b64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
|
1082
|
-
const payload = b64url(JSON.stringify({ iat: now - 60, exp: now + 540, iss: cfg.appId }));
|
|
1083
|
-
const signingInput = `${header}.${payload}`;
|
|
1084
|
-
const signature = createSign("RSA-SHA256").update(signingInput).sign(cfg.privateKeyPem);
|
|
1085
|
-
return `${signingInput}.${b64url(signature)}`;
|
|
1086
|
-
}
|
|
1087
|
-
var RENEW_BEFORE_MS = 5 * 60 * 1e3;
|
|
1088
|
-
var GitHubAppLeaser = class {
|
|
1089
|
-
cfg;
|
|
1090
|
-
fetchImpl;
|
|
1091
|
-
now;
|
|
1092
|
-
apiBase;
|
|
1093
|
-
cache = /* @__PURE__ */ new Map();
|
|
1094
|
-
installationIds = /* @__PURE__ */ new Map();
|
|
1095
|
-
constructor(cfg, opts = {}) {
|
|
1096
|
-
this.cfg = cfg;
|
|
1097
|
-
this.fetchImpl = opts.fetchImpl ?? fetch;
|
|
1098
|
-
this.now = opts.now ?? Date.now;
|
|
1099
|
-
this.apiBase = (cfg.apiBaseUrl ?? "https://api.github.com").replace(/\/$/, "");
|
|
1100
|
-
}
|
|
1101
|
-
headers(jwt) {
|
|
1102
|
-
return {
|
|
1103
|
-
Authorization: `Bearer ${jwt}`,
|
|
1104
|
-
Accept: "application/vnd.github+json",
|
|
1105
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
1106
|
-
"User-Agent": "agentbox-relay"
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* Resolve the installation id for `owner/repo`, or null when the App is not
|
|
1111
|
-
* installed on it (404). Caches positive lookups. Non-404 errors throw.
|
|
1112
|
-
*/
|
|
1113
|
-
async lookupInstallationId(owner, repo) {
|
|
1114
|
-
const key = `${owner}/${repo}`;
|
|
1115
|
-
const cached2 = this.installationIds.get(key);
|
|
1116
|
-
if (cached2 !== void 0) return cached2;
|
|
1117
|
-
const jwt = appJwt(this.cfg, this.now());
|
|
1118
|
-
const res = await this.fetchImpl(`${this.apiBase}/repos/${owner}/${repo}/installation`, {
|
|
1119
|
-
headers: this.headers(jwt)
|
|
1120
|
-
});
|
|
1121
|
-
if (res.status === 404) return null;
|
|
1122
|
-
if (!res.ok) {
|
|
1123
|
-
throw new Error(`GET installation for ${key} \u2192 ${String(res.status)}`);
|
|
1124
|
-
}
|
|
1125
|
-
const body = await res.json();
|
|
1126
|
-
if (typeof body.id !== "number") throw new Error("installation response missing id");
|
|
1127
|
-
this.installationIds.set(key, body.id);
|
|
1128
|
-
return body.id;
|
|
1129
|
-
}
|
|
1130
|
-
async installationId(owner, repo) {
|
|
1131
|
-
const id = await this.lookupInstallationId(owner, repo);
|
|
1132
|
-
if (id === null) throw new Error(`GitHub App is not installed on ${owner}/${repo}`);
|
|
1133
|
-
return id;
|
|
1134
|
-
}
|
|
1135
|
-
/** Whether the App is installed on `owner/repo` — no token is minted. */
|
|
1136
|
-
async isRepoInstalled(owner, repo) {
|
|
1137
|
-
return await this.lookupInstallationId(owner, repo) !== null;
|
|
1138
|
-
}
|
|
1139
|
-
/**
|
|
1140
|
-
* Mint (or return a cached) installation token scoped to the single repo with
|
|
1141
|
-
* `contents: write` + `pull_requests: write`. Throws on any GitHub error.
|
|
1142
|
-
*/
|
|
1143
|
-
async leaseRepoToken(owner, repo) {
|
|
1144
|
-
const key = `${owner}/${repo}`;
|
|
1145
|
-
const cached2 = this.cache.get(key);
|
|
1146
|
-
if (cached2 && cached2.expiresAtMs - this.now() > RENEW_BEFORE_MS) {
|
|
1147
|
-
return { token: cached2.token, expiresAt: cached2.expiresAt };
|
|
1148
|
-
}
|
|
1149
|
-
const id = await this.installationId(owner, repo);
|
|
1150
|
-
const jwt = appJwt(this.cfg, this.now());
|
|
1151
|
-
const res = await this.fetchImpl(`${this.apiBase}/app/installations/${String(id)}/access_tokens`, {
|
|
1152
|
-
method: "POST",
|
|
1153
|
-
headers: { ...this.headers(jwt), "Content-Type": "application/json" },
|
|
1154
|
-
body: JSON.stringify({
|
|
1155
|
-
repositories: [repo],
|
|
1156
|
-
permissions: { contents: "write", pull_requests: "write" }
|
|
1157
|
-
})
|
|
1158
|
-
});
|
|
1159
|
-
if (!res.ok) {
|
|
1160
|
-
throw new Error(`failed to mint installation token for ${key} (\u2192 ${String(res.status)})`);
|
|
1161
|
-
}
|
|
1162
|
-
const body = await res.json();
|
|
1163
|
-
if (!body.token || !body.expires_at) throw new Error("access_tokens response missing token/expires_at");
|
|
1164
|
-
this.cache.set(key, {
|
|
1165
|
-
token: body.token,
|
|
1166
|
-
expiresAt: body.expires_at,
|
|
1167
|
-
expiresAtMs: Date.parse(body.expires_at)
|
|
1168
|
-
});
|
|
1169
|
-
return { token: body.token, expiresAt: body.expires_at };
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
// ../../packages/relay/dist/chunk-YEQGR3RG.js
|
|
1174
|
-
async function drainOneCreateJob(store, createBox2, workerId) {
|
|
1175
|
-
if (!store.claimNextCreateJob || !store.completeCreateJob) return null;
|
|
1176
|
-
const job = await store.claimNextCreateJob(workerId);
|
|
1177
|
-
if (!job) return null;
|
|
1178
|
-
try {
|
|
1179
|
-
const { boxId } = await createBox2(job.request, job.id);
|
|
1180
|
-
await store.completeCreateJob(job.id, "done", { boxId });
|
|
1181
|
-
} catch (err2) {
|
|
1182
|
-
await store.completeCreateJob(job.id, "failed", {
|
|
1183
|
-
error: err2 instanceof Error ? err2.message : String(err2)
|
|
1184
|
-
});
|
|
1185
|
-
}
|
|
1186
|
-
return job.id;
|
|
1187
|
-
}
|
|
1188
|
-
async function drainCreateJobs(store, createBox2, workerId, max = 10) {
|
|
1189
|
-
let processed = 0;
|
|
1190
|
-
while (processed < max) {
|
|
1191
|
-
const id = await drainOneCreateJob(store, createBox2, workerId);
|
|
1192
|
-
if (!id) break;
|
|
1193
|
-
processed++;
|
|
1194
|
-
}
|
|
1195
|
-
return processed;
|
|
1196
|
-
}
|
|
1197
|
-
var DEFAULT_EVENT_CAP = RELAY_EVENT_RING_SIZE;
|
|
1198
|
-
var SCHEMA_SQL = `
|
|
1199
|
-
CREATE TABLE IF NOT EXISTS boxes (
|
|
1200
|
-
box_id text PRIMARY KEY,
|
|
1201
|
-
token text NOT NULL,
|
|
1202
|
-
origin_url text,
|
|
1203
|
-
data jsonb NOT NULL,
|
|
1204
|
-
registered_at timestamptz NOT NULL DEFAULT now()
|
|
1205
|
-
);
|
|
1206
|
-
CREATE INDEX IF NOT EXISTS boxes_token_idx ON boxes (token);
|
|
1207
|
-
|
|
1208
|
-
CREATE TABLE IF NOT EXISTS events (
|
|
1209
|
-
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
1210
|
-
box_id text NOT NULL,
|
|
1211
|
-
type text NOT NULL,
|
|
1212
|
-
ts text,
|
|
1213
|
-
payload jsonb,
|
|
1214
|
-
received_at timestamptz NOT NULL DEFAULT now()
|
|
1215
|
-
);
|
|
1216
|
-
CREATE INDEX IF NOT EXISTS events_box_idx ON events (box_id, id);
|
|
1217
|
-
|
|
1218
|
-
CREATE TABLE IF NOT EXISTS box_status (
|
|
1219
|
-
box_id text PRIMARY KEY,
|
|
1220
|
-
name text,
|
|
1221
|
-
project_index int,
|
|
1222
|
-
status jsonb NOT NULL,
|
|
1223
|
-
updated_at timestamptz NOT NULL DEFAULT now()
|
|
1224
|
-
);
|
|
1225
|
-
|
|
1226
|
-
CREATE TABLE IF NOT EXISTS prompts (
|
|
1227
|
-
id text PRIMARY KEY,
|
|
1228
|
-
box_id text NOT NULL,
|
|
1229
|
-
ev jsonb NOT NULL,
|
|
1230
|
-
method text NOT NULL,
|
|
1231
|
-
params jsonb,
|
|
1232
|
-
status text NOT NULL DEFAULT 'pending',
|
|
1233
|
-
answer text,
|
|
1234
|
-
cancelled boolean,
|
|
1235
|
-
result jsonb,
|
|
1236
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
1237
|
-
expires_at timestamptz
|
|
1238
|
-
);
|
|
1239
|
-
CREATE INDEX IF NOT EXISTS prompts_box_pending_idx ON prompts (box_id) WHERE status = 'pending';
|
|
1240
|
-
|
|
1241
|
-
CREATE TABLE IF NOT EXISTS create_jobs (
|
|
1242
|
-
id text PRIMARY KEY,
|
|
1243
|
-
status text NOT NULL DEFAULT 'queued',
|
|
1244
|
-
request jsonb NOT NULL,
|
|
1245
|
-
result jsonb,
|
|
1246
|
-
claimed_by text,
|
|
1247
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
1248
|
-
started_at timestamptz,
|
|
1249
|
-
finished_at timestamptz
|
|
1250
|
-
);
|
|
1251
|
-
CREATE INDEX IF NOT EXISTS create_jobs_queued_idx ON create_jobs (created_at) WHERE status = 'queued';
|
|
1252
|
-
`;
|
|
1253
|
-
var PostgresStore = class {
|
|
1254
|
-
eventCap;
|
|
1255
|
-
connectionString;
|
|
1256
|
-
injectedPool;
|
|
1257
|
-
poolPromise = null;
|
|
1258
|
-
constructor(opts = {}) {
|
|
1259
|
-
this.connectionString = opts.connectionString;
|
|
1260
|
-
this.injectedPool = opts.pool;
|
|
1261
|
-
this.eventCap = opts.eventCap ?? DEFAULT_EVENT_CAP;
|
|
1262
|
-
}
|
|
1263
|
-
/** Lazily build (or reuse) the pg Pool. `pg` is imported on first use only. */
|
|
1264
|
-
pool() {
|
|
1265
|
-
if (this.injectedPool) return Promise.resolve(this.injectedPool);
|
|
1266
|
-
if (!this.poolPromise) {
|
|
1267
|
-
this.poolPromise = import("pg").then(({ Pool }) => new Pool({ connectionString: this.connectionString }));
|
|
1268
|
-
}
|
|
1269
|
-
return this.poolPromise;
|
|
1270
|
-
}
|
|
1271
|
-
async query(text, params) {
|
|
1272
|
-
const pool = await this.pool();
|
|
1273
|
-
const res = await pool.query(text, params);
|
|
1274
|
-
return res.rows;
|
|
1275
|
-
}
|
|
1276
|
-
/** Create the tables if absent. Call once on boot (idempotent). */
|
|
1277
|
-
async migrate() {
|
|
1278
|
-
const pool = await this.pool();
|
|
1279
|
-
await pool.query(SCHEMA_SQL);
|
|
1280
|
-
}
|
|
1281
|
-
/** Release the pool (tests / graceful shutdown). No-op for an injected pool. */
|
|
1282
|
-
async close() {
|
|
1283
|
-
if (this.injectedPool) return;
|
|
1284
|
-
if (this.poolPromise) {
|
|
1285
|
-
const pool = await this.poolPromise;
|
|
1286
|
-
await pool.end();
|
|
1287
|
-
this.poolPromise = null;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
// --- boxes ---
|
|
1291
|
-
async registerBox(reg) {
|
|
1292
|
-
const originUrl = reg.originUrl ?? null;
|
|
1293
|
-
await this.query(
|
|
1294
|
-
`INSERT INTO boxes (box_id, token, origin_url, data)
|
|
1295
|
-
VALUES ($1, $2, $3, $4)
|
|
1296
|
-
ON CONFLICT (box_id) DO UPDATE
|
|
1297
|
-
SET token = EXCLUDED.token, origin_url = EXCLUDED.origin_url, data = EXCLUDED.data`,
|
|
1298
|
-
[reg.boxId, reg.token, originUrl, JSON.stringify(reg)]
|
|
1299
|
-
);
|
|
1300
|
-
}
|
|
1301
|
-
async getBox(boxId) {
|
|
1302
|
-
const rows = await this.query(
|
|
1303
|
-
`SELECT data FROM boxes WHERE box_id = $1`,
|
|
1304
|
-
[boxId]
|
|
1305
|
-
);
|
|
1306
|
-
return rows[0]?.data;
|
|
1307
|
-
}
|
|
1308
|
-
async authenticateBox(token) {
|
|
1309
|
-
if (token.length === 0) return null;
|
|
1310
|
-
const rows = await this.query(
|
|
1311
|
-
`SELECT data FROM boxes WHERE token = $1 LIMIT 1`,
|
|
1312
|
-
[token]
|
|
1313
|
-
);
|
|
1314
|
-
return rows[0]?.data ?? null;
|
|
1315
|
-
}
|
|
1316
|
-
async listBoxes() {
|
|
1317
|
-
const rows = await this.query(
|
|
1318
|
-
`SELECT data FROM boxes ORDER BY registered_at`
|
|
1319
|
-
);
|
|
1320
|
-
return rows.map((r) => r.data);
|
|
1321
|
-
}
|
|
1322
|
-
async forgetBox(boxId) {
|
|
1323
|
-
const rows = await this.query(
|
|
1324
|
-
`DELETE FROM boxes WHERE box_id = $1 RETURNING box_id`,
|
|
1325
|
-
[boxId]
|
|
1326
|
-
);
|
|
1327
|
-
return rows.length > 0;
|
|
1328
|
-
}
|
|
1329
|
-
async countBoxes() {
|
|
1330
|
-
const rows = await this.query(`SELECT count(*)::text AS n FROM boxes`);
|
|
1331
|
-
return Number.parseInt(rows[0]?.n ?? "0", 10);
|
|
1332
|
-
}
|
|
1333
|
-
// --- events ---
|
|
1334
|
-
async appendEvent(input) {
|
|
1335
|
-
const rows = await this.query(
|
|
1336
|
-
`INSERT INTO events (box_id, type, ts, payload)
|
|
1337
|
-
VALUES ($1, $2, $3, $4)
|
|
1338
|
-
RETURNING id, received_at`,
|
|
1339
|
-
[input.boxId, input.type, input.ts ?? null, input.payload === void 0 ? null : JSON.stringify(input.payload)]
|
|
1340
|
-
);
|
|
1341
|
-
const id = Number(rows[0].id);
|
|
1342
|
-
if (this.eventCap > 0) {
|
|
1343
|
-
await this.query(`DELETE FROM events WHERE id <= $1`, [id - this.eventCap]);
|
|
1344
|
-
}
|
|
1345
|
-
return {
|
|
1346
|
-
id,
|
|
1347
|
-
boxId: input.boxId,
|
|
1348
|
-
type: input.type,
|
|
1349
|
-
ts: input.ts,
|
|
1350
|
-
payload: input.payload,
|
|
1351
|
-
receivedAt: new Date(rows[0].received_at).toISOString()
|
|
1352
|
-
};
|
|
1353
|
-
}
|
|
1354
|
-
async listEvents(since, boxId) {
|
|
1355
|
-
const rows = boxId !== void 0 ? await this.query(
|
|
1356
|
-
`SELECT id, box_id, type, ts, payload, received_at FROM events
|
|
1357
|
-
WHERE id > $1 AND box_id = $2 ORDER BY id`,
|
|
1358
|
-
[since, boxId]
|
|
1359
|
-
) : await this.query(
|
|
1360
|
-
`SELECT id, box_id, type, ts, payload, received_at FROM events
|
|
1361
|
-
WHERE id > $1 ORDER BY id`,
|
|
1362
|
-
[since]
|
|
1363
|
-
);
|
|
1364
|
-
return rows.map(rowToEvent);
|
|
1365
|
-
}
|
|
1366
|
-
async countEvents() {
|
|
1367
|
-
const rows = await this.query(`SELECT count(*)::text AS n FROM events`);
|
|
1368
|
-
return Number.parseInt(rows[0]?.n ?? "0", 10);
|
|
1369
|
-
}
|
|
1370
|
-
// --- status ---
|
|
1371
|
-
async setStatus(boxId, name, projectIndex, status) {
|
|
1372
|
-
await this.query(
|
|
1373
|
-
`INSERT INTO box_status (box_id, name, project_index, status, updated_at)
|
|
1374
|
-
VALUES ($1, $2, $3, $4, now())
|
|
1375
|
-
ON CONFLICT (box_id) DO UPDATE
|
|
1376
|
-
SET name = EXCLUDED.name, project_index = EXCLUDED.project_index,
|
|
1377
|
-
status = EXCLUDED.status, updated_at = now()`,
|
|
1378
|
-
[boxId, name, projectIndex ?? null, JSON.stringify(status)]
|
|
1379
|
-
);
|
|
1380
|
-
}
|
|
1381
|
-
async getStatus(boxId) {
|
|
1382
|
-
const rows = await this.query(
|
|
1383
|
-
`SELECT status FROM box_status WHERE box_id = $1`,
|
|
1384
|
-
[boxId]
|
|
1385
|
-
);
|
|
1386
|
-
return rows[0]?.status;
|
|
1387
|
-
}
|
|
1388
|
-
async deleteStatus(boxId) {
|
|
1389
|
-
await this.query(`DELETE FROM box_status WHERE box_id = $1`, [boxId]);
|
|
1390
|
-
}
|
|
1391
|
-
/**
|
|
1392
|
-
* All box status snapshots in one query (avoids N+1 over listBoxes +
|
|
1393
|
-
* per-box getStatus). Used by the hosted hub UI to render every box's live
|
|
1394
|
-
* status. Not on the Store interface — only the hosted Postgres path needs it.
|
|
1395
|
-
*/
|
|
1396
|
-
async listStatuses() {
|
|
1397
|
-
const rows = await this.query(
|
|
1398
|
-
`SELECT box_id, status FROM box_status`
|
|
1399
|
-
);
|
|
1400
|
-
return rows.map((r) => ({ boxId: r.box_id, status: r.status }));
|
|
1401
|
-
}
|
|
1402
|
-
// --- prompt mailbox ---
|
|
1403
|
-
async createPrompt(row) {
|
|
1404
|
-
await this.query(
|
|
1405
|
-
`INSERT INTO prompts (id, box_id, ev, method, params, status, answer, cancelled, result, created_at, expires_at)
|
|
1406
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
|
1407
|
-
ON CONFLICT (id) DO NOTHING`,
|
|
1408
|
-
[
|
|
1409
|
-
row.id,
|
|
1410
|
-
row.boxId,
|
|
1411
|
-
JSON.stringify(row.ev),
|
|
1412
|
-
row.method,
|
|
1413
|
-
row.params === void 0 ? null : JSON.stringify(row.params),
|
|
1414
|
-
row.status,
|
|
1415
|
-
row.answer ?? null,
|
|
1416
|
-
row.cancelled ?? null,
|
|
1417
|
-
row.result === void 0 ? null : JSON.stringify(row.result),
|
|
1418
|
-
row.createdAt,
|
|
1419
|
-
row.expiresAt ?? null
|
|
1420
|
-
]
|
|
1421
|
-
);
|
|
1422
|
-
}
|
|
1423
|
-
async getPrompt(promptId) {
|
|
1424
|
-
const rows = await this.query(
|
|
1425
|
-
`SELECT id, box_id, ev, method, params, status, answer, cancelled, result, created_at, expires_at
|
|
1426
|
-
FROM prompts WHERE id = $1`,
|
|
1427
|
-
[promptId]
|
|
1428
|
-
);
|
|
1429
|
-
return rows[0] ? rowToPrompt(rows[0]) : null;
|
|
1430
|
-
}
|
|
1431
|
-
async answerPrompt(promptId, answer, cancelled) {
|
|
1432
|
-
const rows = await this.query(
|
|
1433
|
-
`UPDATE prompts SET status = 'answered', answer = $2, cancelled = $3
|
|
1434
|
-
WHERE id = $1 AND status = 'pending' RETURNING id`,
|
|
1435
|
-
[promptId, answer, cancelled ?? null]
|
|
1436
|
-
);
|
|
1437
|
-
return rows.length > 0;
|
|
1438
|
-
}
|
|
1439
|
-
async listPendingPrompts(boxId) {
|
|
1440
|
-
const rows = await this.query(
|
|
1441
|
-
`SELECT id, box_id, ev, method, params, status, answer, cancelled, result, created_at, expires_at
|
|
1442
|
-
FROM prompts WHERE box_id = $1 AND status = 'pending' ORDER BY created_at`,
|
|
1443
|
-
[boxId]
|
|
1444
|
-
);
|
|
1445
|
-
return rows.map(rowToPrompt);
|
|
1446
|
-
}
|
|
1447
|
-
async setPromptResult(promptId, result) {
|
|
1448
|
-
await this.query(`UPDATE prompts SET result = $2 WHERE id = $1`, [
|
|
1449
|
-
promptId,
|
|
1450
|
-
JSON.stringify(result)
|
|
1451
|
-
]);
|
|
1452
|
-
}
|
|
1453
|
-
// --- box-create job queue ---
|
|
1454
|
-
async enqueueCreateJob(job) {
|
|
1455
|
-
await this.query(
|
|
1456
|
-
`INSERT INTO create_jobs (id, status, request, result, claimed_by, created_at, started_at, finished_at)
|
|
1457
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (id) DO NOTHING`,
|
|
1458
|
-
[
|
|
1459
|
-
job.id,
|
|
1460
|
-
job.status,
|
|
1461
|
-
JSON.stringify(job.request),
|
|
1462
|
-
job.result ? JSON.stringify(job.result) : null,
|
|
1463
|
-
job.claimedBy ?? null,
|
|
1464
|
-
job.createdAt,
|
|
1465
|
-
job.startedAt ?? null,
|
|
1466
|
-
job.finishedAt ?? null
|
|
1467
|
-
]
|
|
1468
|
-
);
|
|
1469
|
-
}
|
|
1470
|
-
async getCreateJob(id) {
|
|
1471
|
-
const rows = await this.query(
|
|
1472
|
-
`SELECT id, status, request, result, claimed_by, created_at, started_at, finished_at
|
|
1473
|
-
FROM create_jobs WHERE id = $1`,
|
|
1474
|
-
[id]
|
|
1475
|
-
);
|
|
1476
|
-
return rows[0] ? rowToJob(rows[0]) : null;
|
|
1477
|
-
}
|
|
1478
|
-
async claimNextCreateJob(workerId) {
|
|
1479
|
-
const rows = await this.query(
|
|
1480
|
-
`UPDATE create_jobs SET status = 'running', claimed_by = $1, started_at = now()
|
|
1481
|
-
WHERE id = (
|
|
1482
|
-
SELECT id FROM create_jobs WHERE status = 'queued'
|
|
1483
|
-
ORDER BY created_at FOR UPDATE SKIP LOCKED LIMIT 1
|
|
1484
|
-
)
|
|
1485
|
-
RETURNING id, status, request, result, claimed_by, created_at, started_at, finished_at`,
|
|
1486
|
-
[workerId]
|
|
1487
|
-
);
|
|
1488
|
-
return rows[0] ? rowToJob(rows[0]) : null;
|
|
1489
|
-
}
|
|
1490
|
-
async completeCreateJob(id, status, result) {
|
|
1491
|
-
await this.query(
|
|
1492
|
-
`UPDATE create_jobs SET status = $2, result = $3, finished_at = now() WHERE id = $1`,
|
|
1493
|
-
[id, status, JSON.stringify(result)]
|
|
1494
|
-
);
|
|
1495
|
-
}
|
|
1496
|
-
};
|
|
1497
|
-
function rowToJob(r) {
|
|
1498
|
-
return {
|
|
1499
|
-
id: r.id,
|
|
1500
|
-
status: r.status,
|
|
1501
|
-
request: r.request,
|
|
1502
|
-
result: r.result ?? void 0,
|
|
1503
|
-
claimedBy: r.claimed_by ?? void 0,
|
|
1504
|
-
createdAt: new Date(r.created_at).toISOString(),
|
|
1505
|
-
startedAt: r.started_at ? new Date(r.started_at).toISOString() : void 0,
|
|
1506
|
-
finishedAt: r.finished_at ? new Date(r.finished_at).toISOString() : void 0
|
|
1507
|
-
};
|
|
1508
|
-
}
|
|
1509
|
-
function rowToPrompt(r) {
|
|
1510
|
-
return {
|
|
1511
|
-
id: r.id,
|
|
1512
|
-
boxId: r.box_id,
|
|
1513
|
-
ev: r.ev,
|
|
1514
|
-
method: r.method,
|
|
1515
|
-
params: r.params ?? void 0,
|
|
1516
|
-
status: r.status,
|
|
1517
|
-
answer: r.answer ?? void 0,
|
|
1518
|
-
cancelled: r.cancelled ?? void 0,
|
|
1519
|
-
result: r.result ?? void 0,
|
|
1520
|
-
createdAt: new Date(r.created_at).toISOString(),
|
|
1521
|
-
expiresAt: r.expires_at ? new Date(r.expires_at).toISOString() : void 0
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
function rowToEvent(r) {
|
|
1525
|
-
return {
|
|
1526
|
-
id: Number(r.id),
|
|
1527
|
-
boxId: r.box_id,
|
|
1528
|
-
type: r.type,
|
|
1529
|
-
ts: r.ts ?? void 0,
|
|
1530
|
-
payload: r.payload ?? void 0,
|
|
1531
|
-
receivedAt: new Date(r.received_at).toISOString()
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
// ../../packages/relay/dist/chunk-GEIE6TWJ.js
|
|
1536
|
-
import { execa } from "execa";
|
|
1537
|
-
import { createHash, randomBytes } from "crypto";
|
|
1538
|
-
|
|
1539
|
-
// ../../packages/integrations/dist/index.js
|
|
1540
|
-
var linearConnector = {
|
|
1541
|
-
service: "linear",
|
|
1542
|
-
hostBin: "linear",
|
|
1543
|
-
detect: {
|
|
1544
|
-
versionArgs: ["--version"],
|
|
1545
|
-
authArgs: ["auth", "whoami"],
|
|
1546
|
-
installHint: "install @schpet/linear-cli: npm i -g @schpet/linear-cli",
|
|
1547
|
-
loginHint: "linear auth login"
|
|
1548
|
-
},
|
|
1549
|
-
ops: {
|
|
1550
|
-
whoami: {
|
|
1551
|
-
write: false,
|
|
1552
|
-
buildArgv: (args) => ["auth", "whoami", ...args]
|
|
1553
|
-
},
|
|
1554
|
-
"issue.list": {
|
|
1555
|
-
write: false,
|
|
1556
|
-
buildArgv: (args) => ["issue", "list", ...args]
|
|
1557
|
-
},
|
|
1558
|
-
"issue.mine": {
|
|
1559
|
-
// The v2-native read for "issues assigned to me" — the README directs
|
|
1560
|
-
// users here in place of the older `issue list --me`. Listed as a
|
|
1561
|
-
// separate op so the shim doesn't reject the canonical form.
|
|
1562
|
-
write: false,
|
|
1563
|
-
buildArgv: (args) => ["issue", "mine", ...args]
|
|
1564
|
-
},
|
|
1565
|
-
"issue.view": {
|
|
1566
|
-
write: false,
|
|
1567
|
-
buildArgv: (args) => ["issue", "view", ...args]
|
|
1568
|
-
},
|
|
1569
|
-
"issue.query": {
|
|
1570
|
-
write: false,
|
|
1571
|
-
buildArgv: (args) => ["issue", "query", ...args]
|
|
1572
|
-
},
|
|
1573
|
-
"team.list": {
|
|
1574
|
-
write: false,
|
|
1575
|
-
buildArgv: (args) => ["team", "list", ...args]
|
|
1576
|
-
},
|
|
1577
|
-
api: {
|
|
1578
|
-
write: false,
|
|
1579
|
-
buildArgv: (args) => ["api", ...args],
|
|
1580
|
-
refuseCall: refuseGraphqlNonQuery
|
|
1581
|
-
},
|
|
1582
|
-
"issue.create": {
|
|
1583
|
-
write: true,
|
|
1584
|
-
buildArgv: (args) => ["issue", "create", ...args]
|
|
1585
|
-
},
|
|
1586
|
-
"issue.update": {
|
|
1587
|
-
write: true,
|
|
1588
|
-
buildArgv: (args) => ["issue", "update", ...args]
|
|
1589
|
-
},
|
|
1590
|
-
"issue.comment": {
|
|
1591
|
-
// Maps to `linear issue comment add` — `@schpet/linear-cli` v2 uses
|
|
1592
|
-
// `add` (not `create`); `add`'s sibling subcommands are `list`,
|
|
1593
|
-
// `update`, `delete`.
|
|
1594
|
-
write: true,
|
|
1595
|
-
buildArgv: (args) => ["issue", "comment", "add", ...args]
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
function refuseGraphqlNonQuery(args) {
|
|
1600
|
-
const refuse = (reason) => ({
|
|
1601
|
-
exitCode: 65,
|
|
1602
|
-
stderr: `linear api: ${reason}
|
|
1603
|
-
`
|
|
1604
|
-
});
|
|
1605
|
-
for (let i = 0; i < args.length; i++) {
|
|
1606
|
-
const arg = args[i] ?? "";
|
|
1607
|
-
if (arg === "--input" || arg.startsWith("--input=")) {
|
|
1608
|
-
return refuse("'--input' (stdin/file body) isn't supported through the relay");
|
|
1609
|
-
}
|
|
1610
|
-
if (arg === "--variable") {
|
|
1611
|
-
const next = args[i + 1] ?? "";
|
|
1612
|
-
if (variableValueIsFileLoad(next)) {
|
|
1613
|
-
return refuse(
|
|
1614
|
-
"'--variable key=@<path>' (host-file load) isn't supported through the relay"
|
|
1615
|
-
);
|
|
1616
|
-
}
|
|
1617
|
-
if (!next.startsWith("--")) i++;
|
|
1618
|
-
continue;
|
|
1619
|
-
}
|
|
1620
|
-
if (arg.startsWith("--variable=")) {
|
|
1621
|
-
if (variableValueIsFileLoad(arg.slice("--variable=".length))) {
|
|
1622
|
-
return refuse(
|
|
1623
|
-
"'--variable=key=@<path>' (host-file load) isn't supported through the relay"
|
|
1624
|
-
);
|
|
1625
|
-
}
|
|
1626
|
-
continue;
|
|
1627
|
-
}
|
|
1628
|
-
if (arg === "--variables-json") {
|
|
1629
|
-
const next = args[i + 1] ?? "";
|
|
1630
|
-
if (!next.startsWith("--")) i++;
|
|
1631
|
-
continue;
|
|
1632
|
-
}
|
|
1633
|
-
if (arg.startsWith("--variables-json=")) {
|
|
1634
|
-
continue;
|
|
1635
|
-
}
|
|
1636
|
-
if (arg.startsWith("--")) continue;
|
|
1637
|
-
const op = firstGraphqlOperationKeyword(arg);
|
|
1638
|
-
if (op === "mutation" || op === "subscription") {
|
|
1639
|
-
return refuse(
|
|
1640
|
-
`only GraphQL queries are proxied (use issue.create / issue.update / issue.comment for writes); detected operation '${op}'`
|
|
1641
|
-
);
|
|
1642
|
-
}
|
|
1643
|
-
if (op === "unparseable") {
|
|
1644
|
-
return refuse(
|
|
1645
|
-
`couldn't classify positional argv ${JSON.stringify(arg)} as a GraphQL operation (expected 'query', 'mutation', 'subscription', or '{')`
|
|
1646
|
-
);
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
return null;
|
|
1650
|
-
}
|
|
1651
|
-
function variableValueIsFileLoad(value) {
|
|
1652
|
-
if (value.startsWith("@")) return true;
|
|
1653
|
-
return value.includes("=@");
|
|
1654
|
-
}
|
|
1655
|
-
function firstGraphqlOperationKeyword(source) {
|
|
1656
|
-
let i = 0;
|
|
1657
|
-
const n = source.length;
|
|
1658
|
-
while (i < n) {
|
|
1659
|
-
const c = source[i];
|
|
1660
|
-
if (/\s/.test(c) || c === "," || c === "\uFEFF") {
|
|
1661
|
-
i++;
|
|
1662
|
-
continue;
|
|
1663
|
-
}
|
|
1664
|
-
if (c === "#") {
|
|
1665
|
-
while (i < n && source[i] !== "\n") i++;
|
|
1666
|
-
continue;
|
|
1667
|
-
}
|
|
1668
|
-
break;
|
|
1669
|
-
}
|
|
1670
|
-
if (i >= n) return null;
|
|
1671
|
-
if (source[i] === "{") return "anonymous";
|
|
1672
|
-
let j = i;
|
|
1673
|
-
while (j < n) {
|
|
1674
|
-
const c = source[j];
|
|
1675
|
-
if (c >= "a" && c <= "z" || c >= "A" && c <= "Z") {
|
|
1676
|
-
j++;
|
|
1677
|
-
} else {
|
|
1678
|
-
break;
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
if (j === i) return "unparseable";
|
|
1682
|
-
return source.slice(i, j).toLowerCase();
|
|
1683
|
-
}
|
|
1684
|
-
var notionConnector = {
|
|
1685
|
-
service: "notion",
|
|
1686
|
-
hostBin: "ntn",
|
|
1687
|
-
detect: {
|
|
1688
|
-
versionArgs: ["--version"],
|
|
1689
|
-
authArgs: ["api", "v1/users/me"],
|
|
1690
|
-
installHint: "install ntn: https://developers.notion.com/reference/notion-cli",
|
|
1691
|
-
loginHint: "ntn login"
|
|
1692
|
-
},
|
|
1693
|
-
ops: {
|
|
1694
|
-
whoami: {
|
|
1695
|
-
write: false,
|
|
1696
|
-
buildArgv: (args) => ["whoami", ...args]
|
|
1697
|
-
},
|
|
1698
|
-
api: {
|
|
1699
|
-
write: false,
|
|
1700
|
-
buildArgv: (args) => ["api", ...args],
|
|
1701
|
-
refuseCall: refuseUnsafeApiCall
|
|
1702
|
-
},
|
|
1703
|
-
"page.create": {
|
|
1704
|
-
write: true,
|
|
1705
|
-
buildArgv: (args) => ["pages", "create", ...args]
|
|
1706
|
-
},
|
|
1707
|
-
"page.update": {
|
|
1708
|
-
write: true,
|
|
1709
|
-
buildArgv: (args) => ["pages", "update", ...args]
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
};
|
|
1713
|
-
var READ_POST_ENDPOINTS = [
|
|
1714
|
-
/^\/?v1\/search$/,
|
|
1715
|
-
/^\/?v1\/databases\/[^/?]+\/query$/,
|
|
1716
|
-
/^\/?v1\/data_sources\/[^/?]+\/query$/
|
|
1717
|
-
];
|
|
1718
|
-
var SAFE_API_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
1719
|
-
"--spec",
|
|
1720
|
-
"--docs",
|
|
1721
|
-
"-h",
|
|
1722
|
-
"--help",
|
|
1723
|
-
"-v",
|
|
1724
|
-
"--verbose",
|
|
1725
|
-
"-V",
|
|
1726
|
-
"--version"
|
|
1727
|
-
]);
|
|
1728
|
-
function refuseUnsafeApiCall(args) {
|
|
1729
|
-
const refuse = (reason) => ({
|
|
1730
|
-
exitCode: 65,
|
|
1731
|
-
stderr: `notion api: ${reason}
|
|
1732
|
-
`
|
|
1733
|
-
});
|
|
1734
|
-
let explicitMethod = null;
|
|
1735
|
-
let hasBody = false;
|
|
1736
|
-
let endpoint = null;
|
|
1737
|
-
for (let i = 0; i < args.length; i++) {
|
|
1738
|
-
const arg = args[i] ?? "";
|
|
1739
|
-
if (arg === "-X" || arg === "--method") {
|
|
1740
|
-
explicitMethod = args[i + 1] ?? "";
|
|
1741
|
-
i++;
|
|
1742
|
-
continue;
|
|
1743
|
-
}
|
|
1744
|
-
if (arg.startsWith("--method=")) {
|
|
1745
|
-
explicitMethod = arg.slice("--method=".length);
|
|
1746
|
-
continue;
|
|
1747
|
-
}
|
|
1748
|
-
if (arg.startsWith("-X") && arg.length > 2) {
|
|
1749
|
-
explicitMethod = arg.slice(2).replace(/^=/, "");
|
|
1750
|
-
continue;
|
|
1751
|
-
}
|
|
1752
|
-
if (arg === "-d" || arg === "--data") {
|
|
1753
|
-
hasBody = true;
|
|
1754
|
-
i++;
|
|
1755
|
-
continue;
|
|
1756
|
-
}
|
|
1757
|
-
if (arg.startsWith("--data=") || arg.startsWith("-d") && arg.length > 2) {
|
|
1758
|
-
hasBody = true;
|
|
1759
|
-
continue;
|
|
1760
|
-
}
|
|
1761
|
-
if (arg === "--file" || arg.startsWith("--file=")) {
|
|
1762
|
-
return refuse("'--file' (host-file upload) isn't supported through the relay");
|
|
1763
|
-
}
|
|
1764
|
-
if (arg === "--input" || arg.startsWith("--input=")) {
|
|
1765
|
-
return refuse("'--input' (stdin/file body) isn't supported through the relay; use -d <JSON>");
|
|
1766
|
-
}
|
|
1767
|
-
if (arg === "--notion-version") {
|
|
1768
|
-
i++;
|
|
1769
|
-
continue;
|
|
1770
|
-
}
|
|
1771
|
-
if (arg.startsWith("--notion-version=")) continue;
|
|
1772
|
-
if (arg.startsWith("-")) {
|
|
1773
|
-
if (SAFE_API_BOOLEAN_FLAGS.has(arg)) continue;
|
|
1774
|
-
return refuse(
|
|
1775
|
-
`unsupported option '${arg}' (read-only api accepts a path, inline inputs, -d <JSON>, -X GET/POST, --notion-version, --spec, --docs)`
|
|
1776
|
-
);
|
|
1777
|
-
}
|
|
1778
|
-
if (endpoint === null) {
|
|
1779
|
-
endpoint = arg;
|
|
1780
|
-
continue;
|
|
1781
|
-
}
|
|
1782
|
-
if (isBodyAssignment(arg)) hasBody = true;
|
|
1783
|
-
}
|
|
1784
|
-
const method = (explicitMethod && explicitMethod.length > 0 ? explicitMethod : hasBody ? "POST" : "GET").toUpperCase();
|
|
1785
|
-
if (method === "GET") return null;
|
|
1786
|
-
if (method !== "POST") {
|
|
1787
|
-
return refuse(
|
|
1788
|
-
`only GET and read-only POST are proxied (use page.create / page.update for writes); detected method '${method}'`
|
|
1789
|
-
);
|
|
1790
|
-
}
|
|
1791
|
-
if (endpoint === null) {
|
|
1792
|
-
return refuse("could not determine the API endpoint for a non-GET call");
|
|
1793
|
-
}
|
|
1794
|
-
if (endpoint.split("/").some((seg) => seg === "." || seg === "..")) {
|
|
1795
|
-
return refuse(`path traversal segments ('.' / '..') are not allowed in '${endpoint}'`);
|
|
1796
|
-
}
|
|
1797
|
-
if (READ_POST_ENDPOINTS.some((re) => re.test(endpoint))) return null;
|
|
1798
|
-
return refuse(
|
|
1799
|
-
`POST is only proxied for read endpoints (v1/search, v1/databases/{id}/query, v1/data_sources/{id}/query); '${endpoint}' is not one (use page.create / page.update for writes)`
|
|
1800
|
-
);
|
|
1801
|
-
}
|
|
1802
|
-
function isBodyAssignment(token) {
|
|
1803
|
-
if (token.includes(":=")) return true;
|
|
1804
|
-
if (token.includes("==")) return false;
|
|
1805
|
-
return token.includes("=");
|
|
1806
|
-
}
|
|
1807
|
-
var ALL_CONNECTORS = [notionConnector, linearConnector];
|
|
1808
|
-
|
|
1809
|
-
// ../../packages/relay/dist/chunk-GEIE6TWJ.js
|
|
1810
|
-
import { execa as execa2 } from "execa";
|
|
1811
|
-
import { spawn as spawn4 } from "child_process";
|
|
1812
|
-
import { randomBytes as randomBytes2 } from "crypto";
|
|
1813
|
-
import {
|
|
1814
|
-
mkdir,
|
|
1815
|
-
readdir,
|
|
1816
|
-
readFile,
|
|
1817
|
-
rename,
|
|
1818
|
-
unlink,
|
|
1819
|
-
writeFile
|
|
1820
|
-
} from "fs/promises";
|
|
1821
|
-
import { join as join2 } from "path";
|
|
1822
|
-
var GH_PR_OPS = [
|
|
1823
|
-
"create",
|
|
1824
|
-
"view",
|
|
1825
|
-
"list",
|
|
1826
|
-
"diff",
|
|
1827
|
-
"checks",
|
|
1828
|
-
"comment",
|
|
1829
|
-
"review",
|
|
1830
|
-
"merge",
|
|
1831
|
-
"checkout",
|
|
1832
|
-
"close",
|
|
1833
|
-
"reopen"
|
|
1834
|
-
];
|
|
1835
|
-
var PR_REVIEW_COMMENT = /^repos\/[^/]+\/[^/]+\/pulls\/\d+\/comments(\?.*)?$/;
|
|
1836
|
-
var PR_REVIEW_COMMENT_REPLY = /^repos\/[^/]+\/[^/]+\/pulls\/\d+\/comments\/\d+\/replies(\?.*)?$/;
|
|
1837
|
-
var GH_API_WRITE_ALLOWED_ENDPOINTS = [
|
|
1838
|
-
PR_REVIEW_COMMENT,
|
|
1839
|
-
PR_REVIEW_COMMENT_REPLY
|
|
1840
|
-
];
|
|
1841
|
-
var GH_API_ALLOWED_ENDPOINTS = [...GH_API_WRITE_ALLOWED_ENDPOINTS];
|
|
1842
|
-
function injectPrCreateHead(op, branch, args) {
|
|
1843
|
-
if (op !== "create") return args;
|
|
1844
|
-
if (!branch || branch === "HEAD") return args;
|
|
1845
|
-
if (hasHeadArg(args)) return args;
|
|
1846
|
-
return ["--head", branch, ...args];
|
|
1847
|
-
}
|
|
1848
|
-
function hasHeadArg(args) {
|
|
1849
|
-
return args.some((a) => a === "--head" || a.startsWith("--head=") || a.startsWith("-H"));
|
|
1850
|
-
}
|
|
1851
|
-
function hashRpcParams(params) {
|
|
1852
|
-
return createHash("sha256").update(canonicalJson(params)).digest("hex");
|
|
1853
|
-
}
|
|
1854
|
-
function canonicalJson(v) {
|
|
1855
|
-
if (v === null) return "null";
|
|
1856
|
-
if (typeof v === "undefined") return "null";
|
|
1857
|
-
if (typeof v === "number") return Number.isFinite(v) ? String(v) : "null";
|
|
1858
|
-
if (typeof v === "boolean") return v ? "true" : "false";
|
|
1859
|
-
if (typeof v === "string") return JSON.stringify(v);
|
|
1860
|
-
if (Array.isArray(v)) return "[" + v.map(canonicalJson).join(",") + "]";
|
|
1861
|
-
if (typeof v === "object") {
|
|
1862
|
-
const entries = Object.entries(v).filter(([k]) => k !== "hostInitiated").filter(([, val]) => val !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
1863
|
-
return "{" + entries.map(([k, val]) => JSON.stringify(k) + ":" + canonicalJson(val)).join(",") + "}";
|
|
1864
|
-
}
|
|
1865
|
-
return "null";
|
|
1866
|
-
}
|
|
1867
|
-
var DEFAULT_HOST_ACTION_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
1868
|
-
var MAX_BODY_BYTES = 1024 * 1024;
|
|
1869
|
-
var QUEUE_DIR = join2(STATE_DIR, "queue");
|
|
1870
|
-
async function loadQueueConfig() {
|
|
1871
|
-
const d = BUILT_IN_DEFAULTS.queue;
|
|
1872
|
-
let global = {};
|
|
1873
|
-
try {
|
|
1874
|
-
global = parseUserConfig(await readFile(GLOBAL_CONFIG_FILE, "utf8"), GLOBAL_CONFIG_FILE);
|
|
1875
|
-
} catch {
|
|
1876
|
-
}
|
|
1877
|
-
const q = global.queue ?? {};
|
|
1878
|
-
return {
|
|
1879
|
-
enabled: q.enabled ?? d.enabled,
|
|
1880
|
-
maxConcurrent: q.maxConcurrent ?? d.maxConcurrent,
|
|
1881
|
-
maxWorking: q.maxWorking ?? d.maxWorking,
|
|
1882
|
-
idleGraceMs: (q.idleGraceSeconds ?? d.idleGraceSeconds) * 1e3
|
|
1883
|
-
};
|
|
1884
|
-
}
|
|
1885
|
-
async function writeJob(job) {
|
|
1886
|
-
await mkdir(QUEUE_DIR, { recursive: true });
|
|
1887
|
-
const final = join2(QUEUE_DIR, `${job.id}.json`);
|
|
1888
|
-
const tmp = `${final}.tmp.${String(process.pid)}.${String(Date.now())}`;
|
|
1889
|
-
await writeFile(tmp, JSON.stringify(job, null, 2) + "\n", "utf8");
|
|
1890
|
-
await rename(tmp, final);
|
|
1891
|
-
}
|
|
1892
|
-
async function enqueueQueueJob(input) {
|
|
1893
|
-
const cfg = await loadQueueConfig();
|
|
1894
|
-
const ceiling = typeof input.maxRunningOverride === "number" && input.maxRunningOverride > 0 ? input.maxRunningOverride : cfg.maxConcurrent;
|
|
1895
|
-
const maxWorking = typeof input.maxWorkingOverride === "number" && input.maxWorkingOverride > 0 ? input.maxWorkingOverride : void 0;
|
|
1896
|
-
const id = randomBytes2(9).toString("hex");
|
|
1897
|
-
const job = {
|
|
1898
|
-
id,
|
|
1899
|
-
agent: input.agent,
|
|
1900
|
-
status: "queued",
|
|
1901
|
-
boxName: input.boxName,
|
|
1902
|
-
providerName: input.providerName,
|
|
1903
|
-
prompt: input.prompt,
|
|
1904
|
-
agentArgs: input.agentArgs,
|
|
1905
|
-
...input.noAgent ? { noAgent: true } : {},
|
|
1906
|
-
...input.setupWizard ? { setupWizard: true } : {},
|
|
1907
|
-
createOpts: input.createOpts,
|
|
1908
|
-
maxConcurrent: ceiling,
|
|
1909
|
-
...maxWorking !== void 0 ? { maxWorking } : {},
|
|
1910
|
-
...input.openTerminal !== void 0 ? { openTerminal: input.openTerminal } : {},
|
|
1911
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1912
|
-
logPath: queueLogPath(id)
|
|
1913
|
-
};
|
|
1914
|
-
await writeJob(job);
|
|
1915
|
-
let runningCount = 0;
|
|
1916
|
-
try {
|
|
1917
|
-
runningCount = await defaultCountRunningBoxes();
|
|
1918
|
-
} catch {
|
|
1919
|
-
runningCount = 0;
|
|
1920
|
-
}
|
|
1921
|
-
return { job, runningCount, maxConcurrent: ceiling };
|
|
1922
|
-
}
|
|
1923
|
-
async function readJob(id) {
|
|
1924
|
-
try {
|
|
1925
|
-
const raw = await readFile(join2(QUEUE_DIR, `${id}.json`), "utf8");
|
|
1926
|
-
return JSON.parse(raw);
|
|
1927
|
-
} catch (err) {
|
|
1928
|
-
if (err.code === "ENOENT") return null;
|
|
1929
|
-
throw err;
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
async function deleteJob(id) {
|
|
1933
|
-
try {
|
|
1934
|
-
await unlink(join2(QUEUE_DIR, `${id}.json`));
|
|
1935
|
-
} catch (err) {
|
|
1936
|
-
if (err.code !== "ENOENT") throw err;
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
async function loadQueue() {
|
|
1940
|
-
let entries;
|
|
1941
|
-
try {
|
|
1942
|
-
entries = await readdir(QUEUE_DIR);
|
|
1943
|
-
} catch (err) {
|
|
1944
|
-
if (err.code === "ENOENT") return [];
|
|
1945
|
-
throw err;
|
|
1946
|
-
}
|
|
1947
|
-
const out = [];
|
|
1948
|
-
for (const name of entries) {
|
|
1949
|
-
if (!name.endsWith(".json")) continue;
|
|
1950
|
-
try {
|
|
1951
|
-
const raw = await readFile(join2(QUEUE_DIR, name), "utf8");
|
|
1952
|
-
out.push(JSON.parse(raw));
|
|
1953
|
-
} catch {
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
out.sort((a, b) => a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : 0);
|
|
1957
|
-
return out;
|
|
1958
|
-
}
|
|
1959
|
-
var TERMINAL_RETENTION_MS = 60 * 60 * 1e3;
|
|
1960
|
-
var SWEEP_INTERVAL_MS = 60 * 1e3;
|
|
1961
|
-
function processAlive(pid) {
|
|
1962
|
-
try {
|
|
1963
|
-
process.kill(pid, 0);
|
|
1964
|
-
return true;
|
|
1965
|
-
} catch {
|
|
1966
|
-
return false;
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
function countInFlightCreateJobs(jobs, accountedBoxIds) {
|
|
1970
|
-
let n = 0;
|
|
1971
|
-
for (const j of jobs) {
|
|
1972
|
-
if (j.kind === "prepare") continue;
|
|
1973
|
-
if (j.status !== "running") continue;
|
|
1974
|
-
if (j.boxId && accountedBoxIds.has(j.boxId)) continue;
|
|
1975
|
-
if (typeof j.pid === "number" && !processAlive(j.pid)) continue;
|
|
1976
|
-
n += 1;
|
|
1977
|
-
}
|
|
1978
|
-
return n;
|
|
1979
|
-
}
|
|
1980
|
-
var RUNNING_COUNT_CACHE_MS = 3e3;
|
|
1981
|
-
var boxStateCache = null;
|
|
1982
|
-
async function defaultCountRunningBoxes() {
|
|
1983
|
-
const { boxCount, stateIds } = await cachedBoxState();
|
|
1984
|
-
let jobs;
|
|
1985
|
-
try {
|
|
1986
|
-
jobs = await loadQueue();
|
|
1987
|
-
} catch {
|
|
1988
|
-
return boxCount;
|
|
1989
|
-
}
|
|
1990
|
-
return boxCount + countInFlightCreateJobs(jobs, stateIds);
|
|
1991
|
-
}
|
|
1992
|
-
async function cachedBoxState() {
|
|
1993
|
-
const now = Date.now();
|
|
1994
|
-
if (boxStateCache && boxStateCache.expiresAt > now) {
|
|
1995
|
-
return { boxCount: boxStateCache.boxCount, stateIds: boxStateCache.stateIds };
|
|
1996
|
-
}
|
|
1997
|
-
const fresh = await uncachedBoxStateCount();
|
|
1998
|
-
boxStateCache = { ...fresh, expiresAt: now + RUNNING_COUNT_CACHE_MS };
|
|
1999
|
-
return fresh;
|
|
2000
|
-
}
|
|
2001
|
-
async function uncachedBoxStateCount() {
|
|
2002
|
-
let boxes;
|
|
2003
|
-
try {
|
|
2004
|
-
boxes = (await readState(STATE_FILE)).boxes;
|
|
2005
|
-
} catch {
|
|
2006
|
-
return { boxCount: 0, stateIds: /* @__PURE__ */ new Set() };
|
|
2007
|
-
}
|
|
2008
|
-
const stateIds = new Set(boxes.map((b) => b.id));
|
|
2009
|
-
if (boxes.length === 0) return { boxCount: 0, stateIds };
|
|
2010
|
-
let boxCount = 0;
|
|
2011
|
-
const dockerBoxes = [];
|
|
2012
|
-
for (const b of boxes) {
|
|
2013
|
-
const provider = b.provider ?? "docker";
|
|
2014
|
-
if (provider === "docker") {
|
|
2015
|
-
dockerBoxes.push(b);
|
|
2016
|
-
} else {
|
|
2017
|
-
boxCount += 1;
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
if (dockerBoxes.length > 0) {
|
|
2021
|
-
const states = await Promise.all(dockerBoxes.map((b) => inspectDockerState(b.container)));
|
|
2022
|
-
for (const s of states) {
|
|
2023
|
-
if (s === "running") boxCount += 1;
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
return { boxCount, stateIds };
|
|
2027
|
-
}
|
|
2028
|
-
function inspectDockerState(containerName) {
|
|
2029
|
-
return new Promise((resolveP) => {
|
|
2030
|
-
const child = spawn4("docker", ["inspect", "--format", "{{.State.Status}}", containerName], {
|
|
2031
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
2032
|
-
});
|
|
2033
|
-
let out = "";
|
|
2034
|
-
let settled = false;
|
|
2035
|
-
const finish = (state) => {
|
|
2036
|
-
if (settled) return;
|
|
2037
|
-
settled = true;
|
|
2038
|
-
resolveP(state);
|
|
2039
|
-
};
|
|
2040
|
-
const timer = setTimeout(() => {
|
|
2041
|
-
child.kill("SIGTERM");
|
|
2042
|
-
finish("other");
|
|
2043
|
-
}, 1e4);
|
|
2044
|
-
child.stdout?.on("data", (c) => {
|
|
2045
|
-
out += c.toString("utf8");
|
|
2046
|
-
});
|
|
2047
|
-
child.on("error", () => {
|
|
2048
|
-
clearTimeout(timer);
|
|
2049
|
-
finish("other");
|
|
2050
|
-
});
|
|
2051
|
-
child.on("close", () => {
|
|
2052
|
-
clearTimeout(timer);
|
|
2053
|
-
finish(out.trim() === "running" ? "running" : "other");
|
|
2054
|
-
});
|
|
2055
|
-
});
|
|
2056
|
-
}
|
|
2057
|
-
var QUEUE_LOGS_DIR = join2(STATE_DIR, "logs");
|
|
2058
|
-
function queueLogPath(id) {
|
|
2059
|
-
return join2(QUEUE_LOGS_DIR, `queue-${id}.log`);
|
|
2060
|
-
}
|
|
2061
|
-
function queueLoginCodePath(id) {
|
|
2062
|
-
return join2(QUEUE_DIR, `${id}.login-code`);
|
|
2063
|
-
}
|
|
2064
|
-
async function takeQueueLoginCode(id) {
|
|
2065
|
-
try {
|
|
2066
|
-
const code = (await readFile(queueLoginCodePath(id), "utf8")).trim();
|
|
2067
|
-
await unlink(queueLoginCodePath(id)).catch(() => {
|
|
2068
|
-
});
|
|
2069
|
-
return code.length > 0 ? code : null;
|
|
2070
|
-
} catch {
|
|
2071
|
-
return null;
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
var FAILURE_BACKOFF_MS = 5 * 6e4;
|
|
2075
|
-
|
|
2076
|
-
// ../../packages/sandbox-docker/dist/index.js
|
|
2077
1037
|
import { execa as execa18 } from "execa";
|
|
2078
1038
|
import { readdir as readdir6, rm as rm6, stat as stat8 } from "fs/promises";
|
|
2079
1039
|
import { join as join14 } from "path";
|
|
@@ -2088,13 +1048,13 @@ import { dirname as dirname4, join as join16 } from "path";
|
|
|
2088
1048
|
import { execa as execa21 } from "execa";
|
|
2089
1049
|
import { spawn as spawn2 } from "child_process";
|
|
2090
1050
|
import { existsSync as existsSync4, openSync as openSync2 } from "fs";
|
|
2091
|
-
import { mkdir as mkdir8, readFile as readFile7, unlink as
|
|
1051
|
+
import { mkdir as mkdir8, readFile as readFile7, unlink as unlink2, writeFile as writeFile4 } from "fs/promises";
|
|
2092
1052
|
import { homedir as homedir12 } from "os";
|
|
2093
1053
|
import { dirname as dirname5, join as join17, resolve as resolve5 } from "path";
|
|
2094
1054
|
import { setTimeout as delay3 } from "timers/promises";
|
|
2095
1055
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2096
1056
|
async function dockerInfo() {
|
|
2097
|
-
const result = await
|
|
1057
|
+
const result = await execa("docker", ["info"], { reject: false });
|
|
2098
1058
|
if (result.exitCode !== 0) {
|
|
2099
1059
|
throw new Error(
|
|
2100
1060
|
`docker info failed (exit ${String(result.exitCode)}). Is the Docker daemon running?
|
|
@@ -2170,11 +1130,11 @@ async function runBox(spec) {
|
|
|
2170
1130
|
args.push("-e", `${k}=${val}`);
|
|
2171
1131
|
}
|
|
2172
1132
|
args.push(spec.image, "sleep", "infinity");
|
|
2173
|
-
const { stdout } = await
|
|
1133
|
+
const { stdout } = await execa("docker", args);
|
|
2174
1134
|
return stdout.trim();
|
|
2175
1135
|
}
|
|
2176
1136
|
async function dockerStorageDriver() {
|
|
2177
|
-
const result = await
|
|
1137
|
+
const result = await execa("docker", ["info", "--format", "{{.Driver}}"], { reject: false });
|
|
2178
1138
|
if (result.exitCode !== 0) return "";
|
|
2179
1139
|
return (result.stdout ?? "").trim();
|
|
2180
1140
|
}
|
|
@@ -2183,7 +1143,7 @@ async function execInBox(container, cmd, opts = {}) {
|
|
|
2183
1143
|
if (opts.detach) args.push("-d");
|
|
2184
1144
|
if (opts.user) args.push("--user", opts.user);
|
|
2185
1145
|
args.push(container, ...cmd);
|
|
2186
|
-
const result = await
|
|
1146
|
+
const result = await execa("docker", args, {
|
|
2187
1147
|
reject: false,
|
|
2188
1148
|
...opts.timeoutMs ? { timeout: opts.timeoutMs } : {}
|
|
2189
1149
|
});
|
|
@@ -2194,49 +1154,49 @@ async function execInBox(container, cmd, opts = {}) {
|
|
|
2194
1154
|
};
|
|
2195
1155
|
}
|
|
2196
1156
|
async function removeContainer(container) {
|
|
2197
|
-
await
|
|
1157
|
+
await execa("docker", ["rm", "-f", container], { reject: false });
|
|
2198
1158
|
}
|
|
2199
1159
|
async function removeVolume(name) {
|
|
2200
|
-
await
|
|
1160
|
+
await execa("docker", ["volume", "rm", name], { reject: false });
|
|
2201
1161
|
}
|
|
2202
1162
|
async function removeImage(ref, opts = {}) {
|
|
2203
1163
|
const args = ["image", "rm"];
|
|
2204
1164
|
if (opts.force !== false) args.push("-f");
|
|
2205
1165
|
args.push(ref);
|
|
2206
|
-
const result = await
|
|
1166
|
+
const result = await execa("docker", args, { reject: false });
|
|
2207
1167
|
return result.exitCode === 0;
|
|
2208
1168
|
}
|
|
2209
1169
|
async function containerExists(name) {
|
|
2210
|
-
const result = await
|
|
1170
|
+
const result = await execa("docker", ["container", "inspect", "--format", "{{.Id}}", name], {
|
|
2211
1171
|
reject: false
|
|
2212
1172
|
});
|
|
2213
1173
|
return result.exitCode === 0;
|
|
2214
1174
|
}
|
|
2215
1175
|
async function volumeExists(name) {
|
|
2216
|
-
const result = await
|
|
1176
|
+
const result = await execa("docker", ["volume", "inspect", name], { reject: false });
|
|
2217
1177
|
return result.exitCode === 0;
|
|
2218
1178
|
}
|
|
2219
1179
|
async function ensureVolume(name) {
|
|
2220
1180
|
if (await volumeExists(name)) return;
|
|
2221
|
-
await
|
|
1181
|
+
await execa("docker", ["volume", "create", name]);
|
|
2222
1182
|
}
|
|
2223
1183
|
async function removeNetwork(name) {
|
|
2224
|
-
await
|
|
1184
|
+
await execa("docker", ["network", "rm", name], { reject: false });
|
|
2225
1185
|
}
|
|
2226
1186
|
async function pauseContainer(name) {
|
|
2227
|
-
await
|
|
1187
|
+
await execa("docker", ["pause", name]);
|
|
2228
1188
|
}
|
|
2229
1189
|
async function unpauseContainer(name) {
|
|
2230
|
-
await
|
|
1190
|
+
await execa("docker", ["unpause", name]);
|
|
2231
1191
|
}
|
|
2232
1192
|
async function stopContainer(name) {
|
|
2233
|
-
await
|
|
1193
|
+
await execa("docker", ["stop", name]);
|
|
2234
1194
|
}
|
|
2235
1195
|
async function startContainer(name) {
|
|
2236
|
-
await
|
|
1196
|
+
await execa("docker", ["start", name]);
|
|
2237
1197
|
}
|
|
2238
1198
|
async function inspectContainerStatus(name) {
|
|
2239
|
-
const result = await
|
|
1199
|
+
const result = await execa("docker", ["inspect", "--format", "{{.State.Status}}", name], {
|
|
2240
1200
|
reject: false
|
|
2241
1201
|
});
|
|
2242
1202
|
if (result.exitCode !== 0) return "missing";
|
|
@@ -2257,7 +1217,7 @@ async function inspectContainerStatus(name) {
|
|
|
2257
1217
|
}
|
|
2258
1218
|
}
|
|
2259
1219
|
async function inspectContainer(name) {
|
|
2260
|
-
const result = await
|
|
1220
|
+
const result = await execa("docker", ["inspect", name], { reject: false });
|
|
2261
1221
|
if (result.exitCode !== 0) return null;
|
|
2262
1222
|
try {
|
|
2263
1223
|
const parsed = JSON.parse(result.stdout ?? "null");
|
|
@@ -2267,7 +1227,7 @@ async function inspectContainer(name) {
|
|
|
2267
1227
|
}
|
|
2268
1228
|
}
|
|
2269
1229
|
async function inspectVolumeMountpoint(name) {
|
|
2270
|
-
const result = await
|
|
1230
|
+
const result = await execa("docker", ["volume", "inspect", "--format", "{{.Mountpoint}}", name], {
|
|
2271
1231
|
reject: false
|
|
2272
1232
|
});
|
|
2273
1233
|
if (result.exitCode !== 0) return null;
|
|
@@ -2275,7 +1235,7 @@ async function inspectVolumeMountpoint(name) {
|
|
|
2275
1235
|
}
|
|
2276
1236
|
var AGENTBOX_PREFIX = "agentbox-";
|
|
2277
1237
|
async function listAgentboxContainers() {
|
|
2278
|
-
const result = await
|
|
1238
|
+
const result = await execa(
|
|
2279
1239
|
"docker",
|
|
2280
1240
|
["ps", "-a", "--filter", `name=^${AGENTBOX_PREFIX}`, "--format", "{{.Names}}"],
|
|
2281
1241
|
{ reject: false }
|
|
@@ -2284,7 +1244,7 @@ async function listAgentboxContainers() {
|
|
|
2284
1244
|
return (result.stdout ?? "").split("\n").map((s) => s.trim()).filter((s) => s.startsWith(AGENTBOX_PREFIX));
|
|
2285
1245
|
}
|
|
2286
1246
|
async function publishedHostPort(container, containerPort) {
|
|
2287
|
-
const result = await
|
|
1247
|
+
const result = await execa("docker", ["port", container, `${String(containerPort)}/tcp`], {
|
|
2288
1248
|
reject: false
|
|
2289
1249
|
});
|
|
2290
1250
|
if (result.exitCode !== 0) return null;
|
|
@@ -2294,7 +1254,7 @@ async function publishedHostPort(container, containerPort) {
|
|
|
2294
1254
|
return m ? Number(m[1]) : null;
|
|
2295
1255
|
}
|
|
2296
1256
|
async function listAgentboxVolumes() {
|
|
2297
|
-
const result = await
|
|
1257
|
+
const result = await execa(
|
|
2298
1258
|
"docker",
|
|
2299
1259
|
["volume", "ls", "--filter", `name=^${AGENTBOX_PREFIX}`, "--format", "{{.Name}}"],
|
|
2300
1260
|
{ reject: false }
|
|
@@ -2315,12 +1275,12 @@ function tarExcludeArgs(exclude) {
|
|
|
2315
1275
|
return (exclude ?? []).map((p) => `--exclude=${p}`);
|
|
2316
1276
|
}
|
|
2317
1277
|
async function streamTarPipe(producerFile, producerArgs, consumerFile, consumerArgs, producerEnv) {
|
|
2318
|
-
const producer =
|
|
1278
|
+
const producer = execa2(producerFile, producerArgs, {
|
|
2319
1279
|
reject: false,
|
|
2320
1280
|
buffer: { stdout: false },
|
|
2321
1281
|
...producerEnv ? { env: producerEnv } : {}
|
|
2322
1282
|
});
|
|
2323
|
-
const consumer =
|
|
1283
|
+
const consumer = execa2(consumerFile, consumerArgs, {
|
|
2324
1284
|
reject: false,
|
|
2325
1285
|
buffer: { stdout: false }
|
|
2326
1286
|
});
|
|
@@ -2342,7 +1302,7 @@ async function uploadOneToBox(box, hostSrc, boxDst, exclude) {
|
|
|
2342
1302
|
boxParent = boxDst.replace(/\/+$/, "") || "/";
|
|
2343
1303
|
finalName = srcBasename;
|
|
2344
1304
|
} else {
|
|
2345
|
-
const isDir2 = await
|
|
1305
|
+
const isDir2 = await execa2(
|
|
2346
1306
|
"docker",
|
|
2347
1307
|
["exec", box.container, "test", "-d", boxDst],
|
|
2348
1308
|
{ reject: false }
|
|
@@ -2356,7 +1316,7 @@ async function uploadOneToBox(box, hostSrc, boxDst, exclude) {
|
|
|
2356
1316
|
}
|
|
2357
1317
|
}
|
|
2358
1318
|
const finalPath = boxParent === "/" ? `/${finalName}` : `${boxParent}/${finalName}`;
|
|
2359
|
-
const mk = await
|
|
1319
|
+
const mk = await execa2(
|
|
2360
1320
|
"docker",
|
|
2361
1321
|
["exec", "--user", "root", box.container, "mkdir", "-p", boxParent],
|
|
2362
1322
|
{ reject: false }
|
|
@@ -2379,7 +1339,7 @@ async function uploadOneToBox(box, hostSrc, boxDst, exclude) {
|
|
|
2379
1339
|
}
|
|
2380
1340
|
if (finalName !== srcBasename) {
|
|
2381
1341
|
const initial = boxParent === "/" ? `/${srcBasename}` : `${boxParent}/${srcBasename}`;
|
|
2382
|
-
const mv = await
|
|
1342
|
+
const mv = await execa2(
|
|
2383
1343
|
"docker",
|
|
2384
1344
|
["exec", "--user", "root", box.container, "mv", initial, finalPath],
|
|
2385
1345
|
{ reject: false }
|
|
@@ -2390,7 +1350,7 @@ async function uploadOneToBox(box, hostSrc, boxDst, exclude) {
|
|
|
2390
1350
|
);
|
|
2391
1351
|
}
|
|
2392
1352
|
}
|
|
2393
|
-
const chown = await
|
|
1353
|
+
const chown = await execa2(
|
|
2394
1354
|
"docker",
|
|
2395
1355
|
["exec", "--user", "root", box.container, "chown", "-R", "1000:1000", finalPath],
|
|
2396
1356
|
{ reject: false }
|
|
@@ -2402,7 +1362,7 @@ async function uploadOneToBox(box, hostSrc, boxDst, exclude) {
|
|
|
2402
1362
|
};
|
|
2403
1363
|
}
|
|
2404
1364
|
if (finalPath.startsWith(BOX_HOME2 + "/")) {
|
|
2405
|
-
const walk = await
|
|
1365
|
+
const walk = await execa2(
|
|
2406
1366
|
"docker",
|
|
2407
1367
|
[
|
|
2408
1368
|
"exec",
|
|
@@ -2461,7 +1421,7 @@ async function downloadOneFromBox(box, boxSrc, hostDst, exclude) {
|
|
|
2461
1421
|
return { finalPath };
|
|
2462
1422
|
}
|
|
2463
1423
|
async function boxIsDir(container, p) {
|
|
2464
|
-
const r = await
|
|
1424
|
+
const r = await execa2("docker", ["exec", container, "test", "-d", p], { reject: false });
|
|
2465
1425
|
return r.exitCode === 0;
|
|
2466
1426
|
}
|
|
2467
1427
|
async function resolveBoxDestDir(box, boxDst) {
|
|
@@ -2489,7 +1449,7 @@ async function uploadToBox(box, hostSrcs, boxDst, exclude) {
|
|
|
2489
1449
|
return a;
|
|
2490
1450
|
});
|
|
2491
1451
|
const boxDir = await resolveBoxDestDir(box, boxDst);
|
|
2492
|
-
const mk = await
|
|
1452
|
+
const mk = await execa2(
|
|
2493
1453
|
"docker",
|
|
2494
1454
|
["exec", "--user", "root", box.container, "mkdir", "-p", boxDir],
|
|
2495
1455
|
{ reject: false }
|
|
@@ -2515,7 +1475,7 @@ async function uploadToBox(box, hostSrcs, boxDst, exclude) {
|
|
|
2515
1475
|
let warn;
|
|
2516
1476
|
for (const a of absSrcs) {
|
|
2517
1477
|
const landed = boxDir === "/" ? `/${basename(a)}` : `${boxDir}/${basename(a)}`;
|
|
2518
|
-
const chown = await
|
|
1478
|
+
const chown = await execa2(
|
|
2519
1479
|
"docker",
|
|
2520
1480
|
["exec", "--user", "root", box.container, "chown", "-R", "1000:1000", landed],
|
|
2521
1481
|
{ reject: false }
|
|
@@ -2525,7 +1485,7 @@ async function uploadToBox(box, hostSrcs, boxDst, exclude) {
|
|
|
2525
1485
|
}
|
|
2526
1486
|
}
|
|
2527
1487
|
if (boxDir.startsWith(BOX_HOME2 + "/")) {
|
|
2528
|
-
const walk = await
|
|
1488
|
+
const walk = await execa2(
|
|
2529
1489
|
"docker",
|
|
2530
1490
|
[
|
|
2531
1491
|
"exec",
|
|
@@ -2590,7 +1550,7 @@ function createDockerSyncTransport(init) {
|
|
|
2590
1550
|
const transport = {
|
|
2591
1551
|
caps: DOCKER_CAPS,
|
|
2592
1552
|
async exec(cmd, opts) {
|
|
2593
|
-
const r = await
|
|
1553
|
+
const r = await execa3("docker", [...execArgsPrefix(opts), container, ...cmd], {
|
|
2594
1554
|
reject: false
|
|
2595
1555
|
});
|
|
2596
1556
|
return {
|
|
@@ -2604,7 +1564,7 @@ function createDockerSyncTransport(init) {
|
|
|
2604
1564
|
const tarArgs = ["tar", "-xf", "-", "-C", boxDestDir];
|
|
2605
1565
|
if (opts?.noSamePerms) tarArgs.push("--no-same-permissions", "--no-same-owner", "-m");
|
|
2606
1566
|
const args = ["exec", "-i", "--user", `${uid}:${uid}`, container, ...tarArgs];
|
|
2607
|
-
const r = await
|
|
1567
|
+
const r = await execa3("docker", args, { input: createReadStream(hostTarPath), reject: false });
|
|
2608
1568
|
if (r.exitCode !== 0) {
|
|
2609
1569
|
throw new Error(`docker tar extract into ${boxDestDir} failed: ${String(r.stderr).slice(0, 300)}`);
|
|
2610
1570
|
}
|
|
@@ -2616,7 +1576,7 @@ function createDockerSyncTransport(init) {
|
|
|
2616
1576
|
const packArgs = ["-C", hostSrcDir];
|
|
2617
1577
|
for (const ex of opts?.exclude ?? []) packArgs.push(`--exclude=${ex}`);
|
|
2618
1578
|
packArgs.push("-cf", localTar, ".");
|
|
2619
|
-
const packed = await
|
|
1579
|
+
const packed = await execa3("tar", packArgs, { reject: false });
|
|
2620
1580
|
if (packed.exitCode !== 0) {
|
|
2621
1581
|
throw new Error(`tar pack of ${hostSrcDir} failed: ${String(packed.stderr).slice(0, 300)}`);
|
|
2622
1582
|
}
|
|
@@ -2626,7 +1586,7 @@ function createDockerSyncTransport(init) {
|
|
|
2626
1586
|
}
|
|
2627
1587
|
},
|
|
2628
1588
|
async pushFile(hostSrcPath, boxDestPath, opts) {
|
|
2629
|
-
const cp2 = await
|
|
1589
|
+
const cp2 = await execa3("docker", ["cp", hostSrcPath, `${container}:${boxDestPath}`], {
|
|
2630
1590
|
reject: false
|
|
2631
1591
|
});
|
|
2632
1592
|
if (cp2.exitCode !== 0) {
|
|
@@ -2643,17 +1603,17 @@ function createDockerSyncTransport(init) {
|
|
|
2643
1603
|
const tarArgs = ["exec", container, "tar", "-C", boxSrcDir];
|
|
2644
1604
|
for (const ex of opts?.exclude ?? []) tarArgs.push(`--exclude=${ex}`);
|
|
2645
1605
|
tarArgs.push("-cf", "-", ".");
|
|
2646
|
-
const packed = await
|
|
1606
|
+
const packed = await execa3("docker", tarArgs, { encoding: "buffer", reject: false });
|
|
2647
1607
|
if (packed.exitCode !== 0) {
|
|
2648
1608
|
throw new Error(`docker tar of ${boxSrcDir} failed: ${String(packed.stderr).slice(0, 300)}`);
|
|
2649
1609
|
}
|
|
2650
|
-
await
|
|
1610
|
+
await execa3("tar", ["-xf", "-", "-C", hostDestDir], {
|
|
2651
1611
|
input: packed.stdout,
|
|
2652
1612
|
reject: false
|
|
2653
1613
|
});
|
|
2654
1614
|
},
|
|
2655
1615
|
async pullFile(boxSrcPath, hostDestPath) {
|
|
2656
|
-
const cp2 = await
|
|
1616
|
+
const cp2 = await execa3("docker", ["cp", `${container}:${boxSrcPath}`, hostDestPath], {
|
|
2657
1617
|
reject: false
|
|
2658
1618
|
});
|
|
2659
1619
|
if (cp2.exitCode !== 0) {
|
|
@@ -2661,12 +1621,12 @@ function createDockerSyncTransport(init) {
|
|
|
2661
1621
|
}
|
|
2662
1622
|
},
|
|
2663
1623
|
async readText(boxPath) {
|
|
2664
|
-
const r = await
|
|
1624
|
+
const r = await execa3("docker", ["exec", container, "cat", boxPath], { reject: false });
|
|
2665
1625
|
if (r.exitCode !== 0) return null;
|
|
2666
1626
|
return String(r.stdout ?? "");
|
|
2667
1627
|
},
|
|
2668
1628
|
async ensureVolume(name) {
|
|
2669
|
-
await
|
|
1629
|
+
await execa3("docker", ["volume", "create", name], { reject: false });
|
|
2670
1630
|
return { volumeId: name };
|
|
2671
1631
|
},
|
|
2672
1632
|
async seedVolumeFromHost(volume, sources) {
|
|
@@ -2686,7 +1646,7 @@ function createDockerSyncTransport(init) {
|
|
|
2686
1646
|
});
|
|
2687
1647
|
steps.push("chown -R 1000:1000 /dst");
|
|
2688
1648
|
args.push(init.image, "sh", "-c", steps.join(" && "));
|
|
2689
|
-
const r = await
|
|
1649
|
+
const r = await execa3("docker", args, { reject: false });
|
|
2690
1650
|
if (r.exitCode !== 0) {
|
|
2691
1651
|
throw new Error(`seedVolumeFromHost(${volume}) failed: ${String(r.stderr).slice(0, 300)}`);
|
|
2692
1652
|
}
|
|
@@ -2716,7 +1676,7 @@ async function getDockerContext() {
|
|
|
2716
1676
|
const ctx = (result.stdout ?? "").trim();
|
|
2717
1677
|
return ctx.length > 0 ? ctx : void 0;
|
|
2718
1678
|
}
|
|
2719
|
-
var BOXES_ROOT =
|
|
1679
|
+
var BOXES_ROOT = join2(homedir(), ".agentbox", "boxes");
|
|
2720
1680
|
function boxDirSegment(box) {
|
|
2721
1681
|
const mnemonic = sanitizeMnemonic(box.name);
|
|
2722
1682
|
const n = box.projectIndex;
|
|
@@ -2726,14 +1686,14 @@ function boxDirSegment(box) {
|
|
|
2726
1686
|
return `${box.id}-${mnemonic}`;
|
|
2727
1687
|
}
|
|
2728
1688
|
function boxRunDirFor(box) {
|
|
2729
|
-
return
|
|
1689
|
+
return join2(BOXES_ROOT, boxDirSegment(box));
|
|
2730
1690
|
}
|
|
2731
1691
|
function boxStatusPathFor(box) {
|
|
2732
|
-
return
|
|
1692
|
+
return join2(boxRunDirFor(box), "status.json");
|
|
2733
1693
|
}
|
|
2734
1694
|
async function readBoxStatus(box) {
|
|
2735
1695
|
try {
|
|
2736
|
-
const raw = await
|
|
1696
|
+
const raw = await readFile(boxStatusPathFor(box), "utf8");
|
|
2737
1697
|
const parsed = JSON.parse(raw);
|
|
2738
1698
|
if (parsed.schema !== 1) return null;
|
|
2739
1699
|
return parsed;
|
|
@@ -2742,13 +1702,13 @@ async function readBoxStatus(box) {
|
|
|
2742
1702
|
}
|
|
2743
1703
|
}
|
|
2744
1704
|
function orbstackVolumePath(volume, ...sub) {
|
|
2745
|
-
return
|
|
1705
|
+
return join2(homedir(), "OrbStack", "docker", "volumes", volume, ...sub);
|
|
2746
1706
|
}
|
|
2747
1707
|
async function getHostPaths(record) {
|
|
2748
1708
|
const boxDir = boxRunDirFor(record);
|
|
2749
1709
|
return {
|
|
2750
1710
|
boxDir,
|
|
2751
|
-
mergedExport:
|
|
1711
|
+
mergedExport: join2(boxDir, "workspace")
|
|
2752
1712
|
};
|
|
2753
1713
|
}
|
|
2754
1714
|
async function hasContainerPath(container, path) {
|
|
@@ -2758,7 +1718,7 @@ async function hasContainerPath(container, path) {
|
|
|
2758
1718
|
async function refreshExport(record, opts = {}) {
|
|
2759
1719
|
const paths = await getHostPaths(record);
|
|
2760
1720
|
const excludeNodeModules = !opts.includeNodeModules;
|
|
2761
|
-
await
|
|
1721
|
+
await mkdir(paths.mergedExport, { recursive: true });
|
|
2762
1722
|
const bindAvailable = await hasContainerPath(record.container, CONTAINER_EXPORT_MERGED);
|
|
2763
1723
|
if (bindAvailable) {
|
|
2764
1724
|
const args = ["rsync", "-a", "--delete"];
|
|
@@ -2872,7 +1832,7 @@ async function pullToHost(record, opts = {}) {
|
|
|
2872
1832
|
let scratchDir;
|
|
2873
1833
|
if (opts.noRefresh) {
|
|
2874
1834
|
scratchDir = paths.mergedExport;
|
|
2875
|
-
await
|
|
1835
|
+
await mkdir(scratchDir, { recursive: true });
|
|
2876
1836
|
} else {
|
|
2877
1837
|
const refreshed = await refreshExport(record, {
|
|
2878
1838
|
includeNodeModules: opts.includeNodeModules
|
|
@@ -2951,7 +1911,7 @@ async function openInFinder(record, opts) {
|
|
|
2951
1911
|
if (opts.noRefresh) {
|
|
2952
1912
|
const paths = await getHostPaths(record);
|
|
2953
1913
|
hostPath = paths.mergedExport;
|
|
2954
|
-
await
|
|
1914
|
+
await mkdir(hostPath, { recursive: true });
|
|
2955
1915
|
} else {
|
|
2956
1916
|
const refreshed = await refreshExport(record, opts);
|
|
2957
1917
|
hostPath = refreshed.hostPath;
|
|
@@ -2980,16 +1940,16 @@ async function carrySourceHash(entry) {
|
|
|
2980
1940
|
if (entry.kind === "missing") return void 0;
|
|
2981
1941
|
try {
|
|
2982
1942
|
if (entry.kind === "file") {
|
|
2983
|
-
return
|
|
1943
|
+
return createHash("sha256").update(await readFile(entry.absSrc)).digest("hex");
|
|
2984
1944
|
}
|
|
2985
1945
|
const exclude = entry.exclude ?? [];
|
|
2986
|
-
const h =
|
|
1946
|
+
const h = createHash("sha256");
|
|
2987
1947
|
const walk = async (dir, rel) => {
|
|
2988
|
-
const names = (await
|
|
1948
|
+
const names = (await readdir(dir)).sort();
|
|
2989
1949
|
for (const name of names) {
|
|
2990
1950
|
const relPath = rel ? `${rel}/${name}` : name;
|
|
2991
1951
|
if (carryRelExcluded(relPath, exclude)) continue;
|
|
2992
|
-
const abs =
|
|
1952
|
+
const abs = join2(dir, name);
|
|
2993
1953
|
const st = await stat(abs);
|
|
2994
1954
|
if (st.isDirectory()) {
|
|
2995
1955
|
h.update(`d\0${relPath}
|
|
@@ -2997,7 +1957,7 @@ async function carrySourceHash(entry) {
|
|
|
2997
1957
|
await walk(abs, relPath);
|
|
2998
1958
|
} else {
|
|
2999
1959
|
h.update(`f\0${relPath}\0`);
|
|
3000
|
-
h.update(await
|
|
1960
|
+
h.update(await readFile(abs));
|
|
3001
1961
|
h.update("\n");
|
|
3002
1962
|
}
|
|
3003
1963
|
}
|
|
@@ -3256,7 +2216,7 @@ async function ensureClaudeVolume(spec, opts) {
|
|
|
3256
2216
|
aliasedProjectKey = jsonResult.aliasedProjectKey;
|
|
3257
2217
|
workspaceTrusted = jsonResult.workspaceTrusted;
|
|
3258
2218
|
} else {
|
|
3259
|
-
await
|
|
2219
|
+
await writeFile(
|
|
3260
2220
|
join3(filterDir, "_claude.json"),
|
|
3261
2221
|
JSON.stringify(
|
|
3262
2222
|
{
|
|
@@ -3389,7 +2349,7 @@ async function maybeFilterTo(src, dest, hostHome, opts = {}) {
|
|
|
3389
2349
|
if (filtered.removedCommands.length === 0 && !installFixed && !aliased && !trusted) {
|
|
3390
2350
|
return zero;
|
|
3391
2351
|
}
|
|
3392
|
-
await
|
|
2352
|
+
await writeFile(dest, JSON.stringify(working, null, 2));
|
|
3393
2353
|
return {
|
|
3394
2354
|
removedHooks: filtered.removedCommands.length,
|
|
3395
2355
|
installMethodFixed: installFixed,
|
|
@@ -3956,7 +2916,7 @@ function parseExtractResult(stdout) {
|
|
|
3956
2916
|
}
|
|
3957
2917
|
async function extractVolumeAuthToBackup(opts) {
|
|
3958
2918
|
try {
|
|
3959
|
-
await
|
|
2919
|
+
await mkdir2(STATE_DIR, { recursive: true });
|
|
3960
2920
|
const script = 'COPIED=no; if [ -s /dst/auth.json ]; then cp -a /dst/auth.json "/host-state/$DEST" && COPIED=yes; fi; echo "COPIED=$COPIED"';
|
|
3961
2921
|
const { stdout } = await execa6("docker", [
|
|
3962
2922
|
"run",
|
|
@@ -4047,7 +3007,7 @@ echo "EXTRACTED=$EXTRACTED SEEDED=$SEEDED VOLREAL=$VOL_REAL"
|
|
|
4047
3007
|
`;
|
|
4048
3008
|
async function syncClaudeCredentials(spec, opts) {
|
|
4049
3009
|
try {
|
|
4050
|
-
await
|
|
3010
|
+
await mkdir2(STATE_DIR, { recursive: true });
|
|
4051
3011
|
const { stdout } = await execa6("docker", [
|
|
4052
3012
|
"run",
|
|
4053
3013
|
"--rm",
|
|
@@ -5451,7 +4411,7 @@ async function launchVncDaemon(container, timeoutMs = 5e3) {
|
|
|
5451
4411
|
}
|
|
5452
4412
|
var VNC_PASSWORD_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
5453
4413
|
function generateVncPassword() {
|
|
5454
|
-
const bytes =
|
|
4414
|
+
const bytes = randomBytes(8);
|
|
5455
4415
|
let out = "";
|
|
5456
4416
|
for (let i = 0; i < 8; i++) {
|
|
5457
4417
|
out += VNC_PASSWORD_ALPHABET[bytes[i] % VNC_PASSWORD_ALPHABET.length];
|
|
@@ -5529,6 +4489,11 @@ var SUB_VERSION = ["--version"];
|
|
|
5529
4489
|
var SUB_ALIAS = "alias";
|
|
5530
4490
|
var SUB_ALIAS_REMOVE = "--remove";
|
|
5531
4491
|
var SUB_GET = "get";
|
|
4492
|
+
var SUB_SERVICE_INSTALL = ["service", "install"];
|
|
4493
|
+
var SUB_SERVICE_STATUS = ["service", "status"];
|
|
4494
|
+
var SUB_SERVICE_UNINSTALL = ["service", "uninstall"];
|
|
4495
|
+
var PORTLESS_PROBE_NAME = "agentbox-probe";
|
|
4496
|
+
var PORTLESS_LAUNCHD_PLIST = "/Library/LaunchDaemons/sh.portless.proxy.plist";
|
|
5532
4497
|
var PORTLESS_PROXY_PORT = 1355;
|
|
5533
4498
|
var cached = null;
|
|
5534
4499
|
async function detectPortless() {
|
|
@@ -5568,15 +4533,24 @@ async function portlessUnalias(name) {
|
|
|
5568
4533
|
return false;
|
|
5569
4534
|
}
|
|
5570
4535
|
}
|
|
4536
|
+
function composePortlessUrl(name, mode) {
|
|
4537
|
+
const scheme = mode.tls ? "https" : "http";
|
|
4538
|
+
const isDefaultPort = mode.tls ? mode.port === 443 : mode.port === 80;
|
|
4539
|
+
return `${scheme}://${name}.localhost${isDefaultPort ? "" : `:${String(mode.port)}`}`;
|
|
4540
|
+
}
|
|
5571
4541
|
async function portlessGetUrl(name) {
|
|
5572
|
-
const
|
|
4542
|
+
const expectedHost = `${name}.localhost`;
|
|
5573
4543
|
try {
|
|
5574
4544
|
const r = await execa11(PORTLESS_BIN, [SUB_GET, name], { reject: false });
|
|
5575
4545
|
const out = (r.stdout ?? "").trim();
|
|
5576
|
-
if (r.exitCode === 0 && /^https?:\/\//.test(out))
|
|
4546
|
+
if (r.exitCode === 0 && /^https?:\/\//.test(out)) {
|
|
4547
|
+
const host = new URL(out).hostname;
|
|
4548
|
+
if (host === expectedHost) return out;
|
|
4549
|
+
}
|
|
5577
4550
|
} catch {
|
|
5578
4551
|
}
|
|
5579
|
-
|
|
4552
|
+
const mode = await portlessConfiguredMode();
|
|
4553
|
+
return mode === null ? `https://${expectedHost}` : composePortlessUrl(name, mode);
|
|
5580
4554
|
}
|
|
5581
4555
|
function portlessInstallHint() {
|
|
5582
4556
|
return "npm install -g portless";
|
|
@@ -5584,7 +4558,10 @@ function portlessInstallHint() {
|
|
|
5584
4558
|
function portlessStartHint() {
|
|
5585
4559
|
return "portless proxy start";
|
|
5586
4560
|
}
|
|
5587
|
-
function
|
|
4561
|
+
function portlessServiceHint() {
|
|
4562
|
+
return "agentbox install portless";
|
|
4563
|
+
}
|
|
4564
|
+
function portlessDoctorRow(state, service) {
|
|
5588
4565
|
if (!state.installed) {
|
|
5589
4566
|
return {
|
|
5590
4567
|
label: "portless",
|
|
@@ -5598,14 +4575,23 @@ function portlessDoctorRow(state) {
|
|
|
5598
4575
|
label: "portless",
|
|
5599
4576
|
status: "warn",
|
|
5600
4577
|
detail: "installed, proxy not running",
|
|
5601
|
-
hint: `start
|
|
4578
|
+
// The OS service is the hint that actually sticks: `proxy start` has to be
|
|
4579
|
+
// re-run after every reboot, which is how a host ends up here in the first
|
|
4580
|
+
// place. AgentBox also starts a proxy on demand, so this is a nudge, not a
|
|
4581
|
+
// blocker.
|
|
4582
|
+
hint: `make it permanent: \`${portlessServiceHint()}\` (or one-shot: \`${portlessStartHint()}\`)`
|
|
5602
4583
|
};
|
|
5603
4584
|
}
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
4585
|
+
const running = state.version ? `running \xB7 v${state.version}` : "running";
|
|
4586
|
+
if (service?.installed === false) {
|
|
4587
|
+
return {
|
|
4588
|
+
label: "portless",
|
|
4589
|
+
status: "ok",
|
|
4590
|
+
detail: `${running} \xB7 no OS service (won't survive a reboot)`,
|
|
4591
|
+
hint: `optional: \`${portlessServiceHint()}\` to start it at boot`
|
|
4592
|
+
};
|
|
4593
|
+
}
|
|
4594
|
+
return { label: "portless", status: "ok", detail: running };
|
|
5609
4595
|
}
|
|
5610
4596
|
function portlessBrowserEnv(boxName, opts) {
|
|
5611
4597
|
return {
|
|
@@ -5621,13 +4607,11 @@ async function installPortless() {
|
|
|
5621
4607
|
return false;
|
|
5622
4608
|
}
|
|
5623
4609
|
}
|
|
5624
|
-
async function startPortlessProxy() {
|
|
4610
|
+
async function startPortlessProxy(port = PORTLESS_PROXY_PORT) {
|
|
5625
4611
|
try {
|
|
5626
|
-
const r = await execa11(
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
{ reject: false }
|
|
5630
|
-
);
|
|
4612
|
+
const r = await execa11(PORTLESS_BIN, ["proxy", "start", "--no-tls", "-p", String(port)], {
|
|
4613
|
+
reject: false
|
|
4614
|
+
});
|
|
5631
4615
|
return r.exitCode === 0;
|
|
5632
4616
|
} catch {
|
|
5633
4617
|
return false;
|
|
@@ -5668,6 +4652,85 @@ async function startPortlessProxyRoot() {
|
|
|
5668
4652
|
return "failed";
|
|
5669
4653
|
}
|
|
5670
4654
|
}
|
|
4655
|
+
async function portlessServiceStatus() {
|
|
4656
|
+
try {
|
|
4657
|
+
const r = await execa11(PORTLESS_BIN, SUB_SERVICE_STATUS, { reject: false });
|
|
4658
|
+
const m = /^\s*Installed:\s*(yes|no)\s*$/im.exec(r.stdout ?? "");
|
|
4659
|
+
if (m) return { installed: m[1]?.toLowerCase() === "yes" };
|
|
4660
|
+
} catch {
|
|
4661
|
+
}
|
|
4662
|
+
if (process.platform === "darwin") return { installed: existsSync2(PORTLESS_LAUNCHD_PLIST) };
|
|
4663
|
+
return { installed: false };
|
|
4664
|
+
}
|
|
4665
|
+
async function installPortlessService() {
|
|
4666
|
+
const bin = await resolvePortlessBin();
|
|
4667
|
+
try {
|
|
4668
|
+
if (process.platform === "darwin") {
|
|
4669
|
+
const q = shellSingleQuote(bin);
|
|
4670
|
+
const shellCmd = `${q} ${SUB_SERVICE_INSTALL.join(" ")} && ${q} trust`;
|
|
4671
|
+
const script = `do shell script "${escapeForAppleScript(shellCmd)}" with administrator privileges with prompt "AgentBox wants to start the Portless proxy at login."`;
|
|
4672
|
+
const r2 = await execa11("osascript", ["-e", script], { reject: false });
|
|
4673
|
+
if (r2.exitCode === 0) return "started";
|
|
4674
|
+
if (/User canceled|-128/i.test(r2.stderr ?? "")) return "cancelled";
|
|
4675
|
+
return "failed";
|
|
4676
|
+
}
|
|
4677
|
+
const r = await execa11(bin, SUB_SERVICE_INSTALL, { reject: false, stdio: "inherit" });
|
|
4678
|
+
if (r.exitCode !== 0) return "failed";
|
|
4679
|
+
await execa11(bin, ["trust"], { reject: false, stdio: "inherit" });
|
|
4680
|
+
return "started";
|
|
4681
|
+
} catch {
|
|
4682
|
+
return "failed";
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
4685
|
+
async function uninstallPortlessService() {
|
|
4686
|
+
const bin = await resolvePortlessBin();
|
|
4687
|
+
try {
|
|
4688
|
+
if (process.platform === "darwin") {
|
|
4689
|
+
const shellCmd = `${shellSingleQuote(bin)} ${SUB_SERVICE_UNINSTALL.join(" ")}`;
|
|
4690
|
+
const script = `do shell script "${escapeForAppleScript(shellCmd)}" with administrator privileges with prompt "AgentBox wants to remove the Portless startup service."`;
|
|
4691
|
+
const r2 = await execa11("osascript", ["-e", script], { reject: false });
|
|
4692
|
+
return r2.exitCode === 0;
|
|
4693
|
+
}
|
|
4694
|
+
const r = await execa11(bin, SUB_SERVICE_UNINSTALL, { reject: false, stdio: "inherit" });
|
|
4695
|
+
return r.exitCode === 0;
|
|
4696
|
+
} catch {
|
|
4697
|
+
return false;
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
async function portlessConfiguredMode() {
|
|
4701
|
+
try {
|
|
4702
|
+
const r = await execa11(PORTLESS_BIN, [SUB_GET, PORTLESS_PROBE_NAME], { reject: false });
|
|
4703
|
+
const out = (r.stdout ?? "").trim();
|
|
4704
|
+
if (r.exitCode !== 0 || !/^https?:\/\//.test(out)) return null;
|
|
4705
|
+
const u = new URL(out);
|
|
4706
|
+
const tls = u.protocol === "https:";
|
|
4707
|
+
const port = u.port ? Number.parseInt(u.port, 10) : tls ? 443 : 80;
|
|
4708
|
+
return Number.isFinite(port) ? { port, tls } : null;
|
|
4709
|
+
} catch {
|
|
4710
|
+
return null;
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
function needsRoot(port) {
|
|
4714
|
+
return port < 1024;
|
|
4715
|
+
}
|
|
4716
|
+
async function ensurePortlessProxy(opts = {}) {
|
|
4717
|
+
let state = await detectPortless();
|
|
4718
|
+
if (!state.installed || state.proxyRunning) return state;
|
|
4719
|
+
const mode = await portlessConfiguredMode();
|
|
4720
|
+
const wantsRoot = mode === null || needsRoot(mode.port);
|
|
4721
|
+
if (wantsRoot) {
|
|
4722
|
+
if (opts.allowRootPrompt !== true) return state;
|
|
4723
|
+
await startPortlessProxyRoot();
|
|
4724
|
+
resetPortlessCache();
|
|
4725
|
+
state = await detectPortless();
|
|
4726
|
+
if (state.proxyRunning) return state;
|
|
4727
|
+
}
|
|
4728
|
+
await startPortlessProxy(
|
|
4729
|
+
mode !== null && !needsRoot(mode.port) ? mode.port : PORTLESS_PROXY_PORT
|
|
4730
|
+
);
|
|
4731
|
+
resetPortlessCache();
|
|
4732
|
+
return detectPortless();
|
|
4733
|
+
}
|
|
5671
4734
|
function portlessStateDirCandidates() {
|
|
5672
4735
|
const env = process.env["PORTLESS_STATE_DIR"];
|
|
5673
4736
|
if (env && env.trim().length > 0) return [env.trim()];
|
|
@@ -5684,7 +4747,7 @@ function pidAlive(pid) {
|
|
|
5684
4747
|
}
|
|
5685
4748
|
async function readProxyPid(dir) {
|
|
5686
4749
|
try {
|
|
5687
|
-
const raw = await
|
|
4750
|
+
const raw = await readFile4(join8(dir, "proxy.pid"), "utf8");
|
|
5688
4751
|
const pid = Number.parseInt(raw.trim(), 10);
|
|
5689
4752
|
return Number.isFinite(pid) && pid > 0 ? pid : null;
|
|
5690
4753
|
} catch {
|
|
@@ -5709,14 +4772,30 @@ async function resolvePortlessHostStateDir(override) {
|
|
|
5709
4772
|
if (existsSync2("/tmp/portless")) return "/tmp/portless";
|
|
5710
4773
|
return home;
|
|
5711
4774
|
}
|
|
4775
|
+
async function tcpAccepts(port, timeoutMs = 400) {
|
|
4776
|
+
return new Promise((resolve6) => {
|
|
4777
|
+
const socket = connect({ host: "127.0.0.1", port });
|
|
4778
|
+
const done = (result) => {
|
|
4779
|
+
socket.destroy();
|
|
4780
|
+
resolve6(result);
|
|
4781
|
+
};
|
|
4782
|
+
socket.setTimeout(timeoutMs);
|
|
4783
|
+
socket.once("connect", () => {
|
|
4784
|
+
done(true);
|
|
4785
|
+
});
|
|
4786
|
+
socket.once("timeout", () => {
|
|
4787
|
+
done(false);
|
|
4788
|
+
});
|
|
4789
|
+
socket.once("error", () => {
|
|
4790
|
+
done(false);
|
|
4791
|
+
});
|
|
4792
|
+
});
|
|
4793
|
+
}
|
|
5712
4794
|
async function isProxyRunning() {
|
|
5713
4795
|
if (await findLivePortlessStateDir() !== null) return true;
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
} catch {
|
|
5718
|
-
return false;
|
|
5719
|
-
}
|
|
4796
|
+
const mode = await portlessConfiguredMode();
|
|
4797
|
+
if (mode === null) return false;
|
|
4798
|
+
return tcpAccepts(mode.port);
|
|
5720
4799
|
}
|
|
5721
4800
|
var EXCLUDE_DIRS = /* @__PURE__ */ new Set([
|
|
5722
4801
|
"node_modules",
|
|
@@ -5745,7 +4824,7 @@ async function findExcludedDirs(root, excluded = EXCLUDE_DIRS) {
|
|
|
5745
4824
|
const walk = async (dir) => {
|
|
5746
4825
|
let entries;
|
|
5747
4826
|
try {
|
|
5748
|
-
entries = await
|
|
4827
|
+
entries = await readdir3(dir, { withFileTypes: true });
|
|
5749
4828
|
} catch {
|
|
5750
4829
|
return;
|
|
5751
4830
|
}
|
|
@@ -6012,7 +5091,7 @@ async function createCheckpoint(opts) {
|
|
|
6012
5091
|
cliVersion: stamp.cliVersion,
|
|
6013
5092
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6014
5093
|
};
|
|
6015
|
-
await
|
|
5094
|
+
await writeFile2(join10(dir, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n", "utf8");
|
|
6016
5095
|
if (opts.setDefault) {
|
|
6017
5096
|
await setConfigValue("project", "box.defaultCheckpointDocker", name, opts.projectRoot);
|
|
6018
5097
|
log(`set project default checkpoint (box.defaultCheckpointDocker) -> ${name}`);
|
|
@@ -6044,7 +5123,7 @@ async function flattenImage(sourceTag, destTag, log) {
|
|
|
6044
5123
|
"ADD rootfs.tar /",
|
|
6045
5124
|
...renderConfigDirectives(cfg)
|
|
6046
5125
|
];
|
|
6047
|
-
await
|
|
5126
|
+
await writeFile2(join10(scratch, "Dockerfile"), lines.join("\n") + "\n", "utf8");
|
|
6048
5127
|
log(`building flattened ${destTag} from rootfs.tar (FROM scratch)`);
|
|
6049
5128
|
const build = await execa13(
|
|
6050
5129
|
"docker",
|
|
@@ -6185,7 +5264,7 @@ async function ensureRelay(opts = {}) {
|
|
|
6185
5264
|
await reclaimRelay(health.pid, log);
|
|
6186
5265
|
} else {
|
|
6187
5266
|
const existingPid = await readPidFile();
|
|
6188
|
-
if (existingPid !== null && await
|
|
5267
|
+
if (existingPid !== null && await processAlive(existingPid)) {
|
|
6189
5268
|
for (let i = 0; i < 10; i++) {
|
|
6190
5269
|
if (await pingHealthz(300)) return ENDPOINT;
|
|
6191
5270
|
await delay2(200);
|
|
@@ -6194,7 +5273,7 @@ async function ensureRelay(opts = {}) {
|
|
|
6194
5273
|
return ENDPOINT;
|
|
6195
5274
|
}
|
|
6196
5275
|
if (existingPid !== null) {
|
|
6197
|
-
await
|
|
5276
|
+
await unlink(PID_FILE).catch(() => {
|
|
6198
5277
|
});
|
|
6199
5278
|
}
|
|
6200
5279
|
}
|
|
@@ -6214,11 +5293,11 @@ async function reclaimRelay(reportedPid, log) {
|
|
|
6214
5293
|
for (const pid of [reportedPid, pidFromFile]) {
|
|
6215
5294
|
if (typeof pid !== "number" || pid <= 0 || seen.has(pid)) continue;
|
|
6216
5295
|
seen.add(pid);
|
|
6217
|
-
if (!await
|
|
5296
|
+
if (!await processAlive(pid)) continue;
|
|
6218
5297
|
log(`stopping crippled relay pid ${String(pid)}`);
|
|
6219
5298
|
await killPid(pid);
|
|
6220
5299
|
}
|
|
6221
|
-
await
|
|
5300
|
+
await unlink(PID_FILE).catch(() => {
|
|
6222
5301
|
});
|
|
6223
5302
|
if (await pingHealthz(300)) {
|
|
6224
5303
|
throw new Error(
|
|
@@ -6233,7 +5312,7 @@ async function killPid(pid) {
|
|
|
6233
5312
|
return;
|
|
6234
5313
|
}
|
|
6235
5314
|
for (let i = 0; i < 20; i++) {
|
|
6236
|
-
if (!await
|
|
5315
|
+
if (!await processAlive(pid)) return;
|
|
6237
5316
|
await delay2(100);
|
|
6238
5317
|
}
|
|
6239
5318
|
try {
|
|
@@ -6329,7 +5408,7 @@ async function stageRelayHome(version, log) {
|
|
|
6329
5408
|
}
|
|
6330
5409
|
await cp(nodeModules, join11(tmpDir, "node_modules"), { recursive: true, dereference: true });
|
|
6331
5410
|
await rm5(homeDir, { recursive: true, force: true });
|
|
6332
|
-
await
|
|
5411
|
+
await rename(tmpDir, homeDir);
|
|
6333
5412
|
} catch (err) {
|
|
6334
5413
|
await rm5(tmpDir, { recursive: true, force: true }).catch(() => {
|
|
6335
5414
|
});
|
|
@@ -6384,8 +5463,8 @@ async function stopRelay() {
|
|
|
6384
5463
|
if (pid === null) {
|
|
6385
5464
|
return { stopped: false, pid: null };
|
|
6386
5465
|
}
|
|
6387
|
-
if (!await
|
|
6388
|
-
await
|
|
5466
|
+
if (!await processAlive(pid)) {
|
|
5467
|
+
await unlink(PID_FILE).catch(() => {
|
|
6389
5468
|
});
|
|
6390
5469
|
return { stopped: false, pid };
|
|
6391
5470
|
}
|
|
@@ -6394,22 +5473,22 @@ async function stopRelay() {
|
|
|
6394
5473
|
} catch {
|
|
6395
5474
|
}
|
|
6396
5475
|
for (let i = 0; i < 20; i++) {
|
|
6397
|
-
if (!await
|
|
5476
|
+
if (!await processAlive(pid)) break;
|
|
6398
5477
|
await delay2(100);
|
|
6399
5478
|
}
|
|
6400
|
-
if (await
|
|
5479
|
+
if (await processAlive(pid)) {
|
|
6401
5480
|
try {
|
|
6402
5481
|
process.kill(pid, "SIGKILL");
|
|
6403
5482
|
} catch {
|
|
6404
5483
|
}
|
|
6405
5484
|
}
|
|
6406
|
-
await
|
|
5485
|
+
await unlink(PID_FILE).catch(() => {
|
|
6407
5486
|
});
|
|
6408
5487
|
return { stopped: true, pid };
|
|
6409
5488
|
}
|
|
6410
5489
|
async function getRelayStatus() {
|
|
6411
5490
|
const pid = await readPidFile();
|
|
6412
|
-
const pidAlive2 = pid !== null && await
|
|
5491
|
+
const pidAlive2 = pid !== null && await processAlive(pid);
|
|
6413
5492
|
const health = await fetchHealthz(300);
|
|
6414
5493
|
return {
|
|
6415
5494
|
running: health !== null,
|
|
@@ -6494,7 +5573,7 @@ async function readPidFile() {
|
|
|
6494
5573
|
return null;
|
|
6495
5574
|
}
|
|
6496
5575
|
}
|
|
6497
|
-
async function
|
|
5576
|
+
async function processAlive(pid) {
|
|
6498
5577
|
try {
|
|
6499
5578
|
process.kill(pid, 0);
|
|
6500
5579
|
return true;
|
|
@@ -6503,7 +5582,7 @@ async function processAlive2(pid) {
|
|
|
6503
5582
|
}
|
|
6504
5583
|
}
|
|
6505
5584
|
function generateRelayToken() {
|
|
6506
|
-
return
|
|
5585
|
+
return randomBytes2(32).toString("hex");
|
|
6507
5586
|
}
|
|
6508
5587
|
async function registerBoxWithRelay(args) {
|
|
6509
5588
|
const worktrees = (args.worktrees ?? []).map((w) => ({
|
|
@@ -6796,8 +5875,8 @@ async function ensureAgentboxTasksFile(container, services, opts = {}) {
|
|
|
6796
5875
|
return { status: "wrote" };
|
|
6797
5876
|
}
|
|
6798
5877
|
async function writeFileInBox(container, path, content) {
|
|
6799
|
-
const { execa:
|
|
6800
|
-
const result = await
|
|
5878
|
+
const { execa: execa22 } = await import("execa");
|
|
5879
|
+
const result = await execa22(
|
|
6801
5880
|
"docker",
|
|
6802
5881
|
["exec", "-i", "--user", "vscode", container, "sh", "-c", `cat > ${shellQuote(path)}`],
|
|
6803
5882
|
{ input: content, reject: false }
|
|
@@ -8082,8 +7161,9 @@ async function pruneBoxes(opts = {}) {
|
|
|
8082
7161
|
const dryRun = opts.dryRun ?? false;
|
|
8083
7162
|
const all = opts.all ?? false;
|
|
8084
7163
|
const { boxes } = await readState();
|
|
7164
|
+
const dockerBoxes = boxes.filter((b) => (b.provider ?? "docker") === "docker");
|
|
8085
7165
|
const stateChecks = await Promise.all(
|
|
8086
|
-
|
|
7166
|
+
dockerBoxes.map(async (b) => ({ box: b, status: await inspectContainerStatus(b.container) }))
|
|
8087
7167
|
);
|
|
8088
7168
|
const missingRecords = stateChecks.filter((c) => c.status === "missing").map((c) => c.box);
|
|
8089
7169
|
let orphanContainers = [];
|
|
@@ -8639,7 +7719,7 @@ async function dockerChecks() {
|
|
|
8639
7719
|
(async () => {
|
|
8640
7720
|
const engine = await detectEngine().catch(() => "other");
|
|
8641
7721
|
if (engine === "orbstack") return null;
|
|
8642
|
-
return portlessDoctorRow(await detectPortless());
|
|
7722
|
+
return portlessDoctorRow(await detectPortless(), await portlessServiceStatus());
|
|
8643
7723
|
})()
|
|
8644
7724
|
]);
|
|
8645
7725
|
if (info.exitCode !== 0) {
|
|
@@ -8854,11 +7934,21 @@ async function readHubPortlessUrl() {
|
|
|
8854
7934
|
return null;
|
|
8855
7935
|
}
|
|
8856
7936
|
}
|
|
7937
|
+
async function currentHubPortlessUrl() {
|
|
7938
|
+
const cached2 = await readHubPortlessUrl();
|
|
7939
|
+
if (cached2 === null) return null;
|
|
7940
|
+
const portless = await detectPortless();
|
|
7941
|
+
if (!portless.proxyRunning) return null;
|
|
7942
|
+
const url = await portlessGetUrl(HUB_PORTLESS_ALIAS);
|
|
7943
|
+
if (url !== cached2) await writeFile4(HUB_PORTLESS_FILE, url, "utf8").catch(() => {
|
|
7944
|
+
});
|
|
7945
|
+
return url;
|
|
7946
|
+
}
|
|
8857
7947
|
async function syncHubPortless(enabled) {
|
|
8858
7948
|
const teardown = async () => {
|
|
8859
7949
|
await portlessUnalias(HUB_PORTLESS_ALIAS).catch(() => {
|
|
8860
7950
|
});
|
|
8861
|
-
await
|
|
7951
|
+
await unlink2(HUB_PORTLESS_FILE).catch(() => {
|
|
8862
7952
|
});
|
|
8863
7953
|
return void 0;
|
|
8864
7954
|
};
|
|
@@ -8871,7 +7961,7 @@ async function syncHubPortless(enabled) {
|
|
|
8871
7961
|
const url = await portlessGetUrl(HUB_PORTLESS_ALIAS);
|
|
8872
7962
|
await mkdir8(dirname5(HUB_PORTLESS_FILE), { recursive: true });
|
|
8873
7963
|
await writeFile4(HUB_PORTLESS_FILE, url, "utf8");
|
|
8874
|
-
return url;
|
|
7964
|
+
return portless.proxyRunning ? url : void 0;
|
|
8875
7965
|
} catch {
|
|
8876
7966
|
return void 0;
|
|
8877
7967
|
}
|
|
@@ -8899,11 +7989,11 @@ async function reclaimPort(reportedPid, log) {
|
|
|
8899
7989
|
for (const pid of [reportedPid, pidFromFile]) {
|
|
8900
7990
|
if (typeof pid !== "number" || pid <= 0 || seen.has(pid)) continue;
|
|
8901
7991
|
seen.add(pid);
|
|
8902
|
-
if (!await
|
|
7992
|
+
if (!await processAlive(pid)) continue;
|
|
8903
7993
|
log(`stopping process on :${String(PORT2)} (pid ${String(pid)})`);
|
|
8904
7994
|
await killPid(pid);
|
|
8905
7995
|
}
|
|
8906
|
-
await
|
|
7996
|
+
await unlink2(HUB_PID_FILE).catch(() => {
|
|
8907
7997
|
});
|
|
8908
7998
|
if (await pingHealthz(300)) {
|
|
8909
7999
|
throw new Error(
|
|
@@ -8928,7 +8018,7 @@ async function ensureHub(opts = {}) {
|
|
|
8928
8018
|
await reclaimPort(health.pid, log);
|
|
8929
8019
|
} else {
|
|
8930
8020
|
const pid = await readPid(HUB_PID_FILE);
|
|
8931
|
-
if (pid !== null && await
|
|
8021
|
+
if (pid !== null && await processAlive(pid)) {
|
|
8932
8022
|
for (let i = 0; i < 10; i++) {
|
|
8933
8023
|
if (await pingHealthz(300)) return endpointFor(await syncHubPortless(opts.portlessEnabled));
|
|
8934
8024
|
await delay3(200);
|
|
@@ -8936,7 +8026,7 @@ async function ensureHub(opts = {}) {
|
|
|
8936
8026
|
log(`hub pid ${String(pid)} alive but /healthz unresponsive \u2014 restarting it`);
|
|
8937
8027
|
await reclaimPort(pid, log);
|
|
8938
8028
|
} else if (pid !== null) {
|
|
8939
|
-
await
|
|
8029
|
+
await unlink2(HUB_PID_FILE).catch(() => {
|
|
8940
8030
|
});
|
|
8941
8031
|
}
|
|
8942
8032
|
}
|
|
@@ -8987,14 +8077,20 @@ async function spawnHub(hubServer, cliEntry, log, portlessEnabled) {
|
|
|
8987
8077
|
return endpointFor(purl);
|
|
8988
8078
|
}
|
|
8989
8079
|
if (exit !== null) {
|
|
8990
|
-
await
|
|
8080
|
+
await unlink2(HUB_PID_FILE).catch(() => {
|
|
8991
8081
|
});
|
|
8992
8082
|
await delay3(150);
|
|
8993
|
-
throw new Error(
|
|
8083
|
+
throw new Error(
|
|
8084
|
+
await hubStartupError(`hub process exited (${describeExit(exit)}) during startup`)
|
|
8085
|
+
);
|
|
8994
8086
|
}
|
|
8995
8087
|
await delay3(200);
|
|
8996
8088
|
}
|
|
8997
|
-
throw new Error(
|
|
8089
|
+
throw new Error(
|
|
8090
|
+
await hubStartupError(
|
|
8091
|
+
`hub did not become reachable on http://${HOST}:${String(PORT2)} within ~25s`
|
|
8092
|
+
)
|
|
8093
|
+
);
|
|
8998
8094
|
}
|
|
8999
8095
|
function describeExit(exit) {
|
|
9000
8096
|
if (exit.signal !== null) return `killed by ${exit.signal}`;
|
|
@@ -9018,7 +8114,7 @@ async function tailFile(file, maxLines) {
|
|
|
9018
8114
|
async function unregisterHubPortless() {
|
|
9019
8115
|
await portlessUnalias(HUB_PORTLESS_ALIAS).catch(() => {
|
|
9020
8116
|
});
|
|
9021
|
-
await
|
|
8117
|
+
await unlink2(HUB_PORTLESS_FILE).catch(() => {
|
|
9022
8118
|
});
|
|
9023
8119
|
}
|
|
9024
8120
|
async function stopHub() {
|
|
@@ -9027,23 +8123,23 @@ async function stopHub() {
|
|
|
9027
8123
|
await unregisterHubPortless();
|
|
9028
8124
|
return { stopped: false, pid: null };
|
|
9029
8125
|
}
|
|
9030
|
-
if (!await
|
|
9031
|
-
await
|
|
8126
|
+
if (!await processAlive(pid)) {
|
|
8127
|
+
await unlink2(HUB_PID_FILE).catch(() => {
|
|
9032
8128
|
});
|
|
9033
8129
|
await unregisterHubPortless();
|
|
9034
8130
|
return { stopped: false, pid };
|
|
9035
8131
|
}
|
|
9036
8132
|
await killPid(pid);
|
|
9037
|
-
await
|
|
8133
|
+
await unlink2(HUB_PID_FILE).catch(() => {
|
|
9038
8134
|
});
|
|
9039
8135
|
await unregisterHubPortless();
|
|
9040
8136
|
return { stopped: true, pid };
|
|
9041
8137
|
}
|
|
9042
8138
|
async function getHubStatus() {
|
|
9043
8139
|
const pid = await readPid(HUB_PID_FILE);
|
|
9044
|
-
const pidAlive2 = pid !== null && await
|
|
8140
|
+
const pidAlive2 = pid !== null && await processAlive(pid);
|
|
9045
8141
|
const health = await fetchHealthz(300);
|
|
9046
|
-
const ep = await endpointFor(await
|
|
8142
|
+
const ep = await endpointFor(await currentHubPortlessUrl() ?? void 0);
|
|
9047
8143
|
return {
|
|
9048
8144
|
running: health !== null,
|
|
9049
8145
|
ui: health?.ui === true,
|
|
@@ -9094,27 +8190,6 @@ export {
|
|
|
9094
8190
|
parseReplacementsSection,
|
|
9095
8191
|
parseCarrySection,
|
|
9096
8192
|
loadCarrySection,
|
|
9097
|
-
DEFAULT_RELAY_PORT,
|
|
9098
|
-
RELAY_CONTAINER_NAME,
|
|
9099
|
-
RELAY_NETWORK_NAME,
|
|
9100
|
-
RELAY_IMAGE_REF,
|
|
9101
|
-
parseGitRemote,
|
|
9102
|
-
toAuthedHttpsUrl,
|
|
9103
|
-
loadGitHubAppConfig,
|
|
9104
|
-
GitHubAppLeaser,
|
|
9105
|
-
drainCreateJobs,
|
|
9106
|
-
PostgresStore,
|
|
9107
|
-
ALL_CONNECTORS,
|
|
9108
|
-
GH_PR_OPS,
|
|
9109
|
-
injectPrCreateHead,
|
|
9110
|
-
hashRpcParams,
|
|
9111
|
-
loadQueueConfig,
|
|
9112
|
-
writeJob,
|
|
9113
|
-
enqueueQueueJob,
|
|
9114
|
-
readJob,
|
|
9115
|
-
deleteJob,
|
|
9116
|
-
loadQueue,
|
|
9117
|
-
takeQueueLoginCode,
|
|
9118
8193
|
execInBox,
|
|
9119
8194
|
removeImage,
|
|
9120
8195
|
volumeExists,
|
|
@@ -9243,11 +8318,16 @@ export {
|
|
|
9243
8318
|
portlessGetUrl,
|
|
9244
8319
|
portlessInstallHint,
|
|
9245
8320
|
portlessStartHint,
|
|
8321
|
+
portlessServiceHint,
|
|
9246
8322
|
portlessDoctorRow,
|
|
9247
8323
|
portlessBrowserEnv,
|
|
9248
8324
|
installPortless,
|
|
9249
8325
|
startPortlessProxy,
|
|
9250
8326
|
startPortlessProxyRoot,
|
|
8327
|
+
portlessServiceStatus,
|
|
8328
|
+
installPortlessService,
|
|
8329
|
+
uninstallPortlessService,
|
|
8330
|
+
ensurePortlessProxy,
|
|
9251
8331
|
resolvePortlessHostStateDir,
|
|
9252
8332
|
EXCLUDE_DIRS,
|
|
9253
8333
|
SNAPSHOTS_ROOT,
|
|
@@ -9337,4 +8417,4 @@ export {
|
|
|
9337
8417
|
ensureBoxBrowser,
|
|
9338
8418
|
ensureBoxBrowserShowingApp
|
|
9339
8419
|
};
|
|
9340
|
-
//# sourceMappingURL=chunk-
|
|
8420
|
+
//# sourceMappingURL=chunk-BLWAWGFX.js.map
|