@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.
Files changed (180) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -2
  4. package/dist/{_cloud-attach-D4OQO5AJ.js → _cloud-attach-T6GPR6LJ.js} +5 -5
  5. package/dist/{chunk-KY32JO6J.js → chunk-5KHEH47T.js} +91 -79
  6. package/dist/chunk-5KHEH47T.js.map +1 -0
  7. package/dist/{chunk-YRTM3KNT.js → chunk-6U2S6QWD.js} +219 -18
  8. package/dist/chunk-6U2S6QWD.js.map +1 -0
  9. package/dist/{chunk-JYEZ6Q5M.js → chunk-DEDTPG2D.js} +874 -146
  10. package/dist/chunk-DEDTPG2D.js.map +1 -0
  11. package/dist/chunk-G3H2L3O2.js +0 -0
  12. package/dist/{chunk-JNY5GPIM.js → chunk-I654PBHA.js} +290 -330
  13. package/dist/chunk-I654PBHA.js.map +1 -0
  14. package/dist/{chunk-6KOQRSHH.js → chunk-K2EDQGZP.js} +18 -4
  15. package/dist/chunk-K2EDQGZP.js.map +1 -0
  16. package/dist/{chunk-KZWJMNLP.js → chunk-LC4E2EIZ.js} +3 -3
  17. package/dist/{chunk-KZWJMNLP.js.map → chunk-LC4E2EIZ.js.map} +1 -1
  18. package/dist/{chunk-DADOEMXP.js → chunk-NACA6AM7.js} +183 -49
  19. package/dist/chunk-NACA6AM7.js.map +1 -0
  20. package/dist/{chunk-FX32NZD4.js → chunk-RYQLFKCP.js} +20 -10
  21. package/dist/chunk-RYQLFKCP.js.map +1 -0
  22. package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
  23. package/dist/chunk-UIRBYL4G.js.map +1 -0
  24. package/dist/chunk-WJFZJZIM.js +0 -0
  25. package/dist/chunk-WLHJZPFJ.js +845 -0
  26. package/dist/chunk-WLHJZPFJ.js.map +1 -0
  27. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  28. package/dist/dist-3KIJ2KQ2.js +1437 -0
  29. package/dist/dist-3KIJ2KQ2.js.map +1 -0
  30. package/dist/{dist-564EDHFF.js → dist-7OUOHQPA.js} +196 -151
  31. package/dist/dist-7OUOHQPA.js.map +1 -0
  32. package/dist/{dist-CAT2TN75.js → dist-B7TNWGVG.js} +8 -4
  33. package/dist/{dist-UDQMBWYW.js → dist-KYV3LEHG.js} +10 -6
  34. package/dist/{dist-EAR4BLL2.js → dist-PHYCFYKH.js} +37 -17
  35. package/dist/dist-PHYCFYKH.js.map +1 -0
  36. package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
  37. package/dist/{dist-O5Y4X4C5.js → dist-Z7KEPQC7.js} +6 -6
  38. package/dist/index.js +2560 -1108
  39. package/dist/index.js.map +1 -1
  40. package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
  41. package/package.json +28 -28
  42. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  43. package/runtime/_shared/agentbox-codex-hooks.json +1 -1
  44. package/runtime/_shared/agentbox-dockerd-start +0 -0
  45. package/runtime/_shared/agentbox-open +0 -0
  46. package/runtime/_shared/agentbox-portless-trust +0 -0
  47. package/runtime/_shared/agentbox-vnc-start +0 -0
  48. package/runtime/_shared/ctl.cjs +468 -97
  49. package/runtime/_shared/gh-shim +0 -0
  50. package/runtime/_shared/git-shim +53 -3
  51. package/runtime/_shared/linear-shim +0 -0
  52. package/runtime/_shared/ntn-shim +0 -0
  53. package/runtime/daytona/custom-system-CLAUDE.md +1 -1
  54. package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
  55. package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
  56. package/runtime/digitalocean/agentbox-dockerd-start +145 -0
  57. package/runtime/digitalocean/agentbox-open +28 -0
  58. package/runtime/digitalocean/agentbox-portless-trust +82 -0
  59. package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
  60. package/runtime/digitalocean/agentbox-vnc-start +102 -0
  61. package/runtime/digitalocean/claude-managed-settings.json +116 -0
  62. package/runtime/digitalocean/ctl.cjs +27852 -0
  63. package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
  64. package/runtime/digitalocean/gh-shim +344 -0
  65. package/runtime/digitalocean/git-shim +181 -0
  66. package/runtime/digitalocean/linear-shim +181 -0
  67. package/runtime/digitalocean/ntn-shim +95 -0
  68. package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
  69. package/runtime/digitalocean/scripts/install-box.sh +462 -0
  70. package/runtime/docker/Dockerfile.box +5 -0
  71. package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
  72. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  73. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
  74. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  75. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  76. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  77. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
  78. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  79. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  80. package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +2 -1
  81. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  82. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
  83. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  84. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  85. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  86. package/runtime/e2b/agentbox-codex-hooks.json +1 -1
  87. package/runtime/e2b/agentbox-dockerd-start +0 -0
  88. package/runtime/e2b/agentbox-open +0 -0
  89. package/runtime/e2b/agentbox-vnc-start +0 -0
  90. package/runtime/e2b/ctl.cjs +468 -97
  91. package/runtime/e2b/custom-system-CLAUDE.md +6 -3
  92. package/runtime/e2b/gh-shim +0 -0
  93. package/runtime/e2b/git-shim +53 -3
  94. package/runtime/e2b/linear-shim +0 -0
  95. package/runtime/e2b/ntn-shim +0 -0
  96. package/runtime/e2b/scripts/build-template.sh +16 -0
  97. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  98. package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
  99. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  100. package/runtime/hetzner/agentbox-open +0 -0
  101. package/runtime/hetzner/agentbox-portless-trust +0 -0
  102. package/runtime/hetzner/agentbox-vnc-start +0 -0
  103. package/runtime/hetzner/ctl.cjs +468 -97
  104. package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
  105. package/runtime/hetzner/gh-shim +0 -0
  106. package/runtime/hetzner/git-shim +53 -3
  107. package/runtime/hetzner/linear-shim +0 -0
  108. package/runtime/hetzner/ntn-shim +0 -0
  109. package/runtime/hetzner/scripts/install-box.sh +5 -0
  110. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  111. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  113. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  115. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  117. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  118. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  119. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  120. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
  121. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  122. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
  123. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
  124. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
  125. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  126. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
  127. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  128. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  129. package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
  130. package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
  131. package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
  132. package/runtime/hub/apps/hub/{chunk-FSEPYTQ6.js → chunk-3VE7AYVK.js} +594 -145
  133. package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
  134. package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
  135. package/runtime/hub/apps/hub/{chunk-7M6FXZIO.js → chunk-FGBXEXUV.js} +350 -292
  136. package/runtime/hub/apps/hub/{chunk-Z7ZAL24C.js → chunk-YVELHPNY.js} +218 -17
  137. package/runtime/hub/apps/hub/{dist-EKQHCXWE.js → dist-33ZNVTC6.js} +183 -49
  138. package/runtime/hub/apps/hub/{dist-V4TJ44MT.js → dist-4SXAJBOC.js} +195 -150
  139. package/runtime/hub/apps/hub/{dist-QIXUPGPP.js → dist-EPJFN2J3.js} +116 -86
  140. package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
  141. package/runtime/hub/apps/hub/{dist-JGZ55OIJ.js → dist-UJVIROA4.js} +19 -5
  142. package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
  143. package/runtime/hub/apps/hub/{dist-GGWYKXJE.js → dist-YM5J25H6.js} +7 -3
  144. package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
  145. package/runtime/hub/apps/hub/package.json +1 -0
  146. package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-UICXTY25.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
  147. package/runtime/hub/apps/hub/server.js +17 -15
  148. package/runtime/relay/bin.cjs +275 -59
  149. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  150. package/runtime/vercel/agentbox-codex-hooks.json +1 -1
  151. package/runtime/vercel/agentbox-dockerd-start +0 -0
  152. package/runtime/vercel/agentbox-open +0 -0
  153. package/runtime/vercel/agentbox-vnc-start +0 -0
  154. package/runtime/vercel/ctl.cjs +468 -97
  155. package/runtime/vercel/custom-system-CLAUDE.md +3 -2
  156. package/runtime/vercel/gh-shim +0 -0
  157. package/runtime/vercel/git-shim +53 -3
  158. package/runtime/vercel/linear-shim +0 -0
  159. package/runtime/vercel/ntn-shim +0 -0
  160. package/runtime/vercel/scripts/provision.sh +16 -0
  161. package/dist/chunk-6KOQRSHH.js.map +0 -1
  162. package/dist/chunk-DADOEMXP.js.map +0 -1
  163. package/dist/chunk-FX32NZD4.js.map +0 -1
  164. package/dist/chunk-JNY5GPIM.js.map +0 -1
  165. package/dist/chunk-JYEZ6Q5M.js.map +0 -1
  166. package/dist/chunk-KY32JO6J.js.map +0 -1
  167. package/dist/chunk-QT3SHMLY.js.map +0 -1
  168. package/dist/chunk-YRTM3KNT.js.map +0 -1
  169. package/dist/dist-564EDHFF.js.map +0 -1
  170. package/dist/dist-EAR4BLL2.js.map +0 -1
  171. package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
  172. /package/dist/{_cloud-attach-D4OQO5AJ.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
  173. /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
  174. /package/dist/{dist-CAT2TN75.js.map → dist-KYV3LEHG.js.map} +0 -0
  175. /package/dist/{dist-O5Y4X4C5.js.map → dist-T5MXBZGP.js.map} +0 -0
  176. /package/dist/{dist-UDQMBWYW.js.map → dist-Z7KEPQC7.js.map} +0 -0
  177. /package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
  178. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
  179. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
  180. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_ssgManifest.js +0 -0
@@ -8,23 +8,28 @@ import {
8
8
  projectDirSegment,
9
9
  sanitizeMnemonic,
10
10
  setConfigValue
11
- } from "./chunk-QT3SHMLY.js";
11
+ } from "./chunk-UIRBYL4G.js";
12
12
  import {
13
13
  AmbiguousBoxError,
14
14
  BOX_HOME,
15
15
  BUILD_CONTEXT_DIR,
16
16
  BoxNotFoundError,
17
+ CODEX_PULL_ITEMS,
17
18
  DEFAULT_BOX_IMAGE,
18
19
  DEFAULT_ENV_PATTERNS,
19
20
  ENV_PRUNE_DIRS,
20
21
  GitWorktreeError,
21
22
  MINIMAL_TRUSTED_CODEX_CONFIG,
23
+ OPENCODE_PULL_CONFIG_ITEMS,
24
+ OPENCODE_PULL_DATA_ITEMS,
22
25
  ReplaceError,
23
26
  STATE_DIR,
24
27
  STATE_FILE,
25
28
  SYNC_DRYRUN_ENV,
26
29
  addProjectAlias,
27
30
  claudeInstallFingerprint,
31
+ claudeInventoryScript,
32
+ computeClaudePullPlan,
28
33
  computeDockerContextFingerprint,
29
34
  detectGitRepos,
30
35
  dryRunProviderSync,
@@ -40,7 +45,9 @@ import {
40
45
  imageInfo,
41
46
  makeHostGitPorts,
42
47
  makeSyncContext,
48
+ mergeCodexConfigForBox,
43
49
  mintSshKey,
50
+ parseClaudeInventory,
44
51
  parseReplaceRules,
45
52
  parseReplacements,
46
53
  pickFreshBranch,
@@ -52,6 +59,7 @@ import {
52
59
  readPreparedDockerState,
53
60
  readState,
54
61
  recordBox,
62
+ referencedPluginVersionKeys,
55
63
  removeBoxRecord,
56
64
  renderCarryEntries,
57
65
  reserveProjectIndex,
@@ -60,18 +68,19 @@ import {
60
68
  seedAgentsVolume,
61
69
  setInstallMethodNative,
62
70
  syncAgentboxSshConfig,
63
- trustWorkspace
64
- } from "./chunk-JYEZ6Q5M.js";
71
+ trustWorkspace,
72
+ writeClaudeMergedRegistries
73
+ } from "./chunk-DEDTPG2D.js";
65
74
 
66
75
  // ../../packages/sandbox-docker/dist/index.js
67
76
  import { spawnSync } from "child_process";
68
- import { mkdir as mkdir2, mkdtemp as mkdtemp2, readdir as readdir2, readFile as readFile22, rm as rm2, stat as stat2, writeFile as writeFile2 } from "fs/promises";
77
+ import { mkdtemp as mkdtemp2, readdir as readdir2, readFile as readFile22, rm as rm2, stat as stat2, writeFile as writeFile2 } from "fs/promises";
69
78
  import { homedir as homedir2, tmpdir as tmpdir2 } from "os";
70
79
  import { join as join3 } from "path";
71
80
  import { setTimeout as delay } from "timers/promises";
72
81
  import { execa as execa5 } from "execa";
73
- import { execa as execa2 } from "execa";
74
- import { mkdir as mkdir3, readFile as readFile4, readdir as readdir3, stat } from "fs/promises";
82
+ import { execa as execa3 } from "execa";
83
+ import { mkdir as mkdir2, readFile as readFile4, readdir as readdir3, stat } from "fs/promises";
75
84
  import { createHash as createHash2 } from "crypto";
76
85
  import { homedir } from "os";
77
86
  import { dirname as dirname2, join as join22 } from "path";
@@ -83,8 +92,8 @@ import { createReadStream } from "fs";
83
92
  import { mkdtemp, rm } from "fs/promises";
84
93
  import { tmpdir } from "os";
85
94
  import { join } from "path";
86
- import { execa as execa3 } from "execa";
87
- import { chmod, mkdir as mkdir32 } from "fs/promises";
95
+ import { execa as execa32 } from "execa";
96
+ import { chmod, mkdir as mkdir22 } from "fs/promises";
88
97
  import { basename as basename2, join as join4 } from "path";
89
98
  import { execa as execa6 } from "execa";
90
99
  import { spawnSync as spawnSync2 } from "child_process";
@@ -100,7 +109,7 @@ import { homedir as homedir5 } from "os";
100
109
  import { join as join7 } from "path";
101
110
  import { execa as execa8 } from "execa";
102
111
  import { execa as execa9 } from "execa";
103
- import { mkdir as mkdir7, stat as stat7 } from "fs/promises";
112
+ import { mkdir as mkdir6, stat as stat7 } from "fs/promises";
104
113
  import { homedir as homedir10 } from "os";
105
114
  import { basename as basename4, join as join12, resolve as resolve4 } from "path";
106
115
  import { execa as execa16 } from "execa";
@@ -994,10 +1003,10 @@ import { homedir as homedir6 } from "os";
994
1003
  import { join as join8 } from "path";
995
1004
  import { execa as execa11 } from "execa";
996
1005
  import { execa as execa12 } from "execa";
997
- import { mkdir as mkdir4, readdir as readdir32, rm as rm3, stat as stat5 } from "fs/promises";
1006
+ import { mkdir as mkdir3, readdir as readdir32, rm as rm3, stat as stat5 } from "fs/promises";
998
1007
  import { homedir as homedir7, platform } from "os";
999
1008
  import { join as join9, resolve as resolve2 } from "path";
1000
- import { mkdir as mkdir5, mkdtemp as mkdtemp3, readFile as readFile5, readdir as readdir4, rm as rm4, writeFile as writeFile22 } from "fs/promises";
1009
+ import { mkdir as mkdir4, mkdtemp as mkdtemp3, readFile as readFile5, readdir as readdir4, rm as rm4, writeFile as writeFile22 } from "fs/promises";
1001
1010
  import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
1002
1011
  import { basename as basename3, join as join10 } from "path";
1003
1012
  import { execa as execa13 } from "execa";
@@ -1007,7 +1016,7 @@ import { execa as execa15 } from "execa";
1007
1016
  import { spawn } from "child_process";
1008
1017
  import { randomBytes as randomBytes22 } from "crypto";
1009
1018
  import { existsSync as existsSync3, openSync } from "fs";
1010
- import { cp, mkdir as mkdir6, readFile as readFile6, readdir as readdir5, rename as rename2, rm as rm5, unlink as unlink2, writeFile as writeFile3 } from "fs/promises";
1019
+ import { cp, mkdir as mkdir5, readFile as readFile6, readdir as readdir5, rename as rename2, rm as rm5, unlink as unlink2, writeFile as writeFile3 } from "fs/promises";
1011
1020
  import { request as httpRequest } from "http";
1012
1021
  import { createRequire } from "module";
1013
1022
  import { homedir as homedir9 } from "os";
@@ -1517,7 +1526,7 @@ function rowToEvent(r) {
1517
1526
  };
1518
1527
  }
1519
1528
 
1520
- // ../../packages/relay/dist/chunk-4YDQV7UG.js
1529
+ // ../../packages/relay/dist/chunk-LH565Z3T.js
1521
1530
  import { execa } from "execa";
1522
1531
  import { createHash, randomBytes } from "crypto";
1523
1532
 
@@ -1791,7 +1800,8 @@ function isBodyAssignment(token) {
1791
1800
  }
1792
1801
  var ALL_CONNECTORS = [notionConnector, linearConnector];
1793
1802
 
1794
- // ../../packages/relay/dist/chunk-4YDQV7UG.js
1803
+ // ../../packages/relay/dist/chunk-LH565Z3T.js
1804
+ import { execa as execa2 } from "execa";
1795
1805
  import { spawn as spawn4 } from "child_process";
1796
1806
  import { randomBytes as randomBytes2 } from "crypto";
1797
1807
  import {
@@ -2067,105 +2077,18 @@ import { homedir as homedir11 } from "os";
2067
2077
  import { join as join15 } from "path";
2068
2078
  import { execa as execa19 } from "execa";
2069
2079
  import { execa as execa20 } from "execa";
2080
+ import { mkdir as mkdir7 } from "fs/promises";
2081
+ import { dirname as dirname4, join as join16 } from "path";
2082
+ import { execa as execa21 } from "execa";
2070
2083
  import { spawn as spawn2 } from "child_process";
2071
2084
  import { existsSync as existsSync4, openSync as openSync2 } from "fs";
2072
2085
  import { mkdir as mkdir8, readFile as readFile7, unlink as unlink22, writeFile as writeFile4 } from "fs/promises";
2073
2086
  import { homedir as homedir12 } from "os";
2074
- import { dirname as dirname4, join as join16, resolve as resolve5 } from "path";
2087
+ import { dirname as dirname5, join as join17, resolve as resolve5 } from "path";
2075
2088
  import { setTimeout as delay3 } from "timers/promises";
2076
2089
  import { fileURLToPath as fileURLToPath2 } from "url";
2077
- var SKILL_EXCLUDE_PREFIXES = ["agentbox-"];
2078
- var CONTAINER_PLUGINS_PREFIX = "/home/vscode/.claude/plugins/";
2079
- function pickNewItems(boxNames, hostNames, excludePrefixes = []) {
2080
- const host = new Set(hostNames);
2081
- const seen = /* @__PURE__ */ new Set();
2082
- const out = [];
2083
- for (const name of boxNames) {
2084
- if (name.length === 0 || host.has(name) || seen.has(name)) continue;
2085
- if (excludePrefixes.some((p) => name.startsWith(p))) continue;
2086
- seen.add(name);
2087
- out.push(name);
2088
- }
2089
- return out.sort();
2090
- }
2091
- function rewritePluginPaths(value, hostPluginsPrefix) {
2092
- if (typeof value === "string") {
2093
- return value.split(CONTAINER_PLUGINS_PREFIX).join(hostPluginsPrefix);
2094
- }
2095
- if (Array.isArray(value)) {
2096
- return value.map((v) => rewritePluginPaths(v, hostPluginsPrefix));
2097
- }
2098
- if (value !== null && typeof value === "object") {
2099
- const out = {};
2100
- for (const [k, v] of Object.entries(value)) {
2101
- out[k] = rewritePluginPaths(v, hostPluginsPrefix);
2102
- }
2103
- return out;
2104
- }
2105
- return value;
2106
- }
2107
- function isPlainObject4(v) {
2108
- return v !== null && typeof v === "object" && !Array.isArray(v);
2109
- }
2110
- function additiveMerge(hostRoot, boxRoot, hostPluginsPrefix, selectMap, withMap) {
2111
- const hostMap = selectMap(hostRoot);
2112
- const boxMap = selectMap(boxRoot);
2113
- if (!isPlainObject4(boxMap)) {
2114
- return { data: hostRoot, changed: false, addedKeys: [] };
2115
- }
2116
- const base = isPlainObject4(hostMap) ? { ...hostMap } : {};
2117
- const addedKeys = [];
2118
- for (const [key, value] of Object.entries(boxMap)) {
2119
- if (Object.prototype.hasOwnProperty.call(base, key)) continue;
2120
- base[key] = rewritePluginPaths(value, hostPluginsPrefix);
2121
- addedKeys.push(key);
2122
- }
2123
- if (addedKeys.length === 0) {
2124
- return { data: hostRoot, changed: false, addedKeys: [] };
2125
- }
2126
- return { data: withMap(hostRoot, base), changed: true, addedKeys: addedKeys.sort() };
2127
- }
2128
- function mergeKnownMarketplaces(hostJson, boxJson, opts) {
2129
- const prefix = `${opts.hostHome}/.claude/plugins/`;
2130
- return additiveMerge(
2131
- isPlainObject4(hostJson) ? hostJson : {},
2132
- boxJson,
2133
- prefix,
2134
- (root) => root,
2135
- (_host, merged) => merged
2136
- );
2137
- }
2138
- function mergeInstalledPlugins(hostJson, boxJson, opts) {
2139
- const prefix = `${opts.hostHome}/.claude/plugins/`;
2140
- const hostRoot = isPlainObject4(hostJson) ? hostJson : { plugins: {} };
2141
- return additiveMerge(
2142
- hostRoot,
2143
- boxJson,
2144
- prefix,
2145
- (root) => isPlainObject4(root) ? root["plugins"] : void 0,
2146
- (host, merged) => ({ ...host, plugins: merged })
2147
- );
2148
- }
2149
- function referencedPluginVersionKeys(installedPluginsJson) {
2150
- const keys = /* @__PURE__ */ new Set();
2151
- if (!isPlainObject4(installedPluginsJson)) return keys;
2152
- const plugins = installedPluginsJson["plugins"];
2153
- if (!isPlainObject4(plugins)) return keys;
2154
- for (const entries of Object.values(plugins)) {
2155
- if (!Array.isArray(entries)) continue;
2156
- for (const entry of entries) {
2157
- if (!isPlainObject4(entry)) continue;
2158
- const installPath = entry["installPath"];
2159
- if (typeof installPath !== "string") continue;
2160
- const segments = installPath.split("/").filter((s) => s.length > 0);
2161
- if (segments.length < 3) continue;
2162
- keys.add(segments.slice(-3).join("/"));
2163
- }
2164
- }
2165
- return keys;
2166
- }
2167
2090
  async function dockerInfo() {
2168
- const result = await execa2("docker", ["info"], { reject: false });
2091
+ const result = await execa3("docker", ["info"], { reject: false });
2169
2092
  if (result.exitCode !== 0) {
2170
2093
  throw new Error(
2171
2094
  `docker info failed (exit ${String(result.exitCode)}). Is the Docker daemon running?
@@ -2241,11 +2164,11 @@ async function runBox(spec) {
2241
2164
  args.push("-e", `${k}=${val}`);
2242
2165
  }
2243
2166
  args.push(spec.image, "sleep", "infinity");
2244
- const { stdout } = await execa2("docker", args);
2167
+ const { stdout } = await execa3("docker", args);
2245
2168
  return stdout.trim();
2246
2169
  }
2247
2170
  async function dockerStorageDriver() {
2248
- const result = await execa2("docker", ["info", "--format", "{{.Driver}}"], { reject: false });
2171
+ const result = await execa3("docker", ["info", "--format", "{{.Driver}}"], { reject: false });
2249
2172
  if (result.exitCode !== 0) return "";
2250
2173
  return (result.stdout ?? "").trim();
2251
2174
  }
@@ -2254,7 +2177,7 @@ async function execInBox(container, cmd, opts = {}) {
2254
2177
  if (opts.detach) args.push("-d");
2255
2178
  if (opts.user) args.push("--user", opts.user);
2256
2179
  args.push(container, ...cmd);
2257
- const result = await execa2("docker", args, {
2180
+ const result = await execa3("docker", args, {
2258
2181
  reject: false,
2259
2182
  ...opts.timeoutMs ? { timeout: opts.timeoutMs } : {}
2260
2183
  });
@@ -2265,49 +2188,49 @@ async function execInBox(container, cmd, opts = {}) {
2265
2188
  };
2266
2189
  }
2267
2190
  async function removeContainer(container) {
2268
- await execa2("docker", ["rm", "-f", container], { reject: false });
2191
+ await execa3("docker", ["rm", "-f", container], { reject: false });
2269
2192
  }
2270
2193
  async function removeVolume(name) {
2271
- await execa2("docker", ["volume", "rm", name], { reject: false });
2194
+ await execa3("docker", ["volume", "rm", name], { reject: false });
2272
2195
  }
2273
2196
  async function removeImage(ref, opts = {}) {
2274
2197
  const args = ["image", "rm"];
2275
2198
  if (opts.force !== false) args.push("-f");
2276
2199
  args.push(ref);
2277
- const result = await execa2("docker", args, { reject: false });
2200
+ const result = await execa3("docker", args, { reject: false });
2278
2201
  return result.exitCode === 0;
2279
2202
  }
2280
2203
  async function containerExists(name) {
2281
- const result = await execa2("docker", ["container", "inspect", "--format", "{{.Id}}", name], {
2204
+ const result = await execa3("docker", ["container", "inspect", "--format", "{{.Id}}", name], {
2282
2205
  reject: false
2283
2206
  });
2284
2207
  return result.exitCode === 0;
2285
2208
  }
2286
2209
  async function volumeExists(name) {
2287
- const result = await execa2("docker", ["volume", "inspect", name], { reject: false });
2210
+ const result = await execa3("docker", ["volume", "inspect", name], { reject: false });
2288
2211
  return result.exitCode === 0;
2289
2212
  }
2290
2213
  async function ensureVolume(name) {
2291
2214
  if (await volumeExists(name)) return;
2292
- await execa2("docker", ["volume", "create", name]);
2215
+ await execa3("docker", ["volume", "create", name]);
2293
2216
  }
2294
2217
  async function removeNetwork(name) {
2295
- await execa2("docker", ["network", "rm", name], { reject: false });
2218
+ await execa3("docker", ["network", "rm", name], { reject: false });
2296
2219
  }
2297
2220
  async function pauseContainer(name) {
2298
- await execa2("docker", ["pause", name]);
2221
+ await execa3("docker", ["pause", name]);
2299
2222
  }
2300
2223
  async function unpauseContainer(name) {
2301
- await execa2("docker", ["unpause", name]);
2224
+ await execa3("docker", ["unpause", name]);
2302
2225
  }
2303
2226
  async function stopContainer(name) {
2304
- await execa2("docker", ["stop", name]);
2227
+ await execa3("docker", ["stop", name]);
2305
2228
  }
2306
2229
  async function startContainer(name) {
2307
- await execa2("docker", ["start", name]);
2230
+ await execa3("docker", ["start", name]);
2308
2231
  }
2309
2232
  async function inspectContainerStatus(name) {
2310
- const result = await execa2("docker", ["inspect", "--format", "{{.State.Status}}", name], {
2233
+ const result = await execa3("docker", ["inspect", "--format", "{{.State.Status}}", name], {
2311
2234
  reject: false
2312
2235
  });
2313
2236
  if (result.exitCode !== 0) return "missing";
@@ -2328,7 +2251,7 @@ async function inspectContainerStatus(name) {
2328
2251
  }
2329
2252
  }
2330
2253
  async function inspectContainer(name) {
2331
- const result = await execa2("docker", ["inspect", name], { reject: false });
2254
+ const result = await execa3("docker", ["inspect", name], { reject: false });
2332
2255
  if (result.exitCode !== 0) return null;
2333
2256
  try {
2334
2257
  const parsed = JSON.parse(result.stdout ?? "null");
@@ -2338,7 +2261,7 @@ async function inspectContainer(name) {
2338
2261
  }
2339
2262
  }
2340
2263
  async function inspectVolumeMountpoint(name) {
2341
- const result = await execa2("docker", ["volume", "inspect", "--format", "{{.Mountpoint}}", name], {
2264
+ const result = await execa3("docker", ["volume", "inspect", "--format", "{{.Mountpoint}}", name], {
2342
2265
  reject: false
2343
2266
  });
2344
2267
  if (result.exitCode !== 0) return null;
@@ -2346,7 +2269,7 @@ async function inspectVolumeMountpoint(name) {
2346
2269
  }
2347
2270
  var AGENTBOX_PREFIX = "agentbox-";
2348
2271
  async function listAgentboxContainers() {
2349
- const result = await execa2(
2272
+ const result = await execa3(
2350
2273
  "docker",
2351
2274
  ["ps", "-a", "--filter", `name=^${AGENTBOX_PREFIX}`, "--format", "{{.Names}}"],
2352
2275
  { reject: false }
@@ -2355,7 +2278,7 @@ async function listAgentboxContainers() {
2355
2278
  return (result.stdout ?? "").split("\n").map((s) => s.trim()).filter((s) => s.startsWith(AGENTBOX_PREFIX));
2356
2279
  }
2357
2280
  async function publishedHostPort(container, containerPort) {
2358
- const result = await execa2("docker", ["port", container, `${String(containerPort)}/tcp`], {
2281
+ const result = await execa3("docker", ["port", container, `${String(containerPort)}/tcp`], {
2359
2282
  reject: false
2360
2283
  });
2361
2284
  if (result.exitCode !== 0) return null;
@@ -2365,7 +2288,7 @@ async function publishedHostPort(container, containerPort) {
2365
2288
  return m ? Number(m[1]) : null;
2366
2289
  }
2367
2290
  async function listAgentboxVolumes() {
2368
- const result = await execa2(
2291
+ const result = await execa3(
2369
2292
  "docker",
2370
2293
  ["volume", "ls", "--filter", `name=^${AGENTBOX_PREFIX}`, "--format", "{{.Name}}"],
2371
2294
  { reject: false }
@@ -2661,7 +2584,7 @@ function createDockerSyncTransport(init) {
2661
2584
  const transport = {
2662
2585
  caps: DOCKER_CAPS,
2663
2586
  async exec(cmd, opts) {
2664
- const r = await execa3("docker", [...execArgsPrefix(opts), container, ...cmd], {
2587
+ const r = await execa32("docker", [...execArgsPrefix(opts), container, ...cmd], {
2665
2588
  reject: false
2666
2589
  });
2667
2590
  return {
@@ -2675,7 +2598,7 @@ function createDockerSyncTransport(init) {
2675
2598
  const tarArgs = ["tar", "-xf", "-", "-C", boxDestDir];
2676
2599
  if (opts?.noSamePerms) tarArgs.push("--no-same-permissions", "--no-same-owner", "-m");
2677
2600
  const args = ["exec", "-i", "--user", `${uid}:${uid}`, container, ...tarArgs];
2678
- const r = await execa3("docker", args, { input: createReadStream(hostTarPath), reject: false });
2601
+ const r = await execa32("docker", args, { input: createReadStream(hostTarPath), reject: false });
2679
2602
  if (r.exitCode !== 0) {
2680
2603
  throw new Error(`docker tar extract into ${boxDestDir} failed: ${String(r.stderr).slice(0, 300)}`);
2681
2604
  }
@@ -2687,7 +2610,7 @@ function createDockerSyncTransport(init) {
2687
2610
  const packArgs = ["-C", hostSrcDir];
2688
2611
  for (const ex of opts?.exclude ?? []) packArgs.push(`--exclude=${ex}`);
2689
2612
  packArgs.push("-cf", localTar, ".");
2690
- const packed = await execa3("tar", packArgs, { reject: false });
2613
+ const packed = await execa32("tar", packArgs, { reject: false });
2691
2614
  if (packed.exitCode !== 0) {
2692
2615
  throw new Error(`tar pack of ${hostSrcDir} failed: ${String(packed.stderr).slice(0, 300)}`);
2693
2616
  }
@@ -2697,7 +2620,7 @@ function createDockerSyncTransport(init) {
2697
2620
  }
2698
2621
  },
2699
2622
  async pushFile(hostSrcPath, boxDestPath, opts) {
2700
- const cp2 = await execa3("docker", ["cp", hostSrcPath, `${container}:${boxDestPath}`], {
2623
+ const cp2 = await execa32("docker", ["cp", hostSrcPath, `${container}:${boxDestPath}`], {
2701
2624
  reject: false
2702
2625
  });
2703
2626
  if (cp2.exitCode !== 0) {
@@ -2714,17 +2637,17 @@ function createDockerSyncTransport(init) {
2714
2637
  const tarArgs = ["exec", container, "tar", "-C", boxSrcDir];
2715
2638
  for (const ex of opts?.exclude ?? []) tarArgs.push(`--exclude=${ex}`);
2716
2639
  tarArgs.push("-cf", "-", ".");
2717
- const packed = await execa3("docker", tarArgs, { encoding: "buffer", reject: false });
2640
+ const packed = await execa32("docker", tarArgs, { encoding: "buffer", reject: false });
2718
2641
  if (packed.exitCode !== 0) {
2719
2642
  throw new Error(`docker tar of ${boxSrcDir} failed: ${String(packed.stderr).slice(0, 300)}`);
2720
2643
  }
2721
- await execa3("tar", ["-xf", "-", "-C", hostDestDir], {
2644
+ await execa32("tar", ["-xf", "-", "-C", hostDestDir], {
2722
2645
  input: packed.stdout,
2723
2646
  reject: false
2724
2647
  });
2725
2648
  },
2726
2649
  async pullFile(boxSrcPath, hostDestPath) {
2727
- const cp2 = await execa3("docker", ["cp", `${container}:${boxSrcPath}`, hostDestPath], {
2650
+ const cp2 = await execa32("docker", ["cp", `${container}:${boxSrcPath}`, hostDestPath], {
2728
2651
  reject: false
2729
2652
  });
2730
2653
  if (cp2.exitCode !== 0) {
@@ -2732,12 +2655,12 @@ function createDockerSyncTransport(init) {
2732
2655
  }
2733
2656
  },
2734
2657
  async readText(boxPath) {
2735
- const r = await execa3("docker", ["exec", container, "cat", boxPath], { reject: false });
2658
+ const r = await execa32("docker", ["exec", container, "cat", boxPath], { reject: false });
2736
2659
  if (r.exitCode !== 0) return null;
2737
2660
  return String(r.stdout ?? "");
2738
2661
  },
2739
2662
  async ensureVolume(name) {
2740
- await execa3("docker", ["volume", "create", name], { reject: false });
2663
+ await execa32("docker", ["volume", "create", name], { reject: false });
2741
2664
  return { volumeId: name };
2742
2665
  },
2743
2666
  async seedVolumeFromHost(volume, sources) {
@@ -2757,7 +2680,7 @@ function createDockerSyncTransport(init) {
2757
2680
  });
2758
2681
  steps.push("chown -R 1000:1000 /dst");
2759
2682
  args.push(init.image, "sh", "-c", steps.join(" && "));
2760
- const r = await execa3("docker", args, { reject: false });
2683
+ const r = await execa32("docker", args, { reject: false });
2761
2684
  if (r.exitCode !== 0) {
2762
2685
  throw new Error(`seedVolumeFromHost(${volume}) failed: ${String(r.stderr).slice(0, 300)}`);
2763
2686
  }
@@ -2829,7 +2752,7 @@ async function hasContainerPath(container, path) {
2829
2752
  async function refreshExport(record, opts = {}) {
2830
2753
  const paths = await getHostPaths(record);
2831
2754
  const excludeNodeModules = !opts.includeNodeModules;
2832
- await mkdir3(paths.mergedExport, { recursive: true });
2755
+ await mkdir2(paths.mergedExport, { recursive: true });
2833
2756
  const bindAvailable = await hasContainerPath(record.container, CONTAINER_EXPORT_MERGED);
2834
2757
  if (bindAvailable) {
2835
2758
  const args = ["rsync", "-a", "--delete"];
@@ -2943,7 +2866,7 @@ async function pullToHost(record, opts = {}) {
2943
2866
  let scratchDir;
2944
2867
  if (opts.noRefresh) {
2945
2868
  scratchDir = paths.mergedExport;
2946
- await mkdir3(scratchDir, { recursive: true });
2869
+ await mkdir2(scratchDir, { recursive: true });
2947
2870
  } else {
2948
2871
  const refreshed = await refreshExport(record, {
2949
2872
  includeNodeModules: opts.includeNodeModules
@@ -3022,7 +2945,7 @@ async function openInFinder(record, opts) {
3022
2945
  if (opts.noRefresh) {
3023
2946
  const paths = await getHostPaths(record);
3024
2947
  hostPath = paths.mergedExport;
3025
- await mkdir3(hostPath, { recursive: true });
2948
+ await mkdir2(hostPath, { recursive: true });
3026
2949
  } else {
3027
2950
  const refreshed = await refreshExport(record, opts);
3028
2951
  hostPath = refreshed.hostPath;
@@ -3158,7 +3081,9 @@ async function copyOneEntry(container, entry) {
3158
3081
  "--no-same-permissions",
3159
3082
  "--no-same-owner",
3160
3083
  "-m"
3161
- ]
3084
+ ],
3085
+ // COPYFILE_DISABLE silences macOS BSD tar's `._*` resource-fork stubs.
3086
+ { ...process.env, COPYFILE_DISABLE: "1" }
3162
3087
  );
3163
3088
  if (packed.exitCode !== 0) {
3164
3089
  throw new Error(`tar pack failed: ${String(packed.stderr).slice(0, 300)}`);
@@ -3196,7 +3121,9 @@ async function copyOneEntry(container, entry) {
3196
3121
  "--no-same-permissions",
3197
3122
  "--no-same-owner",
3198
3123
  "-m"
3199
- ]
3124
+ ],
3125
+ // COPYFILE_DISABLE silences macOS BSD tar's `._*` resource-fork stubs.
3126
+ { ...process.env, COPYFILE_DISABLE: "1" }
3200
3127
  );
3201
3128
  if (packed.exitCode !== 0) {
3202
3129
  throw new Error(`tar pack failed: ${String(packed.stderr).slice(0, 300)}`);
@@ -3963,52 +3890,11 @@ async function claudeSessionInfo(container, sessionName) {
3963
3890
  }
3964
3891
  return { running: true, sessionName: name, startedAt };
3965
3892
  }
3966
- var PULL_DIR_CATEGORIES = ["skills", "agents", "commands"];
3967
- async function listChildDirs(dir) {
3968
- try {
3969
- const entries = await readdir2(dir, { withFileTypes: true });
3970
- return entries.filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => e.name);
3971
- } catch {
3972
- return [];
3973
- }
3974
- }
3975
- async function readJsonFile(path) {
3976
- try {
3977
- return JSON.parse(await readFile22(path, "utf8"));
3978
- } catch {
3979
- return void 0;
3980
- }
3981
- }
3982
3893
  async function pullClaudeExtras(spec, opts) {
3983
- const hostHome = homedir2();
3984
- const hostClaude = join3(hostHome, ".claude");
3985
- const inventoryScript = [
3986
- "for cat in skills agents commands; do",
3987
- ' [ -d "/src/$cat" ] || continue;',
3988
- ' for d in "/src/$cat"/*/; do',
3989
- ' [ -d "$d" ] || continue;',
3990
- ' printf "DIR %s %s\\n" "$cat" "$(basename "$d")";',
3991
- " done;",
3992
- "done;",
3993
- "if [ -d /src/plugins/cache ]; then",
3994
- " for m in /src/plugins/cache/*/; do",
3995
- ' [ -d "$m" ] || continue;',
3996
- ' for p in "$m"*/; do',
3997
- ' [ -d "$p" ] || continue;',
3998
- ' printf "PLUGIN %s/%s\\n" "$(basename "$m")" "$(basename "$p")";',
3999
- " done;",
4000
- " done;",
4001
- "fi;",
4002
- "for f in installed_plugins known_marketplaces; do",
4003
- ' [ -f "/src/plugins/$f.json" ] || continue;',
4004
- ' printf "JSON %s " "$f";',
4005
- ' base64 -w0 "/src/plugins/$f.json";',
4006
- ' printf "\\n";',
4007
- "done"
4008
- ].join(" ");
3894
+ const hostClaude = join3(homedir2(), ".claude");
4009
3895
  const inv = await execa5(
4010
3896
  "docker",
4011
- ["run", "--rm", "--user", "0", "-v", `${spec.volume}:/src:ro`, opts.image, "sh", "-c", inventoryScript],
3897
+ ["run", "--rm", "--user", "0", "-v", `${spec.volume}:/src:ro`, opts.image, "sh", "-c", claudeInventoryScript("/src")],
4012
3898
  { reject: false }
4013
3899
  );
4014
3900
  if (inv.exitCode !== 0) {
@@ -4016,68 +3902,18 @@ async function pullClaudeExtras(spec, opts) {
4016
3902
  `failed to read claude-config volume ${spec.volume}: ${(inv.stderr ?? "").toString().trim() || `exit ${String(inv.exitCode)}`}`
4017
3903
  );
4018
3904
  }
4019
- const boxDirs = { skills: [], agents: [], commands: [] };
4020
- const boxPlugins = [];
4021
- const boxJson = {};
4022
- for (const line of (inv.stdout ?? "").split("\n")) {
4023
- if (line.startsWith("DIR ")) {
4024
- const rest = line.slice(4);
4025
- const sp = rest.indexOf(" ");
4026
- if (sp === -1) continue;
4027
- const cat = rest.slice(0, sp);
4028
- const name = rest.slice(sp + 1);
4029
- if (cat in boxDirs) boxDirs[cat].push(name);
4030
- } else if (line.startsWith("PLUGIN ")) {
4031
- boxPlugins.push(line.slice(7));
4032
- } else if (line.startsWith("JSON ")) {
4033
- const rest = line.slice(5);
4034
- const sp = rest.indexOf(" ");
4035
- if (sp === -1) continue;
4036
- const which = rest.slice(0, sp);
4037
- try {
4038
- boxJson[which] = JSON.parse(Buffer.from(rest.slice(sp + 1), "base64").toString("utf8"));
4039
- } catch {
4040
- }
4041
- }
4042
- }
4043
- const newItems = [];
4044
- const applyPaths = [];
4045
- for (const cat of PULL_DIR_CATEGORIES) {
4046
- const hostNames = await listChildDirs(join3(hostClaude, cat));
4047
- const excludes = cat === "skills" ? SKILL_EXCLUDE_PREFIXES : [];
4048
- for (const name of pickNewItems(boxDirs[cat] ?? [], hostNames, excludes)) {
4049
- newItems.push({ category: cat, name });
4050
- applyPaths.push({ src: `/src/${cat}/${name}`, dest: `/dst/${cat}/${name}` });
4051
- }
4052
- }
4053
- const hostPluginKeys = [];
4054
- for (const m of await listChildDirs(join3(hostClaude, "plugins", "cache"))) {
4055
- for (const p of await listChildDirs(join3(hostClaude, "plugins", "cache", m))) {
4056
- hostPluginKeys.push(`${m}/${p}`);
4057
- }
4058
- }
4059
- for (const key of pickNewItems(boxPlugins, hostPluginKeys)) {
4060
- newItems.push({ category: "plugins", name: key });
4061
- applyPaths.push({ src: `/src/plugins/cache/${key}`, dest: `/dst/plugins/cache/${key}` });
4062
- }
4063
- const hostInstalled = await readJsonFile(join3(hostClaude, "plugins", "installed_plugins.json"));
4064
- const hostMarkets = await readJsonFile(join3(hostClaude, "plugins", "known_marketplaces.json"));
4065
- const mergedInstalled = mergeInstalledPlugins(hostInstalled, boxJson["installed_plugins"], {
4066
- hostHome
4067
- });
4068
- const mergedMarkets = mergeKnownMarketplaces(hostMarkets, boxJson["known_marketplaces"], {
4069
- hostHome
4070
- });
4071
- const mergedRegistries = [];
4072
- if (mergedInstalled.changed) mergedRegistries.push("installed_plugins.json");
4073
- if (mergedMarkets.changed) mergedRegistries.push("known_marketplaces.json");
3905
+ const inventory = parseClaudeInventory((inv.stdout ?? "").toString());
3906
+ const plan = await computeClaudePullPlan(inventory);
3907
+ const { newItems, mergedRegistries } = plan;
3908
+ const sourceRegistries = inventory.registries;
4074
3909
  if (opts.dryRun || newItems.length === 0 && mergedRegistries.length === 0) {
4075
- return { newItems, mergedRegistries };
3910
+ return { newItems, mergedRegistries, sourceRegistries };
4076
3911
  }
4077
- if (applyPaths.length > 0) {
4078
- const cmds = applyPaths.map(({ src, dest }) => {
3912
+ if (plan.copyRels.length > 0) {
3913
+ const cmds = plan.copyRels.map((rel) => {
3914
+ const dest = `/dst/${rel}`;
4079
3915
  const parent = dest.slice(0, dest.lastIndexOf("/"));
4080
- return `mkdir -p '${parent}' && rsync -a --ignore-existing --exclude=node_modules '${src}/' '${dest}/'`;
3916
+ return `mkdir -p '${parent}' && rsync -a --ignore-existing --exclude=node_modules '/src/${rel}/' '${dest}/'`;
4081
3917
  });
4082
3918
  const apply = await execa5(
4083
3919
  "docker",
@@ -4103,24 +3939,8 @@ async function pullClaudeExtras(spec, opts) {
4103
3939
  );
4104
3940
  }
4105
3941
  }
4106
- if (mergedMarkets.changed || mergedInstalled.changed) {
4107
- await mkdir2(join3(hostClaude, "plugins"), { recursive: true });
4108
- if (mergedMarkets.changed) {
4109
- await writeFile2(
4110
- join3(hostClaude, "plugins", "known_marketplaces.json"),
4111
- `${JSON.stringify(mergedMarkets.data, null, 2)}
4112
- `
4113
- );
4114
- }
4115
- if (mergedInstalled.changed) {
4116
- await writeFile2(
4117
- join3(hostClaude, "plugins", "installed_plugins.json"),
4118
- `${JSON.stringify(mergedInstalled.data, null, 2)}
4119
- `
4120
- );
4121
- }
4122
- }
4123
- return { newItems, mergedRegistries };
3942
+ await writeClaudeMergedRegistries(plan);
3943
+ return { newItems, mergedRegistries, sourceRegistries };
4124
3944
  }
4125
3945
  var CREDENTIALS_BACKUP_FILE = join4(STATE_DIR, "claude-credentials.json");
4126
3946
  var CODEX_CREDENTIALS_BACKUP_FILE = join4(STATE_DIR, "codex-credentials.json");
@@ -4130,7 +3950,7 @@ function parseExtractResult(stdout) {
4130
3950
  }
4131
3951
  async function extractVolumeAuthToBackup(opts) {
4132
3952
  try {
4133
- await mkdir32(STATE_DIR, { recursive: true });
3953
+ await mkdir22(STATE_DIR, { recursive: true });
4134
3954
  const script = 'COPIED=no; if [ -s /dst/auth.json ]; then cp -a /dst/auth.json "/host-state/$DEST" && COPIED=yes; fi; echo "COPIED=$COPIED"';
4135
3955
  const { stdout } = await execa6("docker", [
4136
3956
  "run",
@@ -4221,7 +4041,7 @@ echo "EXTRACTED=$EXTRACTED SEEDED=$SEEDED VOLREAL=$VOL_REAL"
4221
4041
  `;
4222
4042
  async function syncClaudeCredentials(spec, opts) {
4223
4043
  try {
4224
- await mkdir32(STATE_DIR, { recursive: true });
4044
+ await mkdir22(STATE_DIR, { recursive: true });
4225
4045
  const { stdout } = await execa6("docker", [
4226
4046
  "run",
4227
4047
  "--rm",
@@ -4329,6 +4149,16 @@ async function ensureCodexVolume(spec, opts) {
4329
4149
  "-c",
4330
4150
  // --exclude=hooks.json: the AgentBox activity hooks file is box-owned
4331
4151
  // (seeded by seedCodexHooks); never let the host copy clobber it.
4152
+ // --exclude=/config.toml (anchored — plugin repos legitimately contain
4153
+ // files named config.toml): box config is owned by
4154
+ // reconcileVolumeCodexConfig (sanitize + merge), never rsynced — copying
4155
+ // the host file here would wipe box-side `codex plugin add`/`mcp add`
4156
+ // state before the merge could read it.
4157
+ // The `.tmp/marketplaces` includes come FIRST (rsync filter rules are
4158
+ // first-match-wins): git-marketplace snapshots must reach the box or
4159
+ // in-box `codex plugin` breaks; `/.tmp/*` then drops `.tmp`'s other
4160
+ // children (the heavy desktop-app payloads) and the unanchored `.tmp`
4161
+ // still blocks nested `.tmp` dirs elsewhere.
4332
4162
  // The session-state DBs / indexes are excluded so a teleported session
4333
4163
  // resumes at /workspace (Codex reads the cwd from state_*.sqlite's threads
4334
4164
  // index, which it backfills from the box's rollouts) and the host's
@@ -4337,18 +4167,18 @@ async function ensureCodexVolume(spec, opts) {
4337
4167
  // excludes) already copied into the shared volume — rsync without
4338
4168
  // --delete only adds/updates. The globs are no-ops with `-f` when absent,
4339
4169
  // and never touch box-owned `sessions/` (the teleported rollouts) or
4340
- // `hooks.json`.
4341
- // Heavy host-only artifacts are also excluded (mirrors CODEX_RSYNC_EXCLUDES
4342
- // in host-stage.ts): `packages` (macOS standalone release binaries — the
4343
- // in-box codex is npm-installed), `plugins/.plugin-appserver` (the
4170
+ // `hooks.json`. `.tmp` gets a selective purge that keeps `marketplaces/`.
4171
+ // Heavy host-only artifacts are also excluded (mirrors the codex spec in
4172
+ // sandbox-core's registry): `packages` (macOS standalone release binaries —
4173
+ // the in-box codex is npm-installed), `plugins/.plugin-appserver` (the
4344
4174
  // platform-specific plugin app-server runtime), `computer-use` (the macOS
4345
4175
  // `Codex Computer Use.app` bundle), `archived_sessions` (host history), and
4346
- // the regenerable caches (`.tmp`, `tmp`, `cache`, `vendor_imports`,
4347
- // `sqlite`, `models_cache.json`). Without these the shared volume balloons
4348
- // to ~1.5 GB and every create's rsync crawls.
4349
- "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/.tmp /dst/tmp /dst/cache /dst/vendor_imports /dst/sqlite /dst/models_cache.json" + skillsPurge + " && chown -R 1000:1000 /dst"
4176
+ // the regenerable caches (`tmp`, `cache`, `vendor_imports`, `sqlite`,
4177
+ // `models_cache.json`). Without these the shared volume balloons to
4178
+ // ~1.5 GB and every create's rsync crawls.
4179
+ "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"
4350
4180
  ]);
4351
- await sanitizeVolumeCodexConfig(spec.volume, opts.image);
4181
+ await reconcileVolumeCodexConfig(spec.volume, opts.image);
4352
4182
  return { created, synced: true };
4353
4183
  }
4354
4184
  await execa7(
@@ -4368,7 +4198,7 @@ async function ensureCodexVolume(spec, opts) {
4368
4198
  { reject: false }
4369
4199
  );
4370
4200
  if (!await pathExists2(join5(hostCodex, "config.toml"))) {
4371
- await sanitizeVolumeCodexConfig(spec.volume, opts.image);
4201
+ await reconcileVolumeCodexConfig(spec.volume, opts.image);
4372
4202
  }
4373
4203
  return { created, synced: false };
4374
4204
  }
@@ -4410,39 +4240,60 @@ async function seedCodexAgentsOverride(volume, image) {
4410
4240
  return { seeded: false };
4411
4241
  }
4412
4242
  }
4413
- async function sanitizeVolumeCodexConfig(volume, image) {
4243
+ function buildCodexOrphanPurgeScript(keptMarketplaces) {
4244
+ const keepFlags = keptMarketplaces.map((n) => `! -name ${shQuote22(n)}`).join(" ");
4245
+ const purgeDir = (dir) => `{ [ -d ${dir} ] && find ${dir} -mindepth 1 -maxdepth 1` + (keepFlags.length > 0 ? ` ${keepFlags}` : "") + ` -exec rm -rf {} + || true; }`;
4246
+ return `${purgeDir("/dst/plugins/cache")} && ${purgeDir("/dst/.tmp/marketplaces")}`;
4247
+ }
4248
+ async function reconcileVolumeCodexConfig(volume, image) {
4414
4249
  try {
4250
+ const boxRead = await execa7(
4251
+ "docker",
4252
+ ["run", "--rm", "-v", `${volume}:/dst`, image, "sh", "-c", "cat /dst/config.toml"],
4253
+ { reject: false }
4254
+ );
4255
+ const boxText = boxRead.exitCode === 0 ? boxRead.stdout : null;
4415
4256
  const hostConfig = join5(homedir3(), ".codex", "config.toml");
4416
- let text;
4257
+ let base;
4417
4258
  if (!await pathExists2(hostConfig)) {
4418
- text = MINIMAL_TRUSTED_CODEX_CONFIG;
4259
+ base = MINIMAL_TRUSTED_CODEX_CONFIG;
4419
4260
  } else {
4420
- const sanitized = sanitizeCodexConfigForBox(await readFile32(hostConfig, "utf8"));
4421
- if (!sanitized.changed || sanitized.text.length === 0) return { sanitized: false };
4422
- text = sanitized.text;
4261
+ const hostText = await readFile32(hostConfig, "utf8");
4262
+ try {
4263
+ base = sanitizeCodexConfigForBox(hostText).text;
4264
+ } catch {
4265
+ if (boxText !== null) return { reconciled: false };
4266
+ await writeVolumeCodexConfig(volume, image, hostText, null);
4267
+ return { reconciled: true };
4268
+ }
4423
4269
  }
4424
- await execa7(
4425
- "docker",
4426
- [
4427
- "run",
4428
- "--rm",
4429
- "-i",
4430
- "--user",
4431
- "0",
4432
- "-v",
4433
- `${volume}:/dst`,
4434
- image,
4435
- "sh",
4436
- "-c",
4437
- "cat > /dst/config.toml.tmp && chown 1000:1000 /dst/config.toml.tmp && mv /dst/config.toml.tmp /dst/config.toml"
4438
- ],
4439
- { input: text }
4440
- );
4441
- return { sanitized: true };
4270
+ const merged = mergeCodexConfigForBox(base, boxText);
4271
+ await writeVolumeCodexConfig(volume, image, merged.text, merged.marketplaces);
4272
+ return { reconciled: true };
4442
4273
  } catch {
4443
- return { sanitized: false };
4274
+ return { reconciled: false };
4444
4275
  }
4445
4276
  }
4277
+ async function writeVolumeCodexConfig(volume, image, text, keptMarketplaces) {
4278
+ const purge = keptMarketplaces === null ? "" : ` && ${buildCodexOrphanPurgeScript(keptMarketplaces)}`;
4279
+ await execa7(
4280
+ "docker",
4281
+ [
4282
+ "run",
4283
+ "--rm",
4284
+ "-i",
4285
+ "--user",
4286
+ "0",
4287
+ "-v",
4288
+ `${volume}:/dst`,
4289
+ image,
4290
+ "sh",
4291
+ "-c",
4292
+ "cat > /dst/config.toml.tmp && chown 1000:1000 /dst/config.toml.tmp && mv /dst/config.toml.tmp /dst/config.toml" + purge
4293
+ ],
4294
+ { input: text }
4295
+ );
4296
+ }
4446
4297
  var CODEX_FORWARDED_ENV_KEYS = ["OPENAI_API_KEY"];
4447
4298
  function buildCodexMounts(spec, hostEnv) {
4448
4299
  const env = {};
@@ -4607,7 +4458,6 @@ async function codexSessionInfo(container, sessionName) {
4607
4458
  }
4608
4459
  return { running: true, sessionName: name, startedAt };
4609
4460
  }
4610
- var CODEX_PULL_ITEMS = ["config.toml", "auth.json", "prompts"];
4611
4461
  async function pullCodexConfig(spec, opts) {
4612
4462
  const hostCodex = join5(homedir3(), ".codex");
4613
4463
  const inv = await execa7(
@@ -4968,18 +4818,6 @@ async function opencodeSessionInfo(container, sessionName) {
4968
4818
  }
4969
4819
  return { running: true, sessionName: name, startedAt };
4970
4820
  }
4971
- var OPENCODE_PULL_DATA_ITEMS = ["auth.json"];
4972
- var OPENCODE_PULL_CONFIG_ITEMS = [
4973
- "opencode.json",
4974
- "opencode.jsonc",
4975
- "agents",
4976
- "commands",
4977
- "modes",
4978
- "plugins",
4979
- "skills",
4980
- "tools",
4981
- "themes"
4982
- ];
4983
4821
  async function pullOpencodeConfig(spec, opts) {
4984
4822
  const hostData = join7(homedir5(), ".local", "share", "opencode");
4985
4823
  const hostConfig = join7(homedir5(), ".config", "opencode");
@@ -5922,7 +5760,7 @@ async function createSnapshot(opts) {
5922
5760
  const source = resolve2(opts.source);
5923
5761
  const destination = resolve2(opts.destination);
5924
5762
  const excluded = opts.excluded ?? EXCLUDE_DIRS;
5925
- await mkdir4(SNAPSHOTS_ROOT, { recursive: true });
5763
+ await mkdir3(SNAPSHOTS_ROOT, { recursive: true });
5926
5764
  const cpArgs = platform() === "darwin" ? ["-cR"] : ["-R"];
5927
5765
  await execa12("cp", [...cpArgs, `${source}/`, destination]);
5928
5766
  const toPrune = await findExcludedDirs(destination, excluded);
@@ -6120,7 +5958,7 @@ async function createCheckpoint(opts) {
6120
5958
  }
6121
5959
  }
6122
5960
  const tag = checkpointImageTag(opts.projectRoot, name);
6123
- await mkdir5(dir, { recursive: true });
5961
+ await mkdir4(dir, { recursive: true });
6124
5962
  log(`running pre-commit cleanup in ${box.container}`);
6125
5963
  await runCleanup(box.container, log);
6126
5964
  if (type === "layered") {
@@ -6320,7 +6158,7 @@ function shouldReclaimForVersion(health, currentVersion) {
6320
6158
  async function ensureRelay(opts = {}) {
6321
6159
  const log = opts.onLog ?? (() => {
6322
6160
  });
6323
- await mkdir6(STATE_DIR2, { recursive: true });
6161
+ await mkdir5(STATE_DIR2, { recursive: true });
6324
6162
  if (await containerExists(RELAY_CONTAINER_NAME)) {
6325
6163
  await removeContainer(RELAY_CONTAINER_NAME);
6326
6164
  log(`removed legacy relay container ${RELAY_CONTAINER_NAME}`);
@@ -6476,9 +6314,9 @@ async function stageRelayHome(version, log) {
6476
6314
  if (nodeModules === null) return null;
6477
6315
  const tmpDir = `${homeDir}.tmp-${String(process.pid)}`;
6478
6316
  try {
6479
- await mkdir6(RELAY_HOME_DIR, { recursive: true });
6317
+ await mkdir5(RELAY_HOME_DIR, { recursive: true });
6480
6318
  await rm5(tmpDir, { recursive: true, force: true });
6481
- await mkdir6(tmpDir, { recursive: true });
6319
+ await mkdir5(tmpDir, { recursive: true });
6482
6320
  for (const sub of ["dist", "runtime", "share"]) {
6483
6321
  const src = join11(cliRoot, sub);
6484
6322
  if (existsSync3(src)) await cp(src, join11(tmpDir, sub), { recursive: true });
@@ -6952,8 +6790,8 @@ async function ensureAgentboxTasksFile(container, services, opts = {}) {
6952
6790
  return { status: "wrote" };
6953
6791
  }
6954
6792
  async function writeFileInBox(container, path, content) {
6955
- const { execa: execa21 } = await import("execa");
6956
- const result = await execa21(
6793
+ const { execa: execa222 } = await import("execa");
6794
+ const result = await execa222(
6957
6795
  "docker",
6958
6796
  ["exec", "-i", "--user", "vscode", container, "sh", "-c", `cat > ${shellQuote(path)}`],
6959
6797
  { input: content, reject: false }
@@ -7250,8 +7088,8 @@ async function createBox(opts) {
7250
7088
  const socketDir = join12(boxDir, "run");
7251
7089
  const socketPath = join12(socketDir, "ctl.sock");
7252
7090
  const mergedExportDir = join12(boxDir, "workspace");
7253
- await mkdir7(socketDir, { recursive: true });
7254
- await mkdir7(mergedExportDir, { recursive: true });
7091
+ await mkdir6(socketDir, { recursive: true });
7092
+ await mkdir6(mergedExportDir, { recursive: true });
7255
7093
  const extraVolumes = await buildIdentityMounts();
7256
7094
  extraVolumes.push(...claudeMounts.extraVolumes);
7257
7095
  if (codexMounts) extraVolumes.push(...codexMounts.extraVolumes);
@@ -7269,7 +7107,7 @@ async function createBox(opts) {
7269
7107
  Object.assign(portlessEnv, portlessBrowserEnv(name, { mapTarget: "host.docker.internal" }));
7270
7108
  try {
7271
7109
  const hostStateDir = await resolvePortlessHostStateDir(opts.portlessStateDir);
7272
- await mkdir7(hostStateDir, { recursive: true });
7110
+ await mkdir6(hostStateDir, { recursive: true });
7273
7111
  const boxStateDir = "/home/vscode/.portless";
7274
7112
  extraVolumes.push(`${hostStateDir}:${boxStateDir}`);
7275
7113
  portlessEnv["PORTLESS_STATE_DIR"] = boxStateDir;
@@ -7328,6 +7166,10 @@ async function createBox(opts) {
7328
7166
  AGENTBOX: "1",
7329
7167
  AGENTBOX_BOX_NAME: name,
7330
7168
  AGENTBOX_HOST_WORKSPACE: workspace,
7169
+ // Absent = enabled; the ctl credential watcher only checks for '0'. The
7170
+ // caller-resolved value wins (it sees CLI overrides like
7171
+ // --no-credential-sync that this function's own config load can't).
7172
+ ...(opts.credentialSync ?? effectiveBoxCfg.credentialSync) === false ? { AGENTBOX_CREDENTIAL_SYNC: "0" } : {},
7331
7173
  ...opts.projectRoot ? { AGENTBOX_PROJECT_ROOT: opts.projectRoot } : {},
7332
7174
  ...projectIndex !== void 0 ? { AGENTBOX_PROJECT_INDEX: String(projectIndex) } : {}
7333
7175
  };
@@ -8602,7 +8444,8 @@ var dockerProvider = {
8602
8444
  portless: po.portless,
8603
8445
  portlessStateDir: po.portlessStateDir,
8604
8446
  projectRoot: req.projectRoot,
8605
- limits: req.limits ?? void 0
8447
+ limits: req.limits ?? void 0,
8448
+ credentialSync: req.credentialSync
8606
8449
  };
8607
8450
  const result = await createBox(opts);
8608
8451
  return {
@@ -8652,6 +8495,9 @@ var dockerProvider = {
8652
8495
  sync(box) {
8653
8496
  return makeDockerSync({ container: box.container });
8654
8497
  },
8498
+ syncTransport(box) {
8499
+ return createDockerSyncTransport({ container: box.container, image: box.image });
8500
+ },
8655
8501
  async inspect(box) {
8656
8502
  const insp = await inspectBox(box.id);
8657
8503
  return {
@@ -8820,14 +8666,126 @@ var providerModule = {
8820
8666
  provider: dockerProvider,
8821
8667
  doctorChecks: dockerChecks
8822
8668
  };
8823
- var STATE_DIR3 = join16(homedir12(), ".agentbox");
8824
- var HUB_PID_FILE = join16(STATE_DIR3, "hub.pid");
8825
- var HUB_LOG_FILE = join16(STATE_DIR3, "hub.log");
8826
- var HUB_TOKEN_FILE = join16(STATE_DIR3, "hub", "token");
8669
+ var posixDirname2 = (rel) => {
8670
+ const d = dirname4(rel);
8671
+ return d === "." ? "" : d;
8672
+ };
8673
+ async function stageItemsFromVolume(volume, image, items, stagingDir) {
8674
+ if (items.length === 0) return;
8675
+ for (const item of items) {
8676
+ const parent = posixDirname2(item.rel);
8677
+ if (parent) await mkdir7(join16(stagingDir, parent), { recursive: true });
8678
+ }
8679
+ const uid = process.getuid?.() ?? 0;
8680
+ const gid = process.getgid?.() ?? 0;
8681
+ const cmds = items.map(
8682
+ (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}'`
8683
+ );
8684
+ cmds.push(`chown -R ${String(uid)}:${String(gid)} /stage`);
8685
+ const r = await execa21(
8686
+ "docker",
8687
+ [
8688
+ "run",
8689
+ "--rm",
8690
+ "--user",
8691
+ "0",
8692
+ "-v",
8693
+ `${volume}:/src:ro`,
8694
+ "-v",
8695
+ `${stagingDir}:/stage`,
8696
+ image,
8697
+ "sh",
8698
+ "-c",
8699
+ cmds.join(" && ")
8700
+ ],
8701
+ { reject: false }
8702
+ );
8703
+ if (r.exitCode !== 0) {
8704
+ throw new Error(
8705
+ `failed to stage items from volume ${volume}: ${(r.stderr ?? "").toString().trim() || `exit ${String(r.exitCode)}`}`
8706
+ );
8707
+ }
8708
+ }
8709
+ function volumeSettingsTarget(volume, image, label) {
8710
+ const run = (args, input) => execa21("docker", args, { reject: false, ...input === void 0 ? {} : { input } });
8711
+ return {
8712
+ label,
8713
+ async exists(rel) {
8714
+ const r = await run(["run", "--rm", "-v", `${volume}:/dst:ro`, image, "test", "-e", `/dst/${rel}`]);
8715
+ return r.exitCode === 0;
8716
+ },
8717
+ async readText(rel) {
8718
+ const r = await run([
8719
+ "run",
8720
+ "--rm",
8721
+ "--user",
8722
+ "0",
8723
+ "-v",
8724
+ `${volume}:/dst:ro`,
8725
+ image,
8726
+ "cat",
8727
+ `/dst/${rel}`
8728
+ ]);
8729
+ return r.exitCode === 0 ? String(r.stdout ?? "") : null;
8730
+ },
8731
+ async writeText(rel, content, opts) {
8732
+ const parent = posixDirname2(rel);
8733
+ const chmod2 = opts?.mode !== void 0 ? ` && chmod ${opts.mode.toString(8)} '/dst/${rel}'` : "";
8734
+ const r = await run(
8735
+ [
8736
+ "run",
8737
+ "--rm",
8738
+ "-i",
8739
+ "--user",
8740
+ "0",
8741
+ "-v",
8742
+ `${volume}:/dst`,
8743
+ image,
8744
+ "sh",
8745
+ "-c",
8746
+ `${parent ? `mkdir -p '/dst/${parent}' && ` : ""}cat > '/dst/${rel}' && chown 1000:1000 '/dst/${rel}'${chmod2}`
8747
+ ],
8748
+ content
8749
+ );
8750
+ if (r.exitCode !== 0) {
8751
+ throw new Error(
8752
+ `failed to write ${rel} into volume ${volume}: ${(r.stderr ?? "").toString().trim() || `exit ${String(r.exitCode)}`}`
8753
+ );
8754
+ }
8755
+ },
8756
+ async copyIn(stagingAbs, rel, kind) {
8757
+ const parent = posixDirname2(rel);
8758
+ 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}'`;
8759
+ const r = await run([
8760
+ "run",
8761
+ "--rm",
8762
+ "--user",
8763
+ "0",
8764
+ "-v",
8765
+ `${stagingAbs}:/stage-item:ro`,
8766
+ "-v",
8767
+ `${volume}:/dst`,
8768
+ image,
8769
+ "sh",
8770
+ "-c",
8771
+ script
8772
+ ]);
8773
+ if (r.exitCode !== 0) {
8774
+ throw new Error(
8775
+ `failed to copy ${rel} into volume ${volume}: ${(r.stderr ?? "").toString().trim() || `exit ${String(r.exitCode)}`}`
8776
+ );
8777
+ }
8778
+ }
8779
+ };
8780
+ }
8781
+ var STATE_DIR3 = join17(homedir12(), ".agentbox");
8782
+ var HUB_PID_FILE = join17(STATE_DIR3, "hub.pid");
8783
+ var HUB_LOG_FILE = join17(STATE_DIR3, "hub.log");
8784
+ var HUB_TOKEN_FILE = join17(STATE_DIR3, "hub", "token");
8827
8785
  var PORT2 = DEFAULT_RELAY_PORT;
8828
8786
  var HOST = "127.0.0.1";
8829
8787
  var HUB_PORTLESS_ALIAS = "agentbox";
8830
- var HUB_PORTLESS_FILE = join16(STATE_DIR3, "hub", "portless-url");
8788
+ var HUB_PORTLESS_FILE = join17(STATE_DIR3, "hub", "portless-url");
8831
8789
  var NODE_MIN = { major: 22, minor: 5 };
8832
8790
  function nodeVersion() {
8833
8791
  const [major, minor] = process.versions.node.split(".").map((n) => Number.parseInt(n, 10));
@@ -8894,7 +8852,7 @@ async function syncHubPortless(enabled) {
8894
8852
  if (!portless.installed) return await teardown();
8895
8853
  await portlessAlias(HUB_PORTLESS_ALIAS, PORT2);
8896
8854
  const url = await portlessGetUrl(HUB_PORTLESS_ALIAS);
8897
- await mkdir8(dirname4(HUB_PORTLESS_FILE), { recursive: true });
8855
+ await mkdir8(dirname5(HUB_PORTLESS_FILE), { recursive: true });
8898
8856
  await writeFile4(HUB_PORTLESS_FILE, url, "utf8");
8899
8857
  return url;
8900
8858
  } catch {
@@ -8904,7 +8862,7 @@ async function syncHubPortless(enabled) {
8904
8862
  function resolveHubServer() {
8905
8863
  const override = process.env.AGENTBOX_HUB_BIN;
8906
8864
  if (override && existsSync4(override)) return override;
8907
- const here = dirname4(fileURLToPath2(import.meta.url));
8865
+ const here = dirname5(fileURLToPath2(import.meta.url));
8908
8866
  const candidates = [
8909
8867
  resolve5(here, "..", "runtime", "hub", "apps", "hub", "server.js"),
8910
8868
  resolve5(here, "..", "..", "..", "apps", "hub", "dist-standalone", "apps", "hub", "server.js"),
@@ -9352,6 +9310,8 @@ export {
9352
9310
  dockerProvider,
9353
9311
  dockerChecks,
9354
9312
  providerModule,
9313
+ stageItemsFromVolume,
9314
+ volumeSettingsTarget,
9355
9315
  resolveHubServer,
9356
9316
  ensureHub,
9357
9317
  stopHub,
@@ -9360,4 +9320,4 @@ export {
9360
9320
  ensureBoxBrowser,
9361
9321
  ensureBoxBrowserShowingApp
9362
9322
  };
9363
- //# sourceMappingURL=chunk-JNY5GPIM.js.map
9323
+ //# sourceMappingURL=chunk-I654PBHA.js.map