@madarco/agentbox 0.27.1 → 0.28.0-nightly.202607251721

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 (364) hide show
  1. package/CHANGELOG.md +87 -4
  2. package/README.md +7 -3
  3. package/dist/_cloud-attach-XZYF324R.js +26 -0
  4. package/dist/admin-client-NOZ5CCAH.js +15 -0
  5. package/dist/chunk-2VW37PW4.js +1694 -0
  6. package/dist/chunk-2VW37PW4.js.map +1 -0
  7. package/dist/{chunk-HR7NHH5J.js → chunk-3UMM4VJH.js} +808 -57
  8. package/dist/chunk-3UMM4VJH.js.map +1 -0
  9. package/dist/chunk-5U5QOFL5.js +20 -0
  10. package/dist/chunk-5U5QOFL5.js.map +1 -0
  11. package/dist/chunk-6P6D77QP.js +285 -0
  12. package/dist/chunk-6P6D77QP.js.map +1 -0
  13. package/dist/chunk-6V366IZC.js +2892 -0
  14. package/dist/chunk-6V366IZC.js.map +1 -0
  15. package/dist/{chunk-KWOEUFVA.js → chunk-7J6G526Q.js} +6 -14
  16. package/dist/{chunk-KWOEUFVA.js.map → chunk-7J6G526Q.js.map} +1 -1
  17. package/dist/{chunk-IDH5A4RR.js → chunk-AYPAYY5R.js} +17 -4
  18. package/dist/chunk-AYPAYY5R.js.map +1 -0
  19. package/dist/{chunk-JGZSA5ZI.js → chunk-BHJCMTHP.js} +58 -15
  20. package/dist/chunk-BHJCMTHP.js.map +1 -0
  21. package/dist/{chunk-26IKZRTT.js → chunk-BLWAWGFX.js} +297 -1217
  22. package/dist/chunk-BLWAWGFX.js.map +1 -0
  23. package/dist/chunk-CGPUFXET.js +95 -0
  24. package/dist/chunk-CGPUFXET.js.map +1 -0
  25. package/dist/{chunk-SJ75AIA2.js → chunk-D6AODRNA.js} +12 -9
  26. package/dist/{chunk-SJ75AIA2.js.map → chunk-D6AODRNA.js.map} +1 -1
  27. package/dist/chunk-DPJMEG7U.js +11 -0
  28. package/dist/chunk-DPJMEG7U.js.map +1 -0
  29. package/dist/chunk-E2ITEZAQ.js +148 -0
  30. package/dist/chunk-E2ITEZAQ.js.map +1 -0
  31. package/dist/{chunk-JE6UI5YR.js → chunk-NKVCIH6N.js} +89 -223
  32. package/dist/chunk-NKVCIH6N.js.map +1 -0
  33. package/dist/chunk-OEYAVBA6.js +120 -0
  34. package/dist/chunk-OEYAVBA6.js.map +1 -0
  35. package/dist/{chunk-UJEH2NJT.js → chunk-PXYPQ5BO.js} +64 -264
  36. package/dist/chunk-PXYPQ5BO.js.map +1 -0
  37. package/dist/chunk-QESXSSO6.js +670 -0
  38. package/dist/chunk-QESXSSO6.js.map +1 -0
  39. package/dist/{chunk-NEF6MDJO.js → chunk-QJCK2AFX.js} +128 -26
  40. package/dist/chunk-QJCK2AFX.js.map +1 -0
  41. package/dist/chunk-RUJJY23M.js +84 -0
  42. package/dist/chunk-RUJJY23M.js.map +1 -0
  43. package/dist/{chunk-LL7NCMUU.js → chunk-SKNJRYM5.js} +7 -13
  44. package/dist/chunk-SKNJRYM5.js.map +1 -0
  45. package/dist/chunk-WFGAMJ5Q.js +689 -0
  46. package/dist/chunk-WFGAMJ5Q.js.map +1 -0
  47. package/dist/chunk-ZJL56TJD.js +1444 -0
  48. package/dist/chunk-ZJL56TJD.js.map +1 -0
  49. package/dist/{chunk-V5XXJH63.js → chunk-ZXOP4LBG.js} +5 -8
  50. package/dist/chunk-ZXOP4LBG.js.map +1 -0
  51. package/dist/control-plane-2VEM2KCL.js +31 -0
  52. package/dist/custody-client-P6XIXHRG.js +16 -0
  53. package/dist/{dist-TSFVB7AI.js → dist-2SYQI5S2.js} +11 -7
  54. package/dist/dist-2SYQI5S2.js.map +1 -0
  55. package/dist/{dist-KQTMCVME.js → dist-6QZMZEL7.js} +18 -11
  56. package/dist/dist-6QZMZEL7.js.map +1 -0
  57. package/dist/{dist-FTKS2GI4.js → dist-JHMILJUT.js} +10 -6
  58. package/dist/{dist-OO52HARR.js → dist-JOFZOZCY.js} +41 -25
  59. package/dist/{dist-O3LKOIE7.js → dist-KZ2GEEEX.js} +11 -7
  60. package/dist/dist-KZ2GEEEX.js.map +1 -0
  61. package/dist/{dist-Z6L5MM5D.js → dist-Q5NY4CF6.js} +10 -6
  62. package/dist/{dist-U2SVLJUQ.js → dist-SKMNEDVW.js} +8 -2
  63. package/dist/dist-SKMNEDVW.js.map +1 -0
  64. package/dist/dist-SRCKO7ZV.js +197 -0
  65. package/dist/dist-SRCKO7ZV.js.map +1 -0
  66. package/dist/{dist-WVYAURMF.js → dist-UXZQWKY6.js} +10 -6
  67. package/dist/dist-UXZQWKY6.js.map +1 -0
  68. package/dist/env-file-UDUDQMP4.js +11 -0
  69. package/dist/env-file-UDUDQMP4.js.map +1 -0
  70. package/dist/hub-adopt-ZS5CREYF.js +21 -0
  71. package/dist/hub-adopt-ZS5CREYF.js.map +1 -0
  72. package/dist/index.js +2461 -1905
  73. package/dist/index.js.map +1 -1
  74. package/dist/node-postgres-6JUOVUN5.js +3584 -0
  75. package/dist/node-postgres-6JUOVUN5.js.map +1 -0
  76. package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js → prepared-state-75DIZ55S-P6LE4N64.js} +3 -2
  77. package/dist/prepared-state-75DIZ55S-P6LE4N64.js.map +1 -0
  78. package/dist/remote-hub-SJ4XWBA5.js +9 -0
  79. package/dist/remote-hub-SJ4XWBA5.js.map +1 -0
  80. package/dist/sqlite-proxy-53E5D2VM.js +2882 -0
  81. package/dist/sqlite-proxy-53E5D2VM.js.map +1 -0
  82. package/package.json +1 -1
  83. package/runtime/_shared/ctl.cjs +29199 -16813
  84. package/runtime/digitalocean/ctl.cjs +29199 -16813
  85. package/runtime/docker/packages/ctl/dist/bin.cjs +29199 -16813
  86. package/runtime/e2b/ctl.cjs +29199 -16813
  87. package/runtime/hetzner/ctl.cjs +29199 -16813
  88. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  89. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  90. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js +5 -5
  91. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +1 -1
  92. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js +2 -2
  93. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js.nft.json +1 -1
  94. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js +2 -2
  95. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js.nft.json +1 -1
  96. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js +2 -2
  97. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js.nft.json +1 -1
  98. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js +2 -2
  99. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js.nft.json +1 -1
  100. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js +2 -2
  101. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js.nft.json +1 -1
  102. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js +2 -2
  103. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js.nft.json +1 -1
  104. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js +2 -2
  105. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.nft.json +1 -1
  106. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +2 -2
  107. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -1
  108. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js +2 -2
  109. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js.nft.json +1 -1
  110. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js +2 -2
  111. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js.nft.json +1 -1
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js +4 -4
  113. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js.nft.json +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js +2 -2
  115. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js.nft.json +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js +2 -2
  117. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js.nft.json +1 -1
  118. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js +2 -2
  119. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js.nft.json +1 -1
  120. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js +2 -2
  121. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js.nft.json +1 -1
  122. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js +2 -2
  123. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js.nft.json +1 -1
  124. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js +2 -2
  125. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js.nft.json +1 -1
  126. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js +2 -2
  127. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js.nft.json +1 -1
  128. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js +2 -2
  129. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js.nft.json +1 -1
  130. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js +2 -2
  131. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.nft.json +1 -1
  132. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js +2 -2
  133. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js.nft.json +1 -1
  134. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js +2 -2
  135. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js.nft.json +1 -1
  136. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js +2 -2
  137. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js.nft.json +1 -1
  138. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js +2 -2
  139. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js.nft.json +1 -1
  140. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js +2 -2
  141. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js.nft.json +1 -1
  142. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js +2 -2
  143. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js.nft.json +1 -1
  144. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js +2 -2
  145. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js.nft.json +1 -1
  146. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
  147. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js +2 -2
  148. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js.nft.json +1 -1
  149. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  150. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js +2 -2
  151. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  152. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  153. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js +2 -2
  154. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.nft.json +1 -1
  155. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
  156. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js +2 -2
  157. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js.nft.json +1 -1
  158. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  159. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js +4 -2
  160. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js.nft.json +1 -1
  161. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  162. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  163. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  164. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  165. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  166. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  167. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  168. package/runtime/hub/apps/hub/.next/server/chunks/0-fj_better-auth_dist_adapters_kysely-adapter_index_mjs_0btft52._.js +3 -0
  169. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_0gvv4ct._.js +4 -0
  170. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_0pn9b49._.js +4 -0
  171. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_145bz8z._.js +9 -0
  172. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_14y990b._.js +3 -0
  173. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_1nl4l3q._.js +3 -0
  174. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_sqlite-proxy_index_05v_j5r.js +15 -0
  175. package/runtime/hub/apps/hub/.next/server/chunks/{[externals]__12m3qoa._.js → [externals]__0f3aqcx._.js} +2 -2
  176. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0-9g1s8._.js +3 -0
  177. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0-pvfxg._.js +3 -0
  178. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__01amzh6._.js +3 -0
  179. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__02q799_._.js +3 -0
  180. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__03k22rl._.js +3 -0
  181. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04tqk-j._.js +3 -0
  182. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__05ovf1y._.js +3 -0
  183. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__05s-_x7._.js +3 -0
  184. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07dnyfi._.js +3 -0
  185. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07zk6qo._.js +3 -0
  186. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0_59yi6._.js +3 -0
  187. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ajlo3d._.js +3 -0
  188. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0b5s54n._.js +3 -0
  189. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c4fiez._.js +3 -0
  190. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c9iff1._.js +3 -0
  191. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +5 -5
  192. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0dh6lzr._.js +3 -0
  193. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ey83ai._.js +3 -0
  194. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0h6vdvr._.js +3 -0
  195. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0lup7p4._.js +3 -0
  196. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0luxuu4._.js +3 -0
  197. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0nl2u6u._.js +3 -0
  198. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0nonp-6._.js +3 -0
  199. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0oplozy._.js +3 -0
  200. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0p-6wgd._.js +3 -0
  201. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0rcnwbw._.js +3 -0
  202. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0tuz1am._.js +3 -0
  203. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-9g0ae._.js +1 -1
  204. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__10ry4ss._.js +3 -0
  205. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11hv164._.js +3 -0
  206. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__154_i13._.js +3 -0
  207. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__17676rc._.js +3 -0
  208. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bg1alc._.js +3 -0
  209. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1cvqb1d._.js +3 -0
  210. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d60gbz._.js +3 -0
  211. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dm0jmw._.js +6 -0
  212. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dv_b1t._.js +3 -0
  213. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1fzxip4._.js +3 -0
  214. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4oj-e._.js +3 -0
  215. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1i4gq_2._.js +3 -0
  216. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v1p7in._.js +3 -0
  217. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9_her._.js +4 -0
  218. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1x1jkpb._.js +3 -0
  219. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1yd8n5l._.js +3 -0
  220. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20t_rs8._.js +3 -0
  221. package/runtime/hub/apps/hub/.next/server/chunks/_033w048._.js +1 -1
  222. package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
  223. package/runtime/hub/apps/hub/.next/server/chunks/{_0760z6y._.js → _0907rw0._.js} +15 -15
  224. package/runtime/hub/apps/hub/.next/server/chunks/_0f3molr._.js +1 -1
  225. package/runtime/hub/apps/hub/.next/server/chunks/_0lgs9kd._.js +1 -1
  226. package/runtime/hub/apps/hub/.next/server/chunks/_0pyhcqe._.js +1 -1
  227. package/runtime/hub/apps/hub/.next/server/chunks/_1-42ili._.js +1 -1
  228. package/runtime/hub/apps/hub/.next/server/chunks/_11__3wi._.js +1 -1
  229. package/runtime/hub/apps/hub/.next/server/chunks/_12flzuh._.js +1 -1
  230. package/runtime/hub/apps/hub/.next/server/chunks/_1bng7w9._.js +1 -1
  231. package/runtime/hub/apps/hub/.next/server/chunks/_1rpkqst._.js +1 -1
  232. package/runtime/hub/apps/hub/.next/server/chunks/_1wt72m1._.js +1 -1
  233. package/runtime/hub/apps/hub/.next/server/chunks/_1x3l5t8._.js +1 -1
  234. package/runtime/hub/apps/hub/.next/server/chunks/packages_relay_dist_control-plane_03a-9aj.js +62 -31
  235. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0xy-j7z._.js +1 -1
  236. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_1uccfbf._.js +1 -1
  237. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_010858m.js +1 -1
  238. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_04zwxnx.js +1 -1
  239. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_06exuc7.js +1 -1
  240. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2ldrt.js +1 -1
  241. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2tzep.js +1 -1
  242. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_116nh32.js +1 -1
  243. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_11dyjcb.js +1 -1
  244. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_1_4knli.js +1 -1
  245. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0ebuy19._.js +3 -0
  246. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0wxhi0-._.js +3 -0
  247. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0xe4ick._.js +9 -0
  248. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_14oaveu._.js +4 -0
  249. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_sqlite-proxy_index_1a6wfdg.js +15 -0
  250. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0-pm2yl._.js +3 -0
  251. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__08-1wwu._.js +1 -1
  252. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0c9mbcn._.js +1 -1
  253. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0gdfxj4._.js +1 -1
  254. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0kc-hwp._.js +1 -1
  255. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0lu73p6._.js +1 -1
  256. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0m1yf2b._.js +4 -0
  257. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0wv-3zo._.js +3 -0
  258. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__10bfmwi._.js +1 -1
  259. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__18qvdzb._.js +2 -2
  260. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1l2urlw._.js +1 -1
  261. package/runtime/hub/apps/hub/.next/server/chunks/ssr/{_0ro6vh6._.js → _0r2xlss._.js} +3 -3
  262. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +1 -1
  263. package/runtime/hub/apps/hub/.next/server/chunks/ssr/packages_relay_dist_control-plane_0ve-wz4.js +2 -25
  264. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  265. package/runtime/hub/apps/hub/.next/server/middleware.js +1 -1
  266. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  267. package/runtime/hub/apps/hub/.next/static/chunks/{2xc1sm79a6tsb.js → 2gsrna76i1d80.js} +1 -1
  268. package/runtime/hub/apps/hub/attach-helper.cjs +191 -0
  269. package/runtime/hub/apps/hub/{auth-DC44GQZY.js → auth-IRNNO3IK.js} +2 -2
  270. package/runtime/hub/apps/hub/{auth-config-LALRDYDO.js → auth-config-WJHIMGUE.js} +4 -2
  271. package/runtime/hub/apps/hub/{chunk-YJ5MJOXK.js → chunk-4LYVBRBC.js} +2094 -220
  272. package/runtime/hub/apps/hub/chunk-6AVSKCZJ.js +669 -0
  273. package/runtime/hub/apps/hub/{chunk-QSMPSV5Z.js → chunk-A5Y7LJMU.js} +57 -14
  274. package/runtime/hub/apps/hub/chunk-EDRFXO2M.js +35 -0
  275. package/runtime/hub/apps/hub/chunk-F2JI4GMX.js +2891 -0
  276. package/runtime/hub/apps/hub/{chunk-EHBJKZCL.js → chunk-O3K3ZGFF.js} +500 -35
  277. package/runtime/hub/apps/hub/chunk-RII6IKNJ.js +688 -0
  278. package/runtime/hub/apps/hub/{chunk-RXYOWSSN.js → chunk-RMEUA6PA.js} +120 -14
  279. package/runtime/hub/apps/hub/{chunk-3FJNKSNZ.js → chunk-SCHQR5KR.js} +3 -1
  280. package/runtime/hub/apps/hub/{dist-6FPPUSWZ.js → dist-2GEAA7QA.js} +15 -3
  281. package/runtime/hub/apps/hub/{dist-JG45OFT2.js → dist-36O6F6M3.js} +39 -24
  282. package/runtime/hub/apps/hub/{dist-3I7KUI6W.js → dist-IWLEL2TO.js} +21 -24
  283. package/runtime/hub/apps/hub/{dist-G6TXUSPZ.js → dist-NYKIT5W5.js} +10 -11
  284. package/runtime/hub/apps/hub/{dist-EQV4L7KP.js → dist-QB2IJ7OD.js} +7 -1
  285. package/runtime/hub/apps/hub/{dist-LYDHYTP2.js → dist-RBBXXGLI.js} +129 -26
  286. package/runtime/hub/apps/hub/{dist-GTVVXCBP.js → dist-RRJN2U5P.js} +10 -14
  287. package/runtime/hub/apps/hub/{dist-DX6IYMAH.js → dist-UWXGDCK4.js} +14 -11
  288. package/runtime/hub/apps/hub/{hub-token-COBZGSLS.js → hub-token-6USIMBPQ.js} +2 -2
  289. package/runtime/hub/apps/hub/hub-worker-SOFWVTWU.js +215 -0
  290. package/runtime/hub/apps/hub/node-postgres-DIU2H5VP.js +3583 -0
  291. package/runtime/hub/apps/hub/package.json +5 -2
  292. package/runtime/hub/apps/hub/{prepared-state-75DIZ55S-2IFNUHHM.js → prepared-state-75DIZ55S-P5FHEORG.js} +1 -1
  293. package/runtime/hub/apps/hub/server.js +247 -66
  294. package/runtime/hub/apps/hub/sqlite-proxy-VJS3HIOV.js +2881 -0
  295. package/runtime/relay/bin.cjs +694 -13
  296. package/runtime/vercel/ctl.cjs +29199 -16813
  297. package/dist/_cloud-attach-WDGM6FL5.js +0 -19
  298. package/dist/chunk-26IKZRTT.js.map +0 -1
  299. package/dist/chunk-HR7NHH5J.js.map +0 -1
  300. package/dist/chunk-IDH5A4RR.js.map +0 -1
  301. package/dist/chunk-JE6UI5YR.js.map +0 -1
  302. package/dist/chunk-JGZSA5ZI.js.map +0 -1
  303. package/dist/chunk-LL7NCMUU.js.map +0 -1
  304. package/dist/chunk-NEF6MDJO.js.map +0 -1
  305. package/dist/chunk-UJEH2NJT.js.map +0 -1
  306. package/dist/chunk-V5XXJH63.js.map +0 -1
  307. package/dist/dist-KQTMCVME.js.map +0 -1
  308. package/dist/dist-O3LKOIE7.js.map +0 -1
  309. package/dist/dist-TSFVB7AI.js.map +0 -1
  310. package/runtime/hub/apps/hub/.next/server/chunks/0zhp_better-auth_dist_adapters_kysely-adapter_index_mjs_1rl4qnh._.js +0 -3
  311. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04h15ml._.js +0 -3
  312. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04jgk9x._.js +0 -3
  313. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07ednlo._.js +0 -3
  314. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0a7djvw._.js +0 -3
  315. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ig1bot._.js +0 -3
  316. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +0 -3
  317. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ql4fjo._.js +0 -3
  318. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +0 -3
  319. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0t7o5ed._.js +0 -3
  320. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vs8fma._.js +0 -3
  321. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w9ud8u._.js +0 -3
  322. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0xh14bo._.js +0 -3
  323. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yhb0gc._.js +0 -3
  324. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-0flwc._.js +0 -3
  325. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13ioh5z._.js +0 -3
  326. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13jwk_k._.js +0 -3
  327. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16_uteg._.js +0 -3
  328. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16p2m-g._.js +0 -3
  329. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__19pc87s._.js +0 -3
  330. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_gu2yk._.js +0 -3
  331. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1a50b07._.js +0 -3
  332. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ai-945._.js +0 -3
  333. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bu2zio._.js +0 -3
  334. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ctczev._.js +0 -3
  335. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d6mtlk._.js +0 -3
  336. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dn_3i1._.js +0 -3
  337. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1e4z_-v._.js +0 -3
  338. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f2sueq._.js +0 -3
  339. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f9zctr._.js +0 -3
  340. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4xycg._.js +0 -3
  341. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +0 -3
  342. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1js2jdv._.js +0 -3
  343. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1md9kdw._.js +0 -3
  344. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mttufy._.js +0 -3
  345. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1nepkp-._.js +0 -6
  346. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1pp5oib._.js +0 -3
  347. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q5bqse._.js +0 -3
  348. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qwhzmi._.js +0 -3
  349. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thipug._.js +0 -3
  350. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9om6g._.js +0 -3
  351. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1xeczo7._.js +0 -3
  352. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20503l7._.js +0 -3
  353. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[externals]_pg_20c820g._.js +0 -3
  354. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0j0tjwn._.js +0 -3
  355. /package/dist/{_cloud-attach-WDGM6FL5.js.map → _cloud-attach-XZYF324R.js.map} +0 -0
  356. /package/dist/{dist-FTKS2GI4.js.map → admin-client-NOZ5CCAH.js.map} +0 -0
  357. /package/dist/{dist-OO52HARR.js.map → control-plane-2VEM2KCL.js.map} +0 -0
  358. /package/dist/{dist-U2SVLJUQ.js.map → custody-client-P6XIXHRG.js.map} +0 -0
  359. /package/dist/{dist-WVYAURMF.js.map → dist-JHMILJUT.js.map} +0 -0
  360. /package/dist/{dist-Z6L5MM5D.js.map → dist-JOFZOZCY.js.map} +0 -0
  361. /package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js.map → dist-Q5NY4CF6.js.map} +0 -0
  362. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_buildManifest.js +0 -0
  363. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_clientMiddlewareManifest.js +0 -0
  364. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_ssgManifest.js +0 -0
