@madarco/agentbox 0.22.2 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/{_cloud-attach-Y5WZ7F53.js → _cloud-attach-RFPLNACE.js} +4 -4
  3. package/dist/{chunk-BMCT3LBE.js → chunk-6OQENOJZ.js} +8 -8
  4. package/dist/{chunk-ES2DDCAC.js → chunk-CKC3CP7Y.js} +284 -154
  5. package/dist/chunk-CKC3CP7Y.js.map +1 -0
  6. package/dist/{chunk-AYNGC4Z5.js → chunk-ERMU7RMK.js} +43 -58
  7. package/dist/{chunk-AYNGC4Z5.js.map → chunk-ERMU7RMK.js.map} +1 -1
  8. package/dist/chunk-G3H2L3O2.js +0 -0
  9. package/dist/{chunk-3KAWXDQ4.js → chunk-JXDSSSXS.js} +3 -3
  10. package/dist/{chunk-S4OWE3UD.js → chunk-L5SOSNQI.js} +3 -3
  11. package/dist/{chunk-V2NCCC2B.js → chunk-Q626V2YX.js} +2 -2
  12. package/dist/{chunk-5DZTXHLQ.js → chunk-QGL734YX.js} +169 -52
  13. package/dist/chunk-QGL734YX.js.map +1 -0
  14. package/dist/chunk-QT3SHMLY.js +0 -0
  15. package/dist/{chunk-7HAGPF4X.js → chunk-QVWGQJV6.js} +2 -2
  16. package/dist/chunk-WJFZJZIM.js +0 -0
  17. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  18. package/dist/dist-2BTJQUJS.js +0 -0
  19. package/dist/{dist-SJRMFVRV.js → dist-GEHCZJCS.js} +5 -5
  20. package/dist/{dist-AN5NUXA5.js → dist-GJCIKH2C.js} +5 -5
  21. package/dist/{dist-FNAGMTUI.js → dist-JFUUDAI3.js} +17 -3
  22. package/dist/{dist-VOVN64Y2.js → dist-W5476E2U.js} +5 -5
  23. package/dist/{dist-K5GASNBV.js → dist-Z3GSHEFO.js} +7 -6
  24. package/dist/index.js +391 -215
  25. package/dist/index.js.map +1 -1
  26. package/dist/{prepared-state-5FIGV4BE-WPHOEDA6.js → prepared-state-LW2PKTEQ-5YMKG7UN.js} +2 -2
  27. package/package.json +28 -27
  28. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  29. package/runtime/_shared/agentbox-dockerd-start +0 -0
  30. package/runtime/_shared/agentbox-open +0 -0
  31. package/runtime/_shared/agentbox-portless-trust +0 -0
  32. package/runtime/_shared/agentbox-vnc-start +0 -0
  33. package/runtime/_shared/ctl.cjs +3 -1
  34. package/runtime/_shared/gh-shim +0 -0
  35. package/runtime/_shared/git-shim +0 -0
  36. package/runtime/_shared/linear-shim +0 -0
  37. package/runtime/_shared/ntn-shim +0 -0
  38. package/runtime/docker/Dockerfile.box +12 -0
  39. package/runtime/docker/packages/ctl/dist/bin.cjs +3 -1
  40. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  41. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  42. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  43. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  44. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +44 -0
  45. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  46. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  47. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  48. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +0 -0
  49. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  50. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  51. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  52. package/runtime/e2b/agentbox-dockerd-start +0 -0
  53. package/runtime/e2b/agentbox-open +0 -0
  54. package/runtime/e2b/agentbox-vnc-start +0 -0
  55. package/runtime/e2b/ctl.cjs +3 -1
  56. package/runtime/e2b/gh-shim +0 -0
  57. package/runtime/e2b/git-shim +0 -0
  58. package/runtime/e2b/linear-shim +0 -0
  59. package/runtime/e2b/ntn-shim +0 -0
  60. package/runtime/e2b/scripts/build-template.sh +0 -0
  61. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  62. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  63. package/runtime/hetzner/agentbox-open +0 -0
  64. package/runtime/hetzner/agentbox-portless-trust +0 -0
  65. package/runtime/hetzner/agentbox-vnc-start +0 -0
  66. package/runtime/hetzner/ctl.cjs +3 -1
  67. package/runtime/hetzner/gh-shim +0 -0
  68. package/runtime/hetzner/git-shim +0 -0
  69. package/runtime/hetzner/linear-shim +0 -0
  70. package/runtime/hetzner/ntn-shim +0 -0
  71. package/runtime/hetzner/scripts/install-box.sh +0 -0
  72. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  73. package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +2 -0
  74. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  75. package/runtime/hub/apps/hub/.next/routes-manifest.json +14 -0
  76. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page_client-reference-manifest.js +1 -1
  77. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/app-paths-manifest.json +3 -0
  78. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/build-manifest.json +9 -0
  79. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/server-reference-manifest.json +4 -0
  80. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js +9 -0
  81. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.map +5 -0
  82. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.nft.json +1 -0
  83. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route_client-reference-manifest.js +3 -0
  84. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/app-paths-manifest.json +3 -0
  85. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/build-manifest.json +9 -0
  86. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/server-reference-manifest.json +4 -0
  87. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js +8 -0
  88. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.map +5 -0
  89. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.nft.json +1 -0
  90. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route_client-reference-manifest.js +3 -0
  91. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
  92. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  93. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  94. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
  95. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  96. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  97. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  98. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  99. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  100. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  101. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  102. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  103. package/runtime/hub/apps/hub/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  104. package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +2 -0
  105. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_open-targets_route_actions_1z-vd4m.js +3 -0
  106. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_open_route_actions_1agwl8h.js +3 -0
  107. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  108. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ql4fjo._.js +1 -1
  109. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vs8fma._.js +1 -1
  110. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w9ud8u._.js +1 -1
  111. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yhb0gc._.js +1 -1
  112. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-0flwc._.js +3 -0
  113. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1a50b07._.js +3 -0
  114. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +2 -2
  115. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dn_3i1._.js +1 -1
  116. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +1 -1
  117. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1js2jdv._.js +1 -1
  118. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1nepkp-._.js +1 -1
  119. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q5bqse._.js +1 -1
  120. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +2 -2
  121. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thipug._.js +3 -0
  122. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9om6g._.js +1 -1
  123. package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
  124. package/runtime/hub/apps/hub/.next/server/chunks/_0f3molr._.js +3 -0
  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/chunks/ssr/apps_hub_app_(dashboard)_boxes_[id]_page_tsx_1-j_972._.js +1 -1
  128. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_components_box-table_tsx_0a9pyn_._.js +1 -1
  129. package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +2 -0
  130. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  131. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  132. package/runtime/hub/apps/hub/.next/static/chunks/1py5tlz57h7ra.js +1 -0
  133. package/runtime/hub/apps/hub/.next/static/chunks/{3y2c7woqhtx9s.js → 23fswvjrabu89.js} +1 -1
  134. package/runtime/hub/apps/hub/.next/static/chunks/3nedwutnzpdis.css +3 -0
  135. package/runtime/hub/apps/hub/.next/static/chunks/3p86ecqhr_7yy.js +1 -0
  136. package/runtime/hub/apps/hub/.next/static/chunks/3qof5hg87qf5n.js +1 -0
  137. package/runtime/hub/apps/hub/{chunk-673QOHSR.js → chunk-6HD4PARX.js} +9 -9
  138. package/runtime/hub/apps/hub/{chunk-7J6ZFTT4.js → chunk-JQFB2CNA.js} +132 -16
  139. package/runtime/hub/apps/hub/{chunk-5XQ3T3W2.js → chunk-K6RA5GJI.js} +231 -126
  140. package/runtime/hub/apps/hub/{dist-GCALYJN7.js → dist-3HR4RIPE.js} +17 -3
  141. package/runtime/hub/apps/hub/{dist-EI54M5DP.js → dist-7GNKBKFV.js} +29 -42
  142. package/runtime/hub/apps/hub/{dist-MOCUH2OC.js → dist-JWVTVHBT.js} +4 -4
  143. package/runtime/hub/apps/hub/{dist-LYTWBTUL.js → dist-OUNL2TCW.js} +4 -4
  144. package/runtime/hub/apps/hub/{dist-K7WHNDZB.js → dist-TOHA4OA5.js} +4 -4
  145. package/runtime/hub/apps/hub/{prepared-state-5FIGV4BE-D2HJEY2L.js → prepared-state-LW2PKTEQ-7BCXARGA.js} +1 -1
  146. package/runtime/hub/apps/hub/server.js +105 -24
  147. package/runtime/relay/bin.cjs +3 -1
  148. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  149. package/runtime/vercel/agentbox-dockerd-start +0 -0
  150. package/runtime/vercel/agentbox-open +0 -0
  151. package/runtime/vercel/agentbox-vnc-start +0 -0
  152. package/runtime/vercel/ctl.cjs +3 -1
  153. package/runtime/vercel/gh-shim +0 -0
  154. package/runtime/vercel/git-shim +0 -0
  155. package/runtime/vercel/linear-shim +0 -0
  156. package/runtime/vercel/ntn-shim +0 -0
  157. package/runtime/vercel/scripts/provision.sh +0 -0
  158. package/LICENSE +0 -21
  159. package/dist/chunk-5DZTXHLQ.js.map +0 -1
  160. package/dist/chunk-ES2DDCAC.js.map +0 -1
  161. package/runtime/hub/apps/hub/.next/static/chunks/0dx4alyqu7cq1.css +0 -3
  162. package/runtime/hub/apps/hub/.next/static/chunks/332lo0ac7l2wv.js +0 -1
  163. package/runtime/hub/apps/hub/.next/static/chunks/3gdqmzzl34ilu.js +0 -1
  164. package/runtime/hub/apps/hub/.next/static/chunks/44exu5uemf-ev.js +0 -1
  165. /package/dist/{_cloud-attach-Y5WZ7F53.js.map → _cloud-attach-RFPLNACE.js.map} +0 -0
  166. /package/dist/{chunk-BMCT3LBE.js.map → chunk-6OQENOJZ.js.map} +0 -0
  167. /package/dist/{chunk-3KAWXDQ4.js.map → chunk-JXDSSSXS.js.map} +0 -0
  168. /package/dist/{chunk-S4OWE3UD.js.map → chunk-L5SOSNQI.js.map} +0 -0
  169. /package/dist/{chunk-V2NCCC2B.js.map → chunk-Q626V2YX.js.map} +0 -0
  170. /package/dist/{chunk-7HAGPF4X.js.map → chunk-QVWGQJV6.js.map} +0 -0
  171. /package/dist/{dist-SJRMFVRV.js.map → dist-GEHCZJCS.js.map} +0 -0
  172. /package/dist/{dist-AN5NUXA5.js.map → dist-GJCIKH2C.js.map} +0 -0
  173. /package/dist/{dist-FNAGMTUI.js.map → dist-JFUUDAI3.js.map} +0 -0
  174. /package/dist/{dist-K5GASNBV.js.map → dist-W5476E2U.js.map} +0 -0
  175. /package/dist/{dist-VOVN64Y2.js.map → dist-Z3GSHEFO.js.map} +0 -0
  176. /package/dist/{prepared-state-5FIGV4BE-WPHOEDA6.js.map → prepared-state-LW2PKTEQ-5YMKG7UN.js.map} +0 -0
  177. /package/runtime/hub/apps/hub/.next/static/{zT1paOSXMJpAPsZ1dFK2V → 6WtaFwavHBpin3eT7-HjR}/_buildManifest.js +0 -0
  178. /package/runtime/hub/apps/hub/.next/static/{zT1paOSXMJpAPsZ1dFK2V → 6WtaFwavHBpin3eT7-HjR}/_clientMiddlewareManifest.js +0 -0
  179. /package/runtime/hub/apps/hub/.next/static/{zT1paOSXMJpAPsZ1dFK2V → 6WtaFwavHBpin3eT7-HjR}/_ssgManifest.js +0 -0
