@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,2806 @@
1
+ import { createRequire as __cr } from 'node:module'; import { fileURLToPath as __f } from 'node:url'; import { dirname as __d } from 'node:path'; const require = __cr(import.meta.url); const __filename = __f(import.meta.url); const __dirname = __d(__filename);
2
+ import {
3
+ CLAUDE_FORWARDED_ENV_KEYS,
4
+ CODEX_FORWARDED_ENV_KEYS,
5
+ CODEX_OVERRIDE_WROTE_MARKER,
6
+ OPENCODE_FORWARDED_ENV_KEYS,
7
+ SHARED_CLAUDE_VOLUME,
8
+ SHARED_CODEX_VOLUME,
9
+ SHARED_OPENCODE_VOLUME,
10
+ TERM_FALLBACK_SNIPPET,
11
+ buildCodexAgentsOverrideScript,
12
+ buildTmuxConfigShellSnippet,
13
+ ensureRelay,
14
+ extractCodexCredentials,
15
+ extractOpencodeCredentials,
16
+ forgetBoxFromRelay,
17
+ generateRelayToken,
18
+ generateVncPassword,
19
+ portlessAlias,
20
+ portlessGetUrl,
21
+ portlessUnalias,
22
+ registerBoxWithRelay,
23
+ syncClaudeCredentials
24
+ } from "./chunk-V5KGFHCF.js";
25
+ import {
26
+ hashProjectPath,
27
+ loadEffectiveConfig,
28
+ projectDirSegment,
29
+ require_dist,
30
+ sanitizeMnemonic
31
+ } from "./chunk-AKLBSCSZ.js";
32
+ import {
33
+ BOX_DYNAMIC_SYNC_MANIFEST,
34
+ BOX_HOME,
35
+ BOX_MEMORY_DIR,
36
+ BOX_WORKFLOWS_DIR,
37
+ DEFAULT_BOX_IMAGE,
38
+ SEED_MARKER,
39
+ SYNC_DRYRUN_ENV,
40
+ allocateProjectIndex,
41
+ buildHostSyncManifest,
42
+ computeSyncDelta,
43
+ detectGitRepos,
44
+ dirnameUnix,
45
+ dryRunProviderSync,
46
+ extractCredentials,
47
+ generateBoxId,
48
+ hostClaudeBackupExpired,
49
+ makeHostGitPorts,
50
+ makeSyncContext,
51
+ planCarryEntry,
52
+ pushEnvFiles,
53
+ readCliStamp,
54
+ readPreparedStateRaw,
55
+ readState,
56
+ recordBox,
57
+ removeBoxRecord,
58
+ renderCarryEntries,
59
+ resolveSyncTopology,
60
+ resyncWorkspace,
61
+ stageClaudeCredentialsForUpload,
62
+ stageClaudeJsonOnlyForUpload,
63
+ stageClaudeStaticForUpload,
64
+ stageCodexCredentialsForUpload,
65
+ stageCodexStaticForUpload,
66
+ stageDynamicSyncTarball,
67
+ stageOpencodeCredentialsForUpload,
68
+ stageOpencodeStateForUpload,
69
+ stageOpencodeStaticForUpload
70
+ } from "./chunk-LJG4CEGS.js";
71
+ import {
72
+ execa
73
+ } from "./chunk-EFW34I43.js";
74
+ import {
75
+ __toESM
76
+ } from "./chunk-TZFWAJVB.js";
77
+
78
+ // ../../packages/sandbox-cloud/dist/index.js
79
+ import { basename as basename2, resolve } from "path";
80
+ import { mkdtemp, rm, writeFile } from "fs/promises";
81
+ import { tmpdir } from "os";
82
+ import { join } from "path";
83
+ import { mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
84
+ import { tmpdir as tmpdir2 } from "os";
85
+ import { join as join2 } from "path";
86
+ import { mkdtemp as mkdtemp3, rm as rm3, writeFile as writeFile2 } from "fs/promises";
87
+ import { tmpdir as tmpdir3 } from "os";
88
+ import { dirname, join as join3 } from "path";
89
+ import { mkdtemp as mkdtemp4, rm as rm4 } from "fs/promises";
90
+ import { tmpdir as tmpdir4 } from "os";
91
+ import { join as join4 } from "path";
92
+ import { mkdir, readFile, readdir, rm as rm5, writeFile as writeFile3 } from "fs/promises";
93
+ import { homedir } from "os";
94
+ import { basename, join as join5 } from "path";
95
+ var import_yaml = __toESM(require_dist(), 1);
96
+ import { readFile as readFile2 } from "fs/promises";
97
+ import { join as join6 } from "path";
98
+ import { existsSync, mkdirSync, renameSync, statSync } from "fs";
99
+ import { mkdtemp as mkdtemp5, rm as rm6 } from "fs/promises";
100
+ import { tmpdir as tmpdir5 } from "os";
101
+ import {
102
+ basename as hostBasename,
103
+ dirname as hostDirname,
104
+ join as hostJoin,
105
+ resolve as hostResolve
106
+ } from "path";
107
+ import { posix } from "path";
108
+ import { copyFile, mkdir as mkdir2, mkdtemp as mkdtemp6, rm as rm7, stat } from "fs/promises";
109
+ import { tmpdir as tmpdir6 } from "os";
110
+ import { dirname as dirname2, join as join7 } from "path";
111
+ function quoteShellArgv(argv) {
112
+ return argv.map(quoteShellArg).join(" ");
113
+ }
114
+ function quoteShellArg(arg) {
115
+ if (arg.length === 0) return "''";
116
+ if (/^[A-Za-z0-9_@%+=:,./-]+$/.test(arg)) return arg;
117
+ return "'" + arg.replace(/'/g, "'\\''") + "'";
118
+ }
119
+ function bashScript(body) {
120
+ return `bash -c ${quoteShellArg(body)}`;
121
+ }
122
+ var TARGET_REF = "refs/agentbox-resync/target";
123
+ var STASH_REF = "refs/agentbox-resync/stash";
124
+ var SHA_RE = /^[0-9a-f]{40}$/;
125
+ var BOX_REVLIST_CAP = 500;
126
+ async function resyncCloudWorkspace(backend, handle, worktrees, onLog) {
127
+ const log = onLog ?? (() => {
128
+ });
129
+ const probeAsRoot = backend.name === "vercel" || backend.name === "e2b";
130
+ const stage = await mkdtemp(join(tmpdir(), "agentbox-resync-"));
131
+ const prefetch = /* @__PURE__ */ new Map();
132
+ try {
133
+ for (const [i, w] of worktrees.entries()) {
134
+ prefetch.set(w.hostMainRepo, await prefetchRepo(backend, handle, w, stage, i, log));
135
+ }
136
+ const hostPorts = makeHostGitPorts();
137
+ const ports = {
138
+ ...hostPorts,
139
+ // Merge target = the in-box temp ref. When no shared ancestor was found we
140
+ // fall back to the box branch: the concern treats `hostRef === boxBranch`
141
+ // as "merging self" and skips the merge, but STILL overlays the host's
142
+ // untracked files (non-destructive, box wins) — whereas a null ref would
143
+ // make it skip the whole repo. stashSha is null in that case (no bundle),
144
+ // so the stash overlay is skipped too.
145
+ resolveHostRef: (hostMain) => {
146
+ const pf = prefetch.get(hostMain);
147
+ return Promise.resolve(pf ? pf.targetRef ?? pf.branch : null);
148
+ },
149
+ // The stash object is in-box (bundled + fetched); the concern applies by SHA.
150
+ createHostStash: (hostMain) => Promise.resolve(prefetch.get(hostMain)?.stashSha ?? null),
151
+ boxGit: (ct, args) => boxGit(backend, handle, ct, args),
152
+ probeUntrackedTokens: (ct, paths) => probeUntrackedTokens(backend, handle, ct, paths, probeAsRoot),
153
+ applyTarToBox: (ct, tar) => applyTarToBox(backend, handle, stage, ct, tar)
154
+ };
155
+ const results = await resyncWorkspace(worktrees, ports, log);
156
+ await cleanupBoxRefs(backend, handle, worktrees, prefetch);
157
+ return results;
158
+ } finally {
159
+ await rm(stage, { recursive: true, force: true });
160
+ }
161
+ }
162
+ async function prefetchRepo(backend, handle, w, stage, idx, log) {
163
+ const ct = w.containerPath;
164
+ const hostMain = w.hostMainRepo;
165
+ const none = { targetRef: null, stashSha: null, branch: w.branch };
166
+ const rev = await backend.exec(
167
+ handle,
168
+ bashScript(`git -C ${quoteShellArg(ct)} rev-list --max-count=${String(BOX_REVLIST_CAP)} ${quoteShellArg(w.branch)} 2>/dev/null || true`)
169
+ );
170
+ const boxShas = rev.stdout.split("\n").map((s) => s.trim()).filter((s) => SHA_RE.test(s));
171
+ if (boxShas.length === 0) {
172
+ log(`resync: ${ct}: box branch has no commits; overlay only`);
173
+ return none;
174
+ }
175
+ const batch = await execa(
176
+ "git",
177
+ ["-C", hostMain, "cat-file", "--batch-check=%(objectname) %(objecttype)"],
178
+ { input: boxShas.join("\n"), reject: false }
179
+ );
180
+ const present = /* @__PURE__ */ new Set();
181
+ for (const line of batch.stdout.split("\n")) {
182
+ const parts = line.trim().split(" ");
183
+ if (parts.length >= 2 && parts[1] === "commit" && parts[0]) present.add(parts[0]);
184
+ }
185
+ const base = boxShas.find((s) => present.has(s));
186
+ if (!base) {
187
+ log(`resync: ${ct}: no shared ancestor with the host (repo replaced?); overlay only (non-destructive)`);
188
+ return none;
189
+ }
190
+ const hRes = await execa("git", ["-C", hostMain, "rev-parse", "HEAD"], { reject: false });
191
+ const hostTip = hRes.stdout.trim();
192
+ if (hRes.exitCode !== 0 || !SHA_RE.test(hostTip)) return none;
193
+ const stashRes = await execa("git", ["-C", hostMain, "stash", "create"], { reject: false });
194
+ const stashSha = stashRes.exitCode === 0 && SHA_RE.test(stashRes.stdout.trim()) ? stashRes.stdout.trim() : null;
195
+ const needTarget = hostTip !== base;
196
+ const bundleRefs = [];
197
+ if (needTarget) bundleRefs.push(TARGET_REF);
198
+ if (stashSha) bundleRefs.push(STASH_REF);
199
+ if (bundleRefs.length === 0) {
200
+ log(`resync: ${ct}: already up to date with the host; overlay untracked only`);
201
+ return { targetRef: null, stashSha: null, branch: w.branch };
202
+ }
203
+ const bundlePath = join(stage, `resync-${String(idx)}.bundle`);
204
+ try {
205
+ if (needTarget) await execa("git", ["-C", hostMain, "update-ref", TARGET_REF, hostTip], { reject: false });
206
+ if (stashSha) await execa("git", ["-C", hostMain, "update-ref", STASH_REF, stashSha], { reject: false });
207
+ const b = await execa(
208
+ "git",
209
+ ["-C", hostMain, "bundle", "create", bundlePath, ...bundleRefs, `^${base}`],
210
+ { reject: false }
211
+ );
212
+ if (b.exitCode !== 0) {
213
+ log(`resync: ${ct}: bundle build failed; overlay only: ${(b.stderr || "").split("\n")[0]}`);
214
+ return none;
215
+ }
216
+ } finally {
217
+ if (needTarget) await execa("git", ["-C", hostMain, "update-ref", "-d", TARGET_REF], { reject: false });
218
+ if (stashSha) await execa("git", ["-C", hostMain, "update-ref", "-d", STASH_REF], { reject: false });
219
+ }
220
+ const remote = `/tmp/agentbox-resync-${String(idx)}.bundle`;
221
+ await backend.uploadFile(handle, bundlePath, remote);
222
+ const refspecs = bundleRefs.map((r) => `+${r}:${r}`);
223
+ const fetch2 = await backend.exec(
224
+ handle,
225
+ bashScript(
226
+ `git -C ${quoteShellArg(ct)} fetch --no-tags ${quoteShellArg(remote)} ${refspecs.map((r) => quoteShellArg(r)).join(" ")} && rm -f ${quoteShellArg(remote)}`
227
+ )
228
+ );
229
+ if (fetch2.exitCode !== 0) {
230
+ log(`resync: ${ct}: in-box bundle fetch failed; overlay only: ${(fetch2.stderr || fetch2.stdout || "").split("\n")[0]}`);
231
+ return none;
232
+ }
233
+ log(
234
+ needTarget ? `resync: ${ct}: fetched host commits (${base.slice(0, 8)}..${hostTip.slice(0, 8)})${stashSha ? " + host stash" : ""}` : `resync: ${ct}: no new host commits; fetched host stash only`
235
+ );
236
+ return { targetRef: needTarget ? TARGET_REF : null, stashSha, branch: w.branch };
237
+ }
238
+ async function boxGit(backend, handle, ct, args) {
239
+ const cmd = `git -C ${quoteShellArg(ct)} ${quoteShellArgv(args)}`;
240
+ const r = await backend.exec(handle, bashScript(cmd));
241
+ return { exitCode: r.exitCode, stdout: r.stdout, stderr: r.stderr };
242
+ }
243
+ async function probeUntrackedTokens(backend, handle, ct, relPaths, asRoot) {
244
+ const tokens = /* @__PURE__ */ new Map();
245
+ if (relPaths.length === 0) return tokens;
246
+ const payload = Buffer.from(relPaths.join("\0")).toString("base64");
247
+ const script = `printf %s ${quoteShellArg(payload)} | base64 -d | ( cd ${quoteShellArg(ct)} && while IFS= read -r -d '' f; do if [ -f "$f" ] && [ ! -L "$f" ]; then printf '%s\\0%s\\0' "$(sha256sum < "$f" | cut -d' ' -f1)" "$f"; elif [ -e "$f" ]; then printf '%s\\0%s\\0' '-' "$f"; fi; done )`;
248
+ const r = await backend.exec(handle, bashScript(script), asRoot ? { user: "root" } : void 0);
249
+ if (r.exitCode === 0) {
250
+ const flat = r.stdout.split("\0").filter((s) => s.length > 0);
251
+ for (let i = 0; i + 1 < flat.length; i += 2) {
252
+ const token = flat[i];
253
+ const path = flat[i + 1];
254
+ if (token !== void 0 && path !== void 0) tokens.set(path, token);
255
+ }
256
+ }
257
+ return tokens;
258
+ }
259
+ async function applyTarToBox(backend, handle, stage, ct, tar) {
260
+ const local = join(stage, "overlay.tar");
261
+ await writeFile(local, tar);
262
+ const remote = "/tmp/agentbox-resync-overlay.tar";
263
+ await backend.uploadFile(handle, local, remote);
264
+ await backend.exec(
265
+ handle,
266
+ bashScript(`tar -C ${quoteShellArg(ct)} -xf ${quoteShellArg(remote)} && rm -f ${quoteShellArg(remote)}`)
267
+ );
268
+ }
269
+ async function cleanupBoxRefs(backend, handle, worktrees, prefetch) {
270
+ for (const w of worktrees) {
271
+ if (!prefetch.get(w.hostMainRepo)?.targetRef) continue;
272
+ const ct = quoteShellArg(w.containerPath);
273
+ await backend.exec(
274
+ handle,
275
+ bashScript(
276
+ `git -C ${ct} update-ref -d ${TARGET_REF} 2>/dev/null || true; git -C ${ct} update-ref -d ${STASH_REF} 2>/dev/null || true`
277
+ )
278
+ ).catch(() => {
279
+ });
280
+ }
281
+ }
282
+ function createCloudSyncTransport(init) {
283
+ const { backend, handle } = init;
284
+ const hasVolume = typeof backend.ensureVolume === "function";
285
+ let tarSeq = 0;
286
+ const caps = {
287
+ persistentVolumes: hasVolume,
288
+ helperContainer: false,
289
+ ephemeralFs: !hasVolume
290
+ };
291
+ const transport = {
292
+ caps,
293
+ async exec(cmd, opts) {
294
+ const r = await backend.exec(handle, quoteShellArgv(cmd), {
295
+ cwd: opts?.cwd,
296
+ env: opts?.env,
297
+ user: opts?.user,
298
+ attemptTimeoutMs: opts?.attemptTimeoutMs,
299
+ noRetry: opts?.noRetry
300
+ });
301
+ return { exitCode: r.exitCode, stdout: r.stdout, stderr: r.stderr };
302
+ },
303
+ async applyTarball(hostTarPath, boxDestDir) {
304
+ const remoteTar = `/tmp/agentbox-apply-${String(tarSeq++)}.tar`;
305
+ await backend.uploadFile(handle, hostTarPath, remoteTar);
306
+ const r = await backend.exec(
307
+ handle,
308
+ `tar -xf ${remoteTar} -C ${boxDestDir} --no-same-permissions --no-same-owner -m && rm -f ${remoteTar}`
309
+ );
310
+ if (r.exitCode !== 0) {
311
+ throw new Error(
312
+ `cloud tar extract into ${boxDestDir} failed (exit ${String(r.exitCode)}): ${r.stderr.slice(-200)}`
313
+ );
314
+ }
315
+ },
316
+ async pushTree(hostSrcDir, boxDestDir, opts) {
317
+ const stage = await mkdtemp2(join2(tmpdir2(), "agentbox-pushtree-"));
318
+ const localTar = join2(stage, "tree.tar");
319
+ try {
320
+ const packArgs = ["-C", hostSrcDir];
321
+ for (const ex of opts?.exclude ?? []) packArgs.push(`--exclude=${ex}`);
322
+ packArgs.push("-cf", localTar, ".");
323
+ const packed = await execa("tar", packArgs, { reject: false });
324
+ if (packed.exitCode !== 0) {
325
+ throw new Error(`tar pack of ${hostSrcDir} failed: ${String(packed.stderr).slice(0, 300)}`);
326
+ }
327
+ await transport.applyTarball(localTar, boxDestDir, opts);
328
+ } finally {
329
+ await rm2(stage, { recursive: true, force: true });
330
+ }
331
+ },
332
+ async pushFile(hostSrcPath, boxDestPath, opts) {
333
+ await backend.uploadFile(handle, hostSrcPath, boxDestPath);
334
+ if (opts?.uid !== void 0 && opts.uid !== 0) {
335
+ await backend.exec(handle, `chown ${String(opts.uid)}:${String(opts.uid)} ${boxDestPath}`);
336
+ }
337
+ if (opts?.mode !== void 0) {
338
+ await backend.exec(handle, `chmod ${opts.mode.toString(8)} ${boxDestPath}`);
339
+ }
340
+ },
341
+ async pullTree(boxSrcDir, hostDestDir, opts) {
342
+ const remoteTar = `/tmp/agentbox-pull-${String(tarSeq++)}.tar`;
343
+ const excludes = (opts?.exclude ?? []).map((e) => `--exclude=${e}`).join(" ");
344
+ const pack = await backend.exec(
345
+ handle,
346
+ `tar -C ${boxSrcDir} ${excludes} -cf ${remoteTar} .`
347
+ );
348
+ if (pack.exitCode !== 0) {
349
+ throw new Error(`cloud tar of ${boxSrcDir} failed: ${pack.stderr.slice(-200)}`);
350
+ }
351
+ const stage = await mkdtemp2(join2(tmpdir2(), "agentbox-pulltree-"));
352
+ const localTar = join2(stage, "tree.tar");
353
+ try {
354
+ await backend.downloadFile(handle, remoteTar, localTar);
355
+ await execa("tar", ["-xf", localTar, "-C", hostDestDir], { reject: false });
356
+ } finally {
357
+ await rm2(stage, { recursive: true, force: true });
358
+ await backend.exec(handle, `rm -f ${remoteTar}`).catch(() => {
359
+ });
360
+ }
361
+ },
362
+ async pullFile(boxSrcPath, hostDestPath) {
363
+ await backend.downloadFile(handle, boxSrcPath, hostDestPath);
364
+ },
365
+ async readText(boxPath) {
366
+ const r = await backend.exec(handle, `cat ${boxPath} 2>/dev/null`, { noRetry: true });
367
+ if (r.exitCode !== 0) return null;
368
+ return r.stdout;
369
+ }
370
+ };
371
+ if (hasVolume) {
372
+ transport.ensureVolume = async (name) => {
373
+ const ensured = await backend.ensureVolume(name);
374
+ return ensured;
375
+ };
376
+ }
377
+ return transport;
378
+ }
379
+ var CREDENTIALS_VOLUME = "agentbox-credentials";
380
+ var AGENT_SPECS = [
381
+ {
382
+ kind: "claude",
383
+ staticMountPath: "/home/vscode/.claude",
384
+ credentialsMountPath: "/home/vscode/.agentbox-creds/claude",
385
+ credentialsSubpath: "claude/",
386
+ stageStatic: (opts) => stageClaudeStaticForUpload({ hostWorkspace: opts.hostWorkspace }),
387
+ stageCredentials: () => stageClaudeCredentialsForUpload()
388
+ },
389
+ {
390
+ kind: "codex",
391
+ staticMountPath: "/home/vscode/.codex",
392
+ credentialsMountPath: "/home/vscode/.agentbox-creds/codex",
393
+ credentialsSubpath: "codex/",
394
+ stageStatic: () => stageCodexStaticForUpload(),
395
+ stageCredentials: () => stageCodexCredentialsForUpload()
396
+ },
397
+ {
398
+ kind: "opencode",
399
+ staticMountPath: "/home/vscode/.local/share/opencode",
400
+ credentialsMountPath: "/home/vscode/.agentbox-creds/opencode",
401
+ credentialsSubpath: "opencode/",
402
+ stageStatic: () => stageOpencodeStaticForUpload(),
403
+ stageCredentials: () => stageOpencodeCredentialsForUpload()
404
+ }
405
+ ];
406
+ async function ensureAgentVolumesForCloud(backend, opts = {}) {
407
+ const log = opts.onLog ?? (() => {
408
+ });
409
+ const allAgents = AGENT_SPECS.map((s) => s.kind);
410
+ if (typeof backend.ensureVolume !== "function") {
411
+ log(
412
+ `cloud backend '${backend.name}' has no volume primitive \u2014 agent credentials seeded per-create only`
413
+ );
414
+ return { mounts: [], env: buildForwardedEnv(allAgents), agents: allAgents };
415
+ }
416
+ let volumeId;
417
+ try {
418
+ const ensured = await backend.ensureVolume(CREDENTIALS_VOLUME);
419
+ volumeId = ensured.volumeId;
420
+ } catch (err) {
421
+ const msg = err instanceof Error ? err.message : String(err);
422
+ log(`ensureVolume(${CREDENTIALS_VOLUME}) failed (skipping credentials seed): ${msg}`);
423
+ return { mounts: [], env: buildForwardedEnv([]), agents: [] };
424
+ }
425
+ const mounts = AGENT_SPECS.map((spec) => ({
426
+ volumeId,
427
+ mountPath: spec.credentialsMountPath,
428
+ subpath: spec.credentialsSubpath
429
+ }));
430
+ return { mounts, env: buildForwardedEnv(allAgents), agents: allAgents };
431
+ }
432
+ function buildForwardedEnv(agents) {
433
+ const env = {};
434
+ if (agents.includes("opencode")) {
435
+ env["OPENCODE_CONFIG_DIR"] = "/home/vscode/.local/share/opencode/config";
436
+ }
437
+ const forwardedKeys = /* @__PURE__ */ new Set([
438
+ ...CLAUDE_FORWARDED_ENV_KEYS,
439
+ ...CODEX_FORWARDED_ENV_KEYS,
440
+ ...OPENCODE_FORWARDED_ENV_KEYS
441
+ ]);
442
+ for (const k of forwardedKeys) {
443
+ const v = process.env[k];
444
+ if (typeof v === "string" && v.length > 0) env[k] = v;
445
+ }
446
+ return env;
447
+ }
448
+ async function seedAgentVolumesIfFresh(backend, handle, opts = {}) {
449
+ const log = opts.onLog ?? (() => {
450
+ });
451
+ const wanted = new Set(opts.agents ?? AGENT_SPECS.map((s) => s.kind));
452
+ const specs = AGENT_SPECS.filter((s) => wanted.has(s.kind));
453
+ await Promise.allSettled(
454
+ specs.map(
455
+ (spec) => seedCredentialsOne(backend, handle, spec, opts).catch((err) => {
456
+ log(
457
+ `${spec.kind}: credentials seed failed (continuing): ${err instanceof Error ? err.message : String(err)}`
458
+ );
459
+ })
460
+ )
461
+ );
462
+ }
463
+ async function ensureAgentHomeDirsOwned(backend, handle, opts = {}) {
464
+ const log = opts.onLog ?? (() => {
465
+ });
466
+ const paths = AGENT_SPECS.map((s) => s.staticMountPath).join(" ");
467
+ try {
468
+ await backend.exec(
469
+ handle,
470
+ `sudo -n chown -R vscode:vscode ${paths} 2>/dev/null || true`
471
+ );
472
+ } catch (err) {
473
+ log(
474
+ `agent home-dir ownership normalize failed (continuing): ${err instanceof Error ? err.message : String(err)}`
475
+ );
476
+ }
477
+ }
478
+ async function refreshAgentCredentialsBackup(opts = {}) {
479
+ const log = opts.onLog ?? (() => {
480
+ });
481
+ if (!await hostClaudeBackupExpired()) {
482
+ return;
483
+ }
484
+ log("claude: host credentials backup expired \u2014 refreshing from docker shared volume");
485
+ const image = DEFAULT_BOX_IMAGE;
486
+ try {
487
+ const r = await syncClaudeCredentials({ volume: SHARED_CLAUDE_VOLUME }, { image, isolate: false });
488
+ if (r.direction === "extracted") {
489
+ log("claude: refreshed host credentials backup from docker shared volume");
490
+ } else if (r.direction === "noop") {
491
+ log("claude: no docker shared volume to refresh from (continuing with existing backup)");
492
+ }
493
+ } catch {
494
+ }
495
+ try {
496
+ await extractCodexCredentials(SHARED_CODEX_VOLUME, image);
497
+ } catch {
498
+ }
499
+ try {
500
+ await extractOpencodeCredentials(SHARED_OPENCODE_VOLUME, image);
501
+ } catch {
502
+ }
503
+ }
504
+ async function seedCredentialsOne(backend, handle, spec, opts) {
505
+ const log = opts.onLog ?? (() => {
506
+ });
507
+ const hasVolume = typeof backend.ensureVolume === "function";
508
+ if (hasVolume && !opts.force) {
509
+ const probe = await backend.exec(
510
+ handle,
511
+ `test -f ${spec.credentialsMountPath}/${SEED_MARKER}`
512
+ );
513
+ if (probe.exitCode === 0) {
514
+ log(`${spec.kind}: credentials already seeded \u2014 mounting only`);
515
+ return;
516
+ }
517
+ }
518
+ log(`${spec.kind}: staging host credentials`);
519
+ const staged = await spec.stageCredentials();
520
+ for (const w of staged.warnings) log(w);
521
+ try {
522
+ if (staged.tarballPath === null) {
523
+ log(`${spec.kind}: no credentials to seed`);
524
+ return;
525
+ }
526
+ let tarSize = 0;
527
+ try {
528
+ const { statSync: statSync2 } = await import("fs");
529
+ tarSize = statSync2(staged.tarballPath).size;
530
+ } catch {
531
+ }
532
+ const sizeKB = (tarSize / 1024).toFixed(1);
533
+ log(`${spec.kind}: uploading ${sizeKB} KB credentials tarball`);
534
+ const t0 = Date.now();
535
+ const remoteTar = `/tmp/agentbox-${spec.kind}-creds.tar.gz`;
536
+ try {
537
+ await backend.uploadFile(handle, staged.tarballPath, remoteTar);
538
+ } catch (err) {
539
+ const msg = `${spec.kind}: credentials upload failed (${err instanceof Error ? err.message : String(err)}); agent falls back to interactive login`;
540
+ log(msg);
541
+ return;
542
+ }
543
+ const upDt = ((Date.now() - t0) / 1e3).toFixed(1);
544
+ log(`${spec.kind}: upload done in ${upDt}s`);
545
+ const extractCmd = hasVolume ? (
546
+ // Daytona volumes are S3-backed FUSE and reject chmod/utime. The
547
+ // credentials payload is one small file, so we extract straight into
548
+ // the mount with `cp` (not tar — tar would chmod the parent dir during
549
+ // delayed-set-stat and abort with EPERM). Two-step: tar into a local-fs
550
+ // staging dir, then cp the file across. Marker tracks idempotency.
551
+ (() => {
552
+ const stageDir = `/tmp/agentbox-creds-stage-${spec.kind}`;
553
+ return `set -e; rm -rf ${stageDir}; mkdir -p ${stageDir}; tar -xzf ${remoteTar} -C ${stageDir}; cp -r ${stageDir}/. ${spec.credentialsMountPath}/; rm -rf ${stageDir}; date -u +%FT%TZ > ${spec.credentialsMountPath}/${SEED_MARKER}; rm -f ${remoteTar}`;
554
+ })()
555
+ ) : (
556
+ // Ephemeral FS: extract straight into the box-baked `~/.agentbox-creds/
557
+ // <agent>/` dir. `sudo -u vscode` ensures the on-disk file ends up
558
+ // vscode-owned regardless of which user `backend.exec` runs as
559
+ // (e2b: vscode, vercel: vscode, hetzner: vscode via ssh — sudo
560
+ // works on all three because vscode has passwordless sudo). The
561
+ // `--no-same-permissions --no-same-owner -m` flags mirror what
562
+ // vercel/hetzner did in their old custom pushers.
563
+ `set -e; sudo -u vscode mkdir -p ${spec.credentialsMountPath}; sudo -u vscode tar -xzf ${remoteTar} -C ${spec.credentialsMountPath} --no-same-permissions --no-same-owner -m; rm -f ${remoteTar}`
564
+ );
565
+ const extract = await backend.exec(handle, extractCmd);
566
+ if (extract.exitCode !== 0) {
567
+ const msg = `${spec.kind}: credentials extract failed (exit ${String(extract.exitCode)}); agent falls back to interactive login. stdout: ${extract.stdout.slice(-200)} stderr: ${extract.stderr.slice(-200)}`;
568
+ log(msg);
569
+ return;
570
+ }
571
+ log(`${spec.kind}: credentials seeded`);
572
+ } finally {
573
+ await staged.cleanup();
574
+ }
575
+ }
576
+ var OPENCODE_STATE_DIR = "/home/vscode/.local/state/opencode";
577
+ async function seedOpencodeModelState(backend, handle, opts = {}) {
578
+ const log = opts.onLog ?? (() => {
579
+ });
580
+ const staged = await stageOpencodeStateForUpload();
581
+ if (staged.tarballPath === null) {
582
+ log("opencode: no host model selection to seed");
583
+ return;
584
+ }
585
+ try {
586
+ const remoteTar = "/tmp/agentbox-opencode-state.tar.gz";
587
+ await backend.uploadFile(handle, staged.tarballPath, remoteTar);
588
+ const res = await backend.exec(
589
+ handle,
590
+ `set -e; mkdir -p ${OPENCODE_STATE_DIR}; tar -xzf ${remoteTar} -C ${OPENCODE_STATE_DIR}; chown -R vscode:vscode ${OPENCODE_STATE_DIR} 2>/dev/null || true; rm -f ${remoteTar}`
591
+ );
592
+ if (res.exitCode !== 0) {
593
+ log(
594
+ `opencode: model-state seed failed (exit ${String(res.exitCode)}); box falls back to OpenCode's default model. stderr: ${res.stderr.slice(-200)}`
595
+ );
596
+ return;
597
+ }
598
+ log("opencode: model selection seeded \u2713");
599
+ } finally {
600
+ await staged.cleanup();
601
+ }
602
+ }
603
+ async function extractCloudAgentCredentials(backend, handle, opts = {}) {
604
+ const transport = createCloudSyncTransport({ backend, handle });
605
+ return extractCredentials(transport, { onLog: opts.onLog, backups: opts.backups });
606
+ }
607
+ function sq(p) {
608
+ return `'${p.replace(/'/g, `'\\''`)}'`;
609
+ }
610
+ var REMOTE_TAR = "/tmp/agentbox-dynsync.tar.gz";
611
+ var BOX_STAGE = "/tmp/agentbox-dynsync-stage";
612
+ async function seedDynamicConfig(backend, handle, opts) {
613
+ const log = opts.onLog ?? (() => {
614
+ });
615
+ try {
616
+ let boxManifest = null;
617
+ try {
618
+ const res = await backend.exec(handle, `cat ${BOX_DYNAMIC_SYNC_MANIFEST} 2>/dev/null || true`);
619
+ const out = res.stdout.trim();
620
+ if (res.exitCode === 0 && out.length > 0) {
621
+ boxManifest = JSON.parse(out);
622
+ }
623
+ } catch {
624
+ boxManifest = null;
625
+ }
626
+ const host = await buildHostSyncManifest(opts.workspacePath);
627
+ const delta = computeSyncDelta(host, boxManifest);
628
+ if (delta.uploads.length === 0 && delta.deletions.length === 0) {
629
+ log("claude workflows + memory already up to date in box");
630
+ return;
631
+ }
632
+ delta.nextManifest.syncedAt = (/* @__PURE__ */ new Date()).toISOString();
633
+ const staged = await stageDynamicSyncTarball(delta.uploads);
634
+ const manifestDir = await mkdtemp3(join3(tmpdir3(), "agentbox-dynsync-manifest-"));
635
+ const manifestTmp = join3(manifestDir, "dynamic-sync.json");
636
+ await writeFile2(manifestTmp, JSON.stringify(delta.nextManifest, null, 2));
637
+ try {
638
+ const steps = [
639
+ "set -e",
640
+ `mkdir -p /home/vscode/.agentbox ${BOX_WORKFLOWS_DIR} ${BOX_MEMORY_DIR}`
641
+ ];
642
+ if (staged.tarballPath) {
643
+ await backend.uploadFile(handle, staged.tarballPath, REMOTE_TAR);
644
+ steps.push(
645
+ `rm -rf ${BOX_STAGE}`,
646
+ `mkdir -p ${BOX_STAGE}`,
647
+ `tar -xzf ${REMOTE_TAR} -C ${BOX_STAGE}`,
648
+ `if [ -d ${BOX_STAGE}/workflows ]; then cp -a ${BOX_STAGE}/workflows/. ${BOX_WORKFLOWS_DIR}/; fi`,
649
+ `if [ -d ${BOX_STAGE}/memory ]; then cp -a ${BOX_STAGE}/memory/. ${BOX_MEMORY_DIR}/; fi`,
650
+ `rm -rf ${BOX_STAGE} ${REMOTE_TAR}`
651
+ );
652
+ }
653
+ for (const d of delta.deletions) {
654
+ steps.push(`rm -f ${sq(d.dst)}`);
655
+ }
656
+ const res = await backend.exec(handle, steps.join("; "));
657
+ if (res.exitCode !== 0) {
658
+ log(
659
+ `dynamic config seed failed (exit ${String(res.exitCode)}): ${res.stderr.slice(-200)}`
660
+ );
661
+ return;
662
+ }
663
+ await backend.uploadFile(handle, manifestTmp, BOX_DYNAMIC_SYNC_MANIFEST);
664
+ log(
665
+ `seeded claude workflows + memory: ${String(delta.uploads.length)} file(s) updated, ${String(delta.deletions.length)} removed`
666
+ );
667
+ } finally {
668
+ await staged.cleanup();
669
+ await rm3(dirname(manifestTmp), { recursive: true, force: true });
670
+ }
671
+ } catch (err) {
672
+ log(
673
+ `claude workflows + memory seed skipped (non-fatal): ${err instanceof Error ? err.message : String(err)}`
674
+ );
675
+ }
676
+ }
677
+ var BOX_CODEX_HOME = "/home/vscode/.codex";
678
+ async function ensureCodexAgentsOverride(backend, handle, opts = {}) {
679
+ const log = opts.onLog ?? (() => {
680
+ });
681
+ const script = buildCodexAgentsOverrideScript(BOX_CODEX_HOME) + `
682
+ chown vscode:vscode "$OVR" 2>/dev/null || true
683
+ chmod 0644 "$OVR" 2>/dev/null || true`;
684
+ try {
685
+ const res = await backend.exec(handle, script);
686
+ if (res.exitCode !== 0)
687
+ log(
688
+ `codex AGENTS.override seed failed (continuing): exit ${res.exitCode}${res.stderr.trim() ? `: ${res.stderr.trim()}` : ""}`
689
+ );
690
+ else if (res.stdout.includes(CODEX_OVERRIDE_WROTE_MARKER))
691
+ log("seeded Codex AGENTS.override.md");
692
+ else log("codex AGENTS.override skipped: box-facts file absent");
693
+ } catch (err) {
694
+ log(
695
+ `codex AGENTS.override seed failed (continuing): ${err instanceof Error ? err.message : String(err)}`
696
+ );
697
+ }
698
+ }
699
+ var REMOTE_TAR2 = "/tmp/agentbox-claude-json.tar.gz";
700
+ var BOX_CLAUDE_DIR = "/home/vscode/.claude";
701
+ async function seedClaudeJsonAtCreate(backend, handle, opts = {}) {
702
+ const log = opts.onLog ?? (() => {
703
+ });
704
+ let staged = null;
705
+ try {
706
+ staged = await stageClaudeJsonOnlyForUpload({ hostWorkspace: opts.hostWorkspace });
707
+ if (staged.tarballPath === null) {
708
+ log("claude: no _claude.json overlay (host has no claude config)");
709
+ return;
710
+ }
711
+ await backend.uploadFile(handle, staged.tarballPath, REMOTE_TAR2);
712
+ const extract = await backend.exec(
713
+ handle,
714
+ `set -e; mkdir -p ${BOX_CLAUDE_DIR}; tar -xzf ${REMOTE_TAR2} -C ${BOX_CLAUDE_DIR}; rm -f ${REMOTE_TAR2}`
715
+ );
716
+ if (extract.exitCode !== 0) {
717
+ log(
718
+ `claude: _claude.json overlay extract failed (exit ${String(extract.exitCode)}); stderr: ${extract.stderr.slice(-200)}`
719
+ );
720
+ return;
721
+ }
722
+ log("claude: _claude.json overlay seeded");
723
+ } catch (err) {
724
+ log(
725
+ `claude: _claude.json overlay failed (continuing): ${err instanceof Error ? err.message : String(err)}`
726
+ );
727
+ } finally {
728
+ if (staged) await staged.cleanup();
729
+ }
730
+ }
731
+ var FALLBACK_NAME = "agentbox";
732
+ var FALLBACK_EMAIL = "agentbox@users.noreply.github.com";
733
+ async function seedGitIdentity(backend, handle, opts = {}) {
734
+ const log = opts.onLog ?? (() => {
735
+ });
736
+ const name = await readHostGitConfig("user.name", opts.hostRepo) ?? FALLBACK_NAME;
737
+ const email = await readHostGitConfig("user.email", opts.hostRepo) ?? FALLBACK_EMAIL;
738
+ const script = `git config --global user.name ${quoteShellArg(name)} && git config --global user.email ${quoteShellArg(email)}`;
739
+ const r = await backend.exec(handle, bashScript(script));
740
+ if (r.exitCode !== 0) {
741
+ log(`git: identity config failed (exit ${String(r.exitCode)}): ${(r.stderr || r.stdout).trim()}`);
742
+ return;
743
+ }
744
+ log(`git: configured committer identity ${name} <${email}>`);
745
+ }
746
+ async function readHostGitConfig(key, hostRepo) {
747
+ const args = hostRepo ? ["-C", hostRepo, "config", key] : ["config", key];
748
+ const r = await execa("git", args, { reject: false });
749
+ if (r.exitCode !== 0) return null;
750
+ const value = (r.stdout ?? "").trim();
751
+ return value.length > 0 ? value : null;
752
+ }
753
+ async function uploadEnvFiles(args) {
754
+ if (args.files.length === 0) return { copied: 0 };
755
+ const ctx = makeSyncContext({
756
+ boxName: "",
757
+ boxId: "",
758
+ provider: "cloud",
759
+ hostWorkspace: args.workspacePath,
760
+ boxWorkspace: args.workspaceDir ?? "/workspace",
761
+ onLog: args.onLog
762
+ });
763
+ const transport = createCloudSyncTransport({ backend: args.backend, handle: args.handle });
764
+ return pushEnvFiles(ctx, transport, args.files);
765
+ }
766
+ async function uploadCarryPaths(args) {
767
+ const log = args.onLog ?? (() => {
768
+ });
769
+ if (args.entries.length === 0) {
770
+ return { copied: 0, errors: [], applied: [] };
771
+ }
772
+ const stage = await mkdtemp4(join4(tmpdir4(), "agentbox-carry-"));
773
+ const errors = [];
774
+ const applied = [];
775
+ let copied = 0;
776
+ try {
777
+ for (const [i, entry] of args.entries.entries()) {
778
+ const where = `carry[${String(i)}] "${entry.rawSrc}"`;
779
+ if (entry.kind === "missing") {
780
+ log(`${where}: skipped (missing on host, optional)`);
781
+ continue;
782
+ }
783
+ try {
784
+ await uploadOneEntry({
785
+ backend: args.backend,
786
+ handle: args.handle,
787
+ entry,
788
+ stageDir: stage,
789
+ index: i
790
+ });
791
+ copied += 1;
792
+ applied.push({ src: entry.absSrc, dest: entry.absDest, bytes: entry.bytes ?? 0 });
793
+ } catch (err) {
794
+ const msg = err instanceof Error ? err.message : String(err);
795
+ errors.push(`${where}: ${msg}`);
796
+ log(`${where}: failed: ${msg}`);
797
+ }
798
+ }
799
+ } finally {
800
+ await rm4(stage, { recursive: true, force: true });
801
+ }
802
+ return { copied, errors, applied };
803
+ }
804
+ async function uploadOneEntry(args) {
805
+ const { entry } = args;
806
+ const plan = planCarryEntry(entry);
807
+ if (!plan) return;
808
+ const { boxDest, isDir, parentDir, exclude, uid, mode, fileBase, renameNeeded } = plan;
809
+ const localTar = join4(args.stageDir, `carry-${String(args.index)}.tar`);
810
+ const excludeArgs = isDir ? exclude.map((p) => `--exclude=${p}`) : [];
811
+ const tarArgs = isDir ? ["-C", entry.absSrc, "-cf", localTar, ...excludeArgs, "."] : ["-C", dirnameUnix(entry.absSrc), "-cf", localTar, fileBase];
812
+ const packed = await execa("tar", tarArgs, { reject: false });
813
+ if (packed.exitCode !== 0) {
814
+ throw new Error(`tar pack failed: ${String(packed.stderr).slice(0, 300)}`);
815
+ }
816
+ const remoteTar = `/tmp/agentbox-carry-${String(args.index)}.tar`;
817
+ await args.backend.uploadFile(args.handle, localTar, remoteTar);
818
+ const parts = [
819
+ `mkdir -p ${shellQuote(parentDir)}`,
820
+ isDir ? `tar -xf ${remoteTar} -C ${shellQuote(boxDest)} --no-same-permissions --no-same-owner -m` : `tar -xf ${remoteTar} -C ${shellQuote(parentDir)} --no-same-permissions --no-same-owner -m`
821
+ ];
822
+ if (renameNeeded) {
823
+ parts.push(
824
+ `mv ${shellQuote(`${parentDir}/${fileBase}`)} ${shellQuote(boxDest)}`
825
+ );
826
+ }
827
+ if (mode) parts.push(`chmod -R ${mode} ${shellQuote(boxDest)}`);
828
+ parts.push(`chown -R ${String(uid)}:${String(uid)} ${shellQuote(boxDest)}`);
829
+ if (plan.parentChainNeeded) {
830
+ parts.push(
831
+ `parent=$(dirname ${shellQuote(boxDest)}); while [ "$parent" != "${BOX_HOME}" ] && [ "$parent" != "/" ]; do chown ${String(uid)}:${String(uid)} "$parent"; parent=$(dirname "$parent"); done`
832
+ );
833
+ }
834
+ parts.push(`rm -f ${remoteTar}`);
835
+ const cmd = parts.join(" && ");
836
+ const wantsRoot = args.backend.name === "vercel" || args.backend.name === "e2b";
837
+ const execOpts = wantsRoot ? { user: "root" } : void 0;
838
+ const res = await args.backend.exec(args.handle, cmd, execOpts);
839
+ if (res.exitCode !== 0) {
840
+ throw new Error(
841
+ `in-box extract failed (exit ${String(res.exitCode)}): ${(res.stderr || res.stdout).slice(-300)}`
842
+ );
843
+ }
844
+ }
845
+ function shellQuote(s) {
846
+ return `'${s.replace(/'/g, `'\\''`)}'`;
847
+ }
848
+ function makeCloudSync(backend, handle, opts = {}) {
849
+ if (process.env[SYNC_DRYRUN_ENV]) return dryRunProviderSync(backend.name);
850
+ return {
851
+ // Cloud live-box resync: pre-fetch the host commits into the box, then run
852
+ // the shared resync concern (merge + overlay, box wins; never reset --hard).
853
+ // See workspace-resync.ts. The provider's resyncWorkspace(box) re-derives the
854
+ // worktrees (detectGitRepos) + gates on hostSeeded before calling here.
855
+ async resyncWorkspace(ctx, worktrees) {
856
+ if (worktrees.length === 0) return { repos: [], hadConflicts: false };
857
+ const repos = await resyncCloudWorkspace(backend, handle, worktrees, ctx.onLog);
858
+ const hadConflicts = repos.some(
859
+ (r) => r.mergeConflicts.length > 0 || r.overlaySkipped.length > 0
860
+ );
861
+ return { repos, hadConflicts };
862
+ },
863
+ async seedAgentConfig(ctx) {
864
+ await ensureAgentHomeDirsOwned(backend, handle, { onLog: ctx.onLog });
865
+ await ensureCodexAgentsOverride(backend, handle, { onLog: ctx.onLog });
866
+ await seedOpencodeModelState(backend, handle, { onLog: ctx.onLog });
867
+ await seedClaudeJsonAtCreate(backend, handle, {
868
+ hostWorkspace: ctx.hostWorkspace,
869
+ onLog: ctx.onLog
870
+ });
871
+ await seedDynamicConfig(backend, handle, {
872
+ workspacePath: ctx.hostWorkspace,
873
+ onLog: ctx.onLog
874
+ });
875
+ },
876
+ async seedCredentials(ctx) {
877
+ await refreshAgentCredentialsBackup({ onLog: ctx.onLog });
878
+ const agents = opts.agents ?? [];
879
+ if (agents.length > 0) {
880
+ await seedAgentVolumesIfFresh(backend, handle, {
881
+ agents,
882
+ hostWorkspace: ctx.hostWorkspace,
883
+ onLog: ctx.onLog
884
+ });
885
+ }
886
+ },
887
+ extractCredentials() {
888
+ return extractCloudAgentCredentials(backend, handle);
889
+ },
890
+ async seedGitIdentity(ctx) {
891
+ await seedGitIdentity(backend, handle, {
892
+ hostRepo: ctx.hostWorkspace,
893
+ onLog: ctx.onLog
894
+ });
895
+ },
896
+ async seedEnvFiles(ctx, patterns) {
897
+ return uploadEnvFiles({
898
+ backend,
899
+ handle,
900
+ workspacePath: ctx.hostWorkspace,
901
+ files: patterns,
902
+ workspaceDir: ctx.boxWorkspace,
903
+ onLog: ctx.onLog
904
+ });
905
+ },
906
+ async applyCarry(ctx, entries) {
907
+ const rendered = await renderCarryEntries(
908
+ entries,
909
+ {
910
+ name: ctx.boxName,
911
+ id: ctx.boxId,
912
+ kind: "cloud",
913
+ hostWorkspace: ctx.hostWorkspace,
914
+ projectRoot: ctx.projectRoot
915
+ },
916
+ ctx.onLog
917
+ );
918
+ return uploadCarryPaths({ backend, handle, entries: rendered, onLog: ctx.onLog });
919
+ }
920
+ };
921
+ }
922
+ var CLOUD_CHECKPOINTS_ROOT = join5(homedir(), ".agentbox", "cloud-checkpoints");
923
+ var CLOUD_SNAPSHOT_NAME_PREFIX = "agentbox-ckpt-";
924
+ function cloudSnapshotName(projectRoot, name) {
925
+ const mnemonic = sanitizeMnemonic(basename(projectRoot));
926
+ return `${CLOUD_SNAPSHOT_NAME_PREFIX}${hashProjectPath(projectRoot)}_${mnemonic}-${name}`;
927
+ }
928
+ function backendDir(backend, projectRoot) {
929
+ return join5(CLOUD_CHECKPOINTS_ROOT, backend, projectDirSegment(projectRoot));
930
+ }
931
+ function checkpointDir(backend, projectRoot, name) {
932
+ return join5(backendDir(backend, projectRoot), name);
933
+ }
934
+ async function readManifest(dir) {
935
+ try {
936
+ const raw = await readFile(join5(dir, "manifest.json"), "utf8");
937
+ const m = JSON.parse(raw);
938
+ if (m.schema !== 1 && m.schema !== 2) return null;
939
+ return m;
940
+ } catch {
941
+ return null;
942
+ }
943
+ }
944
+ async function listCloudCheckpointsInDir(root) {
945
+ let entries;
946
+ try {
947
+ entries = (await readdir(root, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
948
+ } catch {
949
+ return [];
950
+ }
951
+ const out = [];
952
+ for (const name of entries) {
953
+ const dir = join5(root, name);
954
+ const manifest = await readManifest(dir);
955
+ if (manifest) out.push({ name, dir, manifest });
956
+ }
957
+ out.sort((a, b) => a.manifest.createdAt.localeCompare(b.manifest.createdAt));
958
+ return out;
959
+ }
960
+ async function listCloudCheckpoints(projectRoot, backend) {
961
+ return listCloudCheckpointsInDir(backendDir(backend, projectRoot));
962
+ }
963
+ async function resolveCloudCheckpoint(projectRoot, backend, ref) {
964
+ const dir = checkpointDir(backend, projectRoot, ref);
965
+ const manifest = await readManifest(dir);
966
+ if (!manifest) return null;
967
+ return { name: ref, dir, manifest };
968
+ }
969
+ async function writeCloudCheckpointManifest(projectRoot, backend, name, fields) {
970
+ const dir = checkpointDir(backend, projectRoot, name);
971
+ await mkdir(dir, { recursive: true });
972
+ const manifest = {
973
+ schema: 2,
974
+ name,
975
+ backend,
976
+ snapshotName: fields.snapshotName,
977
+ sourceBoxId: fields.sourceBoxId,
978
+ sourceBoxName: fields.sourceBoxName,
979
+ baseProvider: fields.baseProvider,
980
+ baseFingerprint: fields.baseFingerprint,
981
+ cliVersion: fields.cliVersion,
982
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
983
+ };
984
+ await writeFile3(join5(dir, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n", "utf8");
985
+ return { name, dir, manifest };
986
+ }
987
+ function currentCloudBaseFingerprint(provider) {
988
+ try {
989
+ const raw = readPreparedStateRaw(provider);
990
+ return raw?.base?.contextSha256;
991
+ } catch {
992
+ return void 0;
993
+ }
994
+ }
995
+ function baseFreshnessFromFingerprints(stored, live) {
996
+ if (!stored) return { state: "unprepared" };
997
+ if (!live) return { state: "unknown" };
998
+ if (stored !== live) {
999
+ return {
1000
+ state: "stale",
1001
+ reason: `baked runtime differs (base ${stored.slice(0, 12)}, current ${live.slice(0, 12)})`
1002
+ };
1003
+ }
1004
+ return { state: "fresh" };
1005
+ }
1006
+ async function removeCloudCheckpointDir(projectRoot, backend, name) {
1007
+ const dir = checkpointDir(backend, projectRoot, name);
1008
+ const existed = await readManifest(dir) !== null;
1009
+ if (!existed) return false;
1010
+ await rm5(dir, { recursive: true, force: true });
1011
+ return true;
1012
+ }
1013
+ function isSnapshotGoneError(err) {
1014
+ if (err === null || typeof err !== "object") return false;
1015
+ const e = err;
1016
+ const status = e.response?.status ?? e.status;
1017
+ if (status === 410) return true;
1018
+ const parts = [
1019
+ typeof e.json?.error?.message === "string" ? e.json.error.message : "",
1020
+ typeof e.message === "string" ? e.message : ""
1021
+ ];
1022
+ const msg = parts.join(" ").toLowerCase();
1023
+ return /snapshot[^.]*\b(expired|deleted|gone|not[ -]?found)\b/.test(msg) || msg.includes("expired or deleted");
1024
+ }
1025
+ async function readExposedServicePorts(workspacePath) {
1026
+ let text;
1027
+ try {
1028
+ text = await readFile2(join6(workspacePath, "agentbox.yaml"), "utf8");
1029
+ } catch {
1030
+ return [];
1031
+ }
1032
+ let doc;
1033
+ try {
1034
+ doc = (0, import_yaml.parse)(text);
1035
+ } catch {
1036
+ return [];
1037
+ }
1038
+ if (!isPlainObject(doc)) return [];
1039
+ const services = doc["services"];
1040
+ if (!isPlainObject(services)) return [];
1041
+ const out = /* @__PURE__ */ new Set();
1042
+ for (const value of Object.values(services)) {
1043
+ if (!isPlainObject(value)) continue;
1044
+ const expose = value["expose"];
1045
+ if (!isPlainObject(expose)) continue;
1046
+ const port = expose["port"];
1047
+ if (typeof port === "number" && Number.isInteger(port) && port > 0 && port < 65536) {
1048
+ out.add(port);
1049
+ }
1050
+ }
1051
+ return [...out].sort((a, b) => a - b);
1052
+ }
1053
+ function isPlainObject(v) {
1054
+ return typeof v === "object" && v !== null && !Array.isArray(v);
1055
+ }
1056
+ var REMOTE_UP_TAR = "/tmp/agentbox-cp-up.tar.gz";
1057
+ var REMOTE_DOWN_TAR = "/tmp/agentbox-cp-down.tar.gz";
1058
+ var BOX_HOME2 = "/home/vscode";
1059
+ async function uploadOneToCloudBox(backend, handle, hostSrc, boxDst, exclude) {
1060
+ const srcAbs = hostResolve(hostSrc);
1061
+ if (!existsSync(srcAbs)) throw new Error(`source not found: ${hostSrc}`);
1062
+ const srcBasename = hostBasename(srcAbs);
1063
+ const srcParent = hostDirname(srcAbs);
1064
+ let boxParent;
1065
+ let finalName;
1066
+ if (boxDst.endsWith("/")) {
1067
+ boxParent = boxDst.replace(/\/+$/, "") || "/";
1068
+ finalName = srcBasename;
1069
+ } else {
1070
+ boxParent = posix.dirname(boxDst);
1071
+ finalName = posix.basename(boxDst);
1072
+ }
1073
+ const finalPath = boxParent === "/" ? `/${finalName}` : `${boxParent}/${finalName}`;
1074
+ const stage = await mkdtemp5(hostJoin(tmpdir5(), "agentbox-cp-up-"));
1075
+ const localTar = hostJoin(stage, "payload.tar.gz");
1076
+ try {
1077
+ const excludeArgs = (exclude ?? []).map((p) => `--exclude=${p}`);
1078
+ await execa("tar", ["-C", srcParent, "-czf", localTar, ...excludeArgs, srcBasename], {
1079
+ env: { ...process.env, COPYFILE_DISABLE: "1" }
1080
+ });
1081
+ await backend.uploadFile(handle, localTar, REMOTE_UP_TAR);
1082
+ const initialPath = boxParent === "/" ? `/${srcBasename}` : `${boxParent}/${srcBasename}`;
1083
+ const renameStep = finalName !== srcBasename ? `$SUDO cp -f ${quoteShellArg(initialPath)} ${quoteShellArg(finalPath)} && $SUDO rm -f ${quoteShellArg(initialPath)}` : ": # no rename";
1084
+ const underHome = finalPath.startsWith(BOX_HOME2 + "/");
1085
+ const parentWalk = underHome ? `parent=$(dirname ${quoteShellArg(finalPath)}); while [ "$parent" != ${quoteShellArg(BOX_HOME2)} ] && [ "$parent" != "/" ]; do $SUDO chown "$(id -un):$(id -gn)" "$parent" || true; parent=$(dirname "$parent"); done` : `: # dest outside ${BOX_HOME2}; leave parent ownership untouched`;
1086
+ const script = [
1087
+ `set -euo pipefail`,
1088
+ `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`,
1089
+ `$SUDO mkdir -p ${quoteShellArg(boxParent)}`,
1090
+ // --no-same-permissions / --no-same-owner / -m: Daytona's S3-backed
1091
+ // FUSE volumes reject chmod/utime/chown; skipping them lets the extract
1092
+ // complete on a mounted-volume destination. Harmless no-op on the
1093
+ // sandbox's regular disk. Same flags as the credential-seed extract.
1094
+ `$SUDO tar -xzf ${quoteShellArg(REMOTE_UP_TAR)} -C ${quoteShellArg(boxParent)} --no-same-permissions --no-same-owner -m`,
1095
+ renameStep,
1096
+ // chown the landed subtree, then the parent chain back up to $HOME.
1097
+ // Tolerate failure (chown bad on read-only / FUSE mounts).
1098
+ `$SUDO chown -R "$(id -un):$(id -gn)" ${quoteShellArg(finalPath)} || true`,
1099
+ parentWalk,
1100
+ `rm -f ${quoteShellArg(REMOTE_UP_TAR)}`
1101
+ ].join("\n");
1102
+ const r = await backend.exec(handle, bashScript(script));
1103
+ if (r.exitCode !== 0) {
1104
+ throw new Error(`cloud upload extract failed: ${r.stderr || r.stdout}`);
1105
+ }
1106
+ } finally {
1107
+ await rm6(stage, { recursive: true, force: true });
1108
+ }
1109
+ return { finalPath };
1110
+ }
1111
+ async function pullCloudDirContents(backend, handle, boxSrcDir, hostDstDir) {
1112
+ const dstAbs = hostResolve(hostDstDir);
1113
+ mkdirSync(dstAbs, { recursive: true });
1114
+ const stage = await mkdtemp5(hostJoin(tmpdir5(), "agentbox-pull-"));
1115
+ const localTar = hostJoin(stage, "payload.tar.gz");
1116
+ try {
1117
+ const packScript = [
1118
+ `set -euo pipefail`,
1119
+ `cd ${quoteShellArg(boxSrcDir)}`,
1120
+ `tar -czf ${quoteShellArg(REMOTE_DOWN_TAR)} .`
1121
+ ].join("\n");
1122
+ const r = await backend.exec(handle, bashScript(packScript));
1123
+ if (r.exitCode !== 0) {
1124
+ throw new Error(`cloud workspace pack failed: ${r.stderr || r.stdout}`);
1125
+ }
1126
+ await backend.downloadFile(handle, REMOTE_DOWN_TAR, localTar);
1127
+ await execa("tar", ["-xzf", localTar, "-C", dstAbs]);
1128
+ await backend.exec(handle, `rm -f ${quoteShellArg(REMOTE_DOWN_TAR)}`).catch(() => {
1129
+ });
1130
+ } finally {
1131
+ await rm6(stage, { recursive: true, force: true });
1132
+ }
1133
+ return { finalPath: dstAbs };
1134
+ }
1135
+ async function downloadOneFromCloudBox(backend, handle, boxSrc, hostDst, exclude) {
1136
+ const srcBasename = posix.basename(boxSrc);
1137
+ const srcParent = posix.dirname(boxSrc);
1138
+ const dstAbs = hostResolve(hostDst);
1139
+ let hostParent;
1140
+ let finalName;
1141
+ const dstExists = existsSync(dstAbs);
1142
+ if (hostDst.endsWith("/") || dstExists && statSync(dstAbs).isDirectory()) {
1143
+ hostParent = dstAbs;
1144
+ finalName = srcBasename;
1145
+ } else {
1146
+ hostParent = hostDirname(dstAbs);
1147
+ finalName = hostBasename(dstAbs);
1148
+ }
1149
+ mkdirSync(hostParent, { recursive: true });
1150
+ const finalPath = hostJoin(hostParent, finalName);
1151
+ const stage = await mkdtemp5(hostJoin(tmpdir5(), "agentbox-cp-down-"));
1152
+ const localTar = hostJoin(stage, "payload.tar.gz");
1153
+ try {
1154
+ const excludeArgs = (exclude ?? []).map((p) => `--exclude=${quoteShellArg(p)}`).join(" ");
1155
+ const packScript = [
1156
+ `set -euo pipefail`,
1157
+ `cd ${quoteShellArg(srcParent)}`,
1158
+ `tar -czf ${quoteShellArg(REMOTE_DOWN_TAR)} ${excludeArgs} ${quoteShellArg(srcBasename)}`
1159
+ ].join("\n");
1160
+ const r = await backend.exec(handle, bashScript(packScript));
1161
+ if (r.exitCode !== 0) {
1162
+ throw new Error(`cloud download pack failed: ${r.stderr || r.stdout}`);
1163
+ }
1164
+ await backend.downloadFile(handle, REMOTE_DOWN_TAR, localTar);
1165
+ await execa("tar", ["-xzf", localTar, "-C", hostParent]);
1166
+ if (finalName !== srcBasename) {
1167
+ renameSync(hostJoin(hostParent, srcBasename), finalPath);
1168
+ }
1169
+ await backend.exec(handle, `rm -f ${quoteShellArg(REMOTE_DOWN_TAR)}`).catch(() => {
1170
+ });
1171
+ } finally {
1172
+ await rm6(stage, { recursive: true, force: true });
1173
+ }
1174
+ return { finalPath };
1175
+ }
1176
+ async function uploadToCloudBox(backend, handle, hostSrcs, boxDst, exclude) {
1177
+ if (hostSrcs.length === 1) {
1178
+ return uploadOneToCloudBox(backend, handle, hostSrcs[0], boxDst, exclude);
1179
+ }
1180
+ if (!boxDst.endsWith("/")) {
1181
+ throw new Error(
1182
+ `cannot copy multiple sources to '${boxDst}': destination is not a directory (add a trailing slash, e.g. ${boxDst}/)`
1183
+ );
1184
+ }
1185
+ for (const src of hostSrcs) {
1186
+ await uploadOneToCloudBox(backend, handle, src, boxDst, exclude);
1187
+ }
1188
+ return { finalPath: boxDst };
1189
+ }
1190
+ async function downloadFromCloudBox(backend, handle, boxSrcs, hostDst, exclude) {
1191
+ if (boxSrcs.length === 1) {
1192
+ return downloadOneFromCloudBox(backend, handle, boxSrcs[0], hostDst, exclude);
1193
+ }
1194
+ const dstAbs = hostResolve(hostDst);
1195
+ const dstExists = existsSync(dstAbs);
1196
+ if (!hostDst.endsWith("/") && !(dstExists && statSync(dstAbs).isDirectory())) {
1197
+ throw new Error(
1198
+ `cannot copy multiple sources to '${hostDst}': destination is not a directory (add a trailing slash, e.g. ${hostDst}/)`
1199
+ );
1200
+ }
1201
+ mkdirSync(dstAbs, { recursive: true });
1202
+ for (const src of boxSrcs) {
1203
+ await downloadOneFromCloudBox(backend, handle, src, dstAbs, exclude);
1204
+ }
1205
+ return { finalPath: dstAbs };
1206
+ }
1207
+ function buildBootstrapEnv(args) {
1208
+ const env = [
1209
+ `AGENTBOX_BOX_ID=${quoteShellArgv([args.boxId])}`,
1210
+ `AGENTBOX_BOX_NAME=${quoteShellArgv([args.boxName])}`,
1211
+ `AGENTBOX_BOX_KIND=cloud`,
1212
+ `AGENTBOX_LAUNCH_DOCKERD=${args.launchDockerd ? "1" : "0"}`
1213
+ ];
1214
+ if (args.relayUrl) env.push(`AGENTBOX_RELAY_URL=${quoteShellArgv([args.relayUrl])}`);
1215
+ if (args.relayToken) env.push(`AGENTBOX_RELAY_TOKEN=${quoteShellArgv([args.relayToken])}`);
1216
+ if (args.bridgeToken) env.push(`AGENTBOX_BRIDGE_TOKEN=${quoteShellArgv([args.bridgeToken])}`);
1217
+ if (args.webProxyPort !== void 0)
1218
+ env.push(`AGENTBOX_WEB_PROXY_PORT=${quoteShellArgv([String(args.webProxyPort)])}`);
1219
+ if (args.boxHost) env.push(`AGENTBOX_BOX_HOST=${quoteShellArgv([args.boxHost])}`);
1220
+ if (args.vncPassword) {
1221
+ env.push(`AGENTBOX_VNC_ENABLED=1`);
1222
+ env.push(`AGENTBOX_VNC_PASSWORD=${quoteShellArgv([args.vncPassword])}`);
1223
+ } else {
1224
+ env.push(`AGENTBOX_VNC_ENABLED=0`);
1225
+ }
1226
+ if (args.clone) {
1227
+ env.push(`AGENTBOX_CLONE_URL=${quoteShellArgv([args.clone.authedUrl])}`);
1228
+ env.push(`AGENTBOX_ORIGIN_URL=${quoteShellArgv([args.clone.originUrl])}`);
1229
+ if (args.clone.branch)
1230
+ env.push(`AGENTBOX_CLONE_BRANCH=${quoteShellArgv([args.clone.branch])}`);
1231
+ if (args.clone.depth !== void 0)
1232
+ env.push(`AGENTBOX_CLONE_DEPTH=${quoteShellArgv([String(args.clone.depth)])}`);
1233
+ }
1234
+ const boxEnvFile = [
1235
+ `AGENTBOX_BOX_ID=${quoteShellArgv([args.boxId])}`,
1236
+ `AGENTBOX_BOX_NAME=${quoteShellArgv([args.boxName])}`,
1237
+ `AGENTBOX_BOX_KIND=cloud`
1238
+ ];
1239
+ if (args.webProxyPort !== void 0)
1240
+ boxEnvFile.push(`AGENTBOX_WEB_PROXY_PORT=${quoteShellArgv([String(args.webProxyPort)])}`);
1241
+ if (args.boxHost) boxEnvFile.push(`AGENTBOX_BOX_HOST=${quoteShellArgv([args.boxHost])}`);
1242
+ if (args.controlPlaneUrl) {
1243
+ env.push(`AGENTBOX_CONTROL_PLANE_URL=${quoteShellArgv([args.controlPlaneUrl])}`);
1244
+ }
1245
+ const pushMode = args.gitPushMode ?? "auto";
1246
+ const lease = pushMode === "lease" || pushMode === "auto" && Boolean(args.controlPlaneUrl);
1247
+ if (lease) {
1248
+ boxEnvFile.push(`AGENTBOX_GIT_LEASE=1`);
1249
+ }
1250
+ return { env, boxEnvFile };
1251
+ }
1252
+ async function kickCloudBootstrap(args) {
1253
+ const { env, boxEnvFile } = buildBootstrapEnv(args);
1254
+ const script = [
1255
+ `set -e`,
1256
+ // /etc/agentbox is root-owned; the non-root sandbox user needs sudo to
1257
+ // write the login-shell env file (cloud bases grant vscode passwordless
1258
+ // sudo; root SSH boxes fall through with SUDO=''). Quoted heredoc → the
1259
+ // values (already shell-quoted for `set -a; . box.env`) land verbatim.
1260
+ `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`,
1261
+ `$SUDO mkdir -p /etc/agentbox`,
1262
+ `$SUDO tee /etc/agentbox/box.env >/dev/null <<'AGENTBOX_BOX_ENV_EOF'`,
1263
+ ...boxEnvFile,
1264
+ `AGENTBOX_BOX_ENV_EOF`,
1265
+ `export ${env.join(" ")}`,
1266
+ `/usr/local/bin/agentbox-ctl bootstrap`
1267
+ ].join("\n");
1268
+ const r = await args.backend.exec(args.handle, bashScript(script));
1269
+ if (r.stdout && args.onLog) {
1270
+ for (const line of r.stdout.split("\n")) if (line.trim()) args.onLog(line);
1271
+ }
1272
+ if (r.exitCode !== 0) {
1273
+ throw new Error(`agentbox-ctl bootstrap failed: ${r.stderr || r.stdout}`);
1274
+ }
1275
+ }
1276
+ async function readGitOriginUrl(workspacePath) {
1277
+ const r = await execa("git", ["-C", workspacePath, "remote", "get-url", "origin"], {
1278
+ reject: false
1279
+ });
1280
+ const url = (r.stdout ?? "").trim();
1281
+ return r.exitCode === 0 && url.length > 0 ? url : void 0;
1282
+ }
1283
+ async function registerBoxWithPlane(args) {
1284
+ const url = `${args.controlPlaneUrl.replace(/\/$/, "")}/admin/register-box`;
1285
+ const res = await fetch(url, {
1286
+ method: "POST",
1287
+ headers: {
1288
+ "Content-Type": "application/json",
1289
+ Authorization: `Bearer ${args.adminToken}`
1290
+ },
1291
+ body: JSON.stringify({
1292
+ boxId: args.boxId,
1293
+ token: args.token,
1294
+ name: args.name,
1295
+ kind: "cloud",
1296
+ backend: args.backend,
1297
+ originUrl: args.originUrl,
1298
+ bridgeToken: args.bridgeToken,
1299
+ previewUrl: args.previewUrl,
1300
+ previewToken: args.previewToken,
1301
+ createdAt: args.createdAt,
1302
+ projectIndex: args.projectIndex,
1303
+ autoApproveHostActions: args.autoApproveHostActions,
1304
+ autoApproveSafeHostActions: args.autoApproveSafeHostActions
1305
+ })
1306
+ });
1307
+ if (!res.ok) {
1308
+ const text = await res.text().catch(() => "");
1309
+ throw new Error(`plane register-box \u2192 ${String(res.status)}: ${text}`);
1310
+ }
1311
+ }
1312
+ var WORKSPACE_DIR_DEFAULT = "/workspace";
1313
+ async function seedCloudWorkspace(args) {
1314
+ const workspaceDir = args.workspaceDir ?? WORKSPACE_DIR_DEFAULT;
1315
+ const log = args.onLog ?? (() => {
1316
+ });
1317
+ const repos = await detectGitRepos(args.workspacePath);
1318
+ const root = repos.find((r) => r.kind === "root");
1319
+ const nested = repos.filter((r) => r.kind === "nested");
1320
+ if (!root && args.overlay) {
1321
+ log("checkpoint restore: non-git workspace \u2014 keeping snapshot /workspace as-is");
1322
+ return { fromGit: false, branch: args.branch };
1323
+ }
1324
+ if (root) {
1325
+ log(
1326
+ args.overlay ? nested.length > 0 ? `checkpoint restore: re-branching /workspace + ${String(nested.length)} nested repo${nested.length === 1 ? "" : "s"} (warm artifacts kept)` : "checkpoint restore: re-branching /workspace onto a fresh per-box branch (warm artifacts kept)" : nested.length > 0 ? `seeding /workspace from shallow git clone (+${String(nested.length)} nested repo${nested.length === 1 ? "" : "s"})` : "seeding /workspace from shallow git clone"
1327
+ );
1328
+ const resyncRepos = [];
1329
+ const rootConflicts = await reseedRepo({
1330
+ backend: args.backend,
1331
+ handle: args.handle,
1332
+ hostRepo: root.hostMainRepo,
1333
+ branch: args.branch,
1334
+ workspaceDir,
1335
+ bundleDepth: args.bundleDepth,
1336
+ fromBranch: args.fromBranch,
1337
+ useBranch: args.useBranch,
1338
+ overlay: args.overlay,
1339
+ skipCarryOver: args.skipCarryOver,
1340
+ onLog: log
1341
+ });
1342
+ if (args.overlay) resyncRepos.push({ containerPath: workspaceDir, ...rootConflicts });
1343
+ for (const r of nested) {
1344
+ const sub = `${workspaceDir}/${r.relPathFromWorkspace}`;
1345
+ log(`seeding nested repo ${r.relPathFromWorkspace} from shallow git clone`);
1346
+ const nestedConflicts = await reseedRepo({
1347
+ backend: args.backend,
1348
+ handle: args.handle,
1349
+ hostRepo: r.hostMainRepo,
1350
+ branch: args.branch,
1351
+ workspaceDir: sub,
1352
+ bundleDepth: args.bundleDepth,
1353
+ overlay: args.overlay,
1354
+ skipCarryOver: args.skipCarryOver,
1355
+ onLog: log
1356
+ });
1357
+ if (args.overlay) resyncRepos.push({ containerPath: sub, ...nestedConflicts });
1358
+ }
1359
+ const resync = args.overlay ? {
1360
+ repos: resyncRepos,
1361
+ hadConflicts: resyncRepos.some(
1362
+ (r) => r.mergeConflicts.length > 0 || r.overlaySkipped.length > 0
1363
+ )
1364
+ } : void 0;
1365
+ return { fromGit: true, branch: args.branch, resync };
1366
+ }
1367
+ log("seeding /workspace from workspace tarball (no git detected)");
1368
+ await seedFromTar({
1369
+ backend: args.backend,
1370
+ handle: args.handle,
1371
+ hostDir: args.workspacePath,
1372
+ workspaceDir
1373
+ });
1374
+ return { fromGit: false, branch: args.branch };
1375
+ }
1376
+ var STASH_CARRYOVER_REF = "refs/agentbox-carryover/stash";
1377
+ var REMOTE_UNTRACKED_TAR = "/tmp/agentbox-carryover-untracked.tar.gz";
1378
+ var MERGE_CONFLICT_MARKER = "__AGENTBOX_MERGE_CONFLICT__:";
1379
+ var OVERLAY_SKIP_MARKER = "__AGENTBOX_OVERLAY_SKIP__:";
1380
+ function parseSeedConflicts(stdout) {
1381
+ const merge = /* @__PURE__ */ new Set();
1382
+ const overlay = /* @__PURE__ */ new Set();
1383
+ for (const raw of stdout.split("\n")) {
1384
+ const line = raw.trim();
1385
+ if (line.startsWith(MERGE_CONFLICT_MARKER)) {
1386
+ const p = line.slice(MERGE_CONFLICT_MARKER.length).trim();
1387
+ if (p) merge.add(p);
1388
+ } else if (line.startsWith(OVERLAY_SKIP_MARKER)) {
1389
+ const p = line.slice(OVERLAY_SKIP_MARKER.length).trim();
1390
+ if (p) overlay.add(p);
1391
+ }
1392
+ }
1393
+ return { mergeConflicts: [...merge], overlaySkipped: [...overlay] };
1394
+ }
1395
+ function buildCarryOverSteps(opts) {
1396
+ const wd = quoteShellArgv([opts.workspaceDir]);
1397
+ const stashRef = quoteShellArgv(["refs/remotes/origin/agentbox-carryover/stash"]);
1398
+ const untracked = quoteShellArgv([REMOTE_UNTRACKED_TAR]);
1399
+ const steps = [];
1400
+ if (opts.hasStash) {
1401
+ steps.push(
1402
+ opts.detectConflicts ? `if git -C ${wd} rev-parse --verify ${stashRef} >/dev/null 2>&1; then if ! git -C ${wd} stash apply ${stashRef} >/dev/null 2>&1; then git -C ${wd} diff --name-only --diff-filter=U | while IFS= read -r p; do [ -n "$p" ] && echo "${MERGE_CONFLICT_MARKER}$p"; done || true ; git -C ${wd} checkout --ours -- . >/dev/null 2>&1 || true ; git -C ${wd} add -A >/dev/null 2>&1 || true ; fi ; git -C ${wd} update-ref -d ${stashRef} || true ; fi` : `if git -C ${wd} rev-parse --verify ${stashRef} >/dev/null 2>&1; then git -C ${wd} stash apply ${stashRef} || echo "agentbox: stash apply soft-failed; carry-over may be incomplete" >&2 ; git -C ${wd} update-ref -d ${stashRef} || true ; fi`
1403
+ );
1404
+ }
1405
+ if (opts.hasUntracked) {
1406
+ steps.push(
1407
+ opts.detectConflicts ? `if [ -f ${untracked} ]; then tar -tzf ${untracked} | while IFS= read -r p; do case "$p" in ''|*/) continue ;; esac; if [ -e ${wd}/"$p" ]; then echo "${OVERLAY_SKIP_MARKER}$p"; fi; done || true ; tar -C ${wd} --skip-old-files -xzf ${untracked} || true ; rm -f ${untracked} ; fi` : `if [ -f ${untracked} ]; then tar -C ${wd} -xzf ${untracked} && rm -f ${untracked} ; fi`
1408
+ );
1409
+ }
1410
+ return steps;
1411
+ }
1412
+ var DEFAULT_BUNDLE_DEPTH = 200;
1413
+ var LARGE_BUNDLE_DEPTH = 100;
1414
+ var LARGE_BUNDLE_THRESHOLD_BYTES = 20 * 1024 * 1024;
1415
+ async function reseedRepo(args) {
1416
+ if (args.overlay) {
1417
+ const delta = await tryReseedRepoDelta(args);
1418
+ if (delta) return delta;
1419
+ (args.onLog ?? (() => {
1420
+ }))(
1421
+ `checkpoint restore: ${args.workspaceDir}: delta not usable, falling back to full clone`
1422
+ );
1423
+ }
1424
+ return seedFromGitClone(args);
1425
+ }
1426
+ async function seedFromGitClone(args) {
1427
+ const log = args.onLog ?? (() => {
1428
+ });
1429
+ let conflicts = { mergeConflicts: [], overlaySkipped: [] };
1430
+ const stage = await mkdtemp6(join7(tmpdir6(), "agentbox-clone-"));
1431
+ const cloneDir = join7(stage, "clone");
1432
+ const tarPath = join7(stage, "workspace.tar.gz");
1433
+ const untrackedTarPath = join7(stage, "untracked.tar.gz");
1434
+ const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
1435
+ const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
1436
+ let stashRefCreated = false;
1437
+ try {
1438
+ if (stashSha) {
1439
+ const ref = await execa(
1440
+ "git",
1441
+ ["-C", args.hostRepo, "update-ref", STASH_CARRYOVER_REF, stashSha],
1442
+ { reject: false }
1443
+ );
1444
+ stashRefCreated = ref.exitCode === 0;
1445
+ }
1446
+ const configured = args.bundleDepth;
1447
+ const adaptive = configured === void 0;
1448
+ const initialDepth = adaptive ? DEFAULT_BUNDLE_DEPTH : configured === 0 ? null : configured;
1449
+ log(
1450
+ adaptive ? `clone: depth=${String(DEFAULT_BUNDLE_DEPTH)} (default, adaptive)` : initialDepth === null ? "clone: depth=full (configured)" : `clone: depth=${String(initialDepth)} (configured)`
1451
+ );
1452
+ const cloneBranch = args.useBranch ?? args.fromBranch;
1453
+ const lfsRef = cloneBranch ?? "HEAD";
1454
+ await runShallowClone(args.hostRepo, cloneDir, initialDepth, stashRefCreated, cloneBranch);
1455
+ await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
1456
+ await tarCloneDir(cloneDir, tarPath);
1457
+ if (adaptive && initialDepth !== null) {
1458
+ const size = await safeFileSize(tarPath);
1459
+ if (size > LARGE_BUNDLE_THRESHOLD_BYTES) {
1460
+ const mb = (size / (1024 * 1024)).toFixed(1);
1461
+ log(
1462
+ `clone tar exceeded ${String(LARGE_BUNDLE_THRESHOLD_BYTES / (1024 * 1024))} MB at depth ${String(DEFAULT_BUNDLE_DEPTH)} (${mb} MB), rebuilding at depth ${String(LARGE_BUNDLE_DEPTH)}`
1463
+ );
1464
+ await rm7(cloneDir, { recursive: true, force: true });
1465
+ await rm7(tarPath, { force: true });
1466
+ await runShallowClone(args.hostRepo, cloneDir, LARGE_BUNDLE_DEPTH, stashRefCreated, cloneBranch);
1467
+ await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
1468
+ await tarCloneDir(cloneDir, tarPath);
1469
+ }
1470
+ }
1471
+ const remoteUrl = await readOriginUrl(args.hostRepo);
1472
+ const remoteTar = "/tmp/agentbox-workspace.tar.gz";
1473
+ await args.backend.uploadFile(args.handle, tarPath, remoteTar);
1474
+ if (untrackedSize > 0) {
1475
+ await args.backend.uploadFile(args.handle, untrackedTarPath, REMOTE_UNTRACKED_TAR);
1476
+ }
1477
+ const setOrigin = remoteUrl ? `git -C ${quoteShellArgv([args.workspaceDir])} remote set-url origin ${quoteShellArgv([remoteUrl])}` : ": # no host origin to copy";
1478
+ const SUDO = `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`;
1479
+ const carryOverSteps = buildCarryOverSteps({
1480
+ workspaceDir: args.workspaceDir,
1481
+ hasStash: Boolean(stashSha),
1482
+ hasUntracked: untrackedSize > 0,
1483
+ // Conflict detection (box-wins + markers) only matters on a checkpoint
1484
+ // restore, where /workspace already has the snapshot's files to collide
1485
+ // with. A fresh seed checks out onto an empty tree — nothing to conflict.
1486
+ detectConflicts: Boolean(args.overlay)
1487
+ });
1488
+ const gitDir = `${args.workspaceDir}/.git`;
1489
+ const prepSteps = args.overlay ? [`$SUDO rm -rf ${quoteShellArgv([gitDir])}`] : [
1490
+ `$SUDO rm -rf ${quoteShellArgv([args.workspaceDir])}`,
1491
+ `$SUDO mkdir -p ${quoteShellArgv([args.workspaceDir])}`,
1492
+ `$SUDO chown "$(id -un):$(id -gn)" ${quoteShellArgv([args.workspaceDir])}`
1493
+ ];
1494
+ const checkoutSteps = args.overlay ? [
1495
+ args.useBranch ? `git -C ${quoteShellArgv([args.workspaceDir])} checkout -f ${quoteShellArgv([args.branch])}` : `git -C ${quoteShellArgv([args.workspaceDir])} checkout -f -B ${quoteShellArgv([args.branch])}`,
1496
+ `git -C ${quoteShellArgv([args.workspaceDir])} reset --hard HEAD`
1497
+ ] : [
1498
+ // reuse: the clone already landed on `<branch>` (pinned via
1499
+ // `--branch`); a plain checkout materializes the working tree without
1500
+ // resetting the ref. fork: `-B` (re)points `<branch>` at clone HEAD.
1501
+ args.useBranch ? `git -C ${quoteShellArgv([args.workspaceDir])} checkout ${quoteShellArgv([args.branch])}` : `git -C ${quoteShellArgv([args.workspaceDir])} checkout -B ${quoteShellArgv([args.branch])}`
1502
+ ];
1503
+ const script = [
1504
+ `set -euo pipefail`,
1505
+ // Move out of any cwd we might inherit from Daytona's executeCommand
1506
+ // before we delete /workspace. The agentbox image bakes WORKDIR
1507
+ // /workspace; if the shell's cwd is /workspace when we `rm -rf` it,
1508
+ // the next process inherits a stale cwd FD and tar's children fail
1509
+ // with "Unable to read current working directory".
1510
+ `cd /tmp`,
1511
+ SUDO,
1512
+ // Fresh: rm -rf only the dir we extract into (for nested repos that's
1513
+ // `/workspace/<rel>`, so the root clone is preserved). Overlay: rm only
1514
+ // `<dir>/.git`, preserving the warm working tree.
1515
+ ...prepSteps,
1516
+ `tar -C ${quoteShellArgv([args.workspaceDir])} -xzf ${quoteShellArgv([remoteTar])}`,
1517
+ setOrigin,
1518
+ ...checkoutSteps,
1519
+ ...carryOverSteps,
1520
+ `rm -f ${quoteShellArgv([remoteTar])}`
1521
+ ].join("\n");
1522
+ const r = await args.backend.exec(args.handle, bashScript(script));
1523
+ if (r.exitCode !== 0) {
1524
+ throw new Error(`workspace seed (clone) failed: ${r.stderr || r.stdout}`);
1525
+ }
1526
+ if (args.overlay) conflicts = parseSeedConflicts(r.stdout);
1527
+ } finally {
1528
+ if (stashRefCreated) {
1529
+ await execa("git", ["-C", args.hostRepo, "update-ref", "-d", STASH_CARRYOVER_REF], {
1530
+ reject: false
1531
+ });
1532
+ }
1533
+ await rm7(stage, { recursive: true, force: true });
1534
+ }
1535
+ return conflicts;
1536
+ }
1537
+ var DELTA_TARGET_REF = "refs/agentbox-delta/target";
1538
+ var REMOTE_DELTA_BUNDLE = "/tmp/agentbox-delta.bundle";
1539
+ var REMOTE_DELTA_LFS = "/tmp/agentbox-delta-lfs.tar.gz";
1540
+ var SHA_RE2 = /^[0-9a-f]{40}$/;
1541
+ async function tryReseedRepoDelta(args) {
1542
+ const log = args.onLog ?? (() => {
1543
+ });
1544
+ const wd = quoteShellArgv([args.workspaceDir]);
1545
+ const tipRes = await args.backend.exec(
1546
+ args.handle,
1547
+ bashScript(`git -C ${wd} rev-parse HEAD 2>/dev/null || true`)
1548
+ );
1549
+ const checkpointTip = tipRes.stdout.trim();
1550
+ if (!SHA_RE2.test(checkpointTip)) return null;
1551
+ const baseRef = args.useBranch ?? args.fromBranch ?? "HEAD";
1552
+ const targetRes = await execa("git", ["-C", args.hostRepo, "rev-parse", baseRef], {
1553
+ reject: false
1554
+ });
1555
+ const target = targetRes.stdout.trim();
1556
+ if (targetRes.exitCode !== 0 || !SHA_RE2.test(target)) return null;
1557
+ const hasTip = await execa(
1558
+ "git",
1559
+ ["-C", args.hostRepo, "cat-file", "-e", `${checkpointTip}^{commit}`],
1560
+ { reject: false }
1561
+ );
1562
+ if (hasTip.exitCode !== 0) return null;
1563
+ const ancestor = await execa(
1564
+ "git",
1565
+ ["-C", args.hostRepo, "merge-base", "--is-ancestor", checkpointTip, target],
1566
+ { reject: false }
1567
+ );
1568
+ if (ancestor.exitCode !== 0) return null;
1569
+ const stage = await mkdtemp6(join7(tmpdir6(), "agentbox-delta-"));
1570
+ const bundlePath = join7(stage, "delta.bundle");
1571
+ const untrackedTarPath = join7(stage, "untracked.tar.gz");
1572
+ const deltaLfsTarPath = join7(stage, "delta-lfs.tar.gz");
1573
+ const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
1574
+ const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
1575
+ let stashRefCreated = false;
1576
+ try {
1577
+ if (stashSha) {
1578
+ const ref = await execa(
1579
+ "git",
1580
+ ["-C", args.hostRepo, "update-ref", STASH_CARRYOVER_REF, stashSha],
1581
+ { reject: false }
1582
+ );
1583
+ stashRefCreated = ref.exitCode === 0;
1584
+ }
1585
+ const needTarget = target !== checkpointTip;
1586
+ if (needTarget) {
1587
+ await execa("git", ["-C", args.hostRepo, "update-ref", DELTA_TARGET_REF, target], {
1588
+ reject: false
1589
+ });
1590
+ }
1591
+ const bundleRefs = [];
1592
+ if (needTarget) bundleRefs.push(DELTA_TARGET_REF);
1593
+ if (stashRefCreated) bundleRefs.push(STASH_CARRYOVER_REF);
1594
+ let haveBundle = false;
1595
+ if (bundleRefs.length > 0) {
1596
+ const b = await execa(
1597
+ "git",
1598
+ ["-C", args.hostRepo, "bundle", "create", bundlePath, ...bundleRefs, `^${checkpointTip}`],
1599
+ { reject: false }
1600
+ );
1601
+ if (b.exitCode !== 0) return null;
1602
+ haveBundle = true;
1603
+ await args.backend.uploadFile(args.handle, bundlePath, REMOTE_DELTA_BUNDLE);
1604
+ }
1605
+ if (untrackedSize > 0) {
1606
+ await args.backend.uploadFile(args.handle, untrackedTarPath, REMOTE_UNTRACKED_TAR);
1607
+ }
1608
+ const deltaLfsSize = await maybeBuildDeltaLfsTar(
1609
+ args.hostRepo,
1610
+ target,
1611
+ checkpointTip,
1612
+ deltaLfsTarPath
1613
+ );
1614
+ if (deltaLfsSize > 0) {
1615
+ await args.backend.uploadFile(args.handle, deltaLfsTarPath, REMOTE_DELTA_LFS);
1616
+ log(
1617
+ `checkpoint restore: ${args.workspaceDir}: ${String(deltaLfsSize)} B of new git-lfs objects`
1618
+ );
1619
+ }
1620
+ log(
1621
+ needTarget ? `checkpoint restore: ${args.workspaceDir}: delta bundle (${checkpointTip.slice(0, 8)}..${target.slice(0, 8)})` : `checkpoint restore: ${args.workspaceDir}: no new host commits; re-branch + carry-over only`
1622
+ );
1623
+ const remoteUrl = await readOriginUrl(args.hostRepo);
1624
+ const setOrigin = remoteUrl ? `git -C ${wd} remote set-url origin ${quoteShellArgv([remoteUrl])}` : ": # no host origin to copy";
1625
+ const fetchRefspecs = [];
1626
+ if (needTarget) fetchRefspecs.push(`+${DELTA_TARGET_REF}:${DELTA_TARGET_REF}`);
1627
+ if (stashRefCreated)
1628
+ fetchRefspecs.push(`+${STASH_CARRYOVER_REF}:refs/remotes/origin/agentbox-carryover/stash`);
1629
+ const fetchStep = haveBundle && fetchRefspecs.length > 0 ? `git -C ${wd} fetch --no-tags ${quoteShellArgv([REMOTE_DELTA_BUNDLE])} ${fetchRefspecs.map((s) => quoteShellArgv([s])).join(" ")}` : ": # no delta bundle to fetch";
1630
+ const checkoutStep = args.useBranch ? `git -C ${wd} checkout -f ${quoteShellArgv([args.branch])}` : `git -C ${wd} checkout -f -B ${quoteShellArgv([args.branch])} ${quoteShellArgv([target])}`;
1631
+ const carryOverSteps = buildCarryOverSteps({
1632
+ workspaceDir: args.workspaceDir,
1633
+ hasStash: Boolean(stashSha),
1634
+ hasUntracked: untrackedSize > 0,
1635
+ detectConflicts: true
1636
+ });
1637
+ const lfsStep = deltaLfsSize > 0 ? `tar -C ${quoteShellArgv([`${args.workspaceDir}/.git`])} -xzf ${quoteShellArgv([REMOTE_DELTA_LFS])}` : ": # no delta lfs objects";
1638
+ const SUDO = `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`;
1639
+ const script = [
1640
+ `set -euo pipefail`,
1641
+ `cd /tmp`,
1642
+ SUDO,
1643
+ fetchStep,
1644
+ lfsStep,
1645
+ checkoutStep,
1646
+ `git -C ${wd} reset --hard ${quoteShellArgv([target])}`,
1647
+ setOrigin,
1648
+ ...carryOverSteps,
1649
+ `git -C ${wd} update-ref -d ${quoteShellArgv([DELTA_TARGET_REF])} || true`,
1650
+ `rm -f ${quoteShellArgv([REMOTE_DELTA_BUNDLE])} ${quoteShellArgv([REMOTE_DELTA_LFS])}`
1651
+ ].join("\n");
1652
+ const r = await args.backend.exec(args.handle, bashScript(script));
1653
+ if (r.exitCode !== 0) {
1654
+ log(`checkpoint restore: ${args.workspaceDir}: delta apply failed, falling back: ${r.stderr || r.stdout}`);
1655
+ return null;
1656
+ }
1657
+ return parseSeedConflicts(r.stdout);
1658
+ } finally {
1659
+ if (stashRefCreated) {
1660
+ await execa("git", ["-C", args.hostRepo, "update-ref", "-d", STASH_CARRYOVER_REF], {
1661
+ reject: false
1662
+ });
1663
+ }
1664
+ await execa("git", ["-C", args.hostRepo, "update-ref", "-d", DELTA_TARGET_REF], {
1665
+ reject: false
1666
+ });
1667
+ await rm7(stage, { recursive: true, force: true });
1668
+ }
1669
+ }
1670
+ async function runShallowClone(hostRepo, cloneDir, depth, includeStashRef, fromBranch) {
1671
+ const cloneArgs = ["clone", "--no-checkout", "--quiet"];
1672
+ if (depth !== null) cloneArgs.push(`--depth=${String(depth)}`);
1673
+ if (fromBranch) cloneArgs.push("--branch", fromBranch);
1674
+ cloneArgs.push(`file://${hostRepo}`, cloneDir);
1675
+ await execa("git", cloneArgs);
1676
+ if (includeStashRef) {
1677
+ const fetchArgs = ["-C", cloneDir, "fetch", "--quiet"];
1678
+ if (depth !== null) fetchArgs.push(`--depth=${String(depth)}`);
1679
+ fetchArgs.push(
1680
+ `file://${hostRepo}`,
1681
+ `+${STASH_CARRYOVER_REF}:refs/remotes/origin/agentbox-carryover/stash`
1682
+ );
1683
+ await execa("git", fetchArgs, { reject: false });
1684
+ }
1685
+ }
1686
+ async function tarCloneDir(cloneDir, outPath) {
1687
+ await execa("tar", ["-C", cloneDir, "-czf", outPath, "."], {
1688
+ env: { ...process.env, COPYFILE_DISABLE: "1" }
1689
+ });
1690
+ }
1691
+ var LFS_OID_RE = /^[0-9a-f]{64}$/;
1692
+ function lfsObjectRelPath(oid) {
1693
+ return join7("lfs", "objects", oid.slice(0, 2), oid.slice(2, 4), oid);
1694
+ }
1695
+ async function lfsOidsForRef(hostRepo, ref) {
1696
+ const listed = await execa("git", ["-C", hostRepo, "lfs", "ls-files", "--long", ref], {
1697
+ reject: false
1698
+ });
1699
+ if (listed.exitCode !== 0) return [];
1700
+ const oids = listed.stdout.split("\n").map((l) => l.trim().split(/\s+/)[0] ?? "").filter((o) => LFS_OID_RE.test(o));
1701
+ return [...new Set(oids)];
1702
+ }
1703
+ async function seedCloneLfsObjects(hostRepo, cloneDir, ref, log) {
1704
+ const tracked = await execa("git", ["-C", hostRepo, "lfs", "ls-files", "-n", ref], {
1705
+ reject: false
1706
+ });
1707
+ if (tracked.exitCode !== 0 || tracked.stdout.trim().length === 0) return;
1708
+ const fetched = await execa("git", ["-C", hostRepo, "lfs", "fetch", "origin", ref], {
1709
+ reject: false
1710
+ });
1711
+ if (fetched.exitCode !== 0) {
1712
+ const msg = (fetched.stderr || fetched.stdout || `exit ${String(fetched.exitCode ?? "?")}`).trim().split("\n")[0];
1713
+ log(`git-lfs prefetch for ${ref} skipped (best-effort, continuing): ${msg}`);
1714
+ }
1715
+ const oids = await lfsOidsForRef(hostRepo, ref);
1716
+ let copied = 0;
1717
+ for (const oid of oids) {
1718
+ const rel = lfsObjectRelPath(oid);
1719
+ const dst = join7(cloneDir, ".git", rel);
1720
+ try {
1721
+ await mkdir2(dirname2(dst), { recursive: true });
1722
+ await copyFile(join7(hostRepo, ".git", rel), dst);
1723
+ copied++;
1724
+ } catch {
1725
+ }
1726
+ }
1727
+ if (copied > 0) log(`seeded ${String(copied)} git-lfs object(s) for ${ref} into clone`);
1728
+ }
1729
+ async function maybeBuildDeltaLfsTar(hostRepo, target, checkpointTip, outPath) {
1730
+ const targetOids = await lfsOidsForRef(hostRepo, target);
1731
+ if (targetOids.length === 0) return 0;
1732
+ const have = new Set(await lfsOidsForRef(hostRepo, checkpointTip));
1733
+ const deltaOids = targetOids.filter((o) => !have.has(o));
1734
+ if (deltaOids.length === 0) return 0;
1735
+ await execa("git", ["-C", hostRepo, "lfs", "fetch", "origin", target], { reject: false });
1736
+ const gitDir = join7(hostRepo, ".git");
1737
+ const relPaths = [];
1738
+ for (const oid of deltaOids) {
1739
+ const rel = lfsObjectRelPath(oid);
1740
+ try {
1741
+ await stat(join7(gitDir, rel));
1742
+ relPaths.push(rel);
1743
+ } catch {
1744
+ }
1745
+ }
1746
+ if (relPaths.length === 0) return 0;
1747
+ const tar = await execa("tar", ["-C", gitDir, "-czf", outPath, ...relPaths], {
1748
+ env: { ...process.env, COPYFILE_DISABLE: "1" },
1749
+ reject: false
1750
+ });
1751
+ if (tar.exitCode !== 0) return 0;
1752
+ return safeFileSize(outPath);
1753
+ }
1754
+ async function safeFileSize(path) {
1755
+ try {
1756
+ return (await stat(path)).size;
1757
+ } catch {
1758
+ return 0;
1759
+ }
1760
+ }
1761
+ async function safeStashCreate(hostRepo) {
1762
+ const r = await execa("git", ["-C", hostRepo, "stash", "create"], { reject: false });
1763
+ if (r.exitCode !== 0) return null;
1764
+ const sha = r.stdout.trim();
1765
+ return sha.length > 0 ? sha : null;
1766
+ }
1767
+ async function maybeBuildUntrackedTar(hostRepo, outPath) {
1768
+ const list = await execa(
1769
+ "git",
1770
+ ["-C", hostRepo, "ls-files", "--others", "--exclude-standard", "-z"],
1771
+ { reject: false }
1772
+ );
1773
+ if (list.exitCode !== 0 || list.stdout.length === 0) return 0;
1774
+ const tar = await execa(
1775
+ "tar",
1776
+ ["-C", hostRepo, "--null", "-T", "-", "-czf", outPath],
1777
+ {
1778
+ input: list.stdout,
1779
+ env: { ...process.env, COPYFILE_DISABLE: "1" },
1780
+ reject: false
1781
+ }
1782
+ );
1783
+ if (tar.exitCode !== 0) return 0;
1784
+ try {
1785
+ const { stat: stat2 } = await import("fs/promises");
1786
+ const s = await stat2(outPath);
1787
+ return s.size;
1788
+ } catch {
1789
+ return 0;
1790
+ }
1791
+ }
1792
+ async function readOriginUrl(hostRepo) {
1793
+ const r = await execa("git", ["-C", hostRepo, "remote", "get-url", "origin"], { reject: false });
1794
+ if (r.exitCode !== 0) return null;
1795
+ const out = (r.stdout ?? "").trim();
1796
+ return out.length > 0 ? out : null;
1797
+ }
1798
+ async function seedFromTar(args) {
1799
+ const stage = await mkdtemp6(join7(tmpdir6(), "agentbox-tar-"));
1800
+ const tarPath = join7(stage, "workspace.tar.gz");
1801
+ try {
1802
+ await execa("tar", ["-C", args.hostDir, "-czf", tarPath, "."]);
1803
+ const remoteTar = "/tmp/agentbox-workspace.tar.gz";
1804
+ await args.backend.uploadFile(args.handle, tarPath, remoteTar);
1805
+ const SUDO = `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`;
1806
+ const script = [
1807
+ `set -euo pipefail`,
1808
+ // Move out of any cwd we might inherit from Daytona's executeCommand
1809
+ // before we delete /workspace. The agentbox image bakes WORKDIR
1810
+ // /workspace; if the shell's cwd is /workspace when we `rm -rf` it,
1811
+ // the next process inherits a stale cwd FD and git-clone's child
1812
+ // (index-pack) fails with "Unable to read current working directory".
1813
+ `cd /tmp`,
1814
+ SUDO,
1815
+ `$SUDO rm -rf ${quoteShellArgv([args.workspaceDir])}`,
1816
+ `$SUDO mkdir -p ${quoteShellArgv([args.workspaceDir])}`,
1817
+ `$SUDO chown "$(id -un):$(id -gn)" ${quoteShellArgv([args.workspaceDir])}`,
1818
+ `tar -C ${quoteShellArgv([args.workspaceDir])} -xzf ${quoteShellArgv([remoteTar])}`,
1819
+ `rm -f ${quoteShellArgv([remoteTar])}`
1820
+ ].join("\n");
1821
+ const r = await args.backend.exec(args.handle, bashScript(script));
1822
+ if (r.exitCode !== 0) {
1823
+ throw new Error(`workspace seed (tar) failed: ${r.stderr || r.stdout}`);
1824
+ }
1825
+ } finally {
1826
+ await rm7(stage, { recursive: true, force: true });
1827
+ }
1828
+ }
1829
+ var CLOUD_WORKSPACE_DIR = "/workspace";
1830
+ var CLOUD_WEB_PROXY_PORT = 80;
1831
+ var CLOUD_VNC_PORT = 6080;
1832
+ var DEFAULT_SIGNED_URL_TTL_SECONDS = 3600;
1833
+ var FALLBACK_IMAGE = "agentbox/box:dev";
1834
+ var DEFAULT_PORTLESS_PROXY_PORT = 1355;
1835
+ function parsePortlessUrl(url) {
1836
+ try {
1837
+ const u = new URL(url);
1838
+ if (!u.hostname.endsWith(".localhost")) return void 0;
1839
+ const tls = u.protocol === "https:";
1840
+ const proxyPort = u.port ? Number.parseInt(u.port, 10) : tls ? 443 : 80;
1841
+ if (!Number.isFinite(proxyPort)) return void 0;
1842
+ return { proxyPort, tls };
1843
+ } catch {
1844
+ return void 0;
1845
+ }
1846
+ }
1847
+ function parseLoopbackPort(url) {
1848
+ try {
1849
+ const u = new URL(url);
1850
+ if (u.hostname !== "127.0.0.1" && u.hostname !== "localhost") return void 0;
1851
+ const port = Number.parseInt(u.port, 10);
1852
+ return Number.isFinite(port) ? port : void 0;
1853
+ } catch {
1854
+ return void 0;
1855
+ }
1856
+ }
1857
+ function deriveCloudBoxHost(boxName, webPreviewUrl) {
1858
+ if (!webPreviewUrl) return void 0;
1859
+ if (parseLoopbackPort(webPreviewUrl) !== void 0) return `${boxName}.localhost`;
1860
+ try {
1861
+ return new URL(webPreviewUrl).host;
1862
+ } catch {
1863
+ return void 0;
1864
+ }
1865
+ }
1866
+ async function registerHostPortlessAlias(args) {
1867
+ const localPort = parseLoopbackPort(args.previewUrl);
1868
+ if (localPort === void 0) return void 0;
1869
+ const ok = await portlessAlias(args.alias, localPort);
1870
+ if (!ok) {
1871
+ args.onLog(
1872
+ `portless: ${args.label} alias not registered (portless CLI missing or not running) \u2014 host URL stays http://127.0.0.1:${String(localPort)}`
1873
+ );
1874
+ return void 0;
1875
+ }
1876
+ const url = await portlessGetUrl(args.alias);
1877
+ args.onLog(`portless alias ${url} -> 127.0.0.1:${String(localPort)}`);
1878
+ return url;
1879
+ }
1880
+ async function bootstrapPortlessForCloudBox(backend, handle, args) {
1881
+ const url = await registerHostPortlessAlias({
1882
+ alias: args.boxName,
1883
+ previewUrl: args.webPreviewUrl,
1884
+ label: "web",
1885
+ onLog: args.onLog
1886
+ });
1887
+ if (!url) return void 0;
1888
+ if (backend.startInBoxPortless) {
1889
+ const mode = parsePortlessUrl(url) ?? { proxyPort: DEFAULT_PORTLESS_PROXY_PORT, tls: false };
1890
+ try {
1891
+ await backend.startInBoxPortless(handle, {
1892
+ boxName: args.boxName,
1893
+ proxyPort: mode.proxyPort,
1894
+ tls: mode.tls,
1895
+ webPort: args.webPort
1896
+ });
1897
+ args.onLog(
1898
+ `portless: in-box mirror up on 127.0.0.1:${String(mode.proxyPort)} (${mode.tls ? "https" : "http"})`
1899
+ );
1900
+ } catch (err) {
1901
+ args.onLog(
1902
+ `portless: in-box mirror failed (continuing): ${err instanceof Error ? err.message : String(err)}`
1903
+ );
1904
+ }
1905
+ }
1906
+ return { alias: args.boxName, url };
1907
+ }
1908
+ function createCloudProvider(backend, opts = {}) {
1909
+ const providerName = backend.name;
1910
+ function handleFor(box) {
1911
+ const sandboxId = box.cloud?.sandboxId;
1912
+ if (!sandboxId) {
1913
+ throw new Error(`cloud box ${box.name} has no sandboxId \u2014 record is malformed`);
1914
+ }
1915
+ return { sandboxId };
1916
+ }
1917
+ function mintBox(req) {
1918
+ const id = generateBoxId();
1919
+ const name = req.name ?? `${basename2(req.workspacePath)}-${id}`;
1920
+ return {
1921
+ id,
1922
+ name,
1923
+ // --use-branch reuses the named branch directly; otherwise fork a fresh
1924
+ // per-box branch. The CLI validated `useBranch` exists host-side.
1925
+ branch: req.useBranch ?? `agentbox/${name}`
1926
+ };
1927
+ }
1928
+ async function probe(box) {
1929
+ try {
1930
+ const h = handleFor(box);
1931
+ const state = await backend.state(h);
1932
+ return state;
1933
+ } catch {
1934
+ return "missing";
1935
+ }
1936
+ }
1937
+ async function persistLastState(box, lastState) {
1938
+ if (!box.cloud) return;
1939
+ try {
1940
+ await recordBox({ ...box, cloud: { ...box.cloud, lastState } });
1941
+ } catch {
1942
+ }
1943
+ }
1944
+ async function reEnsureCloudBox(box, h) {
1945
+ const webPort = box.cloud?.webPort ?? backend.webProxyPort ?? CLOUD_WEB_PROXY_PORT;
1946
+ let webPreview;
1947
+ try {
1948
+ webPreview = await backend.previewUrl(h, webPort);
1949
+ } catch {
1950
+ const cached = box.cloud?.previewUrls?.[webPort];
1951
+ webPreview = cached ? { url: cached } : void 0;
1952
+ }
1953
+ const servicePreviews = {};
1954
+ try {
1955
+ const ports = await readExposedServicePorts(box.workspacePath);
1956
+ for (const port of ports) {
1957
+ if (port === webPort) continue;
1958
+ try {
1959
+ const p = await backend.previewUrl(h, port);
1960
+ servicePreviews[port] = p.url;
1961
+ } catch {
1962
+ }
1963
+ }
1964
+ } catch {
1965
+ }
1966
+ let relayPreview;
1967
+ try {
1968
+ relayPreview = await backend.previewUrl(h, 8788);
1969
+ } catch {
1970
+ relayPreview = box.cloud?.relayPreviewUrl ? { url: box.cloud.relayPreviewUrl, token: box.cloud.relayPreviewToken } : void 0;
1971
+ }
1972
+ const mergedPreviews = {
1973
+ ...box.cloud?.previewUrls ?? {},
1974
+ ...servicePreviews
1975
+ };
1976
+ if (webPreview !== void 0) mergedPreviews[webPort] = webPreview.url;
1977
+ let portlessAliasName = box.portlessAlias;
1978
+ let portlessUrlResolved = box.portlessUrl;
1979
+ if (box.portlessAlias && webPreview) {
1980
+ const r = await bootstrapPortlessForCloudBox(backend, h, {
1981
+ boxName: box.name,
1982
+ webPreviewUrl: webPreview.url,
1983
+ webPort,
1984
+ onLog: () => {
1985
+ }
1986
+ });
1987
+ if (r) {
1988
+ portlessAliasName = r.alias;
1989
+ portlessUrlResolved = r.url;
1990
+ }
1991
+ }
1992
+ let portlessVncAliasName = box.portlessVncAlias;
1993
+ let portlessVncUrlResolved = box.portlessVncUrl;
1994
+ if (box.portlessVncAlias && box.vncEnabled) {
1995
+ try {
1996
+ const vncPreview = await backend.previewUrl(h, CLOUD_VNC_PORT);
1997
+ const url = await registerHostPortlessAlias({
1998
+ alias: box.portlessVncAlias,
1999
+ previewUrl: vncPreview.url,
2000
+ label: "vnc",
2001
+ onLog: () => {
2002
+ }
2003
+ });
2004
+ if (url) {
2005
+ portlessVncAliasName = box.portlessVncAlias;
2006
+ portlessVncUrlResolved = url;
2007
+ }
2008
+ } catch {
2009
+ }
2010
+ }
2011
+ const next = {
2012
+ ...box,
2013
+ portlessAlias: portlessAliasName,
2014
+ portlessUrl: portlessUrlResolved,
2015
+ portlessVncAlias: portlessVncAliasName,
2016
+ portlessVncUrl: portlessVncUrlResolved,
2017
+ cloud: {
2018
+ ...box.cloud ?? { backend: providerName, sandboxId: h.sandboxId },
2019
+ webPort,
2020
+ previewUrls: Object.keys(mergedPreviews).length > 0 ? mergedPreviews : void 0,
2021
+ relayPreviewUrl: relayPreview?.url ?? box.cloud?.relayPreviewUrl,
2022
+ relayPreviewToken: relayPreview?.token ?? box.cloud?.relayPreviewToken,
2023
+ // reEnsureCloudBox only runs on a freshly-woken box (start/resume), so
2024
+ // the box is now running — persist it for the fast `agentbox list` path.
2025
+ lastState: "running"
2026
+ }
2027
+ };
2028
+ await recordBox(next);
2029
+ await kickCloudBootstrap({
2030
+ backend,
2031
+ handle: h,
2032
+ boxId: box.id,
2033
+ boxName: box.name,
2034
+ relayUrl: `http://127.0.0.1:${String(8788)}`,
2035
+ relayToken: box.relayToken ?? "",
2036
+ bridgeToken: box.cloud?.bridgeToken,
2037
+ webProxyPort: backend.webProxyPort,
2038
+ launchDockerd: opts.launchDockerd !== false,
2039
+ vncPassword: box.vncEnabled ? box.vncPassword : void 0,
2040
+ controlPlaneUrl: box.cloud?.controlPlaneUrl,
2041
+ gitPushMode: box.cloud?.gitPushMode,
2042
+ boxHost: deriveCloudBoxHost(box.name, webPreview?.url)
2043
+ });
2044
+ if (box.cloud?.controlPlaneUrl && box.relayToken) {
2045
+ const adminToken = process.env.AGENTBOX_RELAY_ADMIN_TOKEN;
2046
+ const originUrl = await readGitOriginUrl(box.workspacePath).catch(() => void 0);
2047
+ if (adminToken && originUrl) {
2048
+ try {
2049
+ await registerBoxWithPlane({
2050
+ controlPlaneUrl: box.cloud.controlPlaneUrl,
2051
+ adminToken,
2052
+ boxId: box.id,
2053
+ token: box.relayToken,
2054
+ name: box.name,
2055
+ originUrl,
2056
+ backend: backend.name,
2057
+ bridgeToken: box.cloud.bridgeToken,
2058
+ previewUrl: relayPreview?.url,
2059
+ previewToken: relayPreview?.token,
2060
+ createdAt: box.createdAt,
2061
+ projectIndex: box.projectIndex,
2062
+ autoApproveHostActions: box.autoApproveHostActions,
2063
+ autoApproveSafeHostActions: box.autoApproveSafeHostActions
2064
+ });
2065
+ } catch {
2066
+ }
2067
+ }
2068
+ } else if (relayPreview && box.relayToken && box.cloud?.bridgeToken) {
2069
+ try {
2070
+ await registerBoxWithRelay({
2071
+ boxId: box.id,
2072
+ token: box.relayToken,
2073
+ name: box.name,
2074
+ kind: "cloud",
2075
+ backend: backend.name,
2076
+ previewUrl: relayPreview.url,
2077
+ previewToken: relayPreview.token,
2078
+ bridgeToken: box.cloud.bridgeToken,
2079
+ createdAt: box.createdAt,
2080
+ projectIndex: box.projectIndex,
2081
+ autoApproveHostActions: box.autoApproveHostActions,
2082
+ autoApproveSafeHostActions: box.autoApproveSafeHostActions
2083
+ });
2084
+ } catch {
2085
+ }
2086
+ }
2087
+ return next;
2088
+ }
2089
+ return {
2090
+ name: providerName,
2091
+ async create(reqRaw) {
2092
+ const req = reqRaw.workspacePath ? { ...reqRaw, workspacePath: resolve(reqRaw.workspacePath) } : reqRaw;
2093
+ const log = req.onLog ?? (() => {
2094
+ });
2095
+ const { id, name, branch } = mintBox(req);
2096
+ const image = opts.provisionImage ? await opts.provisionImage(req) : req.image ?? FALLBACK_IMAGE;
2097
+ const baseResources = opts.defaultResources ?? { cpu: 2, memory: 4, disk: 8 };
2098
+ const vcpuOverride = req.providerOptions?.["vcpus"];
2099
+ const resources = typeof vcpuOverride === "number" && vcpuOverride > 0 ? { ...baseResources, cpu: vcpuOverride } : baseResources;
2100
+ const timeoutOverride = req.providerOptions?.["timeoutMs"];
2101
+ const timeoutMs = typeof timeoutOverride === "number" && timeoutOverride > 0 ? timeoutOverride : void 0;
2102
+ const networkPolicyOpt = req.providerOptions?.["networkPolicy"];
2103
+ const networkPolicy = typeof networkPolicyOpt === "string" && networkPolicyOpt.trim() !== "" ? networkPolicyOpt.trim() : void 0;
2104
+ const sizeOpt = req.providerOptions?.["size"];
2105
+ const size = typeof sizeOpt === "string" && sizeOpt.trim() !== "" ? sizeOpt.trim() : void 0;
2106
+ const relayToken = generateRelayToken();
2107
+ const bridgeToken = generateRelayToken();
2108
+ try {
2109
+ await ensureRelay({ onLog: log });
2110
+ } catch (err) {
2111
+ log(
2112
+ `relay ensure failed (continuing): ${err instanceof Error ? err.message : String(err)}`
2113
+ );
2114
+ }
2115
+ let snapshotName;
2116
+ let resolvedCheckpointRef;
2117
+ if (req.checkpointRef && req.projectRoot) {
2118
+ const found = await resolveCloudCheckpoint(
2119
+ req.projectRoot,
2120
+ backend.name,
2121
+ req.checkpointRef
2122
+ );
2123
+ if (found) {
2124
+ snapshotName = found.manifest.snapshotName;
2125
+ resolvedCheckpointRef = found.name;
2126
+ log(`provisioning from cloud checkpoint '${found.name}' (snapshot ${snapshotName})`);
2127
+ } else {
2128
+ log(
2129
+ `cloud checkpoint '${req.checkpointRef}' not found for ${backend.name}; provisioning from base image`
2130
+ );
2131
+ }
2132
+ }
2133
+ const agentVolumes = await ensureAgentVolumesForCloud(backend, { onLog: log });
2134
+ const exposeServicePorts = await readExposedServicePorts(req.workspacePath);
2135
+ const provisionEnv = {
2136
+ AGENTBOX_BOX_ID: id,
2137
+ AGENTBOX_BOX_NAME: name,
2138
+ AGENTBOX_BOX_KIND: "cloud",
2139
+ // In-sandbox relay is on the box's loopback at the in-box port.
2140
+ // 8788 is distinct from the host relay's 8787 so a nested agentbox
2141
+ // run inside the box can claim :8787 without colliding.
2142
+ AGENTBOX_RELAY_URL: `http://127.0.0.1:${String(8788)}`,
2143
+ AGENTBOX_RELAY_TOKEN: relayToken,
2144
+ AGENTBOX_BRIDGE_TOKEN: bridgeToken,
2145
+ ...agentVolumes.env
2146
+ };
2147
+ const provisionFrom = async (snapshot) => {
2148
+ log(
2149
+ snapshot ? `provisioning ${providerName} sandbox from snapshot` : `provisioning ${providerName} sandbox`
2150
+ );
2151
+ return backend.provision({
2152
+ name,
2153
+ image,
2154
+ snapshot,
2155
+ resources,
2156
+ size,
2157
+ timeoutMs,
2158
+ exposePorts: exposeServicePorts,
2159
+ networkPolicy,
2160
+ env: provisionEnv,
2161
+ volumes: agentVolumes.mounts,
2162
+ onLog: log
2163
+ });
2164
+ };
2165
+ let handle;
2166
+ try {
2167
+ handle = await provisionFrom(snapshotName);
2168
+ } catch (err) {
2169
+ if (snapshotName && isSnapshotGoneError(err)) {
2170
+ log(
2171
+ `checkpoint snapshot '${resolvedCheckpointRef ?? snapshotName}' has expired or been deleted; starting a fresh box from the base image instead`
2172
+ );
2173
+ if (req.projectRoot && resolvedCheckpointRef) {
2174
+ try {
2175
+ await removeCloudCheckpointDir(req.projectRoot, backend.name, resolvedCheckpointRef);
2176
+ } catch {
2177
+ }
2178
+ }
2179
+ snapshotName = void 0;
2180
+ resolvedCheckpointRef = void 0;
2181
+ handle = await provisionFrom(void 0);
2182
+ } else {
2183
+ throw err;
2184
+ }
2185
+ }
2186
+ const inBoxClone = req.inBoxClone ? {
2187
+ authedUrl: req.inBoxClone.authedUrl,
2188
+ originUrl: req.inBoxClone.originUrl,
2189
+ branch: req.inBoxClone.branch,
2190
+ depth: req.bundleDepth
2191
+ } : void 0;
2192
+ try {
2193
+ let resync;
2194
+ if (inBoxClone) {
2195
+ log("skipping host workspace seed \u2014 box will clone in-box at bootstrap");
2196
+ } else {
2197
+ const seedResult = await seedCloudWorkspace({
2198
+ backend,
2199
+ handle,
2200
+ workspacePath: req.workspacePath,
2201
+ branch,
2202
+ workspaceDir: CLOUD_WORKSPACE_DIR,
2203
+ bundleDepth: req.bundleDepth,
2204
+ fromBranch: req.fromBranch,
2205
+ useBranch: req.useBranch,
2206
+ overlay: Boolean(snapshotName),
2207
+ // `--no-resync` (resyncOnStart === false): re-branch the box to the
2208
+ // host tip but skip replaying the host's uncommitted/untracked state
2209
+ // onto the warm checkpoint tree — matches docker's gated resync.
2210
+ skipCarryOver: Boolean(snapshotName) && req.resyncOnStart === false,
2211
+ onLog: log
2212
+ });
2213
+ resync = seedResult.resync && seedResult.resync.hadConflicts ? seedResult.resync : void 0;
2214
+ }
2215
+ const syncCtx = makeSyncContext({
2216
+ boxName: name,
2217
+ boxId: id,
2218
+ provider: "cloud",
2219
+ hostWorkspace: req.workspacePath,
2220
+ projectRoot: req.projectRoot,
2221
+ boxWorkspace: CLOUD_WORKSPACE_DIR,
2222
+ onLog: log
2223
+ });
2224
+ const sync = makeCloudSync(backend, handle, { agents: agentVolumes.agents });
2225
+ await sync.seedCredentials(syncCtx);
2226
+ await sync.seedAgentConfig(syncCtx);
2227
+ await sync.seedGitIdentity(syncCtx);
2228
+ if (req.envFilesToImport && req.envFilesToImport.length > 0) {
2229
+ const { copied } = await sync.seedEnvFiles(syncCtx, req.envFilesToImport);
2230
+ if (copied > 0) log(`copied ${String(copied)} env/config file(s) into /workspace`);
2231
+ }
2232
+ let carrySummary;
2233
+ if (req.carry && req.carry.length > 0) {
2234
+ log(`carry: copying ${String(req.carry.length)} host path(s) into the box`);
2235
+ const result = await sync.applyCarry(syncCtx, req.carry);
2236
+ log(`carry: copied ${String(result.copied)}/${String(req.carry.length)} entry/entries`);
2237
+ for (const err of result.errors) log(`carry: ${err}`);
2238
+ if (result.applied.length > 0) {
2239
+ carrySummary = { count: result.applied.length, entries: result.applied };
2240
+ }
2241
+ }
2242
+ const vncEnabled = req.vnc?.enabled !== false;
2243
+ const vncPassword = vncEnabled ? generateVncPassword() : void 0;
2244
+ const wp = backend.webProxyPort ?? CLOUD_WEB_PROXY_PORT;
2245
+ let webPreview;
2246
+ try {
2247
+ webPreview = await backend.previewUrl(handle, wp);
2248
+ } catch {
2249
+ webPreview = void 0;
2250
+ }
2251
+ log("running in-box bootstrap (clone? + dockerd + ctl + vnc)");
2252
+ await kickCloudBootstrap({
2253
+ backend,
2254
+ handle,
2255
+ boxId: id,
2256
+ boxName: name,
2257
+ relayUrl: `http://127.0.0.1:${String(8788)}`,
2258
+ relayToken,
2259
+ bridgeToken,
2260
+ webProxyPort: backend.webProxyPort,
2261
+ launchDockerd: opts.launchDockerd !== false,
2262
+ vncPassword,
2263
+ clone: inBoxClone,
2264
+ controlPlaneUrl: req.controlPlaneUrl,
2265
+ gitPushMode: req.gitPushMode,
2266
+ boxHost: deriveCloudBoxHost(name, webPreview?.url),
2267
+ onLog: log
2268
+ });
2269
+ const portlessOpt = req.providerOptions?.["portless"] ?? true;
2270
+ let portlessAliasName;
2271
+ let portlessUrlResolved;
2272
+ if (portlessOpt && webPreview) {
2273
+ const r = await bootstrapPortlessForCloudBox(backend, handle, {
2274
+ boxName: name,
2275
+ webPreviewUrl: webPreview.url,
2276
+ webPort: wp,
2277
+ onLog: log
2278
+ });
2279
+ if (r) {
2280
+ portlessAliasName = r.alias;
2281
+ portlessUrlResolved = r.url;
2282
+ }
2283
+ }
2284
+ let vncPreview;
2285
+ if (portlessOpt && vncEnabled) {
2286
+ try {
2287
+ vncPreview = await backend.previewUrl(handle, CLOUD_VNC_PORT);
2288
+ } catch {
2289
+ vncPreview = void 0;
2290
+ }
2291
+ }
2292
+ let portlessVncAliasName;
2293
+ let portlessVncUrlResolved;
2294
+ if (portlessOpt && vncPreview) {
2295
+ const vncAlias = `vnc-${name}`;
2296
+ const url = await registerHostPortlessAlias({
2297
+ alias: vncAlias,
2298
+ previewUrl: vncPreview.url,
2299
+ label: "vnc",
2300
+ onLog: log
2301
+ });
2302
+ if (url) {
2303
+ portlessVncAliasName = vncAlias;
2304
+ portlessVncUrlResolved = url;
2305
+ }
2306
+ }
2307
+ const servicePorts = exposeServicePorts;
2308
+ const servicePreviews = {};
2309
+ for (const port of servicePorts) {
2310
+ if (port === wp) continue;
2311
+ try {
2312
+ const p = await backend.previewUrl(handle, port);
2313
+ servicePreviews[port] = p.url;
2314
+ } catch {
2315
+ }
2316
+ }
2317
+ let relayPreview;
2318
+ try {
2319
+ relayPreview = await backend.previewUrl(handle, 8788);
2320
+ } catch {
2321
+ relayPreview = void 0;
2322
+ }
2323
+ const state = await readState();
2324
+ const projectIndex = req.projectRoot ? allocateProjectIndex(state, req.projectRoot) : void 0;
2325
+ const effectiveBoxForApprove = (await loadEffectiveConfig(req.projectRoot ?? req.workspacePath)).effective.box;
2326
+ const autoApproveHostActions = effectiveBoxForApprove.autoApproveHostActions;
2327
+ const autoApproveSafeHostActions = effectiveBoxForApprove.autoApproveSafeHostActions;
2328
+ if (req.controlPlaneUrl) {
2329
+ const adminToken = process.env.AGENTBOX_RELAY_ADMIN_TOKEN;
2330
+ const originUrl = req.inBoxClone ? req.inBoxClone.originUrl : await readGitOriginUrl(req.workspacePath).catch(() => void 0);
2331
+ if (!adminToken) {
2332
+ log(
2333
+ "control-plane URL configured but AGENTBOX_RELAY_ADMIN_TOKEN is unset; box git push (lease) will fail until the box is registered on the plane"
2334
+ );
2335
+ } else if (!originUrl) {
2336
+ log(
2337
+ "control-plane box: could not resolve the workspace origin URL; lease-push will fail until the box is registered on the plane with an origin"
2338
+ );
2339
+ } else {
2340
+ try {
2341
+ await registerBoxWithPlane({
2342
+ controlPlaneUrl: req.controlPlaneUrl,
2343
+ adminToken,
2344
+ boxId: id,
2345
+ token: relayToken,
2346
+ name,
2347
+ originUrl,
2348
+ backend: backend.name,
2349
+ bridgeToken,
2350
+ previewUrl: relayPreview?.url,
2351
+ previewToken: relayPreview?.token,
2352
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2353
+ projectIndex,
2354
+ autoApproveHostActions,
2355
+ autoApproveSafeHostActions
2356
+ });
2357
+ } catch (err) {
2358
+ log(
2359
+ `register with control plane failed (continuing): ${err instanceof Error ? err.message : String(err)}`
2360
+ );
2361
+ }
2362
+ }
2363
+ } else if (relayPreview) {
2364
+ try {
2365
+ await registerBoxWithRelay({
2366
+ boxId: id,
2367
+ token: relayToken,
2368
+ name,
2369
+ projectIndex,
2370
+ kind: "cloud",
2371
+ backend: backend.name,
2372
+ previewUrl: relayPreview.url,
2373
+ previewToken: relayPreview.token,
2374
+ bridgeToken,
2375
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2376
+ autoApproveHostActions,
2377
+ autoApproveSafeHostActions
2378
+ });
2379
+ } catch (err) {
2380
+ log(
2381
+ `register with host relay failed (continuing): ${err instanceof Error ? err.message : String(err)}`
2382
+ );
2383
+ }
2384
+ }
2385
+ const record = {
2386
+ id,
2387
+ name,
2388
+ provider: providerName,
2389
+ // `container` carries the sandbox id with a `cloud:` prefix —
2390
+ // unique within state, never collides with a real docker
2391
+ // container, and grepping for `agentbox-cloud-*` (the old
2392
+ // synthetic value) finds nothing now. `image` mirrors the
2393
+ // resolved cloud image so `BoxRecord.image: string` stays
2394
+ // required without docker-internal readers seeing `undefined`.
2395
+ container: `cloud:${handle.sandboxId}`,
2396
+ image,
2397
+ workspacePath: req.workspacePath,
2398
+ projectRoot: req.projectRoot,
2399
+ projectIndex,
2400
+ relayToken,
2401
+ withPlaywright: req.withPlaywright,
2402
+ withEnv: req.withEnv,
2403
+ autoApproveHostActions: autoApproveHostActions ? true : void 0,
2404
+ autoApproveSafeHostActions: autoApproveSafeHostActions === false ? false : void 0,
2405
+ carry: carrySummary,
2406
+ portlessAlias: portlessAliasName,
2407
+ portlessUrl: portlessUrlResolved,
2408
+ portlessVncAlias: portlessVncAliasName,
2409
+ portlessVncUrl: portlessVncUrlResolved,
2410
+ vncEnabled,
2411
+ vncPassword,
2412
+ vncContainerPort: vncEnabled ? CLOUD_VNC_PORT : void 0,
2413
+ resourceLimits: req.limits ? {
2414
+ memoryBytes: req.limits.memoryBytes ?? void 0,
2415
+ cpus: req.limits.cpus ?? void 0,
2416
+ pidsLimit: req.limits.pidsLimit ?? void 0,
2417
+ disk: req.limits.disk ?? void 0
2418
+ } : void 0,
2419
+ cloud: {
2420
+ backend: backend.name,
2421
+ sandboxId: handle.sandboxId,
2422
+ image,
2423
+ webPort: wp,
2424
+ previewUrls: (() => {
2425
+ const m = { ...servicePreviews };
2426
+ if (webPreview) m[wp] = webPreview.url;
2427
+ return Object.keys(m).length > 0 ? m : void 0;
2428
+ })(),
2429
+ relayPreviewUrl: relayPreview?.url,
2430
+ relayPreviewToken: relayPreview?.token,
2431
+ bridgeToken,
2432
+ snapshotRef: resolvedCheckpointRef,
2433
+ lastState: "running",
2434
+ sessionTimeoutMs: timeoutMs,
2435
+ // Only host-seeded boxes share a fork base with the host, so only
2436
+ // they can be resynced back to the host tip on session start (7.5).
2437
+ // inBoxClone / plane boxes clone from a leased URL — left unset.
2438
+ hostSeeded: inBoxClone ? void 0 : true,
2439
+ workspaceBranch: branch,
2440
+ topology: resolveSyncTopology(backend.name, req.controlPlaneUrl),
2441
+ controlPlaneUrl: req.controlPlaneUrl,
2442
+ gitPushMode: req.gitPushMode
2443
+ },
2444
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
2445
+ };
2446
+ await recordBox(record);
2447
+ return { record, imageBuilt: false, resync };
2448
+ } catch (err) {
2449
+ try {
2450
+ await backend.destroy(handle);
2451
+ } catch {
2452
+ }
2453
+ throw err;
2454
+ }
2455
+ },
2456
+ async start(box) {
2457
+ const h = handleFor(box);
2458
+ await backend.start(h);
2459
+ return reEnsureCloudBox(box, h);
2460
+ },
2461
+ async reconnect(box) {
2462
+ const h = handleFor(box);
2463
+ const state = await probe(box);
2464
+ if (state === "running") return reEnsureCloudBox(box, h);
2465
+ if (state === "paused") {
2466
+ await backend.resume(h);
2467
+ return reEnsureCloudBox(box, h);
2468
+ }
2469
+ if (state === "stopped") {
2470
+ await backend.start(h);
2471
+ return reEnsureCloudBox(box, h);
2472
+ }
2473
+ throw new Error(
2474
+ `cannot recover ${box.name}: sandbox ${box.cloud?.sandboxId ?? box.id} is ${state}`
2475
+ );
2476
+ },
2477
+ async repairReachability(box) {
2478
+ return await backend.repairReachability?.(handleFor(box)) ?? { changed: false };
2479
+ },
2480
+ async pause(box) {
2481
+ await backend.pause(handleFor(box));
2482
+ await persistLastState(box, "paused");
2483
+ },
2484
+ async resume(box) {
2485
+ const h = handleFor(box);
2486
+ await backend.resume(h);
2487
+ await reEnsureCloudBox(box, h);
2488
+ },
2489
+ async stop(box) {
2490
+ await backend.stop(handleFor(box));
2491
+ await persistLastState(box, "paused");
2492
+ },
2493
+ async destroy(box) {
2494
+ try {
2495
+ await backend.destroy(handleFor(box));
2496
+ } catch (err) {
2497
+ const msg = err instanceof Error ? err.message : String(err);
2498
+ if (!/not.?found|missing/i.test(msg)) throw err;
2499
+ }
2500
+ if (box.portlessAlias) {
2501
+ try {
2502
+ await portlessUnalias(box.portlessAlias);
2503
+ } catch {
2504
+ }
2505
+ }
2506
+ if (box.portlessVncAlias) {
2507
+ try {
2508
+ await portlessUnalias(box.portlessVncAlias);
2509
+ } catch {
2510
+ }
2511
+ }
2512
+ try {
2513
+ await forgetBoxFromRelay(box.id);
2514
+ } catch {
2515
+ }
2516
+ await removeBoxRecord(box.id);
2517
+ },
2518
+ async probeState(box) {
2519
+ return probe(box);
2520
+ },
2521
+ async inspect(box) {
2522
+ const state = await probe(box);
2523
+ const webPort = box.cloud?.webPort ?? backend.webProxyPort ?? CLOUD_WEB_PROXY_PORT;
2524
+ const portlessWebUrl = box.portlessAlias !== void 0 ? box.portlessUrl ?? `https://${box.portlessAlias}.localhost` : void 0;
2525
+ const cachedWebUrl = box.cloud?.previewUrls?.[webPort];
2526
+ const webUrl = portlessWebUrl ?? cachedWebUrl;
2527
+ const endpoints = [];
2528
+ if (webUrl) {
2529
+ endpoints.push({
2530
+ kind: "web",
2531
+ name: "web",
2532
+ containerPort: webPort,
2533
+ url: webUrl,
2534
+ reachable: true
2535
+ });
2536
+ }
2537
+ for (const [portStr, url] of Object.entries(box.cloud?.previewUrls ?? {})) {
2538
+ const port = Number.parseInt(portStr, 10);
2539
+ if (!Number.isFinite(port) || port === webPort) continue;
2540
+ endpoints.push({
2541
+ kind: "web",
2542
+ name: `service-${String(port)}`,
2543
+ containerPort: port,
2544
+ url,
2545
+ reachable: true
2546
+ });
2547
+ }
2548
+ return {
2549
+ record: box,
2550
+ state,
2551
+ endpoints: {
2552
+ domain: webUrl ? new URL(webUrl).host : "",
2553
+ domainIsOrb: false,
2554
+ endpoints
2555
+ },
2556
+ raw: void 0
2557
+ };
2558
+ },
2559
+ async exec(box, argv, opts2) {
2560
+ const r = await backend.exec(handleFor(box), quoteShellArgv(argv), {
2561
+ cwd: opts2?.cwd,
2562
+ env: opts2?.env,
2563
+ user: opts2?.user
2564
+ });
2565
+ return { exitCode: r.exitCode, stdout: r.stdout, stderr: r.stderr };
2566
+ },
2567
+ async buildAttach(box, kind, opts2) {
2568
+ if (!backend.attachArgv) {
2569
+ throw new Error(
2570
+ `cloud backend '${backend.name}' does not implement attachArgv \u2014 interactive attach not supported`
2571
+ );
2572
+ }
2573
+ const handle = handleFor(box);
2574
+ const baseArgv = await backend.attachArgv(handle);
2575
+ const inner = renderInnerCommand(kind, opts2);
2576
+ const argv = opts2?.detached ? [...baseArgv.slice(1), inner] : [...baseArgv.slice(1), "-t", inner];
2577
+ const fullArgv = [baseArgv[0], ...argv];
2578
+ const cleanup = backend.revokeAttachToken ? async () => {
2579
+ await backend.revokeAttachToken(handle, baseArgv);
2580
+ } : void 0;
2581
+ return { argv: fullArgv, cleanup };
2582
+ },
2583
+ async uploadPath(box, hostSrcs, boxDst, exclude) {
2584
+ return uploadToCloudBox(backend, handleFor(box), hostSrcs, boxDst, exclude);
2585
+ },
2586
+ async downloadPath(box, boxSrcs, hostDst, exclude) {
2587
+ return downloadFromCloudBox(backend, handleFor(box), boxSrcs, hostDst, exclude);
2588
+ },
2589
+ async downloadDirContents(box, boxSrc, hostDst) {
2590
+ return pullCloudDirContents(backend, handleFor(box), boxSrc, hostDst);
2591
+ },
2592
+ async resolveUrl(box, opts2) {
2593
+ const h = handleFor(box);
2594
+ const kind = opts2?.kind ?? "web";
2595
+ if (!opts2?.loopback) {
2596
+ if (kind === "web" && box.portlessAlias) {
2597
+ return box.portlessUrl ?? `https://${box.portlessAlias}.localhost`;
2598
+ }
2599
+ if (kind === "vnc" && box.portlessVncAlias) {
2600
+ return box.portlessVncUrl ?? `https://${box.portlessVncAlias}.localhost`;
2601
+ }
2602
+ }
2603
+ const port = kind === "vnc" ? CLOUD_VNC_PORT : box.cloud?.webPort ?? backend.webProxyPort ?? CLOUD_WEB_PROXY_PORT;
2604
+ if (backend.signedPreviewUrl) {
2605
+ const ttl = opts2?.ttl ?? DEFAULT_SIGNED_URL_TTL_SECONDS;
2606
+ try {
2607
+ const signed = await backend.signedPreviewUrl(h, port, ttl);
2608
+ return signed.url;
2609
+ } catch (err) {
2610
+ if (kind === "web") {
2611
+ const fallbackPort = await firstExposedServicePort(box);
2612
+ if (fallbackPort !== void 0 && fallbackPort !== port) {
2613
+ const signed = await backend.signedPreviewUrl(h, fallbackPort, ttl);
2614
+ return signed.url;
2615
+ }
2616
+ }
2617
+ throw err;
2618
+ }
2619
+ }
2620
+ const p = await backend.previewUrl(h, port);
2621
+ throw new Error(
2622
+ `cloud backend '${backend.name}' does not support signed preview URLs; the standard URL (${p.url}) requires a header token (e.g. x-daytona-preview-token: ${p.token ?? "<unset>"}) that browsers can't attach from a click. Use a programmatic client or wait for backend support.`
2623
+ );
2624
+ },
2625
+ // Cloud checkpoint capability. Backends without `createSnapshot` get a
2626
+ // capability stub whose methods throw — the CLI's `agentbox checkpoint
2627
+ // create` then surfaces a clean "not supported" error rather than a
2628
+ // silent no-op.
2629
+ checkpoint: makeCloudCheckpoint(backend),
2630
+ sync(box) {
2631
+ return makeCloudSync(backend, handleFor(box));
2632
+ },
2633
+ // Session-start live-box resync (Phase 7.5): merge the host's current state
2634
+ // back into the box, box-wins on conflict. Gated on `hostSeeded` so
2635
+ // inBoxClone / plane boxes (no host fork base) are left untouched. The box
2636
+ // layout is re-derived host-side (`detectGitRepos`) rather than recorded.
2637
+ async resyncWorkspace(box, onLog) {
2638
+ if (box.cloud?.hostSeeded !== true) return { repos: [], hadConflicts: false };
2639
+ const repos = await detectGitRepos(box.workspacePath);
2640
+ if (repos.length === 0) return { repos: [], hadConflicts: false };
2641
+ const branch = box.cloud.workspaceBranch ?? `agentbox/${box.name}`;
2642
+ const worktrees = repos.map((r) => {
2643
+ const containerPath = r.relPathFromWorkspace ? `${CLOUD_WORKSPACE_DIR}/${r.relPathFromWorkspace}` : CLOUD_WORKSPACE_DIR;
2644
+ return {
2645
+ kind: r.kind,
2646
+ hostMainRepo: r.hostMainRepo,
2647
+ containerPath,
2648
+ // Cloud boxes clone in place, so the worktree lives at its mount path.
2649
+ gitWorktreePath: containerPath,
2650
+ branch,
2651
+ relPathFromWorkspace: r.relPathFromWorkspace
2652
+ };
2653
+ });
2654
+ const ctx = makeSyncContext({
2655
+ boxName: box.name,
2656
+ boxId: box.id,
2657
+ provider: "cloud",
2658
+ hostWorkspace: box.workspacePath,
2659
+ boxWorkspace: CLOUD_WORKSPACE_DIR,
2660
+ onLog
2661
+ });
2662
+ return makeCloudSync(backend, handleFor(box)).resyncWorkspace(ctx, worktrees);
2663
+ },
2664
+ // Extract the box's agent login(s) back to the host (~/.agentbox) so the
2665
+ // next box inherits the login. Lives on the base cloud provider (not inside
2666
+ // `checkpoint.create`) so it works even for providers that override the
2667
+ // whole `checkpoint` capability (vercel). The CLI calls this on
2668
+ // `checkpoint create --set-default`, while the box is guaranteed running.
2669
+ async extractAgentCredentials(box) {
2670
+ if (!box.cloud?.sandboxId) return [];
2671
+ const ctx = makeSyncContext({
2672
+ boxName: box.name,
2673
+ boxId: box.id,
2674
+ provider: "cloud",
2675
+ hostWorkspace: box.workspacePath
2676
+ });
2677
+ return makeCloudSync(backend, handleFor(box)).extractCredentials(ctx);
2678
+ }
2679
+ // stats is provider-optional; cloud backends without a metrics API just
2680
+ // omit it. Backends that have one can decorate the returned provider.
2681
+ };
2682
+ }
2683
+ var RESERVED_CLOUD_PORTS = /* @__PURE__ */ new Set([CLOUD_WEB_PROXY_PORT, CLOUD_VNC_PORT, 8788]);
2684
+ async function firstExposedServicePort(box) {
2685
+ const reserved = (p) => RESERVED_CLOUD_PORTS.has(p) || p === box.cloud?.webPort;
2686
+ const fromRecord = Object.keys(box.cloud?.previewUrls ?? {}).map(Number).filter((p) => Number.isInteger(p) && !reserved(p));
2687
+ if (fromRecord.length > 0) return Math.min(...fromRecord);
2688
+ try {
2689
+ const fromYaml = (await readExposedServicePorts(box.workspacePath)).filter((p) => !reserved(p));
2690
+ if (fromYaml.length > 0) return Math.min(...fromYaml);
2691
+ } catch {
2692
+ }
2693
+ return void 0;
2694
+ }
2695
+ function makeCloudCheckpoint(backend) {
2696
+ return {
2697
+ async create(box, name) {
2698
+ if (!backend.createSnapshot) {
2699
+ throw new Error(
2700
+ `cloud backend '${backend.name}' doesn't support snapshots \u2014 \`agentbox checkpoint\` unavailable`
2701
+ );
2702
+ }
2703
+ if (!box.projectRoot) {
2704
+ throw new Error(
2705
+ `cloud checkpoint requires the box to have a project root (run \`agentbox checkpoint\` from inside the project)`
2706
+ );
2707
+ }
2708
+ if (!box.cloud?.sandboxId) {
2709
+ throw new Error(`cloud box ${box.name} has no sandboxId \u2014 record is malformed`);
2710
+ }
2711
+ const snapshotName = cloudSnapshotName(box.projectRoot, name);
2712
+ await backend.createSnapshot({ sandboxId: box.cloud.sandboxId }, snapshotName);
2713
+ const info = await writeCloudCheckpointManifest(box.projectRoot, backend.name, name, {
2714
+ snapshotName,
2715
+ sourceBoxId: box.id,
2716
+ sourceBoxName: box.name,
2717
+ baseProvider: backend.name,
2718
+ baseFingerprint: currentCloudBaseFingerprint(backend.name),
2719
+ cliVersion: readCliStamp().cliVersion
2720
+ });
2721
+ return { ref: info.name };
2722
+ },
2723
+ async list(projectRoot) {
2724
+ const entries = await listCloudCheckpoints(projectRoot, backend.name);
2725
+ return entries.map((e) => ({ ref: e.name, createdAt: e.manifest.createdAt }));
2726
+ },
2727
+ async remove(projectRoot, ref) {
2728
+ const entry = await resolveCloudCheckpoint(projectRoot, backend.name, ref);
2729
+ if (!entry) return;
2730
+ if (backend.deleteSnapshot) {
2731
+ try {
2732
+ await backend.deleteSnapshot(entry.manifest.snapshotName);
2733
+ } catch {
2734
+ }
2735
+ }
2736
+ await removeCloudCheckpointDir(projectRoot, backend.name, ref);
2737
+ }
2738
+ };
2739
+ }
2740
+ function hostTermForCloud() {
2741
+ const t = process.env["TERM"];
2742
+ return t && /^[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(t) ? t : "xterm-256color";
2743
+ }
2744
+ function renderInnerCommand(kind, opts) {
2745
+ const sessionName = opts?.sessionName ?? defaultSessionName(kind);
2746
+ const fallback = opts?.command ?? defaultCommand(kind, opts);
2747
+ if (kind === "logs") {
2748
+ return fallback;
2749
+ }
2750
+ if (opts?.noTmux) {
2751
+ return fallback;
2752
+ }
2753
+ const sessionQ = shellSingle(sessionName);
2754
+ const cwdQ = shellSingle(CLOUD_WORKSPACE_DIR);
2755
+ const fallbackQ = shellSingle(fallback);
2756
+ const configSnippet = buildTmuxConfigShellSnippet(sessionName);
2757
+ const lines = [
2758
+ `command -v tmux >/dev/null || { echo "tmux not installed in sandbox"; exit 127; }`,
2759
+ `tmux has-session -t ${sessionQ} 2>/dev/null || tmux new-session -d -c ${cwdQ} -s ${sessionQ} ${fallbackQ}`,
2760
+ configSnippet
2761
+ ];
2762
+ if (opts?.detached) return TERM_FALLBACK_SNIPPET + lines.join("; ");
2763
+ return TERM_FALLBACK_SNIPPET + [...lines, `exec tmux attach -t ${sessionQ}`].join("; ");
2764
+ }
2765
+ function defaultSessionName(kind) {
2766
+ switch (kind) {
2767
+ case "shell":
2768
+ return "shell";
2769
+ case "agent":
2770
+ return "agent";
2771
+ case "logs":
2772
+ return "logs";
2773
+ }
2774
+ }
2775
+ function defaultCommand(kind, opts) {
2776
+ switch (kind) {
2777
+ case "shell":
2778
+ return "bash -l";
2779
+ case "agent":
2780
+ return "bash -l";
2781
+ case "logs": {
2782
+ if (!opts?.service) {
2783
+ return 'echo "no service specified \u2014 set BuildAttachOptions.service"';
2784
+ }
2785
+ const tail = opts.tail !== void 0 ? String(opts.tail) : "200";
2786
+ const args = [`--tail ${shellSingle(tail)}`];
2787
+ if (opts.follow !== false) args.push("--follow");
2788
+ return `/usr/local/bin/agentbox-ctl logs ${shellSingle(opts.service)} ${args.join(" ")}`;
2789
+ }
2790
+ }
2791
+ }
2792
+ function shellSingle(s) {
2793
+ return "'" + s.replace(/'/g, "'\\''") + "'";
2794
+ }
2795
+
2796
+ export {
2797
+ listCloudCheckpoints,
2798
+ resolveCloudCheckpoint,
2799
+ writeCloudCheckpointManifest,
2800
+ currentCloudBaseFingerprint,
2801
+ baseFreshnessFromFingerprints,
2802
+ removeCloudCheckpointDir,
2803
+ createCloudProvider,
2804
+ hostTermForCloud,
2805
+ renderInnerCommand
2806
+ };