@@ -22,7 +22,14 @@ import {
22
22
  readBoxStatus,
23
23
  registerBoxWithRelay,
24
24
  syncClaudeCredentials
25
- } from "./chunk-YJ5MJOXK.js";
25
+ } from "./chunk-4LYVBRBC.js";
26
+ import {
27
+ hashProjectPath,
28
+ loadEffectiveConfig,
29
+ projectDirSegment,
30
+ require_dist,
31
+ sanitizeMnemonic
32
+ } from "./chunk-A5Y7LJMU.js";
26
33
  import {
27
34
  AGENT_SYNC_SPECS,
28
35
  BOX_DYNAMIC_SYNC_MANIFEST,
@@ -30,10 +37,12 @@ import {
30
37
  BOX_MEMORY_DIR,
31
38
  BOX_WORKFLOWS_DIR,
32
39
  DEFAULT_BOX_IMAGE,
40
+ DEFAULT_ENV_PATTERNS,
33
41
  SEED_MARKER,
34
42
  SYNC_DRYRUN_ENV,
35
43
  UserFacingError,
36
44
  allocateProjectIndex,
45
+ boxSshDirForProvider,
37
46
  buildHostSyncManifest,
38
47
  computeSyncDelta,
39
48
  describeInbound,
@@ -48,6 +57,7 @@ import {
48
57
  makeSyncContext,
49
58
  parseInboundSpec,
50
59
  planCarryEntry,
60
+ projectSlugFromOriginUrl,
51
61
  pushCredentialToBox,
52
62
  pushEnvFiles,
53
63
  readCliStamp,
@@ -59,6 +69,7 @@ import {
59
69
  renderCarryEntries,
60
70
  resolveSyncTopology,
61
71
  resyncWorkspace,
72
+ scanHostEnvFiles,
62
73
  shouldAcceptCredentialUpdate,
63
74
  stageAllAgentStatic,
64
75
  stageClaudeCredentialsForUpload,
@@ -71,17 +82,10 @@ import {
71
82
  stageOpencodeStateForUpload,
72
83
  stageOpencodeStaticForUpload,
73
84
  writeCredentialBackup
74
- } from "./chunk-RXYOWSSN.js";
85
+ } from "./chunk-RMEUA6PA.js";
75
86
  import {
76
87
  execa
77
88
  } from "./chunk-UDZ3VXRF.js";
78
- import {
79
- hashProjectPath,
80
- loadEffectiveConfig,
81
- projectDirSegment,
82
- require_dist,
83
- sanitizeMnemonic
84
- } from "./chunk-QSMPSV5Z.js";
85
89
  import {
86
90
  __toESM
87
91
  } from "./chunk-OG4KH2FZ.js";
@@ -116,9 +120,18 @@ import {
116
120
  resolve as hostResolve
117
121
  } from "path";
118
122
  import { posix } from "path";
119
- import { copyFile, mkdir as mkdir2, mkdtemp as mkdtemp6, rm as rm7, stat } from "fs/promises";
123
+ import { readdir as readdir2, readFile as readFile3 } from "fs/promises";
124
+ import { join as join7 } from "path";
125
+ import { createHash } from "crypto";
126
+ import { rm as rm7, writeFile as writeFile4 } from "fs/promises";
120
127
  import { tmpdir as tmpdir6 } from "os";
121
- import { dirname as dirname2, join as join7 } from "path";
128
+ import { join as join8 } from "path";
129
+ import { gzipSync } from "zlib";
130
+ import { connect } from "net";
131
+ import { copyFile, mkdir as mkdir2, mkdtemp as mkdtemp6, rm as rm8, stat } from "fs/promises";
132
+ import { tmpdir as tmpdir7 } from "os";
133
+ import { dirname as dirname2, join as join9 } from "path";
134
+ import { spawn } from "child_process";
122
135
  function quoteShellArgv(argv) {
123
136
  return argv.map(quoteShellArg).join(" ");
124
137
  }
@@ -1427,14 +1440,21 @@ async function registerBoxWithPlane(args) {
1427
1440
  name: args.name,
1428
1441
  kind: "cloud",
1429
1442
  backend: args.backend,
1443
+ sandboxId: args.sandboxId,
1430
1444
  originUrl: args.originUrl,
1445
+ worktrees: args.worktrees,
1431
1446
  bridgeToken: args.bridgeToken,
1432
1447
  previewUrl: args.previewUrl,
1433
1448
  previewToken: args.previewToken,
1434
1449
  createdAt: args.createdAt,
1435
1450
  projectIndex: args.projectIndex,
1436
1451
  autoApproveHostActions: args.autoApproveHostActions,
1437
- autoApproveSafeHostActions: args.autoApproveSafeHostActions
1452
+ autoApproveSafeHostActions: args.autoApproveSafeHostActions,
1453
+ publicHost: args.publicHost,
1454
+ image: args.image,
1455
+ webPort: args.webPort,
1456
+ agent: args.agent,
1457
+ projectSlug: args.projectSlug
1438
1458
  })
1439
1459
  });
