@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
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ generateRelayToken
4
+ } from "./chunk-BLWAWGFX.js";
5
+ import {
6
+ registrationToBoxRecord
7
+ } from "./chunk-ZJL56TJD.js";
8
+ import {
9
+ allocateProjectIndex,
10
+ boxSshDirForProvider,
11
+ defaultBoxSshDir,
12
+ readState,
13
+ recordBox
14
+ } from "./chunk-PXYPQ5BO.js";
15
+
16
+ // src/control-plane/hub-adopt.ts
17
+ import { execa } from "execa";
18
+
19
+ // src/control-plane/hub-pull.ts
20
+ import { basename } from "path";
21
+ import { chmod, mkdir, writeFile } from "fs/promises";
22
+
23
+ // src/control-plane/match-ref.ts
24
+ function matchRegistration(regs, ref) {
25
+ const exact = regs.find((r) => r.boxId === ref || r.name === ref || r.sandboxId === ref);
26
+ if (exact) return exact;
27
+ const byPrefix = regs.filter(
28
+ (r) => r.boxId.startsWith(ref) || r.sandboxId?.startsWith(ref) === true
29
+ );
30
+ return byPrefix.length === 1 ? byPrefix[0] : void 0;
31
+ }
32
+
33
+ // src/control-plane/hub-pull.ts
34
+ async function pullBoxSshKeys(args) {
35
+ const boxes = await args.admin.listBoxes();
36
+ const reg = matchRegistration(boxes, args.box);
37
+ const key = reg?.sandboxId ?? reg?.boxId ?? args.box;
38
+ const files = await downloadBoxSshKeys({
39
+ custody: args.custody,
40
+ provider: reg?.backend,
41
+ key
42
+ });
43
+ return { key, dest: sshDestFor(reg?.backend, key), files, registered: reg !== void 0 };
44
+ }
45
+ function sshDestFor(provider, key) {
46
+ return (provider ? boxSshDirForProvider(provider, key) : null) ?? defaultBoxSshDir(key);
47
+ }
48
+ async function downloadBoxSshKeys(args) {
49
+ const dest = sshDestFor(args.provider, args.key);
50
+ const entries = await args.custody.list(`boxes/${args.key}/ssh`);
51
+ const files = [];
52
+ if (entries.length > 0) await mkdir(dest, { recursive: true, mode: 448 });
53
+ for (const e of entries) {
54
+ const data = await args.custody.get(e.path);
55
+ if (data === null) continue;
56
+ const name = basename(e.path);
57
+ const out = `${dest}/${name}`;
58
+ await writeFile(out, data, { mode: 384 });
59
+ await chmod(out, 384);
60
+ files.push(name);
61
+ }
62
+ return files;
63
+ }
64
+
65
+ // src/control-plane/hub-adopt.ts
66
+ var HubBoxNotFoundError = class extends Error {
67
+ constructor(ref) {
68
+ super(`no box matching '${ref}' is registered on the control box`);
69
+ this.name = "HubBoxNotFoundError";
70
+ }
71
+ };
72
+ function normalizeOriginUrl(url) {
73
+ return url.trim().replace(/^[a-z+]+:\/\//i, "").replace(/^[^@/]+@/, "").replace(/:(?=\D)/, "/").replace(/\.git\/?$/i, "").replace(/\/+$/, "").toLowerCase();
74
+ }
75
+ async function readOriginUrl(dir) {
76
+ const r = await execa("git", ["-C", dir, "remote", "get-url", "origin"], { reject: false });
77
+ const url = (r.stdout ?? "").trim();
78
+ return r.exitCode === 0 && url.length > 0 ? url : void 0;
79
+ }
80
+ async function readRepoRoot(dir) {
81
+ const r = await execa("git", ["-C", dir, "rev-parse", "--show-toplevel"], { reject: false });
82
+ const root = (r.stdout ?? "").trim();
83
+ return r.exitCode === 0 && root.length > 0 ? root : void 0;
84
+ }
85
+ async function matchLocalProject(originUrl, cwd, state) {
86
+ if (!originUrl) return void 0;
87
+ const want = normalizeOriginUrl(originUrl);
88
+ const cwdOrigin = await readOriginUrl(cwd).catch(() => void 0);
89
+ if (cwdOrigin && normalizeOriginUrl(cwdOrigin) === want) {
90
+ const root = await readRepoRoot(cwd).catch(() => void 0);
91
+ if (root) return root;
92
+ }
93
+ const seen = /* @__PURE__ */ new Set();
94
+ for (const b of state.boxes) {
95
+ const root = b.projectRoot;
96
+ if (!root || seen.has(root)) continue;
97
+ seen.add(root);
98
+ const origin = await readOriginUrl(root).catch(() => void 0);
99
+ if (origin && normalizeOriginUrl(origin) === want) return root;
100
+ }
101
+ return void 0;
102
+ }
103
+ async function adoptHubBox(args) {
104
+ const log = args.log ?? (() => {
105
+ });
106
+ const cwd = args.cwd ?? process.cwd();
107
+ const registrations = await args.admin.listBoxes();
108
+ const reg = matchRegistration(registrations, args.ref);
109
+ if (!reg) throw new HubBoxNotFoundError(args.ref);
110
+ const sandboxId = reg.sandboxId ?? reg.boxId;
111
+ const state = await readState();
112
+ const existing = state.boxes.find(
113
+ (b) => b.cloud?.sandboxId !== void 0 && b.cloud.sandboxId === sandboxId || b.id === reg.boxId
114
+ );
115
+ const projectRoot = existing?.projectRoot ?? await matchLocalProject(reg.originUrl, cwd, state);
116
+ const projectIndex = existing?.projectIndex ?? (projectRoot ? allocateProjectIndex(state, projectRoot) : void 0);
117
+ const record = registrationToBoxRecord(reg, {
118
+ controlPlaneUrl: args.controlPlaneUrl,
119
+ existing,
120
+ projectRoot,
121
+ projectIndex,
122
+ freshToken: generateRelayToken
123
+ });
124
+ const sshFiles = await downloadBoxSshKeys({
125
+ custody: args.custody,
126
+ provider: reg.backend,
127
+ key: sandboxId
128
+ }).catch(() => []);
129
+ if (sshFiles.length > 0) {
130
+ log(`pulled ${String(sshFiles.length)} SSH key file(s) for ${reg.name}`);
131
+ }
132
+ const sshKeysMissing = record.ssh?.identityFile !== void 0 && sshFiles.length === 0;
133
+ if (sshKeysMissing) {
134
+ log(
135
+ `WARN: no SSH key material in custody for ${reg.name} (boxes/${sandboxId}/ssh) \u2014 attach / cp will not work until it is there. Try \`agentbox hub pull ${reg.name}\`.`
136
+ );
137
+ }
138
+ await recordBox(record);
139
+ return { record, sshFiles, projectRoot, refreshed: existing !== void 0, sshKeysMissing };
140
+ }
141
+
142
+ export {
143
+ pullBoxSshKeys,
144
+ HubBoxNotFoundError,
145
+ normalizeOriginUrl,
146
+ adoptHubBox
147
+ };
148
+ //# sourceMappingURL=chunk-E2ITEZAQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/control-plane/hub-adopt.ts","../src/control-plane/hub-pull.ts","../src/control-plane/match-ref.ts"],"sourcesContent":["/**\n * `agentbox hub adopt <box>` — materialize a local `BoxRecord` for a box that\n * lives in the control box's registry (created from the web UI or `--via-hub`).\n *\n * With a control box configured the PC is a thin client: the control box is the\n * source of truth for cloud boxes, and the local `state.json` record is a\n * materialized cache. Adoption is what writes that cache — without it a\n * hub-created box can't be resolved by name at all, because every direct PC↔box\n * command (`attach`, `cp`, `download`, `url`, `screen`, `destroy`) goes\n * `resolveBoxOrExit` → `readState` → provider.\n *\n * Everything needed to rebuild the record rides on the registration (the\n * adoption material added by the plane-register enrichment): provider, sandbox\n * id, public VM IP, image, web port, agent, branch, origin URL. The per-box SSH\n * key material comes from custody (`boxes/<sandboxId>/ssh/`) via the existing\n * `pullBoxSshKeys`.\n *\n * Kept free of command-layer concerns (logging, exit codes, config reads) so it\n * is unit-testable with fake clients + a temp HOME, mirroring `hub-pull.ts`.\n */\nimport { execa } from 'execa';\nimport type { BoxRecord } from '@agentbox/core';\nimport { readState } from '@agentbox/sandbox-core';\nimport { generateRelayToken, recordBox } from '@agentbox/sandbox-docker';\nimport { allocateProjectIndex } from '@agentbox/sandbox-core';\nimport { registrationToBoxRecord } from '@agentbox/relay';\nimport type { CustodyClient } from './custody-client.js';\nimport type { ControlPlaneAdminClient } from './admin-client.js';\nimport { downloadBoxSshKeys } from './hub-pull.js';\nimport { matchRegistration } from './match-ref.js';\n\nexport interface HubAdoptArgs {\n admin: ControlPlaneAdminClient;\n custody: CustodyClient;\n /** Box id, name, or sandbox id as shown by `hub boxes list`. */\n ref: string;\n /** The control-plane base URL, persisted on the record's cloud fields. */\n controlPlaneUrl: string;\n /** cwd for origin-URL project matching. Defaults to `process.cwd()`. */\n cwd?: string;\n log?: (line: string) => void;\n}\n\nexport interface HubAdoptResult {\n record: BoxRecord;\n /** Basenames of SSH key files pulled from custody (empty for e2b/vercel). */\n sshFiles: string[];\n /** Local project the box's origin URL matched, when any. */\n projectRoot?: string;\n /** True when an existing local record was refreshed rather than created. */\n refreshed: boolean;\n /**\n * True when the box needs a per-box SSH key (the record has an `identityFile`)\n * but custody had none. The box is adopted and `url` works, but `attach`/`cp`\n * will fail until the key is there.\n */\n sshKeysMissing?: boolean;\n}\n\n/** Thrown when the ref matches no registration on the control box. */\nexport class HubBoxNotFoundError extends Error {\n constructor(ref: string) {\n super(`no box matching '${ref}' is registered on the control box`);\n this.name = 'HubBoxNotFoundError';\n }\n}\n\n/**\n * Normalize a git remote URL for comparison: drop the scheme, any user@, a\n * trailing `.git`, and case — so `git@github.com:o/r.git`,\n * `https://github.com/o/r`, and `ssh://git@github.com/o/r.git` all match.\n */\nexport function normalizeOriginUrl(url: string): string {\n return url\n .trim()\n .replace(/^[a-z+]+:\\/\\//i, '')\n .replace(/^[^@/]+@/, '')\n .replace(/:(?=\\D)/, '/')\n .replace(/\\.git\\/?$/i, '')\n .replace(/\\/+$/, '')\n .toLowerCase();\n}\n\n/** A repo's `origin` remote URL, or undefined when it isn't a repo / has none. */\nasync function readOriginUrl(dir: string): Promise<string | undefined> {\n const r = await execa('git', ['-C', dir, 'remote', 'get-url', 'origin'], { reject: false });\n const url = (r.stdout ?? '').trim();\n return r.exitCode === 0 && url.length > 0 ? url : undefined;\n}\n\n/** Absolute path of the repo root containing `dir`, or undefined. */\nasync function readRepoRoot(dir: string): Promise<string | undefined> {\n const r = await execa('git', ['-C', dir, 'rev-parse', '--show-toplevel'], { reject: false });\n const root = (r.stdout ?? '').trim();\n return r.exitCode === 0 && root.length > 0 ? root : undefined;\n}\n\n/**\n * Find the local checkout for a hub box's origin URL: the cwd's repo first,\n * then any other project already in state with the same origin. Returns the\n * project root, or undefined when this PC has no clone of the repo (the box is\n * still adoptable — it just shows under `ls -g` only).\n */\nasync function matchLocalProject(\n originUrl: string | undefined,\n cwd: string,\n state: { boxes: BoxRecord[] },\n): Promise<string | undefined> {\n if (!originUrl) return undefined;\n const want = normalizeOriginUrl(originUrl);\n const cwdOrigin = await readOriginUrl(cwd).catch(() => undefined);\n if (cwdOrigin && normalizeOriginUrl(cwdOrigin) === want) {\n const root = await readRepoRoot(cwd).catch(() => undefined);\n if (root) return root;\n }\n // Fall back to the project roots of boxes already in state: a repo we've\n // created a box from before is a clone we know the path of.\n const seen = new Set<string>();\n for (const b of state.boxes) {\n const root = b.projectRoot;\n if (!root || seen.has(root)) continue;\n seen.add(root);\n const origin = await readOriginUrl(root).catch(() => undefined);\n if (origin && normalizeOriginUrl(origin) === want) return root;\n }\n return undefined;\n}\n\n\n/**\n * Rebuild a local `BoxRecord` from a control-box registration, download the\n * box's SSH key material from custody, and persist it to `state.json`.\n *\n * Idempotent: re-adopting an already-local box refreshes the cached record from\n * the registration while preserving the fields only the PC knows (its id, so\n * status paths stay stable, and any project linkage already resolved).\n */\nexport async function adoptHubBox(args: HubAdoptArgs): Promise<HubAdoptResult> {\n const log = args.log ?? (() => {});\n const cwd = args.cwd ?? process.cwd();\n\n const registrations = await args.admin.listBoxes();\n const reg = matchRegistration(registrations, args.ref);\n if (!reg) throw new HubBoxNotFoundError(args.ref);\n\n const sandboxId = reg.sandboxId ?? reg.boxId;\n\n const state = await readState();\n // Re-adopt keeps the existing local identity: the relay writes status.json\n // under a path keyed by the box id + project index, so minting a new id on\n // every refresh would orphan the box's status.\n // Identity only — sandbox id or box id. A NAME match is not identity: names\n // are not unique across providers, so adopting a hub box called `foo` would\n // have overwritten an unrelated local (e.g. docker) box called `foo` with\n // cloud fields, corrupting the record for a different box entirely.\n const existing = state.boxes.find(\n (b) => (b.cloud?.sandboxId !== undefined && b.cloud.sandboxId === sandboxId) || b.id === reg.boxId,\n );\n\n const projectRoot =\n existing?.projectRoot ?? (await matchLocalProject(reg.originUrl, cwd, state));\n const projectIndex =\n existing?.projectIndex ??\n (projectRoot ? allocateProjectIndex(state, projectRoot) : undefined);\n\n // One source of truth for registration → record reconstruction, shared with\n // the control box's own `hydrateRegisteredBox` (@agentbox/relay). The PC-only\n // concerns — which local project the box maps to, its per-project index, and\n // the SSH-key download below — stay here.\n const record: BoxRecord = registrationToBoxRecord(reg, {\n controlPlaneUrl: args.controlPlaneUrl,\n existing,\n projectRoot,\n projectIndex,\n freshToken: generateRelayToken,\n });\n\n // Key material: only providers that mint a keypair (hetzner/DO) have any.\n // Detected by what's actually in custody rather than by provider name, so a\n // new SSH provider needs no change here.\n //\n // Pass the provider + key we already resolved rather than the raw ref: letting\n // the download re-resolve it meant a sandbox-id ref landed the keys in a\n // different dir than the `identityFile` we just recorded.\n const sshFiles = await downloadBoxSshKeys({\n custody: args.custody,\n provider: reg.backend,\n key: sandboxId,\n }).catch(() => []);\n if (sshFiles.length > 0) {\n log(`pulled ${String(sshFiles.length)} SSH key file(s) for ${reg.name}`);\n }\n // A box we just gave an `identityFile` but no key for is adopted-but-unusable:\n // `attach`/`cp` would fail later on a missing-key ssh error rather than here,\n // where we know why. The record is still worth writing (`url` works, and the\n // key can be fetched later), so this is reported, not thrown.\n const sshKeysMissing = record.ssh?.identityFile !== undefined && sshFiles.length === 0;\n if (sshKeysMissing) {\n log(\n `WARN: no SSH key material in custody for ${reg.name} (boxes/${sandboxId}/ssh) — ` +\n `attach / cp will not work until it is there. Try \\`agentbox hub pull ${reg.name}\\`.`,\n );\n }\n\n await recordBox(record);\n return { record, sshFiles, projectRoot, refreshed: existing !== undefined, sshKeysMissing };\n}\n","/**\n * `agentbox hub pull <box>` — download a hub-created box's per-box SSH key\n * material from the control box's custody store into the PC's on-disk ssh dir\n * (`~/.agentbox/[<namespace>/]boxes/<sandboxId>/ssh/`), so `attach` / port\n * forwards / `cp` work exactly as for a PC-created box.\n *\n * Keyed by the provider sandbox id (from the box's control-box registration),\n * which is the id both the on-disk ssh dir and the custody `boxes/<id>/ssh/`\n * subtree use — so the bytes land at the exact path attach/cp read.\n */\nimport { basename } from 'node:path';\nimport { chmod, mkdir, writeFile } from 'node:fs/promises';\nimport { boxSshDirForProvider, defaultBoxSshDir } from '@agentbox/sandbox-core';\nimport type { CustodyClient } from './custody-client.js';\nimport type { ControlPlaneAdminClient } from './admin-client.js';\nimport { matchRegistration } from './match-ref.js';\n\nexport interface HubPullResult {\n /** The id the keys are stored under (sandboxId, or the box id as a fallback). */\n key: string;\n /** On-disk directory the keys were written to. */\n dest: string;\n /** Basenames of the files written. */\n files: string[];\n /** True when the box was found in the control box's registry. */\n registered: boolean;\n}\n\nexport interface HubPullArgs {\n admin: ControlPlaneAdminClient;\n custody: CustodyClient;\n /** Box id or name as shown by `hub boxes list`. */\n box: string;\n}\n\n/**\n * Resolve the box → its sandbox id + provider, then download every file under\n * custody `boxes/<key>/ssh/` into the matching on-disk ssh dir. Pure of any\n * command-layer concern (logging/exit codes) so it is unit-testable with a fake\n * fetch + a temp HOME.\n */\nexport async function pullBoxSshKeys(args: HubPullArgs): Promise<HubPullResult> {\n const boxes = await args.admin.listBoxes();\n // The SAME matcher adoption uses. Resolving refs differently here is not a\n // cosmetic inconsistency: a ref this missed but adoption matched lost\n // `provider` and fell back to `args.box` as the key — writing one box's keys\n // into another id's on-disk dir and custody subtree.\n const reg = matchRegistration(boxes, args.box);\n const key = reg?.sandboxId ?? reg?.boxId ?? args.box;\n const files = await downloadBoxSshKeys({\n custody: args.custody,\n provider: reg?.backend,\n key,\n });\n return { key, dest: sshDestFor(reg?.backend, key), files, registered: reg !== undefined };\n}\n\n/** The on-disk ssh dir for a box, provider-namespaced when the provider has one. */\nfunction sshDestFor(provider: string | undefined, key: string): string {\n return (provider ? boxSshDirForProvider(provider, key) : null) ?? defaultBoxSshDir(key);\n}\n\n/**\n * Download every file under custody `boxes/<key>/ssh/` into the box's on-disk\n * ssh dir. Takes the ALREADY-RESOLVED provider + key rather than a ref, so a\n * caller that has the registration in hand (adoption) can't re-resolve it\n * differently — and doesn't pay for a second registry fetch.\n */\nexport async function downloadBoxSshKeys(args: {\n custody: CustodyClient;\n /** Backend name from the registration; undefined → the un-namespaced default dir. */\n provider: string | undefined;\n /** Sandbox id (the id both the ssh dir and the custody subtree are keyed by). */\n key: string;\n}): Promise<string[]> {\n const dest = sshDestFor(args.provider, args.key);\n const entries = await args.custody.list(`boxes/${args.key}/ssh`);\n const files: string[] = [];\n if (entries.length > 0) await mkdir(dest, { recursive: true, mode: 0o700 });\n for (const e of entries) {\n const data = await args.custody.get(e.path);\n if (data === null) continue;\n const name = basename(e.path);\n const out = `${dest}/${name}`;\n await writeFile(out, data, { mode: 0o600 });\n await chmod(out, 0o600);\n files.push(name);\n }\n return files;\n}\n","/**\n * Resolving a user's box ref against the control box's registry.\n *\n * Lives in its own module because BOTH `hub-adopt` and `hub-pull` must resolve\n * a ref identically — they key different things off the result (a `BoxRecord`\n * vs. the custody `boxes/<key>/ssh` subtree), so a matcher that drifts between\n * them writes one box's keys under another box's id.\n */\nimport type { BoxRegistration } from '@agentbox/relay';\n\n/**\n * Resolve a ref using the SAME rules the local resolver uses (`findBox`): exact\n * id / name / sandbox id, then a UNIQUE id-or-sandbox-id prefix. Without the\n * prefix arm, a shortened ref that works for a local box mysteriously fails for\n * a hub-only one.\n *\n * An ambiguous prefix resolves to nothing rather than picking one: callers write\n * state and then drive the box, so guessing wrong is worse than not matching.\n */\nexport function matchRegistration(\n regs: BoxRegistration[],\n ref: string,\n): BoxRegistration | undefined {\n const exact = regs.find((r) => r.boxId === ref || r.name === ref || r.sandboxId === ref);\n if (exact) return exact;\n const byPrefix = regs.filter(\n (r) => r.boxId.startsWith(ref) || r.sandboxId?.startsWith(ref) === true,\n );\n return byPrefix.length === 1 ? byPrefix[0] : undefined;\n}\n"],"mappings":"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","names":[]}
@@ -1,24 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- DEFAULT_RELAY_PORT,
3
+ providerForBox
4
+ } from "./chunk-OEYAVBA6.js";
5
+ import {
6
+ buildCloudAttachInnerCommand,
7
+ startDetachedCloudAgent,
8
+ startDetachedSession
9
+ } from "./chunk-3UMM4VJH.js";
10
+ import {
4
11
  readBoxStatus,
5
12
  startClaudeSession,
6
13
  startCodexSession,
7
14
  startOpencodeSession
8
- } from "./chunk-26IKZRTT.js";
15
+ } from "./chunk-BLWAWGFX.js";
9
16
  import {
10
- PROVIDER_NAMES,
11
- isProviderKind,
12
- loadEffectiveConfig
13
- } from "./chunk-JGZSA5ZI.js";
17
+ DEFAULT_RELAY_PORT
18
+ } from "./chunk-ZJL56TJD.js";
14
19
  import {
15
- isSupportedApiVersion,
16
- pluginForProvider,
17
- pluginProviderNames
18
- } from "./chunk-UJEH2NJT.js";
20
+ loadEffectiveConfig
21
+ } from "./chunk-BHJCMTHP.js";
19
22
 
