@madarco/agentbox 0.23.5 → 0.24.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 +61 -0
- package/LICENSE +21 -0
- package/README.md +3 -2
- package/dist/{_cloud-attach-D4OQO5AJ.js → _cloud-attach-T6GPR6LJ.js} +5 -5
- package/dist/{chunk-KY32JO6J.js → chunk-5KHEH47T.js} +91 -79
- package/dist/chunk-5KHEH47T.js.map +1 -0
- package/dist/{chunk-YRTM3KNT.js → chunk-6U2S6QWD.js} +219 -18
- package/dist/chunk-6U2S6QWD.js.map +1 -0
- package/dist/{chunk-JYEZ6Q5M.js → chunk-DEDTPG2D.js} +874 -146
- package/dist/chunk-DEDTPG2D.js.map +1 -0
- package/dist/chunk-G3H2L3O2.js +0 -0
- package/dist/{chunk-JNY5GPIM.js → chunk-I654PBHA.js} +290 -330
- package/dist/chunk-I654PBHA.js.map +1 -0
- package/dist/{chunk-6KOQRSHH.js → chunk-K2EDQGZP.js} +18 -4
- package/dist/chunk-K2EDQGZP.js.map +1 -0
- package/dist/{chunk-KZWJMNLP.js → chunk-LC4E2EIZ.js} +3 -3
- package/dist/{chunk-KZWJMNLP.js.map → chunk-LC4E2EIZ.js.map} +1 -1
- package/dist/{chunk-DADOEMXP.js → chunk-NACA6AM7.js} +183 -49
- package/dist/chunk-NACA6AM7.js.map +1 -0
- package/dist/{chunk-FX32NZD4.js → chunk-RYQLFKCP.js} +20 -10
- package/dist/chunk-RYQLFKCP.js.map +1 -0
- package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
- package/dist/chunk-UIRBYL4G.js.map +1 -0
- package/dist/chunk-WJFZJZIM.js +0 -0
- package/dist/chunk-WLHJZPFJ.js +845 -0
- package/dist/chunk-WLHJZPFJ.js.map +1 -0
- package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
- package/dist/dist-3KIJ2KQ2.js +1437 -0
- package/dist/dist-3KIJ2KQ2.js.map +1 -0
- package/dist/{dist-564EDHFF.js → dist-7OUOHQPA.js} +196 -151
- package/dist/dist-7OUOHQPA.js.map +1 -0
- package/dist/{dist-CAT2TN75.js → dist-B7TNWGVG.js} +8 -4
- package/dist/{dist-UDQMBWYW.js → dist-KYV3LEHG.js} +10 -6
- package/dist/{dist-EAR4BLL2.js → dist-PHYCFYKH.js} +37 -17
- package/dist/dist-PHYCFYKH.js.map +1 -0
- package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
- package/dist/{dist-O5Y4X4C5.js → dist-Z7KEPQC7.js} +6 -6
- package/dist/index.js +2560 -1108
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
- package/package.json +28 -28
- package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
- package/runtime/_shared/agentbox-codex-hooks.json +1 -1
- 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 +468 -97
- package/runtime/_shared/gh-shim +0 -0
- package/runtime/_shared/git-shim +53 -3
- package/runtime/_shared/linear-shim +0 -0
- package/runtime/_shared/ntn-shim +0 -0
- package/runtime/daytona/custom-system-CLAUDE.md +1 -1
- package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
- package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
- package/runtime/digitalocean/agentbox-dockerd-start +145 -0
- package/runtime/digitalocean/agentbox-open +28 -0
- package/runtime/digitalocean/agentbox-portless-trust +82 -0
- package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
- package/runtime/digitalocean/agentbox-vnc-start +102 -0
- package/runtime/digitalocean/claude-managed-settings.json +116 -0
- package/runtime/digitalocean/ctl.cjs +27852 -0
- package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
- package/runtime/digitalocean/gh-shim +344 -0
- package/runtime/digitalocean/git-shim +181 -0
- package/runtime/digitalocean/linear-shim +181 -0
- package/runtime/digitalocean/ntn-shim +95 -0
- package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
- package/runtime/digitalocean/scripts/install-box.sh +462 -0
- package/runtime/docker/Dockerfile.box +5 -0
- package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
- 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 +0 -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/custom-system-CLAUDE.md +2 -1
- package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
- 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-codex-hooks.json +1 -1
- 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 +468 -97
- package/runtime/e2b/custom-system-CLAUDE.md +6 -3
- package/runtime/e2b/gh-shim +0 -0
- package/runtime/e2b/git-shim +53 -3
- package/runtime/e2b/linear-shim +0 -0
- package/runtime/e2b/ntn-shim +0 -0
- package/runtime/e2b/scripts/build-template.sh +16 -0
- package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
- package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
- 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 +468 -97
- package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
- package/runtime/hetzner/gh-shim +0 -0
- package/runtime/hetzner/git-shim +53 -3
- package/runtime/hetzner/linear-shim +0 -0
- package/runtime/hetzner/ntn-shim +0 -0
- package/runtime/hetzner/scripts/install-box.sh +5 -0
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/server/app/(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/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
- 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]__1bqbkd5._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.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/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
- package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-FSEPYTQ6.js → chunk-3VE7AYVK.js} +594 -145
- package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
- package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-7M6FXZIO.js → chunk-FGBXEXUV.js} +350 -292
- package/runtime/hub/apps/hub/{chunk-Z7ZAL24C.js → chunk-YVELHPNY.js} +218 -17
- package/runtime/hub/apps/hub/{dist-EKQHCXWE.js → dist-33ZNVTC6.js} +183 -49
- package/runtime/hub/apps/hub/{dist-V4TJ44MT.js → dist-4SXAJBOC.js} +195 -150
- package/runtime/hub/apps/hub/{dist-QIXUPGPP.js → dist-EPJFN2J3.js} +116 -86
- package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
- package/runtime/hub/apps/hub/{dist-JGZ55OIJ.js → dist-UJVIROA4.js} +19 -5
- package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
- package/runtime/hub/apps/hub/{dist-GGWYKXJE.js → dist-YM5J25H6.js} +7 -3
- package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
- package/runtime/hub/apps/hub/package.json +1 -0
- package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-UICXTY25.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
- package/runtime/hub/apps/hub/server.js +17 -15
- package/runtime/relay/bin.cjs +275 -59
- package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
- package/runtime/vercel/agentbox-codex-hooks.json +1 -1
- 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 +468 -97
- package/runtime/vercel/custom-system-CLAUDE.md +3 -2
- package/runtime/vercel/gh-shim +0 -0
- package/runtime/vercel/git-shim +53 -3
- package/runtime/vercel/linear-shim +0 -0
- package/runtime/vercel/ntn-shim +0 -0
- package/runtime/vercel/scripts/provision.sh +16 -0
- package/dist/chunk-6KOQRSHH.js.map +0 -1
- package/dist/chunk-DADOEMXP.js.map +0 -1
- package/dist/chunk-FX32NZD4.js.map +0 -1
- package/dist/chunk-JNY5GPIM.js.map +0 -1
- package/dist/chunk-JYEZ6Q5M.js.map +0 -1
- package/dist/chunk-KY32JO6J.js.map +0 -1
- package/dist/chunk-QT3SHMLY.js.map +0 -1
- package/dist/chunk-YRTM3KNT.js.map +0 -1
- package/dist/dist-564EDHFF.js.map +0 -1
- package/dist/dist-EAR4BLL2.js.map +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
- /package/dist/{_cloud-attach-D4OQO5AJ.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
- /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
- /package/dist/{dist-CAT2TN75.js.map → dist-KYV3LEHG.js.map} +0 -0
- /package/dist/{dist-O5Y4X4C5.js.map → dist-T5MXBZGP.js.map} +0 -0
- /package/dist/{dist-UDQMBWYW.js.map → dist-Z7KEPQC7.js.map} +0 -0
- /package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_ssgManifest.js +0 -0
|
@@ -4,16 +4,21 @@ import {
|
|
|
4
4
|
BOX_HOME,
|
|
5
5
|
BUILD_CONTEXT_DIR,
|
|
6
6
|
BoxNotFoundError,
|
|
7
|
+
CODEX_PULL_ITEMS,
|
|
7
8
|
DEFAULT_BOX_IMAGE,
|
|
8
9
|
DEFAULT_ENV_PATTERNS,
|
|
9
10
|
ENV_PRUNE_DIRS,
|
|
10
11
|
GitWorktreeError,
|
|
11
12
|
MINIMAL_TRUSTED_CODEX_CONFIG,
|
|
13
|
+
OPENCODE_PULL_CONFIG_ITEMS,
|
|
14
|
+
OPENCODE_PULL_DATA_ITEMS,
|
|
12
15
|
STATE_DIR,
|
|
13
16
|
STATE_FILE,
|
|
14
17
|
SYNC_DRYRUN_ENV,
|
|
15
18
|
addProjectAlias,
|
|
16
19
|
claudeInstallFingerprint,
|
|
20
|
+
claudeInventoryScript,
|
|
21
|
+
computeClaudePullPlan,
|
|
17
22
|
computeDockerContextFingerprint,
|
|
18
23
|
detectGitRepos,
|
|
19
24
|
dryRunProviderSync,
|
|
@@ -36,7 +41,10 @@ import {
|
|
|
36
41
|
looksLikeSecret,
|
|
37
42
|
makeHostGitPorts,
|
|
38
43
|
makeSyncContext,
|
|
44
|
+
mergeCodexConfigForBox,
|
|
39
45
|
mintSshKey,
|
|
46
|
+
parseClaudeInventory,
|
|
47
|
+
parseCredentialsUpdate,
|
|
40
48
|
parseDownloadKind,
|
|
41
49
|
parseReplacements,
|
|
42
50
|
pickFreshBranch,
|
|
@@ -46,10 +54,12 @@ import {
|
|
|
46
54
|
pullOrBuild,
|
|
47
55
|
pushEnvFiles,
|
|
48
56
|
readCliStamp,
|
|
57
|
+
readCredentialBackup,
|
|
49
58
|
readPreparedDockerState,
|
|
50
59
|
readState,
|
|
51
60
|
realpathSafe,
|
|
52
61
|
recordBox,
|
|
62
|
+
referencedPluginVersionKeys,
|
|
53
63
|
remoteTrackingRef,
|
|
54
64
|
removeBoxRecord,
|
|
55
65
|
renderCarryEntries,
|
|
@@ -62,10 +72,13 @@ import {
|
|
|
62
72
|
sanitizeGitArgs,
|
|
63
73
|
seedAgentsVolume,
|
|
64
74
|
setInstallMethodNative,
|
|
75
|
+
shouldAcceptCredentialUpdate,
|
|
65
76
|
syncAgentboxSshConfig,
|
|
66
77
|
trustWorkspace,
|
|
67
|
-
upstreamRef
|
|
68
|
-
|
|
78
|
+
upstreamRef,
|
|
79
|
+
writeClaudeMergedRegistries,
|
|
80
|
+
writeCredentialBackup
|
|
81
|
+
} from "./chunk-3VE7AYVK.js";
|
|
69
82
|
import {
|
|
70
83
|
execa
|
|
71
84
|
} from "./chunk-EFW34I43.js";
|
|
@@ -79,14 +92,14 @@ import {
|
|
|
79
92
|
require_dist,
|
|
80
93
|
sanitizeMnemonic,
|
|
81
94
|
setConfigValue
|
|
82
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-64WEKO34.js";
|
|
83
96
|
import {
|
|
84
97
|
__toESM
|
|
85
98
|
} from "./chunk-TZFWAJVB.js";
|
|
86
99
|
|
|
87
100
|
// ../../packages/sandbox-docker/dist/index.js
|
|
88
101
|
import { spawnSync } from "child_process";
|
|
89
|
-
import {
|
|
102
|
+
import { mkdtemp as mkdtemp2, readdir as readdir2, readFile as readFile23, rm as rm22, stat as stat2, writeFile as writeFile3 } from "fs/promises";
|
|
90
103
|
import { homedir as homedir2, tmpdir as tmpdir2 } from "os";
|
|
91
104
|
import { join as join3 } from "path";
|
|
92
105
|
import { setTimeout as delay } from "timers/promises";
|
|
@@ -100,7 +113,7 @@ import { createReadStream } from "fs";
|
|
|
100
113
|
import { mkdtemp as mkdtemp3, rm as rm3 } from "fs/promises";
|
|
101
114
|
import { tmpdir as tmpdir3 } from "os";
|
|
102
115
|
import { join as join4 } from "path";
|
|
103
|
-
import { chmod, mkdir as
|
|
116
|
+
import { chmod, mkdir as mkdir22 } from "fs/promises";
|
|
104
117
|
import { basename as basename2, join as join42 } from "path";
|
|
105
118
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
106
119
|
import { readFile as readFile32, stat as stat3 } from "fs/promises";
|
|
@@ -112,7 +125,7 @@ import { spawnSync as spawnSync3 } from "child_process";
|
|
|
112
125
|
import { stat as stat4 } from "fs/promises";
|
|
113
126
|
import { homedir as homedir5 } from "os";
|
|
114
127
|
import { join as join7 } from "path";
|
|
115
|
-
import { mkdir as
|
|
128
|
+
import { mkdir as mkdir6, stat as stat7 } from "fs/promises";
|
|
116
129
|
import { homedir as homedir10 } from "os";
|
|
117
130
|
import { basename as basename4, join as join12, resolve as resolve4 } from "path";
|
|
118
131
|
|
|
@@ -694,17 +707,17 @@ import { existsSync as existsSync22 } from "fs";
|
|
|
694
707
|
import { readFile as readFile42 } from "fs/promises";
|
|
695
708
|
import { homedir as homedir6 } from "os";
|
|
696
709
|
import { join as join8 } from "path";
|
|
697
|
-
import { mkdir as
|
|
710
|
+
import { mkdir as mkdir32, readdir as readdir32, rm as rm32, stat as stat5 } from "fs/promises";
|
|
698
711
|
import { homedir as homedir7, platform } from "os";
|
|
699
712
|
import { join as join9, resolve as resolve2 } from "path";
|
|
700
|
-
import { mkdir as
|
|
713
|
+
import { mkdir as mkdir4, mkdtemp as mkdtemp32, readFile as readFile5, readdir as readdir4, rm as rm4, writeFile as writeFile22 } from "fs/promises";
|
|
701
714
|
import { homedir as homedir8, tmpdir as tmpdir32 } from "os";
|
|
702
715
|
import { basename as basename3, join as join10 } from "path";
|
|
703
716
|
import { stat as stat6 } from "fs/promises";
|
|
704
717
|
import { spawn as spawn6 } from "child_process";
|
|
705
718
|
import { randomBytes as randomBytes22 } from "crypto";
|
|
706
719
|
import { existsSync as existsSync3, openSync as openSync2 } from "fs";
|
|
707
|
-
import { cp, mkdir as
|
|
720
|
+
import { cp, mkdir as mkdir5, readFile as readFile6, readdir as readdir5, rename as rename3, rm as rm5, unlink as unlink2, writeFile as writeFile32 } from "fs/promises";
|
|
708
721
|
import { request as httpRequest } from "http";
|
|
709
722
|
import { createRequire } from "module";
|
|
710
723
|
import { homedir as homedir9 } from "os";
|
|
@@ -1336,7 +1349,7 @@ var GitHubAppLeaser = class {
|
|
|
1336
1349
|
}
|
|
1337
1350
|
};
|
|
1338
1351
|
|
|
1339
|
-
// ../../packages/relay/dist/chunk-
|
|
1352
|
+
// ../../packages/relay/dist/chunk-LH565Z3T.js
|
|
1340
1353
|
import { spawn as spawn3 } from "child_process";
|
|
1341
1354
|
import { createServer } from "http";
|
|
1342
1355
|
import { mkdtemp, rm as rm2 } from "fs/promises";
|
|
@@ -1623,7 +1636,7 @@ function getConnector(service) {
|
|
|
1623
1636
|
return null;
|
|
1624
1637
|
}
|
|
1625
1638
|
|
|
1626
|
-
// ../../packages/relay/dist/chunk-
|
|
1639
|
+
// ../../packages/relay/dist/chunk-LH565Z3T.js
|
|
1627
1640
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
1628
1641
|
import { randomUUID as randomUUID22 } from "crypto";
|
|
1629
1642
|
import { spawn as spawn5 } from "child_process";
|
|
@@ -2196,6 +2209,10 @@ async function resolveCloudBackend(name) {
|
|
|
2196
2209
|
const pkg = "@agentbox/sandbox-e2b";
|
|
2197
2210
|
return loadCloudBackend(pkg, async () => (await import(pkg)).e2bBackend);
|
|
2198
2211
|
}
|
|
2212
|
+
if (name === "digitalocean") {
|
|
2213
|
+
const pkg = "@agentbox/sandbox-digitalocean";
|
|
2214
|
+
return loadCloudBackend(pkg, async () => (await import(pkg)).digitaloceanBackend);
|
|
2215
|
+
}
|
|
2199
2216
|
const plugin = pluginForProvider(name);
|
|
2200
2217
|
if (plugin) {
|
|
2201
2218
|
if (!isSupportedApiVersion(plugin.apiVersion)) {
|
|
@@ -3210,6 +3227,82 @@ var BoxNotices = class {
|
|
|
3210
3227
|
return this.entries.size;
|
|
3211
3228
|
}
|
|
3212
3229
|
};
|
|
3230
|
+
var CREDENTIALS_UPDATED_EVENT = "credentials-updated";
|
|
3231
|
+
var CredentialsFanout = class {
|
|
3232
|
+
log;
|
|
3233
|
+
debounceMs;
|
|
3234
|
+
runPropagate;
|
|
3235
|
+
backupPathFor;
|
|
3236
|
+
pending = /* @__PURE__ */ new Map();
|
|
3237
|
+
chains = /* @__PURE__ */ new Map();
|
|
3238
|
+
constructor(deps) {
|
|
3239
|
+
this.log = deps.log;
|
|
3240
|
+
this.debounceMs = deps.debounceMs ?? 3e3;
|
|
3241
|
+
this.runPropagate = deps.runPropagate ?? defaultRunPropagate;
|
|
3242
|
+
this.backupPathFor = deps.backupPathFor;
|
|
3243
|
+
}
|
|
3244
|
+
/**
|
|
3245
|
+
* Validate, newest-wins-gate, persist the host backup, and schedule the
|
|
3246
|
+
* fan-out. Fast (no box I/O); the propagate CLI does the slow work detached.
|
|
3247
|
+
*/
|
|
3248
|
+
async handle(sourceBoxId, payload) {
|
|
3249
|
+
const update = parseCredentialsUpdate(payload);
|
|
3250
|
+
if (!update) return { accepted: false, reason: "invalid payload" };
|
|
3251
|
+
const backupPath = this.backupPathFor?.(update.agent);
|
|
3252
|
+
const existing = await readCredentialBackup(update.agent, { backupPath });
|
|
3253
|
+
const verdict = shouldAcceptCredentialUpdate(update.agent, update.content, existing);
|
|
3254
|
+
if (!verdict.accept) {
|
|
3255
|
+
return { accepted: false, reason: verdict.reason };
|
|
3256
|
+
}
|
|
3257
|
+
await writeCredentialBackup(update.agent, update.content, { backupPath });
|
|
3258
|
+
this.log(
|
|
3259
|
+
`credentials: accepted ${update.agent} update from box ${sourceBoxId} (${verdict.reason}); fan-out in ${String(this.debounceMs)}ms`
|
|
3260
|
+
);
|
|
3261
|
+
this.schedule(update.agent, sourceBoxId);
|
|
3262
|
+
return { accepted: true, reason: verdict.reason };
|
|
3263
|
+
}
|
|
3264
|
+
schedule(agent, sourceBoxId) {
|
|
3265
|
+
const existing = this.pending.get(agent);
|
|
3266
|
+
if (existing) clearTimeout(existing);
|
|
3267
|
+
const timer = setTimeout(() => {
|
|
3268
|
+
this.pending.delete(agent);
|
|
3269
|
+
const prev = this.chains.get(agent) ?? Promise.resolve();
|
|
3270
|
+
const next = prev.then(() => this.runPropagate(agent, sourceBoxId)).catch((err) => {
|
|
3271
|
+
this.log(
|
|
3272
|
+
`credentials: ${agent} fan-out failed: ${err instanceof Error ? err.message : String(err)}`
|
|
3273
|
+
);
|
|
3274
|
+
});
|
|
3275
|
+
this.chains.set(agent, next);
|
|
3276
|
+
}, this.debounceMs);
|
|
3277
|
+
timer.unref();
|
|
3278
|
+
this.pending.set(agent, timer);
|
|
3279
|
+
}
|
|
3280
|
+
/** Pending debounce timers + in-flight chain, for tests/shutdown. */
|
|
3281
|
+
async flush() {
|
|
3282
|
+
for (const [agent, timer] of this.pending) {
|
|
3283
|
+
clearTimeout(timer);
|
|
3284
|
+
this.pending.delete(agent);
|
|
3285
|
+
void agent;
|
|
3286
|
+
}
|
|
3287
|
+
await Promise.all([...this.chains.values()]);
|
|
3288
|
+
}
|
|
3289
|
+
};
|
|
3290
|
+
async function defaultRunPropagate(agent, sourceBoxId) {
|
|
3291
|
+
const entry = process.env["AGENTBOX_CLI_ENTRY"];
|
|
3292
|
+
if (!entry) {
|
|
3293
|
+
throw new Error("AGENTBOX_CLI_ENTRY not set; cannot run credential propagate host-side");
|
|
3294
|
+
}
|
|
3295
|
+
const result = await execa(
|
|
3296
|
+
process.execPath,
|
|
3297
|
+
[entry, "credentials", "propagate", "--agent", agent, "--source-box", sourceBoxId],
|
|
3298
|
+
{ reject: false, timeout: 3e5 }
|
|
3299
|
+
);
|
|
3300
|
+
if (result.exitCode !== 0) {
|
|
3301
|
+
throw new Error(
|
|
3302
|
+
`credentials propagate exited ${String(result.exitCode)}: ${String(result.stderr).slice(-300)}`
|
|
3303
|
+
);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3213
3306
|
var BOX_STATUS_EVENT = "box-status";
|
|
3214
3307
|
var MAX_BODY_BYTES = 1024 * 1024;
|
|
3215
3308
|
var GIT_RPC_TIMEOUT_MS = 12e4;
|
|
@@ -3303,6 +3396,7 @@ function createRelayServer(opts) {
|
|
|
3303
3396
|
const host = opts.host ?? "0.0.0.0";
|
|
3304
3397
|
const mode = opts.mode ?? "host";
|
|
3305
3398
|
const hostActions = mode === "box" ? new HostActionQueue() : null;
|
|
3399
|
+
const credentialsFanout = mode === "box" ? null : new CredentialsFanout({ log });
|
|
3306
3400
|
if (mode === "box" && (!opts.bridgeToken || opts.bridgeToken.length === 0)) {
|
|
3307
3401
|
throw new Error("relay mode='box' requires a non-empty bridgeToken");
|
|
3308
3402
|
}
|
|
@@ -3428,6 +3522,14 @@ function createRelayServer(opts) {
|
|
|
3428
3522
|
send(res, 202, { ok: true });
|
|
3429
3523
|
return;
|
|
3430
3524
|
}
|
|
3525
|
+
if (body.type === CREDENTIALS_UPDATED_EVENT && credentialsFanout) {
|
|
3526
|
+
const verdict = await credentialsFanout.handle(reg.boxId, body.payload);
|
|
3527
|
+
log(
|
|
3528
|
+
`credentials-updated box=${reg.boxId} accepted=${String(verdict.accepted)} (${verdict.reason})`
|
|
3529
|
+
);
|
|
3530
|
+
send(res, 202, { ok: true, accepted: verdict.accepted });
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3431
3533
|
const ev = await store.appendEvent({
|
|
3432
3534
|
boxId: reg.boxId,
|
|
3433
3535
|
type: body.type,
|
|
@@ -3862,6 +3964,13 @@ function createRelayServer(opts) {
|
|
|
3862
3964
|
previewToken: reg.previewToken,
|
|
3863
3965
|
onEvents: async (evs) => {
|
|
3864
3966
|
for (const ev of evs) {
|
|
3967
|
+
if (ev.type === CREDENTIALS_UPDATED_EVENT && credentialsFanout) {
|
|
3968
|
+
const verdict = await credentialsFanout.handle(reg.boxId, ev.payload);
|
|
3969
|
+
log(
|
|
3970
|
+
`credentials-updated box=${reg.boxId} accepted=${String(verdict.accepted)} (${verdict.reason})`
|
|
3971
|
+
);
|
|
3972
|
+
continue;
|
|
3973
|
+
}
|
|
3865
3974
|
await store.appendEvent({
|
|
3866
3975
|
boxId: reg.boxId,
|
|
3867
3976
|
type: ev.type,
|
|
@@ -5528,103 +5637,15 @@ import { join as join14 } from "path";
|
|
|
5528
5637
|
import { join as join13 } from "path";
|
|
5529
5638
|
import { homedir as homedir11 } from "os";
|
|
5530
5639
|
import { join as join15 } from "path";
|
|
5640
|
+
import { mkdir as mkdir7 } from "fs/promises";
|
|
5641
|
+
import { dirname as dirname4, join as join16 } from "path";
|
|
5531
5642
|
import { spawn as spawn22 } from "child_process";
|
|
5532
5643
|
import { existsSync as existsSync4, openSync as openSync22 } from "fs";
|
|
5533
5644
|
import { mkdir as mkdir8, readFile as readFile7, unlink as unlink22, writeFile as writeFile4 } from "fs/promises";
|
|
5534
5645
|
import { homedir as homedir12 } from "os";
|
|
5535
|
-
import { dirname as
|
|
5646
|
+
import { dirname as dirname5, join as join17, resolve as resolve5 } from "path";
|
|
5536
5647
|
import { setTimeout as delay3 } from "timers/promises";
|
|
5537
5648
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5538
|
-
var SKILL_EXCLUDE_PREFIXES = ["agentbox-"];
|
|
5539
|
-
var CONTAINER_PLUGINS_PREFIX = "/home/vscode/.claude/plugins/";
|
|
5540
|
-
function pickNewItems(boxNames, hostNames, excludePrefixes = []) {
|
|
5541
|
-
const host = new Set(hostNames);
|
|
5542
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5543
|
-
const out = [];
|
|
5544
|
-
for (const name of boxNames) {
|
|
5545
|
-
if (name.length === 0 || host.has(name) || seen.has(name)) continue;
|
|
5546
|
-
if (excludePrefixes.some((p) => name.startsWith(p))) continue;
|
|
5547
|
-
seen.add(name);
|
|
5548
|
-
out.push(name);
|
|
5549
|
-
}
|
|
5550
|
-
return out.sort();
|
|
5551
|
-
}
|
|
5552
|
-
function rewritePluginPaths(value, hostPluginsPrefix) {
|
|
5553
|
-
if (typeof value === "string") {
|
|
5554
|
-
return value.split(CONTAINER_PLUGINS_PREFIX).join(hostPluginsPrefix);
|
|
5555
|
-
}
|
|
5556
|
-
if (Array.isArray(value)) {
|
|
5557
|
-
return value.map((v) => rewritePluginPaths(v, hostPluginsPrefix));
|
|
5558
|
-
}
|
|
5559
|
-
if (value !== null && typeof value === "object") {
|
|
5560
|
-
const out = {};
|
|
5561
|
-
for (const [k, v] of Object.entries(value)) {
|
|
5562
|
-
out[k] = rewritePluginPaths(v, hostPluginsPrefix);
|
|
5563
|
-
}
|
|
5564
|
-
return out;
|
|
5565
|
-
}
|
|
5566
|
-
return value;
|
|
5567
|
-
}
|
|
5568
|
-
function isPlainObject(v) {
|
|
5569
|
-
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
5570
|
-
}
|
|
5571
|
-
function additiveMerge(hostRoot, boxRoot, hostPluginsPrefix, selectMap, withMap) {
|
|
5572
|
-
const hostMap = selectMap(hostRoot);
|
|
5573
|
-
const boxMap = selectMap(boxRoot);
|
|
5574
|
-
if (!isPlainObject(boxMap)) {
|
|
5575
|
-
return { data: hostRoot, changed: false, addedKeys: [] };
|
|
5576
|
-
}
|
|
5577
|
-
const base = isPlainObject(hostMap) ? { ...hostMap } : {};
|
|
5578
|
-
const addedKeys = [];
|
|
5579
|
-
for (const [key, value] of Object.entries(boxMap)) {
|
|
5580
|
-
if (Object.prototype.hasOwnProperty.call(base, key)) continue;
|
|
5581
|
-
base[key] = rewritePluginPaths(value, hostPluginsPrefix);
|
|
5582
|
-
addedKeys.push(key);
|
|
5583
|
-
}
|
|
5584
|
-
if (addedKeys.length === 0) {
|
|
5585
|
-
return { data: hostRoot, changed: false, addedKeys: [] };
|
|
5586
|
-
}
|
|
5587
|
-
return { data: withMap(hostRoot, base), changed: true, addedKeys: addedKeys.sort() };
|
|
5588
|
-
}
|
|
5589
|
-
function mergeKnownMarketplaces(hostJson, boxJson, opts) {
|
|
5590
|
-
const prefix = `${opts.hostHome}/.claude/plugins/`;
|
|
5591
|
-
return additiveMerge(
|
|
5592
|
-
isPlainObject(hostJson) ? hostJson : {},
|
|
5593
|
-
boxJson,
|
|
5594
|
-
prefix,
|
|
5595
|
-
(root) => root,
|
|
5596
|
-
(_host, merged) => merged
|
|
5597
|
-
);
|
|
5598
|
-
}
|
|
5599
|
-
function mergeInstalledPlugins(hostJson, boxJson, opts) {
|
|
5600
|
-
const prefix = `${opts.hostHome}/.claude/plugins/`;
|
|
5601
|
-
const hostRoot = isPlainObject(hostJson) ? hostJson : { plugins: {} };
|
|
5602
|
-
return additiveMerge(
|
|
5603
|
-
hostRoot,
|
|
5604
|
-
boxJson,
|
|
5605
|
-
prefix,
|
|
5606
|
-
(root) => isPlainObject(root) ? root["plugins"] : void 0,
|
|
5607
|
-
(host, merged) => ({ ...host, plugins: merged })
|
|
5608
|
-
);
|
|
5609
|
-
}
|
|
5610
|
-
function referencedPluginVersionKeys(installedPluginsJson) {
|
|
5611
|
-
const keys = /* @__PURE__ */ new Set();
|
|
5612
|
-
if (!isPlainObject(installedPluginsJson)) return keys;
|
|
5613
|
-
const plugins = installedPluginsJson["plugins"];
|
|
5614
|
-
if (!isPlainObject(plugins)) return keys;
|
|
5615
|
-
for (const entries of Object.values(plugins)) {
|
|
5616
|
-
if (!Array.isArray(entries)) continue;
|
|
5617
|
-
for (const entry of entries) {
|
|
5618
|
-
if (!isPlainObject(entry)) continue;
|
|
5619
|
-
const installPath = entry["installPath"];
|
|
5620
|
-
if (typeof installPath !== "string") continue;
|
|
5621
|
-
const segments = installPath.split("/").filter((s) => s.length > 0);
|
|
5622
|
-
if (segments.length < 3) continue;
|
|
5623
|
-
keys.add(segments.slice(-3).join("/"));
|
|
5624
|
-
}
|
|
5625
|
-
}
|
|
5626
|
-
return keys;
|
|
5627
|
-
}
|
|
5628
5649
|
async function dockerInfo() {
|
|
5629
5650
|
const result = await execa("docker", ["info"], { reject: false });
|
|
5630
5651
|
if (result.exitCode !== 0) {
|
|
@@ -6619,7 +6640,9 @@ async function copyOneEntry(container, entry) {
|
|
|
6619
6640
|
"--no-same-permissions",
|
|
6620
6641
|
"--no-same-owner",
|
|
6621
6642
|
"-m"
|
|
6622
|
-
]
|
|
6643
|
+
],
|
|
6644
|
+
// COPYFILE_DISABLE silences macOS BSD tar's `._*` resource-fork stubs.
|
|
6645
|
+
{ ...process.env, COPYFILE_DISABLE: "1" }
|
|
6623
6646
|
);
|
|
6624
6647
|
if (packed.exitCode !== 0) {
|
|
6625
6648
|
throw new Error(`tar pack failed: ${String(packed.stderr).slice(0, 300)}`);
|
|
@@ -6657,7 +6680,9 @@ async function copyOneEntry(container, entry) {
|
|
|
6657
6680
|
"--no-same-permissions",
|
|
6658
6681
|
"--no-same-owner",
|
|
6659
6682
|
"-m"
|
|
6660
|
-
]
|
|
6683
|
+
],
|
|
6684
|
+
// COPYFILE_DISABLE silences macOS BSD tar's `._*` resource-fork stubs.
|
|
6685
|
+
{ ...process.env, COPYFILE_DISABLE: "1" }
|
|
6661
6686
|
);
|
|
6662
6687
|
if (packed.exitCode !== 0) {
|
|
6663
6688
|
throw new Error(`tar pack failed: ${String(packed.stderr).slice(0, 300)}`);
|
|
@@ -7424,52 +7449,11 @@ async function claudeSessionInfo(container, sessionName) {
|
|
|
7424
7449
|
}
|
|
7425
7450
|
return { running: true, sessionName: name, startedAt };
|
|
7426
7451
|
}
|
|
7427
|
-
var PULL_DIR_CATEGORIES = ["skills", "agents", "commands"];
|
|
7428
|
-
async function listChildDirs(dir) {
|
|
7429
|
-
try {
|
|
7430
|
-
const entries = await readdir2(dir, { withFileTypes: true });
|
|
7431
|
-
return entries.filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => e.name);
|
|
7432
|
-
} catch {
|
|
7433
|
-
return [];
|
|
7434
|
-
}
|
|
7435
|
-
}
|
|
7436
|
-
async function readJsonFile(path) {
|
|
7437
|
-
try {
|
|
7438
|
-
return JSON.parse(await readFile23(path, "utf8"));
|
|
7439
|
-
} catch {
|
|
7440
|
-
return void 0;
|
|
7441
|
-
}
|
|
7442
|
-
}
|
|
7443
7452
|
async function pullClaudeExtras(spec, opts) {
|
|
7444
|
-
const
|
|
7445
|
-
const hostClaude = join3(hostHome, ".claude");
|
|
7446
|
-
const inventoryScript = [
|
|
7447
|
-
"for cat in skills agents commands; do",
|
|
7448
|
-
' [ -d "/src/$cat" ] || continue;',
|
|
7449
|
-
' for d in "/src/$cat"/*/; do',
|
|
7450
|
-
' [ -d "$d" ] || continue;',
|
|
7451
|
-
' printf "DIR %s %s\\n" "$cat" "$(basename "$d")";',
|
|
7452
|
-
" done;",
|
|
7453
|
-
"done;",
|
|
7454
|
-
"if [ -d /src/plugins/cache ]; then",
|
|
7455
|
-
" for m in /src/plugins/cache/*/; do",
|
|
7456
|
-
' [ -d "$m" ] || continue;',
|
|
7457
|
-
' for p in "$m"*/; do',
|
|
7458
|
-
' [ -d "$p" ] || continue;',
|
|
7459
|
-
' printf "PLUGIN %s/%s\\n" "$(basename "$m")" "$(basename "$p")";',
|
|
7460
|
-
" done;",
|
|
7461
|
-
" done;",
|
|
7462
|
-
"fi;",
|
|
7463
|
-
"for f in installed_plugins known_marketplaces; do",
|
|
7464
|
-
' [ -f "/src/plugins/$f.json" ] || continue;',
|
|
7465
|
-
' printf "JSON %s " "$f";',
|
|
7466
|
-
' base64 -w0 "/src/plugins/$f.json";',
|
|
7467
|
-
' printf "\\n";',
|
|
7468
|
-
"done"
|
|
7469
|
-
].join(" ");
|
|
7453
|
+
const hostClaude = join3(homedir2(), ".claude");
|
|
7470
7454
|
const inv = await execa(
|
|
7471
7455
|
"docker",
|
|
7472
|
-
["run", "--rm", "--user", "0", "-v", `${spec.volume}:/src:ro`, opts.image, "sh", "-c",
|
|
7456
|
+
["run", "--rm", "--user", "0", "-v", `${spec.volume}:/src:ro`, opts.image, "sh", "-c", claudeInventoryScript("/src")],
|
|
7473
7457
|
{ reject: false }
|
|
7474
7458
|
);
|
|
7475
7459
|
if (inv.exitCode !== 0) {
|
|
@@ -7477,68 +7461,18 @@ async function pullClaudeExtras(spec, opts) {
|
|
|
7477
7461
|
`failed to read claude-config volume ${spec.volume}: ${(inv.stderr ?? "").toString().trim() || `exit ${String(inv.exitCode)}`}`
|
|
7478
7462
|
);
|
|
7479
7463
|
}
|
|
7480
|
-
const
|
|
7481
|
-
const
|
|
7482
|
-
const
|
|
7483
|
-
|
|
7484
|
-
if (line.startsWith("DIR ")) {
|
|
7485
|
-
const rest = line.slice(4);
|
|
7486
|
-
const sp = rest.indexOf(" ");
|
|
7487
|
-
if (sp === -1) continue;
|
|
7488
|
-
const cat = rest.slice(0, sp);
|
|
7489
|
-
const name = rest.slice(sp + 1);
|
|
7490
|
-
if (cat in boxDirs) boxDirs[cat].push(name);
|
|
7491
|
-
} else if (line.startsWith("PLUGIN ")) {
|
|
7492
|
-
boxPlugins.push(line.slice(7));
|
|
7493
|
-
} else if (line.startsWith("JSON ")) {
|
|
7494
|
-
const rest = line.slice(5);
|
|
7495
|
-
const sp = rest.indexOf(" ");
|
|
7496
|
-
if (sp === -1) continue;
|
|
7497
|
-
const which = rest.slice(0, sp);
|
|
7498
|
-
try {
|
|
7499
|
-
boxJson[which] = JSON.parse(Buffer.from(rest.slice(sp + 1), "base64").toString("utf8"));
|
|
7500
|
-
} catch {
|
|
7501
|
-
}
|
|
7502
|
-
}
|
|
7503
|
-
}
|
|
7504
|
-
const newItems = [];
|
|
7505
|
-
const applyPaths = [];
|
|
7506
|
-
for (const cat of PULL_DIR_CATEGORIES) {
|
|
7507
|
-
const hostNames = await listChildDirs(join3(hostClaude, cat));
|
|
7508
|
-
const excludes = cat === "skills" ? SKILL_EXCLUDE_PREFIXES : [];
|
|
7509
|
-
for (const name of pickNewItems(boxDirs[cat] ?? [], hostNames, excludes)) {
|
|
7510
|
-
newItems.push({ category: cat, name });
|
|
7511
|
-
applyPaths.push({ src: `/src/${cat}/${name}`, dest: `/dst/${cat}/${name}` });
|
|
7512
|
-
}
|
|
7513
|
-
}
|
|
7514
|
-
const hostPluginKeys = [];
|
|
7515
|
-
for (const m of await listChildDirs(join3(hostClaude, "plugins", "cache"))) {
|
|
7516
|
-
for (const p of await listChildDirs(join3(hostClaude, "plugins", "cache", m))) {
|
|
7517
|
-
hostPluginKeys.push(`${m}/${p}`);
|
|
7518
|
-
}
|
|
7519
|
-
}
|
|
7520
|
-
for (const key of pickNewItems(boxPlugins, hostPluginKeys)) {
|
|
7521
|
-
newItems.push({ category: "plugins", name: key });
|
|
7522
|
-
applyPaths.push({ src: `/src/plugins/cache/${key}`, dest: `/dst/plugins/cache/${key}` });
|
|
7523
|
-
}
|
|
7524
|
-
const hostInstalled = await readJsonFile(join3(hostClaude, "plugins", "installed_plugins.json"));
|
|
7525
|
-
const hostMarkets = await readJsonFile(join3(hostClaude, "plugins", "known_marketplaces.json"));
|
|
7526
|
-
const mergedInstalled = mergeInstalledPlugins(hostInstalled, boxJson["installed_plugins"], {
|
|
7527
|
-
hostHome
|
|
7528
|
-
});
|
|
7529
|
-
const mergedMarkets = mergeKnownMarketplaces(hostMarkets, boxJson["known_marketplaces"], {
|
|
7530
|
-
hostHome
|
|
7531
|
-
});
|
|
7532
|
-
const mergedRegistries = [];
|
|
7533
|
-
if (mergedInstalled.changed) mergedRegistries.push("installed_plugins.json");
|
|
7534
|
-
if (mergedMarkets.changed) mergedRegistries.push("known_marketplaces.json");
|
|
7464
|
+
const inventory = parseClaudeInventory((inv.stdout ?? "").toString());
|
|
7465
|
+
const plan = await computeClaudePullPlan(inventory);
|
|
7466
|
+
const { newItems, mergedRegistries } = plan;
|
|
7467
|
+
const sourceRegistries = inventory.registries;
|
|
7535
7468
|
if (opts.dryRun || newItems.length === 0 && mergedRegistries.length === 0) {
|
|
7536
|
-
return { newItems, mergedRegistries };
|
|
7469
|
+
return { newItems, mergedRegistries, sourceRegistries };
|
|
7537
7470
|
}
|
|
7538
|
-
if (
|
|
7539
|
-
const cmds =
|
|
7471
|
+
if (plan.copyRels.length > 0) {
|
|
7472
|
+
const cmds = plan.copyRels.map((rel) => {
|
|
7473
|
+
const dest = `/dst/${rel}`;
|
|
7540
7474
|
const parent = dest.slice(0, dest.lastIndexOf("/"));
|
|
7541
|
-
return `mkdir -p '${parent}' && rsync -a --ignore-existing --exclude=node_modules '
|
|
7475
|
+
return `mkdir -p '${parent}' && rsync -a --ignore-existing --exclude=node_modules '/src/${rel}/' '${dest}/'`;
|
|
7542
7476
|
});
|
|
7543
7477
|
const apply = await execa(
|
|
7544
7478
|
"docker",
|
|
@@ -7564,24 +7498,8 @@ async function pullClaudeExtras(spec, opts) {
|
|
|
7564
7498
|
);
|
|
7565
7499
|
}
|
|
7566
7500
|
}
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
if (mergedMarkets.changed) {
|
|
7570
|
-
await writeFile3(
|
|
7571
|
-
join3(hostClaude, "plugins", "known_marketplaces.json"),
|
|
7572
|
-
`${JSON.stringify(mergedMarkets.data, null, 2)}
|
|
7573
|
-
`
|
|
7574
|
-
);
|
|
7575
|
-
}
|
|
7576
|
-
if (mergedInstalled.changed) {
|
|
7577
|
-
await writeFile3(
|
|
7578
|
-
join3(hostClaude, "plugins", "installed_plugins.json"),
|
|
7579
|
-
`${JSON.stringify(mergedInstalled.data, null, 2)}
|
|
7580
|
-
`
|
|
7581
|
-
);
|
|
7582
|
-
}
|
|
7583
|
-
}
|
|
7584
|
-
return { newItems, mergedRegistries };
|
|
7501
|
+
await writeClaudeMergedRegistries(plan);
|
|
7502
|
+
return { newItems, mergedRegistries, sourceRegistries };
|
|
7585
7503
|
}
|
|
7586
7504
|
var CREDENTIALS_BACKUP_FILE = join42(STATE_DIR, "claude-credentials.json");
|
|
7587
7505
|
var CODEX_CREDENTIALS_BACKUP_FILE = join42(STATE_DIR, "codex-credentials.json");
|
|
@@ -7591,7 +7509,7 @@ function parseExtractResult(stdout) {
|
|
|
7591
7509
|
}
|
|
7592
7510
|
async function extractVolumeAuthToBackup(opts) {
|
|
7593
7511
|
try {
|
|
7594
|
-
await
|
|
7512
|
+
await mkdir22(STATE_DIR, { recursive: true });
|
|
7595
7513
|
const script = 'COPIED=no; if [ -s /dst/auth.json ]; then cp -a /dst/auth.json "/host-state/$DEST" && COPIED=yes; fi; echo "COPIED=$COPIED"';
|
|
7596
7514
|
const { stdout } = await execa("docker", [
|
|
7597
7515
|
"run",
|
|
@@ -7682,7 +7600,7 @@ echo "EXTRACTED=$EXTRACTED SEEDED=$SEEDED VOLREAL=$VOL_REAL"
|
|
|
7682
7600
|
`;
|
|
7683
7601
|
async function syncClaudeCredentials(spec, opts) {
|
|
7684
7602
|
try {
|
|
7685
|
-
await
|
|
7603
|
+
await mkdir22(STATE_DIR, { recursive: true });
|
|
7686
7604
|
const { stdout } = await execa("docker", [
|
|
7687
7605
|
"run",
|
|
7688
7606
|
"--rm",
|
|
@@ -7790,6 +7708,16 @@ async function ensureCodexVolume(spec, opts) {
|
|
|
7790
7708
|
"-c",
|
|
7791
7709
|
// --exclude=hooks.json: the AgentBox activity hooks file is box-owned
|
|
7792
7710
|
// (seeded by seedCodexHooks); never let the host copy clobber it.
|
|
7711
|
+
// --exclude=/config.toml (anchored — plugin repos legitimately contain
|
|
7712
|
+
// files named config.toml): box config is owned by
|
|
7713
|
+
// reconcileVolumeCodexConfig (sanitize + merge), never rsynced — copying
|
|
7714
|
+
// the host file here would wipe box-side `codex plugin add`/`mcp add`
|
|
7715
|
+
// state before the merge could read it.
|
|
7716
|
+
// The `.tmp/marketplaces` includes come FIRST (rsync filter rules are
|
|
7717
|
+
// first-match-wins): git-marketplace snapshots must reach the box or
|
|
7718
|
+
// in-box `codex plugin` breaks; `/.tmp/*` then drops `.tmp`'s other
|
|
7719
|
+
// children (the heavy desktop-app payloads) and the unanchored `.tmp`
|
|
7720
|
+
// still blocks nested `.tmp` dirs elsewhere.
|
|
7793
7721
|
// The session-state DBs / indexes are excluded so a teleported session
|
|
7794
7722
|
// resumes at /workspace (Codex reads the cwd from state_*.sqlite's threads
|
|
7795
7723
|
// index, which it backfills from the box's rollouts) and the host's
|
|
@@ -7798,18 +7726,18 @@ async function ensureCodexVolume(spec, opts) {
|
|
|
7798
7726
|
// excludes) already copied into the shared volume — rsync without
|
|
7799
7727
|
// --delete only adds/updates. The globs are no-ops with `-f` when absent,
|
|
7800
7728
|
// and never touch box-owned `sessions/` (the teleported rollouts) or
|
|
7801
|
-
// `hooks.json`.
|
|
7802
|
-
// Heavy host-only artifacts are also excluded (mirrors
|
|
7803
|
-
//
|
|
7804
|
-
// in-box codex is npm-installed), `plugins/.plugin-appserver` (the
|
|
7729
|
+
// `hooks.json`. `.tmp` gets a selective purge that keeps `marketplaces/`.
|
|
7730
|
+
// Heavy host-only artifacts are also excluded (mirrors the codex spec in
|
|
7731
|
+
// sandbox-core's registry): `packages` (macOS standalone release binaries —
|
|
7732
|
+
// the in-box codex is npm-installed), `plugins/.plugin-appserver` (the
|
|
7805
7733
|
// platform-specific plugin app-server runtime), `computer-use` (the macOS
|
|
7806
7734
|
// `Codex Computer Use.app` bundle), `archived_sessions` (host history), and
|
|
7807
|
-
// the regenerable caches (
|
|
7808
|
-
// `
|
|
7809
|
-
//
|
|
7810
|
-
"rsync -a --exclude=sessions --exclude=log --exclude=history.jsonl --exclude=hooks.json" + skillsExclude + " --exclude=state_*.sqlite* --exclude=logs_*.sqlite* --exclude=session_index.jsonl --exclude=external_agent_session_imports.json --exclude=shell_snapshots --exclude=packages --exclude=plugins/.plugin-appserver --exclude=computer-use --exclude=archived_sessions --exclude=.tmp --exclude=tmp --exclude=cache --exclude=vendor_imports --exclude=sqlite --exclude=models_cache.json /src/ /dst/ && rm -rf /dst/state_*.sqlite* /dst/logs_*.sqlite* /dst/session_index.jsonl /dst/external_agent_session_imports.json /dst/shell_snapshots /dst/packages /dst/plugins/.plugin-appserver /dst/computer-use /dst/archived_sessions /dst
|
|
7735
|
+
// the regenerable caches (`tmp`, `cache`, `vendor_imports`, `sqlite`,
|
|
7736
|
+
// `models_cache.json`). Without these the shared volume balloons to
|
|
7737
|
+
// ~1.5 GB and every create's rsync crawls.
|
|
7738
|
+
"rsync -a --include=/.tmp/ --include=/.tmp/marketplaces/*** --exclude=/.tmp/* --exclude=sessions --exclude=log --exclude=history.jsonl --exclude=hooks.json --exclude=/config.toml" + skillsExclude + " --exclude=state_*.sqlite* --exclude=logs_*.sqlite* --exclude=session_index.jsonl --exclude=external_agent_session_imports.json --exclude=shell_snapshots --exclude=packages --exclude=plugins/.plugin-appserver --exclude=computer-use --exclude=archived_sessions --exclude=.tmp --exclude=tmp --exclude=cache --exclude=vendor_imports --exclude=sqlite --exclude=models_cache.json /src/ /dst/ && rm -rf /dst/state_*.sqlite* /dst/logs_*.sqlite* /dst/session_index.jsonl /dst/external_agent_session_imports.json /dst/shell_snapshots /dst/packages /dst/plugins/.plugin-appserver /dst/computer-use /dst/archived_sessions /dst/tmp /dst/cache /dst/vendor_imports /dst/sqlite /dst/models_cache.json && { [ -d /dst/.tmp ] && find /dst/.tmp -mindepth 1 -maxdepth 1 ! -name marketplaces -exec rm -rf {} + || true; }" + skillsPurge + " && chown -R 1000:1000 /dst"
|
|
7811
7739
|
]);
|
|
7812
|
-
await
|
|
7740
|
+
await reconcileVolumeCodexConfig(spec.volume, opts.image);
|
|
7813
7741
|
return { created, synced: true };
|
|
7814
7742
|
}
|
|
7815
7743
|
await execa(
|
|
@@ -7829,7 +7757,7 @@ async function ensureCodexVolume(spec, opts) {
|
|
|
7829
7757
|
{ reject: false }
|
|
7830
7758
|
);
|
|
7831
7759
|
if (!await pathExists2(join5(hostCodex, "config.toml"))) {
|
|
7832
|
-
await
|
|
7760
|
+
await reconcileVolumeCodexConfig(spec.volume, opts.image);
|
|
7833
7761
|
}
|
|
7834
7762
|
return { created, synced: false };
|
|
7835
7763
|
}
|
|
@@ -7871,39 +7799,60 @@ async function seedCodexAgentsOverride(volume, image) {
|
|
|
7871
7799
|
return { seeded: false };
|
|
7872
7800
|
}
|
|
7873
7801
|
}
|
|
7874
|
-
|
|
7802
|
+
function buildCodexOrphanPurgeScript(keptMarketplaces) {
|
|
7803
|
+
const keepFlags = keptMarketplaces.map((n) => `! -name ${shQuote22(n)}`).join(" ");
|
|
7804
|
+
const purgeDir = (dir) => `{ [ -d ${dir} ] && find ${dir} -mindepth 1 -maxdepth 1` + (keepFlags.length > 0 ? ` ${keepFlags}` : "") + ` -exec rm -rf {} + || true; }`;
|
|
7805
|
+
return `${purgeDir("/dst/plugins/cache")} && ${purgeDir("/dst/.tmp/marketplaces")}`;
|
|
7806
|
+
}
|
|
7807
|
+
async function reconcileVolumeCodexConfig(volume, image) {
|
|
7875
7808
|
try {
|
|
7809
|
+
const boxRead = await execa(
|
|
7810
|
+
"docker",
|
|
7811
|
+
["run", "--rm", "-v", `${volume}:/dst`, image, "sh", "-c", "cat /dst/config.toml"],
|
|
7812
|
+
{ reject: false }
|
|
7813
|
+
);
|
|
7814
|
+
const boxText = boxRead.exitCode === 0 ? boxRead.stdout : null;
|
|
7876
7815
|
const hostConfig = join5(homedir32(), ".codex", "config.toml");
|
|
7877
|
-
let
|
|
7816
|
+
let base;
|
|
7878
7817
|
if (!await pathExists2(hostConfig)) {
|
|
7879
|
-
|
|
7818
|
+
base = MINIMAL_TRUSTED_CODEX_CONFIG;
|
|
7880
7819
|
} else {
|
|
7881
|
-
const
|
|
7882
|
-
|
|
7883
|
-
|
|
7820
|
+
const hostText = await readFile32(hostConfig, "utf8");
|
|
7821
|
+
try {
|
|
7822
|
+
base = sanitizeCodexConfigForBox(hostText).text;
|
|
7823
|
+
} catch {
|
|
7824
|
+
if (boxText !== null) return { reconciled: false };
|
|
7825
|
+
await writeVolumeCodexConfig(volume, image, hostText, null);
|
|
7826
|
+
return { reconciled: true };
|
|
7827
|
+
}
|
|
7884
7828
|
}
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
"run",
|
|
7889
|
-
"--rm",
|
|
7890
|
-
"-i",
|
|
7891
|
-
"--user",
|
|
7892
|
-
"0",
|
|
7893
|
-
"-v",
|
|
7894
|
-
`${volume}:/dst`,
|
|
7895
|
-
image,
|
|
7896
|
-
"sh",
|
|
7897
|
-
"-c",
|
|
7898
|
-
"cat > /dst/config.toml.tmp && chown 1000:1000 /dst/config.toml.tmp && mv /dst/config.toml.tmp /dst/config.toml"
|
|
7899
|
-
],
|
|
7900
|
-
{ input: text }
|
|
7901
|
-
);
|
|
7902
|
-
return { sanitized: true };
|
|
7829
|
+
const merged = mergeCodexConfigForBox(base, boxText);
|
|
7830
|
+
await writeVolumeCodexConfig(volume, image, merged.text, merged.marketplaces);
|
|
7831
|
+
return { reconciled: true };
|
|
7903
7832
|
} catch {
|
|
7904
|
-
return {
|
|
7833
|
+
return { reconciled: false };
|
|
7905
7834
|
}
|
|
7906
7835
|
}
|
|
7836
|
+
async function writeVolumeCodexConfig(volume, image, text, keptMarketplaces) {
|
|
7837
|
+
const purge = keptMarketplaces === null ? "" : ` && ${buildCodexOrphanPurgeScript(keptMarketplaces)}`;
|
|
7838
|
+
await execa(
|
|
7839
|
+
"docker",
|
|
7840
|
+
[
|
|
7841
|
+
"run",
|
|
7842
|
+
"--rm",
|
|
7843
|
+
"-i",
|
|
7844
|
+
"--user",
|
|
7845
|
+
"0",
|
|
7846
|
+
"-v",
|
|
7847
|
+
`${volume}:/dst`,
|
|
7848
|
+
image,
|
|
7849
|
+
"sh",
|
|
7850
|
+
"-c",
|
|
7851
|
+
"cat > /dst/config.toml.tmp && chown 1000:1000 /dst/config.toml.tmp && mv /dst/config.toml.tmp /dst/config.toml" + purge
|
|
7852
|
+
],
|
|
7853
|
+
{ input: text }
|
|
7854
|
+
);
|
|
7855
|
+
}
|
|
7907
7856
|
var CODEX_FORWARDED_ENV_KEYS = ["OPENAI_API_KEY"];
|
|
7908
7857
|
function buildCodexMounts(spec, hostEnv) {
|
|
7909
7858
|
const env = {};
|
|
@@ -8068,7 +8017,6 @@ async function codexSessionInfo(container, sessionName) {
|
|
|
8068
8017
|
}
|
|
8069
8018
|
return { running: true, sessionName: name, startedAt };
|
|
8070
8019
|
}
|
|
8071
|
-
var CODEX_PULL_ITEMS = ["config.toml", "auth.json", "prompts"];
|
|
8072
8020
|
async function pullCodexConfig(spec, opts) {
|
|
8073
8021
|
const hostCodex = join5(homedir32(), ".codex");
|
|
8074
8022
|
const inv = await execa(
|
|
@@ -8429,18 +8377,6 @@ async function opencodeSessionInfo(container, sessionName) {
|
|
|
8429
8377
|
}
|
|
8430
8378
|
return { running: true, sessionName: name, startedAt };
|
|
8431
8379
|
}
|
|
8432
|
-
var OPENCODE_PULL_DATA_ITEMS = ["auth.json"];
|
|
8433
|
-
var OPENCODE_PULL_CONFIG_ITEMS = [
|
|
8434
|
-
"opencode.json",
|
|
8435
|
-
"opencode.jsonc",
|
|
8436
|
-
"agents",
|
|
8437
|
-
"commands",
|
|
8438
|
-
"modes",
|
|
8439
|
-
"plugins",
|
|
8440
|
-
"skills",
|
|
8441
|
-
"tools",
|
|
8442
|
-
"themes"
|
|
8443
|
-
];
|
|
8444
8380
|
async function pullOpencodeConfig(spec, opts) {
|
|
8445
8381
|
const hostData = join7(homedir5(), ".local", "share", "opencode");
|
|
8446
8382
|
const hostConfig = join7(homedir5(), ".config", "opencode");
|
|
@@ -9383,7 +9319,7 @@ async function createSnapshot(opts) {
|
|
|
9383
9319
|
const source = resolve2(opts.source);
|
|
9384
9320
|
const destination = resolve2(opts.destination);
|
|
9385
9321
|
const excluded = opts.excluded ?? EXCLUDE_DIRS;
|
|
9386
|
-
await
|
|
9322
|
+
await mkdir32(SNAPSHOTS_ROOT, { recursive: true });
|
|
9387
9323
|
const cpArgs = platform() === "darwin" ? ["-cR"] : ["-R"];
|
|
9388
9324
|
await execa("cp", [...cpArgs, `${source}/`, destination]);
|
|
9389
9325
|
const toPrune = await findExcludedDirs(destination, excluded);
|
|
@@ -9581,7 +9517,7 @@ async function createCheckpoint(opts) {
|
|
|
9581
9517
|
}
|
|
9582
9518
|
}
|
|
9583
9519
|
const tag = checkpointImageTag(opts.projectRoot, name);
|
|
9584
|
-
await
|
|
9520
|
+
await mkdir4(dir, { recursive: true });
|
|
9585
9521
|
log(`running pre-commit cleanup in ${box.container}`);
|
|
9586
9522
|
await runCleanup(box.container, log);
|
|
9587
9523
|
if (type === "layered") {
|
|
@@ -9781,7 +9717,7 @@ function shouldReclaimForVersion(health, currentVersion) {
|
|
|
9781
9717
|
async function ensureRelay(opts = {}) {
|
|
9782
9718
|
const log = opts.onLog ?? (() => {
|
|
9783
9719
|
});
|
|
9784
|
-
await
|
|
9720
|
+
await mkdir5(STATE_DIR2, { recursive: true });
|
|
9785
9721
|
if (await containerExists(RELAY_CONTAINER_NAME)) {
|
|
9786
9722
|
await removeContainer(RELAY_CONTAINER_NAME);
|
|
9787
9723
|
log(`removed legacy relay container ${RELAY_CONTAINER_NAME}`);
|
|
@@ -9937,9 +9873,9 @@ async function stageRelayHome(version, log) {
|
|
|
9937
9873
|
if (nodeModules === null) return null;
|
|
9938
9874
|
const tmpDir = `${homeDir}.tmp-${String(process.pid)}`;
|
|
9939
9875
|
try {
|
|
9940
|
-
await
|
|
9876
|
+
await mkdir5(RELAY_HOME_DIR, { recursive: true });
|
|
9941
9877
|
await rm5(tmpDir, { recursive: true, force: true });
|
|
9942
|
-
await
|
|
9878
|
+
await mkdir5(tmpDir, { recursive: true });
|
|
9943
9879
|
for (const sub of ["dist", "runtime", "share"]) {
|
|
9944
9880
|
const src = join11(cliRoot, sub);
|
|
9945
9881
|
if (existsSync3(src)) await cp(src, join11(tmpDir, sub), { recursive: true });
|
|
@@ -10413,8 +10349,8 @@ async function ensureAgentboxTasksFile(container, services, opts = {}) {
|
|
|
10413
10349
|
return { status: "wrote" };
|
|
10414
10350
|
}
|
|
10415
10351
|
async function writeFileInBox(container, path, content) {
|
|
10416
|
-
const { execa:
|
|
10417
|
-
const result = await
|
|
10352
|
+
const { execa: execa22 } = await import("./execa-4DLVNM6E.js");
|
|
10353
|
+
const result = await execa22(
|
|
10418
10354
|
"docker",
|
|
10419
10355
|
["exec", "-i", "--user", "vscode", container, "sh", "-c", `cat > ${shellQuote2(path)}`],
|
|
10420
10356
|
{ input: content, reject: false }
|
|
@@ -10711,8 +10647,8 @@ async function createBox(opts) {
|
|
|
10711
10647
|
const socketDir = join12(boxDir, "run");
|
|
10712
10648
|
const socketPath = join12(socketDir, "ctl.sock");
|
|
10713
10649
|
const mergedExportDir = join12(boxDir, "workspace");
|
|
10714
|
-
await
|
|
10715
|
-
await
|
|
10650
|
+
await mkdir6(socketDir, { recursive: true });
|
|
10651
|
+
await mkdir6(mergedExportDir, { recursive: true });
|
|
10716
10652
|
const extraVolumes = await buildIdentityMounts();
|
|
10717
10653
|
extraVolumes.push(...claudeMounts.extraVolumes);
|
|
10718
10654
|
if (codexMounts) extraVolumes.push(...codexMounts.extraVolumes);
|
|
@@ -10730,7 +10666,7 @@ async function createBox(opts) {
|
|
|
10730
10666
|
Object.assign(portlessEnv, portlessBrowserEnv(name, { mapTarget: "host.docker.internal" }));
|
|
10731
10667
|
try {
|
|
10732
10668
|
const hostStateDir = await resolvePortlessHostStateDir(opts.portlessStateDir);
|
|
10733
|
-
await
|
|
10669
|
+
await mkdir6(hostStateDir, { recursive: true });
|
|
10734
10670
|
const boxStateDir = "/home/vscode/.portless";
|
|
10735
10671
|
extraVolumes.push(`${hostStateDir}:${boxStateDir}`);
|
|
10736
10672
|
portlessEnv["PORTLESS_STATE_DIR"] = boxStateDir;
|
|
@@ -10789,6 +10725,10 @@ async function createBox(opts) {
|
|
|
10789
10725
|
AGENTBOX: "1",
|
|
10790
10726
|
AGENTBOX_BOX_NAME: name,
|
|
10791
10727
|
AGENTBOX_HOST_WORKSPACE: workspace,
|
|
10728
|
+
// Absent = enabled; the ctl credential watcher only checks for '0'. The
|
|
10729
|
+
// caller-resolved value wins (it sees CLI overrides like
|
|
10730
|
+
// --no-credential-sync that this function's own config load can't).
|
|
10731
|
+
...(opts.credentialSync ?? effectiveBoxCfg.credentialSync) === false ? { AGENTBOX_CREDENTIAL_SYNC: "0" } : {},
|
|
10792
10732
|
...opts.projectRoot ? { AGENTBOX_PROJECT_ROOT: opts.projectRoot } : {},
|
|
10793
10733
|
...projectIndex !== void 0 ? { AGENTBOX_PROJECT_INDEX: String(projectIndex) } : {}
|
|
10794
10734
|
};
|
|
@@ -12063,7 +12003,8 @@ var dockerProvider = {
|
|
|
12063
12003
|
portless: po.portless,
|
|
12064
12004
|
portlessStateDir: po.portlessStateDir,
|
|
12065
12005
|
projectRoot: req.projectRoot,
|
|
12066
|
-
limits: req.limits ?? void 0
|
|
12006
|
+
limits: req.limits ?? void 0,
|
|
12007
|
+
credentialSync: req.credentialSync
|
|
12067
12008
|
};
|
|
12068
12009
|
const result = await createBox(opts);
|
|
12069
12010
|
return {
|
|
@@ -12113,6 +12054,9 @@ var dockerProvider = {
|
|
|
12113
12054
|
sync(box) {
|
|
12114
12055
|
return makeDockerSync({ container: box.container });
|
|
12115
12056
|
},
|
|
12057
|
+
syncTransport(box) {
|
|
12058
|
+
return createDockerSyncTransport({ container: box.container, image: box.image });
|
|
12059
|
+
},
|
|
12116
12060
|
async inspect(box) {
|
|
12117
12061
|
const insp = await inspectBox(box.id);
|
|
12118
12062
|
return {
|
|
@@ -12281,14 +12225,126 @@ var providerModule = {
|
|
|
12281
12225
|
provider: dockerProvider,
|
|
12282
12226
|
doctorChecks: dockerChecks
|
|
12283
12227
|
};
|
|
12284
|
-
var
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12228
|
+
var posixDirname2 = (rel) => {
|
|
12229
|
+
const d = dirname4(rel);
|
|
12230
|
+
return d === "." ? "" : d;
|
|
12231
|
+
};
|
|
12232
|
+
async function stageItemsFromVolume(volume, image, items, stagingDir) {
|
|
12233
|
+
if (items.length === 0) return;
|
|
12234
|
+
for (const item of items) {
|
|
12235
|
+
const parent = posixDirname2(item.rel);
|
|
12236
|
+
if (parent) await mkdir7(join16(stagingDir, parent), { recursive: true });
|
|
12237
|
+
}
|
|
12238
|
+
const uid = process.getuid?.() ?? 0;
|
|
12239
|
+
const gid = process.getgid?.() ?? 0;
|
|
12240
|
+
const cmds = items.map(
|
|
12241
|
+
(item) => item.kind === "dir" ? `mkdir -p '/stage/${item.rel}' && rsync -a --exclude=node_modules '/src/${item.rel}/' '/stage/${item.rel}/'` : `cp -a '/src/${item.rel}' '/stage/${item.rel}'`
|
|
12242
|
+
);
|
|
12243
|
+
cmds.push(`chown -R ${String(uid)}:${String(gid)} /stage`);
|
|
12244
|
+
const r = await execa(
|
|
12245
|
+
"docker",
|
|
12246
|
+
[
|
|
12247
|
+
"run",
|
|
12248
|
+
"--rm",
|
|
12249
|
+
"--user",
|
|
12250
|
+
"0",
|
|
12251
|
+
"-v",
|
|
12252
|
+
`${volume}:/src:ro`,
|
|
12253
|
+
"-v",
|
|
12254
|
+
`${stagingDir}:/stage`,
|
|
12255
|
+
image,
|
|
12256
|
+
"sh",
|
|
12257
|
+
"-c",
|
|
12258
|
+
cmds.join(" && ")
|
|
12259
|
+
],
|
|
12260
|
+
{ reject: false }
|
|
12261
|
+
);
|
|
12262
|
+
if (r.exitCode !== 0) {
|
|
12263
|
+
throw new Error(
|
|
12264
|
+
`failed to stage items from volume ${volume}: ${(r.stderr ?? "").toString().trim() || `exit ${String(r.exitCode)}`}`
|
|
12265
|
+
);
|
|
12266
|
+
}
|
|
12267
|
+
}
|
|
12268
|
+
function volumeSettingsTarget(volume, image, label) {
|
|
12269
|
+
const run = (args, input) => execa("docker", args, { reject: false, ...input === void 0 ? {} : { input } });
|
|
12270
|
+
return {
|
|
12271
|
+
label,
|
|
12272
|
+
async exists(rel) {
|
|
12273
|
+
const r = await run(["run", "--rm", "-v", `${volume}:/dst:ro`, image, "test", "-e", `/dst/${rel}`]);
|
|
12274
|
+
return r.exitCode === 0;
|
|
12275
|
+
},
|
|
12276
|
+
async readText(rel) {
|
|
12277
|
+
const r = await run([
|
|
12278
|
+
"run",
|
|
12279
|
+
"--rm",
|
|
12280
|
+
"--user",
|
|
12281
|
+
"0",
|
|
12282
|
+
"-v",
|
|
12283
|
+
`${volume}:/dst:ro`,
|
|
12284
|
+
image,
|
|
12285
|
+
"cat",
|
|
12286
|
+
`/dst/${rel}`
|
|
12287
|
+
]);
|
|
12288
|
+
return r.exitCode === 0 ? String(r.stdout ?? "") : null;
|
|
12289
|
+
},
|
|
12290
|
+
async writeText(rel, content, opts) {
|
|
12291
|
+
const parent = posixDirname2(rel);
|
|
12292
|
+
const chmod2 = opts?.mode !== void 0 ? ` && chmod ${opts.mode.toString(8)} '/dst/${rel}'` : "";
|
|
12293
|
+
const r = await run(
|
|
12294
|
+
[
|
|
12295
|
+
"run",
|
|
12296
|
+
"--rm",
|
|
12297
|
+
"-i",
|
|
12298
|
+
"--user",
|
|
12299
|
+
"0",
|
|
12300
|
+
"-v",
|
|
12301
|
+
`${volume}:/dst`,
|
|
12302
|
+
image,
|
|
12303
|
+
"sh",
|
|
12304
|
+
"-c",
|
|
12305
|
+
`${parent ? `mkdir -p '/dst/${parent}' && ` : ""}cat > '/dst/${rel}' && chown 1000:1000 '/dst/${rel}'${chmod2}`
|
|
12306
|
+
],
|
|
12307
|
+
content
|
|
12308
|
+
);
|
|
12309
|
+
if (r.exitCode !== 0) {
|
|
12310
|
+
throw new Error(
|
|
12311
|
+
`failed to write ${rel} into volume ${volume}: ${(r.stderr ?? "").toString().trim() || `exit ${String(r.exitCode)}`}`
|
|
12312
|
+
);
|
|
12313
|
+
}
|
|
12314
|
+
},
|
|
12315
|
+
async copyIn(stagingAbs, rel, kind) {
|
|
12316
|
+
const parent = posixDirname2(rel);
|
|
12317
|
+
const script = `${parent ? `mkdir -p '/dst/${parent}' && ` : ""}` + (kind === "dir" ? `mkdir -p '/dst/${rel}' && rsync -a --ignore-existing '/stage-item/' '/dst/${rel}/'` : `cp -a /stage-item '/dst/${rel}'`) + ` && chown -R 1000:1000 '/dst/${rel}'`;
|
|
12318
|
+
const r = await run([
|
|
12319
|
+
"run",
|
|
12320
|
+
"--rm",
|
|
12321
|
+
"--user",
|
|
12322
|
+
"0",
|
|
12323
|
+
"-v",
|
|
12324
|
+
`${stagingAbs}:/stage-item:ro`,
|
|
12325
|
+
"-v",
|
|
12326
|
+
`${volume}:/dst`,
|
|
12327
|
+
image,
|
|
12328
|
+
"sh",
|
|
12329
|
+
"-c",
|
|
12330
|
+
script
|
|
12331
|
+
]);
|
|
12332
|
+
if (r.exitCode !== 0) {
|
|
12333
|
+
throw new Error(
|
|
12334
|
+
`failed to copy ${rel} into volume ${volume}: ${(r.stderr ?? "").toString().trim() || `exit ${String(r.exitCode)}`}`
|
|
12335
|
+
);
|
|
12336
|
+
}
|
|
12337
|
+
}
|
|
12338
|
+
};
|
|
12339
|
+
}
|
|
12340
|
+
var STATE_DIR3 = join17(homedir12(), ".agentbox");
|
|
12341
|
+
var HUB_PID_FILE = join17(STATE_DIR3, "hub.pid");
|
|
12342
|
+
var HUB_LOG_FILE = join17(STATE_DIR3, "hub.log");
|
|
12343
|
+
var HUB_TOKEN_FILE = join17(STATE_DIR3, "hub", "token");
|
|
12288
12344
|
var PORT2 = DEFAULT_RELAY_PORT;
|
|
12289
12345
|
var HOST = "127.0.0.1";
|
|
12290
12346
|
var HUB_PORTLESS_ALIAS = "agentbox";
|
|
12291
|
-
var HUB_PORTLESS_FILE =
|
|
12347
|
+
var HUB_PORTLESS_FILE = join17(STATE_DIR3, "hub", "portless-url");
|
|
12292
12348
|
var NODE_MIN = { major: 22, minor: 5 };
|
|
12293
12349
|
function nodeVersion() {
|
|
12294
12350
|
const [major, minor] = process.versions.node.split(".").map((n) => Number.parseInt(n, 10));
|
|
@@ -12355,7 +12411,7 @@ async function syncHubPortless(enabled) {
|
|
|
12355
12411
|
if (!portless.installed) return await teardown();
|
|
12356
12412
|
await portlessAlias(HUB_PORTLESS_ALIAS, PORT2);
|
|
12357
12413
|
const url = await portlessGetUrl(HUB_PORTLESS_ALIAS);
|
|
12358
|
-
await mkdir8(
|
|
12414
|
+
await mkdir8(dirname5(HUB_PORTLESS_FILE), { recursive: true });
|
|
12359
12415
|
await writeFile4(HUB_PORTLESS_FILE, url, "utf8");
|
|
12360
12416
|
return url;
|
|
12361
12417
|
} catch {
|
|
@@ -12365,7 +12421,7 @@ async function syncHubPortless(enabled) {
|
|
|
12365
12421
|
function resolveHubServer() {
|
|
12366
12422
|
const override = process.env.AGENTBOX_HUB_BIN;
|
|
12367
12423
|
if (override && existsSync4(override)) return override;
|
|
12368
|
-
const here =
|
|
12424
|
+
const here = dirname5(fileURLToPath2(import.meta.url));
|
|
12369
12425
|
const candidates = [
|
|
12370
12426
|
resolve5(here, "..", "runtime", "hub", "apps", "hub", "server.js"),
|
|
12371
12427
|
resolve5(here, "..", "..", "..", "apps", "hub", "dist-standalone", "apps", "hub", "server.js"),
|
|
@@ -12798,6 +12854,8 @@ export {
|
|
|
12798
12854
|
dockerProvider,
|
|
12799
12855
|
dockerChecks,
|
|
12800
12856
|
providerModule,
|
|
12857
|
+
stageItemsFromVolume,
|
|
12858
|
+
volumeSettingsTarget,
|
|
12801
12859
|
resolveHubServer,
|
|
12802
12860
|
ensureHub,
|
|
12803
12861
|
stopHub,
|