@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,2281 @@
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
+ $e,
4
+ BD,
5
+ L,
6
+ fe,
7
+ me,
8
+ v,
9
+ ve,
10
+ we,
11
+ ye
12
+ } from "./chunk-OF242BLD.js";
13
+ import {
14
+ createCloudProvider
15
+ } from "./chunk-JDA7BPPN.js";
16
+ import {
17
+ detectPortless,
18
+ portlessDoctorRow
19
+ } from "./chunk-V5KGFHCF.js";
20
+ import "./chunk-AKLBSCSZ.js";
21
+ import "./chunk-3LAHFDJF.js";
22
+ import {
23
+ UserFacingError,
24
+ claudeInstallFingerprint,
25
+ computeContextSha256,
26
+ errSummary,
27
+ hostOpenCommand,
28
+ preparedStatePathFor,
29
+ readCliStamp,
30
+ readPreparedStateRaw,
31
+ stageAgentsStaticForUpload,
32
+ stageClaudeStaticForUpload,
33
+ stageCodexStaticForUpload,
34
+ stageOpencodeStaticForUpload,
35
+ writeManagedSecrets,
36
+ writePreparedStateRaw
37
+ } from "./chunk-LJG4CEGS.js";
38
+ import {
39
+ execa
40
+ } from "./chunk-EFW34I43.js";
41
+ import "./chunk-TZFWAJVB.js";
42
+
43
+ // ../../packages/sandbox-hetzner/dist/chunk-3ZWBEZND.js
44
+ import { existsSync, readFileSync } from "fs";
45
+ import { homedir } from "os";
46
+ import { resolve } from "path";
47
+ import { spawnSync } from "child_process";
48
+ import { homedir as homedir2 } from "os";
49
+ import { resolve as resolve2 } from "path";
50
+ import { existsSync as existsSync2 } from "fs";
51
+ import { dirname, resolve as resolve3 } from "path";
52
+ import { fileURLToPath } from "url";
53
+ var HETZNER_KEYS = ["HCLOUD_TOKEN", "HCLOUD_ENDPOINT"];
54
+ var loaded = false;
55
+ function ensureHetznerEnvLoaded() {
56
+ if (loaded) return;
57
+ loaded = true;
58
+ importHetznerFromFile(resolve(homedir(), ".agentbox", "secrets.env"));
59
+ }
60
+ function importHetznerFromFile(path) {
61
+ if (!existsSync(path)) return;
62
+ let body;
63
+ try {
64
+ body = readFileSync(path, "utf8");
65
+ } catch {
66
+ return;
67
+ }
68
+ const parsed = parseEnvFile(body);
69
+ for (const key of HETZNER_KEYS) {
70
+ if (process.env[key] !== void 0) continue;
71
+ const value = parsed[key];
72
+ if (typeof value === "string") {
73
+ process.env[key] = value;
74
+ }
75
+ }
76
+ }
77
+ function parseEnvFile(body) {
78
+ const out = {};
79
+ for (const rawLine of body.split(/\r?\n/)) {
80
+ const line = rawLine.trim();
81
+ if (line.length === 0 || line.startsWith("#")) continue;
82
+ const stripped = line.startsWith("export ") ? line.slice("export ".length) : line;
83
+ const eq = stripped.indexOf("=");
84
+ if (eq <= 0) continue;
85
+ const key = stripped.slice(0, eq).trim();
86
+ let value = stripped.slice(eq + 1).trim();
87
+ if (value.length >= 2 && (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'"))) {
88
+ value = value.slice(1, -1);
89
+ }
90
+ out[key] = value;
91
+ }
92
+ return out;
93
+ }
94
+ var DEFAULT_HCLOUD_ENDPOINT = "https://api.hetzner.cloud/v1";
95
+ var HetznerApiError = class extends Error {
96
+ statusCode;
97
+ code;
98
+ details;
99
+ constructor(statusCode, code, message, details) {
100
+ super(`hetzner ${String(statusCode)} ${code}: ${message}`);
101
+ this.name = "HetznerApiError";
102
+ this.statusCode = statusCode;
103
+ this.code = code;
104
+ this.details = details;
105
+ }
106
+ };
107
+ function makeHetznerClient(opts = {}) {
108
+ ensureHetznerEnvLoaded();
109
+ const rawToken = opts.token ?? process.env.HCLOUD_TOKEN;
110
+ if (!rawToken || rawToken.trim().length === 0) {
111
+ throw new Error(
112
+ "Hetzner credentials not configured: HCLOUD_TOKEN is empty.\nRun `agentbox hetzner login` interactively, or set HCLOUD_TOKEN in the environment."
113
+ );
114
+ }
115
+ const token = rawToken.trim();
116
+ const endpoint = (opts.endpoint ?? process.env.HCLOUD_ENDPOINT ?? DEFAULT_HCLOUD_ENDPOINT).replace(/\/$/, "");
117
+ const fetchImpl = opts.fetchImpl ?? fetch;
118
+ async function req(method, path, body) {
119
+ const url = `${endpoint}${path}`;
120
+ const init = {
121
+ method,
122
+ headers: {
123
+ Authorization: `Bearer ${token}`,
124
+ ...body !== void 0 ? { "Content-Type": "application/json" } : {}
125
+ },
126
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
127
+ };
128
+ const res = await fetchImpl(url, init);
129
+ if (res.status === 204) return null;
130
+ if (res.status === 404) return null;
131
+ if (!res.ok) {
132
+ let parsed = {};
133
+ try {
134
+ parsed = await res.json();
135
+ } catch {
136
+ }
137
+ const code = parsed.error?.code ?? `http_${String(res.status)}`;
138
+ const msg = parsed.error?.message ?? res.statusText ?? "unknown error";
139
+ throw new HetznerApiError(res.status, code, msg, parsed.error?.details);
140
+ }
141
+ const text = await res.text();
142
+ if (text.length === 0) return null;
143
+ return JSON.parse(text);
144
+ }
145
+ async function reqExpect(method, path, body) {
146
+ const out = await req(method, path, body);
147
+ if (out === null) {
148
+ throw new HetznerApiError(0, "empty_response", `expected a body from ${method} ${path}`);
149
+ }
150
+ return out;
151
+ }
152
+ return {
153
+ async getServer(id) {
154
+ const r = await req("GET", `/servers/${String(id)}`);
155
+ return r?.server ?? null;
156
+ },
157
+ async createServer(reqBody) {
158
+ const r = await reqExpect(
159
+ "POST",
160
+ "/servers",
161
+ reqBody
162
+ );
163
+ return { server: r.server, action: r.action };
164
+ },
165
+ async listServers(opts2) {
166
+ const params = new URLSearchParams();
167
+ if (opts2?.label_selector) params.set("label_selector", opts2.label_selector);
168
+ params.set("per_page", "50");
169
+ const all = [];
170
+ let pageNum = 1;
171
+ while (true) {
172
+ params.set("page", String(pageNum));
173
+ const r = await reqExpect("GET", `/servers?${params.toString()}`);
174
+ all.push(...r.servers);
175
+ const next = r.meta?.pagination?.next_page;
176
+ if (typeof next !== "number") break;
177
+ pageNum = next;
178
+ }
179
+ return all;
180
+ },
181
+ async deleteServer(id) {
182
+ const r = await req("DELETE", `/servers/${String(id)}`);
183
+ return r?.action ?? null;
184
+ },
185
+ async powerOn(id) {
186
+ const r = await reqExpect(
187
+ "POST",
188
+ `/servers/${String(id)}/actions/poweron`
189
+ );
190
+ return r.action;
191
+ },
192
+ async powerOff(id) {
193
+ const r = await reqExpect(
194
+ "POST",
195
+ `/servers/${String(id)}/actions/poweroff`
196
+ );
197
+ return r.action;
198
+ },
199
+ async shutdown(id) {
200
+ const r = await reqExpect(
201
+ "POST",
202
+ `/servers/${String(id)}/actions/shutdown`
203
+ );
204
+ return r.action;
205
+ },
206
+ async createImage(id, body) {
207
+ const r = await reqExpect(
208
+ "POST",
209
+ `/servers/${String(id)}/actions/create_image`,
210
+ body
211
+ );
212
+ return { image: r.image, action: r.action };
213
+ },
214
+ async getImage(id) {
215
+ const r = await req("GET", `/images/${String(id)}`);
216
+ return r?.image ?? null;
217
+ },
218
+ async listImages(opts2) {
219
+ const params = new URLSearchParams();
220
+ if (opts2?.type) params.set("type", opts2.type);
221
+ if (opts2?.label_selector) params.set("label_selector", opts2.label_selector);
222
+ if (opts2?.name) params.set("name", opts2.name);
223
+ params.set("per_page", "50");
224
+ const all = [];
225
+ let pageNum = 1;
226
+ while (true) {
227
+ params.set("page", String(pageNum));
228
+ const r = await reqExpect("GET", `/images?${params.toString()}`);
229
+ all.push(...r.images);
230
+ const next = r.meta?.pagination?.next_page;
231
+ if (typeof next !== "number") break;
232
+ pageNum = next;
233
+ }
234
+ return all;
235
+ },
236
+ async deleteImage(id) {
237
+ await req("DELETE", `/images/${String(id)}`);
238
+ },
239
+ async createFirewall(reqBody) {
240
+ const r = await reqExpect("POST", "/firewalls", reqBody);
241
+ return r.firewall;
242
+ },
243
+ async setFirewallRules(id, rules) {
244
+ const r = await reqExpect(
245
+ "POST",
246
+ `/firewalls/${String(id)}/actions/set_rules`,
247
+ { rules }
248
+ );
249
+ return r.actions;
250
+ },
251
+ async getFirewall(id) {
252
+ const r = await req("GET", `/firewalls/${String(id)}`);
253
+ return r?.firewall ?? null;
254
+ },
255
+ async deleteFirewall(id) {
256
+ await req("DELETE", `/firewalls/${String(id)}`);
257
+ },
258
+ async listLocations() {
259
+ const r = await reqExpect("GET", "/locations");
260
+ return r.locations;
261
+ }
262
+ };
263
+ }
264
+ function exitOnCancel(v2) {
265
+ if (BD(v2)) {
266
+ ve("Cancelled.");
267
+ process.exit(130);
268
+ }
269
+ return v2;
270
+ }
271
+ var DASHBOARD_KEYS_URL = "https://console.hetzner.cloud/projects";
272
+ var MANAGED_KEYS = ["HCLOUD_TOKEN", "HCLOUD_ENDPOINT"];
273
+ async function ensureHetznerCredentials(opts = {}) {
274
+ ensureHetznerEnvLoaded();
275
+ if (!opts.force && hasUsableCredentials()) return;
276
+ if (!process.stdin.isTTY) return;
277
+ we("Hetzner Cloud setup");
278
+ ye(
279
+ `AgentBox needs a Hetzner Cloud API token (project-scoped) to provision VPSes.
280
+
281
+ 1. Open ${DASHBOARD_KEYS_URL}
282
+ 2. Pick a project (or create one).
283
+ 3. Security \u2192 API Tokens \u2192 Generate API Token (Read + Write).`,
284
+ "API token required"
285
+ );
286
+ const open = exitOnCancel(
287
+ await me({
288
+ message: `Open ${DASHBOARD_KEYS_URL} in your browser?`,
289
+ initialValue: true
290
+ })
291
+ );
292
+ if (open) openDashboard();
293
+ for (let attempt = 0; attempt < 2; attempt++) {
294
+ const creds = await promptForCredentials();
295
+ const result = await validateCredentials(creds);
296
+ if (result.ok) {
297
+ persistCredentials(creds);
298
+ v.success(`Hetzner credentials saved to ${secretsPath()}`);
299
+ fe("Setup complete.");
300
+ return;
301
+ }
302
+ if (result.kind === "auth" && attempt === 0) {
303
+ v.error(`That token was rejected by Hetzner: ${result.message}`);
304
+ v.info("Try again, or press Ctrl-C to cancel.");
305
+ continue;
306
+ }
307
+ if (result.kind === "network") {
308
+ v.warn(`Could not reach Hetzner to validate (${result.message}) \u2014 saving anyway.`);
309
+ persistCredentials(creds);
310
+ v.success(`Hetzner credentials saved to ${secretsPath()}`);
311
+ fe("Setup complete (unvalidated).");
312
+ return;
313
+ }
314
+ throw new Error(`Hetzner credentials rejected: ${result.message}`);
315
+ }
316
+ }
317
+ function hasUsableCredentials() {
318
+ return typeof process.env.HCLOUD_TOKEN === "string" && process.env.HCLOUD_TOKEN.length > 0;
319
+ }
320
+ async function promptForCredentials() {
321
+ const token = exitOnCancel(
322
+ await $e({
323
+ message: "Paste your Hetzner Cloud API token",
324
+ validate(v2) {
325
+ if (!v2 || v2.trim().length === 0) return "Cannot be empty";
326
+ return void 0;
327
+ }
328
+ })
329
+ );
330
+ return { token: token.trim() };
331
+ }
332
+ async function validateCredentials(creds) {
333
+ const s = L();
334
+ s.start("Validating credentials with Hetzner");
335
+ try {
336
+ const client2 = makeHetznerClient({ token: creds.token, endpoint: creds.endpoint });
337
+ await client2.listLocations();
338
+ s.stop("Hetzner credentials accepted");
339
+ return { ok: true };
340
+ } catch (err) {
341
+ const message = err instanceof Error ? err.message : String(err);
342
+ s.stop("Hetzner credentials check failed");
343
+ if (/401|403|unauthor|forbidden|invalid|token/i.test(message)) {
344
+ return { ok: false, kind: "auth", message };
345
+ }
346
+ return { ok: false, kind: "network", message };
347
+ }
348
+ }
349
+ function persistCredentials(creds) {
350
+ const record = { HCLOUD_TOKEN: creds.token };
351
+ if (creds.endpoint) record.HCLOUD_ENDPOINT = creds.endpoint;
352
+ writeManagedSecrets(MANAGED_KEYS, record);
353
+ }
354
+ async function setHetznerCredentials(fields) {
355
+ const token = (fields.token ?? "").trim();
356
+ const endpoint = (fields.endpoint ?? "").trim() || void 0;
357
+ if (!token) {
358
+ return { ok: false, error: "token is required", status: { configured: false } };
359
+ }
360
+ const creds = { token, endpoint };
361
+ const result = await validateCredentials(creds);
362
+ if (!result.ok && result.kind === "auth") {
363
+ return { ok: false, error: `token rejected by Hetzner: ${result.message}`, status: { configured: false } };
364
+ }
365
+ persistCredentials(creds);
366
+ const label = result.ok ? "token" : "token (unvalidated)";
367
+ return { ok: true, status: { configured: true, label } };
368
+ }
369
+ function openDashboard() {
370
+ try {
371
+ const r = spawnSync(hostOpenCommand(), [DASHBOARD_KEYS_URL], { stdio: "ignore" });
372
+ if (r.status !== 0) {
373
+ v.warn(`Could not auto-open the browser \u2014 visit ${DASHBOARD_KEYS_URL} manually.`);
374
+ }
375
+ } catch {
376
+ v.warn(`Could not auto-open the browser \u2014 visit ${DASHBOARD_KEYS_URL} manually.`);
377
+ }
378
+ }
379
+ function secretsPath() {
380
+ return resolve2(homedir2(), ".agentbox", "secrets.env");
381
+ }
382
+ function readHetznerCredStatus() {
383
+ const shellHadToken = !!process.env.HCLOUD_TOKEN;
384
+ ensureHetznerEnvLoaded();
385
+ const token = process.env.HCLOUD_TOKEN;
386
+ const endpoint = process.env.HCLOUD_ENDPOINT;
387
+ if (!token) return { source: "none" };
388
+ return {
389
+ token,
390
+ endpoint,
391
+ source: shellHadToken ? "env" : "secrets.env"
392
+ };
393
+ }
394
+ function maskKey(value) {
395
+ if (value.length <= 8) return "*".repeat(value.length);
396
+ return `${value.slice(0, 4)}\u2026${"*".repeat(8)}${value.slice(-4)}`;
397
+ }
398
+ var PROBES = [
399
+ "https://api.ipify.org",
400
+ "https://ifconfig.io/ip",
401
+ "https://icanhazip.com"
402
+ ];
403
+ var TIMEOUT_MS = 3e3;
404
+ var IPV4_RE = /^(?:\d{1,3}\.){3}\d{1,3}$/;
405
+ var IPV6_RE = /^[0-9a-fA-F:]+$/;
406
+ async function detectEgressIp(opts = {}) {
407
+ const probes = opts.probes ?? PROBES;
408
+ const timeout = opts.timeoutMs ?? TIMEOUT_MS;
409
+ const fetchImpl = opts.fetchImpl ?? fetch;
410
+ const errors = [];
411
+ for (const url of probes) {
412
+ try {
413
+ const ip = await raceTimeout(probe(url, fetchImpl), timeout);
414
+ if (ip) {
415
+ opts.onLog?.(`egress-ip: detected ${ip} via ${url}`);
416
+ return ip;
417
+ }
418
+ errors.push(`${url}: empty/invalid response`);
419
+ } catch (err) {
420
+ errors.push(`${url}: ${err instanceof Error ? err.message : String(err)}`);
421
+ }
422
+ }
423
+ throw new Error(
424
+ `could not auto-detect the host's egress IP \u2014 all ${String(probes.length)} probes failed:
425
+ ` + errors.map((e) => ` - ${e}`).join("\n") + `
426
+ Override with --firewall-source <cidr> (e.g. --firewall-source 0.0.0.0/0 for the explicit-open opt-in).`
427
+ );
428
+ }
429
+ async function probe(url, fetchImpl) {
430
+ const res = await fetchImpl(url, { method: "GET" });
431
+ if (!res.ok) return null;
432
+ const body = (await res.text()).trim();
433
+ if (IPV4_RE.test(body)) {
434
+ const parts = body.split(".").map((p) => Number.parseInt(p, 10));
435
+ if (parts.every((p) => p >= 0 && p <= 255)) return body;
436
+ return null;
437
+ }
438
+ if (IPV6_RE.test(body) && body.includes(":")) return body;
439
+ return null;
440
+ }
441
+ async function raceTimeout(p, ms) {
442
+ let timer;
443
+ try {
444
+ return await Promise.race([
445
+ p,
446
+ new Promise((_resolve, reject) => {
447
+ timer = setTimeout(() => reject(new Error(`probe timed out after ${String(ms)}ms`)), ms);
448
+ })
449
+ ]);
450
+ } finally {
451
+ if (timer !== void 0) clearTimeout(timer);
452
+ }
453
+ }
454
+ var DEFAULT_BACKOFF = [1e3, 2e3, 4e3];
455
+ var DEFAULT_ATTEMPT_TIMEOUT_MS = 3e4;
456
+ var AttemptTimeoutError = class extends Error {
457
+ constructor(method, ms) {
458
+ super(`hetzner ${method}: per-attempt timeout after ${String(ms)}ms`);
459
+ this.name = "AttemptTimeoutError";
460
+ }
461
+ };
462
+ function isAttemptTimeout(err) {
463
+ return err instanceof AttemptTimeoutError;
464
+ }
465
+ function isRetriable(err, allowAmbiguous) {
466
+ if (err instanceof HetznerApiError) {
467
+ if (err.statusCode === 429 || err.code === "rate_limit_exceeded") return true;
468
+ if (err.statusCode >= 500 && err.statusCode <= 599) return allowAmbiguous;
469
+ if (err.code === "locked" || err.code === "conflict") return true;
470
+ return false;
471
+ }
472
+ if (err instanceof AttemptTimeoutError) return allowAmbiguous;
473
+ if (err && typeof err === "object") {
474
+ const candidates = [err, err.cause];
475
+ for (const c of candidates) {
476
+ if (!c || typeof c !== "object") continue;
477
+ const code = c.code;
478
+ if (code === "ECONNRESET" || code === "ETIMEDOUT" || code === "ECONNABORTED" || code === "EAI_AGAIN" || code === "ECONNREFUSED" || code === "ENOTFOUND" || code === "UND_ERR_SOCKET" || code === "UND_ERR_CONNECT_TIMEOUT") {
479
+ return allowAmbiguous;
480
+ }
481
+ }
482
+ }
483
+ return false;
484
+ }
485
+ async function withHetznerRetry(opts, fn) {
486
+ const backoff = opts.backoffMs ?? DEFAULT_BACKOFF;
487
+ const maxAttempts = backoff.length + 1;
488
+ const timeoutMs = opts.attemptTimeoutMs ?? DEFAULT_ATTEMPT_TIMEOUT_MS;
489
+ const log2 = opts.onRetry ?? defaultRetryLog;
490
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
491
+ try {
492
+ return await raceTimeout2(fn(), timeoutMs, opts.method);
493
+ } catch (err) {
494
+ const last = attempt === maxAttempts;
495
+ if (last || !isRetriable(err, opts.retryOnAmbiguous)) throw err;
496
+ const delay = backoff[attempt - 1] ?? backoff[backoff.length - 1] ?? 4e3;
497
+ log2(
498
+ `hetzner ${opts.method}: attempt ${String(attempt)} failed (${errorSummary(err)}); retrying in ${String(delay)}ms`
499
+ );
500
+ await sleep(delay);
501
+ }
502
+ }
503
+ throw new Error(`withHetznerRetry: exhausted attempts for ${opts.method}`);
504
+ }
505
+ function defaultRetryLog(line) {
506
+ process.stderr.write(`
507
+ [hetzner-retry] ${line}
508
+ `);
509
+ }
510
+ function sleep(ms) {
511
+ return new Promise((resolve42) => setTimeout(resolve42, ms));
512
+ }
513
+ async function raceTimeout2(p, ms, method) {
514
+ let timer;
515
+ try {
516
+ return await Promise.race([
517
+ p,
518
+ new Promise((_resolve, reject) => {
519
+ timer = setTimeout(() => reject(new AttemptTimeoutError(method, ms)), ms);
520
+ })
521
+ ]);
522
+ } finally {
523
+ if (timer !== void 0) clearTimeout(timer);
524
+ }
525
+ }
526
+ function errorSummary(err) {
527
+ if (err instanceof HetznerApiError) {
528
+ return `HetznerApiError ${String(err.statusCode)} ${err.code}: ${truncate(err.message)}`;
529
+ }
530
+ if (err instanceof Error) {
531
+ const code = err.code;
532
+ return code !== void 0 ? `${err.name}(${String(code)}): ${truncate(err.message)}` : `${err.name}: ${truncate(err.message)}`;
533
+ }
534
+ return truncate(String(err));
535
+ }
536
+ function truncate(s, max = 160) {
537
+ return s.length > max ? `${s.slice(0, max)}\u2026` : s;
538
+ }
539
+ function sshOnlyInboundRule(sourceCidr) {
540
+ return [
541
+ {
542
+ direction: "in",
543
+ protocol: "tcp",
544
+ port: "22",
545
+ source_ips: [sourceCidr],
546
+ description: "agentbox: SSH from host egress IP only"
547
+ }
548
+ ];
549
+ }
550
+ function controlPlaneInboundRules(hostCidr) {
551
+ return [
552
+ {
553
+ direction: "in",
554
+ protocol: "tcp",
555
+ port: "22",
556
+ source_ips: [hostCidr],
557
+ description: "agentbox control plane: SSH from host egress IP only"
558
+ },
559
+ {
560
+ direction: "in",
561
+ protocol: "tcp",
562
+ port: "80",
563
+ source_ips: ["0.0.0.0/0", "::/0"],
564
+ description: "agentbox control plane: HTTP (ACME challenge + redirect)"
565
+ },
566
+ {
567
+ direction: "in",
568
+ protocol: "tcp",
569
+ port: "443",
570
+ source_ips: ["0.0.0.0/0", "::/0"],
571
+ description: "agentbox control plane: HTTPS"
572
+ }
573
+ ];
574
+ }
575
+ async function createPerBoxFirewall(client2, opts) {
576
+ return withHetznerRetry(
577
+ { method: "createFirewall", retryOnAmbiguous: false, attemptTimeoutMs: 6e4 },
578
+ () => client2.createFirewall({
579
+ name: opts.name,
580
+ rules: sshOnlyInboundRule(opts.sourceCidr),
581
+ labels: {
582
+ "agentbox.managed": "true",
583
+ "agentbox.role": "box",
584
+ ...opts.labels
585
+ }
586
+ })
587
+ );
588
+ }
589
+ async function syncFirewallSource(client2, firewallId, sourceCidr) {
590
+ await withHetznerRetry(
591
+ { method: "setFirewallRules", retryOnAmbiguous: true, attemptTimeoutMs: 6e4 },
592
+ () => client2.setFirewallRules(firewallId, sshOnlyInboundRule(sourceCidr))
593
+ );
594
+ }
595
+ async function deletePerBoxFirewall(client2, firewallId, opts = {}) {
596
+ const deadline = Date.now() + (opts.detachWaitMs ?? 6e4);
597
+ let interval = 1e3;
598
+ while (true) {
599
+ try {
600
+ await withHetznerRetry(
601
+ { method: "deleteFirewall", retryOnAmbiguous: true, attemptTimeoutMs: 3e4 },
602
+ () => client2.deleteFirewall(firewallId)
603
+ );
604
+ return;
605
+ } catch (err) {
606
+ if (err instanceof HetznerApiError && (err.statusCode === 404 || err.code === "not_found")) {
607
+ return;
608
+ }
609
+ const stillAttached = err instanceof HetznerApiError && (err.statusCode === 409 || err.code === "conflict" || err.code === "resource_in_use");
610
+ if (stillAttached && Date.now() < deadline) {
611
+ await new Promise((r) => setTimeout(r, interval));
612
+ interval = Math.min(interval * 2, 8e3);
613
+ continue;
614
+ }
615
+ throw err;
616
+ }
617
+ }
618
+ }
619
+ function firewallNeedsSync(allowedSource, currentEgress) {
620
+ if (allowedSource === "0.0.0.0/0") return false;
621
+ return allowedSource !== currentEgress;
622
+ }
623
+ function normalizeSourceCidr(raw) {
624
+ const trimmed = raw.trim();
625
+ if (trimmed.includes("/")) return trimmed;
626
+ if (trimmed.includes(":")) return `${trimmed}/128`;
627
+ return `${trimmed}/32`;
628
+ }
629
+ var SELF = dirname(fileURLToPath(import.meta.url));
630
+ function findStagedCliRuntimeRoot() {
631
+ const candidates = [
632
+ resolve3(SELF, "..", "runtime"),
633
+ // <cliRoot>/dist/.. → <cliRoot> then /runtime
634
+ resolve3(SELF, "..", "..", "runtime")
635
+ // chunk-NNNN.js at <cliRoot>/dist/<sub>/.. → <cliRoot>/runtime
636
+ ];
637
+ for (const c of candidates) {
638
+ if (existsSync2(resolve3(c, "hetzner", "scripts", "install-box.sh"))) return c;
639
+ }
640
+ return void 0;
641
+ }
642
+ var RUNTIME_ASSETS = [
643
+ { name: "install-box.sh", remoteBasename: "agentbox-install.sh", remoteMode: 493 },
644
+ { name: "agentbox-ctl", remoteBasename: "agentbox-ctl", remoteMode: 493 },
645
+ { name: "agentbox-vnc-start", remoteBasename: "agentbox-vnc-start", remoteMode: 493 },
646
+ { name: "agentbox-dockerd-start", remoteBasename: "agentbox-dockerd-start", remoteMode: 493 },
647
+ { name: "agentbox-portless-trust", remoteBasename: "agentbox-portless-trust", remoteMode: 493 },
648
+ { name: "agentbox-checkpoint-cleanup", remoteBasename: "agentbox-checkpoint-cleanup", remoteMode: 493 },
649
+ { name: "agentbox-open", remoteBasename: "agentbox-open", remoteMode: 493 },
650
+ { name: "gh-shim", remoteBasename: "agentbox-gh-shim", remoteMode: 493 },
651
+ { name: "git-shim", remoteBasename: "agentbox-git-shim", remoteMode: 493 },
652
+ { name: "ntn-shim", remoteBasename: "agentbox-ntn-shim", remoteMode: 493 },
653
+ { name: "linear-shim", remoteBasename: "agentbox-linear-shim", remoteMode: 493 },
654
+ { name: "custom-system-CLAUDE.md", remoteBasename: "agentbox-custom-CLAUDE.md", remoteMode: 420 },
655
+ { name: "claude-managed-settings.json", remoteBasename: "agentbox-managed-settings.json", remoteMode: 420 },
656
+ { name: "agentbox-codex-hooks.json", remoteBasename: "agentbox-codex-hooks.json", remoteMode: 420 },
657
+ { name: "agentbox-setup-skill.md", remoteBasename: "agentbox-setup-skill.md", remoteMode: 420 }
658
+ ];
659
+ function candidatesFor(name, opts = {}) {
660
+ const cliRoot = opts.cliRuntimeRoot;
661
+ const monorepo = opts.repoRoot ?? guessRepoRoot();
662
+ const monorepoRelative = {
663
+ "install-box.sh": ["packages/sandbox-hetzner/scripts/install-box.sh"],
664
+ "agentbox-ctl": ["packages/ctl/dist/bin.cjs"],
665
+ "agentbox-vnc-start": ["packages/sandbox-docker/scripts/agentbox-vnc-start"],
666
+ "agentbox-dockerd-start": ["packages/sandbox-docker/scripts/agentbox-dockerd-start"],
667
+ "agentbox-portless-trust": ["packages/sandbox-docker/scripts/agentbox-portless-trust"],
668
+ "agentbox-checkpoint-cleanup": ["packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup"],
669
+ "agentbox-open": ["packages/sandbox-docker/scripts/agentbox-open"],
670
+ "gh-shim": ["packages/sandbox-docker/scripts/gh-shim"],
671
+ "git-shim": ["packages/sandbox-docker/scripts/git-shim"],
672
+ "ntn-shim": ["packages/sandbox-docker/scripts/ntn-shim"],
673
+ "linear-shim": ["packages/sandbox-docker/scripts/linear-shim"],
674
+ "custom-system-CLAUDE.md": ["packages/sandbox-hetzner/scripts/custom-system-CLAUDE.md"],
675
+ "claude-managed-settings.json": ["packages/sandbox-docker/scripts/claude-managed-settings.json"],
676
+ "agentbox-codex-hooks.json": ["packages/sandbox-docker/scripts/agentbox-codex-hooks.json"],
677
+ "agentbox-setup-skill.md": ["apps/cli/share/agentbox-setup/SKILL.md"]
678
+ };
679
+ const cliRelative = {
680
+ "install-box.sh": ["hetzner/scripts/install-box.sh"],
681
+ "agentbox-ctl": ["hetzner/ctl.cjs"],
682
+ "agentbox-vnc-start": ["hetzner/agentbox-vnc-start", "docker/packages/sandbox-docker/scripts/agentbox-vnc-start"],
683
+ "agentbox-dockerd-start": ["hetzner/agentbox-dockerd-start", "docker/packages/sandbox-docker/scripts/agentbox-dockerd-start"],
684
+ "agentbox-portless-trust": ["hetzner/agentbox-portless-trust", "docker/packages/sandbox-docker/scripts/agentbox-portless-trust"],
685
+ "agentbox-checkpoint-cleanup": ["hetzner/agentbox-checkpoint-cleanup", "docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup"],
686
+ "agentbox-open": ["hetzner/agentbox-open", "docker/packages/sandbox-docker/scripts/agentbox-open"],
687
+ "gh-shim": ["hetzner/gh-shim", "docker/packages/sandbox-docker/scripts/gh-shim"],
688
+ "git-shim": ["hetzner/git-shim", "docker/packages/sandbox-docker/scripts/git-shim"],
689
+ "ntn-shim": ["hetzner/ntn-shim", "docker/packages/sandbox-docker/scripts/ntn-shim"],
690
+ "linear-shim": ["hetzner/linear-shim", "docker/packages/sandbox-docker/scripts/linear-shim"],
691
+ "custom-system-CLAUDE.md": ["hetzner/custom-system-CLAUDE.md"],
692
+ "claude-managed-settings.json": ["hetzner/claude-managed-settings.json", "docker/packages/sandbox-docker/scripts/claude-managed-settings.json"],
693
+ "agentbox-codex-hooks.json": ["hetzner/agentbox-codex-hooks.json", "docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json"],
694
+ "agentbox-setup-skill.md": ["hetzner/agentbox-setup-skill.md", "docker/apps/cli/share/agentbox-setup/SKILL.md"]
695
+ };
696
+ const out = [];
697
+ if (cliRoot) {
698
+ for (const rel of cliRelative[name] ?? []) out.push(resolve3(cliRoot, rel));
699
+ }
700
+ for (const rel of monorepoRelative[name] ?? []) out.push(resolve3(monorepo, rel));
701
+ return out;
702
+ }
703
+ function resolveRuntimeAssets(opts = {}) {
704
+ const out = [];
705
+ const missing = [];
706
+ for (const asset of RUNTIME_ASSETS) {
707
+ const cands = candidatesFor(asset.name, opts);
708
+ const hit = cands.find((p) => existsSync2(p));
709
+ if (!hit) {
710
+ missing.push({ name: asset.name, tried: cands });
711
+ continue;
712
+ }
713
+ out.push({ ...asset, localPath: hit });
714
+ }
715
+ if (missing.length > 0) {
716
+ const lines = missing.flatMap((m) => [` - ${m.name}: tried`, ...m.tried.map((p) => ` ${p}`)]);
717
+ throw new Error(
718
+ `hetzner: could not resolve runtime assets \u2014 these files are needed to install on the prepare VPS:
719
+ ` + lines.join("\n") + `
720
+
721
+ If you are running from the monorepo, ensure \`pnpm -w build\` has run so packages/ctl/dist/bin.cjs exists. If you are running from a published CLI bundle, the runtime/hetzner tree should be staged automatically.`
722
+ );
723
+ }
724
+ return out;
725
+ }
726
+ function guessRepoRoot() {
727
+ let cur = SELF;
728
+ for (let i = 0; i < 8; i++) {
729
+ if (existsSync2(resolve3(cur, "pnpm-workspace.yaml"))) return cur;
730
+ const parent = dirname(cur);
731
+ if (parent === cur) break;
732
+ cur = parent;
733
+ }
734
+ return SELF;
735
+ }
736
+ var SCHEMA = 2;
737
+ function preparedStatePath() {
738
+ return preparedStatePathFor("hetzner");
739
+ }
740
+ function readPreparedState() {
741
+ const raw = readPreparedStateRaw("hetzner");
742
+ if (raw === null || typeof raw !== "object") return { schema: SCHEMA };
743
+ const parsed = raw;
744
+ if (parsed.schema === 1) {
745
+ const v1 = parsed;
746
+ return migrateFromV1(v1);
747
+ }
748
+ if (parsed.schema !== SCHEMA) {
749
+ return { schema: SCHEMA };
750
+ }
751
+ return {
752
+ schema: SCHEMA,
753
+ base: parsed.base
754
+ };
755
+ }
756
+ function migrateFromV1(v1) {
757
+ const base = v1.base ? {
758
+ imageId: v1.base.imageId,
759
+ description: v1.base.description,
760
+ createdAt: v1.base.createdAt,
761
+ contextSha256: v1.base.installScriptSha256
762
+ } : void 0;
763
+ return {
764
+ schema: SCHEMA,
765
+ base
766
+ };
767
+ }
768
+ function writePreparedState(state) {
769
+ writePreparedStateRaw("hetzner", state);
770
+ }
771
+ function updatePreparedState(mutate) {
772
+ const s = readPreparedState();
773
+ mutate(s);
774
+ writePreparedState(s);
775
+ }
776
+ async function currentHetznerBaseFingerprintLive(claudeInstall = "native") {
777
+ try {
778
+ const assets = resolveRuntimeAssets({ cliRuntimeRoot: findStagedCliRuntimeRoot() });
779
+ return claudeInstallFingerprint(
780
+ await computeContextSha256(assets.map((a) => ({ rel: a.name, abs: a.localPath }))),
781
+ claudeInstall
782
+ );
783
+ } catch {
784
+ return void 0;
785
+ }
786
+ }
787
+
788
+ // ../../packages/sandbox-hetzner/dist/index.js
789
+ import { existsSync as existsSync22 } from "fs";
790
+ import { rm as rm2, rename, mkdir as mkdir3 } from "fs/promises";
791
+ import { join as join4 } from "path";
792
+ import { resolve as resolvePath } from "path";
793
+ import { join as join2 } from "path";
794
+ import { mkdir, readFile } from "fs/promises";
795
+ import { dirname as dirname2, join, resolve as resolve4 } from "path";
796
+ import { existsSync as existsSync3 } from "fs";
797
+ import { mkdir as mkdir2, rm } from "fs/promises";
798
+ import { createServer } from "net";
799
+ import { homedir as homedir3 } from "os";
800
+ import { dirname as dirname22, join as join3, resolve as resolve22 } from "path";
801
+ import { mkdir as mkdir4, rm as rm3, writeFile } from "fs/promises";
802
+ import { homedir as homedir22, tmpdir } from "os";
803
+ import { join as join5 } from "path";
804
+ function generatePrepareCloudInit(opts) {
805
+ const pubkey = opts.sshPubkey.trim();
806
+ return [
807
+ "#cloud-config",
808
+ "# AgentBox temporary prepare VPS \u2014 used by `agentbox prepare --provider hetzner`",
809
+ "# to bake the base snapshot. SSH key is single-use and discarded on VPS destroy.",
810
+ "disable_root: false",
811
+ "ssh_pwauth: false",
812
+ // Hetzner's Ubuntu 24.04 stock image enforces a first-login password
813
+ // change for root. With key-based auth that path can't run (no TTY),
814
+ // so sshd refuses with "Password change required but no TTY available."
815
+ // Telling cloud-init to NOT expire passwords + clearing root's expiry
816
+ // via `passwd -d` removes the gate. Belt-and-braces: the chpasswd block
817
+ // covers cloud-init's own users-and-groups run; the runcmd covers the
818
+ // case where the image's pre-baked expiry survives cloud-init.
819
+ "chpasswd:",
820
+ " expire: false",
821
+ "users:",
822
+ " - name: root",
823
+ " lock_passwd: false",
824
+ " ssh_authorized_keys:",
825
+ ` - ${yamlScalar(pubkey)}`,
826
+ "runcmd:",
827
+ " - [ passwd, -d, root ]",
828
+ ' - [ chage, -E, "-1", -I, "-1", -M, "99999", root ]',
829
+ ' - [ bash, -lc, "echo agentbox-prepare-ready" ]',
830
+ ""
831
+ ].join("\n");
832
+ }
833
+ function controlPlaneCloudInit(opts) {
834
+ const pubkey = opts.sshPubkey.trim();
835
+ return [
836
+ "#cloud-config",
837
+ "# AgentBox control-plane VPS \u2014 provisioned by `agentbox control-plane setup --deploy hetzner`.",
838
+ "disable_root: false",
839
+ "ssh_pwauth: false",
840
+ "chpasswd:",
841
+ " expire: false",
842
+ "users:",
843
+ " - name: root",
844
+ " lock_passwd: false",
845
+ " ssh_authorized_keys:",
846
+ ` - ${yamlScalar(pubkey)}`,
847
+ "runcmd:",
848
+ " - [ passwd, -d, root ]",
849
+ ' - [ chage, -E, "-1", -I, "-1", -M, "99999", root ]',
850
+ ' - [ bash, -lc, "curl -fsSL https://get.docker.com | sh" ]',
851
+ ' - [ bash, -lc, "apt-get update && apt-get install -y git" ]',
852
+ ` - [ bash, -lc, "git clone --depth 1 --branch ${shArg(opts.repoRef)} ${shArg(opts.repoUrl)} /opt/agentbox || git clone ${shArg(opts.repoUrl)} /opt/agentbox" ]`,
853
+ ""
854
+ ].join("\n");
855
+ }
856
+ function shArg(value) {
857
+ return `'${value.replace(/'/g, "'\\''")}'`;
858
+ }
859
+ function generateBoxCloudInit(opts) {
860
+ const pubkey = opts.sshPubkey.trim();
861
+ const lines = [
862
+ "#cloud-config",
863
+ `# AgentBox per-box VPS \u2014 box '${opts.boxName}'`,
864
+ "disable_root: true",
865
+ "ssh_pwauth: false",
866
+ // Same first-login expiry guard as the prepare cloud-init — keeps
867
+ // Hetzner's Ubuntu hardening from blocking our key-based vscode login.
868
+ "chpasswd:",
869
+ " expire: false",
870
+ "users:",
871
+ " - name: vscode",
872
+ " lock_passwd: false",
873
+ " sudo: ALL=(ALL) NOPASSWD:ALL",
874
+ " ssh_authorized_keys:",
875
+ ` - ${yamlScalar(pubkey)}`
876
+ ];
877
+ const writeFiles = [
878
+ " path: /etc/hosts",
879
+ " append: true",
880
+ ` content: "127.0.0.1 ${opts.boxName}.localhost\\n"`
881
+ ];
882
+ lines.push("write_files:");
883
+ lines.push(" - " + writeFiles[0]);
884
+ for (let i = 1; i < writeFiles.length; i++) {
885
+ lines.push(" " + writeFiles[i]);
886
+ }
887
+ if (opts.boxEnv && Object.keys(opts.boxEnv).length > 0) {
888
+ const envContent = Object.entries(opts.boxEnv).map(([k, v2]) => `${k}=${v2}`).join("\\n") + "\\n";
889
+ lines.push(" - path: /etc/agentbox/box.env");
890
+ lines.push(' permissions: "0644"');
891
+ lines.push(` content: "${envContent}"`);
892
+ }
893
+ lines.push("");
894
+ return lines.join("\n");
895
+ }
896
+ function yamlScalar(value) {
897
+ if (/["\\]/.test(value)) {
898
+ return JSON.stringify(value);
899
+ }
900
+ return `"${value}"`;
901
+ }
902
+ async function pollUntil(label, check, opts = {}) {
903
+ const deadline = Date.now() + (opts.deadlineMs ?? 5 * 6e4);
904
+ const max = opts.maxIntervalMs ?? 1e4;
905
+ let interval = opts.intervalMs ?? 1e3;
906
+ let attempt = 0;
907
+ while (true) {
908
+ attempt += 1;
909
+ const out = await check();
910
+ if (out !== null && out !== void 0) return out;
911
+ if (Date.now() >= deadline) {
912
+ throw new Error(`hetzner: timed out waiting for ${label} after ${String(attempt)} attempts`);
913
+ }
914
+ opts.onPoll?.(`${label}: not ready yet (attempt ${String(attempt)}); polling again in ${String(interval)}ms`);
915
+ await new Promise((r) => setTimeout(r, interval));
916
+ interval = Math.min(interval * 2, max);
917
+ }
918
+ }
919
+ async function mintSshKey(targetDir, comment) {
920
+ const dir = resolve4(targetDir);
921
+ const priv = join(dir, "id_ed25519");
922
+ const pub = `${priv}.pub`;
923
+ await mkdir(dir, { recursive: true, mode: 448 });
924
+ await execa(
925
+ "ssh-keygen",
926
+ ["-t", "ed25519", "-N", "", "-C", comment, "-f", priv, "-q"],
927
+ { stdio: "pipe" }
928
+ );
929
+ const publicKey = (await readFile(pub, "utf8")).trim();
930
+ return { dir, privatePath: priv, publicPath: pub, publicKey };
931
+ }
932
+ async function mintPrepareKey() {
933
+ const root = resolve4(homedirOrCwd(), ".agentbox", "hetzner", `prepare-${Date.now().toString(36)}`);
934
+ const key = await mintSshKey(root, `agentbox-prepare-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`);
935
+ return {
936
+ ...key,
937
+ cleanup: async () => {
938
+ try {
939
+ const { rm: rm4 } = await import("fs/promises");
940
+ await rm4(dirname2(key.privatePath), { recursive: true, force: true });
941
+ } catch {
942
+ }
943
+ }
944
+ };
945
+ }
946
+ function homedirOrCwd() {
947
+ try {
948
+ return process.env.HOME ?? process.cwd();
949
+ } catch {
950
+ return process.cwd();
951
+ }
952
+ }
953
+ function sshOptArgs(target) {
954
+ const out = [
955
+ "-i",
956
+ target.identity,
957
+ "-o",
958
+ "StrictHostKeyChecking=accept-new",
959
+ "-o",
960
+ `UserKnownHostsFile=${target.knownHosts}`,
961
+ "-o",
962
+ "GlobalKnownHostsFile=/dev/null",
963
+ "-o",
964
+ "BatchMode=yes",
965
+ "-o",
966
+ "LogLevel=ERROR"
967
+ ];
968
+ if (target.controlPath) {
969
+ out.push("-o", `ControlPath=${target.controlPath}`);
970
+ }
971
+ for (const [k, v2] of Object.entries(target.options ?? {})) {
972
+ out.push("-o", `${k}=${v2}`);
973
+ }
974
+ return out;
975
+ }
976
+ async function sshExec(target, remoteCmd, opts = {}) {
977
+ const argv = [
978
+ ...sshOptArgs(target),
979
+ `${target.user}@${target.host}`,
980
+ remoteCmd
981
+ ];
982
+ const child = execa("ssh", argv, {
983
+ reject: false,
984
+ timeout: opts.timeoutMs,
985
+ env: { ...process.env, ...opts.env },
986
+ stdio: opts.onLine ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "pipe"]
987
+ });
988
+ if (opts.onLine) {
989
+ const handle = (chunk) => {
990
+ const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
991
+ for (const line of text.split(/\r?\n/)) {
992
+ if (line.length > 0) opts.onLine?.(line);
993
+ }
994
+ };
995
+ child.stdout?.on("data", handle);
996
+ child.stderr?.on("data", handle);
997
+ }
998
+ const res = await child;
999
+ return {
1000
+ exitCode: typeof res.exitCode === "number" ? res.exitCode : 1,
1001
+ stdout: typeof res.stdout === "string" ? res.stdout : "",
1002
+ stderr: typeof res.stderr === "string" ? res.stderr : ""
1003
+ };
1004
+ }
1005
+ async function scpUpload(target, localPath, remotePath, opts = {}) {
1006
+ const argv = [
1007
+ ...sshOptArgs(target),
1008
+ localPath,
1009
+ `${target.user}@${target.host}:${remotePath}`
1010
+ ];
1011
+ const res = await execa("scp", argv, {
1012
+ reject: false,
1013
+ timeout: opts.timeoutMs
1014
+ });
1015
+ if (res.exitCode !== 0) {
1016
+ throw new Error(
1017
+ `scp upload failed (exit ${String(res.exitCode)}): ${localPath} \u2192 ${remotePath}
1018
+ ${res.stderr ?? ""}`
1019
+ );
1020
+ }
1021
+ }
1022
+ async function scpDownload(target, remotePath, localPath, opts = {}) {
1023
+ const argv = [
1024
+ ...sshOptArgs(target),
1025
+ `${target.user}@${target.host}:${remotePath}`,
1026
+ localPath
1027
+ ];
1028
+ const res = await execa("scp", argv, {
1029
+ reject: false,
1030
+ timeout: opts.timeoutMs
1031
+ });
1032
+ if (res.exitCode !== 0) {
1033
+ throw new Error(
1034
+ `scp download failed (exit ${String(res.exitCode)}): ${remotePath} \u2192 ${localPath}
1035
+ ${res.stderr ?? ""}`
1036
+ );
1037
+ }
1038
+ }
1039
+ async function waitForSsh(target, deadlineMs, intervalMs = 5e3) {
1040
+ const stop = Date.now() + deadlineMs;
1041
+ while (Date.now() < stop) {
1042
+ const res = await sshExec(
1043
+ { ...target, options: { ...target.options, ConnectTimeout: "5" } },
1044
+ "true",
1045
+ { timeoutMs: 1e4 }
1046
+ );
1047
+ if (res.exitCode === 0) return true;
1048
+ await new Promise((r) => setTimeout(r, intervalMs));
1049
+ }
1050
+ return false;
1051
+ }
1052
+ var TEMP_SERVER_TYPE_DEFAULT = "cx23";
1053
+ var TEMP_SERVER_LOCATION_DEFAULT = "nbg1";
1054
+ var PREPARE_SSH_DEADLINE_MS = 5 * 6e4;
1055
+ var INSTALL_SCRIPT_TIMEOUT_MS = 30 * 6e4;
1056
+ var SNAPSHOT_DEADLINE_MS = 20 * 6e4;
1057
+ async function prepareHetzner(opts = {}) {
1058
+ await ensureHetznerCredentials();
1059
+ const client2 = makeHetznerClient();
1060
+ const log = opts.onLog ?? (() => {
1061
+ });
1062
+ const progress = (step) => log(`prepare-hetzner: ${step}`);
1063
+ const existingState = readPreparedState();
1064
+ const assets = resolveRuntimeAssets({
1065
+ cliRuntimeRoot: opts.cliRuntimeRoot ?? findStagedCliRuntimeRoot(),
1066
+ repoRoot: opts.repoRoot
1067
+ });
1068
+ const claudeInstall = opts.claudeInstall ?? "native";
1069
+ const contextSha = claudeInstallFingerprint(
1070
+ await computeContextSha256(assets.map((a) => ({ rel: a.name, abs: a.localPath }))),
1071
+ claudeInstall
1072
+ );
1073
+ if (!opts.force && existingState.base) {
1074
+ const remote = await client2.getImage(existingState.base.imageId).catch(() => null);
1075
+ if (remote && existingState.base.contextSha256 === contextSha) {
1076
+ progress(
1077
+ `base snapshot ${String(existingState.base.imageId)} already exists (fingerprint ${contextSha.slice(0, 12)} matches); skipping rebuild (pass --force to override)`
1078
+ );
1079
+ return {
1080
+ snapshotName: existingState.base.description,
1081
+ imageId: existingState.base.imageId
1082
+ };
1083
+ }
1084
+ if (!remote) {
1085
+ progress(
1086
+ `recorded base snapshot ${String(existingState.base.imageId)} is gone on Hetzner; rebuilding`
1087
+ );
1088
+ } else {
1089
+ progress(
1090
+ `build context changed (was ${existingState.base.contextSha256?.slice(0, 12) ?? "<none>"}, now ${contextSha.slice(0, 12)}); rebuilding base snapshot`
1091
+ );
1092
+ }
1093
+ }
1094
+ progress("minting ephemeral ssh key");
1095
+ const key = await mintPrepareKey();
1096
+ let firewallId = null;
1097
+ let serverId = null;
1098
+ try {
1099
+ progress("detecting host egress IP");
1100
+ const source = opts.firewallSource ? normalizeSourceCidr(opts.firewallSource) : `${await detectEgressIp({ onLog: log })}/32`;
1101
+ const stamp = Date.now().toString(36);
1102
+ const firewallName = `agentbox-prepare-${stamp}`;
1103
+ progress(`creating firewall ${firewallName} (source ${source})`);
1104
+ const firewall = await createPerBoxFirewall(client2, {
1105
+ name: firewallName,
1106
+ sourceCidr: source,
1107
+ labels: { "agentbox.role": "prepare" }
1108
+ });
1109
+ firewallId = firewall.id;
1110
+ const serverName = `agentbox-prepare-${stamp}`;
1111
+ const cloudInit = generatePrepareCloudInit({ sshPubkey: key.publicKey });
1112
+ progress(
1113
+ `creating temp VPS ${serverName} (${opts.serverType ?? TEMP_SERVER_TYPE_DEFAULT} / ${opts.location ?? TEMP_SERVER_LOCATION_DEFAULT})`
1114
+ );
1115
+ const created = await client2.createServer({
1116
+ name: serverName,
1117
+ server_type: opts.serverType ?? TEMP_SERVER_TYPE_DEFAULT,
1118
+ image: "ubuntu-24.04",
1119
+ location: opts.location ?? TEMP_SERVER_LOCATION_DEFAULT,
1120
+ user_data: cloudInit,
1121
+ firewalls: [{ firewall: firewall.id }],
1122
+ labels: { "agentbox.managed": "true", "agentbox.role": "prepare" },
1123
+ start_after_create: true
1124
+ });
1125
+ serverId = created.server.id;
1126
+ const ip = created.server.public_net.ipv4?.ip;
1127
+ if (!ip) {
1128
+ throw new Error("hetzner: temp VPS came up without an IPv4 address");
1129
+ }
1130
+ progress(`waiting for ssh on ${ip} (deadline ${String(PREPARE_SSH_DEADLINE_MS / 1e3)}s)`);
1131
+ const sshTarget = {
1132
+ host: ip,
1133
+ user: "root",
1134
+ identity: key.privatePath,
1135
+ knownHosts: join2(key.dir, "known_hosts")
1136
+ };
1137
+ const up = await waitForSsh(sshTarget, PREPARE_SSH_DEADLINE_MS);
1138
+ if (!up) {
1139
+ throw new Error(
1140
+ `hetzner: ssh on ${ip} did not come up within ${String(PREPARE_SSH_DEADLINE_MS / 1e3)}s`
1141
+ );
1142
+ }
1143
+ progress("ssh up \u2014 scp'ing runtime assets");
1144
+ for (const asset of assets) {
1145
+ const remote = `/tmp/${asset.remoteBasename}`;
1146
+ log(`prepare-hetzner: scp ${asset.name} -> ${remote}`);
1147
+ await scpUpload(sshTarget, asset.localPath, remote);
1148
+ if (asset.remoteMode !== void 0) {
1149
+ const modeOctal = asset.remoteMode.toString(8);
1150
+ await sshExec(sshTarget, `chmod ${modeOctal} ${remote}`);
1151
+ }
1152
+ }
1153
+ progress("running install-box.sh on temp VPS (this takes ~5-15 min)");
1154
+ const installRes = await sshExec(
1155
+ sshTarget,
1156
+ `sudo mkdir -p /var/log/agentbox && set -o pipefail && AGENTBOX_CLAUDE_INSTALL=${claudeInstall} bash -x /tmp/agentbox-install.sh 2>&1 | sudo tee /var/log/agentbox/install.log`,
1157
+ {
1158
+ timeoutMs: INSTALL_SCRIPT_TIMEOUT_MS,
1159
+ onLine: (line) => log(`[install] ${line}`)
1160
+ }
1161
+ );
1162
+ if (installRes.exitCode !== 0) {
1163
+ if (installRes.exitCode === 71) {
1164
+ throw new Error(
1165
+ `Claude Code's native installer could not be reached from the Hetzner VPS after 3 retries (~5 min).
1166
+ This is a transient Cloudflare 403. It usually clears within a few minutes.
1167
+
1168
+ What to do: wait a moment, then re-run \`agentbox prepare --provider hetzner --force\`.
1169
+ Full trace: /var/log/agentbox/install.log inside any box made from the resulting snapshot.`
1170
+ );
1171
+ }
1172
+ throw new Error(
1173
+ `install-box.sh failed on temp VPS (exit ${String(installRes.exitCode)})
1174
+ Last stderr: ${installRes.stderr.slice(-500) || "(empty)"}
1175
+ The full trace was preserved at /var/log/agentbox/install.log inside any box made from the resulting snapshot.`
1176
+ );
1177
+ }
1178
+ progress("install script complete");
1179
+ progress("staging host agent static config");
1180
+ const stagings = [];
1181
+ try {
1182
+ const claudeTar = await stageClaudeStaticForUpload({ hostWorkspace: opts.hostWorkspace });
1183
+ for (const w of claudeTar.warnings) log(`prepare-hetzner: ${w}`);
1184
+ if (claudeTar.tarballPath)
1185
+ stagings.push({ kind: "claude", tar: claudeTar, dest: "/home/vscode/.claude" });
1186
+ else await claudeTar.cleanup();
1187
+ const codexTar = await stageCodexStaticForUpload();
1188
+ for (const w of codexTar.warnings) log(`prepare-hetzner: ${w}`);
1189
+ if (codexTar.tarballPath)
1190
+ stagings.push({ kind: "codex", tar: codexTar, dest: "/home/vscode/.codex" });
1191
+ else await codexTar.cleanup();
1192
+ const opencodeTar = await stageOpencodeStaticForUpload();
1193
+ for (const w of opencodeTar.warnings) log(`prepare-hetzner: ${w}`);
1194
+ if (opencodeTar.tarballPath)
1195
+ stagings.push({
1196
+ kind: "opencode",
1197
+ tar: opencodeTar,
1198
+ dest: "/home/vscode/.local/share/opencode"
1199
+ });
1200
+ else await opencodeTar.cleanup();
1201
+ const agentsTar = await stageAgentsStaticForUpload();
1202
+ for (const w of agentsTar.warnings) log(`prepare-hetzner: ${w}`);
1203
+ if (agentsTar.tarballPath)
1204
+ stagings.push({ kind: "agents", tar: agentsTar, dest: "/home/vscode/.agents" });
1205
+ else await agentsTar.cleanup();
1206
+ for (const s of stagings) {
1207
+ const remote = `/tmp/agentbox-${s.kind}-static.tar.gz`;
1208
+ log(`prepare-hetzner: scp ${s.kind} static (${s.tar.tarballPath}) -> ${remote}`);
1209
+ await scpUpload(sshTarget, s.tar.tarballPath, remote);
1210
+ const extractCmd = `sudo -u vscode mkdir -p ${s.dest} && sudo -u vscode tar -xzf ${remote} -C ${s.dest} --no-same-permissions --no-same-owner -m && rm -f ${remote}`;
1211
+ const r = await sshExec(sshTarget, extractCmd, {
1212
+ onLine: (line) => log(`[stage:${s.kind}] ${line}`)
1213
+ });
1214
+ if (r.exitCode !== 0) {
1215
+ throw new Error(
1216
+ `prepare-hetzner: ${s.kind} static extract failed (exit ${String(r.exitCode)}): ${r.stderr.slice(-300)}`
1217
+ );
1218
+ }
1219
+ progress(`baked ${s.kind} static config into snapshot`);
1220
+ }
1221
+ } finally {
1222
+ for (const s of stagings) await s.tar.cleanup();
1223
+ }
1224
+ const description = opts.name ?? `agentbox-base-${stamp}`;
1225
+ progress(`creating snapshot '${description}' from VPS ${String(serverId)}`);
1226
+ const snap = await client2.createImage(serverId, {
1227
+ type: "snapshot",
1228
+ description,
1229
+ labels: { "agentbox.role": "base", "agentbox.schema": "1" }
1230
+ });
1231
+ progress(
1232
+ `snapshot create requested (image id ${String(snap.image.id)}); polling until available`
1233
+ );
1234
+ const ready = await pollUntil(
1235
+ `image ${String(snap.image.id)} availability`,
1236
+ async () => {
1237
+ const img = await client2.getImage(snap.image.id);
1238
+ if (!img) return null;
1239
+ if (img.status === "available") return img;
1240
+ return null;
1241
+ },
1242
+ {
1243
+ deadlineMs: SNAPSHOT_DEADLINE_MS,
1244
+ intervalMs: 3e3,
1245
+ maxIntervalMs: 1e4,
1246
+ onPoll: (l) => log(`prepare-hetzner: ${l}`)
1247
+ }
1248
+ );
1249
+ progress("persisting hetzner-prepared.json");
1250
+ const state = readPreparedState();
1251
+ const cliStamp = readCliStamp();
1252
+ state.base = {
1253
+ imageId: ready.id,
1254
+ description: ready.description,
1255
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1256
+ contextSha256: contextSha,
1257
+ cliVersion: cliStamp.cliVersion,
1258
+ cliCommit: cliStamp.cliCommit
1259
+ };
1260
+ writePreparedState(state);
1261
+ log(`prepare-hetzner: wrote ${preparedStatePath()}`);
1262
+ progress(`deleting temp VPS ${String(serverId)}`);
1263
+ await client2.deleteServer(serverId);
1264
+ serverId = null;
1265
+ progress(`deleting per-prepare firewall ${String(firewallId)}`);
1266
+ await deletePerBoxFirewall(client2, firewallId);
1267
+ firewallId = null;
1268
+ progress(`prepare complete \u2014 base snapshot ${String(ready.id)} (${ready.description})`);
1269
+ return { snapshotName: ready.description, imageId: ready.id };
1270
+ } catch (err) {
1271
+ if (serverId !== null) {
1272
+ log(`prepare-hetzner: cleanup \u2014 deleting temp VPS ${String(serverId)} after failure`);
1273
+ try {
1274
+ await client2.deleteServer(serverId);
1275
+ } catch (cleanupErr) {
1276
+ log(
1277
+ `prepare-hetzner: WARN \u2014 failed to delete temp VPS ${String(serverId)}; check the Hetzner dashboard manually. ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`
1278
+ );
1279
+ }
1280
+ }
1281
+ if (firewallId !== null) {
1282
+ log(
1283
+ `prepare-hetzner: cleanup \u2014 deleting per-prepare firewall ${String(firewallId)} after failure`
1284
+ );
1285
+ try {
1286
+ await deletePerBoxFirewall(client2, firewallId);
1287
+ } catch (cleanupErr) {
1288
+ log(
1289
+ `prepare-hetzner: WARN \u2014 failed to delete firewall ${String(firewallId)}; check the Hetzner dashboard manually. ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`
1290
+ );
1291
+ }
1292
+ }
1293
+ throw err;
1294
+ } finally {
1295
+ await key.cleanup();
1296
+ }
1297
+ }
1298
+ var prepareHetznerProvider = (req) => prepareHetzner({
1299
+ name: req.name,
1300
+ hostWorkspace: req.hostWorkspace ?? process.cwd(),
1301
+ force: req.force,
1302
+ onLog: req.onLog,
1303
+ // Forward the Claude install mode (native | npm). Without this the Hetzner
1304
+ // bake always ran the native `curl install.sh`, whose CDN 403s datacenter
1305
+ // egress IPs — the `npm` escape hatch (box.claudeInstall / --claude-install
1306
+ // npm) never reached the bake. (matches prepareVercelProvider.)
1307
+ claudeInstall: req.claudeInstall
1308
+ });
1309
+ async function ensureHetznerBaseSnapshot() {
1310
+ const state = readPreparedState();
1311
+ if (state.base !== void 0) return;
1312
+ throw new UserFacingError(
1313
+ "no Hetzner base snapshot found.\nRun `agentbox prepare --provider hetzner` first (Hetzner cannot build images from a Dockerfile,\nso the base snapshot is a one-time prerequisite for cloud boxes on this backend)."
1314
+ );
1315
+ }
1316
+ var HOST = "127.0.0.1";
1317
+ var EPHEMERAL_MIN = 49152;
1318
+ var EPHEMERAL_MAX = 65535;
1319
+ var SshTunnelManager = class {
1320
+ boxes = /* @__PURE__ */ new Map();
1321
+ /**
1322
+ * Open the ControlMaster for `boxId`. Idempotent: if a master is already
1323
+ * up for this box (socket exists + responsive), no-op. Otherwise spawn a
1324
+ * fresh `ssh -fNT -M` and wait for the socket to appear.
1325
+ */
1326
+ async open(opts) {
1327
+ const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
1328
+ await mkdir2(boxSshDir, { recursive: true, mode: 448 });
1329
+ const controlPath = join3(boxSshDir, "control.sock");
1330
+ const knownHosts = join3(boxSshDir, "known_hosts");
1331
+ const user = opts.vpsUser ?? "vscode";
1332
+ const tunnel = {
1333
+ controlPath,
1334
+ vpsHost: opts.vpsHost,
1335
+ vpsUser: user,
1336
+ identity: opts.identity,
1337
+ boxSshDir,
1338
+ forwards: /* @__PURE__ */ new Map()
1339
+ };
1340
+ if (existsSync3(controlPath) && await this.isAlive(controlPath)) {
1341
+ this.boxes.set(opts.boxId, tunnel);
1342
+ return;
1343
+ }
1344
+ if (existsSync3(controlPath)) {
1345
+ await rm(controlPath, { force: true });
1346
+ }
1347
+ const connectTimeout = opts.connectTimeoutSeconds ?? 10;
1348
+ const argv = [
1349
+ "-fNT",
1350
+ "-M",
1351
+ "-S",
1352
+ controlPath,
1353
+ "-i",
1354
+ opts.identity,
1355
+ "-o",
1356
+ "StrictHostKeyChecking=accept-new",
1357
+ "-o",
1358
+ `UserKnownHostsFile=${knownHosts}`,
1359
+ "-o",
1360
+ "GlobalKnownHostsFile=/dev/null",
1361
+ "-o",
1362
+ "BatchMode=yes",
1363
+ "-o",
1364
+ "LogLevel=ERROR",
1365
+ "-o",
1366
+ "ExitOnForwardFailure=yes",
1367
+ "-o",
1368
+ "ServerAliveInterval=30",
1369
+ "-o",
1370
+ "ServerAliveCountMax=3",
1371
+ "-o",
1372
+ `ConnectTimeout=${String(connectTimeout)}`,
1373
+ `${user}@${opts.vpsHost}`
1374
+ ];
1375
+ const res = await execa("ssh", argv, { reject: false });
1376
+ if (res.exitCode !== 0 || !existsSync3(controlPath)) {
1377
+ throw new Error(
1378
+ `ssh ControlMaster failed for ${opts.boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1379
+ );
1380
+ }
1381
+ this.boxes.set(opts.boxId, tunnel);
1382
+ }
1383
+ /**
1384
+ * Mint (or fetch the cached) `127.0.0.1:<localPort> → vps:127.0.0.1:<remotePort>`
1385
+ * forward. Returns the local port. Idempotent per (boxId, remotePort).
1386
+ *
1387
+ * The cached entry is only returned when the underlying ControlMaster is
1388
+ * still alive — without that check we'd happily hand back a localPort that
1389
+ * stopped listening when the master died (e.g. transient network blip,
1390
+ * host sleep/wake). When the master is dead we drop ALL cached forwards
1391
+ * for this box (they all share one tunnel) and re-mint from scratch.
1392
+ */
1393
+ async forward(boxId, remotePort) {
1394
+ const tunnel = this.getTunnelOrThrow(boxId);
1395
+ const cached = tunnel.forwards.get(remotePort);
1396
+ if (cached !== void 0 && await this.isAlive(tunnel.controlPath)) {
1397
+ return cached;
1398
+ }
1399
+ if (cached !== void 0) {
1400
+ tunnel.forwards.clear();
1401
+ }
1402
+ const localPort = await pickFreePort();
1403
+ const argv = [
1404
+ "-O",
1405
+ "forward",
1406
+ "-L",
1407
+ `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1408
+ "-S",
1409
+ tunnel.controlPath,
1410
+ "dummy"
1411
+ // the target host is ignored when -O is used, but argv needs one
1412
+ ];
1413
+ const res = await execa("ssh", argv, { reject: false });
1414
+ if (res.exitCode !== 0) {
1415
+ throw new Error(
1416
+ `ssh -O forward failed for ${boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1417
+ );
1418
+ }
1419
+ tunnel.forwards.set(remotePort, localPort);
1420
+ return localPort;
1421
+ }
1422
+ /**
1423
+ * Tear down a dead ControlMaster + every cached forward for this box,
1424
+ * then re-open from scratch. Idempotent — if the master is already alive
1425
+ * the master open() is a no-op, but the cached forwards still get
1426
+ * cleared so the next forward() call re-mints them. Returns when the
1427
+ * master is open and the box's forwards map is empty (ready for fresh
1428
+ * forward() calls).
1429
+ *
1430
+ * Use case: the cloud-poller observes ECONNREFUSED on the local port and
1431
+ * asks the backend to refresh the preview URL — that path calls into
1432
+ * here so the master + forward both come back fresh.
1433
+ */
1434
+ async refresh(opts) {
1435
+ const existing = this.boxes.get(opts.boxId);
1436
+ if (existing) {
1437
+ const alive = await this.isAlive(existing.controlPath);
1438
+ if (!alive && existsSync3(existing.controlPath)) {
1439
+ try {
1440
+ await execa(
1441
+ "ssh",
1442
+ ["-O", "exit", "-S", existing.controlPath, "dummy"],
1443
+ { reject: false }
1444
+ );
1445
+ } catch {
1446
+ }
1447
+ await rm(existing.controlPath, { force: true });
1448
+ }
1449
+ existing.forwards.clear();
1450
+ }
1451
+ await this.open(opts);
1452
+ }
1453
+ /** Tear down a single forward. Idempotent — unknown ports are no-ops. */
1454
+ async unforward(boxId, remotePort) {
1455
+ const tunnel = this.getTunnelOrThrow(boxId);
1456
+ const localPort = tunnel.forwards.get(remotePort);
1457
+ if (localPort === void 0) return;
1458
+ const argv = [
1459
+ "-O",
1460
+ "cancel",
1461
+ "-L",
1462
+ `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1463
+ "-S",
1464
+ tunnel.controlPath,
1465
+ "dummy"
1466
+ ];
1467
+ await execa("ssh", argv, { reject: false });
1468
+ tunnel.forwards.delete(remotePort);
1469
+ }
1470
+ /**
1471
+ * Close the ControlMaster (and all its forwards). Idempotent — if no
1472
+ * master is recorded, no-op. Removes the socket file.
1473
+ */
1474
+ async close(boxId) {
1475
+ const tunnel = this.boxes.get(boxId);
1476
+ if (!tunnel) return;
1477
+ if (existsSync3(tunnel.controlPath)) {
1478
+ await execa("ssh", ["-O", "exit", "-S", tunnel.controlPath, "dummy"], { reject: false });
1479
+ await rm(tunnel.controlPath, { force: true });
1480
+ }
1481
+ this.boxes.delete(boxId);
1482
+ }
1483
+ /** Tear down every open box. */
1484
+ async closeAll() {
1485
+ const ids = Array.from(this.boxes.keys());
1486
+ await Promise.all(ids.map((id) => this.close(id)));
1487
+ }
1488
+ /** Path to the ControlMaster socket for `boxId`, if open. */
1489
+ controlPath(boxId) {
1490
+ return this.boxes.get(boxId)?.controlPath;
1491
+ }
1492
+ /** True if a ControlMaster is registered for `boxId` (regardless of liveness). */
1493
+ has(boxId) {
1494
+ return this.boxes.has(boxId);
1495
+ }
1496
+ /** Per-box ssh dir (tests use this to verify the layout). */
1497
+ boxSshDir(boxId) {
1498
+ return this.boxes.get(boxId)?.boxSshDir;
1499
+ }
1500
+ /** Re-open the manager record for an existing-on-disk control socket. */
1501
+ registerExisting(boxId, opts) {
1502
+ const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
1503
+ this.boxes.set(boxId, {
1504
+ controlPath: join3(boxSshDir, "control.sock"),
1505
+ vpsHost: opts.vpsHost,
1506
+ vpsUser: opts.vpsUser ?? "vscode",
1507
+ identity: opts.identity,
1508
+ boxSshDir,
1509
+ forwards: /* @__PURE__ */ new Map()
1510
+ });
1511
+ }
1512
+ async isAlive(controlPath) {
1513
+ const res = await execa("ssh", ["-O", "check", "-S", controlPath, "dummy"], { reject: false });
1514
+ return res.exitCode === 0;
1515
+ }
1516
+ getTunnelOrThrow(boxId) {
1517
+ const t = this.boxes.get(boxId);
1518
+ if (!t) throw new Error(`no SSH ControlMaster registered for box ${boxId}; call open() first`);
1519
+ return t;
1520
+ }
1521
+ };
1522
+ function defaultBoxSshDir(boxId) {
1523
+ return resolve22(homedir3(), ".agentbox", "boxes", boxId, "ssh");
1524
+ }
1525
+ async function pickFreePort() {
1526
+ return new Promise((resolveOk, reject) => {
1527
+ const srv = createServer();
1528
+ srv.unref();
1529
+ srv.on("error", reject);
1530
+ srv.listen(0, HOST, () => {
1531
+ const addr = srv.address();
1532
+ if (!addr || typeof addr === "string") {
1533
+ srv.close();
1534
+ reject(new Error("could not get a free local port"));
1535
+ return;
1536
+ }
1537
+ const port = addr.port;
1538
+ srv.close(() => {
1539
+ if (port < EPHEMERAL_MIN || port > EPHEMERAL_MAX) {
1540
+ resolveOk(port);
1541
+ } else {
1542
+ resolveOk(port);
1543
+ }
1544
+ });
1545
+ });
1546
+ });
1547
+ }
1548
+ var HETZNER_DEFAULT_BOX_IMAGE_REF = "agentbox-base";
1549
+ var SCAFFOLDING_FALLBACK_IMAGE = "agentbox/box:dev";
1550
+ var VPS_USER = "vscode";
1551
+ var PROVISION_SSH_DEADLINE_MS = 5 * 6e4;
1552
+ var ACTION_DEADLINE_MS = 5 * 6e4;
1553
+ var SNAPSHOT_DEADLINE_MS2 = 20 * 6e4;
1554
+ var HETZNER_DEFAULT_SERVER_TYPE = "cx23";
1555
+ var HETZNER_DEFAULT_LOCATION = "nbg1";
1556
+ var CLOUD_INIT_BOX_ENV_EXCLUDE = /* @__PURE__ */ new Set([
1557
+ "AGENTBOX_RELAY_URL",
1558
+ "AGENTBOX_RELAY_TOKEN",
1559
+ "AGENTBOX_BRIDGE_TOKEN"
1560
+ ]);
1561
+ function cloudInitBoxEnv(env = {}) {
1562
+ const out = {};
1563
+ for (const [k, v2] of Object.entries(env)) {
1564
+ if (v2 !== void 0 && k.startsWith("AGENTBOX_") && !CLOUD_INIT_BOX_ENV_EXCLUDE.has(k)) {
1565
+ out[k] = v2;
1566
+ }
1567
+ }
1568
+ return out;
1569
+ }
1570
+ var tunnels = new SshTunnelManager();
1571
+ function mapState(s) {
1572
+ switch (s) {
1573
+ case "running":
1574
+ return "running";
1575
+ case "starting":
1576
+ case "initializing":
1577
+ case "stopping":
1578
+ case "migrating":
1579
+ case "rebuilding":
1580
+ return "running";
1581
+ case "off":
1582
+ return "paused";
1583
+ case "deleting":
1584
+ case "unknown":
1585
+ default:
1586
+ return "missing";
1587
+ }
1588
+ }
1589
+ function client() {
1590
+ return makeHetznerClient();
1591
+ }
1592
+ async function getServerStrict(id) {
1593
+ const s = await client().getServer(id);
1594
+ if (!s) {
1595
+ throw new Error(`hetzner: server ${String(id)} not found (already destroyed?)`);
1596
+ }
1597
+ return s;
1598
+ }
1599
+ async function findImageByDescription(c, description) {
1600
+ const all = await c.listImages({ type: "snapshot" });
1601
+ return all.find((i) => i.description === description) ?? null;
1602
+ }
1603
+ async function resolveImageId(c, req) {
1604
+ const ref = req.snapshot ?? req.image;
1605
+ if (!ref || ref === HETZNER_DEFAULT_BOX_IMAGE_REF || ref === SCAFFOLDING_FALLBACK_IMAGE) {
1606
+ await ensureHetznerBaseSnapshot();
1607
+ const state = readPreparedState();
1608
+ if (!state.base) {
1609
+ throw new Error(
1610
+ "no Hetzner base snapshot found \u2014 run `agentbox prepare --provider hetzner` to bake one."
1611
+ );
1612
+ }
1613
+ return state.base.imageId;
1614
+ }
1615
+ if (/^\d+$/.test(ref)) {
1616
+ return Number.parseInt(ref, 10);
1617
+ }
1618
+ const snap = await findImageByDescription(c, ref);
1619
+ if (snap) return snap.id;
1620
+ return ref;
1621
+ }
1622
+ function perBoxDir(sandboxId) {
1623
+ return resolvePath(defaultBoxSshDir(sandboxId), "..");
1624
+ }
1625
+ async function ensurePerBoxState(sandboxId) {
1626
+ const dir = perBoxDir(sandboxId);
1627
+ const sshDir = join4(dir, "ssh");
1628
+ await mkdir3(sshDir, { recursive: true, mode: 448 });
1629
+ return {
1630
+ dir,
1631
+ identity: join4(sshDir, "id_ed25519"),
1632
+ knownHosts: join4(sshDir, "known_hosts")
1633
+ };
1634
+ }
1635
+ function bashScript(s) {
1636
+ return `bash -lc ${shellQuote(s)}`;
1637
+ }
1638
+ function shellQuote(s) {
1639
+ return `'${s.replace(/'/g, `'\\''`)}'`;
1640
+ }
1641
+ function buildSshTarget(state, vpsIp, controlPath) {
1642
+ return {
1643
+ host: vpsIp,
1644
+ user: VPS_USER,
1645
+ identity: state.identity,
1646
+ knownHosts: state.knownHosts,
1647
+ controlPath
1648
+ };
1649
+ }
1650
+ async function firewallEgressStatus(sandboxId) {
1651
+ const id = Number.parseInt(sandboxId, 10);
1652
+ if (!Number.isFinite(id)) return null;
1653
+ const server = await client().getServer(id);
1654
+ if (!server) return null;
1655
+ const firewallId = Number.parseInt(server.labels["agentbox.firewall"] ?? "", 10);
1656
+ if (!Number.isFinite(firewallId)) return null;
1657
+ const firewall = await client().getFirewall(firewallId);
1658
+ const sshRule = firewall?.rules.find((r) => r.direction === "in" && r.port === "22");
1659
+ const allowedSource = sshRule?.source_ips?.[0];
1660
+ const currentEgress = `${await detectEgressIp({})}/32`;
1661
+ return {
1662
+ firewallId,
1663
+ allowedSource,
1664
+ currentEgress,
1665
+ boxRef: server.labels["agentbox.box"] ?? sandboxId
1666
+ };
1667
+ }
1668
+ async function ensureTunnel(sandboxId, state, vpsIp) {
1669
+ if (tunnels.has(sandboxId)) return;
1670
+ try {
1671
+ await tunnels.open({
1672
+ boxId: sandboxId,
1673
+ vpsHost: vpsIp,
1674
+ identity: state.identity
1675
+ });
1676
+ } catch (err) {
1677
+ const s = await firewallEgressStatus(sandboxId).catch(() => null);
1678
+ if (s && firewallNeedsSync(s.allowedSource, s.currentEgress)) {
1679
+ throw new Error(
1680
+ `${err.message}
1681
+
1682
+ hetzner: SSH is blocked by the box firewall \u2014 it allows ${s.allowedSource ?? "(no rule)"} but your egress IP is now ${s.currentEgress}. Your IP changed; run:
1683
+ agentbox hetzner firewall sync ${s.boxRef}
1684
+ (or \`agentbox recover ${s.boxRef}\`, which auto-syncs).`
1685
+ );
1686
+ }
1687
+ throw err;
1688
+ }
1689
+ }
1690
+ async function ensureLiveTarget(sandboxId) {
1691
+ const id = Number.parseInt(sandboxId, 10);
1692
+ if (!Number.isFinite(id)) {
1693
+ throw new Error(`hetzner: invalid sandboxId ${sandboxId}`);
1694
+ }
1695
+ const server = await getServerStrict(id);
1696
+ const vpsIp = server.public_net.ipv4?.ip;
1697
+ if (!vpsIp) {
1698
+ throw new Error(`hetzner: server ${String(id)} has no IPv4 address`);
1699
+ }
1700
+ const state = await ensurePerBoxState(sandboxId);
1701
+ if (!existsSync22(state.identity)) {
1702
+ throw new Error(
1703
+ `hetzner: per-box SSH key missing for sandbox ${sandboxId} (expected at ${state.identity}). If this box was created by a different host, you'll need to re-create it on this host.`
1704
+ );
1705
+ }
1706
+ await ensureTunnel(sandboxId, state, vpsIp);
1707
+ const controlPath = tunnels.controlPath(sandboxId);
1708
+ return { target: buildSshTarget(state, vpsIp, controlPath), state, vpsIp };
1709
+ }
1710
+ var hetznerBackend = {
1711
+ name: "hetzner",
1712
+ async provision(req) {
1713
+ const c = client();
1714
+ const onLog = req.onLog ?? (() => {
1715
+ });
1716
+ const progress = (s) => onLog(`hetzner: ${s}`);
1717
+ await ensureHetznerBaseSnapshot();
1718
+ const imageRef = await resolveImageId(c, req);
1719
+ const egressOverride = req.env?.AGENTBOX_HETZNER_FIREWALL_SOURCE ?? process.env.AGENTBOX_HETZNER_FIREWALL_SOURCE;
1720
+ const source = egressOverride ? normalizeSourceCidr(egressOverride) : `${await detectEgressIp({ onLog })}/32`;
1721
+ progress(`firewall source: ${source}`);
1722
+ const stamp = Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 8);
1723
+ const tempDir = resolvePath(
1724
+ process.env.HOME ?? process.cwd(),
1725
+ ".agentbox",
1726
+ "hetzner",
1727
+ `pending-${stamp}`,
1728
+ "ssh"
1729
+ );
1730
+ const key = await mintSshKey(tempDir, `agentbox-box-${req.name}-${stamp}`);
1731
+ let firewallId = null;
1732
+ let serverId = null;
1733
+ try {
1734
+ const firewall = await createPerBoxFirewall(c, {
1735
+ name: `agentbox-${req.name}-${stamp}`,
1736
+ sourceCidr: source,
1737
+ labels: {
1738
+ "agentbox.box": req.name,
1739
+ "agentbox.role": "box"
1740
+ }
1741
+ });
1742
+ firewallId = firewall.id;
1743
+ const boxEnv = cloudInitBoxEnv(req.env);
1744
+ const cloudInit = generateBoxCloudInit({
1745
+ sshPubkey: key.publicKey,
1746
+ boxName: req.name,
1747
+ boxEnv: Object.keys(boxEnv).length > 0 ? boxEnv : void 0
1748
+ });
1749
+ const serverType = req.size && req.size.trim() || HETZNER_DEFAULT_SERVER_TYPE;
1750
+ progress(
1751
+ `creating VPS '${req.name}' from image ${String(imageRef)} (${serverType} / ${HETZNER_DEFAULT_LOCATION})`
1752
+ );
1753
+ const created = await withHetznerRetry(
1754
+ { method: "createServer", retryOnAmbiguous: false, attemptTimeoutMs: 12e4 },
1755
+ () => c.createServer({
1756
+ name: `agentbox-${req.name}-${stamp}`,
1757
+ server_type: serverType,
1758
+ image: imageRef,
1759
+ location: HETZNER_DEFAULT_LOCATION,
1760
+ user_data: cloudInit,
1761
+ firewalls: [{ firewall: firewall.id }],
1762
+ labels: {
1763
+ "agentbox.managed": "true",
1764
+ "agentbox.role": "box",
1765
+ "agentbox.box": req.name,
1766
+ "agentbox.firewall": String(firewall.id)
1767
+ },
1768
+ start_after_create: true
1769
+ })
1770
+ );
1771
+ serverId = created.server.id;
1772
+ const vpsIp = created.server.public_net.ipv4?.ip;
1773
+ if (!vpsIp) {
1774
+ throw new Error(`hetzner: server ${String(serverId)} came up without an IPv4 address`);
1775
+ }
1776
+ progress(`server ${String(serverId)} provisioned at ${vpsIp}; waiting for ssh`);
1777
+ const sandboxId = String(serverId);
1778
+ const state = await ensurePerBoxState(sandboxId);
1779
+ await rename(key.privatePath, state.identity);
1780
+ await rename(key.publicPath, `${state.identity}.pub`);
1781
+ await rm2(key.dir, { recursive: true, force: true });
1782
+ const pendingParent = resolvePath(key.dir, "..");
1783
+ await rm2(pendingParent, { recursive: true, force: true });
1784
+ const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
1785
+ if (!up) {
1786
+ throw new Error(`hetzner: ssh on ${vpsIp} did not come up within ${String(PROVISION_SSH_DEADLINE_MS / 1e3)}s`);
1787
+ }
1788
+ await ensureTunnel(sandboxId, state, vpsIp);
1789
+ progress("ssh up; ControlMaster open");
1790
+ return { sandboxId };
1791
+ } catch (err) {
1792
+ if (serverId !== null) {
1793
+ progress(`cleanup \u2014 deleting server ${String(serverId)} after provision failure`);
1794
+ try {
1795
+ await c.deleteServer(serverId);
1796
+ } catch (cleanupErr) {
1797
+ onLog(
1798
+ `hetzner: WARN \u2014 failed to delete server ${String(serverId)}; check the Hetzner dashboard manually. ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`
1799
+ );
1800
+ }
1801
+ }
1802
+ if (firewallId !== null) {
1803
+ try {
1804
+ await deletePerBoxFirewall(c, firewallId);
1805
+ } catch {
1806
+ }
1807
+ }
1808
+ try {
1809
+ if (existsSync22(key.dir)) await rm2(key.dir, { recursive: true, force: true });
1810
+ if (serverId !== null) {
1811
+ const finalDir = perBoxDir(String(serverId));
1812
+ if (existsSync22(finalDir)) await rm2(finalDir, { recursive: true, force: true });
1813
+ }
1814
+ } catch {
1815
+ }
1816
+ throw err;
1817
+ }
1818
+ },
1819
+ async get(sandboxId) {
1820
+ const id = Number.parseInt(sandboxId, 10);
1821
+ if (!Number.isFinite(id)) return null;
1822
+ const server = await client().getServer(id);
1823
+ return server ? { sandboxId } : null;
1824
+ },
1825
+ async list() {
1826
+ const servers = await client().listServers({ label_selector: "agentbox.managed=true" });
1827
+ return servers.map((s) => ({
1828
+ sandboxId: String(s.id),
1829
+ name: s.labels["agentbox.box"] ?? s.name,
1830
+ createdAt: s.created,
1831
+ state: mapState(s.status)
1832
+ }));
1833
+ },
1834
+ async start(h) {
1835
+ const id = Number.parseInt(h.sandboxId, 10);
1836
+ await client().powerOn(id);
1837
+ await pollUntil(
1838
+ `server ${h.sandboxId} running`,
1839
+ async () => {
1840
+ const s = await client().getServer(id);
1841
+ return s?.status === "running" ? s : null;
1842
+ },
1843
+ { deadlineMs: ACTION_DEADLINE_MS, intervalMs: 2e3, maxIntervalMs: 8e3 }
1844
+ );
1845
+ const server = await getServerStrict(id);
1846
+ const vpsIp = server.public_net.ipv4?.ip;
1847
+ if (!vpsIp) {
1848
+ throw new Error(`hetzner: server ${h.sandboxId} has no IPv4 address after start`);
1849
+ }
1850
+ const state = await ensurePerBoxState(h.sandboxId);
1851
+ const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
1852
+ if (!up) {
1853
+ throw new Error(
1854
+ `hetzner: ssh on ${vpsIp} did not come up within ${String(PROVISION_SSH_DEADLINE_MS / 1e3)}s after start`
1855
+ );
1856
+ }
1857
+ },
1858
+ async stop(h) {
1859
+ const id = Number.parseInt(h.sandboxId, 10);
1860
+ try {
1861
+ await client().shutdown(id);
1862
+ await pollUntil(
1863
+ `server ${h.sandboxId} off`,
1864
+ async () => {
1865
+ const s = await client().getServer(id);
1866
+ return s?.status === "off" ? s : null;
1867
+ },
1868
+ { deadlineMs: 6e4, intervalMs: 2e3, maxIntervalMs: 8e3 }
1869
+ );
1870
+ } catch {
1871
+ await client().powerOff(id);
1872
+ }
1873
+ await tunnels.close(h.sandboxId);
1874
+ },
1875
+ async pause(h) {
1876
+ await this.stop(h);
1877
+ },
1878
+ async resume(h) {
1879
+ await this.start(h);
1880
+ },
1881
+ async destroy(h) {
1882
+ const id = Number.parseInt(h.sandboxId, 10);
1883
+ await tunnels.close(h.sandboxId);
1884
+ const c = client();
1885
+ let firewallId;
1886
+ try {
1887
+ const server = await c.getServer(id);
1888
+ firewallId = server ? Number.parseInt(server.labels["agentbox.firewall"] ?? "", 10) : void 0;
1889
+ } catch {
1890
+ }
1891
+ try {
1892
+ await c.deleteServer(id);
1893
+ } catch (err) {
1894
+ if (!(err instanceof HetznerApiError && (err.statusCode === 404 || err.code === "not_found"))) {
1895
+ throw err;
1896
+ }
1897
+ }
1898
+ if (firewallId && Number.isFinite(firewallId)) {
1899
+ await deletePerBoxFirewall(c, firewallId);
1900
+ }
1901
+ const dir = perBoxDir(h.sandboxId);
1902
+ try {
1903
+ await rm2(dir, { recursive: true, force: true });
1904
+ } catch {
1905
+ }
1906
+ },
1907
+ async state(h) {
1908
+ const id = Number.parseInt(h.sandboxId, 10);
1909
+ const s = await client().getServer(id);
1910
+ return s ? mapState(s.status) : "missing";
1911
+ },
1912
+ async exec(h, cmd, opts) {
1913
+ const { target } = await ensureLiveTarget(h.sandboxId);
1914
+ const argv = [
1915
+ ...sshOptArgs(target),
1916
+ `${target.user}@${target.host}`,
1917
+ bashScript(opts?.cwd ? `cd ${shellQuote(opts.cwd)} && ${cmd}` : cmd)
1918
+ ];
1919
+ const res = await execa("ssh", argv, {
1920
+ reject: false,
1921
+ timeout: opts?.attemptTimeoutMs ?? 12e4,
1922
+ env: { ...process.env, ...opts?.env ?? {} }
1923
+ });
1924
+ return {
1925
+ exitCode: typeof res.exitCode === "number" ? res.exitCode : 1,
1926
+ stdout: typeof res.stdout === "string" ? res.stdout : "",
1927
+ stderr: typeof res.stderr === "string" ? res.stderr : ""
1928
+ };
1929
+ },
1930
+ async uploadFile(h, localPath, remotePath) {
1931
+ const { target } = await ensureLiveTarget(h.sandboxId);
1932
+ const argv = [
1933
+ ...sshOptArgs(target),
1934
+ localPath,
1935
+ `${target.user}@${target.host}:${remotePath}`
1936
+ ];
1937
+ const res = await execa("scp", argv, { reject: false, timeout: 3e5 });
1938
+ if (res.exitCode !== 0) {
1939
+ throw new Error(`hetzner: scp upload failed (exit ${String(res.exitCode)}): ${res.stderr || ""}`);
1940
+ }
1941
+ },
1942
+ async downloadFile(h, remotePath, localPath) {
1943
+ const { target } = await ensureLiveTarget(h.sandboxId);
1944
+ const argv = [
1945
+ ...sshOptArgs(target),
1946
+ `${target.user}@${target.host}:${remotePath}`,
1947
+ localPath
1948
+ ];
1949
+ const res = await execa("scp", argv, { reject: false, timeout: 3e5 });
1950
+ if (res.exitCode !== 0) {
1951
+ throw new Error(`hetzner: scp download failed (exit ${String(res.exitCode)}): ${res.stderr || ""}`);
1952
+ }
1953
+ },
1954
+ async listFiles(h, remoteDir) {
1955
+ const res = await this.exec(
1956
+ h,
1957
+ // -L for nicer dir-detection on symlinks; `--printf` is non-portable so
1958
+ // use a small awk wrap that prints `<name>\t<d|f>` per entry.
1959
+ `find ${shellQuote(remoteDir)} -mindepth 1 -maxdepth 1 -printf '%f\\t%y\\n'`
1960
+ );
1961
+ if (res.exitCode !== 0) return [];
1962
+ return res.stdout.split(/\r?\n/).filter((line) => line.length > 0).map((line) => {
1963
+ const [name, kind] = line.split(" ");
1964
+ return { name: name ?? line, isDir: kind === "d" };
1965
+ });
1966
+ },
1967
+ async previewUrl(h, port) {
1968
+ const { state, vpsIp } = await ensureLiveTarget(h.sandboxId);
1969
+ void state;
1970
+ void vpsIp;
1971
+ const localPort = await tunnels.forward(h.sandboxId, port);
1972
+ return { url: `http://127.0.0.1:${String(localPort)}` };
1973
+ },
1974
+ async signedPreviewUrl(h, port, _ttl) {
1975
+ void _ttl;
1976
+ return this.previewUrl(h, port);
1977
+ },
1978
+ async refreshPreviewUrl(h, port) {
1979
+ const { state, vpsIp } = await ensureLiveTarget(h.sandboxId);
1980
+ void state;
1981
+ void vpsIp;
1982
+ await tunnels.refresh({
1983
+ boxId: h.sandboxId,
1984
+ vpsHost: vpsIp,
1985
+ identity: state.identity
1986
+ });
1987
+ const localPort = await tunnels.forward(h.sandboxId, port);
1988
+ return { url: `http://127.0.0.1:${String(localPort)}` };
1989
+ },
1990
+ async repairReachability(h) {
1991
+ const s = await firewallEgressStatus(h.sandboxId).catch(() => null);
1992
+ if (!s || !firewallNeedsSync(s.allowedSource, s.currentEgress)) return { changed: false };
1993
+ await syncFirewallSource(client(), s.firewallId, s.currentEgress);
1994
+ return {
1995
+ changed: true,
1996
+ detail: `firewall updated: SSH now allowed from ${s.currentEgress} (was ${s.allowedSource ?? "(no rule)"})`
1997
+ };
1998
+ },
1999
+ async startInBoxPortless(h, opts) {
2000
+ const tlsFlag = opts.tls ? "" : "--no-tls";
2001
+ const startCmd = `sudo portless proxy start ${tlsFlag} -p ${String(opts.proxyPort)}`.replace(/\s+/g, " ");
2002
+ const aliasCmd = `sudo portless alias ${shellQuote(opts.boxName)} ${String(opts.webPort)}`;
2003
+ const cmds = [startCmd, aliasCmd];
2004
+ if (opts.tls) {
2005
+ cmds.push(
2006
+ "sudo agentbox-portless-trust /root/.portless/ca.pem >/dev/null 2>&1 || true",
2007
+ `echo 'export NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/agentbox-portless-ca.crt' | sudo tee /etc/profile.d/agentbox-portless-ca.sh >/dev/null || true`
2008
+ );
2009
+ }
2010
+ await this.exec(h, cmds.join("; "));
2011
+ },
2012
+ async attachArgv(h) {
2013
+ const { target } = await ensureLiveTarget(h.sandboxId);
2014
+ return [
2015
+ "ssh",
2016
+ ...sshOptArgs(target),
2017
+ `${target.user}@${target.host}`
2018
+ ];
2019
+ },
2020
+ async createSnapshot(h, name) {
2021
+ const id = Number.parseInt(h.sandboxId, 10);
2022
+ const c = client();
2023
+ const { image } = await withHetznerRetry(
2024
+ { method: "createImage", retryOnAmbiguous: false, attemptTimeoutMs: 12e4 },
2025
+ () => c.createImage(id, {
2026
+ type: "snapshot",
2027
+ description: name,
2028
+ labels: { "agentbox.role": "ckpt", "agentbox.box": h.sandboxId }
2029
+ })
2030
+ );
2031
+ await pollUntil(
2032
+ `image ${String(image.id)} availability`,
2033
+ async () => {
2034
+ const img = await c.getImage(image.id);
2035
+ return img?.status === "available" ? img : null;
2036
+ },
2037
+ { deadlineMs: SNAPSHOT_DEADLINE_MS2, intervalMs: 3e3, maxIntervalMs: 1e4 }
2038
+ );
2039
+ },
2040
+ async deleteSnapshot(name) {
2041
+ const c = client();
2042
+ const img = await findImageByDescription(c, name);
2043
+ if (!img) return;
2044
+ try {
2045
+ await c.deleteImage(img.id);
2046
+ } catch (err) {
2047
+ if (err instanceof HetznerApiError && (err.statusCode === 404 || err.code === "not_found")) return;
2048
+ throw err;
2049
+ }
2050
+ }
2051
+ };
2052
+ function readCredStatusSummary() {
2053
+ return { configured: readHetznerCredStatus().source !== "none" };
2054
+ }
2055
+ async function doctorChecks() {
2056
+ try {
2057
+ const cred = readHetznerCredStatus();
2058
+ const credRes = cred.source === "none" ? {
2059
+ label: "credentials",
2060
+ status: "warn",
2061
+ detail: "HCLOUD_TOKEN not set",
2062
+ hint: "`agentbox hetzner login`"
2063
+ } : { label: "credentials", status: "ok", detail: `token from ${cred.source}` };
2064
+ const prepared = readPreparedState();
2065
+ const snapRes = prepared.base?.imageId ? {
2066
+ label: "base snapshot",
2067
+ status: "ok",
2068
+ detail: `image ${String(prepared.base.imageId)} (${prepared.base.cliVersion ?? "\u2014"})`
2069
+ } : {
2070
+ label: "base snapshot",
2071
+ status: "warn",
2072
+ detail: "not baked",
2073
+ hint: "`agentbox prepare --provider hetzner`"
2074
+ };
2075
+ const portlessRes = portlessDoctorRow(await detectPortless());
2076
+ return [credRes, snapRes, portlessRes];
2077
+ } catch (err) {
2078
+ return [{ label: "credentials", status: "warn", detail: errSummary(err) }];
2079
+ }
2080
+ }
2081
+ var REMOTE_APP_DIR = "/opt/agentbox/apps/hub";
2082
+ function caddyfile(domain) {
2083
+ return `${domain} {
2084
+ reverse_proxy app:3000
2085
+ }
2086
+ `;
2087
+ }
2088
+ var CADDY_COMPOSE = `services:
2089
+ caddy:
2090
+ image: caddy:2.8
2091
+ restart: unless-stopped
2092
+ ports:
2093
+ - '80:80'
2094
+ - '443:443'
2095
+ volumes:
2096
+ - ${REMOTE_APP_DIR}/Caddyfile:/etc/caddy/Caddyfile:ro
2097
+ - caddy_data:/data
2098
+ - caddy_config:/config
2099
+ depends_on:
2100
+ - app
2101
+ volumes:
2102
+ caddy_data:
2103
+ caddy_config:
2104
+ `;
2105
+ async function serverIpv4(client2, server, deadlineMs) {
2106
+ if (server.public_net.ipv4?.ip) return server.public_net.ipv4.ip;
2107
+ const stop = Date.now() + deadlineMs;
2108
+ while (Date.now() < stop) {
2109
+ const s = await client2.getServer(server.id);
2110
+ if (s?.public_net.ipv4?.ip) return s.public_net.ipv4.ip;
2111
+ await new Promise((r) => setTimeout(r, 3e3));
2112
+ }
2113
+ throw new Error(`server ${String(server.id)} never got a public IPv4`);
2114
+ }
2115
+ async function pollHealthz(url, deadlineMs, log) {
2116
+ const stop = Date.now() + deadlineMs;
2117
+ let lastErr = "";
2118
+ while (Date.now() < stop) {
2119
+ try {
2120
+ const res = await fetch(`${url}/healthz`, { signal: AbortSignal.timeout(8e3) });
2121
+ if (res.ok) return;
2122
+ lastErr = `HTTP ${String(res.status)}`;
2123
+ } catch (e) {
2124
+ lastErr = e instanceof Error ? e.name : String(e);
2125
+ }
2126
+ log(`waiting for ${url}/healthz (cert + app)\u2026 ${lastErr}`);
2127
+ await new Promise((r) => setTimeout(r, 6e3));
2128
+ }
2129
+ throw new Error(`control plane did not become healthy at ${url} (${lastErr})`);
2130
+ }
2131
+ async function deployControlPlaneToHetzner(opts) {
2132
+ const log = opts.onLog ?? (() => {
2133
+ });
2134
+ const repoUrl = opts.repoUrl ?? "https://github.com/madarco/agentbox.git";
2135
+ const repoRef = opts.repoRef ?? "main";
2136
+ const client2 = makeHetznerClient();
2137
+ const stamp = Date.now().toString(36);
2138
+ const name = `agentbox-control-plane-${stamp}`;
2139
+ log("detecting host egress IP for the firewall\u2026");
2140
+ const hostCidr = normalizeSourceCidr(await detectEgressIp());
2141
+ log("creating the control-plane firewall (:22 host-only, :80/:443 open)\u2026");
2142
+ const firewall = await withHetznerRetry(
2143
+ { method: "createFirewall", retryOnAmbiguous: false, attemptTimeoutMs: 6e4 },
2144
+ () => client2.createFirewall({
2145
+ name,
2146
+ rules: controlPlaneInboundRules(hostCidr),
2147
+ labels: { "agentbox.managed": "true", "agentbox.role": "control-plane" }
2148
+ })
2149
+ );
2150
+ const keyDir = join5(homedir22(), ".agentbox", "control-plane", "ssh", stamp);
2151
+ const key = await mintSshKey(keyDir, `agentbox-control-plane-${stamp}`);
2152
+ const knownHosts = join5(keyDir, "known_hosts");
2153
+ log(`provisioning ${opts.serverType ?? "cx23"} VPS (cloning ${repoUrl}@${repoRef})\u2026`);
2154
+ const { server } = await withHetznerRetry(
2155
+ { method: "createServer", retryOnAmbiguous: false, attemptTimeoutMs: 12e4 },
2156
+ () => client2.createServer({
2157
+ name,
2158
+ server_type: opts.serverType ?? "cx23",
2159
+ image: opts.serverImage ?? "ubuntu-24.04",
2160
+ location: opts.location ?? "nbg1",
2161
+ user_data: controlPlaneCloudInit({ sshPubkey: key.publicKey, repoUrl, repoRef }),
2162
+ firewalls: [{ firewall: firewall.id }],
2163
+ labels: { "agentbox.managed": "true", "agentbox.role": "control-plane" },
2164
+ start_after_create: true
2165
+ })
2166
+ );
2167
+ const ip = await serverIpv4(client2, server, 6e4);
2168
+ const domain = opts.domain ?? `${ip}.sslip.io`;
2169
+ const url = `https://${domain}`;
2170
+ const target = { host: ip, user: "root", identity: key.privatePath, knownHosts };
2171
+ log(`VPS ${ip} up; waiting for ssh\u2026`);
2172
+ if (!await waitForSsh(target, 5 * 6e4)) {
2173
+ throw new Error(`ssh never came up on ${ip}`);
2174
+ }
2175
+ log("waiting for cloud-init (Docker + repo clone)\u2026");
2176
+ await sshExec(target, "cloud-init status --wait || true", { timeoutMs: 12 * 6e4, onLine: log });
2177
+ const cloned = await sshExec(target, `test -d ${REMOTE_APP_DIR}`);
2178
+ if (cloned.exitCode !== 0) {
2179
+ throw new Error("repo clone did not complete on the VPS (cloud-init failed)");
2180
+ }
2181
+ const staging = join5(tmpdir(), `agentbox-cp-deploy-${stamp}`);
2182
+ await mkdir4(staging, { recursive: true });
2183
+ try {
2184
+ const envLocal = join5(staging, "control-plane.env");
2185
+ const caddyLocal = join5(staging, "Caddyfile");
2186
+ const composeLocal = join5(staging, "docker-compose.caddy.yml");
2187
+ await writeFile(envLocal, opts.envContent, { mode: 384 });
2188
+ await writeFile(caddyLocal, caddyfile(domain));
2189
+ await writeFile(composeLocal, CADDY_COMPOSE);
2190
+ log("uploading env + Caddy config\u2026");
2191
+ await scpUpload(target, envLocal, `${REMOTE_APP_DIR}/.env`);
2192
+ await scpUpload(target, caddyLocal, `${REMOTE_APP_DIR}/Caddyfile`);
2193
+ await scpUpload(target, composeLocal, `${REMOTE_APP_DIR}/docker-compose.caddy.yml`);
2194
+ } finally {
2195
+ await rm3(staging, { recursive: true, force: true });
2196
+ }
2197
+ log("building + starting the control plane (docker compose up --build)\u2026");
2198
+ const up = await sshExec(
2199
+ target,
2200
+ `cd ${REMOTE_APP_DIR} && docker compose -f docker-compose.yml -f docker-compose.caddy.yml up -d --build`,
2201
+ { timeoutMs: 25 * 6e4, onLine: log }
2202
+ );
2203
+ if (up.exitCode !== 0) {
2204
+ throw new Error(`docker compose up failed (exit ${String(up.exitCode)}): ${up.stderr || up.stdout}`);
2205
+ }
2206
+ log(`provisioned; waiting for HTTPS at ${url} \u2026`);
2207
+ await pollHealthz(url, 3 * 6e4, log);
2208
+ const result = {
2209
+ url,
2210
+ serverId: server.id,
2211
+ ip,
2212
+ domain,
2213
+ firewallId: firewall.id,
2214
+ sshKeyDir: keyDir
2215
+ };
2216
+ return result;
2217
+ }
2218
+ var cloudProvider = createCloudProvider(hetznerBackend, {
2219
+ defaultResources: { cpu: 2, memory: 4, disk: 40 }
2220
+ });
2221
+ var hetznerProvider = {
2222
+ ...cloudProvider,
2223
+ prepare: prepareHetznerProvider,
2224
+ baseFingerprint: () => currentHetznerBaseFingerprintLive()
2225
+ };
2226
+ var providerModule = {
2227
+ provider: hetznerProvider,
2228
+ backend: hetznerBackend,
2229
+ ensureCredentials: ensureHetznerCredentials,
2230
+ readCredStatus: readCredStatusSummary,
2231
+ setCredentials: setHetznerCredentials,
2232
+ currentBaseFingerprintLive: (claudeInstall) => currentHetznerBaseFingerprintLive(claudeInstall),
2233
+ doctorChecks
2234
+ };
2235
+ export {
2236
+ DEFAULT_HCLOUD_ENDPOINT,
2237
+ HETZNER_DEFAULT_BOX_IMAGE_REF,
2238
+ HetznerApiError,
2239
+ RUNTIME_ASSETS,
2240
+ candidatesFor,
2241
+ controlPlaneCloudInit,
2242
+ createPerBoxFirewall,
2243
+ currentHetznerBaseFingerprintLive,
2244
+ deletePerBoxFirewall,
2245
+ deployControlPlaneToHetzner,
2246
+ detectEgressIp,
2247
+ ensureHetznerBaseSnapshot,
2248
+ ensureHetznerCredentials,
2249
+ ensureHetznerEnvLoaded,
2250
+ generateBoxCloudInit,
2251
+ generatePrepareCloudInit,
2252
+ hetznerBackend,
2253
+ hetznerProvider,
2254
+ isAttemptTimeout,
2255
+ isRetriable,
2256
+ makeHetznerClient,
2257
+ maskKey,
2258
+ mintPrepareKey,
2259
+ mintSshKey,
2260
+ normalizeSourceCidr,
2261
+ pollUntil,
2262
+ prepareHetzner,
2263
+ prepareHetznerProvider,
2264
+ preparedStatePath,
2265
+ providerModule,
2266
+ readHetznerCredStatus,
2267
+ readPreparedState,
2268
+ resolveRuntimeAssets,
2269
+ scpDownload,
2270
+ scpUpload,
2271
+ secretsPath,
2272
+ setHetznerCredentials,
2273
+ sshExec,
2274
+ sshOnlyInboundRule,
2275
+ sshOptArgs,
2276
+ syncFirewallSource,
2277
+ updatePreparedState,
2278
+ waitForSsh,
2279
+ withHetznerRetry,
2280
+ writePreparedState
2281
+ };