@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
|
@@ -274,51 +274,60 @@ import { setTimeout as delay } from "timers/promises";
|
|
|
274
274
|
import { execa } from "execa";
|
|
275
275
|
import { readdir, stat as stat2 } from "fs/promises";
|
|
276
276
|
import { join as join2 } from "path";
|
|
277
|
-
import {
|
|
278
|
-
import { homedir as homedir2 } from "os";
|
|
279
|
-
import { dirname as dirname22, resolve } from "path";
|
|
280
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
281
|
-
import { mkdir as mkdir2, open as open2, readFile as readFile2, rename as rename2, rm as rm2, stat as stat3, writeFile as writeFile2 } from "fs/promises";
|
|
277
|
+
import { promises as fs } from "fs";
|
|
282
278
|
import { homedir as homedir3 } from "os";
|
|
283
|
-
import { dirname as dirname3, join as
|
|
279
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
280
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
281
|
+
import { homedir as homedir2 } from "os";
|
|
282
|
+
import { dirname as dirname22, join as join3 } from "path";
|
|
283
|
+
import { mkdir as mkdir2, readFile as readFile2 } from "fs/promises";
|
|
284
|
+
import { join as join5, resolve } from "path";
|
|
285
|
+
import { execa as execa2 } from "execa";
|
|
286
|
+
import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
287
|
+
import { homedir as homedir4 } from "os";
|
|
288
|
+
import { dirname as dirname4, resolve as resolve22 } from "path";
|
|
289
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
290
|
+
import { mkdir as mkdir3, open as open2, readFile as readFile3, rename as rename2, rm as rm2, stat as stat3, writeFile as writeFile2 } from "fs/promises";
|
|
291
|
+
import { homedir as homedir5 } from "os";
|
|
292
|
+
import { dirname as dirname5, join as join6 } from "path";
|
|
284
293
|
import { setTimeout as delay2 } from "timers/promises";
|
|
285
|
-
import { mkdtemp, readFile as
|
|
294
|
+
import { mkdtemp, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
286
295
|
import { tmpdir } from "os";
|
|
287
|
-
import { basename as basename2, join as
|
|
288
|
-
import { join as
|
|
289
|
-
import { homedir as
|
|
296
|
+
import { basename as basename2, join as join7 } from "path";
|
|
297
|
+
import { join as join8 } from "path";
|
|
298
|
+
import { homedir as homedir6 } from "os";
|
|
290
299
|
import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
|
|
291
300
|
import { tmpdir as tmpdir2 } from "os";
|
|
292
|
-
import { join as
|
|
293
|
-
import { execa as
|
|
301
|
+
import { join as join9 } from "path";
|
|
302
|
+
import { execa as execa3 } from "execa";
|
|
294
303
|
import { readdir as readdir2, stat as stat4 } from "fs/promises";
|
|
295
|
-
import { homedir as
|
|
296
|
-
import { join as
|
|
304
|
+
import { homedir as homedir7 } from "os";
|
|
305
|
+
import { join as join10 } from "path";
|
|
297
306
|
import { readdir as readdir3, realpath as realpath2, stat as stat5 } from "fs/promises";
|
|
298
|
-
import { isAbsolute, join as
|
|
307
|
+
import { isAbsolute, join as join11, relative } from "path";
|
|
299
308
|
import { stat as stat6 } from "fs/promises";
|
|
300
|
-
import { chmod, mkdir as
|
|
301
|
-
import { dirname as
|
|
309
|
+
import { chmod, mkdir as mkdir4, readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
|
|
310
|
+
import { dirname as dirname6 } from "path";
|
|
302
311
|
import { createHash } from "crypto";
|
|
303
|
-
import { readFile as
|
|
304
|
-
import { join as
|
|
305
|
-
import { execa as execa3 } from "execa";
|
|
306
|
-
import { createHash as createHash2 } from "crypto";
|
|
307
|
-
import { copyFile, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile6, rm as rm4, stat as stat7 } from "fs/promises";
|
|
308
|
-
import { homedir as homedir6, tmpdir as tmpdir3 } from "os";
|
|
309
|
-
import { basename as basename22, dirname as dirname5, join as join10 } from "path";
|
|
312
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
313
|
+
import { join as join12 } from "path";
|
|
310
314
|
import { execa as execa4 } from "execa";
|
|
311
|
-
import {
|
|
312
|
-
import {
|
|
313
|
-
import {
|
|
315
|
+
import { createHash as createHash2 } from "crypto";
|
|
316
|
+
import { copyFile, mkdir as mkdir5, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile7, rm as rm4, stat as stat7 } from "fs/promises";
|
|
317
|
+
import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
|
|
318
|
+
import { basename as basename22, dirname as dirname7, join as join13 } from "path";
|
|
314
319
|
import { execa as execa5 } from "execa";
|
|
315
|
-
import {
|
|
320
|
+
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";
|
|
321
|
+
import { homedir as homedir10, tmpdir as tmpdir4 } from "os";
|
|
322
|
+
import { basename as basename3, join as join14, relative as relative2 } from "path";
|
|
323
|
+
import { execa as execa6 } from "execa";
|
|
324
|
+
import { homedir as homedir9 } from "os";
|
|
316
325
|
import { parse, stringify } from "smol-toml";
|
|
317
326
|
import { createHash as createHash3 } from "crypto";
|
|
318
|
-
import { existsSync as
|
|
319
|
-
import { readFile as
|
|
320
|
-
import { homedir as
|
|
321
|
-
import { dirname as
|
|
327
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
328
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
329
|
+
import { homedir as homedir11 } from "os";
|
|
330
|
+
import { dirname as dirname8, resolve as pathResolve } from "path";
|
|
322
331
|
var STATE_DIR = join(homedir(), ".agentbox");
|
|
323
332
|
var STATE_FILE = join(STATE_DIR, "state.json");
|
|
324
333
|
var EMPTY = { version: 1, boxes: [] };
|
|
@@ -377,6 +386,8 @@ async function readState(path = STATE_FILE) {
|
|
|
377
386
|
if ((b.provider ?? "docker") === "docker" && !b.docker) {
|
|
378
387
|
b.docker = projectDockerFields(b);
|
|
379
388
|
}
|
|
389
|
+
const legacySsh = b.cloud?.ssh;
|
|
390
|
+
if (!b.ssh && legacySsh) b.ssh = legacySsh;
|
|
380
391
|
}
|
|
381
392
|
return parsed;
|
|
382
393
|
} catch (err) {
|
|
@@ -411,13 +422,28 @@ async function recordLastAgent(boxId, kind, path = STATE_FILE) {
|
|
|
411
422
|
path
|
|
412
423
|
);
|
|
413
424
|
}
|
|
425
|
+
async function setBoxDisplayName(boxId, displayName, path = STATE_FILE) {
|
|
426
|
+
const trimmed = displayName?.trim();
|
|
427
|
+
const next = trimmed ? trimmed : void 0;
|
|
428
|
+
await mutateState(
|
|
429
|
+
(state) => ({
|
|
430
|
+
version: 1,
|
|
431
|
+
boxes: state.boxes.map((b) => {
|
|
432
|
+
if (b.id !== boxId) return b;
|
|
433
|
+
if (next) return { ...b, displayName: next };
|
|
434
|
+
const rest = { ...b };
|
|
435
|
+
delete rest.displayName;
|
|
436
|
+
return rest;
|
|
437
|
+
})
|
|
438
|
+
}),
|
|
439
|
+
path
|
|
440
|
+
);
|
|
441
|
+
}
|
|
414
442
|
async function recordBoxSsh(boxId, ssh, path = STATE_FILE) {
|
|
415
443
|
await mutateState(
|
|
416
444
|
(state) => ({
|
|
417
445
|
version: 1,
|
|
418
|
-
boxes: state.boxes.map(
|
|
419
|
-
(b) => b.id === boxId && b.cloud ? { ...b, cloud: { ...b.cloud, ssh } } : b
|
|
420
|
-
)
|
|
446
|
+
boxes: state.boxes.map((b) => b.id === boxId ? { ...b, ssh } : b)
|
|
421
447
|
}),
|
|
422
448
|
path
|
|
423
449
|
);
|
|
@@ -475,6 +501,8 @@ function findBox(idOrName, state) {
|
|
|
475
501
|
if (prefixMatches.length > 1) return { kind: "ambiguous", matches: prefixMatches };
|
|
476
502
|
const byName = state.boxes.find((b) => b.name === q);
|
|
477
503
|
if (byName) return { kind: "ok", box: byName };
|
|
504
|
+
const byDisplayName = state.boxes.find((b) => b.displayName === q);
|
|
505
|
+
if (byDisplayName) return { kind: "ok", box: byDisplayName };
|
|
478
506
|
const byContainer = state.boxes.find((b) => b.container === q);
|
|
479
507
|
if (byContainer) return { kind: "ok", box: byContainer };
|
|
480
508
|
return { kind: "none" };
|
|
@@ -562,6 +590,283 @@ var GitWorktreeError = class extends Error {
|
|
|
562
590
|
function hostOpenCommand() {
|
|
563
591
|
return process.platform === "linux" ? "xdg-open" : "open";
|
|
564
592
|
}
|
|
593
|
+
function claudeSettingsPath() {
|
|
594
|
+
return join3(homedir2(), ".claude", "settings.json");
|
|
595
|
+
}
|
|
596
|
+
function claudeSshEntryFor(alias, boxName) {
|
|
597
|
+
return {
|
|
598
|
+
id: `agentbox-${alias}`,
|
|
599
|
+
name: `AgentBox: ${boxName}`,
|
|
600
|
+
sshHost: alias,
|
|
601
|
+
startDirectory: "/workspace"
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function readSettings(path) {
|
|
605
|
+
if (!existsSync(path)) return {};
|
|
606
|
+
let parsed;
|
|
607
|
+
try {
|
|
608
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
609
|
+
} catch (err) {
|
|
610
|
+
throw new Error(
|
|
611
|
+
`${path} exists but is not valid JSON (${err instanceof Error ? err.message : String(err)}) \u2014 not touching it. Fix the file and retry.`
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
615
|
+
throw new Error(`${path} is not a JSON object \u2014 not touching it. Fix the file and retry.`);
|
|
616
|
+
}
|
|
617
|
+
return parsed;
|
|
618
|
+
}
|
|
619
|
+
function writeSettings(path, settings) {
|
|
620
|
+
mkdirSync(dirname22(path), { recursive: true });
|
|
621
|
+
writeFileSync(path, JSON.stringify(settings, null, 2) + "\n");
|
|
622
|
+
}
|
|
623
|
+
function entryId(e) {
|
|
624
|
+
if (e !== null && typeof e === "object" && typeof e.id === "string") {
|
|
625
|
+
return e.id;
|
|
626
|
+
}
|
|
627
|
+
return void 0;
|
|
628
|
+
}
|
|
629
|
+
function upsertClaudeSshConfig(entry) {
|
|
630
|
+
const path = claudeSettingsPath();
|
|
631
|
+
const settings = readSettings(path);
|
|
632
|
+
const configs = Array.isArray(settings.sshConfigs) ? settings.sshConfigs : [];
|
|
633
|
+
const idx = configs.findIndex((e) => entryId(e) === entry.id);
|
|
634
|
+
if (idx >= 0) {
|
|
635
|
+
configs[idx] = entry;
|
|
636
|
+
} else {
|
|
637
|
+
configs.push(entry);
|
|
638
|
+
}
|
|
639
|
+
settings.sshConfigs = configs;
|
|
640
|
+
writeSettings(path, settings);
|
|
641
|
+
}
|
|
642
|
+
function pruneOrphanClaudeSshConfigs(liveAliases) {
|
|
643
|
+
return removeClaudeSshConfigs(
|
|
644
|
+
(id) => id.startsWith("agentbox-") && !liveAliases.has(id.slice("agentbox-".length))
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
function removeClaudeSshConfigs(predicate) {
|
|
648
|
+
const path = claudeSettingsPath();
|
|
649
|
+
if (!existsSync(path)) return 0;
|
|
650
|
+
const settings = readSettings(path);
|
|
651
|
+
if (!Array.isArray(settings.sshConfigs)) return 0;
|
|
652
|
+
const kept = settings.sshConfigs.filter((e) => {
|
|
653
|
+
const id = entryId(e);
|
|
654
|
+
return id === void 0 || !predicate(id);
|
|
655
|
+
});
|
|
656
|
+
const removed = settings.sshConfigs.length - kept.length;
|
|
657
|
+
if (removed === 0) return 0;
|
|
658
|
+
settings.sshConfigs = kept;
|
|
659
|
+
writeSettings(path, settings);
|
|
660
|
+
return removed;
|
|
661
|
+
}
|
|
662
|
+
function sshConfigPath() {
|
|
663
|
+
return join4(homedir3(), ".ssh", "config");
|
|
664
|
+
}
|
|
665
|
+
function agentboxSshConfigPath() {
|
|
666
|
+
return join4(homedir3(), ".agentbox", "ssh", "config");
|
|
667
|
+
}
|
|
668
|
+
function stateFilePath() {
|
|
669
|
+
return join4(homedir3(), ".agentbox", "state.json");
|
|
670
|
+
}
|
|
671
|
+
var INCLUDE_BEGIN = "# BEGIN agentbox ssh include";
|
|
672
|
+
var INCLUDE_END = "# END agentbox ssh include";
|
|
673
|
+
function beginMarker(alias) {
|
|
674
|
+
return `# BEGIN agentbox cloud box ${alias}`;
|
|
675
|
+
}
|
|
676
|
+
function endMarker(alias) {
|
|
677
|
+
return `# END agentbox cloud box ${alias}`;
|
|
678
|
+
}
|
|
679
|
+
function agentboxAliasFor(boxName) {
|
|
680
|
+
return boxName;
|
|
681
|
+
}
|
|
682
|
+
async function readFileOrEmpty(path) {
|
|
683
|
+
try {
|
|
684
|
+
return await fs.readFile(path, "utf8");
|
|
685
|
+
} catch (err) {
|
|
686
|
+
if (err.code === "ENOENT") return "";
|
|
687
|
+
throw err;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function buildBlock(opts) {
|
|
691
|
+
const lines = [
|
|
692
|
+
beginMarker(opts.alias),
|
|
693
|
+
`Host ${opts.alias}`,
|
|
694
|
+
` HostName ${opts.hostname}`,
|
|
695
|
+
` User ${opts.user}`
|
|
696
|
+
];
|
|
697
|
+
if (opts.port) {
|
|
698
|
+
lines.push(` Port ${String(opts.port)}`);
|
|
699
|
+
}
|
|
700
|
+
if (opts.identityFile) {
|
|
701
|
+
lines.push(` IdentityFile ${opts.identityFile}`);
|
|
702
|
+
lines.push(` IdentitiesOnly yes`);
|
|
703
|
+
}
|
|
704
|
+
lines.push(
|
|
705
|
+
` StrictHostKeyChecking accept-new`,
|
|
706
|
+
` UserKnownHostsFile /dev/null`,
|
|
707
|
+
` LogLevel ERROR`,
|
|
708
|
+
endMarker(opts.alias),
|
|
709
|
+
""
|
|
710
|
+
);
|
|
711
|
+
return lines.join("\n");
|
|
712
|
+
}
|
|
713
|
+
function stripLegacyInlineBlocks(contents) {
|
|
714
|
+
const pattern = /^# BEGIN agentbox cloud box .*\n[\s\S]*?^# END agentbox cloud box .*\n?/gm;
|
|
715
|
+
return contents.replace(pattern, "");
|
|
716
|
+
}
|
|
717
|
+
function hasIncludeBlock(contents) {
|
|
718
|
+
return contents.includes(INCLUDE_BEGIN) || contents.includes(`Include ${agentboxSshConfigPath()}`);
|
|
719
|
+
}
|
|
720
|
+
async function ensureSshInclude() {
|
|
721
|
+
const path = sshConfigPath();
|
|
722
|
+
await fs.mkdir(join4(homedir3(), ".ssh"), { recursive: true, mode: 448 });
|
|
723
|
+
const existing = stripLegacyInlineBlocks(await readFileOrEmpty(path));
|
|
724
|
+
let next = existing;
|
|
725
|
+
if (!hasIncludeBlock(existing)) {
|
|
726
|
+
const block = `${INCLUDE_BEGIN}
|
|
727
|
+
Include ${agentboxSshConfigPath()}
|
|
728
|
+
${INCLUDE_END}
|
|
729
|
+
`;
|
|
730
|
+
next = existing.length === 0 ? block : `${block}
|
|
731
|
+
${existing}`;
|
|
732
|
+
}
|
|
733
|
+
await fs.writeFile(path, next, { mode: 384 });
|
|
734
|
+
await fs.chmod(path, 384);
|
|
735
|
+
}
|
|
736
|
+
async function syncAgentboxSshConfig(statePath = stateFilePath()) {
|
|
737
|
+
const state = await readState(statePath);
|
|
738
|
+
const blocks = [];
|
|
739
|
+
for (const box of state.boxes) {
|
|
740
|
+
const ssh = box.ssh;
|
|
741
|
+
if (!ssh) continue;
|
|
742
|
+
blocks.push(
|
|
743
|
+
buildBlock({
|
|
744
|
+
alias: agentboxAliasFor(box.name),
|
|
745
|
+
hostname: ssh.host,
|
|
746
|
+
user: ssh.user,
|
|
747
|
+
identityFile: ssh.identityFile,
|
|
748
|
+
port: ssh.port
|
|
749
|
+
})
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
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";
|
|
753
|
+
const path = agentboxSshConfigPath();
|
|
754
|
+
await fs.mkdir(dirname3(path), { recursive: true, mode: 448 });
|
|
755
|
+
await fs.writeFile(path, header + blocks.join("\n"), { mode: 384 });
|
|
756
|
+
await fs.chmod(path, 384);
|
|
757
|
+
await ensureSshInclude();
|
|
758
|
+
try {
|
|
759
|
+
pruneOrphanClaudeSshConfigs(new Set(state.boxes.map((b) => agentboxAliasFor(b.name))));
|
|
760
|
+
} catch {
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
async function hasUnmanagedHostConflict(alias) {
|
|
764
|
+
const contents = stripLegacyInlineBlocks(await readFileOrEmpty(sshConfigPath()));
|
|
765
|
+
if (contents === "") return false;
|
|
766
|
+
return contents.split("\n").some((line) => {
|
|
767
|
+
const m = /^\s*Host\s+(.+?)\s*$/.exec(line);
|
|
768
|
+
if (!m) return false;
|
|
769
|
+
return m[1].split(/\s+/).includes(alias);
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
function parseSshTarget(argv) {
|
|
773
|
+
let target;
|
|
774
|
+
for (let i = argv.length - 1; i >= 0; i--) {
|
|
775
|
+
const v = argv[i];
|
|
776
|
+
if (!v || v.startsWith("-")) continue;
|
|
777
|
+
const at = v.indexOf("@");
|
|
778
|
+
if (at <= 0) continue;
|
|
779
|
+
target = { user: v.slice(0, at), host: v.slice(at + 1) };
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
if (!target) return void 0;
|
|
783
|
+
let identityFile;
|
|
784
|
+
for (let i = 0; i < argv.length - 1; i++) {
|
|
785
|
+
if (argv[i] === "-i") {
|
|
786
|
+
identityFile = argv[i + 1];
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return { ...target, identityFile };
|
|
791
|
+
}
|
|
792
|
+
async function readAgentboxSshAlias(alias) {
|
|
793
|
+
const contents = await readFileOrEmpty(agentboxSshConfigPath());
|
|
794
|
+
if (contents === "") return void 0;
|
|
795
|
+
const begin = beginMarker(alias);
|
|
796
|
+
const end = endMarker(alias);
|
|
797
|
+
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
798
|
+
const match = new RegExp(`^${escape(begin)}\\n([\\s\\S]*?)${escape(end)}`, "m").exec(contents);
|
|
799
|
+
if (!match) return void 0;
|
|
800
|
+
const body = match[1] ?? "";
|
|
801
|
+
const field = (name) => new RegExp(`^\\s*${name}\\s+(.+)$`, "m").exec(body)?.[1]?.trim();
|
|
802
|
+
return { hostName: field("HostName"), identityFile: field("IdentityFile") };
|
|
803
|
+
}
|
|
804
|
+
async function resolveCloudSshTarget(box, provider, opts = {}) {
|
|
805
|
+
if (!provider.buildAttach) {
|
|
806
|
+
throw new Error(`cloud provider '${provider.name}' does not support SSH attach`);
|
|
807
|
+
}
|
|
808
|
+
if (opts.bringOnline ?? true) {
|
|
809
|
+
const state = await provider.probeState(box);
|
|
810
|
+
if (state === "paused") {
|
|
811
|
+
opts.logInfo?.("box is paused; resuming");
|
|
812
|
+
await provider.resume(box);
|
|
813
|
+
} else if (state === "stopped") {
|
|
814
|
+
opts.logInfo?.("box is stopped; starting");
|
|
815
|
+
await provider.start(box);
|
|
816
|
+
} else if (state === "missing") {
|
|
817
|
+
throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
const spec = await provider.buildAttach(box, "shell", { noTmux: true });
|
|
821
|
+
const target = parseSshTarget(spec.argv);
|
|
822
|
+
if (!target) {
|
|
823
|
+
throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
|
|
824
|
+
}
|
|
825
|
+
const alias = agentboxAliasFor(box.name);
|
|
826
|
+
return { alias, host: target.host, user: target.user, identityFile: target.identityFile };
|
|
827
|
+
}
|
|
828
|
+
async function ensureCloudSshAlias(box, provider, opts = {}) {
|
|
829
|
+
const conn = await resolveCloudSshTarget(box, provider, opts);
|
|
830
|
+
await recordBoxSsh(box.id, {
|
|
831
|
+
host: conn.host,
|
|
832
|
+
user: conn.user,
|
|
833
|
+
identityFile: conn.identityFile
|
|
834
|
+
});
|
|
835
|
+
await syncAgentboxSshConfig();
|
|
836
|
+
return conn;
|
|
837
|
+
}
|
|
838
|
+
async function autoWriteSshConfig(box, provider, enabled, logWarn) {
|
|
839
|
+
if (!enabled) return;
|
|
840
|
+
try {
|
|
841
|
+
const conn = await resolveCloudSshTarget(box, provider, { bringOnline: false });
|
|
842
|
+
if (!conn.identityFile) return;
|
|
843
|
+
await recordBoxSsh(box.id, {
|
|
844
|
+
host: conn.host,
|
|
845
|
+
user: conn.user,
|
|
846
|
+
identityFile: conn.identityFile
|
|
847
|
+
});
|
|
848
|
+
await syncAgentboxSshConfig();
|
|
849
|
+
} catch (err) {
|
|
850
|
+
logWarn?.(
|
|
851
|
+
`ssh-config auto-write for ${box.name} failed: ${err instanceof Error ? err.message : String(err)}`
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
async function mintSshKey(targetDir, comment) {
|
|
856
|
+
const dir = resolve(targetDir);
|
|
857
|
+
const priv = join5(dir, "id_ed25519");
|
|
858
|
+
const pub = `${priv}.pub`;
|
|
859
|
+
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
860
|
+
const existing = await readFile2(pub, "utf8").catch(() => null);
|
|
861
|
+
if (existing !== null) {
|
|
862
|
+
return { dir, privatePath: priv, publicPath: pub, publicKey: existing.trim() };
|
|
863
|
+
}
|
|
864
|
+
await execa2("ssh-keygen", ["-t", "ed25519", "-N", "", "-C", comment, "-f", priv, "-q"], {
|
|
865
|
+
stdio: "pipe"
|
|
866
|
+
});
|
|
867
|
+
const publicKey = (await readFile2(pub, "utf8")).trim();
|
|
868
|
+
return { dir, privatePath: priv, publicPath: pub, publicKey };
|
|
869
|
+
}
|
|
565
870
|
var BOX_WORKSPACE = "/workspace";
|
|
566
871
|
function run(provider, box, argv) {
|
|
567
872
|
return provider.exec(box, argv, { cwd: BOX_WORKSPACE });
|
|
@@ -637,17 +942,17 @@ function errSummary(err) {
|
|
|
637
942
|
return err instanceof Error ? firstLine(err.message) : String(err);
|
|
638
943
|
}
|
|
639
944
|
function secretsEnvPath() {
|
|
640
|
-
return
|
|
945
|
+
return resolve22(homedir4(), ".agentbox", "secrets.env");
|
|
641
946
|
}
|
|
642
947
|
function writeManagedSecrets(managedKeys, record) {
|
|
643
948
|
for (const k of managedKeys) delete process.env[k];
|
|
644
949
|
for (const [k, v] of Object.entries(record)) process.env[k] = v;
|
|
645
950
|
const path = secretsEnvPath();
|
|
646
|
-
|
|
951
|
+
mkdirSync2(dirname4(path), { recursive: true });
|
|
647
952
|
let existing = "";
|
|
648
|
-
if (
|
|
953
|
+
if (existsSync2(path)) {
|
|
649
954
|
try {
|
|
650
|
-
existing =
|
|
955
|
+
existing = readFileSync2(path, "utf8");
|
|
651
956
|
} catch {
|
|
652
957
|
existing = "";
|
|
653
958
|
}
|
|
@@ -663,7 +968,7 @@ function writeManagedSecrets(managedKeys, record) {
|
|
|
663
968
|
const body = (kept ? `${kept}
|
|
664
969
|
` : "") + lines.join("\n") + "\n";
|
|
665
970
|
const tmp = `${path}.tmp`;
|
|
666
|
-
|
|
971
|
+
writeFileSync2(tmp, body, { mode: 384 });
|
|
667
972
|
try {
|
|
668
973
|
chmodSync(tmp, 384);
|
|
669
974
|
} catch {
|
|
@@ -674,8 +979,8 @@ function writeManagedSecrets(managedKeys, record) {
|
|
|
674
979
|
} catch {
|
|
675
980
|
}
|
|
676
981
|
}
|
|
677
|
-
var PLUGINS_FILE =
|
|
678
|
-
var SUPPORTED_SDK_API_VERSIONS = [1];
|
|
982
|
+
var PLUGINS_FILE = join6(homedir5(), ".agentbox", "plugins.json");
|
|
983
|
+
var SUPPORTED_SDK_API_VERSIONS = [1, 2];
|
|
679
984
|
function isSupportedApiVersion(v) {
|
|
680
985
|
return SUPPORTED_SDK_API_VERSIONS.includes(v);
|
|
681
986
|
}
|
|
@@ -685,7 +990,7 @@ var LOCK_ACQUIRE_TIMEOUT_MS2 = 2e4;
|
|
|
685
990
|
var LOCK_RETRY_MS2 = 25;
|
|
686
991
|
async function withFileLock(path, fn) {
|
|
687
992
|
const lockPath = `${path}.lock`;
|
|
688
|
-
await
|
|
993
|
+
await mkdir3(dirname5(path), { recursive: true });
|
|
689
994
|
const deadline = Date.now() + LOCK_ACQUIRE_TIMEOUT_MS2;
|
|
690
995
|
let held = false;
|
|
691
996
|
while (!held) {
|
|
@@ -726,8 +1031,8 @@ function normalize2(raw) {
|
|
|
726
1031
|
}
|
|
727
1032
|
function readPluginRegistrySync(path = PLUGINS_FILE) {
|
|
728
1033
|
try {
|
|
729
|
-
if (!
|
|
730
|
-
return normalize2(JSON.parse(
|
|
1034
|
+
if (!existsSync3(path)) return { ...EMPTY2 };
|
|
1035
|
+
return normalize2(JSON.parse(readFileSync3(path, "utf8")));
|
|
731
1036
|
} catch {
|
|
732
1037
|
return { ...EMPTY2 };
|
|
733
1038
|
}
|
|
@@ -735,7 +1040,7 @@ function readPluginRegistrySync(path = PLUGINS_FILE) {
|
|
|
735
1040
|
async function readForWrite(path) {
|
|
736
1041
|
let raw;
|
|
737
1042
|
try {
|
|
738
|
-
raw = await
|
|
1043
|
+
raw = await readFile3(path, "utf8");
|
|
739
1044
|
} catch (err) {
|
|
740
1045
|
if (err.code === "ENOENT") return { ...EMPTY2 };
|
|
741
1046
|
throw err;
|
|
@@ -757,7 +1062,7 @@ async function readForWrite(path) {
|
|
|
757
1062
|
return p;
|
|
758
1063
|
}
|
|
759
1064
|
async function writeRegistry(file, path = PLUGINS_FILE) {
|
|
760
|
-
await
|
|
1065
|
+
await mkdir3(dirname5(path), { recursive: true });
|
|
761
1066
|
const tmp = `${path}.tmp.${String(process.pid)}.${String(Date.now())}`;
|
|
762
1067
|
await writeFile2(tmp, JSON.stringify(file, null, 2) + "\n", "utf8");
|
|
763
1068
|
await rename2(tmp, path);
|
|
@@ -804,21 +1109,21 @@ function wantsRender(e) {
|
|
|
804
1109
|
async function renderCarryEntries(entries, ctx, onLog) {
|
|
805
1110
|
if (!entries.some(wantsRender)) return entries;
|
|
806
1111
|
const context = carryPlaceholderContext(ctx);
|
|
807
|
-
const stage = await mkdtemp(
|
|
1112
|
+
const stage = await mkdtemp(join7(tmpdir(), "agentbox-carry-render-"));
|
|
808
1113
|
const out = [];
|
|
809
1114
|
for (const [i, entry] of entries.entries()) {
|
|
810
1115
|
if (!wantsRender(entry)) {
|
|
811
1116
|
out.push(entry);
|
|
812
1117
|
continue;
|
|
813
1118
|
}
|
|
814
|
-
const content = await
|
|
1119
|
+
const content = await readFile4(entry.absSrc, "utf8");
|
|
815
1120
|
const rendered = applyReplacements(content, {
|
|
816
1121
|
env: entry.replaceEnvs,
|
|
817
1122
|
rules: entry.replace,
|
|
818
1123
|
context,
|
|
819
1124
|
onWarn: (msg) => onLog?.(`carry: ${entry.rawSrc}: ${msg}`)
|
|
820
1125
|
});
|
|
821
|
-
const tmp =
|
|
1126
|
+
const tmp = join7(stage, `${String(i)}-${basename2(entry.absSrc)}`);
|
|
822
1127
|
await writeFile3(tmp, rendered, "utf8");
|
|
823
1128
|
out.push({ ...entry, absSrc: tmp, bytes: Buffer.byteLength(rendered) });
|
|
824
1129
|
const what = [
|
|
@@ -874,7 +1179,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
874
1179
|
credential: {
|
|
875
1180
|
boxRelPath: ".credentials.json",
|
|
876
1181
|
boxAbsPath: `${CLAUDE_BOX_DIR}/.credentials.json`,
|
|
877
|
-
hostBackup:
|
|
1182
|
+
hostBackup: join8(STATE_DIR, "claude-credentials.json"),
|
|
878
1183
|
cloudMountPath: "/home/vscode/.agentbox-creds/claude",
|
|
879
1184
|
cloudSubpath: "claude/",
|
|
880
1185
|
realShape: "claude-oauth"
|
|
@@ -934,7 +1239,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
934
1239
|
credential: {
|
|
935
1240
|
boxRelPath: "auth.json",
|
|
936
1241
|
boxAbsPath: `${CODEX_BOX_DIR}/auth.json`,
|
|
937
|
-
hostBackup:
|
|
1242
|
+
hostBackup: join8(STATE_DIR, "codex-credentials.json"),
|
|
938
1243
|
cloudMountPath: "/home/vscode/.agentbox-creds/codex",
|
|
939
1244
|
cloudSubpath: "codex/",
|
|
940
1245
|
realShape: "nonempty-json"
|
|
@@ -985,7 +1290,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
985
1290
|
credential: {
|
|
986
1291
|
boxRelPath: "auth.json",
|
|
987
1292
|
boxAbsPath: `${OPENCODE_BOX_DIR}/auth.json`,
|
|
988
|
-
hostBackup:
|
|
1293
|
+
hostBackup: join8(STATE_DIR, "opencode-credentials.json"),
|
|
989
1294
|
cloudMountPath: "/home/vscode/.agentbox-creds/opencode",
|
|
990
1295
|
cloudSubpath: "opencode/",
|
|
991
1296
|
realShape: "nonempty-json"
|
|
@@ -1019,7 +1324,7 @@ function makeSyncContext(init) {
|
|
|
1019
1324
|
hostWorkspace: init.hostWorkspace,
|
|
1020
1325
|
projectRoot: init.projectRoot ?? init.hostWorkspace,
|
|
1021
1326
|
boxWorkspace: init.boxWorkspace ?? "/workspace",
|
|
1022
|
-
hostHome: init.hostHome ??
|
|
1327
|
+
hostHome: init.hostHome ?? homedir6(),
|
|
1023
1328
|
onLog: init.onLog ?? (() => {
|
|
1024
1329
|
})
|
|
1025
1330
|
};
|
|
@@ -1077,7 +1382,7 @@ function buildHostEnvFindArgs(patterns) {
|
|
|
1077
1382
|
}
|
|
1078
1383
|
async function findEnvFilesForTar(workspaceDir, patterns) {
|
|
1079
1384
|
if (patterns.length === 0) return [];
|
|
1080
|
-
const found = await
|
|
1385
|
+
const found = await execa3("find", buildHostEnvFindArgs(patterns).slice(1), {
|
|
1081
1386
|
cwd: workspaceDir,
|
|
1082
1387
|
reject: false
|
|
1083
1388
|
});
|
|
@@ -1091,10 +1396,10 @@ async function scanHostEnvFiles(workspaceDir, patterns) {
|
|
|
1091
1396
|
async function pushEnvFiles(ctx, transport, patterns) {
|
|
1092
1397
|
const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
|
|
1093
1398
|
if (list.length === 0) return { copied: 0 };
|
|
1094
|
-
const stage = await mkdtemp2(
|
|
1095
|
-
const localTar =
|
|
1399
|
+
const stage = await mkdtemp2(join9(tmpdir2(), "agentbox-envfiles-"));
|
|
1400
|
+
const localTar = join9(stage, "envfiles.tar");
|
|
1096
1401
|
try {
|
|
1097
|
-
const packed = await
|
|
1402
|
+
const packed = await execa3(
|
|
1098
1403
|
"tar",
|
|
1099
1404
|
["-C", ctx.hostWorkspace, "--null", "-T", "-", "-cf", localTar],
|
|
1100
1405
|
{ input: list.join("\0"), reject: false }
|
|
@@ -1164,9 +1469,9 @@ function encodeClaudeProjectsKey(absPath) {
|
|
|
1164
1469
|
return absPath.replace(/[^a-zA-Z0-9]/g, "-");
|
|
1165
1470
|
}
|
|
1166
1471
|
var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
|
|
1167
|
-
async function resolveClaudeMemoryDir(hostWorkspace, hostHome =
|
|
1472
|
+
async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir7()) {
|
|
1168
1473
|
if (hostWorkspace.length === 0) return null;
|
|
1169
|
-
const memDir =
|
|
1474
|
+
const memDir = join10(
|
|
1170
1475
|
hostHome,
|
|
1171
1476
|
".claude",
|
|
1172
1477
|
"projects",
|
|
@@ -1209,8 +1514,8 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
|
|
|
1209
1514
|
return;
|
|
1210
1515
|
}
|
|
1211
1516
|
for (const ent of entries) {
|
|
1212
|
-
const realFull =
|
|
1213
|
-
const virtualFull = virtualDir ?
|
|
1517
|
+
const realFull = join11(realDir, ent.name);
|
|
1518
|
+
const virtualFull = virtualDir ? join11(virtualDir, ent.name) : ent.name;
|
|
1214
1519
|
if (ent.isSymbolicLink()) {
|
|
1215
1520
|
let real;
|
|
1216
1521
|
try {
|
|
@@ -1288,7 +1593,7 @@ function isRealAgentCredential(agent, text) {
|
|
|
1288
1593
|
}
|
|
1289
1594
|
async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now()) {
|
|
1290
1595
|
try {
|
|
1291
|
-
const parsed = JSON.parse(await
|
|
1596
|
+
const parsed = JSON.parse(await readFile5(path, "utf8"));
|
|
1292
1597
|
const exp = parsed?.claudeAiOauth?.expiresAt;
|
|
1293
1598
|
return typeof exp === "number" && Number.isFinite(exp) && exp < now;
|
|
1294
1599
|
} catch {
|
|
@@ -1297,7 +1602,7 @@ async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now
|
|
|
1297
1602
|
}
|
|
1298
1603
|
async function hostBackupHasCredentials(path = CLAUDE_HOST_BACKUP) {
|
|
1299
1604
|
try {
|
|
1300
|
-
const parsed = JSON.parse(await
|
|
1605
|
+
const parsed = JSON.parse(await readFile5(path, "utf8"));
|
|
1301
1606
|
const rt = parsed?.claudeAiOauth?.refreshToken;
|
|
1302
1607
|
return typeof rt === "string" && rt.length > 0;
|
|
1303
1608
|
} catch {
|
|
@@ -1313,7 +1618,7 @@ async function extractCredentials(transport, opts = {}) {
|
|
|
1313
1618
|
try {
|
|
1314
1619
|
const text = await transport.readText(spec.credential.boxAbsPath);
|
|
1315
1620
|
if (!text || !isRealAgentCredential(spec.id, text)) continue;
|
|
1316
|
-
await
|
|
1621
|
+
await mkdir4(dirname6(hostBackup), { recursive: true });
|
|
1317
1622
|
await writeFile4(hostBackup, text, { mode: 384 });
|
|
1318
1623
|
await chmod(hostBackup, 384).catch(() => {
|
|
1319
1624
|
});
|
|
@@ -1454,20 +1759,20 @@ async function resyncWorkspace(worktrees, ports, onLog) {
|
|
|
1454
1759
|
function makeHostGitPorts() {
|
|
1455
1760
|
return {
|
|
1456
1761
|
async resolveHostRef(hostMain) {
|
|
1457
|
-
const hostBranchProbe = await
|
|
1762
|
+
const hostBranchProbe = await execa4(
|
|
1458
1763
|
"git",
|
|
1459
1764
|
["-C", hostMain, "symbolic-ref", "--short", "-q", "HEAD"],
|
|
1460
1765
|
{ reject: false }
|
|
1461
1766
|
);
|
|
1462
|
-
const hostRef = hostBranchProbe.exitCode === 0 && hostBranchProbe.stdout.trim() ? hostBranchProbe.stdout.trim() : (await
|
|
1767
|
+
const hostRef = hostBranchProbe.exitCode === 0 && hostBranchProbe.stdout.trim() ? hostBranchProbe.stdout.trim() : (await execa4("git", ["-C", hostMain, "rev-parse", "HEAD"], { reject: false })).stdout.trim();
|
|
1463
1768
|
return hostRef || null;
|
|
1464
1769
|
},
|
|
1465
1770
|
async createHostStash(hostMain) {
|
|
1466
|
-
const stash = await
|
|
1771
|
+
const stash = await execa4("git", ["-C", hostMain, "stash", "create"], { reject: false });
|
|
1467
1772
|
return stash.exitCode === 0 ? stash.stdout.trim() || null : null;
|
|
1468
1773
|
},
|
|
1469
1774
|
async listHostUntracked(hostMain) {
|
|
1470
|
-
const untracked = await
|
|
1775
|
+
const untracked = await execa4(
|
|
1471
1776
|
"git",
|
|
1472
1777
|
["-C", hostMain, "ls-files", "--others", "--exclude-standard", "-z"],
|
|
1473
1778
|
{ reject: false }
|
|
@@ -1475,10 +1780,10 @@ function makeHostGitPorts() {
|
|
|
1475
1780
|
return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
|
|
1476
1781
|
},
|
|
1477
1782
|
async hashHostFile(hostMain, relPath) {
|
|
1478
|
-
return createHash("sha256").update(await
|
|
1783
|
+
return createHash("sha256").update(await readFile6(join12(hostMain, relPath))).digest("hex");
|
|
1479
1784
|
},
|
|
1480
1785
|
async packHostFiles(hostMain, relPaths) {
|
|
1481
|
-
const tarOut = await
|
|
1786
|
+
const tarOut = await execa4("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
|
|
1482
1787
|
input: relPaths.join("\0"),
|
|
1483
1788
|
encoding: "buffer",
|
|
1484
1789
|
reject: false
|
|
@@ -1508,7 +1813,7 @@ async function walkFiles(root, prefix = "") {
|
|
|
1508
1813
|
const out = [];
|
|
1509
1814
|
for (const ent of entries) {
|
|
1510
1815
|
const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
|
|
1511
|
-
const full =
|
|
1816
|
+
const full = join13(root, ent.name);
|
|
1512
1817
|
if (ent.isDirectory()) {
|
|
1513
1818
|
out.push(...await walkFiles(full, rel));
|
|
1514
1819
|
} else if (ent.isFile()) {
|
|
@@ -1524,7 +1829,7 @@ async function walkFiles(root, prefix = "") {
|
|
|
1524
1829
|
return out;
|
|
1525
1830
|
}
|
|
1526
1831
|
async function hashFile(absPath) {
|
|
1527
|
-
const buf = await
|
|
1832
|
+
const buf = await readFile7(absPath);
|
|
1528
1833
|
return createHash2("sha256").update(buf).digest("hex");
|
|
1529
1834
|
}
|
|
1530
1835
|
async function buildHostSet(name, hostDir, boxDst) {
|
|
@@ -1532,12 +1837,12 @@ async function buildHostSet(name, hostDir, boxDst) {
|
|
|
1532
1837
|
const rels = await walkFiles(hostDir);
|
|
1533
1838
|
const files = {};
|
|
1534
1839
|
for (const rel of rels) {
|
|
1535
|
-
files[rel] = await hashFile(
|
|
1840
|
+
files[rel] = await hashFile(join13(hostDir, rel));
|
|
1536
1841
|
}
|
|
1537
1842
|
return { dst: boxDst, files, hostDir };
|
|
1538
1843
|
}
|
|
1539
|
-
async function buildHostSyncManifest(workspacePath, hostHome =
|
|
1540
|
-
const workflowsDir =
|
|
1844
|
+
async function buildHostSyncManifest(workspacePath, hostHome = homedir8()) {
|
|
1845
|
+
const workflowsDir = join13(hostHome, ".claude", "workflows");
|
|
1541
1846
|
const workflowsHost = await pathExists3(workflowsDir) ? workflowsDir : null;
|
|
1542
1847
|
const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
|
|
1543
1848
|
const [workflows, memory] = await Promise.all([
|
|
@@ -1559,7 +1864,7 @@ function computeSyncDelta(host, box) {
|
|
|
1559
1864
|
uploads.push({
|
|
1560
1865
|
set: name,
|
|
1561
1866
|
rel,
|
|
1562
|
-
absSrc:
|
|
1867
|
+
absSrc: join13(hostSet.hostDir, rel),
|
|
1563
1868
|
dst: `${hostSet.dst}/${rel}`
|
|
1564
1869
|
});
|
|
1565
1870
|
}
|
|
@@ -1578,16 +1883,16 @@ async function stageDynamicSyncTarball(uploads) {
|
|
|
1578
1883
|
return { tarballPath: null, cleanup: async () => {
|
|
1579
1884
|
} };
|
|
1580
1885
|
}
|
|
1581
|
-
const stageDir = await mkdtemp3(
|
|
1886
|
+
const stageDir = await mkdtemp3(join13(tmpdir3(), "agentbox-dynsync-stage-"));
|
|
1582
1887
|
let tarballPath = null;
|
|
1583
1888
|
try {
|
|
1584
1889
|
for (const up of uploads) {
|
|
1585
|
-
const target =
|
|
1586
|
-
await
|
|
1890
|
+
const target = join13(stageDir, up.set, up.rel);
|
|
1891
|
+
await mkdir5(dirname7(target), { recursive: true });
|
|
1587
1892
|
await copyFile(up.absSrc, target);
|
|
1588
1893
|
}
|
|
1589
|
-
tarballPath =
|
|
1590
|
-
await
|
|
1894
|
+
tarballPath = join13(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
|
|
1895
|
+
await execa5("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
1591
1896
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
1592
1897
|
});
|
|
1593
1898
|
const tp = tarballPath;
|
|
@@ -1720,7 +2025,7 @@ var BOX_WORKSPACE2 = "/workspace";
|
|
|
1720
2025
|
var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
|
|
1721
2026
|
trust_level = "trusted"
|
|
1722
2027
|
`;
|
|
1723
|
-
function sanitizeCodexConfigForBox(tomlText, hostHome =
|
|
2028
|
+
function sanitizeCodexConfigForBox(tomlText, hostHome = homedir9()) {
|
|
1724
2029
|
const cfg = parse(tomlText);
|
|
1725
2030
|
let changed = false;
|
|
1726
2031
|
if (isRecord(cfg["mcp_servers"])) {
|
|
@@ -1788,7 +2093,7 @@ async function findBrokenSymlinks(root) {
|
|
|
1788
2093
|
return;
|
|
1789
2094
|
}
|
|
1790
2095
|
for (const ent of entries) {
|
|
1791
|
-
const full =
|
|
2096
|
+
const full = join14(dir, ent.name);
|
|
1792
2097
|
if (ent.isSymbolicLink()) {
|
|
1793
2098
|
try {
|
|
1794
2099
|
await stat8(full);
|
|
@@ -1804,15 +2109,15 @@ async function findBrokenSymlinks(root) {
|
|
|
1804
2109
|
return broken;
|
|
1805
2110
|
}
|
|
1806
2111
|
async function mkStageDir(prefix) {
|
|
1807
|
-
return mkdtemp4(
|
|
2112
|
+
return mkdtemp4(join14(tmpdir4(), `agentbox-${prefix}-stage-`));
|
|
1808
2113
|
}
|
|
1809
2114
|
function emptyResult(warnings = []) {
|
|
1810
2115
|
return { tarballPath: null, cleanup: async () => {
|
|
1811
2116
|
}, warnings };
|
|
1812
2117
|
}
|
|
1813
2118
|
async function tarballFromDir(stageDir, agent) {
|
|
1814
|
-
const tarballPath =
|
|
1815
|
-
await
|
|
2119
|
+
const tarballPath = join14(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
|
|
2120
|
+
await execa6("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
|
|
1816
2121
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
1817
2122
|
});
|
|
1818
2123
|
return tarballPath;
|
|
@@ -1828,7 +2133,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
1828
2133
|
const stageDir = await mkStageDir(agent);
|
|
1829
2134
|
let tarballPath = null;
|
|
1830
2135
|
try {
|
|
1831
|
-
await copyFile2(sourcePath,
|
|
2136
|
+
await copyFile2(sourcePath, join14(stageDir, tarballEntryName));
|
|
1832
2137
|
tarballPath = await tarballFromDir(stageDir, agent);
|
|
1833
2138
|
return {
|
|
1834
2139
|
tarballPath,
|
|
@@ -1844,11 +2149,11 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
|
|
|
1844
2149
|
var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
|
|
1845
2150
|
async function buildBoxClaudeJsonFromHost(opts) {
|
|
1846
2151
|
const { hostHome, hostWorkspace } = opts;
|
|
1847
|
-
const hostClaudeJson =
|
|
2152
|
+
const hostClaudeJson = join14(hostHome, ".claude.json");
|
|
1848
2153
|
let working;
|
|
1849
2154
|
if (await pathExists4(hostClaudeJson)) {
|
|
1850
2155
|
try {
|
|
1851
|
-
working = JSON.parse(await
|
|
2156
|
+
working = JSON.parse(await readFile8(hostClaudeJson, "utf8"));
|
|
1852
2157
|
} catch {
|
|
1853
2158
|
working = null;
|
|
1854
2159
|
}
|
|
@@ -1879,7 +2184,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
|
|
|
1879
2184
|
return working;
|
|
1880
2185
|
}
|
|
1881
2186
|
async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
1882
|
-
const hostHome = opts.hostHome ??
|
|
2187
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
1883
2188
|
const stageDir = await mkStageDir("claude-json-only");
|
|
1884
2189
|
let tarballPath = null;
|
|
1885
2190
|
try {
|
|
@@ -1887,7 +2192,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
1887
2192
|
hostHome,
|
|
1888
2193
|
hostWorkspace: opts.hostWorkspace
|
|
1889
2194
|
});
|
|
1890
|
-
await writeFile5(
|
|
2195
|
+
await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
1891
2196
|
tarballPath = await tarballFromDir(stageDir, "claude-json-only");
|
|
1892
2197
|
return {
|
|
1893
2198
|
tarballPath,
|
|
@@ -1901,8 +2206,8 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
|
|
|
1901
2206
|
}
|
|
1902
2207
|
}
|
|
1903
2208
|
async function stageClaudeStaticForUpload(opts = {}) {
|
|
1904
|
-
const hostHome = opts.hostHome ??
|
|
1905
|
-
const hostClaude =
|
|
2209
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2210
|
+
const hostClaude = join14(hostHome, ".claude");
|
|
1906
2211
|
if (!await pathExists4(hostClaude)) return emptyResult();
|
|
1907
2212
|
const stageDir = await mkStageDir("claude-static");
|
|
1908
2213
|
let tarballPath = null;
|
|
@@ -1912,17 +2217,17 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
1912
2217
|
...CLAUDE_STATIC_EXCLUDES.map((p) => `--exclude=${p}`),
|
|
1913
2218
|
...broken.map((r) => `--exclude=/${r}`)
|
|
1914
2219
|
];
|
|
1915
|
-
await
|
|
2220
|
+
await execa6("rsync", [
|
|
1916
2221
|
"-a",
|
|
1917
2222
|
"--copy-unsafe-links",
|
|
1918
2223
|
...excludes,
|
|
1919
2224
|
`${hostClaude}/`,
|
|
1920
2225
|
`${stageDir}/`
|
|
1921
2226
|
]);
|
|
1922
|
-
const settingsPath =
|
|
2227
|
+
const settingsPath = join14(stageDir, "settings.json");
|
|
1923
2228
|
if (await pathExists4(settingsPath)) {
|
|
1924
2229
|
try {
|
|
1925
|
-
const parsed = JSON.parse(await
|
|
2230
|
+
const parsed = JSON.parse(await readFile8(settingsPath, "utf8"));
|
|
1926
2231
|
const filtered = filterHostHooks(parsed, hostHome);
|
|
1927
2232
|
if (filtered.removedCommands.length > 0) {
|
|
1928
2233
|
await writeFile5(settingsPath, JSON.stringify(filtered.data, null, 2));
|
|
@@ -1934,15 +2239,15 @@ async function stageClaudeStaticForUpload(opts = {}) {
|
|
|
1934
2239
|
hostHome,
|
|
1935
2240
|
hostWorkspace: opts.hostWorkspace
|
|
1936
2241
|
});
|
|
1937
|
-
await writeFile5(
|
|
1938
|
-
const pluginsDir =
|
|
2242
|
+
await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
|
|
2243
|
+
const pluginsDir = join14(stageDir, "plugins");
|
|
1939
2244
|
if (await pathExists4(pluginsDir)) {
|
|
1940
2245
|
try {
|
|
1941
2246
|
const entries = await readdir5(pluginsDir, { withFileTypes: true });
|
|
1942
2247
|
for (const ent of entries) {
|
|
1943
2248
|
if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
|
|
1944
|
-
const file =
|
|
1945
|
-
const raw = await
|
|
2249
|
+
const file = join14(pluginsDir, ent.name);
|
|
2250
|
+
const raw = await readFile8(file, "utf8");
|
|
1946
2251
|
const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
|
|
1947
2252
|
if (replaced !== raw) await writeFile5(file, replaced);
|
|
1948
2253
|
}
|
|
@@ -1970,20 +2275,20 @@ var CODEX_KEYCHAIN_WARNING = 'codex: ~/.codex/auth.json missing. On macOS the co
|
|
|
1970
2275
|
async function sanitizeStagedCodexConfig(configPath, hostHome) {
|
|
1971
2276
|
try {
|
|
1972
2277
|
if (!await pathExists4(configPath)) return;
|
|
1973
|
-
const { text, changed } = sanitizeCodexConfigForBox(await
|
|
2278
|
+
const { text, changed } = sanitizeCodexConfigForBox(await readFile8(configPath, "utf8"), hostHome);
|
|
1974
2279
|
if (changed) await writeFile5(configPath, text);
|
|
1975
2280
|
} catch {
|
|
1976
2281
|
}
|
|
1977
2282
|
}
|
|
1978
2283
|
async function stageCodexStaticForUpload(opts = {}) {
|
|
1979
|
-
const hostHome = opts.hostHome ??
|
|
1980
|
-
const hostCodex =
|
|
2284
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2285
|
+
const hostCodex = join14(hostHome, ".codex");
|
|
1981
2286
|
if (!await pathExists4(hostCodex)) return emptyResult();
|
|
1982
2287
|
const stageDir = await mkStageDir("codex-static");
|
|
1983
2288
|
let tarballPath = null;
|
|
1984
2289
|
try {
|
|
1985
2290
|
const codexBroken = await findBrokenSymlinks(hostCodex);
|
|
1986
|
-
await
|
|
2291
|
+
await execa6("rsync", [
|
|
1987
2292
|
"-a",
|
|
1988
2293
|
"-L",
|
|
1989
2294
|
...codexBroken.map((r) => `--exclude=/${r}`),
|
|
@@ -1991,7 +2296,7 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
1991
2296
|
`${hostCodex}/`,
|
|
1992
2297
|
`${stageDir}/`
|
|
1993
2298
|
]);
|
|
1994
|
-
await sanitizeStagedCodexConfig(
|
|
2299
|
+
await sanitizeStagedCodexConfig(join14(stageDir, "config.toml"), hostHome);
|
|
1995
2300
|
tarballPath = await tarballFromDir(stageDir, "codex-static");
|
|
1996
2301
|
return {
|
|
1997
2302
|
tarballPath,
|
|
@@ -2005,14 +2310,14 @@ async function stageCodexStaticForUpload(opts = {}) {
|
|
|
2005
2310
|
}
|
|
2006
2311
|
}
|
|
2007
2312
|
async function stageAgentsStaticForUpload(opts = {}) {
|
|
2008
|
-
const hostHome = opts.hostHome ??
|
|
2009
|
-
const hostAgents =
|
|
2313
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2314
|
+
const hostAgents = join14(hostHome, ".agents");
|
|
2010
2315
|
if (!await pathExists4(hostAgents)) return emptyResult();
|
|
2011
2316
|
const stageDir = await mkStageDir("agents-static");
|
|
2012
2317
|
let tarballPath = null;
|
|
2013
2318
|
try {
|
|
2014
2319
|
const broken = await findBrokenSymlinks(hostAgents);
|
|
2015
|
-
await
|
|
2320
|
+
await execa6("rsync", [
|
|
2016
2321
|
"-a",
|
|
2017
2322
|
"-L",
|
|
2018
2323
|
...broken.map((r) => `--exclude=/${r}`),
|
|
@@ -2032,20 +2337,20 @@ async function stageAgentsStaticForUpload(opts = {}) {
|
|
|
2032
2337
|
}
|
|
2033
2338
|
}
|
|
2034
2339
|
async function stageCodexCredentialsForUpload(opts = {}) {
|
|
2035
|
-
const hostHome = opts.hostHome ??
|
|
2036
|
-
const cloudBackup =
|
|
2340
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2341
|
+
const cloudBackup = join14(hostHome, ".agentbox", "codex-credentials.json");
|
|
2037
2342
|
if (await pathExists4(cloudBackup)) {
|
|
2038
2343
|
return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
|
|
2039
2344
|
}
|
|
2040
|
-
const hostAuth =
|
|
2345
|
+
const hostAuth = join14(hostHome, ".codex", "auth.json");
|
|
2041
2346
|
if (!await pathExists4(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
|
|
2042
2347
|
return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
|
|
2043
2348
|
}
|
|
2044
2349
|
var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
|
|
2045
2350
|
async function stageOpencodeStaticForUpload(opts = {}) {
|
|
2046
|
-
const hostHome = opts.hostHome ??
|
|
2047
|
-
const hostData =
|
|
2048
|
-
const hostConfig =
|
|
2351
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2352
|
+
const hostData = join14(hostHome, ".local", "share", "opencode");
|
|
2353
|
+
const hostConfig = join14(hostHome, ".config", "opencode");
|
|
2049
2354
|
const hasData = await pathExists4(hostData);
|
|
2050
2355
|
const hasConfig = await pathExists4(hostConfig);
|
|
2051
2356
|
if (!hasData && !hasConfig) return emptyResult();
|
|
@@ -2054,7 +2359,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2054
2359
|
try {
|
|
2055
2360
|
if (hasData) {
|
|
2056
2361
|
const dataBroken = await findBrokenSymlinks(hostData);
|
|
2057
|
-
await
|
|
2362
|
+
await execa6("rsync", [
|
|
2058
2363
|
"-a",
|
|
2059
2364
|
"-L",
|
|
2060
2365
|
...dataBroken.map((r) => `--exclude=/${r}`),
|
|
@@ -2064,9 +2369,9 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2064
2369
|
]);
|
|
2065
2370
|
}
|
|
2066
2371
|
if (hasConfig) {
|
|
2067
|
-
const configStage =
|
|
2372
|
+
const configStage = join14(stageDir, "config");
|
|
2068
2373
|
const cfgBroken = await findBrokenSymlinks(hostConfig);
|
|
2069
|
-
await
|
|
2374
|
+
await execa6("rsync", [
|
|
2070
2375
|
"-a",
|
|
2071
2376
|
"-L",
|
|
2072
2377
|
...cfgBroken.map((r) => `--exclude=/${r}`),
|
|
@@ -2087,18 +2392,18 @@ async function stageOpencodeStaticForUpload(opts = {}) {
|
|
|
2087
2392
|
}
|
|
2088
2393
|
}
|
|
2089
2394
|
async function stageOpencodeCredentialsForUpload(opts = {}) {
|
|
2090
|
-
const hostHome = opts.hostHome ??
|
|
2091
|
-
const cloudBackup =
|
|
2395
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2396
|
+
const cloudBackup = join14(hostHome, ".agentbox", "opencode-credentials.json");
|
|
2092
2397
|
if (await pathExists4(cloudBackup)) {
|
|
2093
2398
|
return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
|
|
2094
2399
|
}
|
|
2095
|
-
const hostAuth =
|
|
2400
|
+
const hostAuth = join14(hostHome, ".local", "share", "opencode", "auth.json");
|
|
2096
2401
|
if (!await pathExists4(hostAuth)) return emptyResult();
|
|
2097
2402
|
return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
|
|
2098
2403
|
}
|
|
2099
2404
|
async function stageOpencodeStateForUpload(opts = {}) {
|
|
2100
|
-
const hostHome = opts.hostHome ??
|
|
2101
|
-
const hostModel =
|
|
2405
|
+
const hostHome = opts.hostHome ?? homedir10();
|
|
2406
|
+
const hostModel = join14(hostHome, ".local", "state", "opencode", "model.json");
|
|
2102
2407
|
if (!await pathExists4(hostModel)) return emptyResult();
|
|
2103
2408
|
return stageSingleFileTarball("opencode-state", hostModel, "model.json");
|
|
2104
2409
|
}
|
|
@@ -2124,27 +2429,27 @@ function preparedStatePathFor(provider) {
|
|
|
2124
2429
|
if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
|
|
2125
2430
|
throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
|
|
2126
2431
|
}
|
|
2127
|
-
return pathResolve(
|
|
2432
|
+
return pathResolve(homedir11(), ".agentbox", `${provider}-prepared.json`);
|
|
2128
2433
|
}
|
|
2129
2434
|
function readPreparedStateRaw(provider) {
|
|
2130
2435
|
const path = preparedStatePathFor(provider);
|
|
2131
|
-
if (!
|
|
2436
|
+
if (!existsSync4(path)) return null;
|
|
2132
2437
|
try {
|
|
2133
|
-
return JSON.parse(
|
|
2438
|
+
return JSON.parse(readFileSync4(path, "utf8"));
|
|
2134
2439
|
} catch {
|
|
2135
2440
|
return null;
|
|
2136
2441
|
}
|
|
2137
2442
|
}
|
|
2138
2443
|
function writePreparedStateRaw(provider, state) {
|
|
2139
2444
|
const path = preparedStatePathFor(provider);
|
|
2140
|
-
|
|
2445
|
+
mkdirSync3(dirname8(path), { recursive: true });
|
|
2141
2446
|
const body = JSON.stringify(state, null, 2) + "\n";
|
|
2142
2447
|
const tmp = `${path}.tmp`;
|
|
2143
|
-
|
|
2448
|
+
writeFileSync3(tmp, body, { mode: 384 });
|
|
2144
2449
|
renameSync2(tmp, path);
|
|
2145
2450
|
}
|
|
2146
2451
|
async function sha256OfFile(path) {
|
|
2147
|
-
const buf = await
|
|
2452
|
+
const buf = await readFile9(path);
|
|
2148
2453
|
return createHash3("sha256").update(buf).digest("hex");
|
|
2149
2454
|
}
|
|
2150
2455
|
async function computeContextSha256(files) {
|
|
@@ -2213,24 +2518,24 @@ function resolveContextFilesFrom(fileMap, opts) {
|
|
|
2213
2518
|
pathResolve(opts.contextDir, paths.staged),
|
|
2214
2519
|
pathResolve(opts.devRoot, paths.dev)
|
|
2215
2520
|
];
|
|
2216
|
-
const hit = candidates.find((p) =>
|
|
2521
|
+
const hit = candidates.find((p) => existsSync4(p));
|
|
2217
2522
|
if (!hit) return null;
|
|
2218
2523
|
out.push({ rel, abs: hit });
|
|
2219
2524
|
}
|
|
2220
2525
|
return out;
|
|
2221
2526
|
}
|
|
2222
2527
|
|
|
2223
|
-
// ../../packages/sandbox-docker/dist/chunk-
|
|
2224
|
-
import { dirname as dirname23, resolve as
|
|
2528
|
+
// ../../packages/sandbox-docker/dist/chunk-BSXR4H44.js
|
|
2529
|
+
import { dirname as dirname23, resolve as resolve23 } from "path";
|
|
2225
2530
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2226
|
-
import { execa as
|
|
2227
|
-
import { existsSync as
|
|
2531
|
+
import { execa as execa7 } from "execa";
|
|
2532
|
+
import { existsSync as existsSync5 } from "fs";
|
|
2228
2533
|
import { fileURLToPath } from "url";
|
|
2229
|
-
import { dirname as
|
|
2534
|
+
import { dirname as dirname9, resolve as resolve3 } from "path";
|
|
2230
2535
|
var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
|
|
2231
2536
|
async function resolveClaudeInstallMode() {
|
|
2232
2537
|
try {
|
|
2233
|
-
const { loadEffectiveConfig } = await import("./dist-
|
|
2538
|
+
const { loadEffectiveConfig } = await import("./dist-2BTJQUJS.js");
|
|
2234
2539
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
2235
2540
|
return cfg.effective.box.claudeInstall;
|
|
2236
2541
|
} catch {
|
|
@@ -2241,14 +2546,14 @@ var BOX_IMAGE_REGISTRY = "ghcr.io/madarco/agentbox/box";
|
|
|
2241
2546
|
function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
|
|
2242
2547
|
return `${registry}:sha-${sha.slice(0, 16)}`;
|
|
2243
2548
|
}
|
|
2244
|
-
var here =
|
|
2549
|
+
var here = dirname9(fileURLToPath(import.meta.url));
|
|
2245
2550
|
function resolveDockerBuild() {
|
|
2246
2551
|
const override = process.env.AGENTBOX_DOCKER_CONTEXT;
|
|
2247
|
-
if (override &&
|
|
2552
|
+
if (override && existsSync5(resolve3(override, "Dockerfile.box"))) {
|
|
2248
2553
|
return { dockerfile: resolve3(override, "Dockerfile.box"), context: override };
|
|
2249
2554
|
}
|
|
2250
2555
|
const staged = resolve3(here, "..", "runtime", "docker");
|
|
2251
|
-
if (
|
|
2556
|
+
if (existsSync5(resolve3(staged, "Dockerfile.box"))) {
|
|
2252
2557
|
return { dockerfile: resolve3(staged, "Dockerfile.box"), context: staged };
|
|
2253
2558
|
}
|
|
2254
2559
|
const packageRoot = resolve3(here, "..");
|
|
@@ -2261,11 +2566,11 @@ var { dockerfile: DOCKERFILE_PATH_RESOLVED, context: BUILD_CONTEXT_DIR_RESOLVED
|
|
|
2261
2566
|
var DOCKERFILE_PATH = DOCKERFILE_PATH_RESOLVED;
|
|
2262
2567
|
var BUILD_CONTEXT_DIR = BUILD_CONTEXT_DIR_RESOLVED;
|
|
2263
2568
|
async function imageExists(ref) {
|
|
2264
|
-
const result = await
|
|
2569
|
+
const result = await execa7("docker", ["image", "inspect", ref], { reject: false });
|
|
2265
2570
|
return result.exitCode === 0;
|
|
2266
2571
|
}
|
|
2267
2572
|
async function pullImage(target, opts = {}) {
|
|
2268
|
-
const subprocess =
|
|
2573
|
+
const subprocess = execa7("docker", ["pull", target], {
|
|
2269
2574
|
stderr: "pipe",
|
|
2270
2575
|
stdout: "pipe",
|
|
2271
2576
|
reject: false
|
|
@@ -2284,10 +2589,10 @@ async function pullImage(target, opts = {}) {
|
|
|
2284
2589
|
return result.exitCode === 0;
|
|
2285
2590
|
}
|
|
2286
2591
|
async function tagImage(source, target) {
|
|
2287
|
-
await
|
|
2592
|
+
await execa7("docker", ["tag", source, target]);
|
|
2288
2593
|
}
|
|
2289
2594
|
async function imageInfo(ref = DEFAULT_BOX_IMAGE) {
|
|
2290
|
-
const result = await
|
|
2595
|
+
const result = await execa7(
|
|
2291
2596
|
"docker",
|
|
2292
2597
|
["image", "inspect", "--format", "{{.Size}}|{{.Created}}", ref],
|
|
2293
2598
|
{ reject: false }
|
|
@@ -2314,7 +2619,7 @@ async function buildImage(opts = {}) {
|
|
|
2314
2619
|
if (process.env.AGENTBOX === "1") {
|
|
2315
2620
|
args.splice(1, 0, "--network=host");
|
|
2316
2621
|
}
|
|
2317
|
-
const subprocess =
|
|
2622
|
+
const subprocess = execa7("docker", args, {
|
|
2318
2623
|
stderr: "pipe",
|
|
2319
2624
|
stdout: "pipe"
|
|
2320
2625
|
});
|
|
@@ -2332,7 +2637,7 @@ async function buildImage(opts = {}) {
|
|
|
2332
2637
|
return ref;
|
|
2333
2638
|
}
|
|
2334
2639
|
async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
2335
|
-
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-
|
|
2640
|
+
const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-LW2PKTEQ-5YMKG7UN.js");
|
|
2336
2641
|
const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
|
|
2337
2642
|
const allowPull = opts.allowPull !== false;
|
|
2338
2643
|
if (allowPull && registry && fingerprint) {
|
|
@@ -2359,7 +2664,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
|
|
|
2359
2664
|
return { source: "built" };
|
|
2360
2665
|
}
|
|
2361
2666
|
async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
|
|
2362
|
-
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-
|
|
2667
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-LW2PKTEQ-5YMKG7UN.js");
|
|
2363
2668
|
const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
|
|
2364
2669
|
const rawFingerprint = await computeDockerContextFingerprint2({
|
|
2365
2670
|
contextDir: opts.contextDir
|
|
@@ -2396,11 +2701,36 @@ async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
|
|
|
2396
2701
|
});
|
|
2397
2702
|
return { ref, built: source === "built", reason };
|
|
2398
2703
|
}
|
|
2704
|
+
function classifyDockerBaseFreshness(input) {
|
|
2705
|
+
if (!input.imagePresent) return { state: "unprepared" };
|
|
2706
|
+
if (!input.fingerprint) return { state: "unknown" };
|
|
2707
|
+
if (!input.stampedSha) return { state: "stale", reason: "no docker-prepared.json on disk" };
|
|
2708
|
+
if (input.stampedSha !== input.fingerprint) {
|
|
2709
|
+
return {
|
|
2710
|
+
state: "stale",
|
|
2711
|
+
reason: `build context changed (was ${input.stampedSha.slice(0, 12)}, now ${input.fingerprint.slice(0, 12)})`
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
return { state: "fresh" };
|
|
2715
|
+
}
|
|
2716
|
+
async function evaluateDockerBaseFreshness(opts = {}) {
|
|
2717
|
+
const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-LW2PKTEQ-5YMKG7UN.js");
|
|
2718
|
+
const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
|
|
2719
|
+
const imagePresent = await imageExists(ref);
|
|
2720
|
+
if (!imagePresent) return { state: "unprepared" };
|
|
2721
|
+
const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
|
|
2722
|
+
const raw = await computeDockerContextFingerprint2({ contextDir: opts.contextDir });
|
|
2723
|
+
return classifyDockerBaseFreshness({
|
|
2724
|
+
imagePresent,
|
|
2725
|
+
fingerprint: raw ? claudeInstallFingerprint(raw.contextSha256, claudeInstall) : null,
|
|
2726
|
+
stampedSha: readPreparedDockerState2()?.base?.contextSha256 ?? null
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2399
2729
|
var SCHEMA = 1;
|
|
2400
2730
|
function resolveContextFiles(opts = {}) {
|
|
2401
2731
|
const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;
|
|
2402
2732
|
const here2 = dirname23(fileURLToPath2(import.meta.url));
|
|
2403
|
-
const packageRoot =
|
|
2733
|
+
const packageRoot = resolve23(here2, "..");
|
|
2404
2734
|
return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
|
|
2405
2735
|
contextDir: ctx,
|
|
2406
2736
|
devRoot: packageRoot
|
|
@@ -2460,6 +2790,7 @@ export {
|
|
|
2460
2790
|
readState,
|
|
2461
2791
|
recordBox,
|
|
2462
2792
|
recordLastAgent,
|
|
2793
|
+
setBoxDisplayName,
|
|
2463
2794
|
recordBoxSsh,
|
|
2464
2795
|
reserveProjectIndex,
|
|
2465
2796
|
removeBoxRecord,
|
|
@@ -2471,6 +2802,18 @@ export {
|
|
|
2471
2802
|
pickFreshBranch,
|
|
2472
2803
|
GitWorktreeError,
|
|
2473
2804
|
hostOpenCommand,
|
|
2805
|
+
claudeSettingsPath,
|
|
2806
|
+
claudeSshEntryFor,
|
|
2807
|
+
upsertClaudeSshConfig,
|
|
2808
|
+
agentboxSshConfigPath,
|
|
2809
|
+
agentboxAliasFor,
|
|
2810
|
+
syncAgentboxSshConfig,
|
|
2811
|
+
hasUnmanagedHostConflict,
|
|
2812
|
+
readAgentboxSshAlias,
|
|
2813
|
+
resolveCloudSshTarget,
|
|
2814
|
+
ensureCloudSshAlias,
|
|
2815
|
+
autoWriteSshConfig,
|
|
2816
|
+
mintSshKey,
|
|
2474
2817
|
scratchBranchName,
|
|
2475
2818
|
boxGitCheckout,
|
|
2476
2819
|
boxGitNewBranch,
|
|
@@ -2546,16 +2889,19 @@ export {
|
|
|
2546
2889
|
BOX_IMAGE_REGISTRY,
|
|
2547
2890
|
registryRefForSha,
|
|
2548
2891
|
DOCKERFILE_PATH,
|
|
2892
|
+
BUILD_CONTEXT_DIR,
|
|
2549
2893
|
imageExists,
|
|
2550
2894
|
pullImage,
|
|
2551
2895
|
tagImage,
|
|
2552
2896
|
imageInfo,
|
|
2553
2897
|
pullOrBuild,
|
|
2554
2898
|
ensureImage,
|
|
2899
|
+
classifyDockerBaseFreshness,
|
|
2900
|
+
evaluateDockerBaseFreshness,
|
|
2555
2901
|
resolveContextFiles,
|
|
2556
2902
|
computeDockerContextFingerprint,
|
|
2557
2903
|
readPreparedDockerState,
|
|
2558
2904
|
writePreparedDockerState,
|
|
2559
2905
|
preparedMatches
|
|
2560
2906
|
};
|
|
2561
|
-
//# sourceMappingURL=chunk-
|
|
2907
|
+
//# sourceMappingURL=chunk-CKC3CP7Y.js.map
|