1440
1460
  if (!res.ok) {
@@ -1442,6 +1462,256 @@ async function registerBoxWithPlane(args) {
1442
1462
  throw new Error(`plane register-box \u2192 ${String(res.status)}: ${text}`);
1443
1463
  }
1444
1464
  }
1465
+ async function pushBoxSshToCustody(args) {
1466
+ const log = args.log ?? (() => {
1467
+ });
1468
+ const sshDir = boxSshDirForProvider(args.provider, args.sandboxId);
1469
+ if (!sshDir) return 0;
1470
+ const entries = await readdir2(sshDir, { withFileTypes: true }).catch(() => []);
1471
+ const files = entries.filter((e) => e.isFile());
1472
+ if (files.length === 0) return 0;
1473
+ const fetchImpl = args.fetchImpl ?? fetch;
1474
+ const base = args.controlPlaneUrl.replace(/\/+$/, "");
1475
+ let pushed = 0;
1476
+ for (const f of files) {
1477
+ try {
1478
+ const data = await readFile3(join7(sshDir, f.name));
1479
+ const path = `boxes/${args.sandboxId}/ssh/${f.name}`;
1480
+ const res = await fetchImpl(`${base}/admin/custody/${path}`, {
1481
+ method: "PUT",
1482
+ headers: {
1483
+ "Content-Type": "application/json",
1484
+ Authorization: `Bearer ${args.adminToken}`
1485
+ },
1486
+ body: JSON.stringify({ data: data.toString("base64") })
1487
+ });
1488
+ if (res.ok) {
1489
+ pushed += 1;
1490
+ } else {
1491
+ log(`custody push ${f.name} \u2192 ${String(res.status)} (continuing)`);
1492
+ }
1493
+ } catch (err) {
1494
+ log(`custody push ${f.name} failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
1495
+ }
1496
+ }
1497
+ return pushed;
1498
+ }
1499
+ var DEFAULT_REACHABLE_PROBE_MS = 1500;
1500
+ async function hostReachable(url, ms = DEFAULT_REACHABLE_PROBE_MS) {
1501
+ let parsed;
1502
+ try {
1503
+ parsed = new URL(url);
1504
+ } catch {
1505
+ return false;
1506
+ }
1507
+ const port = parsed.port ? Number(parsed.port) : parsed.protocol === "http:" ? 80 : 443;
1508
+ return new Promise((resolve2) => {
1509
+ const socket = connect({ host: parsed.hostname, port });
1510
+ const done = (ok) => {
1511
+ socket.destroy();
1512
+ resolve2(ok);
1513
+ };
1514
+ socket.setTimeout(ms, () => done(false));
1515
+ socket.once("connect", () => done(true));
1516
+ socket.once("error", () => done(false));
1517
+ });
1518
+ }
1519
+ function deadlineFetch(signal, impl = fetch) {
1520
+ return ((url, init) => impl(url, { ...init, signal }));
1521
+ }
1522
+ var SEED_PUSH_MS = 12e4;
1523
+ var DEFAULT_MAX_BODY_BYTES = 32 * 1024 * 1024;
1524
+ function maxBlobBytes(maxBodyBytes) {
1525
+ return Math.floor(maxBodyBytes * 0.7);
1526
+ }
1527
+ function sha256Hex(data) {
1528
+ return createHash("sha256").update(data).digest("hex");
1529
+ }
1530
+ async function buildProjectSeed(args) {
1531
+ const log = args.log ?? (() => {
1532
+ });
1533
+ const maxTarBytes = maxBlobBytes(args.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES);
1534
+ const items = [];
1535
+ let skippedTarBytes;
1536
+ const tar = await buildUntrackedTar(args.projectRoot);
1537
+ if (tar) {
1538
+ if (tar.length > maxTarBytes) {
1539
+ skippedTarBytes = tar.length;
1540
+ log(
1541
+ `seed: untracked tar is ${formatBytes(tar.length)} (> ${formatBytes(maxTarBytes)}) \u2014 skipping it; env files still pushed. Raise \`relay.custodyMaxBodyBytes\` to include it.`
1542
+ );
1543
+ } else {
1544
+ items.push({ relPath: "untracked.tar.gz", data: tar });
1545
+ }
1546
+ }
1547
+ const envRelPaths = args.envPatterns?.length ? await scanHostEnvFiles(args.projectRoot, args.envPatterns) : [];
1548
+ const envTar = await buildTarOf(args.projectRoot, envRelPaths);
1549
+ if (envTar) items.push({ relPath: "env.tar.gz", data: envTar });
1550
+ const manifest = {
1551
+ ...await readSeedRepoMeta(args.projectRoot),
1552
+ files: items.map((i) => ({ path: i.relPath, sha256: sha256Hex(i.data), bytes: i.data.length }))
1553
+ };
1554
+ return { items, manifest, skippedTarBytes, envFiles: envRelPaths };
1555
+ }
1556
+ async function readSeedRepoMeta(projectRoot) {
1557
+ return {
1558
+ version: 1,
1559
+ originUrl: await gitOut(projectRoot, ["remote", "get-url", "origin"]) ?? void 0,
1560
+ baseBranch: await gitOut(projectRoot, ["branch", "--show-current"]) ?? void 0,
1561
+ repoHeadSha: await gitOut(projectRoot, ["rev-parse", "HEAD"]) ?? void 0,
1562
+ files: [],
1563
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
1564
+ };
1565
+ }
1566
+ async function gitOut(dir, argv) {
1567
+ const r = await execa("git", ["-C", dir, ...argv], { reject: false });
1568
+ const out = (r.stdout ?? "").trim();
1569
+ return r.exitCode === 0 && out.length > 0 ? out : null;
1570
+ }
1571
+ async function buildUntrackedTar(repo) {
1572
+ const list = await execa("git", ["-C", repo, "ls-files", "--others", "--exclude-standard", "-z"], {
1573
+ reject: false
1574
+ });
1575
+ if (list.exitCode !== 0 || list.stdout.length === 0) return null;
1576
+ return tarNulList(repo, list.stdout);
1577
+ }
1578
+ async function buildTarOf(repo, relPaths) {
1579
+ if (relPaths.length === 0) return null;
1580
+ return tarNulList(repo, relPaths.join("\0") + "\0");
1581
+ }
1582
+ async function tarNulList(dir, nulList) {
1583
+ const tar = await execa("tar", ["-C", dir, "--null", "-T", "-", "-cf", "-"], {
1584
+ input: nulList,
1585
+ env: { ...process.env, COPYFILE_DISABLE: "1" },
1586
+ encoding: "buffer",
1587
+ reject: false,
1588
+ // Normally small (ignored dirs are excluded), but don't let a pathological
1589
+ // tree blow up the host process.
1590
+ maxBuffer: 256 * 1024 * 1024
1591
+ });
1592
+ if (tar.exitCode !== 0) return null;
1593
+ const raw = tar.stdout;
1594
+ if (!raw || raw.length === 0) return null;
1595
+ return gzipSync(raw);
1596
+ }
1597
+ async function pushProjectSeedToCustody(args) {
1598
+ const log = args.log ?? (() => {
1599
+ });
1600
+ const fetchImpl = args.fetchImpl ?? (await hostReachable(args.controlPlaneUrl) ? deadlineFetch(AbortSignal.timeout(SEED_PUSH_MS)) : null);
1601
+ if (!fetchImpl) {
1602
+ log("seed: control box unreachable \u2014 skipping the seed push");
1603
+ const manifest2 = await readSeedRepoMeta(args.projectRoot);
1604
+ return { uploaded: 0, skipped: 0, manifest: manifest2, envFiles: [], dropped: [], unreachable: true };
1605
+ }
1606
+ const built = await buildProjectSeed(args);
1607
+ const prefix = `projects/${args.slug}/seed`;
1608
+ const base = args.controlPlaneUrl.replace(/\/+$/, "");
1609
+ const headers = {
1610
+ "Content-Type": "application/json",
1611
+ Authorization: `Bearer ${args.adminToken}`
1612
+ };
1613
+ const existing = /* @__PURE__ */ new Map();
1614
+ if (!args.force) {
1615
+ try {
1616
+ const res = await fetchImpl(`${base}/admin/custody?prefix=${encodeURIComponent(prefix)}`, {
1617
+ headers
1618
+ });
1619
+ if (res.ok) {
1620
+ const body = await res.json();
1621
+ for (const e of body.entries) existing.set(e.path, e.sha256);
1622
+ }
1623
+ } catch {
1624
+ }
1625
+ }
1626
+ let uploaded = 0;
1627
+ let skipped = 0;
1628
+ const put = async (relPath, data) => {
1629
+ const path = `${prefix}/${relPath}`;
1630
+ if (!args.force && existing.get(path) === sha256Hex(data)) {
1631
+ skipped += 1;
1632
+ return;
1633
+ }
1634
+ const res = await fetchImpl(`${base}/admin/custody/${encodeCustodyPath(path)}`, {
1635
+ method: "PUT",
1636
+ headers,
1637
+ body: JSON.stringify({ data: data.toString("base64") })
1638
+ });
1639
+ if (!res.ok) {
1640
+ throw new Error(`custody put ${path} \u2192 ${String(res.status)}`);
1641
+ }
1642
+ uploaded += 1;
1643
+ };
1644
+ const dropped = [];
1645
+ for (const item of built.items) {
1646
+ try {
1647
+ await put(item.relPath, item.data);
1648
+ } catch (err) {
1649
+ dropped.push(item.relPath);
1650
+ log(
1651
+ `seed: the control box refused ${item.relPath} (${formatBytes(item.data.length)}): ${err instanceof Error ? err.message : String(err)} \u2014 continuing without it. If it is a size limit, raise AGENTBOX_CUSTODY_MAX_BODY_BYTES on the control box.`
1652
+ );
1653
+ }
1654
+ }
1655
+ const manifest = {
1656
+ ...built.manifest,
1657
+ files: built.manifest.files.filter((f) => !dropped.includes(f.path))
1658
+ };
1659
+ await put("manifest.json", Buffer.from(JSON.stringify(manifest, null, 2), "utf8"));
1660
+ log(`seed: ${String(uploaded)} uploaded, ${String(skipped)} unchanged \u2192 custody ${prefix}`);
1661
+ return {
1662
+ uploaded,
1663
+ skipped,
1664
+ manifest,
1665
+ skippedTarBytes: built.skippedTarBytes,
1666
+ envFiles: built.envFiles,
1667
+ dropped
1668
+ };
1669
+ }
1670
+ var keepExistingFlagCache = null;
1671
+ async function keepExistingFlag() {
1672
+ if (keepExistingFlagCache) return keepExistingFlagCache;
1673
+ const v = await execa("tar", ["--version"], { reject: false });
1674
+ const isGnu = /GNU tar/i.test(`${v.stdout ?? ""}${v.stderr ?? ""}`);
1675
+ keepExistingFlagCache = isGnu ? "--skip-old-files" : "-k";
1676
+ return keepExistingFlagCache;
1677
+ }
1678
+ async function applyProjectSeed(args) {
1679
+ const log = args.log ?? (() => {
1680
+ });
1681
+ const manifestBlob = await args.source.get("manifest.json").catch(() => null);
1682
+ if (!manifestBlob) return null;
1683
+ let manifest = {};
1684
+ try {
1685
+ manifest = JSON.parse(manifestBlob.toString("utf8"));
1686
+ } catch {
1687
+ }
1688
+ const skipFlag = await keepExistingFlag();
1689
+ let files = 0;
1690
+ for (const name of ["untracked.tar.gz", "env.tar.gz"]) {
1691
+ const blob = await args.source.get(name).catch(() => null);
1692
+ if (!blob) continue;
1693
+ const tmp = join8(tmpdir6(), `agentbox-seed-${process.pid}-${Date.now().toString(36)}-${name}`);
1694
+ try {
1695
+ await writeFile4(tmp, blob);
1696
+ await execa("tar", ["-C", args.dest, "-xzf", tmp, skipFlag]);
1697
+ files += 1;
1698
+ } catch (err) {
1699
+ log(`seed: ${name} could not be applied: ${err instanceof Error ? err.message : String(err)}`);
1700
+ } finally {
1701
+ await rm7(tmp, { force: true }).catch(() => {
1702
+ });
1703
+ }
1704
+ }
1705
+ return { files, capturedAt: manifest.createdAt, repoHeadSha: manifest.repoHeadSha };
1706
+ }
1707
+ function encodeCustodyPath(path) {
1708
+ return path.split("/").map((s) => encodeURIComponent(s)).join("/");
1709
+ }
1710
+ function formatBytes(n) {
1711
+ if (n < 1024) return `${String(n)}B`;
1712
+ if (n < 1024 * 1024) return `${(n / 1024).toFixed(0)}KB`;
1713
+ return `${(n / (1024 * 1024)).toFixed(1)}MB`;
1714
+ }
1445
1715
  var WORKSPACE_DIR_DEFAULT = "/workspace";
