@madarco/agentbox 0.21.0 → 0.22.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 (571) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/README.md +32 -0
  3. package/dist/{_cloud-attach-U3QJO7IF.js → _cloud-attach-YH2SU75S.js} +5 -4
  4. package/dist/chunk-ALEYDWAO.js +2561 -0
  5. package/dist/chunk-ALEYDWAO.js.map +1 -0
  6. package/dist/{chunk-QKL7PCXQ.js → chunk-CDEJ2GQK.js} +836 -488
  7. package/dist/chunk-CDEJ2GQK.js.map +1 -0
  8. package/dist/{chunk-PX7G4PSI.js → chunk-GGWVTWJM.js} +65 -34
  9. package/dist/{chunk-PX7G4PSI.js.map → chunk-GGWVTWJM.js.map} +1 -1
  10. package/dist/chunk-KBVD2UUQ.js +1654 -0
  11. package/dist/chunk-KBVD2UUQ.js.map +1 -0
  12. package/dist/{chunk-IXQTUXWV.js → chunk-O2NDZQHN.js} +50 -52
  13. package/dist/{chunk-IXQTUXWV.js.map → chunk-O2NDZQHN.js.map} +1 -1
  14. package/dist/{dist-NWKOEWUJ.js → chunk-O67ZESNL.js} +1059 -109
  15. package/dist/chunk-O67ZESNL.js.map +1 -0
  16. package/dist/chunk-VBSRJG53.js +1241 -0
  17. package/dist/chunk-VBSRJG53.js.map +1 -0
  18. package/dist/{chunk-6JJIKCMY.js → chunk-W2FLHB54.js} +26 -56
  19. package/dist/chunk-W2FLHB54.js.map +1 -0
  20. package/dist/{chunk-YZVFGFYQ.js → chunk-YZXXBHWG.js} +1937 -2975
  21. package/dist/chunk-YZXXBHWG.js.map +1 -0
  22. package/dist/{dist-SAS4PIHA.js → dist-EJXUKIR7.js} +41 -36
  23. package/dist/{dist-UVQJ2BZJ.js → dist-LJHS4PTC.js} +112 -62
  24. package/dist/dist-LJHS4PTC.js.map +1 -0
  25. package/dist/dist-QBXEP4VY.js +89 -0
  26. package/dist/dist-QNV4H6NN.js +80 -0
  27. package/dist/dist-QNV4H6NN.js.map +1 -0
  28. package/dist/{dist-FMA5Y25B.js → dist-UR2DB2HT.js} +83 -9
  29. package/dist/dist-UR2DB2HT.js.map +1 -0
  30. package/dist/dist-YECTRVGD.js +102 -0
  31. package/dist/dist-YECTRVGD.js.map +1 -0
  32. package/dist/index.js +3243 -1448
  33. package/dist/index.js.map +1 -1
  34. package/dist/{prepared-state-MQHD3M5F-YYVVMTNJ.js → prepared-state-5FIGV4BE-BMUK63FD.js} +2 -2
  35. package/dist/prepared-state-5FIGV4BE-BMUK63FD.js.map +1 -0
  36. package/package.json +12 -5
  37. package/runtime/_shared/agentbox-checkpoint-cleanup +55 -0
  38. package/runtime/_shared/agentbox-codex-hooks.json +68 -0
  39. package/runtime/_shared/agentbox-dockerd-start +145 -0
  40. package/runtime/_shared/agentbox-open +28 -0
  41. package/runtime/_shared/agentbox-portless-trust +82 -0
  42. package/runtime/_shared/agentbox-setup-skill.md +317 -0
  43. package/runtime/_shared/agentbox-vnc-start +102 -0
  44. package/runtime/_shared/claude-managed-settings.json +116 -0
  45. package/runtime/_shared/ctl.cjs +27469 -0
  46. package/runtime/_shared/gh-shim +344 -0
  47. package/runtime/_shared/git-shim +131 -0
  48. package/runtime/_shared/linear-shim +181 -0
  49. package/runtime/_shared/ntn-shim +95 -0
  50. package/runtime/_shared/opencode-agentbox-plugin.js +76 -0
  51. package/runtime/docker/Dockerfile.box +30 -17
  52. package/runtime/docker/packages/ctl/dist/bin.cjs +11871 -10351
  53. package/runtime/e2b/ctl.cjs +11871 -10351
  54. package/runtime/e2b/scripts/build-template.sh +31 -15
  55. package/runtime/hetzner/ctl.cjs +11871 -10351
  56. package/runtime/hetzner/scripts/install-box.sh +37 -19
  57. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -0
  58. package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +36 -0
  59. package/runtime/hub/apps/hub/.next/build-manifest.json +21 -0
  60. package/runtime/hub/apps/hub/.next/package.json +1 -0
  61. package/runtime/hub/apps/hub/.next/prerender-manifest.json +36 -0
  62. package/runtime/hub/apps/hub/.next/required-server-files.json +350 -0
  63. package/runtime/hub/apps/hub/.next/routes-manifest.json +292 -0
  64. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route/app-paths-manifest.json +3 -0
  65. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route/build-manifest.json +9 -0
  66. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route/server-reference-manifest.json +4 -0
  67. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js +13 -0
  68. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.map +5 -0
  69. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +1 -0
  70. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route_client-reference-manifest.js +3 -0
  71. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page/app-paths-manifest.json +3 -0
  72. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page/build-manifest.json +17 -0
  73. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page/next-font-manifest.json +13 -0
  74. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page/react-loadable-manifest.json +1 -0
  75. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page/server-reference-manifest.json +4 -0
  76. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page.js +14 -0
  77. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page.js.map +5 -0
  78. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page.js.nft.json +1 -0
  79. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page_client-reference-manifest.js +3 -0
  80. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/events/route/app-paths-manifest.json +3 -0
  81. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/events/route/build-manifest.json +9 -0
  82. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/events/route/server-reference-manifest.json +4 -0
  83. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/events/route.js +7 -0
  84. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/events/route.js.map +5 -0
  85. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/events/route.js.nft.json +1 -0
  86. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/events/route_client-reference-manifest.js +3 -0
  87. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/jobs/[id]/logs/route/app-paths-manifest.json +3 -0
  88. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/jobs/[id]/logs/route/build-manifest.json +9 -0
  89. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/jobs/[id]/logs/route/server-reference-manifest.json +4 -0
  90. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/jobs/[id]/logs/route.js +7 -0
  91. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/jobs/[id]/logs/route.js.map +5 -0
  92. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/jobs/[id]/logs/route.js.nft.json +1 -0
  93. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/jobs/[id]/logs/route_client-reference-manifest.js +3 -0
  94. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route/app-paths-manifest.json +3 -0
  95. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route/build-manifest.json +9 -0
  96. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route/server-reference-manifest.json +4 -0
  97. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js +9 -0
  98. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js.map +5 -0
  99. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js.nft.json +1 -0
  100. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route_client-reference-manifest.js +3 -0
  101. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route/app-paths-manifest.json +3 -0
  102. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route/build-manifest.json +9 -0
  103. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route/server-reference-manifest.json +4 -0
  104. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js +8 -0
  105. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js.map +5 -0
  106. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js.nft.json +1 -0
  107. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route_client-reference-manifest.js +3 -0
  108. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route/app-paths-manifest.json +3 -0
  109. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route/build-manifest.json +9 -0
  110. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route/server-reference-manifest.json +4 -0
  111. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js +9 -0
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js.map +5 -0
  113. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js.nft.json +1 -0
  114. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route_client-reference-manifest.js +3 -0
  115. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route/app-paths-manifest.json +3 -0
  116. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route/build-manifest.json +9 -0
  117. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route/server-reference-manifest.json +4 -0
  118. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js +8 -0
  119. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js.map +5 -0
  120. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js.nft.json +1 -0
  121. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route_client-reference-manifest.js +3 -0
  122. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route/app-paths-manifest.json +3 -0
  123. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route/build-manifest.json +9 -0
  124. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route/server-reference-manifest.json +4 -0
  125. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js +9 -0
  126. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js.map +5 -0
  127. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js.nft.json +1 -0
  128. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route_client-reference-manifest.js +3 -0
  129. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route/app-paths-manifest.json +3 -0
  130. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route/build-manifest.json +9 -0
  131. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route/server-reference-manifest.json +4 -0
  132. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js +8 -0
  133. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js.map +5 -0
  134. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js.nft.json +1 -0
  135. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route_client-reference-manifest.js +3 -0
  136. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route/app-paths-manifest.json +3 -0
  137. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route/build-manifest.json +9 -0
  138. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route/server-reference-manifest.json +4 -0
  139. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js +8 -0
  140. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js.map +5 -0
  141. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js.nft.json +1 -0
  142. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route_client-reference-manifest.js +3 -0
  143. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route/app-paths-manifest.json +3 -0
  144. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route/build-manifest.json +9 -0
  145. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route/server-reference-manifest.json +4 -0
  146. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js +9 -0
  147. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js.map +5 -0
  148. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js.nft.json +1 -0
  149. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route_client-reference-manifest.js +3 -0
  150. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route/app-paths-manifest.json +3 -0
  151. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route/build-manifest.json +9 -0
  152. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route/server-reference-manifest.json +4 -0
  153. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js +8 -0
  154. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js.map +5 -0
  155. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js.nft.json +1 -0
  156. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route_client-reference-manifest.js +3 -0
  157. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route/app-paths-manifest.json +3 -0
  158. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route/build-manifest.json +9 -0
  159. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route/server-reference-manifest.json +4 -0
  160. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js +9 -0
  161. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js.map +5 -0
  162. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js.nft.json +1 -0
  163. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route_client-reference-manifest.js +3 -0
  164. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route/app-paths-manifest.json +3 -0
  165. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route/build-manifest.json +9 -0
  166. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route/server-reference-manifest.json +4 -0
  167. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route.js +7 -0
  168. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route.js.map +5 -0
  169. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route.js.nft.json +1 -0
  170. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route_client-reference-manifest.js +3 -0
  171. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route/app-paths-manifest.json +3 -0
  172. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route/build-manifest.json +9 -0
  173. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route/server-reference-manifest.json +4 -0
  174. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js +8 -0
  175. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js.map +5 -0
  176. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js.nft.json +1 -0
  177. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route_client-reference-manifest.js +3 -0
  178. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route/app-paths-manifest.json +3 -0
  179. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route/build-manifest.json +9 -0
  180. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route/server-reference-manifest.json +4 -0
  181. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js +9 -0
  182. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js.map +5 -0
  183. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js.nft.json +1 -0
  184. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route_client-reference-manifest.js +3 -0
  185. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route/app-paths-manifest.json +3 -0
  186. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route/build-manifest.json +9 -0
  187. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route/server-reference-manifest.json +4 -0
  188. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js +8 -0
  189. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js.map +5 -0
  190. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js.nft.json +1 -0
  191. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route_client-reference-manifest.js +3 -0
  192. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route/app-paths-manifest.json +3 -0
  193. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route/build-manifest.json +9 -0
  194. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route/server-reference-manifest.json +4 -0
  195. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js +8 -0
  196. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js.map +5 -0
  197. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js.nft.json +1 -0
  198. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route_client-reference-manifest.js +3 -0
  199. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route/app-paths-manifest.json +3 -0
  200. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route/build-manifest.json +9 -0
  201. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route/server-reference-manifest.json +4 -0
  202. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route.js +7 -0
  203. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route.js.map +5 -0
  204. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route.js.nft.json +1 -0
  205. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route_client-reference-manifest.js +3 -0
  206. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route/app-paths-manifest.json +3 -0
  207. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route/build-manifest.json +9 -0
  208. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route/server-reference-manifest.json +4 -0
  209. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js +8 -0
  210. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js.map +5 -0
  211. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js.nft.json +1 -0
  212. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route_client-reference-manifest.js +3 -0
  213. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route/app-paths-manifest.json +3 -0
  214. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route/build-manifest.json +9 -0
  215. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route/server-reference-manifest.json +4 -0
  216. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js +8 -0
  217. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js.map +5 -0
  218. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js.nft.json +1 -0
  219. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route_client-reference-manifest.js +3 -0
  220. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route/app-paths-manifest.json +3 -0
  221. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route/build-manifest.json +9 -0
  222. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route/server-reference-manifest.json +4 -0
  223. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js +9 -0
  224. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js.map +5 -0
  225. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js.nft.json +1 -0
  226. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route_client-reference-manifest.js +3 -0
  227. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route/app-paths-manifest.json +3 -0
  228. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route/build-manifest.json +9 -0
  229. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route/server-reference-manifest.json +4 -0
  230. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js +9 -0
  231. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js.map +5 -0
  232. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js.nft.json +1 -0
  233. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route_client-reference-manifest.js +3 -0
  234. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route/app-paths-manifest.json +3 -0
  235. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route/build-manifest.json +9 -0
  236. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route/server-reference-manifest.json +4 -0
  237. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js +9 -0
  238. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js.map +5 -0
  239. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js.nft.json +1 -0
  240. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route_client-reference-manifest.js +3 -0
  241. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route/app-paths-manifest.json +3 -0
  242. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route/build-manifest.json +9 -0
  243. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route/server-reference-manifest.json +4 -0
  244. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js +8 -0
  245. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js.map +5 -0
  246. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js.nft.json +1 -0
  247. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route_client-reference-manifest.js +3 -0
  248. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page/app-paths-manifest.json +3 -0
  249. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page/build-manifest.json +17 -0
  250. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page/next-font-manifest.json +13 -0
  251. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page/react-loadable-manifest.json +1 -0
  252. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page/server-reference-manifest.json +17 -0
  253. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js +17 -0
  254. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js.map +5 -0
  255. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js.nft.json +1 -0
  256. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +3 -0
  257. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/app-paths-manifest.json +3 -0
  258. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/build-manifest.json +17 -0
  259. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/next-font-manifest.json +13 -0
  260. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/react-loadable-manifest.json +1 -0
  261. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/server-reference-manifest.json +137 -0
  262. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js +17 -0
  263. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js.map +5 -0
  264. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js.nft.json +1 -0
  265. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +3 -0
  266. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/app-paths-manifest.json +3 -0
  267. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/build-manifest.json +17 -0
  268. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/next-font-manifest.json +13 -0
  269. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/react-loadable-manifest.json +1 -0
  270. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/server-reference-manifest.json +125 -0
  271. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js +17 -0
  272. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.map +5 -0
  273. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.nft.json +1 -0
  274. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +3 -0
  275. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/app-paths-manifest.json +3 -0
  276. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/build-manifest.json +17 -0
  277. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/next-font-manifest.json +13 -0
  278. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/react-loadable-manifest.json +1 -0
  279. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/server-reference-manifest.json +89 -0
  280. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js +17 -0
  281. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.map +5 -0
  282. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.nft.json +1 -0
  283. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +3 -0
  284. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page/app-paths-manifest.json +3 -0
  285. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page/build-manifest.json +17 -0
  286. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page/next-font-manifest.json +13 -0
  287. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page/react-loadable-manifest.json +1 -0
  288. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page/server-reference-manifest.json +4 -0
  289. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js +16 -0
  290. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js.map +5 -0
  291. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js.nft.json +1 -0
  292. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +3 -0
  293. package/runtime/hub/apps/hub/.next/server/app/[...path]/route/app-paths-manifest.json +3 -0
  294. package/runtime/hub/apps/hub/.next/server/app/[...path]/route/build-manifest.json +9 -0
  295. package/runtime/hub/apps/hub/.next/server/app/[...path]/route/server-reference-manifest.json +4 -0
  296. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js +8 -0
  297. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js.map +5 -0
  298. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js.nft.json +1 -0
  299. package/runtime/hub/apps/hub/.next/server/app/[...path]/route_client-reference-manifest.js +3 -0
  300. package/runtime/hub/apps/hub/.next/server/app/_global-error/page/app-paths-manifest.json +3 -0
  301. package/runtime/hub/apps/hub/.next/server/app/_global-error/page/build-manifest.json +17 -0
  302. package/runtime/hub/apps/hub/.next/server/app/_global-error/page/next-font-manifest.json +6 -0
  303. package/runtime/hub/apps/hub/.next/server/app/_global-error/page/react-loadable-manifest.json +1 -0
  304. package/runtime/hub/apps/hub/.next/server/app/_global-error/page/server-reference-manifest.json +4 -0
  305. package/runtime/hub/apps/hub/.next/server/app/_global-error/page.js +10 -0
  306. package/runtime/hub/apps/hub/.next/server/app/_global-error/page.js.map +5 -0
  307. package/runtime/hub/apps/hub/.next/server/app/_global-error/page.js.nft.json +1 -0
  308. package/runtime/hub/apps/hub/.next/server/app/_global-error/page_client-reference-manifest.js +3 -0
  309. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -0
  310. package/runtime/hub/apps/hub/.next/server/app/_global-error.meta +15 -0
  311. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +14 -0
  312. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +5 -0
  313. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +14 -0
  314. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
  315. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +5 -0
  316. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
  317. package/runtime/hub/apps/hub/.next/server/app/_not-found/page/app-paths-manifest.json +3 -0
  318. package/runtime/hub/apps/hub/.next/server/app/_not-found/page/build-manifest.json +17 -0
  319. package/runtime/hub/apps/hub/.next/server/app/_not-found/page/next-font-manifest.json +13 -0
  320. package/runtime/hub/apps/hub/.next/server/app/_not-found/page/react-loadable-manifest.json +1 -0
  321. package/runtime/hub/apps/hub/.next/server/app/_not-found/page/server-reference-manifest.json +4 -0
  322. package/runtime/hub/apps/hub/.next/server/app/_not-found/page.js +13 -0
  323. package/runtime/hub/apps/hub/.next/server/app/_not-found/page.js.map +5 -0
  324. package/runtime/hub/apps/hub/.next/server/app/_not-found/page.js.nft.json +1 -0
  325. package/runtime/hub/apps/hub/.next/server/app/_not-found/page_client-reference-manifest.js +3 -0
  326. package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +36 -0
  327. package/runtime/hub/apps/hub/.next/server/chunks/01te_@better-auth_kysely-adapter_dist_0jw_ngm._.js +3 -0
  328. package/runtime/hub/apps/hub/.next/server/chunks/01te_@better-auth_kysely-adapter_dist_0z6cvsk._.js +3 -0
  329. package/runtime/hub/apps/hub/.next/server/chunks/01te_@better-auth_kysely-adapter_dist_210bxd8._.js +3 -0
  330. package/runtime/hub/apps/hub/.next/server/chunks/01te_@better-auth_kysely-adapter_dist_index_mjs_0h-j5xt._.js +4 -0
  331. package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(auth)_api_auth_[___all]_route_actions_1agi0ag.js +3 -0
  332. package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_api_v1_boxes_route_actions_1ggp_5o.js +3 -0
  333. package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_api_v1_health_route_actions_017gnzg.js +3 -0
  334. package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_api_v1_projects_route_actions_04w8ozk.js +3 -0
  335. package/runtime/hub/apps/hub/.next/server/chunks/09mp_@better-auth_memory-adapter_dist_index_mjs_0ti_30h._.js +3 -0
  336. package/runtime/hub/apps/hub/.next/server/chunks/09xn_next_0tn6frk._.js +6 -0
  337. package/runtime/hub/apps/hub/.next/server/chunks/0d-b_next_dist_server_app-render_after-task-async-storage_external_0-exn7p.js +3 -0
  338. package/runtime/hub/apps/hub/.next/server/chunks/0m4a_kysely_dist_095p8vu._.js +3 -0
  339. package/runtime/hub/apps/hub/.next/server/chunks/0m4a_kysely_dist_1skbhvx._.js +3 -0
  340. package/runtime/hub/apps/hub/.next/server/chunks/0sj1_@opentelemetry_api_build_esm_index_0xy-j06.js +3 -0
  341. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_jobs_[id]_logs_route_actions_01aqmf3.js +3 -0
  342. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_approvals_route_actions_1vwxs9a.js +3 -0
  343. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_boxes_[id]_route_actions_01510xg.js +3 -0
  344. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_jobs_[id]_route_actions_0oc630h.js +3 -0
  345. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_openapi_json_route_actions_1lunxjz.js +3 -0
  346. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_providers_route_actions_1666ry8.js +3 -0
  347. package/runtime/hub/apps/hub/.next/server/chunks/0web_next-internal_server_app_(dashboard)_api_v1_projects_[id]_route_actions_1beikpx.js +3 -0
  348. package/runtime/hub/apps/hub/.next/server/chunks/0zhp_better-auth_dist_adapters_kysely-adapter_index_mjs_1rl4qnh._.js +3 -0
  349. package/runtime/hub/apps/hub/.next/server/chunks/151__@better-auth_core_dist_0ecdp_3._.js +5 -0
  350. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_approvals_[id]_answer_route_actions_1cq4z5x.js +3 -0
  351. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_[action]_route_actions_0cib0ju.js +3 -0
  352. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_branches_route_actions_15snjix.js +3 -0
  353. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_git_[op]_route_actions_116a41w.js +3 -0
  354. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_git_route_actions_1a-q-i2.js +3 -0
  355. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_services_restart_route_actions_1yvsbmm.js +3 -0
  356. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_services_route_actions_1uvv36v.js +3 -0
  357. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_jobs_[id]_login-code_route_actions_1825jmw.js +3 -0
  358. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_jobs_[id]_logs_route_actions_0msc0_w.js +3 -0
  359. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_projects_[id]_branches_route_actions_07i0vrw.js +3 -0
  360. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_providers_[id]_credentials_route_actions_1cds5re.js +3 -0
  361. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_providers_[id]_prepare_route_actions_079fbng.js +3 -0
  362. package/runtime/hub/apps/hub/.next/server/chunks/[externals]__12m3qoa._.js +3 -0
  363. package/runtime/hub/apps/hub/.next/server/chunks/[externals]_pg_15jfwkh._.js +3 -0
  364. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04h15ml._.js +3 -0
  365. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04jgk9x._.js +3 -0
  366. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07ednlo._.js +3 -0
  367. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +105 -0
  368. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ig1bot._.js +3 -0
  369. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +3 -0
  370. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ql4fjo._.js +3 -0
  371. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0se1fty._.js +3 -0
  372. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0t7o5ed._.js +3 -0
  373. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vs8fma._.js +3 -0
  374. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vxaujy._.js +6 -0
  375. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w9ud8u._.js +3 -0
  376. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yhb0gc._.js +3 -0
  377. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-9g0ae._.js +461 -0
  378. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13jwk_k._.js +3 -0
  379. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16_uteg._.js +3 -0
  380. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16p2m-g._.js +3 -0
  381. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__19pc87s._.js +3 -0
  382. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_gu2yk._.js +3 -0
  383. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ai-945._.js +3 -0
  384. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +14 -0
  385. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bu2zio._.js +3 -0
  386. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ctczev._.js +3 -0
  387. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d6mtlk._.js +3 -0
  388. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d75vsx._.js +6 -0
  389. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dn_3i1._.js +3 -0
  390. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1e4z_-v._.js +3 -0
  391. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f2sueq._.js +3 -0
  392. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f9zctr._.js +3 -0
  393. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +3 -0
  394. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1js2jdv._.js +3 -0
  395. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mttufy._.js +3 -0
  396. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1nepkp-._.js +6 -0
  397. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1pp5oib._.js +3 -0
  398. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q5bqse._.js +3 -0
  399. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +14 -0
  400. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qwhzmi._.js +3 -0
  401. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9om6g._.js +3 -0
  402. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1xeczo7._.js +3 -0
  403. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20503l7._.js +3 -0
  404. package/runtime/hub/apps/hub/.next/server/chunks/[turbopack]_runtime.js +903 -0
  405. package/runtime/hub/apps/hub/.next/server/chunks/_033w048._.js +3 -0
  406. package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +3 -0
  407. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +27 -0
  408. package/runtime/hub/apps/hub/.next/server/chunks/_0pyhcqe._.js +3 -0
  409. package/runtime/hub/apps/hub/.next/server/chunks/_1-42ili._.js +3 -0
  410. package/runtime/hub/apps/hub/.next/server/chunks/_11__3wi._.js +3 -0
  411. package/runtime/hub/apps/hub/.next/server/chunks/_12flzuh._.js +3 -0
  412. package/runtime/hub/apps/hub/.next/server/chunks/_1rpkqst._.js +3 -0
  413. package/runtime/hub/apps/hub/.next/server/chunks/_1wt72m1._.js +3 -0
  414. package/runtime/hub/apps/hub/.next/server/chunks/_1x3l5t8._.js +3 -0
  415. package/runtime/hub/apps/hub/.next/server/chunks/apps_hub__next-internal_server_app_(dashboard)_api_events_route_actions_17s9lxs.js +3 -0
  416. package/runtime/hub/apps/hub/.next/server/chunks/apps_hub__next-internal_server_app_(dashboard)_api_v1_docs_route_actions_0d-s_oo.js +3 -0
  417. package/runtime/hub/apps/hub/.next/server/chunks/apps_hub__next-internal_server_app_[___path]_route_actions_1hdraye.js +3 -0
  418. package/runtime/hub/apps/hub/.next/server/chunks/packages_relay_dist_control-plane_03a-9aj.js +86 -0
  419. package/runtime/hub/apps/hub/.next/server/chunks/ssr/044u_hub__next-internal_server_app_(dashboard)_projects_[id]_page_actions_15f56np.js +3 -0
  420. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0iwlo01._.js +6 -0
  421. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0xy-j7z._.js +3 -0
  422. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_client_components_20xzgz2._.js +3 -0
  423. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_client_components_builtin_forbidden_1x5yo9-.js +3 -0
  424. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_client_components_builtin_global-error_14poel6.js +3 -0
  425. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_client_components_builtin_unauthorized_0vj9qge.js +3 -0
  426. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_010858m.js +4 -0
  427. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_04zwxnx.js +4 -0
  428. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_06exuc7.js +4 -0
  429. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2ldrt.js +4 -0
  430. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2tzep.js +4 -0
  431. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_116nh32.js +4 -0
  432. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_11dyjcb.js +4 -0
  433. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_1_4knli.js +4 -0
  434. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[externals]_pg_15jfwkh._.js +3 -0
  435. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[externals]_pg_20c820g._.js +3 -0
  436. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__03-x9xy._.js +19 -0
  437. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__08-1wwu._.js +3 -0
  438. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0c9mbcn._.js +3 -0
  439. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0cpdgd0._.js +33 -0
  440. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0gdfxj4._.js +3 -0
  441. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0j0tjwn._.js +3 -0
  442. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0kc-hwp._.js +3 -0
  443. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0lu73p6._.js +3 -0
  444. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__10bfmwi._.js +3 -0
  445. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__18qvdzb._.js +33 -0
  446. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1bq2f8q._.js +3 -0
  447. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1c1x9zr._.js +3 -0
  448. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1he4k-q._.js +3 -0
  449. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1l2urlw._.js +3 -0
  450. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[turbopack]_runtime.js +903 -0
  451. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_04br1ft._.js +6 -0
  452. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +3 -0
  453. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0kpdmm-._.js +3 -0
  454. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ozyjt1._.js +21 -0
  455. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +27 -0
  456. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +3 -0
  457. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +3 -0
  458. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0_lzzn3._.js +3 -0
  459. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +3 -0
  460. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(auth)_signin_page_actions_1vmiwl7.js +3 -0
  461. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_approvals_page_actions_1mi0bpn.js +3 -0
  462. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_boxes_[id]_page_actions_0k7kgn2.js +3 -0
  463. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_page_actions_1t3u0xy.js +3 -0
  464. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_settings_page_actions_0ti7gxm.js +3 -0
  465. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app__global-error_page_actions_1ofuxm1.js +3 -0
  466. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app__not-found_page_actions_1fmdkci.js +3 -0
  467. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_[id]_page_tsx_1-j_972._.js +3 -0
  468. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_components_box-table_tsx_0a9pyn_._.js +3 -0
  469. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +3 -0
  470. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_lib_auth_client_ts_1uxjxr_._.js +3 -0
  471. package/runtime/hub/apps/hub/.next/server/chunks/ssr/node_modules__pnpm_04qfi10._.js +3 -0
  472. package/runtime/hub/apps/hub/.next/server/chunks/ssr/node_modules__pnpm_0kvuy0s._.js +33 -0
  473. package/runtime/hub/apps/hub/.next/server/chunks/ssr/packages_relay_dist_control-plane_0ve-wz4.js +80 -0
  474. package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +40 -0
  475. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +21 -0
  476. package/runtime/hub/apps/hub/.next/server/middleware-manifest.json +6 -0
  477. package/runtime/hub/apps/hub/.next/server/middleware.js +5 -0
  478. package/runtime/hub/apps/hub/.next/server/next-font-manifest.js +1 -0
  479. package/runtime/hub/apps/hub/.next/server/next-font-manifest.json +49 -0
  480. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -0
  481. package/runtime/hub/apps/hub/.next/server/pages-manifest.json +3 -0
  482. package/runtime/hub/apps/hub/.next/server/prefetch-hints.json +1 -0
  483. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.js +1 -0
  484. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.json +276 -0
  485. package/runtime/hub/apps/hub/.next/static/TpPTWVdZDxqrPlONtJcR5/_buildManifest.js +11 -0
  486. package/runtime/hub/apps/hub/.next/static/TpPTWVdZDxqrPlONtJcR5/_clientMiddlewareManifest.js +6 -0
  487. package/runtime/hub/apps/hub/.next/static/TpPTWVdZDxqrPlONtJcR5/_ssgManifest.js +1 -0
  488. package/runtime/hub/apps/hub/.next/static/chunks/0cz1d0mv5g_q7.js +1 -0
  489. package/runtime/hub/apps/hub/.next/static/chunks/0dx4alyqu7cq1.css +3 -0
  490. package/runtime/hub/apps/hub/.next/static/chunks/0lq354ziiwxxl.js +1 -0
  491. package/runtime/hub/apps/hub/.next/static/chunks/0ptag81psa0nj.js +1 -0
  492. package/runtime/hub/apps/hub/.next/static/chunks/11vmjdy3390ik.js +1 -0
  493. package/runtime/hub/apps/hub/.next/static/chunks/19cwkdx97a5_c.js +1 -0
  494. package/runtime/hub/apps/hub/.next/static/chunks/1svigjdfotduh.js +1 -0
  495. package/runtime/hub/apps/hub/.next/static/chunks/1t3645mc1s54c.js +1 -0
  496. package/runtime/hub/apps/hub/.next/static/chunks/1y49eldffr2-_.js +31 -0
  497. package/runtime/hub/apps/hub/.next/static/chunks/26ef4lcj-7-li.js +1 -0
  498. package/runtime/hub/apps/hub/.next/static/chunks/2d5e6t-5j4etp.js +1 -0
  499. package/runtime/hub/apps/hub/.next/static/chunks/2ozcn3ku69ymf.js +1 -0
  500. package/runtime/hub/apps/hub/.next/static/chunks/2w65a9zig6ya7.js +4 -0
  501. package/runtime/hub/apps/hub/.next/static/chunks/2x7nfpuaaba_a.js +1 -0
  502. package/runtime/hub/apps/hub/.next/static/chunks/3-zanu4ioia5i.js +1 -0
  503. package/runtime/hub/apps/hub/.next/static/chunks/3c49t4evjq8hf.js +1 -0
  504. package/runtime/hub/apps/hub/.next/static/chunks/3x8k7so-uoat8.js +2 -0
  505. package/runtime/hub/apps/hub/.next/static/chunks/3y2c7woqhtx9s.js +1 -0
  506. package/runtime/hub/apps/hub/.next/static/chunks/turbopack-2x4_cva4cco3h.js +1 -0
  507. package/runtime/hub/apps/hub/.next/static/media/02263ebadd758ea4-s.29yke99gs9qpn.woff2 +0 -0
  508. package/runtime/hub/apps/hub/.next/static/media/03fc1b4a8d284b5e-s.p.0wiir8udbzjvx.woff2 +0 -0
  509. package/runtime/hub/apps/hub/.next/static/media/1a69062cfe6f77f8-s.0o-3_g79811ob.woff2 +0 -0
  510. package/runtime/hub/apps/hub/.next/static/media/1bcd0e671759a44c-s.2qt3tdwt-y9x_.woff2 +0 -0
  511. package/runtime/hub/apps/hub/.next/static/media/23b7a97ae3b5c134-s.p.226pwps5o-gq_.woff2 +0 -0
  512. package/runtime/hub/apps/hub/.next/static/media/2e95a7d252b9825a-s.15orukf5wyxb5.woff2 +0 -0
  513. package/runtime/hub/apps/hub/.next/static/media/2fe89d53234c61d4-s.1u30mmyq6lnsd.woff2 +0 -0
  514. package/runtime/hub/apps/hub/.next/static/media/57215795b8570f5c-s.2rixgazldzomk.woff2 +0 -0
  515. package/runtime/hub/apps/hub/.next/static/media/59b15b4bcd7b1eb5-s.2vemzm0itqzfy.woff2 +0 -0
  516. package/runtime/hub/apps/hub/.next/static/media/5e05ae5b48faa55e-s.1yd4_i3e35931.woff2 +0 -0
  517. package/runtime/hub/apps/hub/.next/static/media/68757d6cddeff913-s.1i-sca43-qwng.woff2 +0 -0
  518. package/runtime/hub/apps/hub/.next/static/media/6ff74e33ebd7bca3-s.352ti9pm7m6qh.woff2 +0 -0
  519. package/runtime/hub/apps/hub/.next/static/media/7fea77d1d19108bf-s.2y65deuc30pmy.woff2 +0 -0
  520. package/runtime/hub/apps/hub/.next/static/media/90c51ce8fb754fe8-s.02z5rrbg5nt92.woff2 +0 -0
  521. package/runtime/hub/apps/hub/.next/static/media/99e609270109b47d-s.p.40sczeszzbjw1.woff2 +0 -0
  522. package/runtime/hub/apps/hub/.next/static/media/9a4838fcda0d1bca-s.0ngr-xkgqz1kf.woff2 +0 -0
  523. package/runtime/hub/apps/hub/.next/static/media/a7afbb44bec2bb18-s.1qc6dx89jd2qv.woff2 +0 -0
  524. package/runtime/hub/apps/hub/.next/static/media/e15f58668ad64cb8-s.3cvcemwuzoywn.woff2 +0 -0
  525. package/runtime/hub/apps/hub/.next/static/media/e390973e931a41c5-s.0rgnxg2b64rzs.woff2 +0 -0
  526. package/runtime/hub/apps/hub/.next/static/media/e532fa1b9921e1cd-s.3cb5lpr2l6xud.woff2 +0 -0
  527. package/runtime/hub/apps/hub/.next/static/media/effe91970fc4db64-s.p.0oace-s_gkfks.woff2 +0 -0
  528. package/runtime/hub/apps/hub/auth-YBXDRLHG.js +75 -0
  529. package/runtime/hub/apps/hub/auth-config-LJGI76HI.js +21 -0
  530. package/runtime/hub/apps/hub/chunk-3LAHFDJF.js +287 -0
  531. package/runtime/hub/apps/hub/chunk-AKLBSCSZ.js +8573 -0
  532. package/runtime/hub/apps/hub/chunk-EFW34I43.js +7299 -0
  533. package/runtime/hub/apps/hub/chunk-JDA7BPPN.js +2806 -0
  534. package/runtime/hub/apps/hub/chunk-LJG4CEGS.js +3341 -0
  535. package/runtime/hub/apps/hub/chunk-OBKLTPIR.js +41 -0
  536. package/runtime/hub/apps/hub/chunk-OF242BLD.js +797 -0
  537. package/runtime/hub/apps/hub/chunk-TZFWAJVB.js +38 -0
  538. package/runtime/hub/apps/hub/chunk-V5KGFHCF.js +12683 -0
  539. package/runtime/hub/apps/hub/cloud-poller-SUNA6ZQC-VSKVMYHL.js +10 -0
  540. package/runtime/hub/apps/hub/dist-BF54UNHK.js +1029 -0
  541. package/runtime/hub/apps/hub/dist-CM4YAQLI.js +1656 -0
  542. package/runtime/hub/apps/hub/dist-ELOY2IUE.js +533 -0
  543. package/runtime/hub/apps/hub/dist-FDBOJ74K.js +1085 -0
  544. package/runtime/hub/apps/hub/dist-GGM4BUKM.js +2281 -0
  545. package/runtime/hub/apps/hub/dist-IENF7YOD.js +88 -0
  546. package/runtime/hub/apps/hub/execa-4DLVNM6E.js +32 -0
  547. package/runtime/hub/apps/hub/hub-token-EW32VDIU.js +25 -0
  548. package/runtime/hub/apps/hub/package.json +55 -0
  549. package/runtime/hub/apps/hub/prepared-state-5FIGV4BE-FIXKBF5A.js +19 -0
  550. package/runtime/hub/apps/hub/public/logo.svg +5 -0
  551. package/runtime/hub/apps/hub/server.js +838 -0
  552. package/runtime/relay/bin.cjs +1738 -482
  553. package/runtime/vercel/ctl.cjs +11871 -10351
  554. package/runtime/vercel/scripts/provision.sh +31 -15
  555. package/dist/chunk-6JJIKCMY.js.map +0 -1
  556. package/dist/chunk-DBMLOY3T.js +0 -793
  557. package/dist/chunk-DBMLOY3T.js.map +0 -1
  558. package/dist/chunk-KTEDFUKM.js +0 -831
  559. package/dist/chunk-KTEDFUKM.js.map +0 -1
  560. package/dist/chunk-QKL7PCXQ.js.map +0 -1
  561. package/dist/chunk-X2DWS4KS.js +0 -820
  562. package/dist/chunk-X2DWS4KS.js.map +0 -1
  563. package/dist/chunk-YZVFGFYQ.js.map +0 -1
  564. package/dist/dist-FMA5Y25B.js.map +0 -1
  565. package/dist/dist-NWKOEWUJ.js.map +0 -1
  566. package/dist/dist-U76JL6HI.js +0 -738
  567. package/dist/dist-U76JL6HI.js.map +0 -1
  568. package/dist/dist-UVQJ2BZJ.js.map +0 -1
  569. /package/dist/{_cloud-attach-U3QJO7IF.js.map → _cloud-attach-YH2SU75S.js.map} +0 -0
  570. /package/dist/{dist-SAS4PIHA.js.map → dist-EJXUKIR7.js.map} +0 -0
  571. /package/dist/{prepared-state-MQHD3M5F-YYVVMTNJ.js.map → dist-QBXEP4VY.js.map} +0 -0