20
23
  // src/commands/_cloud-attach.ts
21
- import { spawn as spawn4 } from "child_process";
22
24
  import { appendFileSync } from "fs";
23
25
  import { homedir } from "os";
24
26
  import { join as join2 } from "path";
@@ -159,99 +161,6 @@ async function withFirewallRepair(provider, box, opts, attempt) {
159
161
  }
160
162
  }
161
163
 
162
- // src/provider/loaders.ts
163
- import { pathToFileURL } from "url";
164
- var IMPORTERS = {
165
- docker: () => import("./dist-OO52HARR.js"),
166
- daytona: () => import("./dist-O3LKOIE7.js"),
167
- hetzner: () => import("./dist-FTKS2GI4.js"),
168
- vercel: () => import("./dist-WVYAURMF.js"),
169
- e2b: () => import("./dist-TSFVB7AI.js"),
170
- digitalocean: () => import("./dist-KQTMCVME.js"),
171
- "remote-docker": () => import("./dist-Z6L5MM5D.js")
172
- };
173
- function pickProviderModule(mod, name) {
174
- const m = mod;
175
- const all = m.providerModules ?? (m.providerModule ? [m.providerModule] : []);
176
- return all.find((pm) => pm.provider?.name === name) ?? null;
177
- }
178
- async function loadProviderModule(name) {
179
- if (isProviderKind(name)) {
180
- return (await IMPORTERS[name]()).providerModule;
181
- }
182
- const plugin = pluginForProvider(name);
183
- if (!plugin) {
184
- throw new Error(
185
- `unknown provider "${name}" \u2014 not built in and no registered plugin provides it (run \`agentbox plugin list\`)`
186
- );
187
- }
188
- if (!isSupportedApiVersion(plugin.apiVersion)) {
189
- throw new Error(
190
- `plugin "${plugin.packageName}" targets provider SDK v${String(plugin.apiVersion)}, which this AgentBox does not support \u2014 update the plugin or AgentBox`
191
- );
192
- }
193
- const mod = await import(pathToFileURL(plugin.resolvedEntry).href);
194
- const providerModule = pickProviderModule(mod, name);
195
- if (!providerModule) {
196
- throw new Error(
197
- `plugin "${plugin.packageName}" does not export a providerModule for "${name}"`
198
- );
199
- }
200
- return providerModule;
201
- }
202
- function getRuntimeProviderNames() {
203
- return [.../* @__PURE__ */ new Set([...PROVIDER_NAMES, ...pluginProviderNames()])];
204
- }
205
- function isRuntimeProvider(name) {
206
- return isProviderKind(name) || pluginProviderNames().includes(name);
207
- }
208
-
209
- // src/provider/spec.ts
210
- var REMOTE_DOCKER = "remote-docker";
211
- function parseProviderSpec(spec) {
212
- const raw = spec.trim();
213
- const colon = raw.indexOf(":");
214
- if (colon < 0) return { name: raw };
215
- const base = raw.slice(0, colon);
216
- const host = raw.slice(colon + 1).trim();
217
- if (base !== "docker" && base !== REMOTE_DOCKER) {
218
- return { name: raw };
219
- }
220
- if (host.length === 0) {
221
- throw new Error(
222
- `provider "${raw}" names no host \u2014 write \`${base}:<ssh-host>\` (an ~/.ssh/config alias or [user@]host[:port])`
223
- );
224
- }
225
- return { name: REMOTE_DOCKER, remoteHost: host };
226
- }
227
-
228
- // src/provider/registry.ts
229
- function isKnownProvider(name) {
230
- try {
231
- return isRuntimeProvider(parseProviderSpec(name).name);
232
- } catch {
233
- return false;
234
- }
235
- }
236
- async function getProvider(name) {
237
- const mod = await loadProviderModule(parseProviderSpec(name).name);
238
- if (mod.ensureCredentials) await mod.ensureCredentials();
239
- return mod.provider;
240
- }
241
- async function providerForBox(box) {
242
- return getProvider(box.provider ?? "docker");
243
- }
244
- async function providerForCreate(choice) {
245
- const flag = choice.flag?.trim();
246
- const spec = flag && flag.length > 0 ? flag : choice.config.box.provider;
247
- if (typeof spec !== "string" || spec.length === 0 || !isKnownProvider(spec)) {
248
- throw new Error(
249
- `unknown sandbox provider "${String(spec)}" (known: ${getRuntimeProviderNames().join(", ")})`
250
- );
251
- }
252
- return getProvider(spec);
253
- }
254
-
255
164
  // src/wrapped-pty/run.ts