1446
1716
  async function seedCloudWorkspace(args) {
1447
1717
  const workspaceDir = args.workspaceDir ?? WORKSPACE_DIR_DEFAULT;
@@ -1560,10 +1830,10 @@ async function seedFromGitClone(args) {
1560
1830
  const log = args.onLog ?? (() => {
1561
1831
  });
1562
1832
  let conflicts = { mergeConflicts: [], overlaySkipped: [] };
1563
- const stage = await mkdtemp6(join7(tmpdir6(), "agentbox-clone-"));
1564
- const cloneDir = join7(stage, "clone");
1565
- const tarPath = join7(stage, "workspace.tar.gz");
1566
- const untrackedTarPath = join7(stage, "untracked.tar.gz");
1833
+ const stage = await mkdtemp6(join9(tmpdir7(), "agentbox-clone-"));
1834
+ const cloneDir = join9(stage, "clone");
1835
+ const tarPath = join9(stage, "workspace.tar.gz");
1836
+ const untrackedTarPath = join9(stage, "untracked.tar.gz");
1567
1837
  const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
1568
1838
  const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
1569
1839
  let stashRefCreated = false;
@@ -1594,8 +1864,8 @@ async function seedFromGitClone(args) {
1594
1864
  log(
1595
1865
  `clone tar exceeded ${String(LARGE_BUNDLE_THRESHOLD_BYTES / (1024 * 1024))} MB at depth ${String(DEFAULT_BUNDLE_DEPTH)} (${mb} MB), rebuilding at depth ${String(LARGE_BUNDLE_DEPTH)}`
1596
1866
  );
1597
- await rm7(cloneDir, { recursive: true, force: true });
1598
- await rm7(tarPath, { force: true });
1867
+ await rm8(cloneDir, { recursive: true, force: true });
1868
+ await rm8(tarPath, { force: true });
1599
1869
  await runShallowClone(args.hostRepo, cloneDir, LARGE_BUNDLE_DEPTH, stashRefCreated, cloneBranch);
1600
1870
  await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
1601
1871
  await tarCloneDir(cloneDir, tarPath);
@@ -1667,7 +1937,7 @@ async function seedFromGitClone(args) {
1667
1937
  reject: false
1668
1938
  });
1669
1939
  }
1670
- await rm7(stage, { recursive: true, force: true });
1940
+ await rm8(stage, { recursive: true, force: true });
1671
1941
  }
