@madarco/agentbox 0.22.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/dist/{_cloud-attach-YH2SU75S.js → _cloud-attach-RFPLNACE.js} +5 -5
- package/dist/{chunk-GGWVTWJM.js → chunk-6OQENOJZ.js} +16 -13
- package/dist/chunk-6OQENOJZ.js.map +1 -0
- package/dist/{chunk-ALEYDWAO.js → chunk-CKC3CP7Y.js} +494 -148
- package/dist/chunk-CKC3CP7Y.js.map +1 -0
- package/dist/{chunk-O67ZESNL.js → chunk-ERMU7RMK.js} +43 -58
- package/dist/{chunk-O67ZESNL.js.map → chunk-ERMU7RMK.js.map} +1 -1
- package/dist/chunk-G3H2L3O2.js +0 -0
- package/dist/{chunk-KBVD2UUQ.js → chunk-JXDSSSXS.js} +3 -3
- package/dist/{chunk-CDEJ2GQK.js → chunk-L5SOSNQI.js} +4 -4
- package/dist/{chunk-W2FLHB54.js → chunk-Q626V2YX.js} +2 -2
- package/dist/{chunk-YZXXBHWG.js → chunk-QGL734YX.js} +170 -53
- package/dist/chunk-QGL734YX.js.map +1 -0
- package/dist/{chunk-VBSRJG53.js → chunk-QT3SHMLY.js} +9 -1
- package/dist/chunk-QT3SHMLY.js.map +1 -0
- package/dist/{chunk-O2NDZQHN.js → chunk-QVWGQJV6.js} +2 -2
- package/dist/chunk-WJFZJZIM.js +0 -0
- package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
- package/dist/{dist-QBXEP4VY.js → dist-2BTJQUJS.js} +2 -2
- package/dist/{dist-UR2DB2HT.js → dist-GEHCZJCS.js} +6 -6
- package/dist/{dist-LJHS4PTC.js → dist-GJCIKH2C.js} +6 -6
- package/dist/{dist-EJXUKIR7.js → dist-JFUUDAI3.js} +18 -4
- package/dist/{dist-QNV4H6NN.js → dist-W5476E2U.js} +6 -6
- package/dist/{dist-YECTRVGD.js → dist-Z3GSHEFO.js} +8 -7
- package/dist/index.js +1339 -782
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js → prepared-state-LW2PKTEQ-5YMKG7UN.js} +2 -2
- package/package.json +28 -27
- package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
- package/runtime/_shared/agentbox-dockerd-start +0 -0
- package/runtime/_shared/agentbox-open +0 -0
- package/runtime/_shared/agentbox-portless-trust +0 -0
- package/runtime/_shared/agentbox-vnc-start +0 -0
- package/runtime/_shared/ctl.cjs +13 -1
- package/runtime/_shared/gh-shim +0 -0
- package/runtime/_shared/git-shim +0 -0
- package/runtime/_shared/linear-shim +0 -0
- package/runtime/_shared/ntn-shim +0 -0
- package/runtime/docker/Dockerfile.box +12 -0
- package/runtime/docker/packages/ctl/dist/bin.cjs +13 -1
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +44 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/git-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
- package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
- package/runtime/e2b/agentbox-dockerd-start +0 -0
- package/runtime/e2b/agentbox-open +0 -0
- package/runtime/e2b/agentbox-vnc-start +0 -0
- package/runtime/e2b/ctl.cjs +13 -1
- package/runtime/e2b/gh-shim +0 -0
- package/runtime/e2b/git-shim +0 -0
- package/runtime/e2b/linear-shim +0 -0
- package/runtime/e2b/ntn-shim +0 -0
- package/runtime/e2b/scripts/build-template.sh +0 -0
- package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
- package/runtime/hetzner/agentbox-dockerd-start +0 -0
- package/runtime/hetzner/agentbox-open +0 -0
- package/runtime/hetzner/agentbox-portless-trust +0 -0
- package/runtime/hetzner/agentbox-vnc-start +0 -0
- package/runtime/hetzner/ctl.cjs +13 -1
- package/runtime/hetzner/gh-shim +0 -0
- package/runtime/hetzner/git-shim +0 -0
- package/runtime/hetzner/linear-shim +0 -0
- package/runtime/hetzner/ntn-shim +0 -0
- package/runtime/hetzner/scripts/install-box.sh +0 -0
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/routes-manifest.json +22 -0
- package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js +8 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route_client-reference-manifest.js +3 -0
- 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/server-reference-manifest.json +12 -0
- 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/server-reference-manifest.json +12 -0
- 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/server-reference-manifest.json +12 -0
- 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_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/0m4a_kysely_dist_095p8vu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_open-targets_route_actions_1z-vd4m.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_open_route_actions_1agwl8h.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_rename_route_actions_0mf3a9p.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ql4fjo._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vs8fma._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w9ud8u._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yhb0gc._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-0flwc._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1a50b07._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dn_3i1._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1js2jdv._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1nepkp-._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q5bqse._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thipug._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9om6g._.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 +14 -14
- package/runtime/hub/apps/hub/.next/server/chunks/_0f3molr._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/_0lgs9kd._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/044u_hub__next-internal_server_app_(dashboard)_projects_[id]_page_actions_15f56np.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ozyjt1._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_boxes_[id]_page_actions_0k7kgn2.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_page_actions_1t3u0xy.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_[id]_page_tsx_1-j_972._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_components_box-table_tsx_0a9pyn_._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/server/server-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/server-reference-manifest.json +24 -0
- package/runtime/hub/apps/hub/.next/static/chunks/1py5tlz57h7ra.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/{3y2c7woqhtx9s.js → 23fswvjrabu89.js} +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/2xc1sm79a6tsb.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/3nedwutnzpdis.css +3 -0
- package/runtime/hub/apps/hub/.next/static/chunks/3p86ecqhr_7yy.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/3qof5hg87qf5n.js +1 -0
- package/runtime/hub/apps/hub/{auth-YBXDRLHG.js → auth-675P3LQS.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-LJGI76HI.js → auth-config-AOBEKRZQ.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-OBKLTPIR.js → chunk-56YQBVN2.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-JDA7BPPN.js → chunk-6HD4PARX.js} +9 -9
- package/runtime/hub/apps/hub/{chunk-AKLBSCSZ.js → chunk-EXQCBM5Q.js} +8 -0
- package/runtime/hub/apps/hub/{chunk-V5KGFHCF.js → chunk-JQFB2CNA.js} +132 -16
- package/runtime/hub/apps/hub/{chunk-LJG4CEGS.js → chunk-K6RA5GJI.js} +412 -117
- package/runtime/hub/apps/hub/{dist-ELOY2IUE.js → dist-3HR4RIPE.js} +17 -3
- package/runtime/hub/apps/hub/{dist-GGM4BUKM.js → dist-7GNKBKFV.js} +29 -42
- package/runtime/hub/apps/hub/{dist-BF54UNHK.js → dist-JWVTVHBT.js} +4 -4
- package/runtime/hub/apps/hub/{dist-CM4YAQLI.js → dist-OUNL2TCW.js} +4 -4
- package/runtime/hub/apps/hub/{dist-IENF7YOD.js → dist-STQK5XM6.js} +1 -1
- package/runtime/hub/apps/hub/{dist-FDBOJ74K.js → dist-TOHA4OA5.js} +4 -4
- package/runtime/hub/apps/hub/{hub-token-EW32VDIU.js → hub-token-2BZFBBW3.js} +2 -2
- package/runtime/hub/apps/hub/{prepared-state-5FIGV4BE-FIXKBF5A.js → prepared-state-LW2PKTEQ-7BCXARGA.js} +1 -1
- package/runtime/hub/apps/hub/server.js +153 -31
- package/runtime/relay/bin.cjs +13 -1
- package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
- package/runtime/vercel/agentbox-dockerd-start +0 -0
- package/runtime/vercel/agentbox-open +0 -0
- package/runtime/vercel/agentbox-vnc-start +0 -0
- package/runtime/vercel/ctl.cjs +13 -1
- package/runtime/vercel/gh-shim +0 -0
- package/runtime/vercel/git-shim +0 -0
- package/runtime/vercel/linear-shim +0 -0
- package/runtime/vercel/ntn-shim +0 -0
- package/runtime/vercel/scripts/provision.sh +0 -0
- package/LICENSE +0 -21
- package/dist/chunk-ALEYDWAO.js.map +0 -1
- package/dist/chunk-GGWVTWJM.js.map +0 -1
- package/dist/chunk-VBSRJG53.js.map +0 -1
- package/dist/chunk-YZXXBHWG.js.map +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/0dx4alyqu7cq1.css +0 -3
- package/runtime/hub/apps/hub/.next/static/chunks/0lq354ziiwxxl.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/11vmjdy3390ik.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/1svigjdfotduh.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/2d5e6t-5j4etp.js +0 -1
- /package/dist/{_cloud-attach-YH2SU75S.js.map → _cloud-attach-RFPLNACE.js.map} +0 -0
- /package/dist/{chunk-KBVD2UUQ.js.map → chunk-JXDSSSXS.js.map} +0 -0
- /package/dist/{chunk-CDEJ2GQK.js.map → chunk-L5SOSNQI.js.map} +0 -0
- /package/dist/{chunk-W2FLHB54.js.map → chunk-Q626V2YX.js.map} +0 -0
- /package/dist/{chunk-O2NDZQHN.js.map → chunk-QVWGQJV6.js.map} +0 -0
- /package/dist/{dist-EJXUKIR7.js.map → dist-2BTJQUJS.js.map} +0 -0
- /package/dist/{dist-UR2DB2HT.js.map → dist-GEHCZJCS.js.map} +0 -0
- /package/dist/{dist-LJHS4PTC.js.map → dist-GJCIKH2C.js.map} +0 -0
- /package/dist/{dist-QBXEP4VY.js.map → dist-JFUUDAI3.js.map} +0 -0
- /package/dist/{dist-QNV4H6NN.js.map → dist-W5476E2U.js.map} +0 -0
- /package/dist/{dist-YECTRVGD.js.map → dist-Z3GSHEFO.js.map} +0 -0
- /package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js.map → prepared-state-LW2PKTEQ-5YMKG7UN.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → 6WtaFwavHBpin3eT7-HjR}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → 6WtaFwavHBpin3eT7-HjR}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → 6WtaFwavHBpin3eT7-HjR}/_ssgManifest.js +0 -0
|
@@ -304,39 +304,47 @@ import { dirname as dirname2, join as join2 } from "path";
|
|
|
304
304
|
import { setTimeout as delay } from "timers/promises";
|
|
305
305
|
import { readdir, stat as stat2 } from "fs/promises";
|
|
306
306
|
import { join as join22 } from "path";
|
|
307
|
-
import {
|
|
308
|
-
import { homedir as homedir22 } from "os";
|
|
309
|
-
import { dirname as dirname22, resolve as resolve3 } from "path";
|
|
310
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
307
|
+
import { promises as fs } from "fs";
|
|
311
308
|
import { homedir as homedir3 } from "os";
|
|
312
|
-
import { dirname as dirname3, join as
|
|
313
|
-
import {
|
|
314
|
-
import {
|
|
315
|
-
import {
|
|
316
|
-
import {
|
|
309
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
310
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
311
|
+
import { homedir as homedir22 } from "os";
|
|
312
|
+
import { dirname as dirname22, join as join3 } from "path";
|
|
313
|
+
import { mkdir as mkdir2, readFile as readFile2 } from "fs/promises";
|
|
314
|
+
import { join as join5, resolve as resolve3 } from "path";
|
|
315
|
+
import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
317
316
|
import { homedir as homedir4 } from "os";
|
|
317
|
+
import { dirname as dirname4, resolve as resolve22 } from "path";
|
|
318
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
319
|
+
import { homedir as homedir5 } from "os";
|
|
320
|
+
import { dirname as dirname5, join as join6 } from "path";
|
|
321
|
+
import { mkdtemp, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
322
|
+
import { tmpdir } from "os";
|
|
323
|
+
import { basename as basename2, join as join7 } from "path";
|
|
324
|
+
import { join as join8 } from "path";
|
|
325
|
+
import { homedir as homedir6 } from "os";
|
|
318
326
|
import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
|
|
319
327
|
import { tmpdir as tmpdir2 } from "os";
|
|
320
|
-
import { join as
|
|
328
|
+
import { join as join9 } from "path";
|
|
321
329
|
import { readdir as readdir2, stat as stat4 } from "fs/promises";
|
|
322
|
-
import { homedir as
|
|
323
|
-
import { join as
|
|
330
|
+
import { homedir as homedir7 } from "os";
|
|
331
|
+
import { join as join10 } from "path";
|
|
324
332
|
import { readdir as readdir3, realpath as realpath2, stat as stat5 } from "fs/promises";
|
|
325
|
-
import { isAbsolute as isAbsolute3, join as
|
|
333
|
+
import { isAbsolute as isAbsolute3, join as join11, relative } from "path";
|
|
326
334
|
import { stat as stat6 } from "fs/promises";
|
|
327
|
-
import { chmod, mkdir as
|
|
328
|
-
import { dirname as
|
|
335
|
+
import { chmod, mkdir as mkdir4, readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
|
|
336
|
+
import { dirname as dirname6 } from "path";
|
|
329
337
|
import { createHash } from "crypto";
|
|
330
|
-
import { readFile as
|
|
331
|
-
import { join as
|
|
338
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
339
|
+
import { join as join12 } from "path";
|
|
332
340
|
import { createHash as createHash2 } from "crypto";
|
|
333
|
-
import { copyFile, mkdir as
|
|
334
|
-
import { homedir as
|
|
335
|
-
import { basename as basename22, dirname as
|
|
336
|
-
import { copyFile as copyFile2, mkdtemp as mkdtemp4, readdir as readdir5, readFile as
|
|
337
|
-
import { homedir as
|
|
338
|
-
import { basename as basename3, join as
|
|
339
|
-
import { homedir as
|
|
341
|
+
import { copyFile, mkdir as mkdir5, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile7, rm as rm4, stat as stat7 } from "fs/promises";
|
|
342
|
+
import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
|
|
343
|
+
import { basename as basename22, dirname as dirname7, join as join13 } from "path";
|
|
344
|
+
import { copyFile as copyFile2, mkdtemp as mkdtemp4, readdir as readdir5, readFile as readFile8, rm as rm5, stat as stat8, writeFile as writeFile5 } from "fs/promises";
|
|
345
|
+
import { homedir as homedir10, tmpdir as tmpdir4 } from "os";
|
|
346
|
+
import { basename as basename3, join as join14, relative as relative2 } from "path";
|
|
347
|
+
import { homedir as homedir9 } from "os";
|
|
340
348
|
|
|
341
349
|
// ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/date.js
|
|
342
350
|
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
@@ -1161,10 +1169,10 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
|
1161
1169
|
|
|
1162
1170
|
// ../../packages/sandbox-core/dist/index.js
|
|
1163
1171
|
import { createHash as createHash3 } from "crypto";
|
|
1164
|
-
import { existsSync as
|
|
1165
|
-
import { readFile as
|
|
1166
|
-
import { homedir as
|
|
1167
|
-
import { dirname as
|
|
1172
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
1173
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
1174
|
+
import { homedir as homedir11 } from "os";
|
|
1175
|
+
import { dirname as dirname8, resolve as pathResolve } from "path";
|
|
1168
1176
|
var STATE_DIR = join2(homedir2(), ".agentbox");
|
|
1169
1177
|
var STATE_FILE = join2(STATE_DIR, "state.json");
|
|
1170
1178
|
var EMPTY = { version: 1, boxes: [] };
|
|
@@ -1223,6 +1231,8 @@ async function readState(path = STATE_FILE) {
|
|
|
1223
1231
|
if ((b.provider ?? "docker") === "docker" && !b.docker) {
|
|
1224
1232
|
b.docker = projectDockerFields(b);
|
|
1225
1233
|
}
|
|
1234
|
+
const legacySsh = b.cloud?.ssh;
|
|
1235
|
+
if (!b.ssh && legacySsh) b.ssh = legacySsh;
|
|
1226
1236
|
}
|
|
1227
1237
|
return parsed;
|
|
1228
1238
|
} catch (err) {
|
|
@@ -1257,6 +1267,32 @@ async function recordLastAgent(boxId, kind, path = STATE_FILE) {
|
|
|
1257
1267
|
path
|
|
1258
1268
|
);
|
|
1259
1269
|
}
|
|
1270
|
+
async function setBoxDisplayName(boxId, displayName, path = STATE_FILE) {
|
|
1271
|
+
const trimmed = displayName?.trim();
|
|
1272
|
+
const next = trimmed ? trimmed : void 0;
|
|
1273
|
+
await mutateState(
|
|
1274
|
+
(state) => ({
|
|
1275
|
+
version: 1,
|
|
1276
|
+
boxes: state.boxes.map((b) => {
|
|
1277
|
+
if (b.id !== boxId) return b;
|
|
1278
|
+
if (next) return { ...b, displayName: next };
|
|
1279
|
+
const rest = { ...b };
|
|
1280
|
+
delete rest.displayName;
|
|
1281
|
+
return rest;
|
|
1282
|
+
})
|
|
1283
|
+
}),
|
|
1284
|
+
path
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
async function recordBoxSsh(boxId, ssh, path = STATE_FILE) {
|
|
1288
|
+
await mutateState(
|
|
1289
|
+
(state) => ({
|
|
1290
|
+
version: 1,
|
|
1291
|
+
boxes: state.boxes.map((b) => b.id === boxId ? { ...b, ssh } : b)
|
|
1292
|
+
}),
|
|
1293
|
+
path
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1260
1296
|
async function reserveProjectIndex(record, projectRoot, path = STATE_FILE) {
|
|
1261
1297
|
let index = 1;
|
|
1262
1298
|
await mutateState((state) => {
|
|
@@ -1310,6 +1346,8 @@ function findBox(idOrName, state) {
|
|
|
1310
1346
|
if (prefixMatches.length > 1) return { kind: "ambiguous", matches: prefixMatches };
|
|
1311
1347
|
const byName = state.boxes.find((b) => b.name === q);
|
|
1312
1348
|
if (byName) return { kind: "ok", box: byName };
|
|
1349
|
+
const byDisplayName = state.boxes.find((b) => b.displayName === q);
|
|
1350
|
+
if (byDisplayName) return { kind: "ok", box: byDisplayName };
|
|
1313
1351
|
const byContainer = state.boxes.find((b) => b.container === q);
|
|
1314
1352
|
if (byContainer) return { kind: "ok", box: byContainer };
|
|
1315
1353
|
return { kind: "none" };
|
|
@@ -1397,6 +1435,231 @@ var GitWorktreeError = class extends Error {
|
|
|
1397
1435
|
function hostOpenCommand() {
|
|
1398
1436
|
return process.platform === "linux" ? "xdg-open" : "open";
|
|
1399
1437
|
}
|
|
1438
|
+
function claudeSettingsPath() {
|
|
1439
|
+
return join3(homedir22(), ".claude", "settings.json");
|
|
1440
|
+
}
|
|
1441
|
+
function readSettings(path) {
|
|
1442
|
+
if (!existsSync(path)) return {};
|
|
1443
|
+
let parsed;
|
|
1444
|
+
try {
|
|
1445
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
1446
|
+
} catch (err) {
|
|
1447
|
+
throw new Error(
|
|
1448
|
+
`${path} exists but is not valid JSON (${err instanceof Error ? err.message : String(err)}) \u2014 not touching it. Fix the file and retry.`
|
|
1449
|
+
);
|
|
1450
|
+
}
|
|
1451
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1452
|
+
throw new Error(`${path} is not a JSON object \u2014 not touching it. Fix the file and retry.`);
|
|
1453
|
+
}
|
|
1454
|
+
return parsed;
|
|
1455
|
+
}
|
|
1456
|
+
function writeSettings(path, settings) {
|
|
1457
|
+
mkdirSync(dirname22(path), { recursive: true });
|
|
1458
|
+
writeFileSync(path, JSON.stringify(settings, null, 2) + "\n");
|
|
1459
|
+
}
|
|
1460
|
+
function entryId(e) {
|
|
1461
|
+
if (e !== null && typeof e === "object" && typeof e.id === "string") {
|
|
1462
|
+
return e.id;
|
|
1463
|
+
}
|
|
1464
|
+
return void 0;
|
|
1465
|
+
}
|
|
1466
|
+
function pruneOrphanClaudeSshConfigs(liveAliases) {
|
|
1467
|
+
return removeClaudeSshConfigs(
|
|
1468
|
+
(id) => id.startsWith("agentbox-") && !liveAliases.has(id.slice("agentbox-".length))
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
function removeClaudeSshConfigs(predicate) {
|
|
1472
|
+
const path = claudeSettingsPath();
|
|
1473
|
+
if (!existsSync(path)) return 0;
|
|
1474
|
+
const settings = readSettings(path);
|
|
1475
|
+
if (!Array.isArray(settings.sshConfigs)) return 0;
|
|
1476
|
+
const kept = settings.sshConfigs.filter((e) => {
|
|
1477
|
+
const id = entryId(e);
|
|
1478
|
+
return id === void 0 || !predicate(id);
|
|
1479
|
+
});
|
|
1480
|
+
const removed = settings.sshConfigs.length - kept.length;
|
|
1481
|
+
if (removed === 0) return 0;
|
|
1482
|
+
settings.sshConfigs = kept;
|
|
1483
|
+
writeSettings(path, settings);
|
|
1484
|
+
return removed;
|
|
1485
|
+
}
|
|
1486
|
+
function sshConfigPath() {
|
|
1487
|
+
return join4(homedir3(), ".ssh", "config");
|
|
1488
|
+
}
|
|
1489
|
+
function agentboxSshConfigPath() {
|
|
1490
|
+
return join4(homedir3(), ".agentbox", "ssh", "config");
|
|
1491
|
+
}
|
|
1492
|
+
function stateFilePath() {
|
|
1493
|
+
return join4(homedir3(), ".agentbox", "state.json");
|
|
1494
|
+
}
|
|
1495
|
+
var INCLUDE_BEGIN = "# BEGIN agentbox ssh include";
|
|
1496
|
+
var INCLUDE_END = "# END agentbox ssh include";
|
|
1497
|
+
function beginMarker(alias) {
|
|
1498
|
+
return `# BEGIN agentbox cloud box ${alias}`;
|
|
1499
|
+
}
|
|
1500
|
+
function endMarker(alias) {
|
|
1501
|
+
return `# END agentbox cloud box ${alias}`;
|
|
1502
|
+
}
|
|
1503
|
+
function agentboxAliasFor(boxName) {
|
|
1504
|
+
return boxName;
|
|
1505
|
+
}
|
|
1506
|
+
async function readFileOrEmpty(path) {
|
|
1507
|
+
try {
|
|
1508
|
+
return await fs.readFile(path, "utf8");
|
|
1509
|
+
} catch (err) {
|
|
1510
|
+
if (err.code === "ENOENT") return "";
|
|
1511
|
+
throw err;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
function buildBlock(opts) {
|
|
1515
|
+
const lines = [
|
|
1516
|
+
beginMarker(opts.alias),
|
|
1517
|
+
`Host ${opts.alias}`,
|
|
1518
|
+
` HostName ${opts.hostname}`,
|
|
1519
|
+
` User ${opts.user}`
|
|
1520
|
+
];
|
|
1521
|
+
if (opts.port) {
|
|
1522
|
+
lines.push(` Port ${String(opts.port)}`);
|
|
1523
|
+
}
|
|
1524
|
+
if (opts.identityFile) {
|
|
1525
|
+
lines.push(` IdentityFile ${opts.identityFile}`);
|
|
1526
|
+
lines.push(` IdentitiesOnly yes`);
|
|
1527
|
+
}
|
|
1528
|
+
lines.push(
|
|
1529
|
+
` StrictHostKeyChecking accept-new`,
|
|
1530
|
+
` UserKnownHostsFile /dev/null`,
|
|
1531
|
+
` LogLevel ERROR`,
|
|
1532
|
+
endMarker(opts.alias),
|
|
1533
|
+
""
|
|
1534
|
+
);
|
|
1535
|
+
return lines.join("\n");
|
|
1536
|
+
}
|
|
1537
|
+
function stripLegacyInlineBlocks(contents) {
|
|
1538
|
+
const pattern = /^# BEGIN agentbox cloud box .*\n[\s\S]*?^# END agentbox cloud box .*\n?/gm;
|
|
1539
|
+
return contents.replace(pattern, "");
|
|
1540
|
+
}
|
|
1541
|
+
function hasIncludeBlock(contents) {
|
|
1542
|
+
return contents.includes(INCLUDE_BEGIN) || contents.includes(`Include ${agentboxSshConfigPath()}`);
|
|
1543
|
+
}
|
|
1544
|
+
async function ensureSshInclude() {
|
|
1545
|
+
const path = sshConfigPath();
|
|
1546
|
+
await fs.mkdir(join4(homedir3(), ".ssh"), { recursive: true, mode: 448 });
|
|
1547
|
+
const existing = stripLegacyInlineBlocks(await readFileOrEmpty(path));
|
|
1548
|
+
let next = existing;
|
|
1549
|
+
if (!hasIncludeBlock(existing)) {
|
|
1550
|
+
const block = `${INCLUDE_BEGIN}
|
|
1551
|
+
Include ${agentboxSshConfigPath()}
|
|
1552
|
+
${INCLUDE_END}
|
|
1553
|
+
`;
|
|
1554
|
+
next = existing.length === 0 ? block : `${block}
|
|
1555
|
+
${existing}`;
|
|
1556
|
+
}
|
|
1557
|
+
await fs.writeFile(path, next, { mode: 384 });
|
|
1558
|
+
await fs.chmod(path, 384);
|
|
1559
|
+
}
|
|
1560
|
+
async function syncAgentboxSshConfig(statePath = stateFilePath()) {
|
|
1561
|
+
const state = await readState(statePath);
|
|
1562
|
+
const blocks = [];
|
|
1563
|
+
for (const box of state.boxes) {
|
|
1564
|
+
const ssh = box.ssh;
|
|
1565
|
+
if (!ssh) continue;
|
|
1566
|
+
blocks.push(
|
|
1567
|
+
buildBlock({
|
|
1568
|
+
alias: agentboxAliasFor(box.name),
|
|
1569
|
+
hostname: ssh.host,
|
|
1570
|
+
user: ssh.user,
|
|
1571
|
+
identityFile: ssh.identityFile,
|
|
1572
|
+
port: ssh.port
|
|
1573
|
+
})
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
const header = "# Managed by agentbox \u2014 regenerated on box create/start/destroy.\n# Do not edit; changes are overwritten. Disable with `agentbox config set ssh.autoConfig false`.\n\n";
|
|
1577
|
+
const path = agentboxSshConfigPath();
|
|
1578
|
+
await fs.mkdir(dirname3(path), { recursive: true, mode: 448 });
|
|
1579
|
+
await fs.writeFile(path, header + blocks.join("\n"), { mode: 384 });
|
|
1580
|
+
await fs.chmod(path, 384);
|
|
1581
|
+
await ensureSshInclude();
|
|
1582
|
+
try {
|
|
1583
|
+
pruneOrphanClaudeSshConfigs(new Set(state.boxes.map((b) => agentboxAliasFor(b.name))));
|
|
1584
|
+
} catch {
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
function parseSshTarget(argv) {
|
|
1588
|
+
let target;
|
|
1589
|
+
for (let i = argv.length - 1; i >= 0; i--) {
|
|
1590
|
+
const v = argv[i];
|
|
1591
|
+
if (!v || v.startsWith("-")) continue;
|
|
1592
|
+
const at = v.indexOf("@");
|
|
1593
|
+
if (at <= 0) continue;
|
|
1594
|
+
target = { user: v.slice(0, at), host: v.slice(at + 1) };
|
|
1595
|
+
break;
|
|
1596
|
+
}
|
|
1597
|
+
if (!target) return void 0;
|
|
1598
|
+
let identityFile;
|
|
1599
|
+
for (let i = 0; i < argv.length - 1; i++) {
|
|
1600
|
+
if (argv[i] === "-i") {
|
|
1601
|
+
identityFile = argv[i + 1];
|
|
1602
|
+
break;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
return { ...target, identityFile };
|
|
1606
|
+
}
|
|
1607
|
+
async function resolveCloudSshTarget(box, provider, opts = {}) {
|
|
1608
|
+
if (!provider.buildAttach) {
|
|
1609
|
+
throw new Error(`cloud provider '${provider.name}' does not support SSH attach`);
|
|
1610
|
+
}
|
|
1611
|
+
if (opts.bringOnline ?? true) {
|
|
1612
|
+
const state = await provider.probeState(box);
|
|
1613
|
+
if (state === "paused") {
|
|
1614
|
+
opts.logInfo?.("box is paused; resuming");
|
|
1615
|
+
await provider.resume(box);
|
|
1616
|
+
} else if (state === "stopped") {
|
|
1617
|
+
opts.logInfo?.("box is stopped; starting");
|
|
1618
|
+
await provider.start(box);
|
|
1619
|
+
} else if (state === "missing") {
|
|
1620
|
+
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
const spec = await provider.buildAttach(box, "shell", { noTmux: true });
|
|
1624
|
+
const target = parseSshTarget(spec.argv);
|
|
1625
|
+
if (!target) {
|
|
1626
|
+
throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
|
|
1627
|
+
}
|
|
1628
|
+
const alias = agentboxAliasFor(box.name);
|
|
1629
|
+
return { alias, host: target.host, user: target.user, identityFile: target.identityFile };
|
|
1630
|
+
}
|
|
1631
|
+
async function autoWriteSshConfig(box, provider, enabled, logWarn) {
|
|
1632
|
+
if (!enabled) return;
|
|
1633
|
+
try {
|
|
1634
|
+
const conn = await resolveCloudSshTarget(box, provider, { bringOnline: false });
|
|
1635
|
+
if (!conn.identityFile) return;
|
|
1636
|
+
await recordBoxSsh(box.id, {
|
|
1637
|
+
host: conn.host,
|
|
1638
|
+
user: conn.user,
|
|
1639
|
+
identityFile: conn.identityFile
|
|
1640
|
+
});
|
|
1641
|
+
await syncAgentboxSshConfig();
|
|
1642
|
+
} catch (err) {
|
|
1643
|
+
logWarn?.(
|
|
1644
|
+
`ssh-config auto-write for ${box.name} failed: ${err instanceof Error ? err.message : String(err)}`
|
|
1645
|
+
);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
async function mintSshKey(targetDir, comment) {
|
|
1649
|
+
const dir = resolve3(targetDir);
|
|
1650
|
+
const priv = join5(dir, "id_ed25519");
|
|
1651
|
+
const pub = `${priv}.pub`;
|
|
1652
|
+
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
1653
|
+
const existing = await readFile2(pub, "utf8").catch(() => null);
|
|
1654
|
+
if (existing !== null) {
|
|
1655
|
+
return { dir, privatePath: priv, publicPath: pub, publicKey: existing.trim() };
|
|
1656
|
+
}
|
|
1657
|
+
await execa("ssh-keygen", ["-t", "ed25519", "-N", "", "-C", comment, "-f", priv, "-q"], {
|
|
1658
|
+
stdio: "pipe"
|
|
1659
|
+
});
|
|
1660
|
+
const publicKey = (await readFile2(pub, "utf8")).trim();
|
|
1661
|
+
return { dir, privatePath: priv, publicPath: pub, publicKey };
|
|
1662
|
+
}
|
|
1400
1663
|
var BOX_WORKSPACE = "/workspace";
|
|
1401
1664
|
function run(provider, box, argv) {
|
|
1402
1665
|
return provider.exec(box, argv, { cwd: BOX_WORKSPACE });
|
|
@@ -1472,17 +1735,17 @@ function errSummary(err) {
|
|
|
1472
1735
|
return err instanceof Error ? firstLine(err.message) : String(err);
|
|
1473
1736
|
}
|
|
1474
1737
|
function secretsEnvPath() {
|
|
1475
|
-
return
|
|
1738
|
+
return resolve22(homedir4(), ".agentbox", "secrets.env");
|
|
1476
1739
|
}
|
|
1477
1740
|
function writeManagedSecrets(managedKeys, record) {
|
|
1478
1741
|
for (const k of managedKeys) delete process.env[k];
|
|
1479
1742
|
for (const [k, v] of Object.entries(record)) process.env[k] = v;
|
|
1480
1743
|
const path = secretsEnvPath();
|
|
1481
|
-
|
|
1744
|
+
mkdirSync2(dirname4(path), { recursive: true });
|
|
1482
1745
|
let existing = "";
|
|
1483
|
-
if (
|
|
1746
|
+
if (existsSync2(path)) {
|
|
1484
1747
|
try {
|
|
1485
|
-
existing =
|
|
1748
|
+
existing = readFileSync2(path, "utf8");
|
|
1486
1749
|
} catch {
|
|
1487
1750
|
existing = "";
|
|
1488
1751
|
}
|
|
@@ -1498,7 +1761,7 @@ function writeManagedSecrets(managedKeys, record) {
|
|
|
1498
1761
|
const body = (kept ? `${kept}
|
|
1499
1762
|
` : "") + lines.join("\n") + "\n";
|
|
1500
1763
|
const tmp = `${path}.tmp`;
|
|
1501
|
-
|
|
1764
|
+
writeFileSync2(tmp, body, { mode: 384 });
|
|
1502
1765
|
try {
|
|
1503
1766
|
chmodSync(tmp, 384);
|
|
1504
1767
|
} catch {
|
|
@@ -1509,8 +1772,8 @@ function writeManagedSecrets(managedKeys, record) {
|
|
|
1509
1772
|
} catch {
|
|
1510
1773
|
}
|
|
1511
1774
|
}
|
|
1512
|
-
var PLUGINS_FILE =
|
|
1513
|
-
var SUPPORTED_SDK_API_VERSIONS = [1];
|
|
1775
|
+
var PLUGINS_FILE = join6(homedir5(), ".agentbox", "plugins.json");
|
|
1776
|
+
var SUPPORTED_SDK_API_VERSIONS = [1, 2];
|
|
1514
1777
|
function isSupportedApiVersion(v) {
|
|
1515
1778
|
return SUPPORTED_SDK_API_VERSIONS.includes(v);
|
|
1516
1779
|
}
|
|
@@ -1524,8 +1787,8 @@ function normalize2(raw) {
|
|
|
1524
1787
|
}
|
|
1525
1788
|
function readPluginRegistrySync(path = PLUGINS_FILE) {
|
|
1526
1789
|
try {
|
|
1527
|
-
if (!
|
|
1528
|
-
return normalize2(JSON.parse(
|
|
1790
|
+
if (!existsSync3(path)) return { ...EMPTY2 };
|
|
1791
|
+
return normalize2(JSON.parse(readFileSync3(path, "utf8")));
|
|
1529
1792
|
} catch {
|
|
1530
1793
|
return { ...EMPTY2 };
|
|
1531
1794
|
}
|
|
@@ -1548,21 +1811,21 @@ function wantsRender(e) {
|
|
|
1548
1811
|
async function renderCarryEntries(entries, ctx, onLog) {
|
|
1549
1812
|
if (!entries.some(wantsRender)) return entries;
|
|
1550
1813
|
const context = carryPlaceholderContext(ctx);
|
|
1551
|
-
const stage = await mkdtemp(
|
|
1814
|
+
const stage = await mkdtemp(join7(tmpdir(), "agentbox-carry-render-"));
|
|
1552
1815
|
const out = [];
|
|
1553
1816
|
for (const [i, entry] of entries.entries()) {
|
|
1554
1817
|
if (!wantsRender(entry)) {
|
|
1555
1818
|
out.push(entry);
|
|
1556
1819
|
continue;
|
|
1557
1820
|
}
|
|
1558
|
-
const content = await
|
|
1821
|
+
const content = await readFile4(entry.absSrc, "utf8");
|
|
1559
1822
|
const rendered = applyReplacements(content, {
|
|
1560
1823
|
env: entry.replaceEnvs,
|
|
1561
1824
|
rules: entry.replace,
|
|
1562
1825
|
context,
|
|
1563
1826
|
onWarn: (msg) => onLog?.(`carry: ${entry.rawSrc}: ${msg}`)
|
|
1564
1827
|
});
|
|
1565
|
-
const tmp =
|
|
1828
|
+
const tmp = join7(stage, `${String(i)}-${basename2(entry.absSrc)}`);
|
|
1566
1829
|
await writeFile3(tmp, rendered, "utf8");
|
|
1567
1830
|
out.push({ ...entry, absSrc: tmp, bytes: Buffer.byteLength(rendered) });
|
|
1568
1831
|
const what = [
|
|
@@ -1618,7 +1881,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
1618
1881
|
credential: {
|
|
1619
1882
|
boxRelPath: ".credentials.json",
|
|
1620
1883
|
boxAbsPath: `${CLAUDE_BOX_DIR}/.credentials.json`,
|
|
1621
|
-
hostBackup:
|
|
1884
|
+
hostBackup: join8(STATE_DIR, "claude-credentials.json"),
|
|
1622
1885
|
cloudMountPath: "/home/vscode/.agentbox-creds/claude",
|
|
1623
1886
|
cloudSubpath: "claude/",
|
|
1624
1887
|
realShape: "claude-oauth"
|
|
@@ -1678,7 +1941,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
1678
1941
|
credential: {
|
|
1679
1942
|
boxRelPath: "auth.json",
|
|
1680
1943
|
boxAbsPath: `${CODEX_BOX_DIR}/auth.json`,
|
|
1681
|
-
hostBackup:
|
|
1944
|
+
hostBackup: join8(STATE_DIR, "codex-credentials.json"),
|
|
1682
1945
|
cloudMountPath: "/home/vscode/.agentbox-creds/codex",
|
|
1683
1946
|
cloudSubpath: "codex/",
|
|
1684
1947
|
realShape: "nonempty-json"
|
|
@@ -1729,7 +1992,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
1729
1992
|
credential: {
|
|
1730
1993
|
boxRelPath: "auth.json",
|
|
1731
1994
|
boxAbsPath: `${OPENCODE_BOX_DIR}/auth.json`,
|
|
1732
|
-
hostBackup:
|
|
1995
|
+
hostBackup: join8(STATE_DIR, "opencode-credentials.json"),
|
|
1733
1996
|
cloudMountPath: "/home/vscode/.agentbox-creds/opencode",
|
|
1734
1997
|
cloudSubpath: "opencode/",
|
|
1735
1998
|
realShape: "nonempty-json"
|
|
@@ -1763,7 +2026,7 @@ function makeSyncContext(init) {
|
|
|
1763
2026
|
hostWorkspace: init.hostWorkspace,
|
|
1764
2027
|
projectRoot: init.projectRoot ?? init.hostWorkspace,
|
|
1765
2028
|
boxWorkspace: init.boxWorkspace ?? "/workspace",
|
|
1766
|
-
hostHome: init.hostHome ??
|
|
2029
|
+
hostHome: init.hostHome ?? homedir6(),
|
|
1767
2030
|
onLog: init.onLog ?? (() => {
|
|
1768
2031
|
})
|
|
1769
2032
|
};
|
|
@@ -1835,8 +2098,8 @@ async function scanHostEnvFiles(workspaceDir, patterns) {
|
|
|
1835
2098
|
async function pushEnvFiles(ctx, transport, patterns) {
|
|
1836
2099
|
const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
|
|
1837
2100
|
if (list.length === 0) return { copied: 0 };
|
|
1838
|
-
const stage = await mkdtemp2(
|
|
1839
|
-
const localTar =
|
|
2101
|
+
const stage = await mkdtemp2(join9(tmpdir2(), "agentbox-envfiles-"));
|
|
2102
|
+
const localTar = join9(stage, "envfiles.tar");
|
|
1840
2103
|
try {
|
|
1841
2104
|
const packed = await execa(
|
|
1842
2105
|
"tar",
|
|
@@ -1908,9 +2171,9 @@ function encodeClaudeProjectsKey(absPath) {
|
|
|
1908
2171
|
return absPath.replace(/[^a-zA-Z0-9]/g, "-");
|
|
1909
2172
|
}
|
|
1910
2173
|
var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
|
|
1911
|
-
async function resolveClaudeMemoryDir(hostWorkspace, hostHome =
|
|
2174
|
+
async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir7()) {
|
|
1912
2175
|
if (hostWorkspace.length === 0) return null;
|
|
1913
|
-
const memDir =
|
|
2176
|
+
const memDir = join10(
|
|
1914
2177
|
hostHome,
|
|
1915
2178
|
".claude",
|
|
1916
2179
|
"projects",
|
|
@@ -1953,8 +2216,8 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
|
|
|
1953
2216
|
return;
|
|
1954
2217
|
}
|
|
1955
2218
|
for (const ent of entries) {
|
|
1956
|
-
const realFull =
|
|
1957
|
-
const virtualFull = virtualDir ?
|
|
2219
|
+
const realFull = join11(realDir, ent.name);
|
|
2220
|
+
const virtualFull = virtualDir ? join11(virtualDir, ent.name) : ent.name;
|
|
1958
2221
|
if (ent.isSymbolicLink()) {
|
|
1959
2222
|
let real;
|
|
1960
2223
|
try {
|
|
@@ -2032,7 +2295,7 @@ function isRealAgentCredential(agent, text) {
|
|
|
2032
2295
|
}
|
|
2033
2296
|
async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now()) {
|
|
2034
2297
|
try {
|
|
2035
|
-
const parsed = JSON.parse(await
|
|
2298
|
+
const parsed = JSON.parse(await readFile5(path, "utf8"));
|
|
2036
2299
|
const exp = parsed?.claudeAiOauth?.expiresAt;
|
|
2037
2300
|
return typeof exp === "number" && Number.isFinite(exp) && exp < now;
|
|
2038
2301
|
} catch {
|
|
@@ -2041,7 +2304,7 @@ async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now
|
|
|
2041
2304
|
}
|
|
2042
2305
|
async function hostBackupHasCredentials(path = CLAUDE_HOST_BACKUP) {
|
|
2043
2306
|
try {
|
|
2044
|
-
const parsed = JSON.parse(await
|
|
2307
|
+
const parsed = JSON.parse(await readFile5(path, "utf8"));
|
|
2045
2308
|
const rt = parsed?.claudeAiOauth?.refreshToken;
|
|
2046
2309
|
return typeof rt === "string" && rt.length > 0;
|
|
2047
2310
|
} catch {
|
|
@@ -2057,7 +2320,7 @@ async function extractCredentials(transport, opts = {}) {
|
|
|
2057
2320
|
try {
|
|
2058
2321
|
const text = await transport.readText(spec.credential.boxAbsPath);
|
|
2059
2322
|
if (!text || !isRealAgentCredential(spec.id, text)) continue;
|
|
2060
|
-
await
|
|
2323
|
+
await mkdir4(dirname6(hostBackup), { recursive: true });
|
|
2061
2324
|
await writeFile4(hostBackup, text, { mode: 384 });
|
|
2062
2325
|
await chmod(hostBackup, 384).catch(() => {
|
|
2063
2326
|
});
|
|
@@ -2219,7 +2482,7 @@ function makeHostGitPorts() {
|
|
|
2219
2482
|
return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
|
|
2220
2483
|
},
|
|
2221
2484
|
async hashHostFile(hostMain, relPath) {
|
|
2222
|
-
return createHash("sha256").update(await
|
|
2485
|
+
return createHash("sha256").update(await readFile6(join12(hostMain, relPath))).digest("hex");
|
|
2223
2486
|
},
|
|
2224
2487
|
async packHostFiles(hostMain, relPaths) {
|
|
2225
2488
|
const tarOut = await execa("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
|
|
@@ -2252,7 +2515,7 @@ async function walkFiles(root, prefix = "") {
|
|
|
2252
2515
|
const out = [];
|
|
2253
2516
|
for (const ent of entries) {
|
|
2254
2517
|
const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
|
|
2255
|
-
const full =
|
|
2518
|
+
const full = join13(root, ent.name);
|
|
2256
2519
|
if (ent.isDirectory()) {
|
|
2257
2520
|
out.push(...await walkFiles(full, rel));
|
|
2258
2521
|
} else if (ent.isFile()) {
|
|
@@ -2268,7 +2531,7 @@ async function walkFiles(root, prefix = "") {
|
|
|
2268
2531
|
return out;
|
|
2269
2532
|
}
|
|
2270
2533
|
async function hashFile(absPath) {
|
|
2271
|
-
const buf = await
|
|
2534
|
+
const buf = await readFile7(absPath);
|
|
2272
2535
|
return createHash2("sha256").update(buf).digest("hex");
|
|
2273
2536
|
}
|
|
2274
2537
|
async function buildHostSet(name, hostDir, boxDst) {
|
|
@@ -2276,12 +2539,12 @@ async function buildHostSet(name, hostDir, boxDst) {
|
|
|
2276
2539
|
const rels = await walkFiles(hostDir);
|
|
2277
2540
|
const files = {};
|
|
2278
2541
|
for (const rel of rels) {
|
|
2279
|
-
files[rel] = await hashFile(
|
|
2542
|
+
files[rel] = await hashFile(join13(hostDir, rel));
|
|
2280
2543
|
}
|
|
2281
2544
|
return { dst: boxDst, files, hostDir };
|
|
2282
2545
|
}
|
|
2283
|
-
async function buildHostSyncManifest(workspacePath, hostHome =
|
|
2284
|
-
const workflowsDir =
|
|
2546
|
+
async function buildHostSyncManifest(workspacePath, hostHome = homedir8()) {
|
|
2547
|
+
const workflowsDir = join13(hostHome, ".claude", "workflows");
|
|
2285
2548
|
const workflowsHost = await pathExists3(workflowsDir) ? workflowsDir : null;
|
|
2286
2549
|
const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
|
|
2287
2550
|
const [workflows, memory] = await Promise.all([
|
|
@@ -2303,7 +2566,7 @@ function computeSyncDelta(host, box) {
|
|
|
2303
2566
|
uploads.push({
|
|
2304
2567
|
set: name,
|
|
2305
2568
|
rel,
|
|
2306
|
-
absSrc:
|
|
2569
|
+
absSrc: join13(hostSet.hostDir, rel),
|
|
2307
2570
|
dst: `${hostSet.dst}/${rel}`
|
|
2308
2571
|
});
|
|
2309
2572
|
}
|
|
@@ -2322,15 +2585,15 @@ async function stageDynamicSyncTarball(uploads) {
|
|
|
2322
2585
|
return { tarballPath: null, cleanup: async () => {
|
|
2323
2586
|
} };
|
|
2324
2587
|
}
|
|
2325
|
-
const stageDir = await mkdtemp3(
|
|
2588
|
+
const stageDir = await mkdtemp3(join13(tmpdir3(), "agentbox-dynsync-stage-"));
|
|
2326
2589
|
let tarballPath = null;
|
|
2327
2590
|
try {
|
|
2328
2591
|
for (const up of uploads) {
|
|
2329
|
-
const target =
|
|
2330
|
-
await
|
|
2592
|
+
const target = join13(stageDir, up.set, up.rel);
|
|
2593
|
+
await mkdir5(dirname7(target), { recursive: true });
|
|
2331
2594
|
await copyFile(up.absSrc, target);
|
|
2332
2595
|
}
|
|
2333
|
-
tarballPath =
|
|
2596
|
+
tarballPath = join13(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
|
|
2334
2597
|
await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
2335
2598
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
2336
2599
|
});
|
|
@@ -2464,7 +2727,7 @@ var BOX_WORKSPACE2 = "/workspace";
|
|
|
2464
2727
|
var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
|
|
2465
2728
|
trust_level = "trusted"
|
|
2466
2729
|
`;
|
|
2467
|
-
function sanitizeCodexConfigForBox(tomlText, hostHome =
|
|
2730
|
+
function sanitizeCodexConfigForBox(tomlText, hostHome = homedir9()) {
|
|
2468
2731
|
const cfg = parse(tomlText);
|
|
2469
2732
|
let changed = false;
|
|
2470
2733
|
if (isRecord(cfg["mcp_servers"])) {
|
|
@@ -2532,7 +2795,7 @@ async function findBrokenSymlinks(root) {
|
|
|
2532
2795
|
return;
|
|
2533
2796
|
}
|
|
2534
2797
|
for (const ent of entries) {
|
|
2535
|
-
const full =
|
|
2798
|
+
const full = join14(dir, ent.name);
|
|
2536
2799
|
if (ent.isSymbolicLink()) {
|
|
2537
2800
|
try {
|
|
2538
2801
|
await stat8(full);
|
|
@@ -2548,14 +2811,14 @@ async function findBrokenSymlinks(root) {
|
|
|
2548
2811
|
return broken;
|
|
2549
2812
|
}
|
|
2550
2813
|
async function mkStageDir(prefix) {
|
|
2551
|
-
return mkdtemp4(
|
|
2814
|
+
return mkdtemp4(join14(tmpdir4(), `agentbox-${prefix}-stage-`));
|
|
2552
2815
|
}
|
|
2553
2816
|
function emptyResult(warnings = []) {
|
|
2554
2817
|
return { tarballPath: null, cleanup: async () => {
|
|
2555
2818
|
}, warnings };
|
|
2556
2819
|
}
|
|
2557
2820
|
async function tarballFromDir(stageDir, agent) {
|
|
2558
|
-
const tarballPath =
|
|
2821
|
+
const tarballPath = join14(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
|
|
2559
2822
|
await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
2560
2823
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
2561
2824
|
});
|
|
@@ -2572,7 +2835,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
2572
2835
|
const stageDir = await mkStageDir(agent);
|
|
2573
2836
|
let tarballPath = null;
|
|
2574
2837
|
try {
|
|
2575
|
-
await copyFile2(sourcePath,
|
|
2838
|
+
await copyFile2(sourcePath, join14(stageDir, tarballEntryName));
|
|
2576
2839
|
tarballPath = await tarballFromDir(stageDir, agent);
|
|
2577
2840
|
return {
|
|
2578
2841
|
tarballPath,
|
|
@@ -2588,11 +2851,11 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
2588
2851
|
var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
|
|
2589
2852
|
async function buildBoxClaudeJsonFromHost(opts) {
|
|
2590
2853
|
const { hostHome, hostWorkspace } = opts;
|
|
2591
|
-
const hostClaudeJson =
|
|
2854
|
+
const hostClaudeJson = join14(hostHome, ".claude.json");
|
|
2592
2855
|
let working;
|
|
2593
2856
|
if (await pathExists4(hostClaudeJson)) {
|
|
2594
2857
|
try {
|
|
2595
|
-
working = JSON.parse(await
|
|
2858
|
+
working = JSON.parse(await readFile8(hostClaudeJson, "utf8"));
|
|
2596
2859
|
} catch {
|
|
2597
2860
|
working = null;
|
|
2598
2861
|
}
|
|
@@ -2623,7 +2886,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
|
|
|
2623
2886
|
return working;
|
|
2624
2887
|
}
|
|
2625
2888
|
async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
2626
|
-
const hostHome = opts.hostHome ??
|
|
2889
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2627
2890
|
const stageDir = await mkStageDir("claude-json-only");
|
|
2628
2891
|
let tarballPath = null;
|
|
2629
2892
|
try {
|
|
@@ -2631,7 +2894,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
2631
2894
|
hostHome,
|
|
2632
2895
|
hostWorkspace: opts.hostWorkspace
|
|
2633
2896
|
});
|
|
2634
|
-
await writeFile5(
|
|
2897
|
+
await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
2635
2898
|
tarballPath = await tarballFromDir(stageDir, "claude-json-only");
|
|
2636
2899
|
return {
|
|
2637
2900
|
tarballPath,
|
|
@@ -2645,8 +2908,8 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
2645
2908
|
}
|
|
2646
2909
|
}
|
|
2647
2910
|
async function stageClaudeStaticForUpload(opts = {}) {
|
|
2648
|
-
const hostHome = opts.hostHome ??
|
|
2649
|
-
const hostClaude =
|
|
2911
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2912
|
+
const hostClaude = join14(hostHome, ".claude");
|
|
2650
2913
|
if (!await pathExists4(hostClaude)) return emptyResult();
|
|
2651
2914
|
const stageDir = await mkStageDir("claude-static");
|
|
2652
2915
|
let tarballPath = null;
|
|
@@ -2663,10 +2926,10 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
2663
2926
|
`${hostClaude}/`,
|
|
2664
2927
|
`${stageDir}/`
|
|
2665
2928
|
]);
|
|
2666
|
-
const settingsPath =
|
|
2929
|
+
const settingsPath = join14(stageDir, "settings.json");
|
|
2667
2930
|
if (await pathExists4(settingsPath)) {
|
|
2668
2931
|
try {
|
|
2669
|
-
const parsed = JSON.parse(await
|
|
2932
|
+
const parsed = JSON.parse(await readFile8(settingsPath, "utf8"));
|
|
2670
2933
|
const filtered = filterHostHooks(parsed, hostHome);
|
|
2671
2934
|
if (filtered.removedCommands.length > 0) {
|
|
2672
2935
|
await writeFile5(settingsPath, JSON.stringify(filtered.data, null, 2));
|
|
@@ -2678,15 +2941,15 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
2678
2941
|
hostHome,
|
|
2679
2942
|
hostWorkspace: opts.hostWorkspace
|
|
2680
2943
|
});
|
|
2681
|
-
await writeFile5(
|
|
2682
|
-
const pluginsDir =
|
|
2944
|
+
await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
2945
|
+
const pluginsDir = join14(stageDir, "plugins");
|
|
2683
2946
|
if (await pathExists4(pluginsDir)) {
|
|
2684
2947
|
try {
|
|
2685
2948
|
const entries = await readdir5(pluginsDir, { withFileTypes: true });
|
|
2686
2949
|
for (const ent of entries) {
|
|
2687
2950
|
if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
|
|
2688
|
-
const file =
|
|
2689
|
-
const raw = await
|
|
2951
|
+
const file = join14(pluginsDir, ent.name);
|
|
2952
|
+
const raw = await readFile8(file, "utf8");
|
|
2690
2953
|
const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
|
|
2691
2954
|
if (replaced !== raw) await writeFile5(file, replaced);
|
|
2692
2955
|
}
|
|
@@ -2714,14 +2977,14 @@ var CODEX_KEYCHAIN_WARNING = 'codex: ~/.codex/auth.json missing. On macOS the co
|
|
|
2714
2977
|
async function sanitizeStagedCodexConfig(configPath, hostHome) {
|
|
2715
2978
|
try {
|
|
2716
2979
|
if (!await pathExists4(configPath)) return;
|
|
2717
|
-
const { text, changed } = sanitizeCodexConfigForBox(await
|
|
2980
|
+
const { text, changed } = sanitizeCodexConfigForBox(await readFile8(configPath, "utf8"), hostHome);
|
|
2718
2981
|
if (changed) await writeFile5(configPath, text);
|
|
2719
2982
|
} catch {
|
|
2720
2983
|
}
|
|
2721
2984
|
}
|
|
2722
2985
|
async function stageCodexStaticForUpload(opts = {}) {
|
|
2723
|
-
const hostHome = opts.hostHome ??
|
|
2724
|
-
const hostCodex =
|
|
2986
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2987
|
+
const hostCodex = join14(hostHome, ".codex");
|
|
2725
2988
|
if (!await pathExists4(hostCodex)) return emptyResult();
|
|
2726
2989
|
const stageDir = await mkStageDir("codex-static");
|
|
2727
2990
|
let tarballPath = null;
|
|
@@ -2735,7 +2998,7 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
2735
2998
|
`${hostCodex}/`,
|
|
2736
2999
|
`${stageDir}/`
|
|
2737
3000
|
]);
|
|
2738
|
-
await sanitizeStagedCodexConfig(
|
|
3001
|
+
await sanitizeStagedCodexConfig(join14(stageDir, "config.toml"), hostHome);
|
|
2739
3002
|
tarballPath = await tarballFromDir(stageDir, "codex-static");
|
|
2740
3003
|
return {
|
|
2741
3004
|
tarballPath,
|
|
@@ -2749,8 +3012,8 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
2749
3012
|
}
|
|
2750
3013
|
}
|
|
2751
3014
|
async function stageAgentsStaticForUpload(opts = {}) {
|
|
2752
|
-
const hostHome = opts.hostHome ??
|
|
2753
|
-
const hostAgents =
|
|
3015
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
3016
|
+
const hostAgents = join14(hostHome, ".agents");
|
|
2754
3017
|
if (!await pathExists4(hostAgents)) return emptyResult();
|
|
2755
3018
|
const stageDir = await mkStageDir("agents-static");
|
|
2756
3019
|
let tarballPath = null;
|
|
@@ -2776,20 +3039,20 @@ async function stageAgentsStaticForUpload(opts = {}) {
|
|
|
2776
3039
|
}
|
|
2777
3040
|
}
|
|
2778
3041
|
async function stageCodexCredentialsForUpload(opts = {}) {
|
|
2779
|
-
const hostHome = opts.hostHome ??
|
|
2780
|
-
const cloudBackup =
|
|
3042
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
3043
|
+
const cloudBackup = join14(hostHome, ".agentbox", "codex-credentials.json");
|
|
2781
3044
|
if (await pathExists4(cloudBackup)) {
|
|
2782
3045
|
return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
|
|
2783
3046
|
}
|
|
2784
|
-
const hostAuth =
|
|
3047
|
+
const hostAuth = join14(hostHome, ".codex", "auth.json");
|
|
2785
3048
|
if (!await pathExists4(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
|
|
2786
3049
|
return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
|
|
2787
3050
|
}
|
|
2788
3051
|
var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
|
|
2789
3052
|
async function stageOpencodeStaticForUpload(opts = {}) {
|
|
2790
|
-
const hostHome = opts.hostHome ??
|
|
2791
|
-
const hostData =
|
|
2792
|
-
const hostConfig =
|
|
3053
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
3054
|
+
const hostData = join14(hostHome, ".local", "share", "opencode");
|
|
3055
|
+
const hostConfig = join14(hostHome, ".config", "opencode");
|
|
2793
3056
|
const hasData = await pathExists4(hostData);
|
|
2794
3057
|
const hasConfig = await pathExists4(hostConfig);
|
|
2795
3058
|
if (!hasData && !hasConfig) return emptyResult();
|
|
@@ -2808,7 +3071,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2808
3071
|
]);
|
|
2809
3072
|
}
|
|
2810
3073
|
if (hasConfig) {
|
|
2811
|
-
const configStage =
|
|
3074
|
+
const configStage = join14(stageDir, "config");
|
|
2812
3075
|
const cfgBroken = await findBrokenSymlinks(hostConfig);
|
|
2813
3076
|
await execa("rsync", [
|
|
2814
3077
|
"-a",
|
|
@@ -2831,18 +3094,18 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2831
3094
|
}
|
|
2832
3095
|
}
|
|
2833
3096
|
async function stageOpencodeCredentialsForUpload(opts = {}) {
|
|
2834
|
-
const hostHome = opts.hostHome ??
|
|
2835
|
-
const cloudBackup =
|
|
3097
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
3098
|
+
const cloudBackup = join14(hostHome, ".agentbox", "opencode-credentials.json");
|
|
2836
3099
|
if (await pathExists4(cloudBackup)) {
|
|
2837
3100
|
return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
|
|
2838
3101
|
}
|
|
2839
|
-
const hostAuth =
|
|
3102
|
+
const hostAuth = join14(hostHome, ".local", "share", "opencode", "auth.json");
|
|
2840
3103
|
if (!await pathExists4(hostAuth)) return emptyResult();
|
|
2841
3104
|
return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
|
|
2842
3105
|
}
|
|
2843
3106
|
async function stageOpencodeStateForUpload(opts = {}) {
|
|
2844
|
-
const hostHome = opts.hostHome ??
|
|
2845
|
-
const hostModel =
|
|
3107
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
3108
|
+
const hostModel = join14(hostHome, ".local", "state", "opencode", "model.json");
|
|
2846
3109
|
if (!await pathExists4(hostModel)) return emptyResult();
|
|
2847
3110
|
return stageSingleFileTarball("opencode-state", hostModel, "model.json");
|
|
2848
3111
|
}
|
|
@@ -2868,27 +3131,27 @@ function preparedStatePathFor(provider) {
|
|
|
2868
3131
|
if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
|
|
2869
3132
|
throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
|
|
2870
3133
|
}
|
|
2871
|
-
return pathResolve(
|
|
3134
|
+
return pathResolve(homedir11(), ".agentbox", `${provider}-prepared.json`);
|
|
2872
3135
|
}
|
|
2873
3136
|
function readPreparedStateRaw(provider) {
|
|
2874
3137
|
const path = preparedStatePathFor(provider);
|
|
2875
|
-
if (!
|
|
3138
|
+
if (!existsSync4(path)) return null;
|
|
2876
3139
|
try {
|
|
2877
|
-
return JSON.parse(
|
|
3140
|
+
return JSON.parse(readFileSync4(path, "utf8"));
|
|
2878
3141
|
} catch {
|
|
2879
3142
|
return null;
|
|
2880
3143
|
}
|
|
2881
3144
|
}
|
|
2882
3145
|
function writePreparedStateRaw(provider, state) {
|
|
2883
3146
|
const path = preparedStatePathFor(provider);
|
|
2884
|
-
|
|
3147
|
+
mkdirSync3(dirname8(path), { recursive: true });
|
|
2885
3148
|
const body = JSON.stringify(state, null, 2) + "\n";
|
|
2886
3149
|
const tmp = `${path}.tmp`;
|
|
2887
|
-
|
|
3150
|
+
writeFileSync3(tmp, body, { mode: 384 });
|
|
2888
3151
|
renameSync2(tmp, path);
|
|
2889
3152
|
}
|
|
2890
3153
|
async function sha256OfFile(path) {
|
|
2891
|
-
const buf = await
|
|
3154
|
+
const buf = await readFile9(path);
|
|
2892
3155
|
return createHash3("sha256").update(buf).digest("hex");
|
|
2893
3156
|
}
|
|
2894
3157
|
async function computeContextSha256(files) {
|
|
@@ -2957,23 +3220,23 @@ function resolveContextFilesFrom(fileMap, opts) {
|
|
|
2957
3220
|
pathResolve(opts.contextDir, paths.staged),
|
|
2958
3221
|
pathResolve(opts.devRoot, paths.dev)
|
|
2959
3222
|
];
|
|
2960
|
-
const hit = candidates.find((p) =>
|
|
3223
|
+
const hit = candidates.find((p) => existsSync4(p));
|
|
2961
3224
|
if (!hit) return null;
|
|
2962
3225
|
out.push({ rel, abs: hit });
|
|
2963
3226
|
}
|
|
2964
3227
|
return out;
|
|
2965
3228
|
}
|
|
2966
3229
|
|
|
2967
|
-
// ../../packages/sandbox-docker/dist/chunk-
|
|
2968
|
-
import { dirname as dirname23, resolve as
|
|
3230
|
+
// ../../packages/sandbox-docker/dist/chunk-BSXR4H44.js
|
|
3231
|
+
import { dirname as dirname23, resolve as resolve23 } from "path";
|
|
2969
3232
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2970
|
-
import { existsSync as
|
|
3233
|
+
import { existsSync as existsSync5 } from "fs";
|
|
2971
3234
|
import { fileURLToPath } from "url";
|
|
2972
|
-
import { dirname as
|
|
3235
|
+
import { dirname as dirname9, resolve as resolve4 } from "path";
|
|
2973
3236
|
var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
|
|
2974
3237
|
async function resolveClaudeInstallMode() {
|
|
2975
3238
|
try {
|
|
2976
|
-
const { loadEffectiveConfig } = await import("./dist-
|
|
3239
|
+
const { loadEffectiveConfig } = await import("./dist-STQK5XM6.js");
|
|
2977
3240
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
2978
3241
|
return cfg.effective.box.claudeInstall;
|
|
2979
3242
|
} catch {
|
|
@@ -2984,14 +3247,14 @@ var BOX_IMAGE_REGISTRY = "ghcr.io/madarco/agentbox/box";
|
|
|
2984
3247
|
function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
|
|
2985
3248
|
return `${registry}:sha-${sha.slice(0, 16)}`;
|
|
2986
3249
|
}
|
|
2987
|
-
var here =
|
|
3250
|
+
var here = dirname9(fileURLToPath(import.meta.url));
|
|
2988
3251
|
function resolveDockerBuild() {
|
|
2989
3252
|
const override = process.env.AGENTBOX_DOCKER_CONTEXT;
|
|
2990
|
-
if (override &&
|
|
3253
|
+
if (override && existsSync5(resolve4(override, "Dockerfile.box"))) {
|
|
2991
3254
|
return { dockerfile: resolve4(override, "Dockerfile.box"), context: override };
|
|
2992
3255
|
}
|
|
2993
3256
|
const staged = resolve4(here, "..", "runtime", "docker");
|
|
2994
|
-
if (
|
|
3257
|
+
if (existsSync5(resolve4(staged, "Dockerfile.box"))) {
|
|
2995
3258
|
return { dockerfile: resolve4(staged, "Dockerfile.box"), context: staged };
|
|
2996
3259
|
}
|
|
2997
3260
|
const packageRoot = resolve4(here, "..");
|
|
@@ -3075,7 +3338,7 @@ async function buildImage(opts = {}) {
|
|
|
3075
3338
|
return ref;
|
|
3076
3339
|
}
|
|
3077
3340
|
async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
3078
|
-
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-
|
|
3341
|
+
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-LW2PKTEQ-7BCXARGA.js");
|
|
3079
3342
|
const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
|
|
3080
3343
|
const allowPull = opts.allowPull !== false;
|
|
3081
3344
|
if (allowPull && registry && fingerprint) {
|
|
@@ -3102,7 +3365,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
|
3102
3365
|
return { source: "built" };
|
|
3103
3366
|
}
|
|
3104
3367
|
async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
|
|
3105
|
-
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-
|
|
3368
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-LW2PKTEQ-7BCXARGA.js");
|
|
3106
3369
|
const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
|
|
3107
3370
|
const rawFingerprint = await computeDockerContextFingerprint2({
|
|
3108
3371
|
contextDir: opts.contextDir
|
|
@@ -3139,11 +3402,36 @@ async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
|
|
|
3139
3402
|
});
|
|
3140
3403
|
return { ref, built: source === "built", reason };
|
|
3141
3404
|
}
|
|
3405
|
+
function classifyDockerBaseFreshness(input) {
|
|
3406
|
+
if (!input.imagePresent) return { state: "unprepared" };
|
|
3407
|
+
if (!input.fingerprint) return { state: "unknown" };
|
|
3408
|
+
if (!input.stampedSha) return { state: "stale", reason: "no docker-prepared.json on disk" };
|
|
3409
|
+
if (input.stampedSha !== input.fingerprint) {
|
|
3410
|
+
return {
|
|
3411
|
+
state: "stale",
|
|
3412
|
+
reason: `build context changed (was ${input.stampedSha.slice(0, 12)}, now ${input.fingerprint.slice(0, 12)})`
|
|
3413
|
+
};
|
|
3414
|
+
}
|
|
3415
|
+
return { state: "fresh" };
|
|
3416
|
+
}
|
|
3417
|
+
async function evaluateDockerBaseFreshness(opts = {}) {
|
|
3418
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-LW2PKTEQ-7BCXARGA.js");
|
|
3419
|
+
const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
|
|
3420
|
+
const imagePresent = await imageExists(ref);
|
|
3421
|
+
if (!imagePresent) return { state: "unprepared" };
|
|
3422
|
+
const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
|
|
3423
|
+
const raw = await computeDockerContextFingerprint2({ contextDir: opts.contextDir });
|
|
3424
|
+
return classifyDockerBaseFreshness({
|
|
3425
|
+
imagePresent,
|
|
3426
|
+
fingerprint: raw ? claudeInstallFingerprint(raw.contextSha256, claudeInstall) : null,
|
|
3427
|
+
stampedSha: readPreparedDockerState2()?.base?.contextSha256 ?? null
|
|
3428
|
+
});
|
|
3429
|
+
}
|
|
3142
3430
|
var SCHEMA = 1;
|
|
3143
3431
|
function resolveContextFiles(opts = {}) {
|
|
3144
3432
|
const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;
|
|
3145
3433
|
const here2 = dirname23(fileURLToPath2(import.meta.url));
|
|
3146
|
-
const packageRoot =
|
|
3434
|
+
const packageRoot = resolve23(here2, "..");
|
|
3147
3435
|
return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
|
|
3148
3436
|
contextDir: ctx,
|
|
3149
3437
|
devRoot: packageRoot
|
|
@@ -3208,6 +3496,7 @@ export {
|
|
|
3208
3496
|
readState,
|
|
3209
3497
|
recordBox,
|
|
3210
3498
|
recordLastAgent,
|
|
3499
|
+
setBoxDisplayName,
|
|
3211
3500
|
reserveProjectIndex,
|
|
3212
3501
|
removeBoxRecord,
|
|
3213
3502
|
findBox,
|
|
@@ -3218,6 +3507,9 @@ export {
|
|
|
3218
3507
|
pickFreshBranch,
|
|
3219
3508
|
GitWorktreeError,
|
|
3220
3509
|
hostOpenCommand,
|
|
3510
|
+
syncAgentboxSshConfig,
|
|
3511
|
+
autoWriteSshConfig,
|
|
3512
|
+
mintSshKey,
|
|
3221
3513
|
BOX_WORKSPACE,
|
|
3222
3514
|
boxGitCheckout,
|
|
3223
3515
|
boxGitNewBranch,
|
|
@@ -3288,12 +3580,15 @@ export {
|
|
|
3288
3580
|
BOX_IMAGE_REGISTRY,
|
|
3289
3581
|
registryRefForSha,
|
|
3290
3582
|
DOCKERFILE_PATH,
|
|
3583
|
+
BUILD_CONTEXT_DIR,
|
|
3291
3584
|
imageExists,
|
|
3292
3585
|
pullImage,
|
|
3293
3586
|
tagImage,
|
|
3294
3587
|
imageInfo,
|
|
3295
3588
|
pullOrBuild,
|
|
3296
3589
|
ensureImage,
|
|
3590
|
+
classifyDockerBaseFreshness,
|
|
3591
|
+
evaluateDockerBaseFreshness,
|
|
3297
3592
|
resolveContextFiles,
|
|
3298
3593
|
computeDockerContextFingerprint,
|
|
3299
3594
|
readPreparedDockerState,
|