256
165
  import { spawn as spawn3, spawnSync as spawnSync2 } from "child_process";
257
166
 
@@ -278,13 +187,13 @@ async function loadPtyBackend() {
278
187
  try {
279
188
  const ptyMod = await import("@homebridge/node-pty-prebuilt-multiarch");
280
189
  const xtermMod = await import("@xterm/headless");
281
- const spawn5 = ptyMod["spawn"] ?? ptyMod["default"]?.["spawn"];
190
+ const spawn4 = ptyMod["spawn"] ?? ptyMod["default"]?.["spawn"];
282
191
  const Terminal = xtermMod["Terminal"] ?? xtermMod["default"]?.["Terminal"];
283
- if (typeof spawn5 !== "function" || typeof Terminal !== "function") {
192
+ if (typeof spawn4 !== "function" || typeof Terminal !== "function") {
284
193
  return null;
285
194
  }
286
195
  return {
287
- ptySpawn: spawn5,
196
+ ptySpawn: spawn4,
288
197
  termCtor: Terminal
289
198
  };
290
199
  } catch {
@@ -1682,7 +1591,10 @@ function subscribePrompts(opts) {
1682
1591
  port,
1683
1592
  method: "GET",
1684
1593
  path: `${url.pathname.replace(/\/$/, "")}/admin/prompts/stream?boxId=${encodeURIComponent(opts.boxId)}`,
1685
- headers: { Accept: "text/event-stream" }
1594
+ headers: {
1595
+ Accept: "text/event-stream",
1596
+ ...opts.authToken ? { Authorization: `Bearer ${opts.authToken}` } : {}
1597
+ }
1686
1598
  });
1687
1599
  req.on("response", (r) => {
1688
1600
  res = r;
@@ -1747,9 +1659,12 @@ function postAnswer(opts) {
1747
1659
  path: `${url.pathname.replace(/\/$/, "")}/admin/prompts/answer`,
1748
1660
  headers: {
1749
1661
  "Content-Type": "application/json",
1750
- "Content-Length": Buffer.byteLength(json).toString()
1662
+ "Content-Length": Buffer.byteLength(json).toString(),
1663
+ ...opts.authToken ? { Authorization: `Bearer ${opts.authToken}` } : {}
1751
1664
  },
1752
- timeout: 3e3
1665
+ // Generous enough for a WAN round-trip to a control box, not just the
1666
+ // loopback relay this once only spoke to.
1667
+ timeout: 8e3
1753
1668
  },
1754
1669
  (res) => {
1755
1670
  res.resume();
@@ -2148,7 +2063,7 @@ async function runWrappedAttach(opts) {
2148
2063
  },
2149
2064
  onAnswer: (body) => {
2150
2065
  if (!body.id.startsWith("local:")) {
2151
- void postAnswer({ relayBaseUrl: opts.relayBaseUrl, body });
2066
+ void postAnswer({ relayBaseUrl: opts.relayBaseUrl, authToken: opts.relayAuthToken, body });
2152
2067
  }
2153
2068
  capturingPrompt = null;
2154
2069
  applyBandChange();
@@ -2193,6 +2108,7 @@ async function runWrappedAttach(opts) {
2193
2108
  }
2194
2109
  const stream = subscribePrompts({
2195
2110
  relayBaseUrl: opts.relayBaseUrl,
2111
+ authToken: opts.relayAuthToken,
2196
2112
  boxId: opts.boxId,
2197
2113
  onPrompt: (ev) => {
2198
2114
  capturingPrompt = ev;
@@ -2229,6 +2145,20 @@ async function runWrappedAttach(opts) {
2229
2145
  stopSpinner();
2230
2146
  applyBandChange();
2231
2147
  }
2148
+ },
2149
+ // A dead prompt stream must never look like "no approvals". The client
2150
+ // retries transient drops itself, but bails permanently on a non-200 — and
2151
+ // for a hub box this URL is the control box with an admin bearer, so a
2152
+ // stale token answers 401 and the footer would sit silent for the whole
2153
+ // session while the box is actually blocked. Surface it in the band, and
2154
+ // pass it to the caller's log so it's diagnosable after the fact.
2155
+ onError: (err) => {
2156
+ opts.onError?.(`prompt stream: ${err.message}`);
2157
+ activeNotice = {
2158
+ id: "prompt-stream-error",
2159
+ message: `approvals unavailable (${err.message}) \u2014 answer them with \`agentbox hub prompts\``
2160
+ };
2161
+ applyBandChange();
2232
2162
  }
2233
2163
  });
2234
2164
  const pollStatus = async () => {
@@ -2552,8 +2482,44 @@ async function pasteHostClipboardImage(provider, box) {
2552
2482
  }
2553
2483
  }
2554
2484
 
2485
+ // src/control-plane/box-plane.ts
2486
+ var LOCAL_RELAY_URL = `http://127.0.0.1:${String(DEFAULT_RELAY_PORT)}`;
2487
+ async function resolveBoxPlane(box) {
2488
+ if ((box.provider ?? "docker") === "docker") return "none";
2489
+ const { loadEffectiveConfig: loadEffectiveConfig2 } = await import("./dist-SKMNEDVW.js");
2490
+ const { loadControlPlaneEnv } = await import("./env-file-UDUDQMP4.js");
2491
+ const configured = await loadEffectiveConfig2(process.cwd()).then((c) => c.effective.relay.controlPlaneUrl).catch(() => void 0);
2492
+ const url = (box.cloud?.controlPlaneUrl ?? configured ?? "").replace(/\/+$/, "");
2493
+ if (!url) return "none";
2494
+ loadControlPlaneEnv();
2495
+ const adminToken = process.env["AGENTBOX_RELAY_ADMIN_TOKEN"] ?? "";
2496
+ return adminToken ? { url, adminToken } : "no-token";
2497
+ }
2498
+ async function resolveBoxPromptSource(box) {
2499
+ const plane = await resolveBoxPlane(box).catch(() => "none");
2500
+ if (plane === "none") return { baseUrl: LOCAL_RELAY_URL, remote: false };
2501
+ if (plane === "no-token") {
2502
+ const named = box.cloud?.controlPlaneUrl ?? "(configured control box)";
2503
+ return { baseUrl: LOCAL_RELAY_URL, remote: false, unauthenticatedPlane: named };
2504
+ }
2505
+ return { baseUrl: plane.url, authToken: plane.adminToken, remote: true };
2506
+ }
2507
+ var warnedNoToken = false;
2508
+ async function attachRelayOptions(box) {
2509
+ const source = await resolveBoxPromptSource(box);
2510
+ if (source.unauthenticatedPlane !== void 0 && !warnedNoToken) {
2511
+ warnedNoToken = true;
2512
+ process.stderr.write(
2513
+ `note: this box's approvals live on ${source.unauthenticatedPlane}, but no admin token is available here,
2514
+ so the attach footer can't show them. Set AGENTBOX_RELAY_ADMIN_TOKEN, or answer them with
2515
+ \`agentbox hub prompts list\` / \`agentbox hub prompts answer\`.
2516
+ `
2517
+ );
2518
+ }
2519
+ return { relayBaseUrl: source.baseUrl, relayAuthToken: source.authToken };
2520
+ }
2521
+
2555
2522
  // src/commands/_cloud-attach.ts
2556
- var RELAY_HOST_URL = `http://127.0.0.1:${String(DEFAULT_RELAY_PORT)}`;
2557
2523
  var RECONNECT_TIMEOUT_MS = 5 * 6e4;
2558
2524
  function abortableSleep(ms, signal) {
2559
2525
  return new Promise((resolve) => {
@@ -2572,19 +2538,6 @@ function abortableSleep(ms, signal) {
2572
2538
  );
2573
2539
  });
2574
2540
  }
2575
- function agentStartBanner(binary) {
2576
- return `printf " agentbox: starting ${binary} (first paint may take a few seconds)...\\r\\n"; `;
2577
- }
2578
- function buildCloudAttachInnerCommand(binary, extraArgs) {
2579
- if (!extraArgs || extraArgs.length === 0) {
2580
- return `bash -lc '${agentStartBanner(binary)}exec ${binary}'`;
2581
- }
2582
- const blob = Buffer.from(
2583
- extraArgs.map((a) => Buffer.from(a, "utf8").toString("base64")).join("\n"),
2584
- "utf8"
2585
- ).toString("base64");
2586
- 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[@]}"'`;
2587
- }
2588
2541
  async function cloudAgentAttach(args) {
2589
2542
  const provider = await providerForBox(args.box);
2590
2543
  if (!provider.buildAttach) {
@@ -2658,7 +2611,7 @@ async function cloudAgentAttach(args) {
2658
2611
  dockerArgv: spec.argv.slice(1),
2659
2612
  env: spec.env,
2660
2613
  initialInput: spec.initialInput,
2661
- relayBaseUrl: RELAY_HOST_URL,
2614
+ ...await attachRelayOptions(box),
2662
2615
  boxId: box.id,
2663
2616
  boxName: box.name,
2664
2617
  projectIndex: box.projectIndex,
@@ -2684,107 +2637,22 @@ async function cloudAgentAttach(args) {
2684
2637
  if (spec.cleanup) await spec.cleanup();
2685
2638
  }
2686
2639
  }
2687
- async function startDetachedSession(provider, box, sessionName, command) {
2688
- if (!provider.buildAttach) {
2689
- throw new Error(`provider '${provider.name}' does not support detached sessions`);
2690
- }
2691
- const spec = await provider.buildAttach(box, "agent", {
2692
- sessionName,
2693
- command,
2694
- detached: true
2695
- });
2696
- try {
2697
- return await runDetached(spec.argv, spec.env);
2698
- } finally {
2699
- if (spec.cleanup) await spec.cleanup();
2700
- }
2701
- }
2702
- var AGENT_AUTH_FAILURE = /Please run \/login|Invalid authentication credentials|API Error: 401|Invalid API key|\bUnauthorized\b/i;
2703
- function sleep(ms) {
2704
- return new Promise((resolve) => setTimeout(resolve, ms));
2705
- }
2706
- async function verifyDetachedSession(provider, box, sessionName, binary, opts = {}) {
2707
- const windowMs = opts.windowMs ?? 1e4;
2708
- const pollMs = opts.pollMs ?? 2e3;
2709
- const q = `'${sessionName.replace(/'/g, `'\\''`)}'`;
2710
- const probe = `tmux has-session -t ${q} 2>/dev/null || exit 7; tmux capture-pane -p -t ${q} 2>/dev/null`;
2711
- const deadline = Date.now() + windowMs;
2712
- for (; ; ) {
2713
- let pane = "";
2714
- try {
2715
- const r = await provider.exec(box, ["bash", "-lc", probe], { user: "vscode" });
2716
- if (r.exitCode === 7) {
2717
- throw new Error(
2718
- `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}`
2719
- );
2720
- }
2721
- pane = r.stdout;
2722
- } catch (err) {
2723
- if (err instanceof Error && err.message.startsWith(`agent '${binary}'`)) throw err;
2724
- }
2725
- if (AGENT_AUTH_FAILURE.test(pane)) {
2726
- throw new Error(
2727
- `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.`
2728
- );
2729
- }
2730
- if (Date.now() >= deadline) break;
2731
- await sleep(pollMs);
2732
- }
2733
- }
2734
2640
  async function cloudAgentStartDetached(args) {
2735
2641
  const provider = await providerForBox(args.box);
2736
- let box = args.box;
2737
- const state = await provider.probeState(box);
2738
- if (state === "missing") {
2739
- throw new Error(`cloud sandbox for ${box.name} is missing; was it destroyed?`);
2740
- }
2741
- if (state !== "running") {
2742
- box = await provider.start(box);
2743
- }
2744
- let extraArgs = args.extraArgs;
2745
- if ((!extraArgs || extraArgs.length === 0) && (args.binary === "claude" || args.binary === "codex")) {
2746
- const resume = await agentResumeArgs(provider, box, args.binary);
2747
- if (resume) extraArgs = resume;
2748
- }
2749
- const command = buildCloudAttachInnerCommand(args.binary, extraArgs);
2750
- const { exitCode, stderr } = await startDetachedSession(
2642
+ await startDetachedCloudAgent({
2751
2643
  provider,
2752
- box,
2753
- args.sessionName,
2754
- command
2755
- );
2756
- if (exitCode !== 0) {
2757
- const detail = stderr.trim().slice(0, 500);
2758
- throw new Error(
2759
- `failed to start the ${args.binary} session in box ${box.name} (exit ${String(exitCode)})` + (detail ? `: ${detail}` : "")
2760
- );
2761
- }
2762
- await verifyDetachedSession(provider, box, args.sessionName, args.binary);
2763
- }
2764
- function runDetached(argv, env) {
2765
- return new Promise((resolve) => {
2766
- const child = spawn4(argv[0], argv.slice(1), {
2767
- stdio: ["ignore", "ignore", "pipe"],
2768
- env: env ? { ...process.env, ...env } : process.env
2769
- });
2770
- let stderr = "";
2771
- child.stderr?.on("data", (c) => {
2772
- stderr += c.toString("utf8");
2773
- });
2774
- child.on("error", (err) => resolve({ exitCode: 1, stderr: stderr + String(err.message ?? err) }));
2775
- child.on("exit", (code) => resolve({ exitCode: code ?? 0, stderr }));
2644
+ box: args.box,
2645
+ binary: args.binary,
2646
+ sessionName: args.sessionName,
2647
+ extraArgs: args.extraArgs,
2648
+ resolveResumeArgs: args.binary === "claude" || args.binary === "codex" ? (box) => agentResumeArgs(provider, box, args.binary) : void 0
2776
2649
  });
2777
2650
  }
2778
2651
 
2779
2652
  export {
2780
- loadProviderModule,
2781
- getRuntimeProviderNames,
2782
- isRuntimeProvider,
2783
- parseProviderSpec,
2784
- isKnownProvider,
2785
- getProvider,
2786
- providerForBox,
2787
- providerForCreate,
2653
+ resolveBoxPlane,
2654
+ resolveBoxPromptSource,
2655
+ attachRelayOptions,
2788
2656
  withFirewallRepair,
2789
2657
  loadPtyBackend,
2790
2658
  herdrSend,
@@ -2813,13 +2681,11 @@ export {
2813
2681
  clipboardCaptureAvailable,
2814
2682
  uploadImageFileToBox,
2815
2683
  pasteHostClipboardImage,
2816
- buildCloudAttachInnerCommand,
2817
2684
  cloudAgentAttach,
2818
- verifyDetachedSession,
2819
2685
  cloudAgentStartDetached,
2820
2686
  applyClaudeSkipPermissions,
2821
2687
  applyCodexSkipPermissions,
2822
2688
  agentResumeArgs,
2823
2689
  restoreAgentSessions
2824
2690
  };
2825
- //# sourceMappingURL=chunk-JE6UI5YR.js.map
2691
+ //# sourceMappingURL=chunk-NKVCIH6N.js.map