1672
1942
  return conflicts;
1673
1943
  }
@@ -1703,10 +1973,10 @@ async function tryReseedRepoDelta(args) {
1703
1973
  { reject: false }
1704
1974
  );
1705
1975
  if (ancestor.exitCode !== 0) return null;
1706
- const stage = await mkdtemp6(join7(tmpdir6(), "agentbox-delta-"));
1707
- const bundlePath = join7(stage, "delta.bundle");
1708
- const untrackedTarPath = join7(stage, "untracked.tar.gz");
1709
- const deltaLfsTarPath = join7(stage, "delta-lfs.tar.gz");
1976
+ const stage = await mkdtemp6(join9(tmpdir7(), "agentbox-delta-"));
1977
+ const bundlePath = join9(stage, "delta.bundle");
1978
+ const untrackedTarPath = join9(stage, "untracked.tar.gz");
1979
+ const deltaLfsTarPath = join9(stage, "delta-lfs.tar.gz");
1710
1980
  const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
1711
1981
  const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
1712
1982
  let stashRefCreated = false;
@@ -1801,7 +2071,7 @@ async function tryReseedRepoDelta(args) {
1801
2071
  await execa("git", ["-C", args.hostRepo, "update-ref", "-d", DELTA_TARGET_REF], {
1802
2072
  reject: false
1803
2073
  });
1804
- await rm7(stage, { recursive: true, force: true });
2074
+ await rm8(stage, { recursive: true, force: true });
1805
2075
  }