@@ -305,41 +305,46 @@ import { setTimeout as delay } from "timers/promises";
305
305
  import { readdir, stat as stat2 } from "fs/promises";
306
306
  import { join as join22 } from "path";
307
307
  import { promises as fs } from "fs";
308
+ import { homedir as homedir3 } from "os";
309
+ import { dirname as dirname3, join as join4 } from "path";
310
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
308
311
  import { homedir as homedir22 } from "os";
309
312
  import { dirname as dirname22, join as join3 } from "path";
310
- import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
311
- import { homedir as homedir3 } from "os";
312
- import { dirname as dirname3, resolve as resolve3 } from "path";
313
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
313
+ import { mkdir as mkdir2, readFile as readFile2 } from "fs/promises";
314
+ import { join as join5, resolve as resolve3 } from "path";
315
+ import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
314
316
  import { homedir as homedir4 } from "os";
315
- import { dirname as dirname4, join as join4 } from "path";
316
- import { mkdtemp, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
317
- import { tmpdir } from "os";
318
- import { basename as basename2, join as join5 } from "path";
319
- import { join as join6 } from "path";
317
+ import { dirname as dirname4, resolve as resolve22 } from "path";
318
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
320
319
  import { homedir as homedir5 } from "os";
320
+ import { dirname as dirname5, join as join6 } from "path";
321
+ import { mkdtemp, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
322
+ import { tmpdir } from "os";
323
+ import { basename as basename2, join as join7 } from "path";
324
+ import { join as join8 } from "path";
325
+ import { homedir as homedir6 } from "os";
321
326
  import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
322
327
  import { tmpdir as tmpdir2 } from "os";
323
- import { join as join7 } from "path";
328
+ import { join as join9 } from "path";
324
329
  import { readdir as readdir2, stat as stat4 } from "fs/promises";
325
- import { homedir as homedir6 } from "os";
326
- import { join as join8 } from "path";
330
+ import { homedir as homedir7 } from "os";
331
+ import { join as join10 } from "path";
327
332
  import { readdir as readdir3, realpath as realpath2, stat as stat5 } from "fs/promises";
328
- import { isAbsolute as isAbsolute3, join as join9, relative } from "path";
333
+ import { isAbsolute as isAbsolute3, join as join11, relative } from "path";
329
334
  import { stat as stat6 } from "fs/promises";
330
- import { chmod, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
331
- import { dirname as dirname5 } from "path";
335
+ import { chmod, mkdir as mkdir4, readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
336
+ import { dirname as dirname6 } from "path";
332
337
  import { createHash } from "crypto";
333
- import { readFile as readFile5 } from "fs/promises";
334
- import { join as join10 } from "path";
338
+ import { readFile as readFile6 } from "fs/promises";
339
+ import { join as join12 } from "path";
335
340
  import { createHash as createHash2 } from "crypto";
336
- import { copyFile, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile6, rm as rm4, stat as stat7 } from "fs/promises";
337
- import { homedir as homedir7, tmpdir as tmpdir3 } from "os";
338
- import { basename as basename22, dirname as dirname6, join as join11 } from "path";
339
- import { copyFile as copyFile2, mkdtemp as mkdtemp4, readdir as readdir5, readFile as readFile7, rm as rm5, stat as stat8, writeFile as writeFile5 } from "fs/promises";
340
- import { homedir as homedir9, tmpdir as tmpdir4 } from "os";
341
- import { basename as basename3, join as join12, relative as relative2 } from "path";
342
- import { homedir as homedir8 } from "os";
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";
343
348
 
344
349
  // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/date.js
345
350
  var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
@@ -1164,10 +1169,10 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
1164
1169
 
1165
1170
  // ../../packages/sandbox-core/dist/index.js
1166
1171
  import { createHash as createHash3 } from "crypto";
1167
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
1168
- import { readFile as readFile8 } from "fs/promises";
1169
- import { homedir as homedir10 } from "os";
1170
- import { dirname as dirname7, resolve as pathResolve } from "path";
1172
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
1173
+ import { readFile as readFile9 } from "fs/promises";
1174
+ import { homedir as homedir11 } from "os";
1175
+ import { dirname as dirname8, resolve as pathResolve } from "path";
1171
1176
  var STATE_DIR = join2(homedir2(), ".agentbox");
1172
1177
  var STATE_FILE = join2(STATE_DIR, "state.json");
1173
1178
  var EMPTY = { version: 1, boxes: [] };
@@ -1226,6 +1231,8 @@ async function readState(path = STATE_FILE) {
1226
1231
  if ((b.provider ?? "docker") === "docker" && !b.docker) {
1227
1232
  b.docker = projectDockerFields(b);
1228
1233
  }
1234
+ const legacySsh = b.cloud?.ssh;
1235
+ if (!b.ssh && legacySsh) b.ssh = legacySsh;
1229
1236
  }
1230
1237
  return parsed;
1231
1238
  } catch (err) {
@@ -1281,9 +1288,7 @@ async function recordBoxSsh(boxId, ssh, path = STATE_FILE) {
1281
1288
  await mutateState(
1282
1289
  (state) => ({
1283
1290
  version: 1,
1284
- boxes: state.boxes.map(
1285
- (b) => b.id === boxId && b.cloud ? { ...b, cloud: { ...b.cloud, ssh } } : b
1286
- )
1291
+ boxes: state.boxes.map((b) => b.id === boxId ? { ...b, ssh } : b)
1287
1292
  }),
1288
1293
  path
1289
1294
  );
@@ -1430,14 +1435,62 @@ var GitWorktreeError = class extends Error {
1430
1435
  function hostOpenCommand() {
1431
1436
  return process.platform === "linux" ? "xdg-open" : "open";
1432
1437
  }
1438
+ function claudeSettingsPath() {
1439
+ return join3(homedir22(), ".claude", "settings.json");
1440
+ }
1441
+ function readSettings(path) {
1442
+ if (!existsSync(path)) return {};
1443
+ let parsed;
1444
+ try {
1445
+ parsed = JSON.parse(readFileSync(path, "utf8"));
1446
+ } catch (err) {
1447
+ throw new Error(
1448
+ `${path} exists but is not valid JSON (${err instanceof Error ? err.message : String(err)}) \u2014 not touching it. Fix the file and retry.`
1449
+ );
1450
+ }
1451
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
1452
+ throw new Error(`${path} is not a JSON object \u2014 not touching it. Fix the file and retry.`);
1453
+ }
1454
+ return parsed;
1455
+ }
1456
+ function writeSettings(path, settings) {
1457
+ mkdirSync(dirname22(path), { recursive: true });
1458
+ writeFileSync(path, JSON.stringify(settings, null, 2) + "\n");
1459
+ }
1460
+ function entryId(e) {
1461
+ if (e !== null && typeof e === "object" && typeof e.id === "string") {
1462
+ return e.id;
1463
+ }
1464
+ return void 0;
1465
+ }
1466
+ function pruneOrphanClaudeSshConfigs(liveAliases) {
1467
+ return removeClaudeSshConfigs(
1468
+ (id) => id.startsWith("agentbox-") && !liveAliases.has(id.slice("agentbox-".length))
1469
+ );
1470
+ }
1471
+ function removeClaudeSshConfigs(predicate) {
1472
+ const path = claudeSettingsPath();
1473
+ if (!existsSync(path)) return 0;
1474
+ const settings = readSettings(path);
1475
+ if (!Array.isArray(settings.sshConfigs)) return 0;
1476
+ const kept = settings.sshConfigs.filter((e) => {
1477
+ const id = entryId(e);
1478
+ return id === void 0 || !predicate(id);
1479
+ });
1480
+ const removed = settings.sshConfigs.length - kept.length;
1481
+ if (removed === 0) return 0;
1482
+ settings.sshConfigs = kept;
1483
+ writeSettings(path, settings);
1484
+ return removed;
1485
+ }
1433
1486
  function sshConfigPath() {
1434
- return join3(homedir22(), ".ssh", "config");
1487
+ return join4(homedir3(), ".ssh", "config");
1435
1488
  }
1436
1489
  function agentboxSshConfigPath() {
1437
- return join3(homedir22(), ".agentbox", "ssh", "config");
1490
+ return join4(homedir3(), ".agentbox", "ssh", "config");
1438
1491
  }
1439
1492
  function stateFilePath() {
1440
- return join3(homedir22(), ".agentbox", "state.json");
1493
+ return join4(homedir3(), ".agentbox", "state.json");
1441
1494
  }
1442
1495
  var INCLUDE_BEGIN = "# BEGIN agentbox ssh include";
1443
1496
  var INCLUDE_END = "# END agentbox ssh include";
@@ -1465,6 +1518,9 @@ function buildBlock(opts) {
1465
1518
  ` HostName ${opts.hostname}`,
1466
1519
  ` User ${opts.user}`
1467
1520
  ];
1521
+ if (opts.port) {
1522
+ lines.push(` Port ${String(opts.port)}`);
1523
+ }
1468
1524
  if (opts.identityFile) {
1469
1525
  lines.push(` IdentityFile ${opts.identityFile}`);
1470
1526
  lines.push(` IdentitiesOnly yes`);
@@ -1487,7 +1543,7 @@ function hasIncludeBlock(contents) {
1487
1543
  }
1488
1544
  async function ensureSshInclude() {
1489
1545
  const path = sshConfigPath();
1490
- await fs.mkdir(join3(homedir22(), ".ssh"), { recursive: true, mode: 448 });
1546
+ await fs.mkdir(join4(homedir3(), ".ssh"), { recursive: true, mode: 448 });
1491
1547
  const existing = stripLegacyInlineBlocks(await readFileOrEmpty(path));
1492
1548
  let next = existing;
1493
1549
  if (!hasIncludeBlock(existing)) {
@@ -1505,23 +1561,28 @@ async function syncAgentboxSshConfig(statePath = stateFilePath()) {
1505
1561
  const state = await readState(statePath);
1506
1562
  const blocks = [];
1507
1563
  for (const box of state.boxes) {
1508
- const ssh = box.cloud?.ssh;
1564
+ const ssh = box.ssh;
1509
1565
  if (!ssh) continue;
1510
1566
  blocks.push(
1511
1567
  buildBlock({
1512
1568
  alias: agentboxAliasFor(box.name),
1513
1569
  hostname: ssh.host,
1514
1570
  user: ssh.user,
1515
- identityFile: ssh.identityFile
1571
+ identityFile: ssh.identityFile,
1572
+ port: ssh.port
1516
1573
  })
1517
1574
  );
1518
1575
  }
1519
1576
  const header = "# Managed by agentbox \u2014 regenerated on box create/start/destroy.\n# Do not edit; changes are overwritten. Disable with `agentbox config set ssh.autoConfig false`.\n\n";
1520
1577
  const path = agentboxSshConfigPath();
1521
- await fs.mkdir(dirname22(path), { recursive: true, mode: 448 });
1578
+ await fs.mkdir(dirname3(path), { recursive: true, mode: 448 });
1522
1579
  await fs.writeFile(path, header + blocks.join("\n"), { mode: 384 });
1523
1580
  await fs.chmod(path, 384);
1524
1581
  await ensureSshInclude();
1582
+ try {
1583
+ pruneOrphanClaudeSshConfigs(new Set(state.boxes.map((b) => agentboxAliasFor(b.name))));
1584
+ } catch {
1585
+ }
1525
1586
  }
1526
1587
  function parseSshTarget(argv) {
1527
1588
  let target;
@@ -1584,6 +1645,21 @@ async function autoWriteSshConfig(box, provider, enabled, logWarn) {
1584
1645
  );
1585
1646
  }
1586
1647
  }
1648
+ async function mintSshKey(targetDir, comment) {
1649
+ const dir = resolve3(targetDir);
1650
+ const priv = join5(dir, "id_ed25519");
1651
+ const pub = `${priv}.pub`;
1652
+ await mkdir2(dir, { recursive: true, mode: 448 });
1653
+ const existing = await readFile2(pub, "utf8").catch(() => null);
1654
+ if (existing !== null) {
1655
+ return { dir, privatePath: priv, publicPath: pub, publicKey: existing.trim() };
1656
+ }
1657
+ await execa("ssh-keygen", ["-t", "ed25519", "-N", "", "-C", comment, "-f", priv, "-q"], {
1658
+ stdio: "pipe"
1659
+ });
1660
+ const publicKey = (await readFile2(pub, "utf8")).trim();
1661
+ return { dir, privatePath: priv, publicPath: pub, publicKey };
1662
+ }
1587
1663
  var BOX_WORKSPACE = "/workspace";
1588
1664
  function run(provider, box, argv) {
1589
1665
  return provider.exec(box, argv, { cwd: BOX_WORKSPACE });
@@ -1659,17 +1735,17 @@ function errSummary(err) {
1659
1735
  return err instanceof Error ? firstLine(err.message) : String(err);
1660
1736
  }
1661
1737
  function secretsEnvPath() {
1662
- return resolve3(homedir3(), ".agentbox", "secrets.env");
1738
+ return resolve22(homedir4(), ".agentbox", "secrets.env");
1663
1739
  }
1664
1740
  function writeManagedSecrets(managedKeys, record) {
1665
1741
  for (const k of managedKeys) delete process.env[k];
1666
1742
  for (const [k, v] of Object.entries(record)) process.env[k] = v;
1667
1743
  const path = secretsEnvPath();
1668
- mkdirSync(dirname3(path), { recursive: true });
1744
+ mkdirSync2(dirname4(path), { recursive: true });
1669
1745
  let existing = "";
1670
- if (existsSync(path)) {
1746
+ if (existsSync2(path)) {
1671
1747
  try {
1672
- existing = readFileSync(path, "utf8");
1748
+ existing = readFileSync2(path, "utf8");
1673
1749
  } catch {
1674
1750
  existing = "";
1675
1751
  }
@@ -1685,7 +1761,7 @@ function writeManagedSecrets(managedKeys, record) {
1685
1761
  const body = (kept ? `${kept}
1686
1762
  ` : "") + lines.join("\n") + "\n";
1687
1763
  const tmp = `${path}.tmp`;
1688
- writeFileSync(tmp, body, { mode: 384 });
1764
+ writeFileSync2(tmp, body, { mode: 384 });
1689
1765
  try {
1690
1766
  chmodSync(tmp, 384);
1691
1767
  } catch {
@@ -1696,8 +1772,8 @@ function writeManagedSecrets(managedKeys, record) {
1696
1772
  } catch {
1697
1773
  }
1698
1774
  }
1699
- var PLUGINS_FILE = join4(homedir4(), ".agentbox", "plugins.json");
1700
- var SUPPORTED_SDK_API_VERSIONS = [1];
1775
+ var PLUGINS_FILE = join6(homedir5(), ".agentbox", "plugins.json");
1776
+ var SUPPORTED_SDK_API_VERSIONS = [1, 2];
1701
1777
  function isSupportedApiVersion(v) {
1702
1778
  return SUPPORTED_SDK_API_VERSIONS.includes(v);
1703
1779
  }
@@ -1711,8 +1787,8 @@ function normalize2(raw) {
1711
1787
  }
1712
1788
  function readPluginRegistrySync(path = PLUGINS_FILE) {
1713
1789
  try {
1714
- if (!existsSync2(path)) return { ...EMPTY2 };
1715
- return normalize2(JSON.parse(readFileSync2(path, "utf8")));
1790
+ if (!existsSync3(path)) return { ...EMPTY2 };
1791
+ return normalize2(JSON.parse(readFileSync3(path, "utf8")));
1716
1792
  } catch {
1717
1793
  return { ...EMPTY2 };
1718
1794
  }
@@ -1735,21 +1811,21 @@ function wantsRender(e) {
1735
1811
  async function renderCarryEntries(entries, ctx, onLog) {
1736
1812
  if (!entries.some(wantsRender)) return entries;
1737
1813
  const context = carryPlaceholderContext(ctx);
1738
- const stage = await mkdtemp(join5(tmpdir(), "agentbox-carry-render-"));
1814
+ const stage = await mkdtemp(join7(tmpdir(), "agentbox-carry-render-"));
1739
1815
  const out = [];
1740
1816
  for (const [i, entry] of entries.entries()) {
1741
1817
  if (!wantsRender(entry)) {
1742
1818
  out.push(entry);
1743
1819
  continue;
1744
1820
  }
1745
- const content = await readFile3(entry.absSrc, "utf8");
1821
+ const content = await readFile4(entry.absSrc, "utf8");
1746
1822
  const rendered = applyReplacements(content, {
1747
1823
  env: entry.replaceEnvs,
1748
1824
  rules: entry.replace,
1749
1825
  context,
1750
1826
  onWarn: (msg) => onLog?.(`carry: ${entry.rawSrc}: ${msg}`)
1751
1827
  });
1752
- const tmp = join5(stage, `${String(i)}-${basename2(entry.absSrc)}`);
1828
+ const tmp = join7(stage, `${String(i)}-${basename2(entry.absSrc)}`);
1753
1829
  await writeFile3(tmp, rendered, "utf8");
1754
1830
  out.push({ ...entry, absSrc: tmp, bytes: Buffer.byteLength(rendered) });
1755
1831
  const what = [
@@ -1805,7 +1881,7 @@ var AGENT_SYNC_SPECS = [
1805
1881
  credential: {
1806
1882
  boxRelPath: ".credentials.json",
1807
1883
  boxAbsPath: `${CLAUDE_BOX_DIR}/.credentials.json`,
1808
- hostBackup: join6(STATE_DIR, "claude-credentials.json"),
1884
+ hostBackup: join8(STATE_DIR, "claude-credentials.json"),
1809
1885
  cloudMountPath: "/home/vscode/.agentbox-creds/claude",
1810
1886
  cloudSubpath: "claude/",
1811
1887
  realShape: "claude-oauth"
@@ -1865,7 +1941,7 @@ var AGENT_SYNC_SPECS = [
1865
1941
  credential: {
1866
1942
  boxRelPath: "auth.json",
1867
1943
  boxAbsPath: `${CODEX_BOX_DIR}/auth.json`,
1868
- hostBackup: join6(STATE_DIR, "codex-credentials.json"),
1944
+ hostBackup: join8(STATE_DIR, "codex-credentials.json"),
1869
1945
  cloudMountPath: "/home/vscode/.agentbox-creds/codex",
1870
1946
  cloudSubpath: "codex/",
1871
1947
  realShape: "nonempty-json"
@@ -1916,7 +1992,7 @@ var AGENT_SYNC_SPECS = [
1916
1992
  credential: {
1917
1993
  boxRelPath: "auth.json",
1918
1994
  boxAbsPath: `${OPENCODE_BOX_DIR}/auth.json`,
1919
- hostBackup: join6(STATE_DIR, "opencode-credentials.json"),
1995
+ hostBackup: join8(STATE_DIR, "opencode-credentials.json"),
1920
1996
  cloudMountPath: "/home/vscode/.agentbox-creds/opencode",
1921
1997
  cloudSubpath: "opencode/",
1922
1998
  realShape: "nonempty-json"
@@ -1950,7 +2026,7 @@ function makeSyncContext(init) {
1950
2026
  hostWorkspace: init.hostWorkspace,
1951
2027
  projectRoot: init.projectRoot ?? init.hostWorkspace,
1952
2028
  boxWorkspace: init.boxWorkspace ?? "/workspace",
1953
- hostHome: init.hostHome ?? homedir5(),
2029
+ hostHome: init.hostHome ?? homedir6(),
1954
2030
  onLog: init.onLog ?? (() => {
1955
2031
  })
1956
2032
  };
@@ -2022,8 +2098,8 @@ async function scanHostEnvFiles(workspaceDir, patterns) {
2022
2098
  async function pushEnvFiles(ctx, transport, patterns) {
2023
2099
  const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
2024
2100
  if (list.length === 0) return { copied: 0 };
2025
- const stage = await mkdtemp2(join7(tmpdir2(), "agentbox-envfiles-"));
2026
- const localTar = join7(stage, "envfiles.tar");
2101
+ const stage = await mkdtemp2(join9(tmpdir2(), "agentbox-envfiles-"));
2102
+ const localTar = join9(stage, "envfiles.tar");
2027
2103
  try {
2028
2104
  const packed = await execa(
2029
2105
  "tar",
@@ -2095,9 +2171,9 @@ function encodeClaudeProjectsKey(absPath) {
2095
2171
  return absPath.replace(/[^a-zA-Z0-9]/g, "-");
2096
2172
  }
2097
2173
  var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
2098
- async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir6()) {
2174
+ async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir7()) {
2099
2175
  if (hostWorkspace.length === 0) return null;
2100
- const memDir = join8(
2176
+ const memDir = join10(
2101
2177
  hostHome,
2102
2178
  ".claude",
2103
2179
  "projects",
@@ -2140,8 +2216,8 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
2140
2216
  return;
2141
2217
  }
2142
2218
  for (const ent of entries) {
2143
- const realFull = join9(realDir, ent.name);
2144
- const virtualFull = virtualDir ? join9(virtualDir, ent.name) : ent.name;
2219
+ const realFull = join11(realDir, ent.name);
2220
+ const virtualFull = virtualDir ? join11(virtualDir, ent.name) : ent.name;
2145
2221
  if (ent.isSymbolicLink()) {
2146
2222
  let real;
2147
2223
  try {
@@ -2219,7 +2295,7 @@ function isRealAgentCredential(agent, text) {
2219
2295
  }
2220
2296
  async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now()) {
2221
2297
  try {
2222
- const parsed = JSON.parse(await readFile4(path, "utf8"));
2298
+ const parsed = JSON.parse(await readFile5(path, "utf8"));
2223
2299
  const exp = parsed?.claudeAiOauth?.expiresAt;
2224
2300
  return typeof exp === "number" && Number.isFinite(exp) && exp < now;
2225
2301
  } catch {
@@ -2228,7 +2304,7 @@ async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now
2228
2304
  }
2229
2305
  async function hostBackupHasCredentials(path = CLAUDE_HOST_BACKUP) {
2230
2306
  try {
2231
- const parsed = JSON.parse(await readFile4(path, "utf8"));
2307
+ const parsed = JSON.parse(await readFile5(path, "utf8"));
2232
2308
  const rt = parsed?.claudeAiOauth?.refreshToken;
2233
2309
  return typeof rt === "string" && rt.length > 0;
2234
2310
  } catch {
@@ -2244,7 +2320,7 @@ async function extractCredentials(transport, opts = {}) {
2244
2320
  try {
2245
2321
  const text = await transport.readText(spec.credential.boxAbsPath);
2246
2322
  if (!text || !isRealAgentCredential(spec.id, text)) continue;
2247
- await mkdir3(dirname5(hostBackup), { recursive: true });
2323
+ await mkdir4(dirname6(hostBackup), { recursive: true });
2248
2324
  await writeFile4(hostBackup, text, { mode: 384 });
2249
2325
  await chmod(hostBackup, 384).catch(() => {
2250
2326
  });
@@ -2406,7 +2482,7 @@ function makeHostGitPorts() {
2406
2482
  return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
2407
2483
  },
2408
2484
  async hashHostFile(hostMain, relPath) {
2409
- return createHash("sha256").update(await readFile5(join10(hostMain, relPath))).digest("hex");
2485
+ return createHash("sha256").update(await readFile6(join12(hostMain, relPath))).digest("hex");
2410
2486
  },
2411
2487
  async packHostFiles(hostMain, relPaths) {
2412
2488
  const tarOut = await execa("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
@@ -2439,7 +2515,7 @@ async function walkFiles(root, prefix = "") {
2439
2515
  const out = [];
2440
2516
  for (const ent of entries) {
2441
2517
  const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
2442
- const full = join11(root, ent.name);
2518
+ const full = join13(root, ent.name);
2443
2519
  if (ent.isDirectory()) {
2444
2520
  out.push(...await walkFiles(full, rel));
2445
2521
  } else if (ent.isFile()) {
@@ -2455,7 +2531,7 @@ async function walkFiles(root, prefix = "") {
2455
2531
  return out;
2456
2532
  }
2457
2533
  async function hashFile(absPath) {
2458
- const buf = await readFile6(absPath);
2534
+ const buf = await readFile7(absPath);
2459
2535
  return createHash2("sha256").update(buf).digest("hex");
2460
2536
  }
2461
2537
  async function buildHostSet(name, hostDir, boxDst) {
@@ -2463,12 +2539,12 @@ async function buildHostSet(name, hostDir, boxDst) {
2463
2539
  const rels = await walkFiles(hostDir);
2464
2540
  const files = {};
2465
2541
  for (const rel of rels) {
2466
- files[rel] = await hashFile(join11(hostDir, rel));
2542
+ files[rel] = await hashFile(join13(hostDir, rel));
2467
2543
  }
2468
2544
  return { dst: boxDst, files, hostDir };
2469
2545
  }
2470
- async function buildHostSyncManifest(workspacePath, hostHome = homedir7()) {
2471
- const workflowsDir = join11(hostHome, ".claude", "workflows");
2546
+ async function buildHostSyncManifest(workspacePath, hostHome = homedir8()) {
2547
+ const workflowsDir = join13(hostHome, ".claude", "workflows");
2472
2548
  const workflowsHost = await pathExists3(workflowsDir) ? workflowsDir : null;
2473
2549
  const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
2474
2550
  const [workflows, memory] = await Promise.all([
@@ -2490,7 +2566,7 @@ function computeSyncDelta(host, box) {
2490
2566
  uploads.push({
2491
2567
  set: name,
2492
2568
  rel,
2493
- absSrc: join11(hostSet.hostDir, rel),
2569
+ absSrc: join13(hostSet.hostDir, rel),
2494
2570
  dst: `${hostSet.dst}/${rel}`
2495
2571
  });
2496
2572
  }
@@ -2509,15 +2585,15 @@ async function stageDynamicSyncTarball(uploads) {
2509
2585
  return { tarballPath: null, cleanup: async () => {
2510
2586
  } };
2511
2587
  }
2512
- const stageDir = await mkdtemp3(join11(tmpdir3(), "agentbox-dynsync-stage-"));
2588
+ const stageDir = await mkdtemp3(join13(tmpdir3(), "agentbox-dynsync-stage-"));
2513
2589
  let tarballPath = null;
2514
2590
  try {
2515
2591
  for (const up of uploads) {
2516
- const target = join11(stageDir, up.set, up.rel);
2517
- await mkdir4(dirname6(target), { recursive: true });
2592
+ const target = join13(stageDir, up.set, up.rel);
2593
+ await mkdir5(dirname7(target), { recursive: true });
2518
2594
  await copyFile(up.absSrc, target);
2519
2595
  }
2520
- tarballPath = join11(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
2596
+ tarballPath = join13(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
2521
2597
  await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
2522
2598
  env: { ...process.env, COPYFILE_DISABLE: "1" }
2523
2599
  });
@@ -2651,7 +2727,7 @@ var BOX_WORKSPACE2 = "/workspace";
2651
2727
  var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
2652
2728
  trust_level = "trusted"
2653
2729
  `;
2654
- function sanitizeCodexConfigForBox(tomlText, hostHome = homedir8()) {
2730
+ function sanitizeCodexConfigForBox(tomlText, hostHome = homedir9()) {
2655
2731
  const cfg = parse(tomlText);
2656
2732
  let changed = false;
2657
2733
  if (isRecord(cfg["mcp_servers"])) {
@@ -2719,7 +2795,7 @@ async function findBrokenSymlinks(root) {
2719
2795
  return;
2720
2796
  }
2721
2797
  for (const ent of entries) {
2722
- const full = join12(dir, ent.name);
2798
+ const full = join14(dir, ent.name);
2723
2799
  if (ent.isSymbolicLink()) {
2724
2800
  try {
2725
2801
  await stat8(full);
@@ -2735,14 +2811,14 @@ async function findBrokenSymlinks(root) {
2735
2811
  return broken;
2736
2812
  }
2737
2813
  async function mkStageDir(prefix) {
2738
- return mkdtemp4(join12(tmpdir4(), `agentbox-${prefix}-stage-`));
2814
+ return mkdtemp4(join14(tmpdir4(), `agentbox-${prefix}-stage-`));
2739
2815
  }
2740
2816
  function emptyResult(warnings = []) {
2741
2817
  return { tarballPath: null, cleanup: async () => {
2742
2818
  }, warnings };
2743
2819
  }
2744
2820
  async function tarballFromDir(stageDir, agent) {
2745
- const tarballPath = join12(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
2821
+ const tarballPath = join14(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
2746
2822
  await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
2747
2823
  env: { ...process.env, COPYFILE_DISABLE: "1" }
2748
2824
  });
@@ -2759,7 +2835,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
2759
2835
  const stageDir = await mkStageDir(agent);
2760
2836
  let tarballPath = null;
2761
2837
  try {
2762
- await copyFile2(sourcePath, join12(stageDir, tarballEntryName));
2838
+ await copyFile2(sourcePath, join14(stageDir, tarballEntryName));
2763
2839
  tarballPath = await tarballFromDir(stageDir, agent);
2764
2840
  return {
2765
2841
  tarballPath,
@@ -2775,11 +2851,11 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
2775
2851
  var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
2776
2852
  async function buildBoxClaudeJsonFromHost(opts) {
2777
2853
  const { hostHome, hostWorkspace } = opts;
2778
- const hostClaudeJson = join12(hostHome, ".claude.json");
2854
+ const hostClaudeJson = join14(hostHome, ".claude.json");
2779
2855
  let working;
2780
2856
  if (await pathExists4(hostClaudeJson)) {
2781
2857
  try {
2782
- working = JSON.parse(await readFile7(hostClaudeJson, "utf8"));
2858
+ working = JSON.parse(await readFile8(hostClaudeJson, "utf8"));
2783
2859
  } catch {
2784
2860
  working = null;
2785
2861
  }
@@ -2810,7 +2886,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
2810
2886
  return working;
2811
2887
  }
2812
2888
  async function stageClaudeJsonOnlyForUpload(opts = {}) {
2813
- const hostHome = opts.hostHome ?? homedir9();
2889
+ const hostHome = opts.hostHome ?? homedir10();
2814
2890
  const stageDir = await mkStageDir("claude-json-only");
2815
2891
  let tarballPath = null;
2816
2892
  try {
@@ -2818,7 +2894,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
2818
2894
  hostHome,
2819
2895
  hostWorkspace: opts.hostWorkspace
2820
2896
  });
2821
- await writeFile5(join12(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
2897
+ await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
2822
2898
  tarballPath = await tarballFromDir(stageDir, "claude-json-only");
2823
2899
  return {
2824
2900
  tarballPath,
@@ -2832,8 +2908,8 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
2832
2908
  }
2833
2909
  }
2834
2910
  async function stageClaudeStaticForUpload(opts = {}) {
2835
- const hostHome = opts.hostHome ?? homedir9();
2836
- const hostClaude = join12(hostHome, ".claude");
2911
+ const hostHome = opts.hostHome ?? homedir10();
2912
+ const hostClaude = join14(hostHome, ".claude");
2837
2913
  if (!await pathExists4(hostClaude)) return emptyResult();
2838
2914
  const stageDir = await mkStageDir("claude-static");
2839
2915
  let tarballPath = null;
@@ -2850,10 +2926,10 @@ async function stageClaudeStaticForUpload(opts = {}) {
2850
2926
  `${hostClaude}/`,
2851
2927
  `${stageDir}/`
2852
2928
  ]);
2853
- const settingsPath = join12(stageDir, "settings.json");
2929
+ const settingsPath = join14(stageDir, "settings.json");
2854
2930
  if (await pathExists4(settingsPath)) {
2855
2931
  try {
2856
- const parsed = JSON.parse(await readFile7(settingsPath, "utf8"));
2932
+ const parsed = JSON.parse(await readFile8(settingsPath, "utf8"));
2857
2933
  const filtered = filterHostHooks(parsed, hostHome);
2858
2934
  if (filtered.removedCommands.length > 0) {
2859
2935
  await writeFile5(settingsPath, JSON.stringify(filtered.data, null, 2));
@@ -2865,15 +2941,15 @@ async function stageClaudeStaticForUpload(opts = {}) {
2865
2941
  hostHome,
2866
2942
  hostWorkspace: opts.hostWorkspace
2867
2943
  });
2868
- await writeFile5(join12(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
2869
- const pluginsDir = join12(stageDir, "plugins");
2944
+ await writeFile5(join14(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
2945
+ const pluginsDir = join14(stageDir, "plugins");
2870
2946
  if (await pathExists4(pluginsDir)) {
2871
2947
  try {
2872
2948
  const entries = await readdir5(pluginsDir, { withFileTypes: true });
2873
2949
  for (const ent of entries) {
2874
2950
  if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
2875
- const file = join12(pluginsDir, ent.name);
2876
- const raw = await readFile7(file, "utf8");
2951
+ const file = join14(pluginsDir, ent.name);
2952
+ const raw = await readFile8(file, "utf8");
2877
2953
  const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
2878
2954
  if (replaced !== raw) await writeFile5(file, replaced);
2879
2955
  }
@@ -2901,14 +2977,14 @@ var CODEX_KEYCHAIN_WARNING = 'codex: ~/.codex/auth.json missing. On macOS the co
2901
2977
  async function sanitizeStagedCodexConfig(configPath, hostHome) {
2902
2978
  try {
2903
2979
  if (!await pathExists4(configPath)) return;
2904
- const { text, changed } = sanitizeCodexConfigForBox(await readFile7(configPath, "utf8"), hostHome);
2980
+ const { text, changed } = sanitizeCodexConfigForBox(await readFile8(configPath, "utf8"), hostHome);
2905
2981
  if (changed) await writeFile5(configPath, text);
2906
2982
  } catch {
2907
2983
  }
2908
2984
  }
2909
2985
  async function stageCodexStaticForUpload(opts = {}) {
2910
- const hostHome = opts.hostHome ?? homedir9();
2911
- const hostCodex = join12(hostHome, ".codex");
2986
+ const hostHome = opts.hostHome ?? homedir10();
2987
+ const hostCodex = join14(hostHome, ".codex");
2912
2988
  if (!await pathExists4(hostCodex)) return emptyResult();
2913
2989
  const stageDir = await mkStageDir("codex-static");
2914
2990
  let tarballPath = null;
@@ -2922,7 +2998,7 @@ async function stageCodexStaticForUpload(opts = {}) {
2922
2998
  `${hostCodex}/`,
2923
2999
  `${stageDir}/`
2924
3000
  ]);
2925
- await sanitizeStagedCodexConfig(join12(stageDir, "config.toml"), hostHome);
3001
+ await sanitizeStagedCodexConfig(join14(stageDir, "config.toml"), hostHome);
2926
3002
  tarballPath = await tarballFromDir(stageDir, "codex-static");
2927
3003
  return {
2928
3004
  tarballPath,
@@ -2936,8 +3012,8 @@ async function stageCodexStaticForUpload(opts = {}) {
2936
3012
  }
2937
3013
  }
2938
3014
  async function stageAgentsStaticForUpload(opts = {}) {
2939
- const hostHome = opts.hostHome ?? homedir9();
2940
- const hostAgents = join12(hostHome, ".agents");
3015
+ const hostHome = opts.hostHome ?? homedir10();
3016
+ const hostAgents = join14(hostHome, ".agents");
2941
3017
  if (!await pathExists4(hostAgents)) return emptyResult();
2942
3018
  const stageDir = await mkStageDir("agents-static");
2943
3019
  let tarballPath = null;
@@ -2963,20 +3039,20 @@ async function stageAgentsStaticForUpload(opts = {}) {
2963
3039
  }
2964
3040
  }
2965
3041
  async function stageCodexCredentialsForUpload(opts = {}) {
2966
- const hostHome = opts.hostHome ?? homedir9();
2967
- const cloudBackup = join12(hostHome, ".agentbox", "codex-credentials.json");
3042
+ const hostHome = opts.hostHome ?? homedir10();
3043
+ const cloudBackup = join14(hostHome, ".agentbox", "codex-credentials.json");
2968
3044
  if (await pathExists4(cloudBackup)) {
2969
3045
  return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
2970
3046
  }
2971
- const hostAuth = join12(hostHome, ".codex", "auth.json");
3047
+ const hostAuth = join14(hostHome, ".codex", "auth.json");
2972
3048
  if (!await pathExists4(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
2973
3049
  return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
2974
3050
  }
2975
3051
  var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
2976
3052
  async function stageOpencodeStaticForUpload(opts = {}) {
2977
- const hostHome = opts.hostHome ?? homedir9();
2978
- const hostData = join12(hostHome, ".local", "share", "opencode");
2979
- const hostConfig = join12(hostHome, ".config", "opencode");
3053
+ const hostHome = opts.hostHome ?? homedir10();
3054
+ const hostData = join14(hostHome, ".local", "share", "opencode");
3055
+ const hostConfig = join14(hostHome, ".config", "opencode");
2980
3056
  const hasData = await pathExists4(hostData);
2981
3057
  const hasConfig = await pathExists4(hostConfig);
2982
3058
  if (!hasData && !hasConfig) return emptyResult();
@@ -2995,7 +3071,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
2995
3071
  ]);
2996
3072
  }
2997
3073
  if (hasConfig) {
2998
- const configStage = join12(stageDir, "config");
3074
+ const configStage = join14(stageDir, "config");
2999
3075
  const cfgBroken = await findBrokenSymlinks(hostConfig);
3000
3076
  await execa("rsync", [
3001
3077
  "-a",
@@ -3018,18 +3094,18 @@ async function stageOpencodeStaticForUpload(opts = {}) {
3018
3094
  }
3019
3095
  }
3020
3096
  async function stageOpencodeCredentialsForUpload(opts = {}) {
3021
- const hostHome = opts.hostHome ?? homedir9();
3022
- const cloudBackup = join12(hostHome, ".agentbox", "opencode-credentials.json");
3097
+ const hostHome = opts.hostHome ?? homedir10();
3098
+ const cloudBackup = join14(hostHome, ".agentbox", "opencode-credentials.json");
3023
3099
  if (await pathExists4(cloudBackup)) {
3024
3100
  return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
3025
3101
  }
3026
- const hostAuth = join12(hostHome, ".local", "share", "opencode", "auth.json");
3102
+ const hostAuth = join14(hostHome, ".local", "share", "opencode", "auth.json");
3027
3103
  if (!await pathExists4(hostAuth)) return emptyResult();
3028
3104
  return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
3029
3105
  }
3030
3106
  async function stageOpencodeStateForUpload(opts = {}) {
3031
- const hostHome = opts.hostHome ?? homedir9();
3032
- const hostModel = join12(hostHome, ".local", "state", "opencode", "model.json");
3107
+ const hostHome = opts.hostHome ?? homedir10();
3108
+ const hostModel = join14(hostHome, ".local", "state", "opencode", "model.json");
3033
3109
  if (!await pathExists4(hostModel)) return emptyResult();
3034
3110
  return stageSingleFileTarball("opencode-state", hostModel, "model.json");
3035
3111
  }
@@ -3055,27 +3131,27 @@ function preparedStatePathFor(provider) {
3055
3131
  if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
3056
3132
  throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
3057
3133
  }
3058
- return pathResolve(homedir10(), ".agentbox", `${provider}-prepared.json`);
3134
+ return pathResolve(homedir11(), ".agentbox", `${provider}-prepared.json`);
3059
3135
  }
3060
3136
  function readPreparedStateRaw(provider) {
3061
3137
  const path = preparedStatePathFor(provider);
3062
- if (!existsSync3(path)) return null;
3138
+ if (!existsSync4(path)) return null;
3063
3139
  try {
3064
- return JSON.parse(readFileSync3(path, "utf8"));
3140
+ return JSON.parse(readFileSync4(path, "utf8"));
3065
3141
  } catch {
3066
3142
  return null;
3067
3143
  }
3068
3144
  }
3069
3145
  function writePreparedStateRaw(provider, state) {
3070
3146
  const path = preparedStatePathFor(provider);
3071
- mkdirSync2(dirname7(path), { recursive: true });
3147
+ mkdirSync3(dirname8(path), { recursive: true });
3072
3148
  const body = JSON.stringify(state, null, 2) + "\n";
3073
3149
  const tmp = `${path}.tmp`;
3074
- writeFileSync2(tmp, body, { mode: 384 });
3150
+ writeFileSync3(tmp, body, { mode: 384 });
3075
3151
  renameSync2(tmp, path);
3076
3152
  }
3077
3153
  async function sha256OfFile(path) {
3078
- const buf = await readFile8(path);
3154
+ const buf = await readFile9(path);
3079
3155
  return createHash3("sha256").update(buf).digest("hex");
3080
3156
  }
3081
3157
  async function computeContextSha256(files) {
@@ -3144,19 +3220,19 @@ function resolveContextFilesFrom(fileMap, opts) {
3144
3220
  pathResolve(opts.contextDir, paths.staged),
3145
3221
  pathResolve(opts.devRoot, paths.dev)
3146
3222
  ];
3147
- const hit = candidates.find((p) => existsSync3(p));
3223
+ const hit = candidates.find((p) => existsSync4(p));
3148
3224
  if (!hit) return null;
3149
3225
  out.push({ rel, abs: hit });
3150
3226
  }
3151
3227
  return out;
3152
3228
  }
3153
3229
 
3154
- // ../../packages/sandbox-docker/dist/chunk-HAYZZFAH.js
3155
- import { dirname as dirname23, resolve as resolve22 } from "path";
3230
+ // ../../packages/sandbox-docker/dist/chunk-BSXR4H44.js
3231
+ import { dirname as dirname23, resolve as resolve23 } from "path";
3156
3232
  import { fileURLToPath as fileURLToPath2 } from "url";
3157
- import { existsSync as existsSync4 } from "fs";
3233
+ import { existsSync as existsSync5 } from "fs";
3158
3234
  import { fileURLToPath } from "url";
3159
- import { dirname as dirname8, resolve as resolve4 } from "path";
3235
+ import { dirname as dirname9, resolve as resolve4 } from "path";
3160
3236
  var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
3161
3237
  async function resolveClaudeInstallMode() {
3162
3238
  try {
@@ -3171,14 +3247,14 @@ var BOX_IMAGE_REGISTRY = "ghcr.io/madarco/agentbox/box";
3171
3247
  function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
3172
3248
  return `${registry}:sha-${sha.slice(0, 16)}`;
3173
3249
  }
3174
- var here = dirname8(fileURLToPath(import.meta.url));
3250
+ var here = dirname9(fileURLToPath(import.meta.url));
3175
3251
  function resolveDockerBuild() {
3176
3252
  const override = process.env.AGENTBOX_DOCKER_CONTEXT;
3177
- if (override && existsSync4(resolve4(override, "Dockerfile.box"))) {
3253
+ if (override && existsSync5(resolve4(override, "Dockerfile.box"))) {
3178
3254
  return { dockerfile: resolve4(override, "Dockerfile.box"), context: override };
3179
3255
  }
3180
3256
  const staged = resolve4(here, "..", "runtime", "docker");
3181
- if (existsSync4(resolve4(staged, "Dockerfile.box"))) {
3257
+ if (existsSync5(resolve4(staged, "Dockerfile.box"))) {
3182
3258
  return { dockerfile: resolve4(staged, "Dockerfile.box"), context: staged };
3183
3259
  }
3184
3260
  const packageRoot = resolve4(here, "..");
@@ -3262,7 +3338,7 @@ async function buildImage(opts = {}) {
3262
3338
  return ref;
3263
3339
  }
3264
3340
  async function pullOrBuild(ref, fingerprint, opts = {}) {
3265
- const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-5FIGV4BE-D2HJEY2L.js");
3341
+ const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-LW2PKTEQ-7BCXARGA.js");
3266
3342
  const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
3267
3343
  const allowPull = opts.allowPull !== false;
3268
3344
  if (allowPull && registry && fingerprint) {
@@ -3289,7 +3365,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
3289
3365
  return { source: "built" };
3290
3366
  }
3291
3367
  async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
3292
- const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-5FIGV4BE-D2HJEY2L.js");
3368
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-LW2PKTEQ-7BCXARGA.js");
3293
3369
  const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
3294
3370
  const rawFingerprint = await computeDockerContextFingerprint2({
3295
3371
  contextDir: opts.contextDir
@@ -3326,11 +3402,36 @@ async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
3326
3402
  });
3327
3403
  return { ref, built: source === "built", reason };
3328
3404
  }
3405
+ function classifyDockerBaseFreshness(input) {
3406
+ if (!input.imagePresent) return { state: "unprepared" };
3407
+ if (!input.fingerprint) return { state: "unknown" };
3408
+ if (!input.stampedSha) return { state: "stale", reason: "no docker-prepared.json on disk" };
3409
+ if (input.stampedSha !== input.fingerprint) {
3410
+ return {
3411
+ state: "stale",
3412
+ reason: `build context changed (was ${input.stampedSha.slice(0, 12)}, now ${input.fingerprint.slice(0, 12)})`
3413
+ };
3414
+ }
3415
+ return { state: "fresh" };
3416
+ }
3417
+ async function evaluateDockerBaseFreshness(opts = {}) {
3418
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-LW2PKTEQ-7BCXARGA.js");
3419
+ const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
3420
+ const imagePresent = await imageExists(ref);
3421
+ if (!imagePresent) return { state: "unprepared" };
3422
+ const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
3423
+ const raw = await computeDockerContextFingerprint2({ contextDir: opts.contextDir });
3424
+ return classifyDockerBaseFreshness({
3425
+ imagePresent,
3426
+ fingerprint: raw ? claudeInstallFingerprint(raw.contextSha256, claudeInstall) : null,
3427
+ stampedSha: readPreparedDockerState2()?.base?.contextSha256 ?? null
3428
+ });
3429
+ }
3329
3430
  var SCHEMA = 1;
3330
3431
  function resolveContextFiles(opts = {}) {
3331
3432
  const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;
3332
3433
  const here2 = dirname23(fileURLToPath2(import.meta.url));
3333
- const packageRoot = resolve22(here2, "..");
3434
+ const packageRoot = resolve23(here2, "..");
3334
3435
  return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
3335
3436
  contextDir: ctx,
3336
3437
  devRoot: packageRoot
@@ -3408,6 +3509,7 @@ export {
3408
3509
  hostOpenCommand,
3409
3510
  syncAgentboxSshConfig,
3410
3511
  autoWriteSshConfig,
3512
+ mintSshKey,
3411
3513
  BOX_WORKSPACE,
3412
3514
  boxGitCheckout,
3413
3515
  boxGitNewBranch,
@@ -3478,12 +3580,15 @@ export {
3478
3580
  BOX_IMAGE_REGISTRY,
3479
3581
  registryRefForSha,
3480
3582
  DOCKERFILE_PATH,
3583
+ BUILD_CONTEXT_DIR,
3481
3584
  imageExists,
3482
3585
  pullImage,
3483
3586
  tagImage,
3484
3587
  imageInfo,
3485
3588
  pullOrBuild,
3486
3589
  ensureImage,
3590
+ classifyDockerBaseFreshness,
3591
+ evaluateDockerBaseFreshness,
3487
3592
  resolveContextFiles,
3488
3593
  computeDockerContextFingerprint,
3489
3594
  readPreparedDockerState,