@@ -0,0 +1,2561 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ../../packages/core/dist/index.js
4
+ import { randomBytes } from "crypto";
5
+ import { realpath } from "fs/promises";
6
+ import { basename, dirname, isAbsolute as isAbsolute2, normalize, resolve as resolve2, sep } from "path";
7
+ var claudeCodeLauncher = {
8
+ kind: "claude-code",
9
+ // claude treats its first positional argument as the seed user turn in
10
+ // interactive mode (`claude "<message>"`), so we slot the initial message
11
+ // ahead of any user-passed flags.
12
+ buildArgs(initialMessage, userArgs) {
13
+ if (!initialMessage) return [...userArgs];
14
+ return [initialMessage, ...userArgs];
15
+ }
16
+ };
17
+ var codexLauncher = {
18
+ kind: "codex",
19
+ buildArgs(initialMessage, userArgs) {
20
+ if (!initialMessage) return [...userArgs];
21
+ return [initialMessage, ...userArgs];
22
+ }
23
+ };
24
+ var opencodeLauncher = {
25
+ kind: "opencode",
26
+ buildArgs(initialMessage, userArgs) {
27
+ if (!initialMessage) return [...userArgs];
28
+ return [initialMessage, ...userArgs];
29
+ }
30
+ };
31
+ function resolveAgentLauncher(kind) {
32
+ if (kind === "claude-code") return claudeCodeLauncher;
33
+ if (kind === "codex") return codexLauncher;
34
+ if (kind === "opencode") return opencodeLauncher;
35
+ throw new Error(`unknown agent kind: ${String(kind)}`);
36
+ }
37
+ var PLACEHOLDER_KEYS = [
38
+ "AGENTBOX_BOX_NAME",
39
+ "AGENTBOX_BOX_ID",
40
+ "AGENTBOX_BOX_KIND",
41
+ "AGENTBOX_HOST_WORKSPACE",
42
+ "AGENTBOX_PROJECT_ROOT",
43
+ // Convenience: the host this box is reachable at. Derived from
44
+ // AGENTBOX_BOX_NAME as `<box-name>.localhost` when not set explicitly (the
45
+ // portless host for docker/hetzner). Public-URL cloud providers
46
+ // (vercel/daytona/e2b) set it explicitly at boot to the real preview host
47
+ // (e.g. `<sub>.vercel.run`), which then wins over the derived fallback.
48
+ "AGENTBOX_BOX_HOST"
49
+ ];
50
+ var PLACEHOLDER_SET = new Set(PLACEHOLDER_KEYS);
51
+ var ReplaceError = class extends Error {
52
+ constructor(message) {
53
+ super(message);
54
+ this.name = "ReplaceError";
55
+ }
56
+ };
57
+ var PLACEHOLDER_RE = /\{\{\s*([A-Z0-9_]+)\s*\}\}/g;
58
+ function substitutePlaceholders(text, context, onWarn) {
59
+ return text.replace(PLACEHOLDER_RE, (match, name) => {
60
+ if (!PLACEHOLDER_SET.has(name)) return match;
61
+ const value = context[name];
62
+ if (value === void 0) {
63
+ onWarn?.(`placeholder {{${name}}} has no value in this context \u2014 left untouched`);
64
+ return match;
65
+ }
66
+ return value;
67
+ });
68
+ }
69
+ function applyReplacements(content, opts) {
70
+ let out = content;
71
+ if (opts.env) {
72
+ out = substitutePlaceholders(out, opts.context, opts.onWarn);
73
+ }
74
+ for (const rule of opts.rules ?? []) {
75
+ const to = substitutePlaceholders(rule.to, opts.context, opts.onWarn);
76
+ if (rule.regex) {
77
+ let re;
78
+ try {
79
+ re = new RegExp(rule.from, rule.flags ?? "g");
80
+ } catch (err) {
81
+ throw new ReplaceError(
82
+ `invalid regex "${rule.from}": ${err instanceof Error ? err.message : String(err)}`
83
+ );
84
+ }
85
+ out = out.replace(re, to);
86
+ } else {
87
+ out = out.split(rule.from).join(to);
88
+ }
89
+ }
90
+ return out;
91
+ }
92
+ function deriveBoxHost(ctx) {
93
+ if (ctx.AGENTBOX_BOX_HOST === void 0 && ctx.AGENTBOX_BOX_NAME !== void 0) {
94
+ ctx.AGENTBOX_BOX_HOST = `${ctx.AGENTBOX_BOX_NAME}.localhost`;
95
+ }
96
+ return ctx;
97
+ }
98
+ function isPlainObject(v) {
99
+ return typeof v === "object" && v !== null && !Array.isArray(v);
100
+ }
101
+ var RULE_KEYS = /* @__PURE__ */ new Set(["from", "to", "regex", "flags"]);
102
+ function parseReplaceRule(raw, where) {
103
+ if (!isPlainObject(raw)) {
104
+ throw new ReplaceError(`${where} must be a mapping with at least { from, to }`);
105
+ }
106
+ for (const key of Object.keys(raw)) {
107
+ if (!RULE_KEYS.has(key)) throw new ReplaceError(`${where} has unknown key "${key}"`);
108
+ }
109
+ if (typeof raw.from !== "string" || raw.from.length === 0) {
110
+ throw new ReplaceError(`${where}.from must be a non-empty string`);
111
+ }
112
+ if (typeof raw.to !== "string") {
113
+ throw new ReplaceError(`${where}.to must be a string`);
114
+ }
115
+ const rule = { from: raw.from, to: raw.to };
116
+ if (raw.regex !== void 0 && raw.regex !== null) {
117
+ if (typeof raw.regex !== "boolean") throw new ReplaceError(`${where}.regex must be a boolean`);
118
+ rule.regex = raw.regex;
119
+ }
120
+ if (raw.flags !== void 0 && raw.flags !== null) {
121
+ if (typeof raw.flags !== "string") throw new ReplaceError(`${where}.flags must be a string`);
122
+ rule.flags = raw.flags;
123
+ }
124
+ if (rule.regex) {
125
+ try {
126
+ new RegExp(rule.from, rule.flags ?? "g");
127
+ } catch (err) {
128
+ throw new ReplaceError(
129
+ `${where}.from is not a valid regex: ${err instanceof Error ? err.message : String(err)}`
130
+ );
131
+ }
132
+ }
133
+ return rule;
134
+ }
135
+ function parseReplaceRules(raw, where) {
136
+ if (raw === void 0 || raw === null) return [];
137
+ if (!Array.isArray(raw)) throw new ReplaceError(`${where} must be a list of rules`);
138
+ return raw.map((r, i) => parseReplaceRule(r, `${where}[${String(i)}]`));
139
+ }
140
+ function parseReplacements(raw) {
141
+ if (raw === void 0 || raw === null) return {};
142
+ if (!isPlainObject(raw)) {
143
+ throw new ReplaceError("replacements must be a mapping of name \u2192 rule list");
144
+ }
145
+ const out = {};
146
+ for (const [name, rules] of Object.entries(raw)) {
147
+ if (!/^[A-Za-z0-9_-]+$/.test(name)) {
148
+ throw new ReplaceError(`replacements.${name}: name must match [A-Za-z0-9_-]+`);
149
+ }
150
+ out[name] = parseReplaceRules(rules, `replacements.${name}`);
151
+ }
152
+ return out;
153
+ }
154
+ function resolveRuleRefs(refs, replacements, where) {
155
+ const out = [];
156
+ for (const name of refs) {
157
+ const set = replacements[name];
158
+ if (set === void 0) {
159
+ const known = Object.keys(replacements);
160
+ throw new ReplaceError(
161
+ `${where}: unknown replacements rule-set "${name}"` + (known.length > 0 ? ` (known: ${known.join(", ")})` : " (none declared)")
162
+ );
163
+ }
164
+ out.push(...set);
165
+ }
166
+ return out;
167
+ }
168
+ var UserFacingError = class extends Error {
169
+ constructor(message) {
170
+ super(message);
171
+ this.name = "UserFacingError";
172
+ }
173
+ };
174
+ var BoxNotFoundError = class extends Error {
175
+ constructor(query) {
176
+ super(`no agentbox matches "${query}"`);
177
+ this.query = query;
178
+ this.name = "BoxNotFoundError";
179
+ }
180
+ query;
181
+ };
182
+ var AmbiguousBoxError = class extends Error {
183
+ constructor(query, matches) {
184
+ const ids = matches.map((m) => m.id).join(", ");
185
+ super(`"${query}" matches multiple boxes: ${ids}`);
186
+ this.query = query;
187
+ this.matches = matches;
188
+ this.name = "AmbiguousBoxError";
189
+ }
190
+ query;
191
+ matches;
192
+ };
193
+ var BOX_ID_PREFIX = "b";
194
+ function generateBoxId() {
195
+ return `${BOX_ID_PREFIX}${randomBytes(4).toString("hex")}`;
196
+ }
197
+ function toSyncKind(k) {
198
+ if (k === "claude-code" || k === "claude") return "claude";
199
+ if (k === "codex") return "codex";
200
+ if (k === "opencode") return "opencode";
201
+ throw new Error(`unknown agent kind: ${k}`);
202
+ }
203
+ function toQueueKind(k) {
204
+ return k === "claude" ? "claude-code" : k;
205
+ }
206
+ function normalizeLastAgent(raw) {
207
+ if (!raw) return void 0;
208
+ if (raw === "claude-code" || raw === "claude") return "claude";
209
+ if (raw === "codex") return "codex";
210
+ if (raw === "opencode") return "opencode";
211
+ return void 0;
212
+ }
213
+ var SYNC_DRYRUN_ENV = "AGENTBOX_SYNC_DRYRUN";
214
+ function dryRunProviderSync(label) {
215
+ const note = (ctx, op, detail = "") => ctx.onLog(`[sync dry-run] ${label}.${op}(${detail})`);
216
+ return {
217
+ resyncWorkspace(ctx, worktrees) {
218
+ note(ctx, "resyncWorkspace", `${String(worktrees.length)} worktree(s)`);
219
+ return Promise.resolve({ repos: [], hadConflicts: false });
220
+ },
221
+ seedAgentConfig(ctx) {
222
+ note(ctx, "seedAgentConfig");
223
+ return Promise.resolve();
224
+ },
225
+ seedCredentials(ctx) {
226
+ note(ctx, "seedCredentials");
227
+ return Promise.resolve();
228
+ },
229
+ extractCredentials(ctx) {
230
+ note(ctx, "extractCredentials");
231
+ return Promise.resolve([]);
232
+ },
233
+ seedGitIdentity(ctx) {
234
+ note(ctx, "seedGitIdentity");
235
+ return Promise.resolve();
236
+ },
237
+ seedEnvFiles(ctx, patterns) {
238
+ note(ctx, "seedEnvFiles", `${String(patterns.length)} pattern(s)`);
239
+ return Promise.resolve({ copied: 0 });
240
+ },
241
+ applyCarry(ctx, entries) {
242
+ note(ctx, "applyCarry", `${String(entries.length)} entry/entries`);
243
+ return Promise.resolve({ copied: 0, errors: [], applied: [] });
244
+ }
245
+ };
246
+ }
247
+ function resolveSyncTopology(providerName, controlPlaneUrl) {
248
+ if (providerName === "docker") return "docker";
249
+ return controlPlaneUrl && controlPlaneUrl.length > 0 ? "control-plane" : "cloud";
250
+ }
251
+ async function realpathSafe(p) {
252
+ try {
253
+ return await realpath(p);
254
+ } catch {
255
+ return resolve2(p);
256
+ }
257
+ }
258
+ function isInside(child, parent) {
259
+ const c = resolve2(child);
260
+ const p = resolve2(parent);
261
+ if (c === p) return true;
262
+ return c.startsWith(p + sep);
263
+ }
264
+ var SCRATCH_BRANCH_PREFIX = "agentbox/";
265
+ function isScratchBranch(branch) {
266
+ return !!branch && branch.startsWith(SCRATCH_BRANCH_PREFIX);
267
+ }
268
+
269
+ // ../../packages/sandbox-core/dist/index.js
270
+ import { mkdir, open, readFile, rename, rm, stat, writeFile } from "fs/promises";
271
+ import { homedir } from "os";
272
+ import { dirname as dirname2, join } from "path";
273
+ import { setTimeout as delay } from "timers/promises";
274
+ import { execa } from "execa";
275
+ import { readdir, stat as stat2 } from "fs/promises";
276
+ import { join as join2 } from "path";
277
+ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
278
+ import { homedir as homedir2 } from "os";
279
+ import { dirname as dirname22, resolve } from "path";
280
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
281
+ import { mkdir as mkdir2, open as open2, readFile as readFile2, rename as rename2, rm as rm2, stat as stat3, writeFile as writeFile2 } from "fs/promises";
282
+ import { homedir as homedir3 } from "os";
283
+ import { dirname as dirname3, join as join3 } from "path";
284
+ import { setTimeout as delay2 } from "timers/promises";
285
+ import { mkdtemp, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
286
+ import { tmpdir } from "os";
287
+ import { basename as basename2, join as join4 } from "path";
288
+ import { join as join5 } from "path";
289
+ import { homedir as homedir4 } from "os";
290
+ import { mkdtemp as mkdtemp2, rm as rm3 } from "fs/promises";
291
+ import { tmpdir as tmpdir2 } from "os";
292
+ import { join as join6 } from "path";
293
+ import { execa as execa2 } from "execa";
294
+ import { readdir as readdir2, stat as stat4 } from "fs/promises";
295
+ import { homedir as homedir5 } from "os";
296
+ import { join as join7 } from "path";
297
+ import { readdir as readdir3, realpath as realpath2, stat as stat5 } from "fs/promises";
298
+ import { isAbsolute, join as join8, relative } from "path";
299
+ import { stat as stat6 } from "fs/promises";
300
+ import { chmod, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
301
+ import { dirname as dirname4 } from "path";
302
+ import { createHash } from "crypto";
303
+ import { readFile as readFile5 } from "fs/promises";
304
+ import { join as join9 } from "path";
305
+ import { execa as execa3 } from "execa";
306
+ import { createHash as createHash2 } from "crypto";
307
+ import { copyFile, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir4, readFile as readFile6, rm as rm4, stat as stat7 } from "fs/promises";
308
+ import { homedir as homedir6, tmpdir as tmpdir3 } from "os";
309
+ import { basename as basename22, dirname as dirname5, join as join10 } from "path";
310
+ import { execa as execa4 } from "execa";
311
+ 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";
312
+ import { homedir as homedir8, tmpdir as tmpdir4 } from "os";
313
+ import { basename as basename3, join as join11, relative as relative2 } from "path";
314
+ import { execa as execa5 } from "execa";
315
+ import { homedir as homedir7 } from "os";
316
+ import { parse, stringify } from "smol-toml";
317
+ import { createHash as createHash3 } from "crypto";
318
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
319
+ import { readFile as readFile8 } from "fs/promises";
320
+ import { homedir as homedir9 } from "os";
321
+ import { dirname as dirname6, resolve as pathResolve } from "path";
322
+ var STATE_DIR = join(homedir(), ".agentbox");
323
+ var STATE_FILE = join(STATE_DIR, "state.json");
324
+ var EMPTY = { version: 1, boxes: [] };
325
+ var LOCK_STALE_MS = 15e3;
326
+ var LOCK_ACQUIRE_TIMEOUT_MS = 2e4;
327
+ var LOCK_RETRY_MS = 25;
328
+ async function withStateLock(path, fn) {
329
+ const lockPath = `${path}.lock`;
330
+ await mkdir(dirname2(path), { recursive: true });
331
+ const deadline = Date.now() + LOCK_ACQUIRE_TIMEOUT_MS;
332
+ let held = false;
333
+ while (!held) {
334
+ try {
335
+ const fh = await open(lockPath, "wx");
336
+ await fh.writeFile(`${String(process.pid)}
337
+ `);
338
+ await fh.close();
339
+ held = true;
340
+ } catch (err) {
341
+ if (err.code !== "EEXIST") throw err;
342
+ try {
343
+ const st = await stat(lockPath);
344
+ if (Date.now() - st.mtimeMs > LOCK_STALE_MS) {
345
+ await rm(lockPath, { force: true });
346
+ continue;
347
+ }
348
+ } catch {
349
+ continue;
350
+ }
351
+ if (Date.now() >= deadline) break;
352
+ await delay(LOCK_RETRY_MS);
353
+ }
354
+ }
355
+ try {
356
+ return await fn();
357
+ } finally {
358
+ if (held) await rm(lockPath, { force: true }).catch(() => {
359
+ });
360
+ }
361
+ }
362
+ async function mutateState(mutator, path = STATE_FILE) {
363
+ await withStateLock(path, async () => {
364
+ const state = await readState(path);
365
+ await writeState(mutator(state), path);
366
+ });
367
+ }
368
+ async function readState(path = STATE_FILE) {
369
+ try {
370
+ const raw = await readFile(path, "utf8");
371
+ const parsed = JSON.parse(raw);
372
+ if (parsed.version !== 1 || !Array.isArray(parsed.boxes)) {
373
+ throw new Error(`unrecognized state file shape at ${path}`);
374
+ }
375
+ for (const b of parsed.boxes) {
376
+ b.provider ??= "docker";
377
+ if ((b.provider ?? "docker") === "docker" && !b.docker) {
378
+ b.docker = projectDockerFields(b);
379
+ }
380
+ }
381
+ return parsed;
382
+ } catch (err) {
383
+ if (err.code === "ENOENT") {
384
+ return { ...EMPTY };
385
+ }
386
+ throw err;
387
+ }
388
+ }
389
+ async function writeState(state, path = STATE_FILE) {
390
+ await mkdir(dirname2(path), { recursive: true });
391
+ const tmp = `${path}.tmp.${String(process.pid)}.${String(Date.now())}`;
392
+ await writeFile(tmp, JSON.stringify(state, null, 2) + "\n", "utf8");
393
+ await rename(tmp, path);
394
+ }
395
+ async function recordBox(box, path = STATE_FILE) {
396
+ const toWrite = (box.provider ?? "docker") === "docker" && !box.docker ? { ...box, docker: projectDockerFields(box) } : box;
397
+ await mutateState(
398
+ (state) => ({
399
+ version: 1,
400
+ boxes: [...state.boxes.filter((b) => b.id !== toWrite.id), toWrite]
401
+ }),
402
+ path
403
+ );
404
+ }
405
+ async function recordLastAgent(boxId, kind, path = STATE_FILE) {
406
+ await mutateState(
407
+ (state) => ({
408
+ version: 1,
409
+ boxes: state.boxes.map((b) => b.id === boxId ? { ...b, lastAgent: kind } : b)
410
+ }),
411
+ path
412
+ );
413
+ }
414
+ async function recordBoxSsh(boxId, ssh, path = STATE_FILE) {
415
+ await mutateState(
416
+ (state) => ({
417
+ version: 1,
418
+ boxes: state.boxes.map(
419
+ (b) => b.id === boxId && b.cloud ? { ...b, cloud: { ...b.cloud, ssh } } : b
420
+ )
421
+ }),
422
+ path
423
+ );
424
+ }
425
+ async function reserveProjectIndex(record, projectRoot, path = STATE_FILE) {
426
+ let index = 1;
427
+ await mutateState((state) => {
428
+ index = allocateProjectIndex(state, projectRoot);
429
+ const reserved = { ...record, projectRoot, projectIndex: index };
430
+ return {
431
+ version: 1,
432
+ boxes: [...state.boxes.filter((b) => b.id !== record.id), reserved]
433
+ };
434
+ }, path);
435
+ return index;
436
+ }
437
+ function projectDockerFields(box) {
438
+ return {
439
+ container: box.container,
440
+ image: box.image,
441
+ snapshotDir: box.snapshotDir ?? null,
442
+ socketPath: box.socketPath,
443
+ claudeConfigVolume: box.claudeConfigVolume,
444
+ codexConfigVolume: box.codexConfigVolume,
445
+ opencodeConfigVolume: box.opencodeConfigVolume,
446
+ vscodeServerVolume: box.vscodeServerVolume,
447
+ cursorServerVolume: box.cursorServerVolume,
448
+ vncHostPort: box.vncHostPort,
449
+ webHostPort: box.webHostPort,
450
+ portlessAlias: box.portlessAlias,
451
+ portlessUrl: box.portlessUrl,
452
+ portlessVncAlias: box.portlessVncAlias,
453
+ portlessVncUrl: box.portlessVncUrl,
454
+ dockerVolume: box.dockerVolume,
455
+ dockerCacheShared: box.dockerCacheShared,
456
+ checkpointImage: box.checkpointImage
457
+ };
458
+ }
459
+ async function removeBoxRecord(id, path = STATE_FILE) {
460
+ let removed = false;
461
+ await mutateState((state) => {
462
+ const next = state.boxes.filter((b) => b.id !== id);
463
+ removed = next.length !== state.boxes.length;
464
+ return { version: 1, boxes: next };
465
+ }, path);
466
+ return removed;
467
+ }
468
+ function findBox(idOrName, state) {
469
+ const q = idOrName.trim();
470
+ if (q.length === 0) return { kind: "none" };
471
+ const exactId = state.boxes.find((b) => b.id === q);
472
+ if (exactId) return { kind: "ok", box: exactId };
473
+ const prefixMatches = state.boxes.filter((b) => b.id.startsWith(q));
474
+ if (prefixMatches.length === 1) return { kind: "ok", box: prefixMatches[0] };
475
+ if (prefixMatches.length > 1) return { kind: "ambiguous", matches: prefixMatches };
476
+ const byName = state.boxes.find((b) => b.name === q);
477
+ if (byName) return { kind: "ok", box: byName };
478
+ const byContainer = state.boxes.find((b) => b.container === q);
479
+ if (byContainer) return { kind: "ok", box: byContainer };
480
+ return { kind: "none" };
481
+ }
482
+ function allocateProjectIndex(state, projectRoot) {
483
+ let max = 0;
484
+ for (const b of state.boxes) {
485
+ if (b.projectRoot !== projectRoot) continue;
486
+ if (typeof b.projectIndex === "number" && b.projectIndex > max) {
487
+ max = b.projectIndex;
488
+ }
489
+ }
490
+ return max + 1;
491
+ }
492
+ function autoPickProjectBox(state, projectRoot) {
493
+ const matches = state.boxes.filter((b) => b.projectRoot === projectRoot);
494
+ if (matches.length === 0) return { kind: "none" };
495
+ if (matches.length === 1) return { kind: "ok", box: matches[0] };
496
+ return { kind: "ambiguous", matches };
497
+ }
498
+ function resolveBoxRef(ref, state, projectRoot) {
499
+ if (ref === void 0) {
500
+ if (projectRoot === void 0) return { kind: "none" };
501
+ return autoPickProjectBox(state, projectRoot);
502
+ }
503
+ const trimmed = ref.trim();
504
+ if (projectRoot !== void 0 && /^[1-9][0-9]*$/.test(trimmed)) {
505
+ const idx = Number.parseInt(trimmed, 10);
506
+ const hit = state.boxes.find((b) => b.projectRoot === projectRoot && b.projectIndex === idx);
507
+ return hit ? { kind: "ok", box: hit } : { kind: "none" };
508
+ }
509
+ return findBox(trimmed, state);
510
+ }
511
+ async function detectGitRepos(workspace) {
512
+ const out = [];
513
+ if (await isGitDir(join2(workspace, ".git"))) {
514
+ out.push({ kind: "root", hostMainRepo: workspace, relPathFromWorkspace: "" });
515
+ }
516
+ let entries;
517
+ try {
518
+ entries = await readdir(workspace, { withFileTypes: true });
519
+ } catch {
520
+ return out;
521
+ }
522
+ for (const e of entries) {
523
+ if (!e.isDirectory() || e.name.startsWith(".")) continue;
524
+ const sub = join2(workspace, e.name);
525
+ if (await isGitDir(join2(sub, ".git"))) {
526
+ out.push({ kind: "nested", hostMainRepo: sub, relPathFromWorkspace: e.name });
527
+ }
528
+ }
529
+ return out;
530
+ }
531
+ async function isGitDir(path) {
532
+ try {
533
+ const s = await stat2(path);
534
+ return s.isDirectory();
535
+ } catch {
536
+ return false;
537
+ }
538
+ }
539
+ async function pickFreshBranch(hostMainRepo, base) {
540
+ let candidate = base;
541
+ let suffix = 2;
542
+ while (await branchExists(hostMainRepo, candidate)) {
543
+ candidate = `${base}-${String(suffix++)}`;
544
+ if (suffix > 100) throw new GitWorktreeError(`could not find a free branch name near ${base}`);
545
+ }
546
+ return candidate;
547
+ }
548
+ async function branchExists(hostMainRepo, name) {
549
+ const result = await execa(
550
+ "git",
551
+ ["-C", hostMainRepo, "show-ref", "--verify", "--quiet", `refs/heads/${name}`],
552
+ { reject: false }
553
+ );
554
+ return result.exitCode === 0;
555
+ }
556
+ var GitWorktreeError = class extends Error {
557
+ constructor(message) {
558
+ super(message);
559
+ this.name = "GitWorktreeError";
560
+ }
561
+ };
562
+ function hostOpenCommand() {
563
+ return process.platform === "linux" ? "xdg-open" : "open";
564
+ }
565
+ var BOX_WORKSPACE = "/workspace";
566
+ function run(provider, box, argv) {
567
+ return provider.exec(box, argv, { cwd: BOX_WORKSPACE });
568
+ }
569
+ function scratchBranchName(name) {
570
+ const trimmed = name.trim();
571
+ return isScratchBranch(trimmed) ? trimmed : `${SCRATCH_BRANCH_PREFIX}${trimmed}`;
572
+ }
573
+ function boxGitCheckout(provider, box, branch, extraArgs = []) {
574
+ return run(provider, box, ["git", "checkout", branch, ...extraArgs]);
575
+ }
576
+ function boxGitNewBranch(provider, box, name, from) {
577
+ const argv = ["git", "checkout", "-b", scratchBranchName(name)];
578
+ if (from && from.trim()) argv.push(from.trim());
579
+ return run(provider, box, argv);
580
+ }
581
+ function gitRpcParams(remote, extraArgs) {
582
+ const params = { path: BOX_WORKSPACE };
583
+ if (remote) params.remote = remote;
584
+ if (extraArgs.length > 0) params.args = extraArgs;
585
+ return params;
586
+ }
587
+ async function boxGitPush(provider, box, opts, deps = {}) {
588
+ const extraArgs = [...opts.args ?? [], ...opts.force ? ["--force"] : []];
589
+ const params = gitRpcParams(opts.remote, extraArgs);
590
+ const tokenArgs = deps.hostInitiatedArgs ? await deps.hostInitiatedArgs("git.push", params) : [];
591
+ const argv = ["agentbox-ctl", "git", "push", ...tokenArgs];
592
+ if (opts.remote) argv.push("--remote", opts.remote);
593
+ argv.push(...extraArgs);
594
+ return run(provider, box, argv);
595
+ }
596
+ async function boxGitPull(provider, box, opts, deps = {}) {
597
+ const extraArgs = opts.args ?? [];
598
+ const params = gitRpcParams(opts.remote, extraArgs);
599
+ const tokenArgs = deps.hostInitiatedArgs ? await deps.hostInitiatedArgs("git.fetch", params) : [];
600
+ const argv = ["agentbox-ctl", "git", "pull", ...tokenArgs];
601
+ if (opts.remote) argv.push("--remote", opts.remote);
602
+ if (opts.ffOnly) argv.push("--ff-only");
603
+ argv.push(...extraArgs);
604
+ return run(provider, box, argv);
605
+ }
606
+ function boxGitPushHost(provider, box, opts = {}) {
607
+ const argv = ["agentbox-ctl", "git", "push", "--host-only"];
608
+ if (opts.as) argv.push("--as", opts.as);
609
+ if (opts.force) argv.push("--force");
610
+ argv.push(...opts.args ?? []);
611
+ return run(provider, box, argv);
612
+ }
613
+ function servicesStatusArgv() {
614
+ return ["agentbox-ctl", "status", "--json"];
615
+ }
616
+ function boxServicesStatusRaw(provider, box) {
617
+ return run(provider, box, servicesStatusArgv());
618
+ }
619
+ function restartServiceArgv(name) {
620
+ return ["agentbox-ctl", "restart", name];
621
+ }
622
+ function boxRestartService(provider, box, name) {
623
+ return run(provider, box, restartServiceArgv(name));
624
+ }
625
+ async function boxRestartServices(provider, box, names) {
626
+ const out = [];
627
+ for (const name of names) {
628
+ out.push({ name, result: await boxRestartService(provider, box, name) });
629
+ }
630
+ return out;
631
+ }
632
+ function firstLine(s) {
633
+ const i = s.indexOf("\n");
634
+ return i === -1 ? s : s.slice(0, i);
635
+ }
636
+ function errSummary(err) {
637
+ return err instanceof Error ? firstLine(err.message) : String(err);
638
+ }
639
+ function secretsEnvPath() {
640
+ return resolve(homedir2(), ".agentbox", "secrets.env");
641
+ }
642
+ function writeManagedSecrets(managedKeys, record) {
643
+ for (const k of managedKeys) delete process.env[k];
644
+ for (const [k, v] of Object.entries(record)) process.env[k] = v;
645
+ const path = secretsEnvPath();
646
+ mkdirSync(dirname22(path), { recursive: true });
647
+ let existing = "";
648
+ if (existsSync(path)) {
649
+ try {
650
+ existing = readFileSync(path, "utf8");
651
+ } catch {
652
+ existing = "";
653
+ }
654
+ }
655
+ const kept = existing.split(/\r?\n/).filter((line) => {
656
+ const stripped = line.startsWith("export ") ? line.slice("export ".length) : line;
657
+ const eq = stripped.indexOf("=");
658
+ if (eq <= 0) return true;
659
+ const key = stripped.slice(0, eq).trim();
660
+ return !managedKeys.includes(key);
661
+ }).join("\n").replace(/\s+$/u, "");
662
+ const lines = Object.entries(record).map(([k, v]) => `${k}=${v}`);
663
+ const body = (kept ? `${kept}
664
+ ` : "") + lines.join("\n") + "\n";
665
+ const tmp = `${path}.tmp`;
666
+ writeFileSync(tmp, body, { mode: 384 });
667
+ try {
668
+ chmodSync(tmp, 384);
669
+ } catch {
670
+ }
671
+ renameSync(tmp, path);
672
+ try {
673
+ chmodSync(path, 384);
674
+ } catch {
675
+ }
676
+ }
677
+ var PLUGINS_FILE = join3(homedir3(), ".agentbox", "plugins.json");
678
+ var SUPPORTED_SDK_API_VERSIONS = [1];
679
+ function isSupportedApiVersion(v) {
680
+ return SUPPORTED_SDK_API_VERSIONS.includes(v);
681
+ }
682
+ var EMPTY2 = { version: 1, plugins: [] };
683
+ var LOCK_STALE_MS2 = 15e3;
684
+ var LOCK_ACQUIRE_TIMEOUT_MS2 = 2e4;
685
+ var LOCK_RETRY_MS2 = 25;
686
+ async function withFileLock(path, fn) {
687
+ const lockPath = `${path}.lock`;
688
+ await mkdir2(dirname3(path), { recursive: true });
689
+ const deadline = Date.now() + LOCK_ACQUIRE_TIMEOUT_MS2;
690
+ let held = false;
691
+ while (!held) {
692
+ try {
693
+ const fh = await open2(lockPath, "wx");
694
+ await fh.writeFile(`${String(process.pid)}
695
+ `);
696
+ await fh.close();
697
+ held = true;
698
+ } catch (err) {
699
+ if (err.code !== "EEXIST") throw err;
700
+ try {
701
+ const st = await stat3(lockPath);
702
+ if (Date.now() - st.mtimeMs > LOCK_STALE_MS2) {
703
+ await rm2(lockPath, { force: true });
704
+ continue;
705
+ }
706
+ } catch {
707
+ continue;
708
+ }
709
+ if (Date.now() >= deadline) break;
710
+ await delay2(LOCK_RETRY_MS2);
711
+ }
712
+ }
713
+ try {
714
+ return await fn();
715
+ } finally {
716
+ if (held) await rm2(lockPath, { force: true }).catch(() => {
717
+ });
718
+ }
719
+ }
720
+ function normalize2(raw) {
721
+ const parsed = raw;
722
+ if (!parsed || parsed.version !== 1 || !Array.isArray(parsed.plugins)) {
723
+ return { ...EMPTY2 };
724
+ }
725
+ return parsed;
726
+ }
727
+ function readPluginRegistrySync(path = PLUGINS_FILE) {
728
+ try {
729
+ if (!existsSync2(path)) return { ...EMPTY2 };
730
+ return normalize2(JSON.parse(readFileSync2(path, "utf8")));
731
+ } catch {
732
+ return { ...EMPTY2 };
733
+ }
734
+ }
735
+ async function readForWrite(path) {
736
+ let raw;
737
+ try {
738
+ raw = await readFile2(path, "utf8");
739
+ } catch (err) {
740
+ if (err.code === "ENOENT") return { ...EMPTY2 };
741
+ throw err;
742
+ }
743
+ let parsed;
744
+ try {
745
+ parsed = JSON.parse(raw);
746
+ } catch (err) {
747
+ throw new Error(
748
+ `refusing to modify a corrupt plugin registry at ${path} (${err.message}) \u2014 fix or delete the file and retry.`
749
+ );
750
+ }
751
+ const p = parsed;
752
+ if (!p || p.version !== 1 || !Array.isArray(p.plugins)) {
753
+ throw new Error(
754
+ `refusing to modify an unrecognized plugin registry at ${path} \u2014 fix or delete the file and retry.`
755
+ );
756
+ }
757
+ return p;
758
+ }
759
+ async function writeRegistry(file, path = PLUGINS_FILE) {
760
+ await mkdir2(dirname3(path), { recursive: true });
761
+ const tmp = `${path}.tmp.${String(process.pid)}.${String(Date.now())}`;
762
+ await writeFile2(tmp, JSON.stringify(file, null, 2) + "\n", "utf8");
763
+ await rename2(tmp, path);
764
+ }
765
+ async function addPluginRecord(record, path = PLUGINS_FILE) {
766
+ await withFileLock(path, async () => {
767
+ const file = await readForWrite(path);
768
+ const next = file.plugins.filter((p) => p.packageName !== record.packageName);
769
+ next.push(record);
770
+ await writeRegistry({ version: 1, plugins: next }, path);
771
+ });
772
+ }
773
+ async function removePluginRecord(nameOrPackage, path = PLUGINS_FILE) {
774
+ let removed = 0;
775
+ await withFileLock(path, async () => {
776
+ const file = await readForWrite(path);
777
+ const next = file.plugins.filter((p) => {
778
+ const match = p.packageName === nameOrPackage || p.providers.includes(nameOrPackage);
779
+ if (match) removed += 1;
780
+ return !match;
781
+ });
782
+ await writeRegistry({ version: 1, plugins: next }, path);
783
+ });
784
+ return removed;
785
+ }
786
+ function pluginProviderNames(path = PLUGINS_FILE) {
787
+ return readPluginRegistrySync(path).plugins.flatMap((p) => p.providers);
788
+ }
789
+ function pluginForProvider(providerName, path = PLUGINS_FILE) {
790
+ return readPluginRegistrySync(path).plugins.find((p) => p.providers.includes(providerName)) ?? null;
791
+ }
792
+ function carryPlaceholderContext(ctx) {
793
+ const out = {};
794
+ if (ctx.name) out.AGENTBOX_BOX_NAME = ctx.name;
795
+ if (ctx.id) out.AGENTBOX_BOX_ID = ctx.id;
796
+ if (ctx.kind) out.AGENTBOX_BOX_KIND = ctx.kind;
797
+ if (ctx.hostWorkspace) out.AGENTBOX_HOST_WORKSPACE = ctx.hostWorkspace;
798
+ if (ctx.projectRoot) out.AGENTBOX_PROJECT_ROOT = ctx.projectRoot;
799
+ return deriveBoxHost(out);
800
+ }
801
+ function wantsRender(e) {
802
+ return e.kind === "file" && (!!e.replaceEnvs || (e.replace?.length ?? 0) > 0);
803
+ }
804
+ async function renderCarryEntries(entries, ctx, onLog) {
805
+ if (!entries.some(wantsRender)) return entries;
806
+ const context = carryPlaceholderContext(ctx);
807
+ const stage = await mkdtemp(join4(tmpdir(), "agentbox-carry-render-"));
808
+ const out = [];
809
+ for (const [i, entry] of entries.entries()) {
810
+ if (!wantsRender(entry)) {
811
+ out.push(entry);
812
+ continue;
813
+ }
814
+ const content = await readFile3(entry.absSrc, "utf8");
815
+ const rendered = applyReplacements(content, {
816
+ env: entry.replaceEnvs,
817
+ rules: entry.replace,
818
+ context,
819
+ onWarn: (msg) => onLog?.(`carry: ${entry.rawSrc}: ${msg}`)
820
+ });
821
+ const tmp = join4(stage, `${String(i)}-${basename2(entry.absSrc)}`);
822
+ await writeFile3(tmp, rendered, "utf8");
823
+ out.push({ ...entry, absSrc: tmp, bytes: Buffer.byteLength(rendered) });
824
+ const what = [
825
+ ...entry.replaceEnvs ? ["env"] : [],
826
+ ...entry.replace?.length ? [`${String(entry.replace.length)} rule(s)`] : []
827
+ ].join("+");
828
+ onLog?.(`carry: rendered ${entry.rawSrc} (${what})`);
829
+ }
830
+ return out;
831
+ }
832
+ var CLAUDE_BOX_DIR = "/home/vscode/.claude";
833
+ var CODEX_BOX_DIR = "/home/vscode/.codex";
834
+ var OPENCODE_BOX_DIR = "/home/vscode/.local/share/opencode";
835
+ var AGENT_SYNC_SPECS = [
836
+ {
837
+ id: "claude",
838
+ aliases: ["claude-code"],
839
+ sessionName: "claude",
840
+ dockerVolume: "agentbox-claude-config",
841
+ staticPaths: [
842
+ {
843
+ hostHomeRel: [".claude"],
844
+ boxDir: CLAUDE_BOX_DIR,
845
+ // Static-stage excludes (single source of truth; consumed by
846
+ // `host-stage.ts:stageClaudeStaticForUpload`). `node_modules` drops
847
+ // host-platform binaries; `.credentials.json` ships separately; the
848
+ // rest is per-machine runtime/history state the in-box claude
849
+ // regenerates (`workflows` is seeded per-box at create time, not baked).
850
+ exclude: [
851
+ "node_modules",
852
+ ".credentials.json",
853
+ "projects",
854
+ "workflows",
855
+ "sessions",
856
+ "history.jsonl",
857
+ "file-history",
858
+ "shell-snapshots",
859
+ "backups",
860
+ "session-env",
861
+ "paste-cache",
862
+ "cache",
863
+ "telemetry",
864
+ "tasks",
865
+ "downloads",
866
+ "chrome",
867
+ "ide",
868
+ "debug",
869
+ "mcp-needs-auth-cache.json",
870
+ "stats-cache.json"
871
+ ]
872
+ }
873
+ ],
874
+ credential: {
875
+ boxRelPath: ".credentials.json",
876
+ boxAbsPath: `${CLAUDE_BOX_DIR}/.credentials.json`,
877
+ hostBackup: join5(STATE_DIR, "claude-credentials.json"),
878
+ cloudMountPath: "/home/vscode/.agentbox-creds/claude",
879
+ cloudSubpath: "claude/",
880
+ realShape: "claude-oauth"
881
+ },
882
+ forwardedEnvKeys: [
883
+ "ANTHROPIC_API_KEY",
884
+ "CLAUDE_CODE_OAUTH_TOKEN",
885
+ "CLAUDE_EFFORT",
886
+ "ANTHROPIC_MODEL"
887
+ ],
888
+ boxRunEnv: () => ({}),
889
+ caps: { resume: true, teleport: "full", activitySource: "scraper" }
890
+ },
891
+ {
892
+ id: "codex",
893
+ aliases: [],
894
+ sessionName: "codex",
895
+ dockerVolume: "agentbox-codex-config",
896
+ staticPaths: [
897
+ {
898
+ hostHomeRel: [".codex"],
899
+ boxDir: CODEX_BOX_DIR,
900
+ // Static-stage excludes (single source of truth; consumed by
901
+ // `host-stage.ts:stageCodexStaticForUpload`). `auth.json` ships
902
+ // separately; `state_*.sqlite*` is the resume-cwd index (rebuilt in-box);
903
+ // `packages`/`plugins/.plugin-appserver`/`computer-use` are heavy
904
+ // macOS-only artifacts; the rest is host-only session/log/cache state.
905
+ exclude: [
906
+ "auth.json",
907
+ "sessions",
908
+ "log",
909
+ "history.jsonl",
910
+ "hooks.json",
911
+ "state_*.sqlite*",
912
+ "logs_*.sqlite*",
913
+ "external_agent_session_imports.json",
914
+ "sqlite",
915
+ "cache",
916
+ "vendor_imports",
917
+ "tmp",
918
+ ".tmp",
919
+ ".codex-global-state.json",
920
+ ".codex-global-state.json.bak",
921
+ ".personality_migration",
922
+ "shell_snapshots",
923
+ "session_index.jsonl",
924
+ "models_cache.json",
925
+ "installation_id",
926
+ "version.json",
927
+ "packages",
928
+ "plugins/.plugin-appserver",
929
+ "computer-use",
930
+ "archived_sessions"
931
+ ]
932
+ }
933
+ ],
934
+ credential: {
935
+ boxRelPath: "auth.json",
936
+ boxAbsPath: `${CODEX_BOX_DIR}/auth.json`,
937
+ hostBackup: join5(STATE_DIR, "codex-credentials.json"),
938
+ cloudMountPath: "/home/vscode/.agentbox-creds/codex",
939
+ cloudSubpath: "codex/",
940
+ realShape: "nonempty-json"
941
+ },
942
+ forwardedEnvKeys: ["OPENAI_API_KEY"],
943
+ boxRunEnv: () => ({}),
944
+ caps: { resume: true, teleport: "full", activitySource: "scraper" }
945
+ },
946
+ {
947
+ id: "opencode",
948
+ aliases: [],
949
+ sessionName: "opencode",
950
+ dockerVolume: "agentbox-opencode-config",
951
+ // The three-XDG-dir layout as DATA: the generic seed loop reproduces
952
+ // `ensureOpencodeVolume`'s three-source rsync (data + config→config +
953
+ // state→.state/opencode newest-wins) with no tool-specific control flow.
954
+ staticPaths: [
955
+ {
956
+ hostHomeRel: [".local", "share", "opencode"],
957
+ boxDir: OPENCODE_BOX_DIR,
958
+ // Static-stage excludes for the data tree (single source of truth;
959
+ // consumed by `host-stage.ts:stageOpencodeStaticForUpload`). `auth.json`
960
+ // ships separately; the rest is host-only runtime state.
961
+ exclude: [
962
+ "auth.json",
963
+ "storage",
964
+ "log",
965
+ "project",
966
+ "cache",
967
+ "bin",
968
+ "repos",
969
+ "snapshot",
970
+ "config",
971
+ "opencode.db",
972
+ "opencode.db-shm",
973
+ "opencode.db-wal"
974
+ ]
975
+ },
976
+ { hostHomeRel: [".config", "opencode"], boxDir: OPENCODE_BOX_DIR, relocToSubpath: "config" },
977
+ {
978
+ hostHomeRel: [".local", "state", "opencode"],
979
+ boxDir: OPENCODE_BOX_DIR,
980
+ relocToSubpath: ".state/opencode",
981
+ update: true,
982
+ exclude: ["locks"]
983
+ }
984
+ ],
985
+ credential: {
986
+ boxRelPath: "auth.json",
987
+ boxAbsPath: `${OPENCODE_BOX_DIR}/auth.json`,
988
+ hostBackup: join5(STATE_DIR, "opencode-credentials.json"),
989
+ cloudMountPath: "/home/vscode/.agentbox-creds/opencode",
990
+ cloudSubpath: "opencode/",
991
+ realShape: "nonempty-json"
992
+ },
993
+ forwardedEnvKeys: [
994
+ "ANTHROPIC_API_KEY",
995
+ "OPENAI_API_KEY",
996
+ "OPENROUTER_API_KEY",
997
+ "GEMINI_API_KEY",
998
+ "GOOGLE_GENERATIVE_AI_API_KEY",
999
+ "GOOGLE_API_KEY",
1000
+ "GROQ_API_KEY"
1001
+ ],
1002
+ boxRunEnv: () => ({
1003
+ OPENCODE_CONFIG_DIR: `${OPENCODE_BOX_DIR}/config`,
1004
+ XDG_STATE_HOME: `${OPENCODE_BOX_DIR}/.state`
1005
+ }),
1006
+ caps: { resume: false, teleport: "stub", activitySource: "plugin" }
1007
+ }
1008
+ ];
1009
+ function resolveAgentSpec(name) {
1010
+ const spec = AGENT_SYNC_SPECS.find((s) => s.id === name || s.aliases.includes(name));
1011
+ if (!spec) throw new Error(`no agent sync spec for '${name}'`);
1012
+ return spec;
1013
+ }
1014
+ function makeSyncContext(init) {
1015
+ return {
1016
+ boxName: init.boxName,
1017
+ boxId: init.boxId,
1018
+ provider: init.provider,
1019
+ hostWorkspace: init.hostWorkspace,
1020
+ projectRoot: init.projectRoot ?? init.hostWorkspace,
1021
+ boxWorkspace: init.boxWorkspace ?? "/workspace",
1022
+ hostHome: init.hostHome ?? homedir4(),
1023
+ onLog: init.onLog ?? (() => {
1024
+ })
1025
+ };
1026
+ }
1027
+ var DEFAULT_ENV_PATTERNS = [
1028
+ ".env",
1029
+ ".env.*",
1030
+ ".envrc",
1031
+ ".dev.vars",
1032
+ "secrets.toml",
1033
+ "local.settings.json",
1034
+ "appsettings.*.json",
1035
+ "agentbox.yaml"
1036
+ ];
1037
+ var ENV_PRUNE_DIRS = [
1038
+ "node_modules",
1039
+ ".git",
1040
+ ".venv",
1041
+ "venv",
1042
+ "__pycache__",
1043
+ "dist",
1044
+ ".next",
1045
+ "build"
1046
+ ];
1047
+ function nameGroup(names) {
1048
+ const out = [];
1049
+ names.forEach((n, i) => {
1050
+ if (i > 0) out.push("-o");
1051
+ out.push("-name", n);
1052
+ });
1053
+ return out;
1054
+ }
1055
+ function buildHostEnvFindArgs(patterns) {
1056
+ return [
1057
+ "find",
1058
+ ".",
1059
+ "(",
1060
+ "-type",
1061
+ "d",
1062
+ "(",
1063
+ ...nameGroup(ENV_PRUNE_DIRS),
1064
+ ")",
1065
+ "-prune",
1066
+ ")",
1067
+ "-o",
1068
+ "(",
1069
+ "-type",
1070
+ "f",
1071
+ "(",
1072
+ ...nameGroup(patterns),
1073
+ ")",
1074
+ "-print0",
1075
+ ")"
1076
+ ];
1077
+ }
1078
+ async function findEnvFilesForTar(workspaceDir, patterns) {
1079
+ if (patterns.length === 0) return [];
1080
+ const found = await execa2("find", buildHostEnvFindArgs(patterns).slice(1), {
1081
+ cwd: workspaceDir,
1082
+ reject: false
1083
+ });
1084
+ if (found.exitCode !== 0) return [];
1085
+ return String(found.stdout).split("\0").filter((p) => p.length > 0);
1086
+ }
1087
+ async function scanHostEnvFiles(workspaceDir, patterns) {
1088
+ const raw = await findEnvFilesForTar(workspaceDir, patterns);
1089
+ return raw.map((p) => p.replace(/^\.\//, "")).filter((p) => p.length > 0);
1090
+ }
1091
+ async function pushEnvFiles(ctx, transport, patterns) {
1092
+ const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
1093
+ if (list.length === 0) return { copied: 0 };
1094
+ const stage = await mkdtemp2(join6(tmpdir2(), "agentbox-envfiles-"));
1095
+ const localTar = join6(stage, "envfiles.tar");
1096
+ try {
1097
+ const packed = await execa2(
1098
+ "tar",
1099
+ ["-C", ctx.hostWorkspace, "--null", "-T", "-", "-cf", localTar],
1100
+ { input: list.join("\0"), reject: false }
1101
+ );
1102
+ if (packed.exitCode !== 0) {
1103
+ ctx.onLog(`warning: env-file tar pack failed: ${String(packed.stderr).slice(0, 300)}`);
1104
+ return { copied: 0 };
1105
+ }
1106
+ try {
1107
+ await transport.applyTarball(localTar, ctx.boxWorkspace, { uid: 1e3 });
1108
+ } catch (err) {
1109
+ ctx.onLog(
1110
+ `warning: env-file copy into box failed: ${err instanceof Error ? err.message : String(err)}`
1111
+ );
1112
+ return { copied: 0 };
1113
+ }
1114
+ } finally {
1115
+ await rm3(stage, { recursive: true, force: true });
1116
+ }
1117
+ return { copied: list.length };
1118
+ }
1119
+ var BOX_HOME = "/home/vscode";
1120
+ function dirnameUnix(p) {
1121
+ const i = p.lastIndexOf("/");
1122
+ if (i <= 0) return "/";
1123
+ return p.slice(0, i);
1124
+ }
1125
+ function basenameUnix(p) {
1126
+ const i = p.lastIndexOf("/");
1127
+ return i < 0 ? p : p.slice(i + 1);
1128
+ }
1129
+ function planCarryEntry(entry) {
1130
+ if (entry.kind === "missing") return null;
1131
+ const boxDest = entry.absDest.startsWith("~/") ? `${BOX_HOME}/${entry.absDest.slice(2)}` : entry.absDest;
1132
+ const boxDestNoSlash = boxDest.endsWith("/") ? boxDest.slice(0, -1) : boxDest;
1133
+ const isDir = entry.kind === "dir";
1134
+ const parentDir = isDir ? boxDestNoSlash : dirnameUnix(boxDestNoSlash);
1135
+ const exclude = isDir ? entry.exclude ?? [] : [];
1136
+ const uid = entry.user ?? 1e3;
1137
+ const mode = entry.mode !== void 0 ? entry.mode.toString(8).padStart(4, "0") : void 0;
1138
+ const fileBase = isDir ? "" : basenameUnix(entry.absSrc);
1139
+ const destBase = isDir ? "" : basenameUnix(boxDest);
1140
+ const renameNeeded = !isDir && fileBase !== destBase;
1141
+ const parentChainNeeded = boxDest.startsWith(`${BOX_HOME}/`) && dirnameUnix(boxDest) !== BOX_HOME;
1142
+ return {
1143
+ boxDest,
1144
+ isDir,
1145
+ parentDir,
1146
+ exclude,
1147
+ uid,
1148
+ mode,
1149
+ fileBase,
1150
+ destBase,
1151
+ renameNeeded,
1152
+ parentChainNeeded
1153
+ };
1154
+ }
1155
+ async function pathExists(p) {
1156
+ try {
1157
+ await stat4(p);
1158
+ return true;
1159
+ } catch {
1160
+ return false;
1161
+ }
1162
+ }
1163
+ function encodeClaudeProjectsKey(absPath) {
1164
+ return absPath.replace(/[^a-zA-Z0-9]/g, "-");
1165
+ }
1166
+ var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
1167
+ async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir5()) {
1168
+ if (hostWorkspace.length === 0) return null;
1169
+ const memDir = join7(
1170
+ hostHome,
1171
+ ".claude",
1172
+ "projects",
1173
+ encodeClaudeProjectsKey(hostWorkspace),
1174
+ "memory"
1175
+ );
1176
+ if (!await pathExists(memDir)) return null;
1177
+ try {
1178
+ const entries = await readdir2(memDir);
1179
+ if (entries.length === 0) return null;
1180
+ } catch {
1181
+ return null;
1182
+ }
1183
+ return memDir;
1184
+ }
1185
+ function isUnder(parent, child) {
1186
+ const rel = relative(parent, child);
1187
+ return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
1188
+ }
1189
+ async function findUnsyncableSymlinks(root, reachableRoots) {
1190
+ const reachable = await Promise.all(
1191
+ reachableRoots.map(async (r) => {
1192
+ try {
1193
+ return await realpath2(r);
1194
+ } catch {
1195
+ return r;
1196
+ }
1197
+ })
1198
+ );
1199
+ const unsyncable = [];
1200
+ const onPath = /* @__PURE__ */ new Set();
1201
+ async function walk(realDir, virtualDir) {
1202
+ if (onPath.has(realDir)) return;
1203
+ onPath.add(realDir);
1204
+ try {
1205
+ let entries;
1206
+ try {
1207
+ entries = await readdir3(realDir, { withFileTypes: true });
1208
+ } catch {
1209
+ return;
1210
+ }
1211
+ for (const ent of entries) {
1212
+ const realFull = join8(realDir, ent.name);
1213
+ const virtualFull = virtualDir ? join8(virtualDir, ent.name) : ent.name;
1214
+ if (ent.isSymbolicLink()) {
1215
+ let real;
1216
+ try {
1217
+ real = await realpath2(realFull);
1218
+ } catch {
1219
+ unsyncable.push(virtualFull);
1220
+ continue;
1221
+ }
1222
+ if (!reachable.some((r) => isUnder(r, real))) {
1223
+ unsyncable.push(virtualFull);
1224
+ continue;
1225
+ }
1226
+ const st = await stat5(real).catch(() => null);
1227
+ if (st?.isDirectory()) await walk(real, virtualFull);
1228
+ } else if (ent.isDirectory()) {
1229
+ await walk(realFull, virtualFull);
1230
+ }
1231
+ }
1232
+ } finally {
1233
+ onPath.delete(realDir);
1234
+ }
1235
+ }
1236
+ await walk(root, "");
1237
+ return unsyncable;
1238
+ }
1239
+ async function pathExists2(p) {
1240
+ try {
1241
+ await stat6(p);
1242
+ return true;
1243
+ } catch {
1244
+ return false;
1245
+ }
1246
+ }
1247
+ async function seedAgentsVolume(args) {
1248
+ const seed = args.transport.seedVolumeFromHost;
1249
+ if (!seed) throw new Error("seedAgentsVolume requires a transport with seedVolumeFromHost");
1250
+ const willSync = args.syncFromHost && await pathExists2(args.hostAgents);
1251
+ if (!willSync) {
1252
+ try {
1253
+ await seed.call(args.transport, args.volume, []);
1254
+ } catch (err) {
1255
+ args.onLog?.(
1256
+ `skills: volume writable-chown failed (ignored): ${err instanceof Error ? err.message : String(err)}`
1257
+ );
1258
+ }
1259
+ return { synced: false };
1260
+ }
1261
+ const excludes = (await findUnsyncableSymlinks(args.hostAgents, [args.hostAgents])).map(
1262
+ (rel) => `/${rel}`
1263
+ );
1264
+ await seed.call(args.transport, args.volume, [
1265
+ { hostDir: args.hostAgents, destSubpath: "", exclude: excludes, copyUnsafeLinks: true }
1266
+ ]);
1267
+ if (excludes.length > 0) {
1268
+ args.onLog?.(`skills: excluded ${String(excludes.length)} unsyncable symlink(s) from ~/.agents`);
1269
+ }
1270
+ return { synced: true };
1271
+ }
1272
+ var SEED_MARKER = ".agentbox-seeded-at";
1273
+ var CLAUDE_HOST_BACKUP = resolveAgentSpec("claude").credential.hostBackup;
1274
+ function isRealAgentCredential(agent, text) {
1275
+ let parsed;
1276
+ try {
1277
+ parsed = JSON.parse(text);
1278
+ } catch {
1279
+ return false;
1280
+ }
1281
+ if (typeof parsed !== "object" || parsed === null) return false;
1282
+ const spec = AGENT_SYNC_SPECS.find((s) => s.id === agent);
1283
+ if (spec?.credential.realShape === "claude-oauth") {
1284
+ const rt = parsed.claudeAiOauth?.refreshToken;
1285
+ return typeof rt === "string" && rt.length > 0;
1286
+ }
1287
+ return Object.keys(parsed).length > 0;
1288
+ }
1289
+ async function hostClaudeBackupExpired(path = CLAUDE_HOST_BACKUP, now = Date.now()) {
1290
+ try {
1291
+ const parsed = JSON.parse(await readFile4(path, "utf8"));
1292
+ const exp = parsed?.claudeAiOauth?.expiresAt;
1293
+ return typeof exp === "number" && Number.isFinite(exp) && exp < now;
1294
+ } catch {
1295
+ return false;
1296
+ }
1297
+ }
1298
+ async function hostBackupHasCredentials(path = CLAUDE_HOST_BACKUP) {
1299
+ try {
1300
+ const parsed = JSON.parse(await readFile4(path, "utf8"));
1301
+ const rt = parsed?.claudeAiOauth?.refreshToken;
1302
+ return typeof rt === "string" && rt.length > 0;
1303
+ } catch {
1304
+ return false;
1305
+ }
1306
+ }
1307
+ async function extractCredentials(transport, opts = {}) {
1308
+ const log = opts.onLog ?? (() => {
1309
+ });
1310
+ const extracted = [];
1311
+ for (const spec of AGENT_SYNC_SPECS) {
1312
+ const hostBackup = opts.backups?.[spec.id] ?? spec.credential.hostBackup;
1313
+ try {
1314
+ const text = await transport.readText(spec.credential.boxAbsPath);
1315
+ if (!text || !isRealAgentCredential(spec.id, text)) continue;
1316
+ await mkdir3(dirname4(hostBackup), { recursive: true });
1317
+ await writeFile4(hostBackup, text, { mode: 384 });
1318
+ await chmod(hostBackup, 384).catch(() => {
1319
+ });
1320
+ extracted.push(spec.id);
1321
+ log(`extracted ${spec.id} login from box to ${hostBackup}`);
1322
+ } catch (err) {
1323
+ log(
1324
+ `WARN: ${spec.id} credential extract failed (${err instanceof Error ? err.message : String(err)}) \u2014 skipping`
1325
+ );
1326
+ }
1327
+ }
1328
+ return extracted;
1329
+ }
1330
+ var NON_REGULAR_TOKEN = "-";
1331
+ function classifyUntrackedOverlay(boxToken, hostHash) {
1332
+ if (boxToken === void 0) return "copy";
1333
+ if (boxToken === NON_REGULAR_TOKEN) return "conflict";
1334
+ return boxToken === hostHash ? "identical" : "conflict";
1335
+ }
1336
+ function splitNul(s) {
1337
+ return s.split("\0").filter((p) => p.length > 0);
1338
+ }
1339
+ async function unmergedPaths(ports, ct) {
1340
+ const r = await ports.boxGit(ct, ["diff", "--name-only", "--diff-filter=U", "-z"]);
1341
+ return r.exitCode === 0 ? splitNul(r.stdout) : [];
1342
+ }
1343
+ async function resyncWorkspace(worktrees, ports, onLog) {
1344
+ const log = onLog ?? (() => {
1345
+ });
1346
+ const results = [];
1347
+ for (const w of worktrees) {
1348
+ const ct = w.containerPath;
1349
+ const hostMain = w.hostMainRepo;
1350
+ const boxBranch = w.branch;
1351
+ const res = { containerPath: ct, mergeConflicts: [], overlaySkipped: [] };
1352
+ const hostRef = await ports.resolveHostRef(hostMain);
1353
+ if (!hostRef) {
1354
+ log(`resync: ${ct}: could not resolve host ref; skipping`);
1355
+ results.push(res);
1356
+ continue;
1357
+ }
1358
+ const hostStashSha = await ports.createHostStash(hostMain);
1359
+ const hostUntracked = await ports.listHostUntracked(hostMain);
1360
+ if (hostRef !== boxBranch) {
1361
+ const status = await ports.boxGit(ct, ["status", "--porcelain"]);
1362
+ const boxDirty = status.stdout.split("\n").some((line) => line.length > 0 && !line.startsWith("??"));
1363
+ let boxStashed = false;
1364
+ if (boxDirty) {
1365
+ const push = await ports.boxGit(ct, ["stash", "push", "-m", "agentbox-resync"]);
1366
+ boxStashed = push.exitCode === 0;
1367
+ }
1368
+ const newCommits = await ports.boxGit(ct, ["rev-list", "--count", `${boxBranch}..${hostRef}`]);
1369
+ const n = newCommits.exitCode === 0 ? newCommits.stdout.trim() : "?";
1370
+ const merge = await ports.boxGit(ct, ["merge", "--no-commit", hostRef]);
1371
+ const mergeInProgress = (await ports.boxGit(ct, ["rev-parse", "-q", "--verify", "MERGE_HEAD"])).exitCode === 0;
1372
+ const conflicts = await unmergedPaths(ports, ct);
1373
+ if (conflicts.length > 0) {
1374
+ await ports.boxGit(ct, ["checkout", "--ours", "--", ...conflicts]);
1375
+ await ports.boxGit(ct, ["add", "--", ...conflicts]);
1376
+ res.mergeConflicts.push(...conflicts);
1377
+ }
1378
+ if (mergeInProgress) {
1379
+ await ports.boxGit(ct, [
1380
+ "-c",
1381
+ "user.name=agentbox",
1382
+ "-c",
1383
+ "user.email=agentbox@users.noreply.github.com",
1384
+ "commit",
1385
+ "--no-edit"
1386
+ ]);
1387
+ log(
1388
+ `resync: ${ct}: merged ${n} new host commit(s) from ${hostRef}` + (conflicts.length > 0 ? ` (${String(conflicts.length)} conflict(s) kept box version)` : "")
1389
+ );
1390
+ } else if (merge.exitCode === 0) {
1391
+ log(`resync: ${ct}: ${n === "0" ? "already up to date" : `fast-forwarded to ${hostRef}`}`);
1392
+ } else {
1393
+ await ports.boxGit(ct, ["merge", "--abort"]);
1394
+ log(`resync: ${ct}: merge skipped (${(merge.stderr || merge.stdout).trim().split("\n")[0]})`);
1395
+ }
1396
+ if (boxStashed) {
1397
+ const pop = await ports.boxGit(ct, ["stash", "pop"]);
1398
+ if (pop.exitCode !== 0) {
1399
+ const popConflicts = await unmergedPaths(ports, ct);
1400
+ for (const p of popConflicts) {
1401
+ await ports.boxGit(ct, ["checkout", "--theirs", "--", p]);
1402
+ await ports.boxGit(ct, ["reset", "-q", "--", p]);
1403
+ }
1404
+ await ports.boxGit(ct, ["stash", "drop"]);
1405
+ }
1406
+ }
1407
+ }
1408
+ if (hostStashSha) {
1409
+ const apply = await ports.boxGit(ct, ["stash", "apply", hostStashSha]);
1410
+ if (apply.exitCode !== 0) {
1411
+ const conflicts = await unmergedPaths(ports, ct);
1412
+ for (const p of conflicts) {
1413
+ await ports.boxGit(ct, ["checkout", "--ours", "--", p]);
1414
+ await ports.boxGit(ct, ["reset", "-q", "--", p]);
1415
+ }
1416
+ if (conflicts.length > 0) res.overlaySkipped.push(...conflicts);
1417
+ }
1418
+ }
1419
+ if (hostUntracked.length > 0) {
1420
+ const boxTokens = await ports.probeUntrackedTokens(ct, hostUntracked);
1421
+ const toCopy = [];
1422
+ let identical = 0;
1423
+ for (const p of hostUntracked) {
1424
+ const boxToken = boxTokens.get(p);
1425
+ let hostHash = "";
1426
+ if (boxToken !== void 0 && boxToken !== NON_REGULAR_TOKEN) {
1427
+ try {
1428
+ hostHash = await ports.hashHostFile(hostMain, p);
1429
+ } catch {
1430
+ identical++;
1431
+ continue;
1432
+ }
1433
+ }
1434
+ const verdict = classifyUntrackedOverlay(boxToken, hostHash);
1435
+ if (verdict === "copy") toCopy.push(p);
1436
+ else if (verdict === "conflict") res.overlaySkipped.push(p);
1437
+ else identical++;
1438
+ }
1439
+ if (identical > 0) {
1440
+ log(`resync: ${ct}: ${String(identical)} untracked host file(s) already identical in box (no-op)`);
1441
+ }
1442
+ if (toCopy.length > 0) {
1443
+ const tar = await ports.packHostFiles(hostMain, toCopy);
1444
+ if (tar) {
1445
+ await ports.applyTarToBox(ct, tar);
1446
+ log(`resync: ${ct}: copied ${String(toCopy.length)} untracked host file(s)`);
1447
+ }
1448
+ }
1449
+ }
1450
+ results.push(res);
1451
+ }
1452
+ return results;
1453
+ }
1454
+ function makeHostGitPorts() {
1455
+ return {
1456
+ async resolveHostRef(hostMain) {
1457
+ const hostBranchProbe = await execa3(
1458
+ "git",
1459
+ ["-C", hostMain, "symbolic-ref", "--short", "-q", "HEAD"],
1460
+ { reject: false }
1461
+ );
1462
+ const hostRef = hostBranchProbe.exitCode === 0 && hostBranchProbe.stdout.trim() ? hostBranchProbe.stdout.trim() : (await execa3("git", ["-C", hostMain, "rev-parse", "HEAD"], { reject: false })).stdout.trim();
1463
+ return hostRef || null;
1464
+ },
1465
+ async createHostStash(hostMain) {
1466
+ const stash = await execa3("git", ["-C", hostMain, "stash", "create"], { reject: false });
1467
+ return stash.exitCode === 0 ? stash.stdout.trim() || null : null;
1468
+ },
1469
+ async listHostUntracked(hostMain) {
1470
+ const untracked = await execa3(
1471
+ "git",
1472
+ ["-C", hostMain, "ls-files", "--others", "--exclude-standard", "-z"],
1473
+ { reject: false }
1474
+ );
1475
+ return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
1476
+ },
1477
+ async hashHostFile(hostMain, relPath) {
1478
+ return createHash("sha256").update(await readFile5(join9(hostMain, relPath))).digest("hex");
1479
+ },
1480
+ async packHostFiles(hostMain, relPaths) {
1481
+ const tarOut = await execa3("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
1482
+ input: relPaths.join("\0"),
1483
+ encoding: "buffer",
1484
+ reject: false
1485
+ });
1486
+ return tarOut.exitCode === 0 ? tarOut.stdout : null;
1487
+ }
1488
+ };
1489
+ }
1490
+ var BOX_WORKFLOWS_DIR = "/home/vscode/.claude/workflows";
1491
+ var BOX_DYNAMIC_SYNC_MANIFEST = "/home/vscode/.agentbox/dynamic-sync.json";
1492
+ var BOX_MEMORY_DIR = `${BOX_CLAUDE_PROJECT_DIR}/memory`;
1493
+ async function pathExists3(p) {
1494
+ try {
1495
+ await stat7(p);
1496
+ return true;
1497
+ } catch {
1498
+ return false;
1499
+ }
1500
+ }
1501
+ async function walkFiles(root, prefix = "") {
1502
+ let entries;
1503
+ try {
1504
+ entries = await readdir4(root, { withFileTypes: true });
1505
+ } catch {
1506
+ return [];
1507
+ }
1508
+ const out = [];
1509
+ for (const ent of entries) {
1510
+ const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
1511
+ const full = join10(root, ent.name);
1512
+ if (ent.isDirectory()) {
1513
+ out.push(...await walkFiles(full, rel));
1514
+ } else if (ent.isFile()) {
1515
+ out.push(rel);
1516
+ } else if (ent.isSymbolicLink()) {
1517
+ try {
1518
+ const s = await stat7(full);
1519
+ if (s.isFile()) out.push(rel);
1520
+ } catch {
1521
+ }
1522
+ }
1523
+ }
1524
+ return out;
1525
+ }
1526
+ async function hashFile(absPath) {
1527
+ const buf = await readFile6(absPath);
1528
+ return createHash2("sha256").update(buf).digest("hex");
1529
+ }
1530
+ async function buildHostSet(name, hostDir, boxDst) {
1531
+ if (hostDir === null) return { dst: boxDst, files: {}, hostDir: null };
1532
+ const rels = await walkFiles(hostDir);
1533
+ const files = {};
1534
+ for (const rel of rels) {
1535
+ files[rel] = await hashFile(join10(hostDir, rel));
1536
+ }
1537
+ return { dst: boxDst, files, hostDir };
1538
+ }
1539
+ async function buildHostSyncManifest(workspacePath, hostHome = homedir6()) {
1540
+ const workflowsDir = join10(hostHome, ".claude", "workflows");
1541
+ const workflowsHost = await pathExists3(workflowsDir) ? workflowsDir : null;
1542
+ const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
1543
+ const [workflows, memory] = await Promise.all([
1544
+ buildHostSet("workflows", workflowsHost, BOX_WORKFLOWS_DIR),
1545
+ buildHostSet("memory", memoryHost, BOX_MEMORY_DIR)
1546
+ ]);
1547
+ return { sets: { workflows, memory } };
1548
+ }
1549
+ var SET_NAMES = ["workflows", "memory"];
1550
+ function computeSyncDelta(host, box) {
1551
+ const uploads = [];
1552
+ const deletions = [];
1553
+ const nextSets = {};
1554
+ for (const name of SET_NAMES) {
1555
+ const hostSet = host.sets[name];
1556
+ const boxFiles = box?.sets?.[name]?.files ?? {};
1557
+ for (const [rel, hash] of Object.entries(hostSet.files)) {
1558
+ if (boxFiles[rel] !== hash) {
1559
+ uploads.push({
1560
+ set: name,
1561
+ rel,
1562
+ absSrc: join10(hostSet.hostDir, rel),
1563
+ dst: `${hostSet.dst}/${rel}`
1564
+ });
1565
+ }
1566
+ }
1567
+ for (const rel of Object.keys(boxFiles)) {
1568
+ if (!(rel in hostSet.files)) {
1569
+ deletions.push({ set: name, rel, dst: `${hostSet.dst}/${rel}` });
1570
+ }
1571
+ }
1572
+ nextSets[name] = { dst: hostSet.dst, files: hostSet.files };
1573
+ }
1574
+ return { uploads, deletions, nextManifest: { version: 1, sets: nextSets } };
1575
+ }
1576
+ async function stageDynamicSyncTarball(uploads) {
1577
+ if (uploads.length === 0) {
1578
+ return { tarballPath: null, cleanup: async () => {
1579
+ } };
1580
+ }
1581
+ const stageDir = await mkdtemp3(join10(tmpdir3(), "agentbox-dynsync-stage-"));
1582
+ let tarballPath = null;
1583
+ try {
1584
+ for (const up of uploads) {
1585
+ const target = join10(stageDir, up.set, up.rel);
1586
+ await mkdir4(dirname5(target), { recursive: true });
1587
+ await copyFile(up.absSrc, target);
1588
+ }
1589
+ tarballPath = join10(tmpdir3(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
1590
+ await execa4("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
1591
+ env: { ...process.env, COPYFILE_DISABLE: "1" }
1592
+ });
1593
+ const tp = tarballPath;
1594
+ return {
1595
+ tarballPath: tp,
1596
+ cleanup: async () => {
1597
+ await rm4(stageDir, { recursive: true, force: true });
1598
+ await rm4(tp, { force: true });
1599
+ }
1600
+ };
1601
+ } catch (err) {
1602
+ await rm4(stageDir, { recursive: true, force: true });
1603
+ if (tarballPath) await rm4(tarballPath, { force: true });
1604
+ throw err;
1605
+ }
1606
+ }
1607
+ function isHostPathHookCommand(command, hostHome) {
1608
+ if (typeof command !== "string" || command.length === 0) return false;
1609
+ if (hostHome.length === 0) return false;
1610
+ return command.includes(hostHome + "/");
1611
+ }
1612
+ function filterHostHooks(data, hostHome) {
1613
+ const clone = structuredClone(data);
1614
+ const removedCommands = [];
1615
+ if (clone === null || typeof clone !== "object" || Array.isArray(clone)) {
1616
+ return { data: clone, removedCommands };
1617
+ }
1618
+ const top = clone;
1619
+ const hooksRoot = top.hooks;
1620
+ if (hooksRoot === null || typeof hooksRoot !== "object" || Array.isArray(hooksRoot)) {
1621
+ return { data: clone, removedCommands };
1622
+ }
1623
+ for (const triggerName of Object.keys(hooksRoot)) {
1624
+ const triggerValue = hooksRoot[triggerName];
1625
+ if (!Array.isArray(triggerValue)) continue;
1626
+ for (const entry of triggerValue) {
1627
+ if (entry === null || typeof entry !== "object") continue;
1628
+ const matcher = entry;
1629
+ const inner = matcher.hooks;
1630
+ if (!Array.isArray(inner)) continue;
1631
+ for (let i = inner.length - 1; i >= 0; i--) {
1632
+ const leaf = inner[i];
1633
+ if (leaf === null || typeof leaf !== "object") continue;
1634
+ if (leaf.type === "command" && typeof leaf.command === "string" && isHostPathHookCommand(leaf.command, hostHome)) {
1635
+ removedCommands.push(leaf.command);
1636
+ inner.splice(i, 1);
1637
+ }
1638
+ }
1639
+ }
1640
+ }
1641
+ return { data: clone, removedCommands };
1642
+ }
1643
+ function trustWorkspace(data, workspacePath) {
1644
+ const clone = structuredClone(data);
1645
+ if (clone === null || typeof clone !== "object" || Array.isArray(clone)) {
1646
+ return { data: clone, trusted: false };
1647
+ }
1648
+ if (workspacePath.length === 0) return { data: clone, trusted: false };
1649
+ const obj = clone;
1650
+ if (obj.projects === null || typeof obj.projects !== "object" || Array.isArray(obj.projects)) {
1651
+ obj.projects = {};
1652
+ }
1653
+ const projects = obj.projects;
1654
+ const existing = projects[workspacePath];
1655
+ const entry = existing !== null && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
1656
+ if (entry.hasTrustDialogAccepted === true) {
1657
+ projects[workspacePath] = entry;
1658
+ return { data: clone, trusted: false };
1659
+ }
1660
+ entry.hasTrustDialogAccepted = true;
1661
+ projects[workspacePath] = entry;
1662
+ return { data: clone, trusted: true };
1663
+ }
1664
+ function addProjectAlias(data, fromPath, toPath) {
1665
+ const clone = structuredClone(data);
1666
+ if (clone === null || typeof clone !== "object" || Array.isArray(clone)) {
1667
+ return { data: clone, aliased: false };
1668
+ }
1669
+ if (fromPath === toPath || fromPath.length === 0 || toPath.length === 0) {
1670
+ return { data: clone, aliased: false };
1671
+ }
1672
+ const obj = clone;
1673
+ const projects = obj.projects;
1674
+ if (projects === null || typeof projects !== "object" || Array.isArray(projects)) {
1675
+ return { data: clone, aliased: false };
1676
+ }
1677
+ const projectsMap = projects;
1678
+ const src = projectsMap[fromPath];
1679
+ if (src === null || typeof src !== "object" || Array.isArray(src)) {
1680
+ return { data: clone, aliased: false };
1681
+ }
1682
+ const existing = projectsMap[toPath];
1683
+ if (existing !== null && typeof existing === "object" && !Array.isArray(existing)) {
1684
+ projectsMap[toPath] = { ...existing, ...src };
1685
+ } else {
1686
+ projectsMap[toPath] = structuredClone(src);
1687
+ }
1688
+ return { data: clone, aliased: true };
1689
+ }
1690
+ function setInstallMethodNative(data) {
1691
+ const clone = structuredClone(data);
1692
+ if (clone === null || typeof clone !== "object" || Array.isArray(clone)) {
1693
+ return { data: clone, applied: false };
1694
+ }
1695
+ const obj = clone;
1696
+ const changed = obj.installMethod !== "native" || obj.autoUpdates !== false || obj.autoUpdatesProtectedForNative !== true;
1697
+ obj.installMethod = "native";
1698
+ obj.autoUpdates = false;
1699
+ obj.autoUpdatesProtectedForNative = true;
1700
+ return { data: clone, applied: changed };
1701
+ }
1702
+ function isHostOnlyPath(cmd, hostHome) {
1703
+ if (typeof cmd !== "string" || cmd.length === 0) return false;
1704
+ if (!cmd.startsWith("/")) return false;
1705
+ const hostOnlyRoots = [
1706
+ hostHome.endsWith("/") ? hostHome : `${hostHome}/`,
1707
+ "/Applications/",
1708
+ "/opt/homebrew/",
1709
+ "/Library/",
1710
+ "/System/",
1711
+ "/private/",
1712
+ "/Users/"
1713
+ ];
1714
+ return hostOnlyRoots.some((root) => cmd.startsWith(root));
1715
+ }
1716
+ function isRecord(v) {
1717
+ return typeof v === "object" && v !== null && !Array.isArray(v);
1718
+ }
1719
+ var BOX_WORKSPACE2 = "/workspace";
1720
+ var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
1721
+ trust_level = "trusted"
1722
+ `;
1723
+ function sanitizeCodexConfigForBox(tomlText, hostHome = homedir7()) {
1724
+ const cfg = parse(tomlText);
1725
+ let changed = false;
1726
+ if (isRecord(cfg["mcp_servers"])) {
1727
+ const servers = cfg["mcp_servers"];
1728
+ for (const [name, def] of Object.entries(servers)) {
1729
+ if (isRecord(def) && isHostOnlyPath(def["command"], hostHome)) {
1730
+ delete servers[name];
1731
+ changed = true;
1732
+ }
1733
+ }
1734
+ }
1735
+ const notify = cfg["notify"];
1736
+ if (Array.isArray(notify) && isHostOnlyPath(notify[0], hostHome)) {
1737
+ delete cfg["notify"];
1738
+ changed = true;
1739
+ }
1740
+ const droppedMarkets = /* @__PURE__ */ new Set();
1741
+ if (isRecord(cfg["marketplaces"])) {
1742
+ const markets = cfg["marketplaces"];
1743
+ for (const [name, def] of Object.entries(markets)) {
1744
+ if (isRecord(def) && def["source_type"] === "local" && isHostOnlyPath(def["source"], hostHome)) {
1745
+ delete markets[name];
1746
+ droppedMarkets.add(name);
1747
+ changed = true;
1748
+ }
1749
+ }
1750
+ }
1751
+ if (droppedMarkets.size > 0 && isRecord(cfg["plugins"])) {
1752
+ const plugins = cfg["plugins"];
1753
+ for (const key of Object.keys(plugins)) {
1754
+ const marketplace = key.split("@")[1];
1755
+ if (marketplace !== void 0 && droppedMarkets.has(marketplace)) {
1756
+ delete plugins[key];
1757
+ changed = true;
1758
+ }
1759
+ }
1760
+ }
1761
+ if (!isRecord(cfg["projects"])) cfg["projects"] = {};
1762
+ const projects = cfg["projects"];
1763
+ const wsEntry = isRecord(projects[BOX_WORKSPACE2]) ? projects[BOX_WORKSPACE2] : {};
1764
+ if (wsEntry["trust_level"] !== "trusted") {
1765
+ wsEntry["trust_level"] = "trusted";
1766
+ projects[BOX_WORKSPACE2] = wsEntry;
1767
+ changed = true;
1768
+ }
1769
+ return { text: changed ? stringify(cfg) : tomlText, changed };
1770
+ }
1771
+ var CREDENTIALS_BACKUP_FILE = resolveAgentSpec("claude").credential.hostBackup;
1772
+ var CLOUD_WORKSPACE = "/workspace";
1773
+ async function pathExists4(p) {
1774
+ try {
1775
+ await stat8(p);
1776
+ return true;
1777
+ } catch {
1778
+ return false;
1779
+ }
1780
+ }
1781
+ async function findBrokenSymlinks(root) {
1782
+ const broken = [];
1783
+ async function walk(dir) {
1784
+ let entries;
1785
+ try {
1786
+ entries = await readdir5(dir, { withFileTypes: true });
1787
+ } catch {
1788
+ return;
1789
+ }
1790
+ for (const ent of entries) {
1791
+ const full = join11(dir, ent.name);
1792
+ if (ent.isSymbolicLink()) {
1793
+ try {
1794
+ await stat8(full);
1795
+ } catch {
1796
+ broken.push(relative2(root, full));
1797
+ }
1798
+ } else if (ent.isDirectory()) {
1799
+ await walk(full);
1800
+ }
1801
+ }
1802
+ }
1803
+ await walk(root);
1804
+ return broken;
1805
+ }
1806
+ async function mkStageDir(prefix) {
1807
+ return mkdtemp4(join11(tmpdir4(), `agentbox-${prefix}-stage-`));
1808
+ }
1809
+ function emptyResult(warnings = []) {
1810
+ return { tarballPath: null, cleanup: async () => {
1811
+ }, warnings };
1812
+ }
1813
+ async function tarballFromDir(stageDir, agent) {
1814
+ const tarballPath = join11(tmpdir4(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
1815
+ await execa5("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
1816
+ env: { ...process.env, COPYFILE_DISABLE: "1" }
1817
+ });
1818
+ return tarballPath;
1819
+ }
1820
+ function makeCleanup(paths) {
1821
+ return async () => {
1822
+ for (const p of paths) {
1823
+ await rm5(p, { recursive: true, force: true });
1824
+ }
1825
+ };
1826
+ }
1827
+ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
1828
+ const stageDir = await mkStageDir(agent);
1829
+ let tarballPath = null;
1830
+ try {
1831
+ await copyFile2(sourcePath, join11(stageDir, tarballEntryName));
1832
+ tarballPath = await tarballFromDir(stageDir, agent);
1833
+ return {
1834
+ tarballPath,
1835
+ cleanup: makeCleanup([stageDir, tarballPath]),
1836
+ warnings: []
1837
+ };
1838
+ } catch (err) {
1839
+ await rm5(stageDir, { recursive: true, force: true });
1840
+ if (tarballPath) await rm5(tarballPath, { force: true });
1841
+ throw err;
1842
+ }
1843
+ }
1844
+ var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
1845
+ async function buildBoxClaudeJsonFromHost(opts) {
1846
+ const { hostHome, hostWorkspace } = opts;
1847
+ const hostClaudeJson = join11(hostHome, ".claude.json");
1848
+ let working;
1849
+ if (await pathExists4(hostClaudeJson)) {
1850
+ try {
1851
+ working = JSON.parse(await readFile7(hostClaudeJson, "utf8"));
1852
+ } catch {
1853
+ working = null;
1854
+ }
1855
+ }
1856
+ if (working === void 0 || working === null) {
1857
+ working = {
1858
+ installMethod: "native",
1859
+ autoUpdates: false,
1860
+ autoUpdatesProtectedForNative: true,
1861
+ // Pre-accept onboarding so the in-box Claude doesn't show the theme
1862
+ // picker on first run. AgentBox installing implies the user has
1863
+ // already used Claude Code on the host.
1864
+ hasCompletedOnboarding: true,
1865
+ projects: { [CLOUD_WORKSPACE]: { hasTrustDialogAccepted: true } }
1866
+ };
1867
+ } else {
1868
+ working = filterHostHooks(working, hostHome).data;
1869
+ working = setInstallMethodNative(working).data;
1870
+ if (hostWorkspace) {
1871
+ working = addProjectAlias(working, hostWorkspace, CLOUD_WORKSPACE).data;
1872
+ }
1873
+ working = trustWorkspace(working, CLOUD_WORKSPACE).data;
1874
+ if (typeof working === "object" && working !== null) {
1875
+ const w = working;
1876
+ if (w["hasCompletedOnboarding"] !== true) w["hasCompletedOnboarding"] = true;
1877
+ }
1878
+ }
1879
+ return working;
1880
+ }
1881
+ async function stageClaudeJsonOnlyForUpload(opts = {}) {
1882
+ const hostHome = opts.hostHome ?? homedir8();
1883
+ const stageDir = await mkStageDir("claude-json-only");
1884
+ let tarballPath = null;
1885
+ try {
1886
+ const claudeJson = await buildBoxClaudeJsonFromHost({
1887
+ hostHome,
1888
+ hostWorkspace: opts.hostWorkspace
1889
+ });
1890
+ await writeFile5(join11(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
1891
+ tarballPath = await tarballFromDir(stageDir, "claude-json-only");
1892
+ return {
1893
+ tarballPath,
1894
+ cleanup: makeCleanup([stageDir, tarballPath]),
1895
+ warnings: []
1896
+ };
1897
+ } catch (err) {
1898
+ await rm5(stageDir, { recursive: true, force: true });
1899
+ if (tarballPath) await rm5(tarballPath, { force: true });
1900
+ throw err;
1901
+ }
1902
+ }
1903
+ async function stageClaudeStaticForUpload(opts = {}) {
1904
+ const hostHome = opts.hostHome ?? homedir8();
1905
+ const hostClaude = join11(hostHome, ".claude");
1906
+ if (!await pathExists4(hostClaude)) return emptyResult();
1907
+ const stageDir = await mkStageDir("claude-static");
1908
+ let tarballPath = null;
1909
+ try {
1910
+ const broken = await findBrokenSymlinks(hostClaude);
1911
+ const excludes = [
1912
+ ...CLAUDE_STATIC_EXCLUDES.map((p) => `--exclude=${p}`),
1913
+ ...broken.map((r) => `--exclude=/${r}`)
1914
+ ];
1915
+ await execa5("rsync", [
1916
+ "-a",
1917
+ "--copy-unsafe-links",
1918
+ ...excludes,
1919
+ `${hostClaude}/`,
1920
+ `${stageDir}/`
1921
+ ]);
1922
+ const settingsPath = join11(stageDir, "settings.json");
1923
+ if (await pathExists4(settingsPath)) {
1924
+ try {
1925
+ const parsed = JSON.parse(await readFile7(settingsPath, "utf8"));
1926
+ const filtered = filterHostHooks(parsed, hostHome);
1927
+ if (filtered.removedCommands.length > 0) {
1928
+ await writeFile5(settingsPath, JSON.stringify(filtered.data, null, 2));
1929
+ }
1930
+ } catch {
1931
+ }
1932
+ }
1933
+ const claudeJson = await buildBoxClaudeJsonFromHost({
1934
+ hostHome,
1935
+ hostWorkspace: opts.hostWorkspace
1936
+ });
1937
+ await writeFile5(join11(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
1938
+ const pluginsDir = join11(stageDir, "plugins");
1939
+ if (await pathExists4(pluginsDir)) {
1940
+ try {
1941
+ const entries = await readdir5(pluginsDir, { withFileTypes: true });
1942
+ for (const ent of entries) {
1943
+ if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
1944
+ const file = join11(pluginsDir, ent.name);
1945
+ const raw = await readFile7(file, "utf8");
1946
+ const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
1947
+ if (replaced !== raw) await writeFile5(file, replaced);
1948
+ }
1949
+ } catch {
1950
+ }
1951
+ }
1952
+ tarballPath = await tarballFromDir(stageDir, "claude-static");
1953
+ return {
1954
+ tarballPath,
1955
+ cleanup: makeCleanup([stageDir, tarballPath]),
1956
+ warnings: []
1957
+ };
1958
+ } catch (err) {
1959
+ await rm5(stageDir, { recursive: true, force: true });
1960
+ if (tarballPath) await rm5(tarballPath, { force: true });
1961
+ throw err;
1962
+ }
1963
+ }
1964
+ async function stageClaudeCredentialsForUpload() {
1965
+ if (!await pathExists4(CREDENTIALS_BACKUP_FILE)) return emptyResult();
1966
+ return stageSingleFileTarball("claude-creds", CREDENTIALS_BACKUP_FILE, ".credentials.json");
1967
+ }
1968
+ var CODEX_STATIC_EXCLUDES = resolveAgentSpec("codex").staticPaths[0]?.exclude ?? [];
1969
+ 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.';
1970
+ async function sanitizeStagedCodexConfig(configPath, hostHome) {
1971
+ try {
1972
+ if (!await pathExists4(configPath)) return;
1973
+ const { text, changed } = sanitizeCodexConfigForBox(await readFile7(configPath, "utf8"), hostHome);
1974
+ if (changed) await writeFile5(configPath, text);
1975
+ } catch {
1976
+ }
1977
+ }
1978
+ async function stageCodexStaticForUpload(opts = {}) {
1979
+ const hostHome = opts.hostHome ?? homedir8();
1980
+ const hostCodex = join11(hostHome, ".codex");
1981
+ if (!await pathExists4(hostCodex)) return emptyResult();
1982
+ const stageDir = await mkStageDir("codex-static");
1983
+ let tarballPath = null;
1984
+ try {
1985
+ const codexBroken = await findBrokenSymlinks(hostCodex);
1986
+ await execa5("rsync", [
1987
+ "-a",
1988
+ "-L",
1989
+ ...codexBroken.map((r) => `--exclude=/${r}`),
1990
+ ...CODEX_STATIC_EXCLUDES.map((p) => `--exclude=${p}`),
1991
+ `${hostCodex}/`,
1992
+ `${stageDir}/`
1993
+ ]);
1994
+ await sanitizeStagedCodexConfig(join11(stageDir, "config.toml"), hostHome);
1995
+ tarballPath = await tarballFromDir(stageDir, "codex-static");
1996
+ return {
1997
+ tarballPath,
1998
+ cleanup: makeCleanup([stageDir, tarballPath]),
1999
+ warnings: []
2000
+ };
2001
+ } catch (err) {
2002
+ await rm5(stageDir, { recursive: true, force: true });
2003
+ if (tarballPath) await rm5(tarballPath, { force: true });
2004
+ throw err;
2005
+ }
2006
+ }
2007
+ async function stageAgentsStaticForUpload(opts = {}) {
2008
+ const hostHome = opts.hostHome ?? homedir8();
2009
+ const hostAgents = join11(hostHome, ".agents");
2010
+ if (!await pathExists4(hostAgents)) return emptyResult();
2011
+ const stageDir = await mkStageDir("agents-static");
2012
+ let tarballPath = null;
2013
+ try {
2014
+ const broken = await findBrokenSymlinks(hostAgents);
2015
+ await execa5("rsync", [
2016
+ "-a",
2017
+ "-L",
2018
+ ...broken.map((r) => `--exclude=/${r}`),
2019
+ `${hostAgents}/`,
2020
+ `${stageDir}/`
2021
+ ]);
2022
+ tarballPath = await tarballFromDir(stageDir, "agents-static");
2023
+ return {
2024
+ tarballPath,
2025
+ cleanup: makeCleanup([stageDir, tarballPath]),
2026
+ warnings: []
2027
+ };
2028
+ } catch (err) {
2029
+ await rm5(stageDir, { recursive: true, force: true });
2030
+ if (tarballPath) await rm5(tarballPath, { force: true });
2031
+ throw err;
2032
+ }
2033
+ }
2034
+ async function stageCodexCredentialsForUpload(opts = {}) {
2035
+ const hostHome = opts.hostHome ?? homedir8();
2036
+ const cloudBackup = join11(hostHome, ".agentbox", "codex-credentials.json");
2037
+ if (await pathExists4(cloudBackup)) {
2038
+ return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
2039
+ }
2040
+ const hostAuth = join11(hostHome, ".codex", "auth.json");
2041
+ if (!await pathExists4(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
2042
+ return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
2043
+ }
2044
+ var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
2045
+ async function stageOpencodeStaticForUpload(opts = {}) {
2046
+ const hostHome = opts.hostHome ?? homedir8();
2047
+ const hostData = join11(hostHome, ".local", "share", "opencode");
2048
+ const hostConfig = join11(hostHome, ".config", "opencode");
2049
+ const hasData = await pathExists4(hostData);
2050
+ const hasConfig = await pathExists4(hostConfig);
2051
+ if (!hasData && !hasConfig) return emptyResult();
2052
+ const stageDir = await mkStageDir("opencode-static");
2053
+ let tarballPath = null;
2054
+ try {
2055
+ if (hasData) {
2056
+ const dataBroken = await findBrokenSymlinks(hostData);
2057
+ await execa5("rsync", [
2058
+ "-a",
2059
+ "-L",
2060
+ ...dataBroken.map((r) => `--exclude=/${r}`),
2061
+ ...OPENCODE_DATA_EXCLUDES.map((p) => `--exclude=${p}`),
2062
+ `${hostData}/`,
2063
+ `${stageDir}/`
2064
+ ]);
2065
+ }
2066
+ if (hasConfig) {
2067
+ const configStage = join11(stageDir, "config");
2068
+ const cfgBroken = await findBrokenSymlinks(hostConfig);
2069
+ await execa5("rsync", [
2070
+ "-a",
2071
+ "-L",
2072
+ ...cfgBroken.map((r) => `--exclude=/${r}`),
2073
+ `${hostConfig}/`,
2074
+ `${configStage}/`
2075
+ ]);
2076
+ }
2077
+ tarballPath = await tarballFromDir(stageDir, "opencode-static");
2078
+ return {
2079
+ tarballPath,
2080
+ cleanup: makeCleanup([stageDir, tarballPath]),
2081
+ warnings: []
2082
+ };
2083
+ } catch (err) {
2084
+ await rm5(stageDir, { recursive: true, force: true });
2085
+ if (tarballPath) await rm5(tarballPath, { force: true });
2086
+ throw err;
2087
+ }
2088
+ }
2089
+ async function stageOpencodeCredentialsForUpload(opts = {}) {
2090
+ const hostHome = opts.hostHome ?? homedir8();
2091
+ const cloudBackup = join11(hostHome, ".agentbox", "opencode-credentials.json");
2092
+ if (await pathExists4(cloudBackup)) {
2093
+ return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
2094
+ }
2095
+ const hostAuth = join11(hostHome, ".local", "share", "opencode", "auth.json");
2096
+ if (!await pathExists4(hostAuth)) return emptyResult();
2097
+ return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
2098
+ }
2099
+ async function stageOpencodeStateForUpload(opts = {}) {
2100
+ const hostHome = opts.hostHome ?? homedir8();
2101
+ const hostModel = join11(hostHome, ".local", "state", "opencode", "model.json");
2102
+ if (!await pathExists4(hostModel)) return emptyResult();
2103
+ return stageSingleFileTarball("opencode-state", hostModel, "model.json");
2104
+ }
2105
+ var CLAUDE_STATIC_BOX_DIR = "/home/vscode/.claude";
2106
+ var CODEX_STATIC_BOX_DIR = "/home/vscode/.codex";
2107
+ var OPENCODE_STATIC_BOX_DIR = "/home/vscode/.local/share/opencode";
2108
+ var AGENTS_STATIC_BOX_DIR = "/home/vscode/.agents";
2109
+ async function stageAllAgentStatic(opts = {}) {
2110
+ const [claude, codex, opencode, agents] = await Promise.all([
2111
+ stageClaudeStaticForUpload({ hostWorkspace: opts.hostWorkspace }),
2112
+ stageCodexStaticForUpload(),
2113
+ stageOpencodeStaticForUpload(),
2114
+ stageAgentsStaticForUpload()
2115
+ ]);
2116
+ return [
2117
+ { kind: "claude", extractDir: CLAUDE_STATIC_BOX_DIR, staged: claude },
2118
+ { kind: "codex", extractDir: CODEX_STATIC_BOX_DIR, staged: codex },
2119
+ { kind: "opencode", extractDir: OPENCODE_STATIC_BOX_DIR, staged: opencode },
2120
+ { kind: "agents", extractDir: AGENTS_STATIC_BOX_DIR, staged: agents }
2121
+ ];
2122
+ }
2123
+ function preparedStatePathFor(provider) {
2124
+ if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
2125
+ throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
2126
+ }
2127
+ return pathResolve(homedir9(), ".agentbox", `${provider}-prepared.json`);
2128
+ }
2129
+ function readPreparedStateRaw(provider) {
2130
+ const path = preparedStatePathFor(provider);
2131
+ if (!existsSync3(path)) return null;
2132
+ try {
2133
+ return JSON.parse(readFileSync3(path, "utf8"));
2134
+ } catch {
2135
+ return null;
2136
+ }
2137
+ }
2138
+ function writePreparedStateRaw(provider, state) {
2139
+ const path = preparedStatePathFor(provider);
2140
+ mkdirSync2(dirname6(path), { recursive: true });
2141
+ const body = JSON.stringify(state, null, 2) + "\n";
2142
+ const tmp = `${path}.tmp`;
2143
+ writeFileSync2(tmp, body, { mode: 384 });
2144
+ renameSync2(tmp, path);
2145
+ }
2146
+ async function sha256OfFile(path) {
2147
+ const buf = await readFile8(path);
2148
+ return createHash3("sha256").update(buf).digest("hex");
2149
+ }
2150
+ async function computeContextSha256(files) {
2151
+ const sorted = [...files].sort((a, b) => a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0);
2152
+ const outer = createHash3("sha256");
2153
+ for (const f of sorted) {
2154
+ const inner = await sha256OfFile(f.abs);
2155
+ outer.update(`${f.rel}\0${inner}
2156
+ `);
2157
+ }
2158
+ return outer.digest("hex");
2159
+ }
2160
+ function claudeInstallFingerprint(baseSha, mode) {
2161
+ if (mode === "native") return baseSha;
2162
+ return createHash3("sha256").update(`${baseSha}\0claude-install=npm`).digest("hex");
2163
+ }
2164
+ function readCliStamp() {
2165
+ return {
2166
+ cliVersion: process.env.AGENTBOX_CLI_VERSION ?? "unknown",
2167
+ cliCommit: process.env.AGENTBOX_CLI_COMMIT ?? "unknown"
2168
+ };
2169
+ }
2170
+ var DOCKER_CONTEXT_FILE_MAP = {
2171
+ "Dockerfile.box": { staged: "Dockerfile.box", dev: "Dockerfile.box" },
2172
+ "ctl/bin.cjs": {
2173
+ staged: "packages/ctl/dist/bin.cjs",
2174
+ dev: "../ctl/dist/bin.cjs"
2175
+ },
2176
+ "share/agentbox-setup/SKILL.md": {
2177
+ staged: "apps/cli/share/agentbox-setup/SKILL.md",
2178
+ dev: "../../apps/cli/share/agentbox-setup/SKILL.md"
2179
+ },
2180
+ "scripts/agentbox-vnc-start": {
2181
+ staged: "packages/sandbox-docker/scripts/agentbox-vnc-start",
2182
+ dev: "scripts/agentbox-vnc-start"
2183
+ },
2184
+ "scripts/agentbox-dockerd-start": {
2185
+ staged: "packages/sandbox-docker/scripts/agentbox-dockerd-start",
2186
+ dev: "scripts/agentbox-dockerd-start"
2187
+ },
2188
+ "scripts/agentbox-checkpoint-cleanup": {
2189
+ staged: "packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup",
2190
+ dev: "scripts/agentbox-checkpoint-cleanup"
2191
+ },
2192
+ "scripts/agentbox-open": {
2193
+ staged: "packages/sandbox-docker/scripts/agentbox-open",
2194
+ dev: "scripts/agentbox-open"
2195
+ },
2196
+ "scripts/custom-system-CLAUDE.md": {
2197
+ staged: "packages/sandbox-docker/scripts/custom-system-CLAUDE.md",
2198
+ dev: "scripts/custom-system-CLAUDE.md"
2199
+ },
2200
+ "scripts/claude-managed-settings.json": {
2201
+ staged: "packages/sandbox-docker/scripts/claude-managed-settings.json",
2202
+ dev: "scripts/claude-managed-settings.json"
2203
+ },
2204
+ "scripts/agentbox-codex-hooks.json": {
2205
+ staged: "packages/sandbox-docker/scripts/agentbox-codex-hooks.json",
2206
+ dev: "scripts/agentbox-codex-hooks.json"
2207
+ }
2208
+ };
2209
+ function resolveContextFilesFrom(fileMap, opts) {
2210
+ const out = [];
2211
+ for (const [rel, paths] of Object.entries(fileMap)) {
2212
+ const candidates = [
2213
+ pathResolve(opts.contextDir, paths.staged),
2214
+ pathResolve(opts.devRoot, paths.dev)
2215
+ ];
2216
+ const hit = candidates.find((p) => existsSync3(p));
2217
+ if (!hit) return null;
2218
+ out.push({ rel, abs: hit });
2219
+ }
2220
+ return out;
2221
+ }
2222
+
2223
+ // ../../packages/sandbox-docker/dist/chunk-HAYZZFAH.js
2224
+ import { dirname as dirname23, resolve as resolve22 } from "path";
2225
+ import { fileURLToPath as fileURLToPath2 } from "url";
2226
+ import { execa as execa6 } from "execa";
2227
+ import { existsSync as existsSync4 } from "fs";
2228
+ import { fileURLToPath } from "url";
2229
+ import { dirname as dirname7, resolve as resolve3 } from "path";
2230
+ var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
2231
+ async function resolveClaudeInstallMode() {
2232
+ try {
2233
+ const { loadEffectiveConfig } = await import("./dist-QBXEP4VY.js");
2234
+ const cfg = await loadEffectiveConfig(process.cwd());
2235
+ return cfg.effective.box.claudeInstall;
2236
+ } catch {
2237
+ return "native";
2238
+ }
2239
+ }
2240
+ var BOX_IMAGE_REGISTRY = "ghcr.io/madarco/agentbox/box";
2241
+ function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
2242
+ return `${registry}:sha-${sha.slice(0, 16)}`;
2243
+ }
2244
+ var here = dirname7(fileURLToPath(import.meta.url));
2245
+ function resolveDockerBuild() {
2246
+ const override = process.env.AGENTBOX_DOCKER_CONTEXT;
2247
+ if (override && existsSync4(resolve3(override, "Dockerfile.box"))) {
2248
+ return { dockerfile: resolve3(override, "Dockerfile.box"), context: override };
2249
+ }
2250
+ const staged = resolve3(here, "..", "runtime", "docker");
2251
+ if (existsSync4(resolve3(staged, "Dockerfile.box"))) {
2252
+ return { dockerfile: resolve3(staged, "Dockerfile.box"), context: staged };
2253
+ }
2254
+ const packageRoot = resolve3(here, "..");
2255
+ return {
2256
+ dockerfile: resolve3(packageRoot, "Dockerfile.box"),
2257
+ context: resolve3(packageRoot, "..", "..")
2258
+ };
2259
+ }
2260
+ var { dockerfile: DOCKERFILE_PATH_RESOLVED, context: BUILD_CONTEXT_DIR_RESOLVED } = resolveDockerBuild();
2261
+ var DOCKERFILE_PATH = DOCKERFILE_PATH_RESOLVED;
2262
+ var BUILD_CONTEXT_DIR = BUILD_CONTEXT_DIR_RESOLVED;
2263
+ async function imageExists(ref) {
2264
+ const result = await execa6("docker", ["image", "inspect", ref], { reject: false });
2265
+ return result.exitCode === 0;
2266
+ }
2267
+ async function pullImage(target, opts = {}) {
2268
+ const subprocess = execa6("docker", ["pull", target], {
2269
+ stderr: "pipe",
2270
+ stdout: "pipe",
2271
+ reject: false
2272
+ });
2273
+ if (opts.onProgress) {
2274
+ const forward = (chunk) => {
2275
+ const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
2276
+ for (const line of text.split(/\r?\n/)) {
2277
+ if (line.length > 0) opts.onProgress?.(line);
2278
+ }
2279
+ };
2280
+ subprocess.stdout?.on("data", forward);
2281
+ subprocess.stderr?.on("data", forward);
2282
+ }
2283
+ const result = await subprocess;
2284
+ return result.exitCode === 0;
2285
+ }
2286
+ async function tagImage(source, target) {
2287
+ await execa6("docker", ["tag", source, target]);
2288
+ }
2289
+ async function imageInfo(ref = DEFAULT_BOX_IMAGE) {
2290
+ const result = await execa6(
2291
+ "docker",
2292
+ ["image", "inspect", "--format", "{{.Size}}|{{.Created}}", ref],
2293
+ { reject: false }
2294
+ );
2295
+ if (result.exitCode !== 0) return { ref, exists: false };
2296
+ const [sizeStr, createdAt] = result.stdout.trim().split("|");
2297
+ const sizeBytes = sizeStr ? Number.parseInt(sizeStr, 10) : NaN;
2298
+ return {
2299
+ ref,
2300
+ exists: true,
2301
+ sizeBytes: Number.isFinite(sizeBytes) ? sizeBytes : void 0,
2302
+ createdAt: createdAt && createdAt.length > 0 ? createdAt : void 0
2303
+ };
2304
+ }
2305
+ async function buildImage(opts = {}) {
2306
+ const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
2307
+ const dockerfile = opts.dockerfile ?? DOCKERFILE_PATH;
2308
+ const contextDir = opts.contextDir ?? BUILD_CONTEXT_DIR;
2309
+ const args = ["build", "-t", ref, "-f", dockerfile];
2310
+ for (const [k, v] of Object.entries(opts.buildArgs ?? {})) {
2311
+ args.push("--build-arg", `${k}=${v}`);
2312
+ }
2313
+ args.push(contextDir);
2314
+ if (process.env.AGENTBOX === "1") {
2315
+ args.splice(1, 0, "--network=host");
2316
+ }
2317
+ const subprocess = execa6("docker", args, {
2318
+ stderr: "pipe",
2319
+ stdout: "pipe"
2320
+ });
2321
+ if (opts.onProgress) {
2322
+ const forward = (chunk) => {
2323
+ const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
2324
+ for (const line of text.split(/\r?\n/)) {
2325
+ if (line.length > 0) opts.onProgress?.(line);
2326
+ }
2327
+ };
2328
+ subprocess.stdout?.on("data", forward);
2329
+ subprocess.stderr?.on("data", forward);
2330
+ }
2331
+ await subprocess;
2332
+ return ref;
2333
+ }
2334
+ async function pullOrBuild(ref, fingerprint, opts = {}) {
2335
+ const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-5FIGV4BE-BMUK63FD.js");
2336
+ const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
2337
+ const allowPull = opts.allowPull !== false;
2338
+ if (allowPull && registry && fingerprint) {
2339
+ const target = registryRefForSha(fingerprint.contextSha256, registry);
2340
+ opts.onProgress?.(`[image] pulling ${target}`);
2341
+ if (await pullImage(target, { onProgress: opts.onProgress })) {
2342
+ await tagImage(target, ref);
2343
+ writePreparedDockerState2({ imageRef: ref, contextSha256: fingerprint.contextSha256 });
2344
+ opts.onProgress?.(`[image] pulled ${target} -> ${ref}`);
2345
+ return { source: "pulled" };
2346
+ }
2347
+ opts.onProgress?.(`[image] registry miss, building ${ref} locally`);
2348
+ }
2349
+ await buildImage({
2350
+ ref,
2351
+ dockerfile: opts.dockerfile,
2352
+ contextDir: opts.contextDir,
2353
+ buildArgs: opts.buildArgs,
2354
+ onProgress: opts.onProgress
2355
+ });
2356
+ if (fingerprint) {
2357
+ writePreparedDockerState2({ imageRef: ref, contextSha256: fingerprint.contextSha256 });
2358
+ }
2359
+ return { source: "built" };
2360
+ }
2361
+ async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
2362
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-5FIGV4BE-BMUK63FD.js");
2363
+ const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
2364
+ const rawFingerprint = await computeDockerContextFingerprint2({
2365
+ contextDir: opts.contextDir
2366
+ });
2367
+ const fingerprint = rawFingerprint ? {
2368
+ ...rawFingerprint,
2369
+ contextSha256: claudeInstallFingerprint(rawFingerprint.contextSha256, claudeInstall)
2370
+ } : null;
2371
+ const prepared = readPreparedDockerState2();
2372
+ const exists = await imageExists(ref);
2373
+ let reason;
2374
+ if (!exists) {
2375
+ reason = `image ${ref} not present`;
2376
+ } else if (!fingerprint) {
2377
+ return { ref, built: false, reason: "image present (fingerprint skipped)" };
2378
+ } else if (!prepared) {
2379
+ reason = "no docker-prepared.json on disk";
2380
+ } else if (!preparedMatches2(prepared, fingerprint.contextSha256)) {
2381
+ reason = `build context changed (was ${prepared.base?.contextSha256?.slice(0, 12) ?? "<none>"}, now ${fingerprint.contextSha256.slice(0, 12)})`;
2382
+ }
2383
+ if (!reason) {
2384
+ return { ref, built: false, reason: "image up to date" };
2385
+ }
2386
+ opts.onProgress?.(`[image] ${ref}: ${reason}`);
2387
+ const npm = claudeInstall === "npm";
2388
+ const { source } = await pullOrBuild(ref, fingerprint, {
2389
+ onProgress: opts.onProgress,
2390
+ dockerfile: opts.dockerfile,
2391
+ contextDir: opts.contextDir,
2392
+ // The published GHCR image is native-only, so npm mode must build locally.
2393
+ allowPull: npm ? false : opts.allowPull,
2394
+ registry: opts.registry,
2395
+ buildArgs: npm ? { AGENTBOX_CLAUDE_INSTALL: "npm" } : void 0
2396
+ });
2397
+ return { ref, built: source === "built", reason };
2398
+ }
2399
+ var SCHEMA = 1;
2400
+ function resolveContextFiles(opts = {}) {
2401
+ const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;
2402
+ const here2 = dirname23(fileURLToPath2(import.meta.url));
2403
+ const packageRoot = resolve22(here2, "..");
2404
+ return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
2405
+ contextDir: ctx,
2406
+ devRoot: packageRoot
2407
+ });
2408
+ }
2409
+ async function computeDockerContextFingerprint(opts = {}) {
2410
+ const files = resolveContextFiles(opts);
2411
+ if (!files) return null;
2412
+ return { contextSha256: await computeContextSha256(files), files };
2413
+ }
2414
+ function readPreparedDockerState() {
2415
+ const raw = readPreparedStateRaw("docker");
2416
+ if (raw === null || typeof raw !== "object") return null;
2417
+ const parsed = raw;
2418
+ if (parsed.schema !== SCHEMA) return null;
2419
+ return { schema: SCHEMA, base: parsed.base };
2420
+ }
2421
+ function writePreparedDockerState(opts) {
2422
+ const stamp = readCliStamp();
2423
+ const state = {
2424
+ schema: SCHEMA,
2425
+ base: {
2426
+ imageRef: opts.imageRef ?? DEFAULT_BOX_IMAGE,
2427
+ contextSha256: opts.contextSha256,
2428
+ cliVersion: stamp.cliVersion,
2429
+ cliCommit: stamp.cliCommit,
2430
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
2431
+ }
2432
+ };
2433
+ writePreparedStateRaw("docker", state);
2434
+ }
2435
+ function preparedMatches(state, current) {
2436
+ return state?.base?.contextSha256 === current;
2437
+ }
2438
+
2439
+ export {
2440
+ resolveAgentLauncher,
2441
+ ReplaceError,
2442
+ parseReplaceRules,
2443
+ parseReplacements,
2444
+ resolveRuleRefs,
2445
+ UserFacingError,
2446
+ BoxNotFoundError,
2447
+ AmbiguousBoxError,
2448
+ generateBoxId,
2449
+ toSyncKind,
2450
+ toQueueKind,
2451
+ normalizeLastAgent,
2452
+ SYNC_DRYRUN_ENV,
2453
+ dryRunProviderSync,
2454
+ resolveSyncTopology,
2455
+ realpathSafe,
2456
+ isInside,
2457
+ STATE_DIR,
2458
+ STATE_FILE,
2459
+ mutateState,
2460
+ readState,
2461
+ recordBox,
2462
+ recordLastAgent,
2463
+ recordBoxSsh,
2464
+ reserveProjectIndex,
2465
+ removeBoxRecord,
2466
+ findBox,
2467
+ allocateProjectIndex,
2468
+ autoPickProjectBox,
2469
+ resolveBoxRef,
2470
+ detectGitRepos,
2471
+ pickFreshBranch,
2472
+ GitWorktreeError,
2473
+ hostOpenCommand,
2474
+ scratchBranchName,
2475
+ boxGitCheckout,
2476
+ boxGitNewBranch,
2477
+ boxGitPush,
2478
+ boxGitPull,
2479
+ boxGitPushHost,
2480
+ boxServicesStatusRaw,
2481
+ boxRestartService,
2482
+ boxRestartServices,
2483
+ firstLine,
2484
+ errSummary,
2485
+ writeManagedSecrets,
2486
+ SUPPORTED_SDK_API_VERSIONS,
2487
+ isSupportedApiVersion,
2488
+ readPluginRegistrySync,
2489
+ addPluginRecord,
2490
+ removePluginRecord,
2491
+ pluginProviderNames,
2492
+ pluginForProvider,
2493
+ renderCarryEntries,
2494
+ makeSyncContext,
2495
+ DEFAULT_ENV_PATTERNS,
2496
+ ENV_PRUNE_DIRS,
2497
+ buildHostEnvFindArgs,
2498
+ scanHostEnvFiles,
2499
+ pushEnvFiles,
2500
+ BOX_HOME,
2501
+ dirnameUnix,
2502
+ planCarryEntry,
2503
+ encodeClaudeProjectsKey,
2504
+ BOX_CLAUDE_PROJECT_DIR,
2505
+ resolveClaudeMemoryDir,
2506
+ findUnsyncableSymlinks,
2507
+ seedAgentsVolume,
2508
+ SEED_MARKER,
2509
+ isRealAgentCredential,
2510
+ hostClaudeBackupExpired,
2511
+ hostBackupHasCredentials,
2512
+ extractCredentials,
2513
+ resyncWorkspace,
2514
+ makeHostGitPorts,
2515
+ BOX_WORKFLOWS_DIR,
2516
+ BOX_DYNAMIC_SYNC_MANIFEST,
2517
+ BOX_MEMORY_DIR,
2518
+ buildHostSyncManifest,
2519
+ computeSyncDelta,
2520
+ stageDynamicSyncTarball,
2521
+ filterHostHooks,
2522
+ trustWorkspace,
2523
+ addProjectAlias,
2524
+ setInstallMethodNative,
2525
+ MINIMAL_TRUSTED_CODEX_CONFIG,
2526
+ sanitizeCodexConfigForBox,
2527
+ stageClaudeJsonOnlyForUpload,
2528
+ stageClaudeStaticForUpload,
2529
+ stageClaudeCredentialsForUpload,
2530
+ stageCodexStaticForUpload,
2531
+ stageAgentsStaticForUpload,
2532
+ stageCodexCredentialsForUpload,
2533
+ stageOpencodeStaticForUpload,
2534
+ stageOpencodeCredentialsForUpload,
2535
+ stageOpencodeStateForUpload,
2536
+ stageAllAgentStatic,
2537
+ preparedStatePathFor,
2538
+ readPreparedStateRaw,
2539
+ writePreparedStateRaw,
2540
+ computeContextSha256,
2541
+ claudeInstallFingerprint,
2542
+ readCliStamp,
2543
+ DOCKER_CONTEXT_FILE_MAP,
2544
+ resolveContextFilesFrom,
2545
+ DEFAULT_BOX_IMAGE,
2546
+ BOX_IMAGE_REGISTRY,
2547
+ registryRefForSha,
2548
+ DOCKERFILE_PATH,
2549
+ imageExists,
2550
+ pullImage,
2551
+ tagImage,
2552
+ imageInfo,
2553
+ pullOrBuild,
2554
+ ensureImage,
2555
+ resolveContextFiles,
2556
+ computeDockerContextFingerprint,
2557
+ readPreparedDockerState,
2558
+ writePreparedDockerState,
2559
+ preparedMatches
2560
+ };
2561
+ //# sourceMappingURL=chunk-ALEYDWAO.js.map