1806
2076
  }
1807
2077
  async function runShallowClone(hostRepo, cloneDir, depth, includeStashRef, fromBranch) {
@@ -1827,7 +2097,7 @@ async function tarCloneDir(cloneDir, outPath) {
1827
2097
  }
1828
2098
  var LFS_OID_RE = /^[0-9a-f]{64}$/;
1829
2099
  function lfsObjectRelPath(oid) {
1830
- return join7("lfs", "objects", oid.slice(0, 2), oid.slice(2, 4), oid);
2100
+ return join9("lfs", "objects", oid.slice(0, 2), oid.slice(2, 4), oid);
1831
2101
  }
1832
2102
  async function lfsOidsForRef(hostRepo, ref) {
1833
2103
  const listed = await execa("git", ["-C", hostRepo, "lfs", "ls-files", "--long", ref], {
@@ -1853,10 +2123,10 @@ async function seedCloneLfsObjects(hostRepo, cloneDir, ref, log) {
1853
2123
  let copied = 0;
1854
2124
  for (const oid of oids) {
1855
2125
  const rel = lfsObjectRelPath(oid);
1856
- const dst = join7(cloneDir, ".git", rel);
2126
+ const dst = join9(cloneDir, ".git", rel);
1857
2127
  try {
1858
2128
  await mkdir2(dirname2(dst), { recursive: true });
1859
- await copyFile(join7(hostRepo, ".git", rel), dst);
2129
+ await copyFile(join9(hostRepo, ".git", rel), dst);
1860
2130
  copied++;
1861
2131
  } catch {
1862
2132
  }
@@ -1870,12 +2140,12 @@ async function maybeBuildDeltaLfsTar(hostRepo, target, checkpointTip, outPath) {
1870
2140
  const deltaOids = targetOids.filter((o) => !have.has(o));
1871
2141
  if (deltaOids.length === 0) return 0;
1872
2142
  await execa("git", ["-C", hostRepo, "lfs", "fetch", "origin", target], { reject: false });
1873
- const gitDir = join7(hostRepo, ".git");
2143
+ const gitDir = join9(hostRepo, ".git");
1874
2144
  const relPaths = [];
1875
2145
  for (const oid of deltaOids) {
1876
2146
  const rel = lfsObjectRelPath(oid);
1877
2147
  try {
1878
- await stat(join7(gitDir, rel));
2148
+ await stat(join9(gitDir, rel));
1879
2149
  relPaths.push(rel);
1880
2150
  } catch {
1881
2151
  }
@@ -1937,8 +2207,8 @@ function wipeDirSteps(dir) {
1937
2207
  return [`$SUDO mkdir -p ${q}`, `$SUDO find ${q} -mindepth 1 -maxdepth 1 -exec rm -rf {} +`];
1938
2208
  }
1939
2209
  async function seedFromTar(args) {
1940
- const stage = await mkdtemp6(join7(tmpdir6(), "agentbox-tar-"));
1941
- const tarPath = join7(stage, "workspace.tar.gz");
2210
+ const stage = await mkdtemp6(join9(tmpdir7(), "agentbox-tar-"));
2211
+ const tarPath = join9(stage, "workspace.tar.gz");
1942
2212
  try {
1943
2213
  await execa("tar", ["-C", args.hostDir, "-czf", tarPath, "."]);
1944
2214
  const remoteTar = "/tmp/agentbox-workspace.tar.gz";
@@ -1963,9 +2233,16 @@ async function seedFromTar(args) {
1963
2233
  throw new Error(`workspace seed (tar) failed: ${r.stderr || r.stdout}`);
1964
2234
  }
1965
2235
  } finally {
1966
- await rm7(stage, { recursive: true, force: true });
2236
+ await rm8(stage, { recursive: true, force: true });
1967
2237
  }
1968
2238
  }
2239
+ function seedEnvPatterns(req) {
2240
+ const patterns = [
2241
+ ...req.envFilesToImport ?? [],
2242
+ ...req.withEnv ? DEFAULT_ENV_PATTERNS : []
2243
+ ];
2244
+ return patterns.length > 0 ? patterns : void 0;
2245
+ }
1969
2246
  var CLOUD_WORKSPACE_DIR = "/workspace";
1970
2247
  var CLOUD_WEB_PROXY_PORT = 80;
1971
2248
  var CLOUD_VNC_PORT = 6080;
@@ -2164,6 +2441,9 @@ function createCloudProvider(backend, opts = {}) {
2164
2441
  previewUrls: Object.keys(mergedPreviews).length > 0 ? mergedPreviews : void 0,
2165
2442
  relayPreviewUrl: relayPreview?.url ?? box.cloud?.relayPreviewUrl,
2166
2443
  relayPreviewToken: relayPreview?.token ?? box.cloud?.relayPreviewToken,
2444
+ // A VPS IP can change across stop/start — take the live handle's value
2445
+ // when the backend reports one, so the record + the plane stay accurate.
2446
+ publicHost: h.publicHost ?? box.cloud?.publicHost,
2167
2447
  // reEnsureCloudBox only runs on a freshly-woken box (start/resume), so
2168
2448
  // the box is now running — persist it for the fast `agentbox list` path.
2169
2449
  lastState: "running"
@@ -2198,13 +2478,30 @@ function createCloudProvider(backend, opts = {}) {
2198
2478
  name: box.name,
2199
2479
  originUrl,
2200
2480
  backend: backend.name,
2481
+ sandboxId: box.cloud.sandboxId,
2482
+ worktrees: [
2483
+ {
2484
+ containerPath: "/workspace",
2485
+ hostMainRepo: box.workspacePath,
2486
+ branch: box.cloud.workspaceBranch ?? `agentbox/${box.name}`,
2487
+ sanctionedBranch: box.cloud.workspaceBranch ?? `agentbox/${box.name}`
2488
+ }
2489
+ ],
2201
2490
  bridgeToken: box.cloud.bridgeToken,
2202
2491
  previewUrl: relayPreview?.url,
2203
2492
  previewToken: relayPreview?.token,
2204
2493
  createdAt: box.createdAt,
2205
2494
  projectIndex: box.projectIndex,
2206
2495
  autoApproveHostActions: box.autoApproveHostActions,
2207
- autoApproveSafeHostActions: box.autoApproveSafeHostActions
2496
+ autoApproveSafeHostActions: box.autoApproveSafeHostActions,
2497
+ // Keep the adoption material fresh across resumes. The VM's public
2498
+ // IP can change on a stop/start, so prefer the live handle's value
2499
+ // over the persisted one.
2500
+ publicHost: h.publicHost ?? box.cloud.publicHost,
2501
+ image: box.cloud.image,
2502
+ webPort: box.cloud.webPort,
2503
+ agent: box.lastAgent,
2504
+ projectSlug: projectSlugFromOriginUrl(originUrl) ?? void 0
2208
2505
  });
2209
2506
  } catch {
2210
2507
  }
@@ -2257,6 +2554,8 @@ function createCloudProvider(backend, opts = {}) {
2257
2554
  const location = typeof locationOpt === "string" && locationOpt.trim() !== "" ? locationOpt.trim() : void 0;
2258
2555
  const inboundOpt = req.providerOptions?.["inbound"];
2259
2556
  const inbound = typeof inboundOpt === "string" && inboundOpt.trim() !== "" ? inboundOpt.trim() : void 0;
2557
+ const extraCidrsOpt = req.providerOptions?.["extraInboundCidrs"];
2558
+ const extraInboundCidrs = req.controlPlaneUrl && Array.isArray(extraCidrsOpt) ? extraCidrsOpt.filter((c) => typeof c === "string" && c.trim() !== "") : void 0;
2260
2559
  const projectOpt = req.providerOptions?.["project"];
2261
2560
  const project = typeof projectOpt === "string" && projectOpt.trim() !== "" ? projectOpt.trim() : void 0;
2262
2561
  const hostOpt = req.providerOptions?.["remoteHost"];
@@ -2326,6 +2625,7 @@ function createCloudProvider(backend, opts = {}) {
2326
2625
  project,
2327
2626
  host,
2328
2627
  inbound,
2628
+ ...extraInboundCidrs && extraInboundCidrs.length > 0 ? { extraInboundCidrs } : {},
2329
2629
  sandboxClass,
2330
2630
  timeoutMs,
2331
2631
  exposePorts: exposeServicePorts,
@@ -2509,7 +2809,8 @@ function createCloudProvider(backend, opts = {}) {
2509
2809
  }
2510
2810
  const state = await readState();
2511
2811
  const projectIndex = req.projectRoot ? allocateProjectIndex(state, req.projectRoot) : void 0;
2512
- const effectiveBoxForApprove = (await loadEffectiveConfig(req.projectRoot ?? req.workspacePath)).effective.box;
2812
+ const effectiveForCreate = (await loadEffectiveConfig(req.projectRoot ?? req.workspacePath)).effective;
2813
+ const effectiveBoxForApprove = effectiveForCreate.box;
2513
2814
  const autoApproveHostActions = effectiveBoxForApprove.autoApproveHostActions;
2514
2815
  const autoApproveSafeHostActions = effectiveBoxForApprove.autoApproveSafeHostActions;
2515
2816
  if (req.controlPlaneUrl) {
@@ -2533,14 +2834,73 @@ function createCloudProvider(backend, opts = {}) {
2533
2834
  name,
2534
2835
  originUrl,
2535
2836
  backend: backend.name,
2837
+ sandboxId: handle.sandboxId,
2838
+ // hostMainRepo is the create-time seed checkout; on a hub
2839
+ // worker it is a temp clone that gets deleted after create, so
2840
+ // host-side git RPCs won't work against it — but the lease
2841
+ // gate's sanctioned-branch auto-allow reads `branch` from this
2842
+ // registration, which is what a control-plane box pushes with.
2843
+ worktrees: [
2844
+ {
2845
+ containerPath: "/workspace",
2846
+ hostMainRepo: req.workspacePath,
2847
+ branch,
2848
+ sanctionedBranch: branch
2849
+ }
2850
+ ],
2536
2851
  bridgeToken,
2537
2852
  previewUrl: relayPreview?.url,
2538
2853
  previewToken: relayPreview?.token,
2539
2854
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2540
2855
  projectIndex,
2541
2856
  autoApproveHostActions,
2542
- autoApproveSafeHostActions
2857
+ autoApproveSafeHostActions,
2858
+ // Adoption material: everything a PC needs to rebuild this
2859
+ // box's BoxRecord from the registration alone (`hub adopt`).
2860
+ publicHost: handle.publicHost,
2861
+ image,
2862
+ webPort: wp,
2863
+ agent: req.agent,
2864
+ projectSlug: projectSlugFromOriginUrl(originUrl) ?? void 0
2543
2865
  });
2866
+ await pushBoxSshToCustody({
2867
+ controlPlaneUrl: req.controlPlaneUrl,
2868
+ adminToken,
2869
+ provider: backend.name,
2870
+ sandboxId: handle.sandboxId,
2871
+ log
2872
+ }).catch(() => 0);
2873
+ if (!req.inBoxClone) {
2874
+ const slug = projectSlugFromOriginUrl(originUrl);
2875
+ if (slug) {
2876
+ const seed = await pushProjectSeedToCustody({
2877
+ controlPlaneUrl: req.controlPlaneUrl,
2878
+ adminToken,
2879
+ slug,
2880
+ projectRoot: req.workspacePath,
2881
+ // Capture exactly the env set THIS box received — the
2882
+ // wizard's picks plus `--with-env`'s defaults — so a
2883
+ // hub-created box gets what a PC-created one got. Not
2884
+ // DEFAULT_ENV_PATTERNS unconditionally: that would ship
2885
+ // secrets the user deliberately declined to import.
2886
+ envPatterns: seedEnvPatterns(req),
2887
+ // Honour the configured cap, so raising it actually admits a
2888
+ // bigger seed instead of silently dropping the tar.
2889
+ maxBodyBytes: effectiveForCreate.relay.custodyMaxBodyBytes,
2890
+ log
2891
+ }).catch((err) => {
2892
+ log(
2893
+ `seed push to custody failed (continuing): ${err instanceof Error ? err.message : String(err)}`
2894
+ );
2895
+ return null;
2896
+ });
2897
+ if (seed?.unreachable) {
2898
+ log(
2899
+ "WARN: control box unreachable \u2014 this project's seed material (untracked files + env) was NOT stored. Boxes created from the hub will miss them until you run `agentbox hub project push`."
2900
+ );
2901
+ }
2902
+ }
2903
+ }
2544
2904
  } catch (err) {
2545
2905
  log(
2546
2906
  `register with control plane failed (continuing): ${err instanceof Error ? err.message : String(err)}`
@@ -2622,6 +2982,9 @@ function createCloudProvider(backend, opts = {}) {
2622
2982
  // Real resources the backend reported (Hetzner: the plan's actual
2623
2983
  // cores/memory/disk). Absent → readers fall back to defaultResources.
2624
2984
  resources: handle.resources,
2985
+ // Public VM IP (direct-SSH backends), so the resume re-registration
2986
+ // and a PC's `hub adopt` can rebuild the SSH target without an API call.
2987
+ publicHost: handle.publicHost,
2625
2988
  // Inbound-access policy the backend applied to the per-box firewall
2626
2989
  // (VPS providers). Persisted so drift re-syncs preserve the whitelist.
2627
2990
  inbound: handle.inbound,
@@ -3048,6 +3411,106 @@ function defaultCommand(kind, opts) {
3048
3411
  function shellSingle(s) {
3049
3412
  return "'" + s.replace(/'/g, "'\\''") + "'";
3050
3413
  }
3414
+ function agentStartBanner(binary) {
3415
+ return `printf " agentbox: starting ${binary} (first paint may take a few seconds)...\\r\\n"; `;
3416
+ }
3417
+ function buildCloudAttachInnerCommand(binary, extraArgs) {
3418
+ if (!extraArgs || extraArgs.length === 0) {
3419
+ return `bash -lc '${agentStartBanner(binary)}exec ${binary}'`;
3420
+ }
3421
+ const blob = Buffer.from(
3422
+ extraArgs.map((a) => Buffer.from(a, "utf8").toString("base64")).join("\n"),
3423
+ "utf8"
3424
+ ).toString("base64");
3425
+ return `bash -lc '${agentStartBanner(binary)}A=(); while IFS= read -r t; do A+=("$(printf %s "$t" | base64 -d)"); done <<< "$(echo ${blob} | base64 -d)"; exec ${binary} "\${A[@]}"'`;
3426
+ }
3427
+ async function startDetachedSession(provider, box, sessionName, command) {
3428
+ if (!provider.buildAttach) {
3429
+ throw new Error(`provider '${provider.name}' does not support detached sessions`);
3430
+ }
3431
+ const spec = await provider.buildAttach(box, "agent", {
3432
+ sessionName,
3433
+ command,
3434
+ detached: true
3435
+ });
3436
+ try {
3437
+ return await runDetached(spec.argv, spec.env);
3438
+ } finally {
3439
+ if (spec.cleanup) await spec.cleanup();
3440
+ }
3441
+ }
3442
+ var AGENT_AUTH_FAILURE = /Please run \/login|Invalid authentication credentials|API Error: 401|Invalid API key|\bUnauthorized\b/i;
3443
+ function sleep(ms) {
3444
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
3445
+ }
3446
+ async function verifyDetachedSession(provider, box, sessionName, binary, opts = {}) {
3447
+ const windowMs = opts.windowMs ?? 1e4;
3448
+ const pollMs = opts.pollMs ?? 2e3;
3449
+ const q = `'${sessionName.replace(/'/g, `'\\''`)}'`;
3450
+ const probe = `tmux has-session -t ${q} 2>/dev/null || exit 7; tmux capture-pane -p -t ${q} 2>/dev/null`;
3451
+ const deadline = Date.now() + windowMs;
3452
+ for (; ; ) {
3453
+ let pane = "";
3454
+ try {
3455
+ const r = await provider.exec(box, ["bash", "-lc", probe], { user: "vscode" });
3456
+ if (r.exitCode === 7) {
3457
+ throw new Error(
3458
+ `agent '${binary}' exited immediately after launch in box ${box.name} \u2014 the session did not stay up. Attach to inspect: agentbox ${binary} attach ${box.name}`
3459
+ );
3460
+ }
3461
+ pane = r.stdout;
3462
+ } catch (err) {
3463
+ if (err instanceof Error && err.message.startsWith(`agent '${binary}'`)) throw err;
3464
+ }
3465
+ if (AGENT_AUTH_FAILURE.test(pane)) {
3466
+ throw new Error(
3467
+ `box ${binary} credentials were rejected \u2014 the agent launched but printed an auth error, so no work will run. Refresh them with \`agentbox ${binary} login\`, then re-run.`
3468
+ );
3469
+ }
3470
+ if (Date.now() >= deadline) break;
3471
+ await sleep(pollMs);
3472
+ }
3473
+ }
3474
+ function runDetached(argv, env) {
3475
+ return new Promise((resolve2) => {
3476
+ const child = spawn(argv[0], argv.slice(1), {
3477
+ stdio: ["ignore", "ignore", "pipe"],
3478
+ env: env ? { ...process.env, ...env } : process.env
3479
+ });
3480
+ let stderr = "";
3481
+ child.stderr?.on("data", (c) => {
3482
+ stderr += c.toString("utf8");
3483
+ });
3484
+ child.on("error", (err) => resolve2({ exitCode: 1, stderr: stderr + String(err.message ?? err) }));
3485
+ child.on("exit", (code) => resolve2({ exitCode: code ?? 0, stderr }));
3486
+ });
3487
+ }
3488
+ async function startDetachedCloudAgent(args) {
3489
+ const { provider, binary, sessionName } = args;
3490
+ let box = args.box;
3491
+ const state = await provider.probeState(box);
3492
+ if (state === "missing") {
3493
+ throw new Error(`cloud sandbox for ${box.name} is missing; was it destroyed?`);
3494
+ }
3495
+ if (state !== "running") {
3496
+ box = await provider.start(box);
3497
+ }
3498
+ let extraArgs = args.extraArgs;
3499
+ if ((!extraArgs || extraArgs.length === 0) && args.resolveResumeArgs) {
3500
+ const resume = await args.resolveResumeArgs(box);
3501
+ if (resume) extraArgs = resume;
3502
+ }
3503
+ const command = buildCloudAttachInnerCommand(binary, extraArgs);
3504
+ const { exitCode, stderr } = await startDetachedSession(provider, box, sessionName, command);
3505
+ if (exitCode !== 0) {
3506
+ const detail = stderr.trim().slice(0, 500);
3507
+ throw new Error(
3508
+ `failed to start the ${binary} session in box ${box.name} (exit ${String(exitCode)})` + (detail ? `: ${detail}` : "")
3509
+ );
3510
+ }
3511
+ await verifyDetachedSession(provider, box, sessionName, binary, args.verify);
3512
+ return box;
3513
+ }
3051
3514
  function remoteTarFor(kind) {
3052
3515
  return `/tmp/agentbox-seed-${kind}.tar.gz`;
3053
3516
  }
@@ -3136,11 +3599,13 @@ export {
3136
3599
  currentCloudBaseFingerprint,
3137
3600
  baseFreshnessFromFingerprints,
3138
3601
  removeCloudCheckpointDir,
3602
+ applyProjectSeed,
3139
3603
  CLOUD_WEB_PROXY_PORT,
3140
3604
  CLOUD_VNC_PORT,
3141
3605
  createCloudProvider,
3142
3606
  hostTermForCloud,
3143
3607
  renderInnerCommand,
3608
+ startDetachedCloudAgent,
3144
3609
  seedAgentStaticIntoCloudBox,
3145
3610
  openWebAppOnVncScreen
3146
3611
  };