@madarco/agentbox 0.23.5 → 0.24.1

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 +81 -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 +2617 -1094
  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 → 3tBexekuTKIr_6nriQjKE}/_buildManifest.js +0 -0
  179. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → 3tBexekuTKIr_6nriQjKE}/_clientMiddlewareManifest.js +0 -0
  180. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → 3tBexekuTKIr_6nriQjKE}/_ssgManifest.js +0 -0
@@ -322,29 +322,33 @@ import { mkdtemp, readFile as readFile4, writeFile as writeFile3 } from "fs/prom
322
322
  import { tmpdir } from "os";
323
323
  import { basename as basename2, join as join7 } from "path";
324
324
  import { join as join8 } from "path";
325
+ import { chmod, mkdir as mkdir4, readdir as readdir2, readFile as readFile5, stat as stat4, writeFile as writeFile4 } from "fs/promises";
325
326
  import { homedir as homedir6 } from "os";
326
- import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
327
- import { tmpdir as tmpdir2 } from "os";
328
- import { join as join9 } from "path";
329
- import { readdir as readdir2, stat as stat4 } from "fs/promises";
327
+ import { dirname as dirname6, join as join9 } from "path";
330
328
  import { homedir as homedir7 } from "os";
331
- import { join as join10 } from "path";
332
- import { readdir as readdir3, realpath as realpath2, stat as stat5 } from "fs/promises";
333
- import { isAbsolute as isAbsolute3, join as join11, relative } from "path";
334
- import { stat as stat6 } from "fs/promises";
335
- import { chmod, mkdir as mkdir4, readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
336
- import { dirname as dirname6 } from "path";
337
- import { createHash } from "crypto";
338
- import { readFile as readFile6 } from "fs/promises";
329
+ import { mkdtemp as mkdtemp3, rm as rm4 } from "fs/promises";
330
+ import { tmpdir as tmpdir3 } from "os";
331
+ import { join as join11 } from "path";
332
+ import { readdir as readdir3, stat as stat5 } from "fs/promises";
333
+ import { homedir as homedir8 } from "os";
339
334
  import { join as join12 } from "path";
335
+ import { readdir as readdir4, realpath as realpath2, stat as stat6 } from "fs/promises";
336
+ import { isAbsolute as isAbsolute3, join as join13, relative } from "path";
337
+ import { stat as stat7 } from "fs/promises";
338
+ import { chmod as chmod2, mkdir as mkdir6, mkdtemp as mkdtemp4, readFile as readFile6, rename as rename3, rm as rm5, writeFile as writeFile6 } from "fs/promises";
339
+ import { tmpdir as tmpdir4 } from "os";
340
+ import { dirname as dirname8, join as join14 } from "path";
341
+ import { createHash } from "crypto";
342
+ import { readFile as readFile7 } from "fs/promises";
343
+ import { join as join15 } from "path";
340
344
  import { createHash as createHash2 } from "crypto";
341
- import { copyFile, mkdir as mkdir5, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile7, rm as rm4, stat as stat7 } from "fs/promises";
342
- import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
343
- import { basename as basename22, dirname as dirname7, join as join13 } from "path";
344
- import { copyFile as copyFile2, mkdtemp as mkdtemp4, readdir as readdir5, readFile as readFile8, rm as rm5, stat as stat8, writeFile as writeFile5 } from "fs/promises";
345
- import { homedir as homedir10, tmpdir as tmpdir4 } from "os";
346
- import { basename as basename3, join as join14, relative as relative2 } from "path";
347
- import { homedir as homedir9 } from "os";
345
+ import { copyFile, mkdir as mkdir7, mkdtemp as mkdtemp5, readdir as readdir5, readFile as readFile8, rm as rm6, stat as stat8 } from "fs/promises";
346
+ import { homedir as homedir9, tmpdir as tmpdir5 } from "os";
347
+ import { basename as basename22, dirname as dirname9, join as join16 } from "path";
348
+ import { copyFile as copyFile2, mkdtemp as mkdtemp6, readdir as readdir6, readFile as readFile9, rm as rm7, stat as stat9, writeFile as writeFile7 } from "fs/promises";
349
+ import { homedir as homedir11, tmpdir as tmpdir6 } from "os";
350
+ import { basename as basename3, join as join17, relative as relative2 } from "path";
351
+ import { homedir as homedir10 } from "os";
348
352
 
349
353
  // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/date.js
350
354
  var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
@@ -1170,9 +1174,9 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
1170
1174
  // ../../packages/sandbox-core/dist/index.js
1171
1175
  import { createHash as createHash3 } from "crypto";
1172
1176
  import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
1173
- import { readFile as readFile9 } from "fs/promises";
1174
- import { homedir as homedir11 } from "os";
1175
- import { dirname as dirname8, resolve as pathResolve } from "path";
1177
+ import { readFile as readFile10 } from "fs/promises";
1178
+ import { homedir as homedir12 } from "os";
1179
+ import { dirname as dirname10, resolve as pathResolve } from "path";
1176
1180
  var STATE_DIR = join2(homedir2(), ".agentbox");
1177
1181
  var STATE_FILE = join2(STATE_DIR, "state.json");
1178
1182
  var EMPTY = { version: 1, boxes: [] };
@@ -1660,6 +1664,47 @@ async function mintSshKey(targetDir, comment) {
1660
1664
  const publicKey = (await readFile2(pub, "utf8")).trim();
1661
1665
  return { dir, privatePath: priv, publicPath: pub, publicKey };
1662
1666
  }
1667
+ var OPEN_INBOUND_SOURCES = ["0.0.0.0/0", "::/0"];
1668
+ function normalizeInboundCidr(raw) {
1669
+ const trimmed = raw.trim();
1670
+ if (trimmed.includes("/")) return trimmed;
1671
+ if (trimmed.includes(":")) return `${trimmed}/128`;
1672
+ return `${trimmed}/32`;
1673
+ }
1674
+ function parseInboundSpec(spec) {
1675
+ let s = (spec ?? "").trim();
1676
+ if (s === "" || /^lock(ed)?$/i.test(s)) return { mode: "locked", sources: [] };
1677
+ if (/^open$/i.test(s)) return { mode: "open", sources: [] };
1678
+ if (/^whitelist\b:?/i.test(s)) s = s.replace(/^whitelist\b:?/i, "").trim();
1679
+ const sources = s.split(/[\s,]+/).map((x) => x.trim()).filter((x) => x.length > 0).map(normalizeInboundCidr);
1680
+ if (sources.length === 0) {
1681
+ throw new Error(
1682
+ "inbound 'whitelist' needs at least one CIDR, e.g. `--inbound 203.0.113.5/32` or `--inbound whitelist:203.0.113.0/24`"
1683
+ );
1684
+ }
1685
+ return { mode: "whitelist", sources };
1686
+ }
1687
+ function resolveInboundSources(policy, hostEgressCidr) {
1688
+ if (policy.mode === "open") return [...OPEN_INBOUND_SOURCES];
1689
+ const out = /* @__PURE__ */ new Set();
1690
+ if (hostEgressCidr && hostEgressCidr.trim().length > 0) {
1691
+ out.add(normalizeInboundCidr(hostEgressCidr));
1692
+ }
1693
+ if (policy.mode === "whitelist") {
1694
+ for (const s of policy.sources) out.add(normalizeInboundCidr(s));
1695
+ }
1696
+ return [...out];
1697
+ }
1698
+ function describeInbound(policy) {
1699
+ switch (policy.mode) {
1700
+ case "open":
1701
+ return "open (SSH reachable from anywhere \u2014 0.0.0.0/0, key-only)";
1702
+ case "whitelist":
1703
+ return `whitelist (host egress + ${policy.sources.join(", ")})`;
1704
+ default:
1705
+ return "locked (SSH reachable only from the host egress IP)";
1706
+ }
1707
+ }
1663
1708
  var BOX_WORKSPACE = "/workspace";
1664
1709
  function run(provider, box, argv) {
1665
1710
  return provider.exec(box, argv, { cwd: BOX_WORKSPACE });
@@ -1909,6 +1954,17 @@ var AGENT_SYNC_SPECS = [
1909
1954
  // separately; `state_*.sqlite*` is the resume-cwd index (rebuilt in-box);
1910
1955
  // `packages`/`plugins/.plugin-appserver`/`computer-use` are heavy
1911
1956
  // macOS-only artifacts; the rest is host-only session/log/cache state.
1957
+ //
1958
+ // `.tmp` carve-in: the git-marketplace snapshots (`.tmp/marketplaces/`,
1959
+ // ~13 MB) must reach the box or in-box `codex plugin` breaks
1960
+ // ("marketplace root does not contain a supported manifest" — and the
1961
+ // box can't re-clone, the git shim blocks `clone`). The includes are
1962
+ // emitted BEFORE the excludes (first-match-wins): the root `.tmp/` dir
1963
+ // and the marketplaces subtree transfer, `/.tmp/*` drops its other
1964
+ // children (the ~200 MB desktop-app `bundled-marketplaces` + `plugins`
1965
+ // payloads), and the unanchored `.tmp` still blocks nested `.tmp` dirs
1966
+ // elsewhere in the tree.
1967
+ include: ["/.tmp/", "/.tmp/marketplaces/***"],
1912
1968
  exclude: [
1913
1969
  "auth.json",
1914
1970
  "sessions",
@@ -1922,6 +1978,7 @@ var AGENT_SYNC_SPECS = [
1922
1978
  "cache",
1923
1979
  "vendor_imports",
1924
1980
  "tmp",
1981
+ "/.tmp/*",
1925
1982
  ".tmp",
1926
1983
  ".codex-global-state.json",
1927
1984
  ".codex-global-state.json.bak",
@@ -2018,6 +2075,233 @@ function resolveAgentSpec(name) {
2018
2075
  if (!spec) throw new Error(`no agent sync spec for '${name}'`);
2019
2076
  return spec;
2020
2077
  }
2078
+ var SKILL_EXCLUDE_PREFIXES = ["agentbox-"];
2079
+ var CONTAINER_PLUGINS_PREFIX = "/home/vscode/.claude/plugins/";
2080
+ function pickNewItems(boxNames, hostNames, excludePrefixes = []) {
2081
+ const host = new Set(hostNames);
2082
+ const seen = /* @__PURE__ */ new Set();
2083
+ const out = [];
2084
+ for (const name of boxNames) {
2085
+ if (name.length === 0 || host.has(name) || seen.has(name)) continue;
2086
+ if (excludePrefixes.some((p) => name.startsWith(p))) continue;
2087
+ seen.add(name);
2088
+ out.push(name);
2089
+ }
2090
+ return out.sort();
2091
+ }
2092
+ function rewritePluginPaths(value, hostPluginsPrefix) {
2093
+ if (typeof value === "string") {
2094
+ return value.split(CONTAINER_PLUGINS_PREFIX).join(hostPluginsPrefix);
2095
+ }
2096
+ if (Array.isArray(value)) {
2097
+ return value.map((v) => rewritePluginPaths(v, hostPluginsPrefix));
2098
+ }
2099
+ if (value !== null && typeof value === "object") {
2100
+ const out = {};
2101
+ for (const [k, v] of Object.entries(value)) {
2102
+ out[k] = rewritePluginPaths(v, hostPluginsPrefix);
2103
+ }
2104
+ return out;
2105
+ }
2106
+ return value;
2107
+ }
2108
+ function isPlainObject2(v) {
2109
+ return v !== null && typeof v === "object" && !Array.isArray(v);
2110
+ }
2111
+ function additiveMerge(hostRoot, boxRoot, hostPluginsPrefix, selectMap, withMap) {
2112
+ const hostMap = selectMap(hostRoot);
2113
+ const boxMap = selectMap(boxRoot);
2114
+ if (!isPlainObject2(boxMap)) {
2115
+ return { data: hostRoot, changed: false, addedKeys: [] };
2116
+ }
2117
+ const base = isPlainObject2(hostMap) ? { ...hostMap } : {};
2118
+ const addedKeys = [];
2119
+ for (const [key, value] of Object.entries(boxMap)) {
2120
+ if (Object.prototype.hasOwnProperty.call(base, key)) continue;
2121
+ base[key] = rewritePluginPaths(value, hostPluginsPrefix);
2122
+ addedKeys.push(key);
2123
+ }
2124
+ if (addedKeys.length === 0) {
2125
+ return { data: hostRoot, changed: false, addedKeys: [] };
2126
+ }
2127
+ return { data: withMap(hostRoot, base), changed: true, addedKeys: addedKeys.sort() };
2128
+ }
2129
+ function mergeKnownMarketplaces(hostJson, boxJson, opts) {
2130
+ const prefix = `${opts.hostHome}/.claude/plugins/`;
2131
+ return additiveMerge(
2132
+ isPlainObject2(hostJson) ? hostJson : {},
2133
+ boxJson,
2134
+ prefix,
2135
+ (root) => root,
2136
+ (_host, merged) => merged
2137
+ );
2138
+ }
2139
+ function mergeInstalledPlugins(hostJson, boxJson, opts) {
2140
+ const prefix = `${opts.hostHome}/.claude/plugins/`;
2141
+ const hostRoot = isPlainObject2(hostJson) ? hostJson : { plugins: {} };
2142
+ return additiveMerge(
2143
+ hostRoot,
2144
+ boxJson,
2145
+ prefix,
2146
+ (root) => isPlainObject2(root) ? root["plugins"] : void 0,
2147
+ (host, merged) => ({ ...host, plugins: merged })
2148
+ );
2149
+ }
2150
+ function referencedPluginVersionKeys(installedPluginsJson) {
2151
+ const keys = /* @__PURE__ */ new Set();
2152
+ if (!isPlainObject2(installedPluginsJson)) return keys;
2153
+ const plugins = installedPluginsJson["plugins"];
2154
+ if (!isPlainObject2(plugins)) return keys;
2155
+ for (const entries of Object.values(plugins)) {
2156
+ if (!Array.isArray(entries)) continue;
2157
+ for (const entry of entries) {
2158
+ if (!isPlainObject2(entry)) continue;
2159
+ const installPath = entry["installPath"];
2160
+ if (typeof installPath !== "string") continue;
2161
+ const segments = installPath.split("/").filter((s) => s.length > 0);
2162
+ if (segments.length < 3) continue;
2163
+ keys.add(segments.slice(-3).join("/"));
2164
+ }
2165
+ }
2166
+ return keys;
2167
+ }
2168
+ var CLAUDE_PULL_DIR_CATEGORIES = ["skills", "agents", "commands"];
2169
+ function claudeInventoryScript(src) {
2170
+ return [
2171
+ "for cat in skills agents commands; do",
2172
+ ` [ -d "${src}/$cat" ] || continue;`,
2173
+ ` for d in "${src}/$cat"/*/; do`,
2174
+ ' [ -d "$d" ] || continue;',
2175
+ ' printf "DIR %s %s\\n" "$cat" "$(basename "$d")";',
2176
+ " done;",
2177
+ "done;",
2178
+ `if [ -d ${src}/plugins/cache ]; then`,
2179
+ ` for m in ${src}/plugins/cache/*/; do`,
2180
+ ' [ -d "$m" ] || continue;',
2181
+ ' for p in "$m"*/; do',
2182
+ ' [ -d "$p" ] || continue;',
2183
+ ' printf "PLUGIN %s/%s\\n" "$(basename "$m")" "$(basename "$p")";',
2184
+ " done;",
2185
+ " done;",
2186
+ "fi;",
2187
+ "for f in installed_plugins known_marketplaces; do",
2188
+ ` [ -f "${src}/plugins/$f.json" ] || continue;`,
2189
+ ' printf "JSON %s " "$f";',
2190
+ ` base64 -w0 "${src}/plugins/$f.json";`,
2191
+ ' printf "\\n";',
2192
+ "done"
2193
+ ].join(" ");
2194
+ }
2195
+ function parseClaudeInventory(stdout) {
2196
+ const dirs = { skills: [], agents: [], commands: [] };
2197
+ const plugins = [];
2198
+ const registries = {};
2199
+ for (const line of stdout.split("\n")) {
2200
+ if (line.startsWith("DIR ")) {
2201
+ const rest = line.slice(4);
2202
+ const sp = rest.indexOf(" ");
2203
+ if (sp === -1) continue;
2204
+ const cat = rest.slice(0, sp);
2205
+ const name = rest.slice(sp + 1);
2206
+ if (cat in dirs) dirs[cat].push(name);
2207
+ } else if (line.startsWith("PLUGIN ")) {
2208
+ plugins.push(line.slice(7));
2209
+ } else if (line.startsWith("JSON ")) {
2210
+ const rest = line.slice(5);
2211
+ const sp = rest.indexOf(" ");
2212
+ if (sp === -1) continue;
2213
+ const which = rest.slice(0, sp);
2214
+ try {
2215
+ registries[which] = JSON.parse(Buffer.from(rest.slice(sp + 1), "base64").toString("utf8"));
2216
+ } catch {
2217
+ }
2218
+ }
2219
+ }
2220
+ return { dirs, plugins, registries };
2221
+ }
2222
+ async function listChildDirs(dir) {
2223
+ try {
2224
+ const entries = await readdir2(dir, { withFileTypes: true });
2225
+ return entries.filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => e.name);
2226
+ } catch {
2227
+ return [];
2228
+ }
2229
+ }
2230
+ async function readJsonFile(path) {
2231
+ try {
2232
+ return JSON.parse(await readFile5(path, "utf8"));
2233
+ } catch {
2234
+ return void 0;
2235
+ }
2236
+ }
2237
+ async function computeClaudePullPlan(inv, opts = {}) {
2238
+ const hostHome = opts.hostHome ?? homedir6();
2239
+ const hostClaude = join9(hostHome, ".claude");
2240
+ const newItems = [];
2241
+ const copyRels = [];
2242
+ for (const cat of CLAUDE_PULL_DIR_CATEGORIES) {
2243
+ const hostNames = await listChildDirs(join9(hostClaude, cat));
2244
+ const excludes = cat === "skills" ? SKILL_EXCLUDE_PREFIXES : [];
2245
+ for (const name of pickNewItems(inv.dirs[cat] ?? [], hostNames, excludes)) {
2246
+ newItems.push({ category: cat, name });
2247
+ copyRels.push(`${cat}/${name}`);
2248
+ }
2249
+ }
2250
+ const hostPluginKeys = [];
2251
+ for (const m of await listChildDirs(join9(hostClaude, "plugins", "cache"))) {
2252
+ for (const p of await listChildDirs(join9(hostClaude, "plugins", "cache", m))) {
2253
+ hostPluginKeys.push(`${m}/${p}`);
2254
+ }
2255
+ }
2256
+ for (const key of pickNewItems(inv.plugins, hostPluginKeys)) {
2257
+ newItems.push({ category: "plugins", name: key });
2258
+ copyRels.push(`plugins/cache/${key}`);
2259
+ }
2260
+ const hostInstalled = await readJsonFile(join9(hostClaude, "plugins", "installed_plugins.json"));
2261
+ const hostMarkets = await readJsonFile(join9(hostClaude, "plugins", "known_marketplaces.json"));
2262
+ const mergedInstalled = mergeInstalledPlugins(hostInstalled, inv.registries["installed_plugins"], {
2263
+ hostHome
2264
+ });
2265
+ const mergedMarkets = mergeKnownMarketplaces(hostMarkets, inv.registries["known_marketplaces"], {
2266
+ hostHome
2267
+ });
2268
+ const mergedRegistries = [];
2269
+ if (mergedInstalled.changed) mergedRegistries.push("installed_plugins.json");
2270
+ if (mergedMarkets.changed) mergedRegistries.push("known_marketplaces.json");
2271
+ return { newItems, copyRels, mergedInstalled, mergedMarkets, mergedRegistries };
2272
+ }
2273
+ async function writeClaudeMergedRegistries(plan, opts = {}) {
2274
+ if (!plan.mergedInstalled.changed && !plan.mergedMarkets.changed) return;
2275
+ const hostClaude = join9(opts.hostHome ?? homedir6(), ".claude");
2276
+ await mkdir4(join9(hostClaude, "plugins"), { recursive: true });
2277
+ if (plan.mergedMarkets.changed) {
2278
+ await writeFile4(
2279
+ join9(hostClaude, "plugins", "known_marketplaces.json"),
2280
+ `${JSON.stringify(plan.mergedMarkets.data, null, 2)}
2281
+ `
2282
+ );
2283
+ }
2284
+ if (plan.mergedInstalled.changed) {
2285
+ await writeFile4(
2286
+ join9(hostClaude, "plugins", "installed_plugins.json"),
2287
+ `${JSON.stringify(plan.mergedInstalled.data, null, 2)}
2288
+ `
2289
+ );
2290
+ }
2291
+ }
2292
+ var CODEX_PULL_ITEMS = ["config.toml", "auth.json", "prompts"];
2293
+ var OPENCODE_PULL_DATA_ITEMS = ["auth.json"];
2294
+ var OPENCODE_PULL_CONFIG_ITEMS = [
2295
+ "opencode.json",
2296
+ "opencode.jsonc",
2297
+ "agents",
2298
+ "commands",
2299
+ "modes",
2300
+ "plugins",
2301
+ "skills",
2302
+ "tools",
2303
+ "themes"
2304
+ ];
2021
2305
  function makeSyncContext(init) {
2022
2306
  return {
2023
2307
  boxName: init.boxName,
@@ -2026,7 +2310,7 @@ function makeSyncContext(init) {
2026
2310
  hostWorkspace: init.hostWorkspace,
2027
2311
  projectRoot: init.projectRoot ?? init.hostWorkspace,
2028
2312
  boxWorkspace: init.boxWorkspace ?? "/workspace",
2029
- hostHome: init.hostHome ?? homedir6(),
2313
+ hostHome: init.hostHome ?? homedir7(),
2030
2314
  onLog: init.onLog ?? (() => {
2031
2315
  })
2032
2316
  };
@@ -2098,8 +2382,8 @@ async function scanHostEnvFiles(workspaceDir, patterns) {
2098
2382
  async function pushEnvFiles(ctx, transport, patterns) {
2099
2383
  const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
2100
2384
  if (list.length === 0) return { copied: 0 };
2101
- const stage = await mkdtemp2(join9(tmpdir2(), "agentbox-envfiles-"));
2102
- const localTar = join9(stage, "envfiles.tar");
2385
+ const stage = await mkdtemp3(join11(tmpdir3(), "agentbox-envfiles-"));
2386
+ const localTar = join11(stage, "envfiles.tar");
2103
2387
  try {
2104
2388
  const packed = await execa(
2105
2389
  "tar",
@@ -2119,7 +2403,7 @@ async function pushEnvFiles(ctx, transport, patterns) {
2119
2403
  return { copied: 0 };
2120
2404
  }
2121
2405
  } finally {
2122
- await rm3(stage, { recursive: true, force: true });
2406
+ await rm4(stage, { recursive: true, force: true });
2123
2407
  }
2124
2408
  return { copied: list.length };
2125
2409
  }
@@ -2159,9 +2443,9 @@ function planCarryEntry(entry) {
2159
2443
  parentChainNeeded
2160
2444
  };
2161
2445
  }
2162
- async function pathExists(p) {
2446
+ async function pathExists2(p) {
2163
2447
  try {
2164
- await stat4(p);
2448
+ await stat5(p);
2165
2449
  return true;
2166
2450
  } catch {
2167
2451
  return false;
@@ -2171,18 +2455,18 @@ function encodeClaudeProjectsKey(absPath) {
2171
2455
  return absPath.replace(/[^a-zA-Z0-9]/g, "-");
2172
2456
  }
2173
2457
  var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
2174
- async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir7()) {
2458
+ async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir8()) {
2175
2459
  if (hostWorkspace.length === 0) return null;
2176
- const memDir = join10(
2460
+ const memDir = join12(
2177
2461
  hostHome,
2178
2462
  ".claude",
2179
2463
  "projects",
2180
2464
  encodeClaudeProjectsKey(hostWorkspace),
2181
2465
  "memory"
2182
2466
  );
2183
- if (!await pathExists(memDir)) return null;
2467
+ if (!await pathExists2(memDir)) return null;
2184
2468
  try {
2185
- const entries = await readdir2(memDir);
2469
+ const entries = await readdir3(memDir);
2186
2470
  if (entries.length === 0) return null;
2187
2471
  } catch {
2188
2472
  return null;
@@ -2211,13 +2495,13 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
2211
2495
  try {
2212
2496
  let entries;
2213
2497
  try {
2214
- entries = await readdir3(realDir, { withFileTypes: true });
2498
+ entries = await readdir4(realDir, { withFileTypes: true });
2215
2499
  } catch {
2216
2500
  return;
2217
2501
  }
2218
2502
  for (const ent of entries) {
2219
- const realFull = join11(realDir, ent.name);
2220
- const virtualFull = virtualDir ? join11(virtualDir, ent.name) : ent.name;
2503
+ const realFull = join13(realDir, ent.name);
2504
+ const virtualFull = virtualDir ? join13(virtualDir, ent.name) : ent.name;
2221
2505
  if (ent.isSymbolicLink()) {
2222
2506
  let real;
2223
2507
  try {
@@ -2230,7 +2514,7 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
2230
2514
  unsyncable.push(virtualFull);
2231
2515
  continue;
2232
2516
  }
2233
- const st = await stat5(real).catch(() => null);
2517
+ const st = await stat6(real).catch(() => null);
2234
2518
  if (st?.isDirectory()) await walk(real, virtualFull);
2235
2519
  } else if (ent.isDirectory()) {
2236
2520
  await walk(realFull, virtualFull);
@@ -2243,9 +2527,9 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
2243
2527
  await walk(root, "");
2244
2528
  return unsyncable;
2245
2529
  }
2246
- async function pathExists2(p) {
2530
+ async function pathExists3(p) {
2247
2531
  try {
2248
- await stat6(p);
2532
+ await stat7(p);
2249
2533
  return true;
2250
2534
  } catch {
2251
2535
  return false;
@@ -2254,7 +2538,7 @@ async function pathExists2(p) {
2254
2538
  async function seedAgentsVolume(args) {
2255
2539
  const seed = args.transport.seedVolumeFromHost;
2256
2540
  if (!seed) throw new Error("seedAgentsVolume requires a transport with seedVolumeFromHost");
2257
- const willSync = args.syncFromHost && await pathExists2(args.hostAgents);
2541
+ const willSync = args.syncFromHost && await pathExists3(args.hostAgents);
2258
2542
  if (!willSync) {
2259
2543
  try {
2260
2544
  await seed.call(args.transport, args.volume, []);
@@ -2295,7 +2579,7 @@ function isRealAgentCredential(agent, text) {
2295
2579
  }
2296
2580
  async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now()) {
2297
2581
  try {
2298
- const parsed = JSON.parse(await readFile5(path, "utf8"));
2582
+ const parsed = JSON.parse(await readFile6(path, "utf8"));
2299
2583
  const exp = parsed?.claudeAiOauth?.expiresAt;
2300
2584
  return typeof exp === "number" && Number.isFinite(exp) && exp < now;
2301
2585
  } catch {
@@ -2304,7 +2588,7 @@ async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now
2304
2588
  }
2305
2589
  async function hostBackupHasCredentials(path = CLAUDE_HOST_BACKUP) {
2306
2590
  try {
2307
- const parsed = JSON.parse(await readFile5(path, "utf8"));
2591
+ const parsed = JSON.parse(await readFile6(path, "utf8"));
2308
2592
  const rt = parsed?.claudeAiOauth?.refreshToken;
2309
2593
  return typeof rt === "string" && rt.length > 0;
2310
2594
  } catch {
@@ -2320,9 +2604,9 @@ async function extractCredentials(transport, opts = {}) {
2320
2604
  try {
2321
2605
  const text = await transport.readText(spec.credential.boxAbsPath);
2322
2606
  if (!text || !isRealAgentCredential(spec.id, text)) continue;
2323
- await mkdir4(dirname6(hostBackup), { recursive: true });
2324
- await writeFile4(hostBackup, text, { mode: 384 });
2325
- await chmod(hostBackup, 384).catch(() => {
2607
+ await mkdir6(dirname8(hostBackup), { recursive: true });
2608
+ await writeFile6(hostBackup, text, { mode: 384 });
2609
+ await chmod2(hostBackup, 384).catch(() => {
2326
2610
  });
2327
2611
  extracted.push(spec.id);
2328
2612
  log(`extracted ${spec.id} login from box to ${hostBackup}`);
@@ -2334,6 +2618,88 @@ async function extractCredentials(transport, opts = {}) {
2334
2618
  }
2335
2619
  return extracted;
2336
2620
  }
2621
+ var MAX_CREDENTIAL_BYTES = 256 * 1024;
2622
+ function parseCredentialsUpdate(payload) {
2623
+ if (payload === null || typeof payload !== "object") return null;
2624
+ const obj = payload;
2625
+ const agent = obj["agent"];
2626
+ if (typeof agent !== "string" || !AGENT_SYNC_SPECS.some((s) => s.id === agent)) return null;
2627
+ const b64 = obj["contentBase64"];
2628
+ if (typeof b64 !== "string" || b64.length === 0 || b64.length > MAX_CREDENTIAL_BYTES) return null;
2629
+ let content;
2630
+ try {
2631
+ content = Buffer.from(b64, "base64").toString("utf8");
2632
+ } catch {
2633
+ return null;
2634
+ }
2635
+ if (!isRealAgentCredential(agent, content)) return null;
2636
+ return { agent, content };
2637
+ }
2638
+ function claudeExpiresAt(text) {
2639
+ try {
2640
+ const parsed = JSON.parse(text);
2641
+ const exp = parsed?.claudeAiOauth?.expiresAt;
2642
+ return typeof exp === "number" && Number.isFinite(exp) ? exp : null;
2643
+ } catch {
2644
+ return null;
2645
+ }
2646
+ }
2647
+ function shouldAcceptCredentialUpdate(agent, incoming, existing) {
2648
+ if (existing === null) return { accept: true, reason: "no existing backup" };
2649
+ if (existing === incoming) return { accept: false, reason: "unchanged" };
2650
+ if (resolveAgentSpec(agent).credential.realShape === "claude-oauth") {
2651
+ const incomingExp = claudeExpiresAt(incoming);
2652
+ const existingExp = claudeExpiresAt(existing);
2653
+ if (incomingExp === null) return { accept: false, reason: "incoming blob has no expiresAt" };
2654
+ if (existingExp !== null && incomingExp <= existingExp) {
2655
+ return { accept: false, reason: "not newer than backup" };
2656
+ }
2657
+ return { accept: true, reason: "newer expiresAt" };
2658
+ }
2659
+ return { accept: true, reason: "content changed" };
2660
+ }
2661
+ async function writeCredentialBackup(agent, content, opts = {}) {
2662
+ const path = opts.backupPath ?? resolveAgentSpec(agent).credential.hostBackup;
2663
+ await mkdir6(dirname8(path), { recursive: true });
2664
+ const tmp = `${path}.tmp-${String(process.pid)}`;
2665
+ await writeFile6(tmp, content, { mode: 384 });
2666
+ await rename3(tmp, path);
2667
+ await chmod2(path, 384).catch(() => {
2668
+ });
2669
+ }
2670
+ async function readCredentialBackup(agent, opts = {}) {
2671
+ const path = opts.backupPath ?? resolveAgentSpec(agent).credential.hostBackup;
2672
+ try {
2673
+ return await readFile6(path, "utf8");
2674
+ } catch {
2675
+ return null;
2676
+ }
2677
+ }
2678
+ async function pushCredentialToBox(transport, agent, content) {
2679
+ const abs = resolveAgentSpec(agent).credential.boxAbsPath;
2680
+ const dir = abs.slice(0, abs.lastIndexOf("/"));
2681
+ const stage = await mkdtemp4(join14(tmpdir4(), "agentbox-cred-push-"));
2682
+ try {
2683
+ const tmp = join14(stage, "credential");
2684
+ await writeFile6(tmp, content, { mode: 384 });
2685
+ const mk = await transport.exec(["sh", "-c", `mkdir -p '${dir}'`]);
2686
+ if (mk.exitCode !== 0) {
2687
+ throw new Error(`mkdir ${dir} in box failed: ${mk.stderr.trim()}`);
2688
+ }
2689
+ await transport.pushFile(tmp, abs);
2690
+ const normalize22 = `chown "$(id -un):" '${abs}' && chmod 600 '${abs}'`;
2691
+ const norm = await transport.exec([
2692
+ "sh",
2693
+ "-c",
2694
+ `{ ${normalize22}; } 2>/dev/null || sudo sh -c "${normalize22.replaceAll('"', '\\"')}"`
2695
+ ]);
2696
+ if (norm.exitCode !== 0) {
2697
+ throw new Error(`chown/chmod of ${abs} in box failed: ${norm.stderr.trim()}`);
2698
+ }
2699
+ } finally {
2700
+ await rm5(stage, { recursive: true, force: true });
2701
+ }
2702
+ }
2337
2703
  var NON_REGULAR_TOKEN = "-";
2338
2704
  function classifyUntrackedOverlay(boxToken, hostHash) {
2339
2705
  if (boxToken === void 0) return "copy";
@@ -2482,7 +2848,7 @@ function makeHostGitPorts() {
2482
2848
  return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
2483
2849
  },
2484
2850
  async hashHostFile(hostMain, relPath) {
2485
- return createHash("sha256").update(await readFile6(join12(hostMain, relPath))).digest("hex");
2851
+ return createHash("sha256").update(await readFile7(join15(hostMain, relPath))).digest("hex");
2486
2852
  },
2487
2853
  async packHostFiles(hostMain, relPaths) {
2488
2854
  const tarOut = await execa("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
@@ -2497,9 +2863,9 @@ function makeHostGitPorts() {
2497
2863
  var BOX_WORKFLOWS_DIR = "/home/vscode/.claude/workflows";
2498
2864
  var BOX_DYNAMIC_SYNC_MANIFEST = "/home/vscode/.agentbox/dynamic-sync.json";
2499
2865
  var BOX_MEMORY_DIR = `${BOX_CLAUDE_PROJECT_DIR}/memory`;
2500
- async function pathExists3(p) {
2866
+ async function pathExists4(p) {
2501
2867
  try {
2502
- await stat7(p);
2868
+ await stat8(p);
2503
2869
  return true;
2504
2870
  } catch {
2505
2871
  return false;
@@ -2508,21 +2874,21 @@ async function pathExists3(p) {
2508
2874
  async function walkFiles(root, prefix = "") {
2509
2875
  let entries;
2510
2876
  try {
2511
- entries = await readdir4(root, { withFileTypes: true });
2877
+ entries = await readdir5(root, { withFileTypes: true });
2512
2878
  } catch {
2513
2879
  return [];
2514
2880
  }
2515
2881
  const out = [];
2516
2882
  for (const ent of entries) {
2517
2883
  const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
2518
- const full = join13(root, ent.name);
2884
+ const full = join16(root, ent.name);
2519
2885
  if (ent.isDirectory()) {
2520
2886
  out.push(...await walkFiles(full, rel));
2521
2887
  } else if (ent.isFile()) {
2522
2888
  out.push(rel);
2523
2889
  } else if (ent.isSymbolicLink()) {
2524
2890
  try {
2525
- const s = await stat7(full);
2891
+ const s = await stat8(full);
2526
2892
  if (s.isFile()) out.push(rel);
2527
2893
  } catch {
2528
2894
  }
@@ -2531,7 +2897,7 @@ async function walkFiles(root, prefix = "") {
2531
2897
  return out;
2532
2898
  }
2533
2899
  async function hashFile(absPath) {
2534
- const buf = await readFile7(absPath);
2900
+ const buf = await readFile8(absPath);
2535
2901
  return createHash2("sha256").update(buf).digest("hex");
2536
2902
  }
2537
2903
  async function buildHostSet(name, hostDir, boxDst) {
@@ -2539,13 +2905,13 @@ async function buildHostSet(name, hostDir, boxDst) {
2539
2905
  const rels = await walkFiles(hostDir);
2540
2906
  const files = {};
2541
2907
  for (const rel of rels) {
2542
- files[rel] = await hashFile(join13(hostDir, rel));
2908
+ files[rel] = await hashFile(join16(hostDir, rel));
2543
2909
  }
2544
2910
  return { dst: boxDst, files, hostDir };
2545
2911
  }
2546
- async function buildHostSyncManifest(workspacePath, hostHome = homedir8()) {
2547
- const workflowsDir = join13(hostHome, ".claude", "workflows");
2548
- const workflowsHost = await pathExists3(workflowsDir) ? workflowsDir : null;
2912
+ async function buildHostSyncManifest(workspacePath, hostHome = homedir9()) {
2913
+ const workflowsDir = join16(hostHome, ".claude", "workflows");
2914
+ const workflowsHost = await pathExists4(workflowsDir) ? workflowsDir : null;
2549
2915
  const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
2550
2916
  const [workflows, memory] = await Promise.all([
2551
2917
  buildHostSet("workflows", workflowsHost, BOX_WORKFLOWS_DIR),
@@ -2566,7 +2932,7 @@ function computeSyncDelta(host, box) {
2566
2932
  uploads.push({
2567
2933
  set: name,
2568
2934
  rel,
2569
- absSrc: join13(hostSet.hostDir, rel),
2935
+ absSrc: join16(hostSet.hostDir, rel),
2570
2936
  dst: `${hostSet.dst}/${rel}`
2571
2937
  });
2572
2938
  }
@@ -2585,15 +2951,15 @@ async function stageDynamicSyncTarball(uploads) {
2585
2951
  return { tarballPath: null, cleanup: async () => {
2586
2952
  } };
2587
2953
  }
2588
- const stageDir = await mkdtemp3(join13(tmpdir3(), "agentbox-dynsync-stage-"));
2954
+ const stageDir = await mkdtemp5(join16(tmpdir5(), "agentbox-dynsync-stage-"));
2589
2955
  let tarballPath = null;
2590
2956
  try {
2591
2957
  for (const up of uploads) {
2592
- const target = join13(stageDir, up.set, up.rel);
2593
- await mkdir5(dirname7(target), { recursive: true });
2958
+ const target = join16(stageDir, up.set, up.rel);
2959
+ await mkdir7(dirname9(target), { recursive: true });
2594
2960
  await copyFile(up.absSrc, target);
2595
2961
  }
2596
- tarballPath = join13(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
2962
+ tarballPath = join16(tmpdir5(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
2597
2963
  await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
2598
2964
  env: { ...process.env, COPYFILE_DISABLE: "1" }
2599
2965
  });
@@ -2601,13 +2967,13 @@ async function stageDynamicSyncTarball(uploads) {
2601
2967
  return {
2602
2968
  tarballPath: tp,
2603
2969
  cleanup: async () => {
2604
- await rm4(stageDir, { recursive: true, force: true });
2605
- await rm4(tp, { force: true });
2970
+ await rm6(stageDir, { recursive: true, force: true });
2971
+ await rm6(tp, { force: true });
2606
2972
  }
2607
2973
  };
2608
2974
  } catch (err) {
2609
- await rm4(stageDir, { recursive: true, force: true });
2610
- if (tarballPath) await rm4(tarballPath, { force: true });
2975
+ await rm6(stageDir, { recursive: true, force: true });
2976
+ if (tarballPath) await rm6(tarballPath, { force: true });
2611
2977
  throw err;
2612
2978
  }
2613
2979
  }
@@ -2727,7 +3093,7 @@ var BOX_WORKSPACE2 = "/workspace";
2727
3093
  var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
2728
3094
  trust_level = "trusted"
2729
3095
  `;
2730
- function sanitizeCodexConfigForBox(tomlText, hostHome = homedir9()) {
3096
+ function sanitizeCodexConfigForBox(tomlText, hostHome = homedir10()) {
2731
3097
  const cfg = parse(tomlText);
2732
3098
  let changed = false;
2733
3099
  if (isRecord(cfg["mcp_servers"])) {
@@ -2773,13 +3139,52 @@ function sanitizeCodexConfigForBox(tomlText, hostHome = homedir9()) {
2773
3139
  projects[BOX_WORKSPACE2] = wsEntry;
2774
3140
  changed = true;
2775
3141
  }
2776
- return { text: changed ? stringify(cfg) : tomlText, changed };
3142
+ const keptMarketplaces = isRecord(cfg["marketplaces"]) ? Object.keys(cfg["marketplaces"]) : [];
3143
+ return { text: changed ? stringify(cfg) : tomlText, changed, keptMarketplaces };
3144
+ }
3145
+ var BOX_MERGED_TABLES = ["marketplaces", "plugins", "mcp_servers", "projects"];
3146
+ function mergeCodexConfigForBox(hostSanitizedText, boxText) {
3147
+ const host = parse(hostSanitizedText);
3148
+ const hostMarketplaces = () => isRecord(host["marketplaces"]) ? Object.keys(host["marketplaces"]) : [];
3149
+ if (boxText === null) {
3150
+ return { text: hostSanitizedText, marketplaces: hostMarketplaces(), mergedFromBox: false };
3151
+ }
3152
+ let box;
3153
+ try {
3154
+ box = parse(boxText);
3155
+ } catch {
3156
+ return { text: hostSanitizedText, marketplaces: hostMarketplaces(), mergedFromBox: false };
3157
+ }
3158
+ let merged = false;
3159
+ for (const table of BOX_MERGED_TABLES) {
3160
+ const boxTable = box[table];
3161
+ if (!isRecord(boxTable)) continue;
3162
+ const hostTable = isRecord(host[table]) ? host[table] : {};
3163
+ for (const [name, def] of Object.entries(boxTable)) {
3164
+ if (name in hostTable) continue;
3165
+ hostTable[name] = def;
3166
+ merged = true;
3167
+ }
3168
+ if (Object.keys(hostTable).length > 0) host[table] = hostTable;
3169
+ }
3170
+ for (const [key, value] of Object.entries(box)) {
3171
+ if (BOX_MERGED_TABLES.includes(key)) continue;
3172
+ if (key in host) continue;
3173
+ host[key] = value;
3174
+ merged = true;
3175
+ }
3176
+ const marketplaces = isRecord(host["marketplaces"]) ? Object.keys(host["marketplaces"]) : [];
3177
+ return {
3178
+ text: merged ? stringify(host) : hostSanitizedText,
3179
+ marketplaces,
3180
+ mergedFromBox: merged
3181
+ };
2777
3182
  }
2778
3183
  var CREDENTIALS_BACKUP_FILE = resolveAgentSpec("claude").credential.hostBackup;
2779
3184
  var CLOUD_WORKSPACE = "/workspace";
2780
- async function pathExists4(p) {
3185
+ async function pathExists5(p) {
2781
3186
  try {
2782
- await stat8(p);
3187
+ await stat9(p);
2783
3188
  return true;
2784
3189
  } catch {
2785
3190
  return false;
@@ -2790,15 +3195,15 @@ async function findBrokenSymlinks(root) {
2790
3195
  async function walk(dir) {
2791
3196
  let entries;
2792
3197
  try {
2793
- entries = await readdir5(dir, { withFileTypes: true });
3198
+ entries = await readdir6(dir, { withFileTypes: true });
2794
3199
  } catch {
2795
3200
  return;
2796
3201
  }
2797
3202
  for (const ent of entries) {
2798
- const full = join14(dir, ent.name);
3203
+ const full = join17(dir, ent.name);
2799
3204
  if (ent.isSymbolicLink()) {
2800
3205
  try {
2801
- await stat8(full);
3206
+ await stat9(full);
2802
3207
  } catch {
2803
3208
  broken.push(relative2(root, full));
2804
3209
  }
@@ -2811,7 +3216,7 @@ async function findBrokenSymlinks(root) {
2811
3216
  return broken;
2812
3217
  }
2813
3218
  async function mkStageDir(prefix) {
2814
- return mkdtemp4(join14(tmpdir4(), `agentbox-${prefix}-stage-`));
3219
+ return mkdtemp6(join17(tmpdir6(), `agentbox-${prefix}-stage-`));
2815
3220
  }
2816
3221
  var STAGE_WRITABLE_CHMOD = "--chmod=Du+rwx,Fu+rw";
2817
3222
  function emptyResult(warnings = []) {
@@ -2819,7 +3224,7 @@ function emptyResult(warnings = []) {
2819
3224
  }, warnings };
2820
3225
  }
2821
3226
  async function tarballFromDir(stageDir, agent) {
2822
- const tarballPath = join14(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
3227
+ const tarballPath = join17(tmpdir6(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
2823
3228
  await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
2824
3229
  env: { ...process.env, COPYFILE_DISABLE: "1" }
2825
3230
  });
@@ -2828,7 +3233,7 @@ async function tarballFromDir(stageDir, agent) {
2828
3233
  function makeCleanup(paths) {
2829
3234
  return async () => {
2830
3235
  for (const p of paths) {
2831
- await rm5(p, { recursive: true, force: true });
3236
+ await rm7(p, { recursive: true, force: true });
2832
3237
  }
2833
3238
  };
2834
3239
  }
@@ -2836,7 +3241,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
2836
3241
  const stageDir = await mkStageDir(agent);
2837
3242
  let tarballPath = null;
2838
3243
  try {
2839
- await copyFile2(sourcePath, join14(stageDir, tarballEntryName));
3244
+ await copyFile2(sourcePath, join17(stageDir, tarballEntryName));
2840
3245
  tarballPath = await tarballFromDir(stageDir, agent);
2841
3246
  return {
2842
3247
  tarballPath,
@@ -2844,19 +3249,19 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
2844
3249
  warnings: []
2845
3250
  };
2846
3251
  } catch (err) {
2847
- await rm5(stageDir, { recursive: true, force: true });
2848
- if (tarballPath) await rm5(tarballPath, { force: true });
3252
+ await rm7(stageDir, { recursive: true, force: true });
3253
+ if (tarballPath) await rm7(tarballPath, { force: true });
2849
3254
  throw err;
2850
3255
  }
2851
3256
  }
2852
3257
  var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
2853
3258
  async function buildBoxClaudeJsonFromHost(opts) {
2854
3259
  const { hostHome, hostWorkspace } = opts;
2855
- const hostClaudeJson = join14(hostHome, ".claude.json");
3260
+ const hostClaudeJson = join17(hostHome, ".claude.json");
2856
3261
  let working;
2857
- if (await pathExists4(hostClaudeJson)) {
3262
+ if (await pathExists5(hostClaudeJson)) {
2858
3263
  try {
2859
- working = JSON.parse(await readFile8(hostClaudeJson, "utf8"));
3264
+ working = JSON.parse(await readFile9(hostClaudeJson, "utf8"));
2860
3265
  } catch {
2861
3266
  working = null;
2862
3267
  }
@@ -2887,7 +3292,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
2887
3292
  return working;
2888
3293
  }
2889
3294
  async function stageClaudeJsonOnlyForUpload(opts = {}) {
2890
- const hostHome = opts.hostHome ?? homedir10();
3295
+ const hostHome = opts.hostHome ?? homedir11();
2891
3296
  const stageDir = await mkStageDir("claude-json-only");
2892
3297
  let tarballPath = null;
2893
3298
  try {
@@ -2895,7 +3300,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
2895
3300
  hostHome,
2896
3301
  hostWorkspace: opts.hostWorkspace
2897
3302
  });
2898
- await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
3303
+ await writeFile7(join17(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
2899
3304
  tarballPath = await tarballFromDir(stageDir, "claude-json-only");
2900
3305
  return {
2901
3306
  tarballPath,
@@ -2903,15 +3308,15 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
2903
3308
  warnings: []
2904
3309
  };
2905
3310
  } catch (err) {
2906
- await rm5(stageDir, { recursive: true, force: true });
2907
- if (tarballPath) await rm5(tarballPath, { force: true });
3311
+ await rm7(stageDir, { recursive: true, force: true });
3312
+ if (tarballPath) await rm7(tarballPath, { force: true });
2908
3313
  throw err;
2909
3314
  }
2910
3315
  }
2911
3316
  async function stageClaudeStaticForUpload(opts = {}) {
2912
- const hostHome = opts.hostHome ?? homedir10();
2913
- const hostClaude = join14(hostHome, ".claude");
2914
- if (!await pathExists4(hostClaude)) return emptyResult();
3317
+ const hostHome = opts.hostHome ?? homedir11();
3318
+ const hostClaude = join17(hostHome, ".claude");
3319
+ if (!await pathExists5(hostClaude)) return emptyResult();
2915
3320
  const stageDir = await mkStageDir("claude-static");
2916
3321
  let tarballPath = null;
2917
3322
  try {
@@ -2928,13 +3333,13 @@ async function stageClaudeStaticForUpload(opts = {}) {
2928
3333
  `${hostClaude}/`,
2929
3334
  `${stageDir}/`
2930
3335
  ]);
2931
- const settingsPath = join14(stageDir, "settings.json");
2932
- if (await pathExists4(settingsPath)) {
3336
+ const settingsPath = join17(stageDir, "settings.json");
3337
+ if (await pathExists5(settingsPath)) {
2933
3338
  try {
2934
- const parsed = JSON.parse(await readFile8(settingsPath, "utf8"));
3339
+ const parsed = JSON.parse(await readFile9(settingsPath, "utf8"));
2935
3340
  const filtered = filterHostHooks(parsed, hostHome);
2936
3341
  if (filtered.removedCommands.length > 0) {
2937
- await writeFile5(settingsPath, JSON.stringify(filtered.data, null, 2));
3342
+ await writeFile7(settingsPath, JSON.stringify(filtered.data, null, 2));
2938
3343
  }
2939
3344
  } catch {
2940
3345
  }
@@ -2943,17 +3348,17 @@ async function stageClaudeStaticForUpload(opts = {}) {
2943
3348
  hostHome,
2944
3349
  hostWorkspace: opts.hostWorkspace
2945
3350
  });
2946
- await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
2947
- const pluginsDir = join14(stageDir, "plugins");
2948
- if (await pathExists4(pluginsDir)) {
3351
+ await writeFile7(join17(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
3352
+ const pluginsDir = join17(stageDir, "plugins");
3353
+ if (await pathExists5(pluginsDir)) {
2949
3354
  try {
2950
- const entries = await readdir5(pluginsDir, { withFileTypes: true });
3355
+ const entries = await readdir6(pluginsDir, { withFileTypes: true });
2951
3356
  for (const ent of entries) {
2952
3357
  if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
2953
- const file = join14(pluginsDir, ent.name);
2954
- const raw = await readFile8(file, "utf8");
3358
+ const file = join17(pluginsDir, ent.name);
3359
+ const raw = await readFile9(file, "utf8");
2955
3360
  const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
2956
- if (replaced !== raw) await writeFile5(file, replaced);
3361
+ if (replaced !== raw) await writeFile7(file, replaced);
2957
3362
  }
2958
3363
  } catch {
2959
3364
  }
@@ -2965,29 +3370,51 @@ async function stageClaudeStaticForUpload(opts = {}) {
2965
3370
  warnings: []
2966
3371
  };
2967
3372
  } catch (err) {
2968
- await rm5(stageDir, { recursive: true, force: true });
2969
- if (tarballPath) await rm5(tarballPath, { force: true });
3373
+ await rm7(stageDir, { recursive: true, force: true });
3374
+ if (tarballPath) await rm7(tarballPath, { force: true });
2970
3375
  throw err;
2971
3376
  }
2972
3377
  }
2973
3378
  async function stageClaudeCredentialsForUpload() {
2974
- if (!await pathExists4(CREDENTIALS_BACKUP_FILE)) return emptyResult();
3379
+ if (!await pathExists5(CREDENTIALS_BACKUP_FILE)) return emptyResult();
2975
3380
  return stageSingleFileTarball("claude-creds", CREDENTIALS_BACKUP_FILE, ".credentials.json");
2976
3381
  }
2977
3382
  var CODEX_STATIC_EXCLUDES = resolveAgentSpec("codex").staticPaths[0]?.exclude ?? [];
3383
+ var CODEX_STATIC_INCLUDES = resolveAgentSpec("codex").staticPaths[0]?.include ?? [];
2978
3384
  var CODEX_KEYCHAIN_WARNING = 'codex: ~/.codex/auth.json missing. On macOS the codex CLI defaults to storing the OAuth token in the system Keychain, which isn\'t reachable from a remote sandbox. To share creds with cloud boxes either:\n - add `cli_auth_credentials_store = "file"` to ~/.codex/config.toml then re-run `codex login`, or\n - set OPENAI_API_KEY in your environment, or\n - run `codex login --with-api-key` for a file-backed login.\nSkipping codex seed; in-box codex will prompt for sign-in.';
2979
3385
  async function sanitizeStagedCodexConfig(configPath, hostHome) {
2980
3386
  try {
2981
- if (!await pathExists4(configPath)) return;
2982
- const { text, changed } = sanitizeCodexConfigForBox(await readFile8(configPath, "utf8"), hostHome);
2983
- if (changed) await writeFile5(configPath, text);
3387
+ if (!await pathExists5(configPath)) return { keptMarketplaces: [] };
3388
+ const { text, changed, keptMarketplaces } = sanitizeCodexConfigForBox(
3389
+ await readFile9(configPath, "utf8"),
3390
+ hostHome
3391
+ );
3392
+ if (changed) await writeFile7(configPath, text);
3393
+ return { keptMarketplaces };
2984
3394
  } catch {
3395
+ return null;
3396
+ }
3397
+ }
3398
+ async function purgeOrphanCodexMarketplaceDirs(stageDir, keptMarketplaces) {
3399
+ const kept = new Set(keptMarketplaces);
3400
+ for (const rel of ["plugins/cache", ".tmp/marketplaces"]) {
3401
+ const dir = join17(stageDir, rel);
3402
+ let entries;
3403
+ try {
3404
+ entries = await readdir6(dir);
3405
+ } catch {
3406
+ continue;
3407
+ }
3408
+ for (const name of entries) {
3409
+ if (kept.has(name)) continue;
3410
+ await rm7(join17(dir, name), { recursive: true, force: true });
3411
+ }
2985
3412
  }
2986
3413
  }
2987
3414
  async function stageCodexStaticForUpload(opts = {}) {
2988
- const hostHome = opts.hostHome ?? homedir10();
2989
- const hostCodex = join14(hostHome, ".codex");
2990
- if (!await pathExists4(hostCodex)) return emptyResult();
3415
+ const hostHome = opts.hostHome ?? homedir11();
3416
+ const hostCodex = join17(hostHome, ".codex");
3417
+ if (!await pathExists5(hostCodex)) return emptyResult();
2991
3418
  const stageDir = await mkStageDir("codex-static");
2992
3419
  let tarballPath = null;
2993
3420
  try {
@@ -2997,11 +3424,15 @@ async function stageCodexStaticForUpload(opts = {}) {
2997
3424
  STAGE_WRITABLE_CHMOD,
2998
3425
  "-L",
2999
3426
  ...codexBroken.map((r) => `--exclude=/${r}`),
3427
+ ...CODEX_STATIC_INCLUDES.map((p) => `--include=${p}`),
3000
3428
  ...CODEX_STATIC_EXCLUDES.map((p) => `--exclude=${p}`),
3001
3429
  `${hostCodex}/`,
3002
3430
  `${stageDir}/`
3003
3431
  ]);
3004
- await sanitizeStagedCodexConfig(join14(stageDir, "config.toml"), hostHome);
3432
+ const sanitized = await sanitizeStagedCodexConfig(join17(stageDir, "config.toml"), hostHome);
3433
+ if (sanitized !== null) {
3434
+ await purgeOrphanCodexMarketplaceDirs(stageDir, sanitized.keptMarketplaces);
3435
+ }
3005
3436
  tarballPath = await tarballFromDir(stageDir, "codex-static");
3006
3437
  return {
3007
3438
  tarballPath,
@@ -3009,15 +3440,15 @@ async function stageCodexStaticForUpload(opts = {}) {
3009
3440
  warnings: []
3010
3441
  };
3011
3442
  } catch (err) {
3012
- await rm5(stageDir, { recursive: true, force: true });
3013
- if (tarballPath) await rm5(tarballPath, { force: true });
3443
+ await rm7(stageDir, { recursive: true, force: true });
3444
+ if (tarballPath) await rm7(tarballPath, { force: true });
3014
3445
  throw err;
3015
3446
  }
3016
3447
  }
3017
3448
  async function stageAgentsStaticForUpload(opts = {}) {
3018
- const hostHome = opts.hostHome ?? homedir10();
3019
- const hostAgents = join14(hostHome, ".agents");
3020
- if (!await pathExists4(hostAgents)) return emptyResult();
3449
+ const hostHome = opts.hostHome ?? homedir11();
3450
+ const hostAgents = join17(hostHome, ".agents");
3451
+ if (!await pathExists5(hostAgents)) return emptyResult();
3021
3452
  const stageDir = await mkStageDir("agents-static");
3022
3453
  let tarballPath = null;
3023
3454
  try {
@@ -3037,28 +3468,28 @@ async function stageAgentsStaticForUpload(opts = {}) {
3037
3468
  warnings: []
3038
3469
  };
3039
3470
  } catch (err) {
3040
- await rm5(stageDir, { recursive: true, force: true });
3041
- if (tarballPath) await rm5(tarballPath, { force: true });
3471
+ await rm7(stageDir, { recursive: true, force: true });
3472
+ if (tarballPath) await rm7(tarballPath, { force: true });
3042
3473
  throw err;
3043
3474
  }
3044
3475
  }
3045
3476
  async function stageCodexCredentialsForUpload(opts = {}) {
3046
- const hostHome = opts.hostHome ?? homedir10();
3047
- const cloudBackup = join14(hostHome, ".agentbox", "codex-credentials.json");
3048
- if (await pathExists4(cloudBackup)) {
3477
+ const hostHome = opts.hostHome ?? homedir11();
3478
+ const cloudBackup = join17(hostHome, ".agentbox", "codex-credentials.json");
3479
+ if (await pathExists5(cloudBackup)) {
3049
3480
  return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
3050
3481
  }
3051
- const hostAuth = join14(hostHome, ".codex", "auth.json");
3052
- if (!await pathExists4(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
3482
+ const hostAuth = join17(hostHome, ".codex", "auth.json");
3483
+ if (!await pathExists5(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
3053
3484
  return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
3054
3485
  }
3055
3486
  var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
3056
3487
  async function stageOpencodeStaticForUpload(opts = {}) {
3057
- const hostHome = opts.hostHome ?? homedir10();
3058
- const hostData = join14(hostHome, ".local", "share", "opencode");
3059
- const hostConfig = join14(hostHome, ".config", "opencode");
3060
- const hasData = await pathExists4(hostData);
3061
- const hasConfig = await pathExists4(hostConfig);
3488
+ const hostHome = opts.hostHome ?? homedir11();
3489
+ const hostData = join17(hostHome, ".local", "share", "opencode");
3490
+ const hostConfig = join17(hostHome, ".config", "opencode");
3491
+ const hasData = await pathExists5(hostData);
3492
+ const hasConfig = await pathExists5(hostConfig);
3062
3493
  if (!hasData && !hasConfig) return emptyResult();
3063
3494
  const stageDir = await mkStageDir("opencode-static");
3064
3495
  let tarballPath = null;
@@ -3076,7 +3507,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
3076
3507
  ]);
3077
3508
  }
3078
3509
  if (hasConfig) {
3079
- const configStage = join14(stageDir, "config");
3510
+ const configStage = join17(stageDir, "config");
3080
3511
  const cfgBroken = await findBrokenSymlinks(hostConfig);
3081
3512
  await execa("rsync", [
3082
3513
  "-a",
@@ -3094,25 +3525,25 @@ async function stageOpencodeStaticForUpload(opts = {}) {
3094
3525
  warnings: []
3095
3526
  };
3096
3527
  } catch (err) {
3097
- await rm5(stageDir, { recursive: true, force: true });
3098
- if (tarballPath) await rm5(tarballPath, { force: true });
3528
+ await rm7(stageDir, { recursive: true, force: true });
3529
+ if (tarballPath) await rm7(tarballPath, { force: true });
3099
3530
  throw err;
3100
3531
  }
3101
3532
  }
3102
3533
  async function stageOpencodeCredentialsForUpload(opts = {}) {
3103
- const hostHome = opts.hostHome ?? homedir10();
3104
- const cloudBackup = join14(hostHome, ".agentbox", "opencode-credentials.json");
3105
- if (await pathExists4(cloudBackup)) {
3534
+ const hostHome = opts.hostHome ?? homedir11();
3535
+ const cloudBackup = join17(hostHome, ".agentbox", "opencode-credentials.json");
3536
+ if (await pathExists5(cloudBackup)) {
3106
3537
  return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
3107
3538
  }
3108
- const hostAuth = join14(hostHome, ".local", "share", "opencode", "auth.json");
3109
- if (!await pathExists4(hostAuth)) return emptyResult();
3539
+ const hostAuth = join17(hostHome, ".local", "share", "opencode", "auth.json");
3540
+ if (!await pathExists5(hostAuth)) return emptyResult();
3110
3541
  return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
3111
3542
  }
3112
3543
  async function stageOpencodeStateForUpload(opts = {}) {
3113
- const hostHome = opts.hostHome ?? homedir10();
3114
- const hostModel = join14(hostHome, ".local", "state", "opencode", "model.json");
3115
- if (!await pathExists4(hostModel)) return emptyResult();
3544
+ const hostHome = opts.hostHome ?? homedir11();
3545
+ const hostModel = join17(hostHome, ".local", "state", "opencode", "model.json");
3546
+ if (!await pathExists5(hostModel)) return emptyResult();
3116
3547
  return stageSingleFileTarball("opencode-state", hostModel, "model.json");
3117
3548
  }
3118
3549
  var CLAUDE_STATIC_BOX_DIR = "/home/vscode/.claude";
@@ -3137,7 +3568,7 @@ function preparedStatePathFor(provider) {
3137
3568
  if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
3138
3569
  throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
3139
3570
  }
3140
- return pathResolve(homedir11(), ".agentbox", `${provider}-prepared.json`);
3571
+ return pathResolve(homedir12(), ".agentbox", `${provider}-prepared.json`);
3141
3572
  }
3142
3573
  function readPreparedStateRaw(provider) {
3143
3574
  const path = preparedStatePathFor(provider);
@@ -3150,14 +3581,14 @@ function readPreparedStateRaw(provider) {
3150
3581
  }
3151
3582
  function writePreparedStateRaw(provider, state) {
3152
3583
  const path = preparedStatePathFor(provider);
3153
- mkdirSync3(dirname8(path), { recursive: true });
3584
+ mkdirSync3(dirname10(path), { recursive: true });
3154
3585
  const body = JSON.stringify(state, null, 2) + "\n";
3155
3586
  const tmp = `${path}.tmp`;
3156
3587
  writeFileSync3(tmp, body, { mode: 384 });
3157
3588
  renameSync2(tmp, path);
3158
3589
  }
3159
3590
  async function sha256OfFile(path) {
3160
- const buf = await readFile9(path);
3591
+ const buf = await readFile10(path);
3161
3592
  return createHash3("sha256").update(buf).digest("hex");
3162
3593
  }
3163
3594
  async function computeContextSha256(files) {
@@ -3238,11 +3669,11 @@ import { dirname as dirname23, resolve as resolve23 } from "path";
3238
3669
  import { fileURLToPath as fileURLToPath2 } from "url";
3239
3670
  import { existsSync as existsSync5 } from "fs";
3240
3671
  import { fileURLToPath } from "url";
3241
- import { dirname as dirname9, resolve as resolve4 } from "path";
3672
+ import { dirname as dirname7, resolve as resolve4 } from "path";
3242
3673
  var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
3243
3674
  async function resolveClaudeInstallMode() {
3244
3675
  try {
3245
- const { loadEffectiveConfig } = await import("./dist-STQK5XM6.js");
3676
+ const { loadEffectiveConfig } = await import("./dist-GF5EBRNG.js");
3246
3677
  const cfg = await loadEffectiveConfig(process.cwd());
3247
3678
  return cfg.effective.box.claudeInstall;
3248
3679
  } catch {
@@ -3253,7 +3684,7 @@ var BOX_IMAGE_REGISTRY = "ghcr.io/madarco/agentbox/box";
3253
3684
  function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
3254
3685
  return `${registry}:sha-${sha.slice(0, 16)}`;
3255
3686
  }
3256
- var here = dirname9(fileURLToPath(import.meta.url));
3687
+ var here = dirname7(fileURLToPath(import.meta.url));
3257
3688
  function resolveDockerBuild() {
3258
3689
  const override = process.env.AGENTBOX_DOCKER_CONTEXT;
3259
3690
  if (override && existsSync5(resolve4(override, "Dockerfile.box"))) {
@@ -3356,7 +3787,7 @@ async function buildImage(opts = {}) {
3356
3787
  return ref;
3357
3788
  }
3358
3789
  async function pullOrBuild(ref, fingerprint, opts = {}) {
3359
- const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-BUO75YLZ-UICXTY25.js");
3790
+ const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-BUO75YLZ-O4GZMDRF.js");
3360
3791
  const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
3361
3792
  const allowPull = opts.allowPull !== false;
3362
3793
  if (allowPull && registry && fingerprint) {
@@ -3383,7 +3814,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
3383
3814
  return { source: "built" };
3384
3815
  }
3385
3816
  async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
3386
- const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-BUO75YLZ-UICXTY25.js");
3817
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-BUO75YLZ-O4GZMDRF.js");
3387
3818
  const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
3388
3819
  const rawFingerprint = await computeDockerContextFingerprint2({
3389
3820
  contextDir: opts.contextDir
@@ -3433,7 +3864,7 @@ function classifyDockerBaseFreshness(input) {
3433
3864
  return { state: "fresh" };
3434
3865
  }
3435
3866
  async function evaluateDockerBaseFreshness(opts = {}) {
3436
- const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-BUO75YLZ-UICXTY25.js");
3867
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-BUO75YLZ-O4GZMDRF.js");
3437
3868
  const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
3438
3869
  const imagePresent = await imageExists(ref);
3439
3870
  if (!imagePresent) return { state: "unprepared" };
@@ -3528,6 +3959,9 @@ export {
3528
3959
  syncAgentboxSshConfig,
3529
3960
  autoWriteSshConfig,
3530
3961
  mintSshKey,
3962
+ parseInboundSpec,
3963
+ resolveInboundSources,
3964
+ describeInbound,
3531
3965
  BOX_WORKSPACE,
3532
3966
  boxGitCheckout,
3533
3967
  boxGitNewBranch,
@@ -3543,6 +3977,15 @@ export {
3543
3977
  isSupportedApiVersion,
3544
3978
  pluginForProvider,
3545
3979
  renderCarryEntries,
3980
+ AGENT_SYNC_SPECS,
3981
+ referencedPluginVersionKeys,
3982
+ claudeInventoryScript,
3983
+ parseClaudeInventory,
3984
+ computeClaudePullPlan,
3985
+ writeClaudeMergedRegistries,
3986
+ CODEX_PULL_ITEMS,
3987
+ OPENCODE_PULL_DATA_ITEMS,
3988
+ OPENCODE_PULL_CONFIG_ITEMS,
3546
3989
  makeSyncContext,
3547
3990
  DEFAULT_ENV_PATTERNS,
3548
3991
  ENV_PRUNE_DIRS,
@@ -3562,6 +4005,11 @@ export {
3562
4005
  hostClaudeBackupExpired,
3563
4006
  hostBackupHasCredentials,
3564
4007
  extractCredentials,
4008
+ parseCredentialsUpdate,
4009
+ shouldAcceptCredentialUpdate,
4010
+ writeCredentialBackup,
4011
+ readCredentialBackup,
4012
+ pushCredentialToBox,
3565
4013
  resyncWorkspace,
3566
4014
  makeHostGitPorts,
3567
4015
  BOX_WORKFLOWS_DIR,
@@ -3576,6 +4024,7 @@ export {
3576
4024
  setInstallMethodNative,
3577
4025
  MINIMAL_TRUSTED_CODEX_CONFIG,
3578
4026
  sanitizeCodexConfigForBox,
4027
+ mergeCodexConfigForBox,
3579
4028
  stageClaudeJsonOnlyForUpload,
3580
4029
  stageClaudeStaticForUpload,
3581
4030
  stageClaudeCredentialsForUpload,