@madarco/agentbox 0.28.1 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (452) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/dist/_cloud-attach-EUO2OL7W.js +30 -0
  3. package/dist/chunk-2JHPGPLE.js +71 -0
  4. package/dist/chunk-2JHPGPLE.js.map +1 -0
  5. package/dist/{chunk-JQLOGVZK.js → chunk-4KYP775X.js} +85 -21
  6. package/dist/chunk-4KYP775X.js.map +1 -0
  7. package/dist/{chunk-V5NWSLWD.js → chunk-4NUETVTR.js} +14 -14
  8. package/dist/{chunk-OXKW4GWD.js → chunk-53OTEDBS.js} +4 -70
  9. package/dist/chunk-53OTEDBS.js.map +1 -0
  10. package/dist/{chunk-FGQFVUMH.js → chunk-6YSYQZRH.js} +3 -3
  11. package/dist/{chunk-KFLGXE3R.js → chunk-73D2HKA3.js} +138 -24
  12. package/dist/chunk-73D2HKA3.js.map +1 -0
  13. package/dist/{chunk-HYXCH4GA.js → chunk-7LC5IG5K.js} +7 -7
  14. package/dist/{chunk-NHVGKFVY.js → chunk-7LNXTPEE.js} +340 -22
  15. package/dist/chunk-7LNXTPEE.js.map +1 -0
  16. package/dist/{chunk-74VIUGY6.js → chunk-A2TATHHJ.js} +6 -9
  17. package/dist/chunk-A2TATHHJ.js.map +1 -0
  18. package/dist/{chunk-YI4GHC2E.js → chunk-AC3HU25W.js} +12 -15
  19. package/dist/chunk-AC3HU25W.js.map +1 -0
  20. package/dist/{chunk-7ABO7OIF.js → chunk-AUHYXXCA.js} +4 -4
  21. package/dist/{chunk-FPMRFMVK.js → chunk-B4YFG5TB.js} +9 -9
  22. package/dist/{chunk-OUF3YTQO.js → chunk-BIKWXLX7.js} +14 -17
  23. package/dist/chunk-BIKWXLX7.js.map +1 -0
  24. package/dist/{chunk-CKD3PRON.js → chunk-CZPVVFCF.js} +12 -9
  25. package/dist/{chunk-CKD3PRON.js.map → chunk-CZPVVFCF.js.map} +1 -1
  26. package/dist/chunk-F4PPZ4SI.js +17 -0
  27. package/dist/chunk-F4PPZ4SI.js.map +1 -0
  28. package/dist/{chunk-BWM56FKY.js → chunk-FEFLAITR.js} +11 -11
  29. package/dist/{chunk-EVT2SNF2.js → chunk-FELVUIIM.js} +3 -3
  30. package/dist/{chunk-46NNZMZT.js → chunk-I2DEYQLZ.js} +372 -72
  31. package/dist/chunk-I2DEYQLZ.js.map +1 -0
  32. package/dist/{chunk-OUWVN2F2.js → chunk-I7BSBUPC.js} +16 -13
  33. package/dist/chunk-I7BSBUPC.js.map +1 -0
  34. package/dist/{chunk-G3H2L3O2.js → chunk-MNDKP4VS.js} +23 -3
  35. package/dist/chunk-MNDKP4VS.js.map +1 -0
  36. package/dist/{chunk-BUMKBUXS.js → chunk-PAWAGULH.js} +3 -3
  37. package/dist/{chunk-4PR3KJ5X.js → chunk-PFEBKXFD.js} +20 -20
  38. package/dist/{chunk-JDSYMTMS.js → chunk-QDU7YDME.js} +130 -66
  39. package/dist/chunk-QDU7YDME.js.map +1 -0
  40. package/dist/{chunk-JNC7MCWJ.js → chunk-S32GHLVU.js} +10 -10
  41. package/dist/chunk-S32GHLVU.js.map +1 -0
  42. package/dist/{chunk-WB6S4W7O.js → chunk-THKVKVRF.js} +2413 -1012
  43. package/dist/chunk-THKVKVRF.js.map +1 -0
  44. package/dist/{chunk-7RSE7ESY.js → chunk-UEEW5TW7.js} +27 -18
  45. package/dist/chunk-UEEW5TW7.js.map +1 -0
  46. package/dist/{chunk-B4DAH2F2.js → chunk-UTOC2NHC.js} +3 -3
  47. package/dist/{chunk-NHTRTST5.js → chunk-WDBDFLH3.js} +38 -15
  48. package/dist/chunk-WDBDFLH3.js.map +1 -0
  49. package/dist/{chunk-PSA6GADQ.js → chunk-WHFCJBMO.js} +14 -1
  50. package/dist/chunk-WHFCJBMO.js.map +1 -0
  51. package/dist/{chunk-KJ5TCYNI.js → chunk-WJUKN4L4.js} +7 -6
  52. package/dist/chunk-WJUKN4L4.js.map +1 -0
  53. package/dist/{chunk-GFOWBXV7.js → chunk-XENTK32L.js} +463 -253
  54. package/dist/chunk-XENTK32L.js.map +1 -0
  55. package/dist/cloud-backends.js +5 -5
  56. package/dist/{cloud-poller-SUNA6ZQC-7M5LJHHE.js → cloud-poller-QJRZXB4W-LJ2BRB3L.js} +2 -2
  57. package/dist/{control-plane-5R7PYRQ6.js → control-plane-YQFX2ILX.js} +19 -18
  58. package/dist/cp-hub-upload-RMJ3XJ65.js +81 -0
  59. package/dist/cp-hub-upload-RMJ3XJ65.js.map +1 -0
  60. package/dist/{custody-client-PNCC2HBJ.js → custody-client-L4FEFW4C.js} +5 -4
  61. package/dist/{deploy-hetzner-SSGSXAKA.js → deploy-hetzner-EECQ4JCM.js} +10 -10
  62. package/dist/{dist-RN6JOAG4.js → dist-3BKIPZR3.js} +81 -45
  63. package/dist/{dist-K5M4HKG7.js → dist-C5B6NGBO.js} +21 -9
  64. package/dist/{dist-6PYXFREL.js → dist-E5EXDZG4.js} +61 -16
  65. package/dist/dist-E5EXDZG4.js.map +1 -0
  66. package/dist/{dist-XATN4ZIR.js → dist-FBM2WS5S.js} +22 -4
  67. package/dist/{dist-XQLKK7H3.js → dist-NFF2KEMB.js} +54 -28
  68. package/dist/dist-NFF2KEMB.js.map +1 -0
  69. package/dist/{dist-5OR4QTQW.js → dist-NTUHJOK3.js} +9 -9
  70. package/dist/{dist-ZNQZHTUN.js → dist-PTYASENV.js} +35 -6
  71. package/dist/{dist-POILUDVJ.js → dist-Q4UDCSZQ.js} +9 -9
  72. package/dist/{dist-M4O5MU5K.js → dist-TXFTYNNE.js} +8 -8
  73. package/dist/{dist-EPFS5PRI.js → dist-XUOHE22G.js} +10 -10
  74. package/dist/{dist-SN2TCRZ5.js → dist-Z2TPC3EN.js} +9 -9
  75. package/dist/host-reach-drainer-N4JSFUBY.js +9 -0
  76. package/dist/hub-3HPYOV5O.js +37 -0
  77. package/dist/{hub-adopt-I44VGSBL.js → hub-adopt-NCCCMMXL.js} +8 -8
  78. package/dist/{hub-api-client-WJPBXZAZ.js → hub-api-client-5U6WOTZ3.js} +2 -2
  79. package/dist/{hub-docker-target-REEEWUG2.js → hub-docker-target-ZKAWXVPH.js} +16 -16
  80. package/dist/index.js +1321 -882
  81. package/dist/index.js.map +1 -1
  82. package/dist/prepare-KIVDQRMN.js +41 -0
  83. package/dist/prepared-custody-EFSOOAIQ.js +36 -0
  84. package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js → prepared-state-LNQ7DYSU-2YFSDOCV.js} +4 -3
  85. package/dist/{publish-credentials-BPHUO5VL.js → publish-credentials-F2A5OVCO.js} +11 -11
  86. package/dist/registry-O3X2CDDU.js +18 -0
  87. package/dist/relay-3T57T4RI.js +20 -0
  88. package/dist/relay-3T57T4RI.js.map +1 -0
  89. package/dist/{remote-docker-share-RX5ARK45.js → remote-docker-share-QDCBM5UM.js} +11 -11
  90. package/dist/remote-docker-share-QDCBM5UM.js.map +1 -0
  91. package/dist/tool-grant-push-6ISDIJKH.js +90 -0
  92. package/dist/tool-grant-push-6ISDIJKH.js.map +1 -0
  93. package/package.json +1 -2
  94. package/runtime/_shared/agentbox-tool-shim +21 -0
  95. package/runtime/_shared/ctl.cjs +6760 -5299
  96. package/runtime/_shared/gh-shim +103 -228
  97. package/runtime/digitalocean/agentbox-tool-shim +21 -0
  98. package/runtime/digitalocean/ctl.cjs +6760 -5299
  99. package/runtime/digitalocean/gh-shim +103 -228
  100. package/runtime/digitalocean/scripts/install-box.sh +9 -15
  101. package/runtime/docker/Dockerfile.box +8 -18
  102. package/runtime/docker/packages/ctl/dist/bin.cjs +6760 -5299
  103. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-tool-shim +21 -0
  104. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +103 -228
  105. package/runtime/e2b/agentbox-tool-shim +21 -0
  106. package/runtime/e2b/ctl.cjs +6760 -5299
  107. package/runtime/e2b/gh-shim +103 -228
  108. package/runtime/e2b/scripts/build-template.sh +5 -9
  109. package/runtime/hetzner/agentbox-tool-shim +21 -0
  110. package/runtime/hetzner/ctl.cjs +6760 -5299
  111. package/runtime/hetzner/gh-shim +103 -228
  112. package/runtime/hetzner/scripts/install-box.sh +9 -15
  113. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  114. package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +2 -0
  115. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  116. package/runtime/hub/apps/hub/.next/routes-manifest.json +16 -0
  117. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js +5 -5
  118. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +1 -1
  119. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js +2 -2
  120. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js.nft.json +1 -1
  121. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js +2 -2
  122. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js.nft.json +1 -1
  123. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js +2 -2
  124. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js.nft.json +1 -1
  125. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/agent/route.js +2 -2
  126. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/agent/route.js.nft.json +1 -1
  127. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js +2 -2
  128. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js.nft.json +1 -1
  129. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/checkpoint/route.js +2 -2
  130. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/checkpoint/route.js.nft.json +1 -1
  131. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js +2 -2
  132. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js.nft.json +1 -1
  133. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js +2 -2
  134. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js.nft.json +1 -1
  135. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/logs/route.js +1 -1
  136. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/logs/route.js.nft.json +1 -1
  137. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js +2 -2
  138. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.nft.json +1 -1
  139. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +2 -2
  140. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -1
  141. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js +2 -2
  142. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js.nft.json +1 -1
  143. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js +2 -2
  144. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js.nft.json +1 -1
  145. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js +2 -2
  146. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js.nft.json +1 -1
  147. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route/app-paths-manifest.json +3 -0
  148. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route/build-manifest.json +9 -0
  149. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route/server-reference-manifest.json +4 -0
  150. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route.js +8 -0
  151. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route.js.map +5 -0
  152. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route.js.nft.json +1 -0
  153. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/vnc/route_client-reference-manifest.js +3 -0
  154. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js +2 -2
  155. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js.nft.json +1 -1
  156. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/checkpoints/route.js +2 -2
  157. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/checkpoints/route.js.nft.json +1 -1
  158. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/[...path]/route.js +1 -1
  159. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/[...path]/route.js.nft.json +1 -1
  160. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/blob/[...path]/route.js +2 -2
  161. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/custody/blob/[...path]/route.js.nft.json +1 -1
  162. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js +2 -2
  163. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js.nft.json +1 -1
  164. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js +2 -2
  165. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js.nft.json +1 -1
  166. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js +2 -2
  167. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js.nft.json +1 -1
  168. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js +2 -2
  169. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js.nft.json +1 -1
  170. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js +2 -2
  171. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js.nft.json +1 -1
  172. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js +2 -2
  173. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js.nft.json +1 -1
  174. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js +2 -2
  175. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js.nft.json +1 -1
  176. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/route.js +2 -2
  177. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/route.js.nft.json +1 -1
  178. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js +2 -2
  179. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.nft.json +1 -1
  180. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js +2 -2
  181. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js.nft.json +1 -1
  182. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js +2 -2
  183. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js.nft.json +1 -1
  184. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/seed/route.js +2 -2
  185. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/seed/route.js.nft.json +1 -1
  186. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js +2 -2
  187. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js.nft.json +1 -1
  188. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js +2 -2
  189. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js.nft.json +1 -1
  190. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js +2 -2
  191. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js.nft.json +1 -1
  192. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js +2 -2
  193. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js.nft.json +1 -1
  194. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/prune/route.js +2 -2
  195. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/prune/route.js.nft.json +1 -1
  196. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/system/route.js +2 -2
  197. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/system/route.js.nft.json +1 -1
  198. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js +1 -1
  199. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js.nft.json +1 -1
  200. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js +1 -1
  201. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js.nft.json +1 -1
  202. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  203. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route/app-paths-manifest.json +3 -0
  204. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route/build-manifest.json +9 -0
  205. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route/server-reference-manifest.json +4 -0
  206. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route.js +8 -0
  207. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route.js.map +5 -0
  208. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route.js.nft.json +1 -0
  209. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/vnc/route_client-reference-manifest.js +3 -0
  210. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/custody/page.js +1 -1
  211. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/custody/page.js.nft.json +1 -1
  212. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js +1 -1
  213. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  214. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js +1 -1
  215. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.nft.json +1 -1
  216. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js +1 -1
  217. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js.nft.json +1 -1
  218. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  219. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/system/page.js +1 -1
  220. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/system/page.js.nft.json +1 -1
  221. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js +4 -4
  222. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js.nft.json +1 -1
  223. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  224. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  225. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  226. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  227. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  228. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  229. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  230. package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +2 -0
  231. package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_boxes_[id]_vnc_route_actions_1cy1392.js +3 -0
  232. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_vnc_route_actions_10y_e83.js +3 -0
  233. package/runtime/hub/apps/hub/.next/server/chunks/{[externals]__1nj4awx._.js → [externals]__02a249v._.js} +2 -2
  234. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__00f9v4p._.js +1 -1
  235. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__01nppdu._.js +1 -1
  236. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__02f8rwr._.js +1 -1
  237. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__068_052._.js +1 -1
  238. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__06ma5m4._.js +3 -0
  239. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07kp2fu._.js +1 -1
  240. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1yi-2wa._.js → [root-of-the-server]__08u01ud._.js} +3 -3
  241. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__098bkh3._.js +3 -0
  242. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1hxo1tv._.js → [root-of-the-server]__09hbkgm._.js} +2 -2
  243. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__09tmbom._.js +3 -0
  244. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0_3m9sf._.js +1 -1
  245. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0aotdzg._.js +3 -0
  246. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0bn6-pu._.js +1 -1
  247. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0cpt9f9._.js +1 -1
  248. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +15 -15
  249. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0dom248._.js +1 -1
  250. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0f0bb7o._.js +1 -1
  251. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0gb04bp._.js +1 -1
  252. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0glplq7._.js +1 -1
  253. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0xrdbh9._.js → [root-of-the-server]__0gxfyol._.js} +2 -2
  254. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0hsb2ak._.js +1 -1
  255. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0joqm8t._.js +1 -1
  256. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0jp-895._.js +1 -1
  257. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1leda2s._.js → [root-of-the-server]__0jpqg_t._.js} +2 -2
  258. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__17bhgkz._.js → [root-of-the-server]__0lgnu00._.js} +2 -2
  259. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0lsv9-6._.js +1 -1
  260. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0pzgufc._.js +1 -1
  261. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0qfv7z6._.js +1 -1
  262. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0qlr61y._.js +1 -1
  263. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0s8srqi._.js +1 -1
  264. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0urn9j5._.js +1 -1
  265. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vb8mk2._.js +4 -0
  266. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__17w5eaa._.js → [root-of-the-server]__0x27ifo._.js} +2 -2
  267. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0y7rvy1._.js +1 -1
  268. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0zsgjre._.js +1 -1
  269. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-bqa8a._.js +1 -1
  270. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11uspjg._.js +1 -1
  271. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0zvr6ul._.js → [root-of-the-server]__15tgdh6._.js} +2 -2
  272. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1ek7nxv._.js → [root-of-the-server]__16bz_kz._.js} +2 -2
  273. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1w7jw4q._.js → [root-of-the-server]__18tehjj._.js} +2 -2
  274. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1ds8g0e._.js → [root-of-the-server]__1_hzv4s._.js} +2 -2
  275. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0cgpsh8._.js → [root-of-the-server]__1b5f5h4._.js} +2 -2
  276. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__10-aihp._.js → [root-of-the-server]__1dv80yf._.js} +2 -2
  277. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1eanlxn._.js +1 -1
  278. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__16lcb2d._.js → [root-of-the-server]__1fc-nvn._.js} +2 -2
  279. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4iahl._.js +1 -1
  280. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0f-c-eh._.js → [root-of-the-server]__1j0vnh3._.js} +2 -2
  281. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1lgrtx6._.js +1 -1
  282. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1unqgd7._.js → [root-of-the-server]__1lz7931._.js} +2 -2
  283. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1oclxlx._.js → [root-of-the-server]__1n3u6-5._.js} +2 -2
  284. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qky5cd._.js +1 -1
  285. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1r2quye._.js +3 -0
  286. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1rb_nc5._.js +1 -1
  287. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0cv16py._.js → [root-of-the-server]__1spr8ss._.js} +2 -2
  288. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1t_juqb._.js +1 -1
  289. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0t8kwy3._.js → [root-of-the-server]__1tct9rj._.js} +3 -3
  290. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0gfa1jg._.js → [root-of-the-server]__1tjtt06._.js} +2 -2
  291. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__09cigc7._.js → [root-of-the-server]__1whjno0._.js} +2 -2
  292. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1wn4-iv._.js +3 -0
  293. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1x6zxrf._.js +1 -1
  294. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__0tyixgg._.js → [root-of-the-server]__1xfxc6i._.js} +2 -2
  295. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1m1_gm_._.js → [root-of-the-server]__1xqcvi4._.js} +2 -2
  296. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__207d30i._.js +1 -1
  297. package/runtime/hub/apps/hub/.next/server/chunks/_07icdxf._.js +1 -1
  298. package/runtime/hub/apps/hub/.next/server/chunks/_0907rw0._.js +1 -1
  299. package/runtime/hub/apps/hub/.next/server/chunks/_0adm87k._.js +1 -1
  300. package/runtime/hub/apps/hub/.next/server/chunks/_0g01mkg._.js +1 -1
  301. package/runtime/hub/apps/hub/.next/server/chunks/_0l_klgd._.js +1 -1
  302. package/runtime/hub/apps/hub/.next/server/chunks/_0lfm81x._.js +1 -1
  303. package/runtime/hub/apps/hub/.next/server/chunks/_0tbg83f._.js +1 -1
  304. package/runtime/hub/apps/hub/.next/server/chunks/_0tms_au._.js +1 -1
  305. package/runtime/hub/apps/hub/.next/server/chunks/_0zhli27._.js +1 -1
  306. package/runtime/hub/apps/hub/.next/server/chunks/_10yfoq5._.js +1 -1
  307. package/runtime/hub/apps/hub/.next/server/chunks/_12uhpbp._.js +1 -1
  308. package/runtime/hub/apps/hub/.next/server/chunks/_17a9v8y._.js +2 -2
  309. package/runtime/hub/apps/hub/.next/server/chunks/_1c7x9ee._.js +1 -1
  310. package/runtime/hub/apps/hub/.next/server/chunks/_1n-c443._.js +1 -1
  311. package/runtime/hub/apps/hub/.next/server/chunks/_1y80vfg._.js +1 -1
  312. package/runtime/hub/apps/hub/.next/server/chunks/_214_q-1._.js +1 -1
  313. package/runtime/hub/apps/hub/.next/server/chunks/apps_hub_app_(dashboard)_api_v1_lib_openapi_ts_1yokmzt._.js +1 -1
  314. package/runtime/hub/apps/hub/.next/server/chunks/{packages_relay_dist_0eg7ay1._.js → packages_relay_dist_0p8dnf4._.js} +4 -4
  315. package/runtime/hub/apps/hub/.next/server/chunks/ssr/{[root-of-the-server]__1plrs94._.js → [root-of-the-server]__0-c5j6l._.js} +2 -2
  316. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0r2xlss._.js +1 -1
  317. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_19vy9ni._.js +2 -2
  318. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_[id]_page_tsx_1-j_972._.js +1 -1
  319. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_settings_page_tsx_0hv6n82._.js +1 -1
  320. package/runtime/hub/apps/hub/.next/server/chunks/ssr/{packages_relay_dist_1z9j3g0._.js → packages_relay_dist_0sap-2l._.js} +4 -4
  321. package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +3 -1
  322. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  323. package/runtime/hub/apps/hub/.next/server/middleware.js +1 -1
  324. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  325. package/runtime/hub/apps/hub/.next/static/chunks/{328ny-3zs_h7m.js → 0jefm3re1-2jv.js} +1 -1
  326. package/runtime/hub/apps/hub/.next/static/chunks/{30h8mz040b5-l.js → 3u4odx1_-dy6b.js} +1 -1
  327. package/runtime/hub/apps/hub/app/(dashboard)/api/v1/boxes/[id]/vnc/route.ts +45 -0
  328. package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/openapi.ts +45 -1
  329. package/runtime/hub/apps/hub/app/(dashboard)/api/v1/lib/validate.ts +14 -3
  330. package/runtime/hub/apps/hub/app/(dashboard)/boxes/[id]/vnc/route.ts +58 -0
  331. package/runtime/hub/apps/hub/app/(dashboard)/boxes/components/access.tsx +26 -9
  332. package/runtime/hub/apps/hub/app/(dashboard)/settings/components/provider-actions.tsx +34 -26
  333. package/runtime/hub/apps/hub/{auth-JMVHQKWY.js → auth-V7KPRWPS.js} +2 -2
  334. package/runtime/hub/apps/hub/{auth-config-5IFRWOK4.js → auth-config-B3Y3BT2I.js} +2 -2
  335. package/runtime/hub/apps/hub/{chunk-QU3FFGJY.js → chunk-2WB3A5IN.js} +11 -14
  336. package/runtime/hub/apps/hub/{chunk-LPYK2354.js → chunk-5ABFGGPT.js} +339 -21
  337. package/runtime/hub/apps/hub/{chunk-VKOCY6SX.js → chunk-BI4MPGQT.js} +49 -14
  338. package/runtime/hub/apps/hub/{chunk-UMPTTQBE.js → chunk-G6FJR7TN.js} +461 -251
  339. package/runtime/hub/apps/hub/{chunk-KTVETF3F.js → chunk-QGAP34GN.js} +11 -8
  340. package/runtime/hub/apps/hub/{chunk-5TM7XXLT.js → chunk-QWSP6WJ2.js} +2833 -1277
  341. package/runtime/hub/apps/hub/{chunk-EZUK53CC.js → chunk-RPPOFMPA.js} +85 -21
  342. package/runtime/hub/apps/hub/{chunk-3LAHFDJF.js → chunk-VWQNSZGI.js} +22 -2
  343. package/runtime/hub/apps/hub/{chunk-D33EV4YZ.js → chunk-ZP4RYI4U.js} +1 -1
  344. package/runtime/hub/apps/hub/{cloud-poller-SUNA6ZQC-VSKVMYHL.js → cloud-poller-QJRZXB4W-G7ECKNKQ.js} +1 -1
  345. package/runtime/hub/apps/hub/{dist-JVEDVVVG.js → dist-4F6XEJHK.js} +7 -7
  346. package/runtime/hub/apps/hub/{dist-2YP57GMB.js → dist-A3JOKKYG.js} +13 -13
  347. package/runtime/hub/apps/hub/{dist-D265LCAN.js → dist-CGH7PEMZ.js} +21 -3
  348. package/runtime/hub/apps/hub/{dist-SYWTB6RD.js → dist-F547YSBE.js} +15 -18
  349. package/runtime/hub/apps/hub/{dist-YK5FFPXZ.js → dist-FEHV4PC7.js} +62 -20
  350. package/runtime/hub/apps/hub/{dist-NKCXH5DW.js → dist-P7NT6VLK.js} +6 -6
  351. package/runtime/hub/apps/hub/{dist-E2FTSTCY.js → dist-W2YXTEQN.js} +34 -5
  352. package/runtime/hub/apps/hub/{dist-ELZHBQEM.js → dist-W5SGEJLA.js} +11 -11
  353. package/runtime/hub/apps/hub/{dist-N3E5YAYY.js → dist-YB3Y2XDK.js} +53 -26
  354. package/runtime/hub/apps/hub/{dist-5HTJSOHS.js → dist-ZTJMZLED.js} +19 -7
  355. package/runtime/hub/apps/hub/docker-compose.yml +1 -0
  356. package/runtime/hub/apps/hub/{hub-token-MDOBY7MZ.js → hub-token-DDJ5Z6RS.js} +2 -2
  357. package/runtime/hub/apps/hub/{hub-worker-UFFLF37F.js → hub-worker-I5QBLSRU.js} +16 -16
  358. package/runtime/hub/apps/hub/lib/boxes/backend-types.ts +11 -0
  359. package/runtime/hub/apps/hub/lib/boxes/types.ts +43 -0
  360. package/runtime/hub/apps/hub/lib/boxes/vnc-link.ts +51 -0
  361. package/runtime/hub/apps/hub/lib/hub-backend.ts +127 -54
  362. package/runtime/hub/apps/hub/lib/hub-worker.ts +4 -4
  363. package/runtime/hub/apps/hub/lib/provider-importers.ts +66 -1
  364. package/runtime/hub/apps/hub/{prepared-state-PV3GUBHO-PPRQDYFR.js → prepared-state-LNQ7DYSU-4I7FNNNS.js} +3 -2
  365. package/runtime/hub/apps/hub/server.js +130 -72
  366. package/runtime/hub/apps/hub/server.ts +18 -0
  367. package/runtime/hub/apps/hub/test/vnc-link.test.ts +61 -0
  368. package/runtime/hub/apps/hub/tsconfig.tsbuildinfo +1 -1
  369. package/runtime/hub-deploy/docker-compose.yml +1 -0
  370. package/runtime/relay/bin.cjs +16626 -14688
  371. package/runtime/vercel/agentbox-tool-shim +21 -0
  372. package/runtime/vercel/ctl.cjs +6760 -5299
  373. package/runtime/vercel/gh-shim +103 -228
  374. package/runtime/vercel/scripts/provision.sh +5 -9
  375. package/share/host-skills/agentbox-info/SKILL.md +24 -14
  376. package/dist/_cloud-attach-Y5HIQ373.js +0 -28
  377. package/dist/chunk-46NNZMZT.js.map +0 -1
  378. package/dist/chunk-74VIUGY6.js.map +0 -1
  379. package/dist/chunk-7RSE7ESY.js.map +0 -1
  380. package/dist/chunk-G3H2L3O2.js.map +0 -1
  381. package/dist/chunk-GFOWBXV7.js.map +0 -1
  382. package/dist/chunk-JDSYMTMS.js.map +0 -1
  383. package/dist/chunk-JNC7MCWJ.js.map +0 -1
  384. package/dist/chunk-JQLOGVZK.js.map +0 -1
  385. package/dist/chunk-KFLGXE3R.js.map +0 -1
  386. package/dist/chunk-KJ5TCYNI.js.map +0 -1
  387. package/dist/chunk-NHTRTST5.js.map +0 -1
  388. package/dist/chunk-NHVGKFVY.js.map +0 -1
  389. package/dist/chunk-OUF3YTQO.js.map +0 -1
  390. package/dist/chunk-OUWVN2F2.js.map +0 -1
  391. package/dist/chunk-OXKW4GWD.js.map +0 -1
  392. package/dist/chunk-PSA6GADQ.js.map +0 -1
  393. package/dist/chunk-WB6S4W7O.js.map +0 -1
  394. package/dist/chunk-YI4GHC2E.js.map +0 -1
  395. package/dist/dist-6PYXFREL.js.map +0 -1
  396. package/dist/dist-XQLKK7H3.js.map +0 -1
  397. package/dist/hub-MJ7O4WXW.js +0 -36
  398. package/dist/prepare-V4U5HVJU.js +0 -40
  399. package/dist/prepared-custody-QIXW7MJM.js +0 -35
  400. package/dist/relay-DRDELF6B.js +0 -20
  401. package/runtime/_shared/linear-shim +0 -181
  402. package/runtime/_shared/ntn-shim +0 -95
  403. package/runtime/digitalocean/linear-shim +0 -181
  404. package/runtime/digitalocean/ntn-shim +0 -95
  405. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -181
  406. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -95
  407. package/runtime/e2b/linear-shim +0 -181
  408. package/runtime/e2b/ntn-shim +0 -95
  409. package/runtime/hetzner/linear-shim +0 -181
  410. package/runtime/hetzner/ntn-shim +0 -95
  411. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__039tc0m._.js +0 -3
  412. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c_3x8u._.js +0 -3
  413. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ty7ew1._.js +0 -3
  414. package/runtime/vercel/linear-shim +0 -181
  415. package/runtime/vercel/ntn-shim +0 -95
  416. /package/dist/{_cloud-attach-Y5HIQ373.js.map → _cloud-attach-EUO2OL7W.js.map} +0 -0
  417. /package/dist/{chunk-V5NWSLWD.js.map → chunk-4NUETVTR.js.map} +0 -0
  418. /package/dist/{chunk-FGQFVUMH.js.map → chunk-6YSYQZRH.js.map} +0 -0
  419. /package/dist/{chunk-HYXCH4GA.js.map → chunk-7LC5IG5K.js.map} +0 -0
  420. /package/dist/{chunk-7ABO7OIF.js.map → chunk-AUHYXXCA.js.map} +0 -0
  421. /package/dist/{chunk-FPMRFMVK.js.map → chunk-B4YFG5TB.js.map} +0 -0
  422. /package/dist/{chunk-BWM56FKY.js.map → chunk-FEFLAITR.js.map} +0 -0
  423. /package/dist/{chunk-EVT2SNF2.js.map → chunk-FELVUIIM.js.map} +0 -0
  424. /package/dist/{chunk-BUMKBUXS.js.map → chunk-PAWAGULH.js.map} +0 -0
  425. /package/dist/{chunk-4PR3KJ5X.js.map → chunk-PFEBKXFD.js.map} +0 -0
  426. /package/dist/{chunk-B4DAH2F2.js.map → chunk-UTOC2NHC.js.map} +0 -0
  427. /package/dist/{cloud-poller-SUNA6ZQC-7M5LJHHE.js.map → cloud-poller-QJRZXB4W-LJ2BRB3L.js.map} +0 -0
  428. /package/dist/{control-plane-5R7PYRQ6.js.map → control-plane-YQFX2ILX.js.map} +0 -0
  429. /package/dist/{custody-client-PNCC2HBJ.js.map → custody-client-L4FEFW4C.js.map} +0 -0
  430. /package/dist/{deploy-hetzner-SSGSXAKA.js.map → deploy-hetzner-EECQ4JCM.js.map} +0 -0
  431. /package/dist/{dist-5OR4QTQW.js.map → dist-3BKIPZR3.js.map} +0 -0
  432. /package/dist/{dist-EPFS5PRI.js.map → dist-C5B6NGBO.js.map} +0 -0
  433. /package/dist/{dist-K5M4HKG7.js.map → dist-FBM2WS5S.js.map} +0 -0
  434. /package/dist/{dist-M4O5MU5K.js.map → dist-NTUHJOK3.js.map} +0 -0
  435. /package/dist/{dist-POILUDVJ.js.map → dist-PTYASENV.js.map} +0 -0
  436. /package/dist/{dist-RN6JOAG4.js.map → dist-Q4UDCSZQ.js.map} +0 -0
  437. /package/dist/{dist-SN2TCRZ5.js.map → dist-TXFTYNNE.js.map} +0 -0
  438. /package/dist/{dist-XATN4ZIR.js.map → dist-XUOHE22G.js.map} +0 -0
  439. /package/dist/{dist-ZNQZHTUN.js.map → dist-Z2TPC3EN.js.map} +0 -0
  440. /package/dist/{hub-MJ7O4WXW.js.map → host-reach-drainer-N4JSFUBY.js.map} +0 -0
  441. /package/dist/{hub-adopt-I44VGSBL.js.map → hub-3HPYOV5O.js.map} +0 -0
  442. /package/dist/{hub-api-client-WJPBXZAZ.js.map → hub-adopt-NCCCMMXL.js.map} +0 -0
  443. /package/dist/{prepare-V4U5HVJU.js.map → hub-api-client-5U6WOTZ3.js.map} +0 -0
  444. /package/dist/{hub-docker-target-REEEWUG2.js.map → hub-docker-target-ZKAWXVPH.js.map} +0 -0
  445. /package/dist/{prepared-custody-QIXW7MJM.js.map → prepare-KIVDQRMN.js.map} +0 -0
  446. /package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js.map → prepared-custody-EFSOOAIQ.js.map} +0 -0
  447. /package/dist/{relay-DRDELF6B.js.map → prepared-state-LNQ7DYSU-2YFSDOCV.js.map} +0 -0
  448. /package/dist/{publish-credentials-BPHUO5VL.js.map → publish-credentials-F2A5OVCO.js.map} +0 -0
  449. /package/dist/{remote-docker-share-RX5ARK45.js.map → registry-O3X2CDDU.js.map} +0 -0
  450. /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → nDHi_1342DzyGDC14ocQo}/_buildManifest.js +0 -0
  451. /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → nDHi_1342DzyGDC14ocQo}/_clientMiddlewareManifest.js +0 -0
  452. /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → nDHi_1342DzyGDC14ocQo}/_ssgManifest.js +0 -0
@@ -9,9 +9,9 @@ import {
9
9
  registryRefForSha,
10
10
  resolveContextFilesFrom,
11
11
  writePreparedStateRaw
12
- } from "./chunk-GFOWBXV7.js";
12
+ } from "./chunk-XENTK32L.js";
13
13
 
14
- // ../../packages/sandbox-docker/dist/chunk-SZLROWLB.js
14
+ // ../../packages/sandbox-docker/dist/chunk-EAAMZ4OS.js
15
15
  import { dirname as dirname2, resolve as resolve2 } from "path";
16
16
  import { fileURLToPath as fileURLToPath2 } from "url";
17
17
  import { execa as execa2 } from "execa";
@@ -58,10 +58,13 @@ var realRunner = async (file, args, opts) => {
58
58
  };
59
59
  async function loginToGhcrWithGh(opts = {}) {
60
60
  const run = opts.run ?? realRunner;
61
- const tok = await run("gh", ["auth", "token"]);
61
+ const tok = await run("gh", ["auth", "token", "--hostname", "github.com"]);
62
62
  const token = tok.stdout.trim();
63
63
  if (tok.exitCode !== 0 || token.length === 0) {
64
- return { ok: false, reason: "no `gh` token on this machine (run `gh auth login`)" };
64
+ return {
65
+ ok: false,
66
+ reason: "no github.com `gh` token on this machine (run `gh auth login --hostname github.com`)"
67
+ };
65
68
  }
66
69
  const scopes = await (opts.fetchScopes ?? fetchTokenScopes)(token);
67
70
  if (scopes.length > 0 && !scopes.includes(PACKAGE_READ_SCOPE)) {
@@ -96,7 +99,7 @@ async function fetchTokenScopes(token) {
96
99
  var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
97
100
  async function resolveClaudeInstallMode() {
98
101
  try {
99
- const { loadEffectiveConfig } = await import("./dist-XATN4ZIR.js");
102
+ const { loadEffectiveConfig } = await import("./dist-FBM2WS5S.js");
100
103
  const cfg = await loadEffectiveConfig(process.cwd());
101
104
  return cfg.effective.box.claudeInstall;
102
105
  } catch {
@@ -211,7 +214,7 @@ async function buildImage(opts = {}) {
211
214
  return ref;
212
215
  }
213
216
  async function pullOrBuild(ref, fingerprint, opts = {}) {
214
- const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-PV3GUBHO-MF56HWMZ.js");
217
+ const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-LNQ7DYSU-2YFSDOCV.js");
215
218
  const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
216
219
  const allowPull = opts.allowPull !== false;
217
220
  if (allowPull && registry && fingerprint) {
@@ -264,7 +267,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
264
267
  return { source: "built" };
265
268
  }
266
269
  async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
267
- const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-PV3GUBHO-MF56HWMZ.js");
270
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-LNQ7DYSU-2YFSDOCV.js");
268
271
  const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
269
272
  const rawFingerprint = await computeDockerContextFingerprint2({
270
273
  contextDir: opts.contextDir
@@ -318,7 +321,7 @@ function classifyDockerBaseFreshness(input) {
318
321
  return { state: "fresh" };
319
322
  }
320
323
  async function evaluateDockerBaseFreshness(opts = {}) {
321
- const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-PV3GUBHO-MF56HWMZ.js");
324
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-LNQ7DYSU-2YFSDOCV.js");
322
325
  const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
323
326
  const imagePresent = await imageExists(ref);
324
327
  if (!imagePresent) return { state: "unprepared" };
@@ -405,4 +408,4 @@ export {
405
408
  writePreparedDockerState,
406
409
  preparedMatches
407
410
  };
408
- //# sourceMappingURL=chunk-CKD3PRON.js.map
411
+ //# sourceMappingURL=chunk-CZPVVFCF.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/sandbox-docker/src/prepared-state.ts","../../../packages/sandbox-docker/src/image.ts","../../../packages/sandbox-docker/src/registry-auth.ts"],"sourcesContent":["/**\n * Docker provider's `~/.agentbox/docker-prepared.json` reader/writer + the\n * build-context fingerprint that drives base-image invalidation.\n *\n * The fingerprint is a SHA-256 over every file `docker build` would COPY\n * into the image — Dockerfile + scripts + baked config files. Two CLIs\n * with identical staged runtime trees produce the same hash; a one-byte\n * edit to any baked asset flips it, which is the signal `ensureImage()`\n * uses to rebuild instead of reusing the cached image.\n */\n\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n computeContextManifest,\n DOCKER_CONTEXT_FILE_MAP,\n readCliStamp,\n readPreparedStateRaw,\n resolveContextFilesFrom,\n writePreparedStateRaw,\n type ContextFile,\n type FileManifest,\n type PreparedBaseSnapshot,\n} from '@agentbox/sandbox-core';\nimport { BUILD_CONTEXT_DIR, DEFAULT_BOX_IMAGE, DOCKERFILE_PATH } from './image.js';\n\nconst SCHEMA = 1 as const;\n\nexport type PreparedDockerState = PreparedBaseSnapshot<string, never>;\n\n/**\n * Resolve every fingerprint input to an absolute path. The canonical file\n * list lives in `@agentbox/sandbox-core` (DOCKER_CONTEXT_FILE_MAP) so the\n * daytona provider can hash the same inputs without depending on this\n * package. Two layouts are tried in order, mirroring `resolveDockerBuild()`\n * in `image.ts`:\n * 1. Build context dir (staged runtime / env override).\n * 2. Sandbox-docker package root (dev fallback).\n *\n * Returns `null` when *any* required file is missing — callers treat that\n * as \"can't fingerprint\" and skip the cache-hit shortcut (always rebuild).\n */\nexport function resolveContextFiles(opts: { contextDir?: string } = {}): ContextFile[] | null {\n const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;\n const here = dirname(fileURLToPath(import.meta.url));\n // sandbox-docker's package root = parent of src/ or parent of dist/.\n const packageRoot = resolve(here, '..');\n return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {\n contextDir: ctx,\n devRoot: packageRoot,\n });\n}\n\nexport interface ResolvedFingerprint {\n contextSha256: string;\n /** Files that fed the hash (in canonical sorted order). */\n files: ContextFile[];\n /** Per-file digests, recorded at bake time so a later `stale` can be explained. */\n manifest: FileManifest;\n}\n\nexport async function computeDockerContextFingerprint(\n opts: {\n contextDir?: string;\n } = {},\n): Promise<ResolvedFingerprint | null> {\n const files = resolveContextFiles(opts);\n if (!files) return null;\n const m = await computeContextManifest(files);\n return { contextSha256: m.contextSha256, files, manifest: m.files };\n}\n\n/**\n * The per-file digests of the CURRENT docker build context, for diffing against\n * a baked manifest. Returns undefined when the context can't be resolved (a dev\n * tree with no staged runtime) — the caller then has nothing to compare and must\n * not claim a diff.\n */\nexport async function currentDockerBaseFileHashes(): Promise<FileManifest | undefined> {\n try {\n const files = resolveContextFiles();\n if (!files) return undefined;\n return (await computeContextManifest(files)).files;\n } catch {\n return undefined;\n }\n}\n\nexport function readPreparedDockerState(): PreparedDockerState | null {\n const raw = readPreparedStateRaw('docker');\n if (raw === null || typeof raw !== 'object') return null;\n const parsed = raw as Partial<PreparedDockerState>;\n if (parsed.schema !== SCHEMA) return null;\n return { schema: SCHEMA, base: parsed.base };\n}\n\nexport function writePreparedDockerState(opts: {\n imageRef?: string;\n contextSha256: string;\n /** Per-file digests of the context this image was built from, when known. */\n files?: FileManifest;\n}): void {\n const stamp = readCliStamp();\n const state: PreparedDockerState = {\n schema: SCHEMA,\n base: {\n imageRef: opts.imageRef ?? DEFAULT_BOX_IMAGE,\n contextSha256: opts.contextSha256,\n cliVersion: stamp.cliVersion,\n cliCommit: stamp.cliCommit,\n createdAt: new Date().toISOString(),\n ...(opts.files ? { files: opts.files } : {}),\n },\n };\n writePreparedStateRaw('docker', state);\n}\n\n/** Convenience for `ensureImage` and `prepare` — true when the stamped fingerprint matches. */\nexport function preparedMatches(state: PreparedDockerState | null, current: string): boolean {\n return state?.base?.contextSha256 === current;\n}\n\n/** Re-export so callers don't reach into image.ts just for the Dockerfile path. */\nexport { DOCKERFILE_PATH };\n","import { execa } from 'execa';\nimport {\n classifyPullFailure,\n isAuthRetryable,\n isGhcrTarget,\n loginToGhcrWithGh,\n type PullFailure,\n} from './registry-auth.js';\nimport { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, resolve } from 'node:path';\nimport {\n BOX_IMAGE_REGISTRY,\n claudeInstallFingerprint,\n registryRefForSha,\n type FileManifest,\n} from '@agentbox/sandbox-core';\n\nexport const DEFAULT_BOX_IMAGE = 'agentbox/box:dev';\n\n/**\n * Resolve the effective `box.claudeInstall` for the current project. Docker\n * builds its image lazily at create time, so every `ensureImage` path must\n * agree on the mode or a native rebuild would clobber an npm-baked image (and\n * vice-versa). Lazy-imported to keep the module load cheap; falls back to\n * `native` if config can't be read.\n */\nasync function resolveClaudeInstallMode(): Promise<'native' | 'npm'> {\n try {\n const { loadEffectiveConfig } = await import('@agentbox/config');\n const cfg = await loadEffectiveConfig(process.cwd());\n return cfg.effective.box.claudeInstall;\n } catch {\n return 'native';\n }\n}\n\n// The registry ref lives in @agentbox/sandbox-core: daytona's linux-vm bake\n// needs it too (a VM snapshot can only be built from a prebuilt registry image),\n// and importing it from here would drag execa into that import graph. Re-exported\n// so existing `@agentbox/sandbox-docker` consumers keep working.\nexport { BOX_IMAGE_REGISTRY, registryRefForSha };\n\nconst here = dirname(fileURLToPath(import.meta.url));\n\n// The Dockerfile's COPY lines reference monorepo-relative paths\n// (packages/ctl/dist/bin.cjs, apps/cli/share/..., packages/sandbox-docker/scripts/*),\n// so the build context must be a dir containing that tree.\n//\n// Resolution order:\n// 0. AGENTBOX_DOCKER_CONTEXT env override (dir holding Dockerfile.box).\n// 1. Staged context shipped with the bundled `agent-box` package: this\n// module is bundled into the CLI at <root>/dist, the stage step mirrors\n// the COPY tree at <root>/runtime/docker (sibling of dist/, uniform in\n// dev and when installed).\n// 2. Legacy monorepo: Dockerfile.box at the sandbox-docker package root,\n// build context = monorepo root.\nfunction resolveDockerBuild(): { dockerfile: string; context: string } {\n const override = process.env.AGENTBOX_DOCKER_CONTEXT;\n if (override && existsSync(resolve(override, 'Dockerfile.box'))) {\n return { dockerfile: resolve(override, 'Dockerfile.box'), context: override };\n }\n const staged = resolve(here, '..', 'runtime', 'docker');\n if (existsSync(resolve(staged, 'Dockerfile.box'))) {\n return { dockerfile: resolve(staged, 'Dockerfile.box'), context: staged };\n }\n // Legacy: src/ (or the unbundled package dist/) is one level under the\n // package root; the monorepo root is two more up.\n const packageRoot = resolve(here, '..');\n return {\n dockerfile: resolve(packageRoot, 'Dockerfile.box'),\n context: resolve(packageRoot, '..', '..'),\n };\n}\n\nconst { dockerfile: DOCKERFILE_PATH_RESOLVED, context: BUILD_CONTEXT_DIR_RESOLVED } =\n resolveDockerBuild();\nexport const DOCKERFILE_PATH = DOCKERFILE_PATH_RESOLVED;\nexport const BUILD_CONTEXT_DIR = BUILD_CONTEXT_DIR_RESOLVED;\n\nexport async function imageExists(ref: string): Promise<boolean> {\n const result = await execa('docker', ['image', 'inspect', ref], { reject: false });\n return result.exitCode === 0;\n}\n\n/**\n * Attempt `docker pull <target>`. Never throws.\n *\n * Reports WHY it failed, not just that it did: a rate-limited pull, a rejected\n * credential and an unpublished tag all exit 1, but only the first two can be\n * fixed by authenticating and only the third means \"build locally\". Returning a\n * bare boolean here is what made a throttled pull look identical to a missing\n * image — a silent ~10-minute rebuild of an image that was in the registry.\n */\nexport async function pullImage(\n target: string,\n opts: { onProgress?: (line: string) => void } = {},\n): Promise<{ ok: boolean; failure?: PullFailure }> {\n const subprocess = execa('docker', ['pull', target], {\n stderr: 'pipe',\n stdout: 'pipe',\n reject: false,\n });\n // Kept so a failure can be classified; docker writes the real reason to stderr.\n let stderrText = '';\n // Always capture stderr, even with no onProgress — the classification below\n // needs it regardless of whether anyone is watching the progress stream.\n subprocess.stderr?.on('data', (chunk: Buffer | string) => {\n stderrText += typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n });\n let heartbeat: NodeJS.Timeout | undefined;\n if (opts.onProgress) {\n let lastLineAt = Date.now();\n const forward = (chunk: Buffer | string): void => {\n lastLineAt = Date.now();\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n // Piped (non-TTY) `docker pull` prints nothing between the last\n // \"Download complete\" and each \"Pull complete\" — the entire extraction\n // phase is silent, which for a multi-GB image reads as a hang. Emit a\n // keepalive so the create spinner keeps moving.\n heartbeat = setInterval(() => {\n if (Date.now() - lastLineAt >= 20_000) {\n opts.onProgress?.(`still extracting ${target} — large layers can take a few minutes`);\n }\n }, 20_000);\n }\n try {\n const result = await subprocess;\n if (result.exitCode === 0) return { ok: true };\n return { ok: false, failure: classifyPullFailure(stderrText || (result.stderr ?? '')) };\n } finally {\n if (heartbeat) clearInterval(heartbeat);\n }\n}\n\nexport async function tagImage(source: string, target: string): Promise<void> {\n await execa('docker', ['tag', source, target]);\n}\n\nexport interface ImageInfo {\n /** Image ref (e.g. `agentbox/box:dev`). */\n ref: string;\n /** True when the engine has the image locally. */\n exists: boolean;\n /** Image size in bytes, when known. */\n sizeBytes?: number;\n /** ISO-8601 creation time, when known. */\n createdAt?: string;\n}\n\n/**\n * Read-only inspect of a Docker image. Used by `agentbox prepare` (no-args\n * status mode) to surface base-image state. Never throws — returns\n * `{ exists: false }` on any error so the status command works even when\n * the docker daemon is unreachable.\n */\nexport async function imageInfo(ref: string = DEFAULT_BOX_IMAGE): Promise<ImageInfo> {\n const result = await execa(\n 'docker',\n ['image', 'inspect', '--format', '{{.Size}}|{{.Created}}', ref],\n { reject: false },\n );\n if (result.exitCode !== 0) return { ref, exists: false };\n const [sizeStr, createdAt] = result.stdout.trim().split('|');\n const sizeBytes = sizeStr ? Number.parseInt(sizeStr, 10) : NaN;\n return {\n ref,\n exists: true,\n sizeBytes: Number.isFinite(sizeBytes) ? sizeBytes : undefined,\n createdAt: createdAt && createdAt.length > 0 ? createdAt : undefined,\n };\n}\n\nexport interface BuildImageOptions {\n ref?: string;\n dockerfile?: string;\n contextDir?: string;\n /** `--build-arg K=V` pairs forwarded to `docker build` (e.g. AGENTBOX_CLAUDE_INSTALL). */\n buildArgs?: Record<string, string>;\n onProgress?: (line: string) => void;\n}\n\nexport async function buildImage(opts: BuildImageOptions = {}): Promise<string> {\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const dockerfile = opts.dockerfile ?? DOCKERFILE_PATH;\n const contextDir = opts.contextDir ?? BUILD_CONTEXT_DIR;\n\n // Dogfood path: when building from inside an agentbox (docker-in-docker),\n // the default bridge network can't bind-mount /proc/<pid>/ns/net for the\n // build container, breaking any RUN that needs network (e.g. apt, curl).\n // Falling back to host networking sidesteps the missing capability.\n const args = ['build', '-t', ref, '-f', dockerfile];\n for (const [k, v] of Object.entries(opts.buildArgs ?? {})) {\n args.push('--build-arg', `${k}=${v}`);\n }\n args.push(contextDir);\n if (process.env.AGENTBOX === '1') {\n args.splice(1, 0, '--network=host');\n }\n\n const subprocess = execa('docker', args, {\n stderr: 'pipe',\n stdout: 'pipe',\n });\n\n if (opts.onProgress) {\n const forward = (chunk: Buffer | string): void => {\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n }\n\n await subprocess;\n return ref;\n}\n\nexport interface PullOrBuildOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the staged runtime / monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /** `--build-arg K=V` pairs forwarded to the local `docker build` (ignored on a registry pull). */\n buildArgs?: Record<string, string>;\n}\n\n/**\n * Make `ref` present locally, preferring a registry pull over a local build.\n *\n * When `fingerprint` is non-null and pulling is allowed, pull the\n * fingerprint-tagged image and retag it to `ref`; on a miss (or when pulling\n * is disabled / unfingerprintable) build from the staged context. Either way,\n * a known fingerprint is stamped into docker-prepared.json so the next\n * `ensureImage()` treats this as a cache hit.\n */\nexport async function pullOrBuild(\n ref: string,\n fingerprint: { contextSha256: string; manifest?: FileManifest } | null,\n opts: PullOrBuildOptions = {},\n): Promise<{ source: 'pulled' | 'built' }> {\n const { writePreparedDockerState } = await import('./prepared-state.js');\n const registry = opts.registry ?? BOX_IMAGE_REGISTRY;\n const allowPull = opts.allowPull !== false;\n\n if (allowPull && registry && fingerprint) {\n const target = registryRefForSha(fingerprint.contextSha256, registry);\n const succeed = async (): Promise<{ source: 'pulled' }> => {\n await tagImage(target, ref);\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n opts.onProgress?.(`[image] pulled ${target} -> ${ref}`);\n return { source: 'pulled' };\n };\n\n opts.onProgress?.(`[image] pulling ${target}`);\n const first = await pullImage(target, { onProgress: opts.onProgress });\n if (first.ok) return succeed();\n\n const failure = first.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] pull failed (${failure.kind}): ${failure.detail}`);\n\n // A throttle or a credential problem is not a missing image: the tag is\n // there and an authenticated pull gets it. GHCR's anonymous limit is per-IP\n // and a machine that just baked a few times trips it, so borrowing the\n // host's `gh` token here is the difference between a retag and a ~10-minute\n // rebuild of an image that was already published.\n if (isAuthRetryable(failure.kind) && isGhcrTarget(target)) {\n opts.onProgress?.('[image] retrying authenticated with your `gh` token');\n const login = await loginToGhcrWithGh();\n if (login.ok) {\n const second = await pullImage(target, { onProgress: opts.onProgress });\n if (second.ok) return succeed();\n const f2 = second.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] authenticated pull also failed (${f2.kind}): ${f2.detail}`);\n } else {\n opts.onProgress?.(\n `[image] could not authenticate to ghcr.io: ${login.reason ?? 'unknown'}`,\n );\n }\n }\n\n opts.onProgress?.(`[image] building ${ref} locally instead`);\n }\n\n await buildImage({\n ref,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n buildArgs: opts.buildArgs,\n onProgress: opts.onProgress,\n });\n if (fingerprint) {\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n }\n return { source: 'built' };\n}\n\nexport interface EnsureImageOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /**\n * How Claude Code is installed into the image. Folded into the build-context\n * fingerprint so a mode switch rebuilds (and an npm image isn't clobbered by\n * a native rebuild). Defaults to the resolved `box.claudeInstall`.\n */\n claudeInstall?: 'native' | 'npm';\n}\n\nexport async function ensureImage(\n ref: string = DEFAULT_BOX_IMAGE,\n opts: EnsureImageOptions = {},\n): Promise<{ ref: string; built: boolean; reason?: string }> {\n // Lazy import: prepared-state imports back into image.ts for the default\n // DOCKERFILE_PATH/BUILD_CONTEXT_DIR constants, so loading it at top-level\n // would create a circular ESM init order.\n const { computeDockerContextFingerprint, readPreparedDockerState, preparedMatches } =\n await import('./prepared-state.js');\n\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const rawFingerprint = await computeDockerContextFingerprint({\n contextDir: opts.contextDir,\n });\n // Fold the install mode into the sha so native↔npm are distinct cache\n // identities (`native` leaves the hash unchanged).\n const fingerprint = rawFingerprint\n ? {\n ...rawFingerprint,\n contextSha256: claudeInstallFingerprint(rawFingerprint.contextSha256, claudeInstall),\n }\n : null;\n const prepared = readPreparedDockerState();\n const exists = await imageExists(ref);\n\n let reason: string | undefined;\n if (!exists) {\n reason = `image ${ref} not present`;\n } else if (!fingerprint) {\n // Couldn't enumerate the context (partial dev rebuild?). Don't rebuild\n // unconditionally — that would surprise users mid-iteration. Trust the\n // image-exists check and leave the prepared file untouched.\n return { ref, built: false, reason: 'image present (fingerprint skipped)' };\n } else if (!prepared) {\n reason = 'no docker-prepared.json on disk';\n } else if (!preparedMatches(prepared, fingerprint.contextSha256)) {\n reason =\n `build context changed (was ${prepared.base?.contextSha256?.slice(0, 12) ?? '<none>'}, ` +\n `now ${fingerprint.contextSha256.slice(0, 12)})`;\n }\n\n if (!reason) {\n return { ref, built: false, reason: 'image up to date' };\n }\n\n opts.onProgress?.(`[image] ${ref}: ${reason}`);\n const npm = claudeInstall === 'npm';\n const { source } = await pullOrBuild(ref, fingerprint, {\n onProgress: opts.onProgress,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n // npm mode pulls too. CI publishes both install variants, and `fingerprint`\n // is already folded with the mode above — so the pull asks for the npm\n // image's own tag and hits. (It used to be native-only, which meant npm\n // users rebuilt the image locally on every first create, forever.) A tag\n // that genuinely isn't published still falls back to a local build.\n allowPull: opts.allowPull,\n registry: opts.registry,\n buildArgs: npm ? { AGENTBOX_CLAUDE_INSTALL: 'npm' } : undefined,\n });\n return { ref, built: source === 'built', reason };\n}\n\n/**\n * Read-only freshness classification of the docker base image, for surfaces\n * (hub API, tray) that want to announce an upcoming bake without triggering\n * it. `unknown` means \"couldn't fingerprint\" and MUST stay inert — the\n * matching `ensureImage` path trusts the existing image and does not rebuild.\n */\nexport type DockerBaseFreshness =\n | { state: 'fresh' }\n | { state: 'unknown' }\n | { state: 'unprepared' }\n | { state: 'stale'; reason: string };\n\n/**\n * Pure decision core shared by `evaluateDockerBaseFreshness`. Mirrors\n * `ensureImage`'s rebuild predicate exactly — if the two ever disagree, the\n * freshness surfaces would announce a bake that create then skips (or miss\n * one it performs). `stampedSha` is `docker-prepared.json`'s fingerprint,\n * null when the stamp is missing/invalid.\n */\nexport function classifyDockerBaseFreshness(input: {\n imagePresent: boolean;\n fingerprint: string | null;\n stampedSha: string | null;\n}): DockerBaseFreshness {\n if (!input.imagePresent) return { state: 'unprepared' };\n if (!input.fingerprint) return { state: 'unknown' };\n if (!input.stampedSha) return { state: 'stale', reason: 'no docker-prepared.json on disk' };\n if (input.stampedSha !== input.fingerprint) {\n return {\n state: 'stale',\n reason:\n `build context changed (was ${input.stampedSha.slice(0, 12)}, ` +\n `now ${input.fingerprint.slice(0, 12)})`,\n };\n }\n return { state: 'fresh' };\n}\n\n/**\n * Cheap live check: would `ensureImage` bake on the next create? The only\n * docker work is one `docker image inspect`; the rest hashes the ~15 build\n * context files. Never builds, pulls, or writes the prepared stamp.\n */\nexport async function evaluateDockerBaseFreshness(\n opts: { ref?: string; claudeInstall?: 'native' | 'npm'; contextDir?: string } = {},\n): Promise<DockerBaseFreshness> {\n // Lazy import for the same circular-init reason as in ensureImage above.\n const { computeDockerContextFingerprint, readPreparedDockerState } =\n await import('./prepared-state.js');\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const imagePresent = await imageExists(ref);\n if (!imagePresent) return { state: 'unprepared' };\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const raw = await computeDockerContextFingerprint({ contextDir: opts.contextDir });\n return classifyDockerBaseFreshness({\n imagePresent,\n fingerprint: raw ? claudeInstallFingerprint(raw.contextSha256, claudeInstall) : null,\n stampedSha: readPreparedDockerState()?.base?.contextSha256 ?? null,\n });\n}\n","/**\n * Why a `docker pull` of the box image failed, and how to retry it authenticated.\n *\n * The box image is published to a PUBLIC GHCR repo, so an anonymous pull works —\n * until it doesn't. GHCR rate-limits anonymous pulls per IP, and a machine that\n * has just baked a few times trips it. `docker pull` then exits non-zero and the\n * caller falls back to a ~10-minute local build of an image that was sitting in\n * the registry all along. Worse, the old code returned a bare boolean, so a\n * rate-limit, a 401 and a genuinely-unpublished tag were indistinguishable and\n * none of them reached the log.\n *\n * So: classify the failure, and when it is a throttle/auth problem on GHCR,\n * borrow the host's `gh` token and retry once.\n *\n * The load-bearing subtlety is the SCOPE. `gh auth token` returns whatever the\n * user's `gh auth login` negotiated — by default `repo`, `read:org`, `gist`,\n * `workflow` and *not* `read:packages`. Logging in to GHCR with such a token is\n * actively worse than staying anonymous: the registry then evaluates an\n * identity that lacks package-read and answers 403, turning a pull that would\n * have succeeded into one that cannot. So we check the scope first and skip the\n * login when it is absent, telling the user the one command that fixes it.\n */\nimport { execa } from 'execa';\n\n/** GHCR is the only registry we know how to authenticate from `gh`. */\nexport const GHCR_HOST = 'ghcr.io';\n\n/** The scope GHCR requires to read a package, public or not. */\nconst PACKAGE_READ_SCOPE = 'read:packages';\n\nexport type PullFailureKind =\n /** GHCR throttled us — the tag exists and an authenticated retry should work. */\n | 'rate-limit'\n /** Credentials rejected or absent where required. */\n | 'unauthorized'\n /** The tag genuinely is not published — a local build is the correct answer. */\n | 'not-found'\n /** DNS / TCP / TLS — nothing to do with the tag. */\n | 'network'\n | 'unknown';\n\nexport interface PullFailure {\n kind: PullFailureKind;\n /** The most useful line of docker's own stderr, for the log. */\n detail: string;\n}\n\n/**\n * Map `docker pull` stderr onto a {@link PullFailureKind}. Substring matching on\n * docker/registry error text rather than exit codes, which are always 1.\n */\nexport function classifyPullFailure(stderr: string): PullFailure {\n const text = stderr.toLowerCase();\n const detail = lastMeaningfulLine(stderr);\n // Order matters: a throttle response also says \"unauthorized\" on some\n // registries, and it is the throttle that decides whether a retry can help.\n if (\n text.includes('toomanyrequests') ||\n text.includes('too many requests') ||\n text.includes('429')\n ) {\n return { kind: 'rate-limit', detail };\n }\n if (\n text.includes('manifest unknown') ||\n text.includes('not found') ||\n text.includes('404') ||\n text.includes('no such manifest')\n ) {\n return { kind: 'not-found', detail };\n }\n if (\n text.includes('unauthorized') ||\n text.includes('authentication required') ||\n text.includes('denied') ||\n text.includes('403')\n ) {\n return { kind: 'unauthorized', detail };\n }\n if (\n text.includes('dial tcp') ||\n text.includes('no such host') ||\n text.includes('timeout') ||\n text.includes('temporary failure in name resolution') ||\n text.includes('connection refused') ||\n text.includes('tls handshake')\n ) {\n return { kind: 'network', detail };\n }\n return { kind: 'unknown', detail };\n}\n\n/** The last non-empty stderr line, trimmed — docker puts the real error last. */\nfunction lastMeaningfulLine(stderr: string): string {\n const lines = stderr\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .filter((l) => l.length > 0);\n return lines.length > 0 ? lines[lines.length - 1]! : 'no error output from docker';\n}\n\n/** Only a throttle or a credential problem can be improved by authenticating. */\nexport function isAuthRetryable(kind: PullFailureKind): boolean {\n return kind === 'rate-limit' || kind === 'unauthorized';\n}\n\n/** True when `target` lives on GHCR, the only host we can log into from `gh`. */\nexport function isGhcrTarget(target: string): boolean {\n return target.startsWith(`${GHCR_HOST}/`);\n}\n\nexport interface GhcrLoginResult {\n ok: boolean;\n /** Why we did not (or could not) log in — always safe to show the user. */\n reason?: string;\n}\n\ninterface Runner {\n (\n file: string,\n args: string[],\n opts?: { input?: string },\n ): Promise<{\n exitCode: number | undefined;\n stdout: string;\n stderr: string;\n }>;\n}\n\nconst realRunner: Runner = async (file, args, opts) => {\n const r = await execa(file, args, {\n reject: false,\n timeout: 30_000,\n ...(opts?.input !== undefined ? { input: opts.input } : {}),\n });\n return { exitCode: r.exitCode, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };\n};\n\n/**\n * Log the local docker engine into GHCR using the host's `gh` token, so the\n * retry is authenticated (and rate-limited far more generously).\n *\n * Refuses rather than risks it when the token lacks `read:packages` — see the\n * module comment. `fetchScopes` is injected so this is testable without network.\n */\nexport async function loginToGhcrWithGh(\n opts: {\n run?: Runner;\n fetchScopes?: (token: string) => Promise<string[]>;\n } = {},\n): Promise<GhcrLoginResult> {\n const run = opts.run ?? realRunner;\n\n const tok = await run('gh', ['auth', 'token']);\n const token = tok.stdout.trim();\n if (tok.exitCode !== 0 || token.length === 0) {\n return { ok: false, reason: 'no `gh` token on this machine (run `gh auth login`)' };\n }\n\n const scopes = await (opts.fetchScopes ?? fetchTokenScopes)(token);\n // An empty list means we could not read the header (offline, or a fine-grained\n // token that reports no classic scopes). Attempting the login is then the\n // lesser evil: a fine-grained PAT with package-read is a normal setup, and a\n // failed login leaves us exactly where we already are.\n if (scopes.length > 0 && !scopes.includes(PACKAGE_READ_SCOPE)) {\n return {\n ok: false,\n reason:\n `your \\`gh\\` token lacks the ${PACKAGE_READ_SCOPE} scope, so authenticating would be ` +\n `rejected by ${GHCR_HOST}. Add it with: gh auth refresh -h github.com -s ${PACKAGE_READ_SCOPE}`,\n };\n }\n\n // GHCR ignores the username when the password is a valid token, but docker\n // requires a non-empty one.\n const login = await run('docker', ['login', GHCR_HOST, '-u', 'agentbox', '--password-stdin'], {\n input: token,\n });\n if (login.exitCode !== 0) {\n return { ok: false, reason: lastMeaningfulLine(login.stderr || login.stdout) };\n }\n return { ok: true };\n}\n\n/** Classic OAuth scopes for `token`, from GitHub's `x-oauth-scopes` header. */\nasync function fetchTokenScopes(token: string): Promise<string[]> {\n try {\n const res = await fetch('https://api.github.com/user', {\n headers: {\n Authorization: `Bearer ${token}`,\n Accept: 'application/vnd.github+json',\n 'User-Agent': 'agentbox',\n },\n signal: AbortSignal.timeout(10_000),\n });\n return (res.headers.get('x-oauth-scopes') ?? '')\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,SAAS,WAAAA,UAAS,WAAAC,g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QAAOC,SAAQC,eAAc,YAAY,GAAG,CAAC;AAEnD,QAAM,cAAcC,SAAQH,OAAM,IAAI;AACtC,SAAO,wBAAwB,yBAAyB;IACtD,YAAY;IACZ,SAAS;EACX,CAAC;AACH;AAUA,eAAsB,gCACpB,OAEI,CAAC,GACgC;AACrC,QAAM,QAAQ,oBAAoB,IAAI;AACtC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,IAAI,MAAM,uBAAuB,KAAK;AAC5C,SAAO,EAAE,eAAe,EAAE,eAAe,OAAO,UAAU,EAAE,MAAM;AACpE;AAQA,eAAsB,8BAAiE;AACrF,MAAI;AACF,UAAM,QAAQ,oBAAoB;AAClC,QAAI,CAAC,MAAO,QAAO;AACnB,YAAQ,MAAM,uBAAuB,KAAK,GAAG;EAC/C,QAAQ;AACN,WAAO;EACT;AACF;AAEO,SAAS,0BAAsD;AACpE,QAAM,MAAM,qBAAqB,QAAQ;AACzC,MAAI,QAAQ,QAAQ,OAAO,QAAQ,SAAU,QAAO;AACpD,QAAM,SAAS;AACf,MAAI,OAAO,WAAW,OAAQ,QAAO;AACrC,SAAO,EAAE,QAAQ,QAAQ,MAAM,OAAO,KAAK;AAC7C;AAEO,SAAS,yBAAyB,MAKhC;AACP,QAAM,QAAQ,aAAa;AAC3B,QAAM,QAA6B;IACjC,QAAQ;IACR,MAAM;MACJ,UAAU,KAAK,YAAY;MAC3B,eAAe,KAAK;MACpB,YAAY,MAAM;MAClB,WAAW,MAAM;MACjB,YAAW,oBAAI,KAAK,GAAE,YAAY;MAClC,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;IAC5C;EACF;AACA,wBAAsB,UAAU,KAAK;AACvC;AAGO,SAAS,gBAAgB,OAAmC,SAA0B;AAC3F,SAAO,OAAO,MAAM,kBAAkB;AACxC;","names":["dirname","resolve","fileURLToPath","execa","execa","writePreparedDockerState","computeDockerContextFingerprint","readPreparedDockerState","preparedMatches","here","dirname","fileURLToPath","resolve"]}
1
+ {"version":3,"sources":["../../../packages/sandbox-docker/src/prepared-state.ts","../../../packages/sandbox-docker/src/image.ts","../../../packages/sandbox-docker/src/registry-auth.ts"],"sourcesContent":["/**\n * Docker provider's `~/.agentbox/docker-prepared.json` reader/writer + the\n * build-context fingerprint that drives base-image invalidation.\n *\n * The fingerprint is a SHA-256 over every file `docker build` would COPY\n * into the image — Dockerfile + scripts + baked config files. Two CLIs\n * with identical staged runtime trees produce the same hash; a one-byte\n * edit to any baked asset flips it, which is the signal `ensureImage()`\n * uses to rebuild instead of reusing the cached image.\n */\n\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n computeContextManifest,\n DOCKER_CONTEXT_FILE_MAP,\n readCliStamp,\n readPreparedStateRaw,\n resolveContextFilesFrom,\n writePreparedStateRaw,\n type ContextFile,\n type FileManifest,\n type PreparedBaseSnapshot,\n} from '@agentbox/sandbox-core';\nimport { BUILD_CONTEXT_DIR, DEFAULT_BOX_IMAGE, DOCKERFILE_PATH } from './image.js';\n\nconst SCHEMA = 1 as const;\n\nexport type PreparedDockerState = PreparedBaseSnapshot<string, never>;\n\n/**\n * Resolve every fingerprint input to an absolute path. The canonical file\n * list lives in `@agentbox/sandbox-core` (DOCKER_CONTEXT_FILE_MAP) so the\n * daytona provider can hash the same inputs without depending on this\n * package. Two layouts are tried in order, mirroring `resolveDockerBuild()`\n * in `image.ts`:\n * 1. Build context dir (staged runtime / env override).\n * 2. Sandbox-docker package root (dev fallback).\n *\n * Returns `null` when *any* required file is missing — callers treat that\n * as \"can't fingerprint\" and skip the cache-hit shortcut (always rebuild).\n */\nexport function resolveContextFiles(opts: { contextDir?: string } = {}): ContextFile[] | null {\n const ctx = opts.contextDir ?? BUILD_CONTEXT_DIR;\n const here = dirname(fileURLToPath(import.meta.url));\n // sandbox-docker's package root = parent of src/ or parent of dist/.\n const packageRoot = resolve(here, '..');\n return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {\n contextDir: ctx,\n devRoot: packageRoot,\n });\n}\n\nexport interface ResolvedFingerprint {\n contextSha256: string;\n /** Files that fed the hash (in canonical sorted order). */\n files: ContextFile[];\n /** Per-file digests, recorded at bake time so a later `stale` can be explained. */\n manifest: FileManifest;\n}\n\nexport async function computeDockerContextFingerprint(\n opts: {\n contextDir?: string;\n } = {},\n): Promise<ResolvedFingerprint | null> {\n const files = resolveContextFiles(opts);\n if (!files) return null;\n const m = await computeContextManifest(files);\n return { contextSha256: m.contextSha256, files, manifest: m.files };\n}\n\n/**\n * The per-file digests of the CURRENT docker build context, for diffing against\n * a baked manifest. Returns undefined when the context can't be resolved (a dev\n * tree with no staged runtime) — the caller then has nothing to compare and must\n * not claim a diff.\n */\nexport async function currentDockerBaseFileHashes(): Promise<FileManifest | undefined> {\n try {\n const files = resolveContextFiles();\n if (!files) return undefined;\n return (await computeContextManifest(files)).files;\n } catch {\n return undefined;\n }\n}\n\nexport function readPreparedDockerState(): PreparedDockerState | null {\n const raw = readPreparedStateRaw('docker');\n if (raw === null || typeof raw !== 'object') return null;\n const parsed = raw as Partial<PreparedDockerState>;\n if (parsed.schema !== SCHEMA) return null;\n return { schema: SCHEMA, base: parsed.base };\n}\n\nexport function writePreparedDockerState(opts: {\n imageRef?: string;\n contextSha256: string;\n /** Per-file digests of the context this image was built from, when known. */\n files?: FileManifest;\n}): void {\n const stamp = readCliStamp();\n const state: PreparedDockerState = {\n schema: SCHEMA,\n base: {\n imageRef: opts.imageRef ?? DEFAULT_BOX_IMAGE,\n contextSha256: opts.contextSha256,\n cliVersion: stamp.cliVersion,\n cliCommit: stamp.cliCommit,\n createdAt: new Date().toISOString(),\n ...(opts.files ? { files: opts.files } : {}),\n },\n };\n writePreparedStateRaw('docker', state);\n}\n\n/** Convenience for `ensureImage` and `prepare` — true when the stamped fingerprint matches. */\nexport function preparedMatches(state: PreparedDockerState | null, current: string): boolean {\n return state?.base?.contextSha256 === current;\n}\n\n/** Re-export so callers don't reach into image.ts just for the Dockerfile path. */\nexport { DOCKERFILE_PATH };\n","import { execa } from 'execa';\nimport {\n classifyPullFailure,\n isAuthRetryable,\n isGhcrTarget,\n loginToGhcrWithGh,\n type PullFailure,\n} from './registry-auth.js';\nimport { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, resolve } from 'node:path';\nimport {\n BOX_IMAGE_REGISTRY,\n claudeInstallFingerprint,\n registryRefForSha,\n type FileManifest,\n} from '@agentbox/sandbox-core';\n\nexport const DEFAULT_BOX_IMAGE = 'agentbox/box:dev';\n\n/**\n * Resolve the effective `box.claudeInstall` for the current project. Docker\n * builds its image lazily at create time, so every `ensureImage` path must\n * agree on the mode or a native rebuild would clobber an npm-baked image (and\n * vice-versa). Lazy-imported to keep the module load cheap; falls back to\n * `native` if config can't be read.\n */\nasync function resolveClaudeInstallMode(): Promise<'native' | 'npm'> {\n try {\n const { loadEffectiveConfig } = await import('@agentbox/config');\n const cfg = await loadEffectiveConfig(process.cwd());\n return cfg.effective.box.claudeInstall;\n } catch {\n return 'native';\n }\n}\n\n// The registry ref lives in @agentbox/sandbox-core: daytona's linux-vm bake\n// needs it too (a VM snapshot can only be built from a prebuilt registry image),\n// and importing it from here would drag execa into that import graph. Re-exported\n// so existing `@agentbox/sandbox-docker` consumers keep working.\nexport { BOX_IMAGE_REGISTRY, registryRefForSha };\n\nconst here = dirname(fileURLToPath(import.meta.url));\n\n// The Dockerfile's COPY lines reference monorepo-relative paths\n// (packages/ctl/dist/bin.cjs, apps/cli/share/..., packages/sandbox-docker/scripts/*),\n// so the build context must be a dir containing that tree.\n//\n// Resolution order:\n// 0. AGENTBOX_DOCKER_CONTEXT env override (dir holding Dockerfile.box).\n// 1. Staged context shipped with the bundled `agent-box` package: this\n// module is bundled into the CLI at <root>/dist, the stage step mirrors\n// the COPY tree at <root>/runtime/docker (sibling of dist/, uniform in\n// dev and when installed).\n// 2. Legacy monorepo: Dockerfile.box at the sandbox-docker package root,\n// build context = monorepo root.\nfunction resolveDockerBuild(): { dockerfile: string; context: string } {\n const override = process.env.AGENTBOX_DOCKER_CONTEXT;\n if (override && existsSync(resolve(override, 'Dockerfile.box'))) {\n return { dockerfile: resolve(override, 'Dockerfile.box'), context: override };\n }\n const staged = resolve(here, '..', 'runtime', 'docker');\n if (existsSync(resolve(staged, 'Dockerfile.box'))) {\n return { dockerfile: resolve(staged, 'Dockerfile.box'), context: staged };\n }\n // Legacy: src/ (or the unbundled package dist/) is one level under the\n // package root; the monorepo root is two more up.\n const packageRoot = resolve(here, '..');\n return {\n dockerfile: resolve(packageRoot, 'Dockerfile.box'),\n context: resolve(packageRoot, '..', '..'),\n };\n}\n\nconst { dockerfile: DOCKERFILE_PATH_RESOLVED, context: BUILD_CONTEXT_DIR_RESOLVED } =\n resolveDockerBuild();\nexport const DOCKERFILE_PATH = DOCKERFILE_PATH_RESOLVED;\nexport const BUILD_CONTEXT_DIR = BUILD_CONTEXT_DIR_RESOLVED;\n\nexport async function imageExists(ref: string): Promise<boolean> {\n const result = await execa('docker', ['image', 'inspect', ref], { reject: false });\n return result.exitCode === 0;\n}\n\n/**\n * Attempt `docker pull <target>`. Never throws.\n *\n * Reports WHY it failed, not just that it did: a rate-limited pull, a rejected\n * credential and an unpublished tag all exit 1, but only the first two can be\n * fixed by authenticating and only the third means \"build locally\". Returning a\n * bare boolean here is what made a throttled pull look identical to a missing\n * image — a silent ~10-minute rebuild of an image that was in the registry.\n */\nexport async function pullImage(\n target: string,\n opts: { onProgress?: (line: string) => void } = {},\n): Promise<{ ok: boolean; failure?: PullFailure }> {\n const subprocess = execa('docker', ['pull', target], {\n stderr: 'pipe',\n stdout: 'pipe',\n reject: false,\n });\n // Kept so a failure can be classified; docker writes the real reason to stderr.\n let stderrText = '';\n // Always capture stderr, even with no onProgress — the classification below\n // needs it regardless of whether anyone is watching the progress stream.\n subprocess.stderr?.on('data', (chunk: Buffer | string) => {\n stderrText += typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n });\n let heartbeat: NodeJS.Timeout | undefined;\n if (opts.onProgress) {\n let lastLineAt = Date.now();\n const forward = (chunk: Buffer | string): void => {\n lastLineAt = Date.now();\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n // Piped (non-TTY) `docker pull` prints nothing between the last\n // \"Download complete\" and each \"Pull complete\" — the entire extraction\n // phase is silent, which for a multi-GB image reads as a hang. Emit a\n // keepalive so the create spinner keeps moving.\n heartbeat = setInterval(() => {\n if (Date.now() - lastLineAt >= 20_000) {\n opts.onProgress?.(`still extracting ${target} — large layers can take a few minutes`);\n }\n }, 20_000);\n }\n try {\n const result = await subprocess;\n if (result.exitCode === 0) return { ok: true };\n return { ok: false, failure: classifyPullFailure(stderrText || (result.stderr ?? '')) };\n } finally {\n if (heartbeat) clearInterval(heartbeat);\n }\n}\n\nexport async function tagImage(source: string, target: string): Promise<void> {\n await execa('docker', ['tag', source, target]);\n}\n\nexport interface ImageInfo {\n /** Image ref (e.g. `agentbox/box:dev`). */\n ref: string;\n /** True when the engine has the image locally. */\n exists: boolean;\n /** Image size in bytes, when known. */\n sizeBytes?: number;\n /** ISO-8601 creation time, when known. */\n createdAt?: string;\n}\n\n/**\n * Read-only inspect of a Docker image. Used by `agentbox prepare` (no-args\n * status mode) to surface base-image state. Never throws — returns\n * `{ exists: false }` on any error so the status command works even when\n * the docker daemon is unreachable.\n */\nexport async function imageInfo(ref: string = DEFAULT_BOX_IMAGE): Promise<ImageInfo> {\n const result = await execa(\n 'docker',\n ['image', 'inspect', '--format', '{{.Size}}|{{.Created}}', ref],\n { reject: false },\n );\n if (result.exitCode !== 0) return { ref, exists: false };\n const [sizeStr, createdAt] = result.stdout.trim().split('|');\n const sizeBytes = sizeStr ? Number.parseInt(sizeStr, 10) : NaN;\n return {\n ref,\n exists: true,\n sizeBytes: Number.isFinite(sizeBytes) ? sizeBytes : undefined,\n createdAt: createdAt && createdAt.length > 0 ? createdAt : undefined,\n };\n}\n\nexport interface BuildImageOptions {\n ref?: string;\n dockerfile?: string;\n contextDir?: string;\n /** `--build-arg K=V` pairs forwarded to `docker build` (e.g. AGENTBOX_CLAUDE_INSTALL). */\n buildArgs?: Record<string, string>;\n onProgress?: (line: string) => void;\n}\n\nexport async function buildImage(opts: BuildImageOptions = {}): Promise<string> {\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const dockerfile = opts.dockerfile ?? DOCKERFILE_PATH;\n const contextDir = opts.contextDir ?? BUILD_CONTEXT_DIR;\n\n // Dogfood path: when building from inside an agentbox (docker-in-docker),\n // the default bridge network can't bind-mount /proc/<pid>/ns/net for the\n // build container, breaking any RUN that needs network (e.g. apt, curl).\n // Falling back to host networking sidesteps the missing capability.\n const args = ['build', '-t', ref, '-f', dockerfile];\n for (const [k, v] of Object.entries(opts.buildArgs ?? {})) {\n args.push('--build-arg', `${k}=${v}`);\n }\n args.push(contextDir);\n if (process.env.AGENTBOX === '1') {\n args.splice(1, 0, '--network=host');\n }\n\n const subprocess = execa('docker', args, {\n stderr: 'pipe',\n stdout: 'pipe',\n });\n\n if (opts.onProgress) {\n const forward = (chunk: Buffer | string): void => {\n const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n for (const line of text.split(/\\r?\\n/)) {\n if (line.length > 0) opts.onProgress?.(line);\n }\n };\n subprocess.stdout?.on('data', forward);\n subprocess.stderr?.on('data', forward);\n }\n\n await subprocess;\n return ref;\n}\n\nexport interface PullOrBuildOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the staged runtime / monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /** `--build-arg K=V` pairs forwarded to the local `docker build` (ignored on a registry pull). */\n buildArgs?: Record<string, string>;\n}\n\n/**\n * Make `ref` present locally, preferring a registry pull over a local build.\n *\n * When `fingerprint` is non-null and pulling is allowed, pull the\n * fingerprint-tagged image and retag it to `ref`; on a miss (or when pulling\n * is disabled / unfingerprintable) build from the staged context. Either way,\n * a known fingerprint is stamped into docker-prepared.json so the next\n * `ensureImage()` treats this as a cache hit.\n */\nexport async function pullOrBuild(\n ref: string,\n fingerprint: { contextSha256: string; manifest?: FileManifest } | null,\n opts: PullOrBuildOptions = {},\n): Promise<{ source: 'pulled' | 'built' }> {\n const { writePreparedDockerState } = await import('./prepared-state.js');\n const registry = opts.registry ?? BOX_IMAGE_REGISTRY;\n const allowPull = opts.allowPull !== false;\n\n if (allowPull && registry && fingerprint) {\n const target = registryRefForSha(fingerprint.contextSha256, registry);\n const succeed = async (): Promise<{ source: 'pulled' }> => {\n await tagImage(target, ref);\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n opts.onProgress?.(`[image] pulled ${target} -> ${ref}`);\n return { source: 'pulled' };\n };\n\n opts.onProgress?.(`[image] pulling ${target}`);\n const first = await pullImage(target, { onProgress: opts.onProgress });\n if (first.ok) return succeed();\n\n const failure = first.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] pull failed (${failure.kind}): ${failure.detail}`);\n\n // A throttle or a credential problem is not a missing image: the tag is\n // there and an authenticated pull gets it. GHCR's anonymous limit is per-IP\n // and a machine that just baked a few times trips it, so borrowing the\n // host's `gh` token here is the difference between a retag and a ~10-minute\n // rebuild of an image that was already published.\n if (isAuthRetryable(failure.kind) && isGhcrTarget(target)) {\n opts.onProgress?.('[image] retrying authenticated with your `gh` token');\n const login = await loginToGhcrWithGh();\n if (login.ok) {\n const second = await pullImage(target, { onProgress: opts.onProgress });\n if (second.ok) return succeed();\n const f2 = second.failure ?? { kind: 'unknown' as const, detail: 'unknown error' };\n opts.onProgress?.(`[image] authenticated pull also failed (${f2.kind}): ${f2.detail}`);\n } else {\n opts.onProgress?.(\n `[image] could not authenticate to ghcr.io: ${login.reason ?? 'unknown'}`,\n );\n }\n }\n\n opts.onProgress?.(`[image] building ${ref} locally instead`);\n }\n\n await buildImage({\n ref,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n buildArgs: opts.buildArgs,\n onProgress: opts.onProgress,\n });\n if (fingerprint) {\n writePreparedDockerState({\n imageRef: ref,\n contextSha256: fingerprint.contextSha256,\n ...(fingerprint.manifest ? { files: fingerprint.manifest } : {}),\n });\n }\n return { source: 'built' };\n}\n\nexport interface EnsureImageOptions {\n onProgress?: (line: string) => void;\n /** Dockerfile path. Defaults to `Dockerfile.box` next to this package. */\n dockerfile?: string;\n /** Build context directory. Defaults to the monorepo root. */\n contextDir?: string;\n /** Try the registry before building. Defaults to true. */\n allowPull?: boolean;\n /** Registry repo to pull from. Defaults to `BOX_IMAGE_REGISTRY`; empty disables pulling. */\n registry?: string;\n /**\n * How Claude Code is installed into the image. Folded into the build-context\n * fingerprint so a mode switch rebuilds (and an npm image isn't clobbered by\n * a native rebuild). Defaults to the resolved `box.claudeInstall`.\n */\n claudeInstall?: 'native' | 'npm';\n}\n\nexport async function ensureImage(\n ref: string = DEFAULT_BOX_IMAGE,\n opts: EnsureImageOptions = {},\n): Promise<{ ref: string; built: boolean; reason?: string }> {\n // Lazy import: prepared-state imports back into image.ts for the default\n // DOCKERFILE_PATH/BUILD_CONTEXT_DIR constants, so loading it at top-level\n // would create a circular ESM init order.\n const { computeDockerContextFingerprint, readPreparedDockerState, preparedMatches } =\n await import('./prepared-state.js');\n\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const rawFingerprint = await computeDockerContextFingerprint({\n contextDir: opts.contextDir,\n });\n // Fold the install mode into the sha so native↔npm are distinct cache\n // identities (`native` leaves the hash unchanged).\n const fingerprint = rawFingerprint\n ? {\n ...rawFingerprint,\n contextSha256: claudeInstallFingerprint(rawFingerprint.contextSha256, claudeInstall),\n }\n : null;\n const prepared = readPreparedDockerState();\n const exists = await imageExists(ref);\n\n let reason: string | undefined;\n if (!exists) {\n reason = `image ${ref} not present`;\n } else if (!fingerprint) {\n // Couldn't enumerate the context (partial dev rebuild?). Don't rebuild\n // unconditionally — that would surprise users mid-iteration. Trust the\n // image-exists check and leave the prepared file untouched.\n return { ref, built: false, reason: 'image present (fingerprint skipped)' };\n } else if (!prepared) {\n reason = 'no docker-prepared.json on disk';\n } else if (!preparedMatches(prepared, fingerprint.contextSha256)) {\n reason =\n `build context changed (was ${prepared.base?.contextSha256?.slice(0, 12) ?? '<none>'}, ` +\n `now ${fingerprint.contextSha256.slice(0, 12)})`;\n }\n\n if (!reason) {\n return { ref, built: false, reason: 'image up to date' };\n }\n\n opts.onProgress?.(`[image] ${ref}: ${reason}`);\n const npm = claudeInstall === 'npm';\n const { source } = await pullOrBuild(ref, fingerprint, {\n onProgress: opts.onProgress,\n dockerfile: opts.dockerfile,\n contextDir: opts.contextDir,\n // npm mode pulls too. CI publishes both install variants, and `fingerprint`\n // is already folded with the mode above — so the pull asks for the npm\n // image's own tag and hits. (It used to be native-only, which meant npm\n // users rebuilt the image locally on every first create, forever.) A tag\n // that genuinely isn't published still falls back to a local build.\n allowPull: opts.allowPull,\n registry: opts.registry,\n buildArgs: npm ? { AGENTBOX_CLAUDE_INSTALL: 'npm' } : undefined,\n });\n return { ref, built: source === 'built', reason };\n}\n\n/**\n * Read-only freshness classification of the docker base image, for surfaces\n * (hub API, tray) that want to announce an upcoming bake without triggering\n * it. `unknown` means \"couldn't fingerprint\" and MUST stay inert — the\n * matching `ensureImage` path trusts the existing image and does not rebuild.\n */\nexport type DockerBaseFreshness =\n | { state: 'fresh' }\n | { state: 'unknown' }\n | { state: 'unprepared' }\n | { state: 'stale'; reason: string };\n\n/**\n * Pure decision core shared by `evaluateDockerBaseFreshness`. Mirrors\n * `ensureImage`'s rebuild predicate exactly — if the two ever disagree, the\n * freshness surfaces would announce a bake that create then skips (or miss\n * one it performs). `stampedSha` is `docker-prepared.json`'s fingerprint,\n * null when the stamp is missing/invalid.\n */\nexport function classifyDockerBaseFreshness(input: {\n imagePresent: boolean;\n fingerprint: string | null;\n stampedSha: string | null;\n}): DockerBaseFreshness {\n if (!input.imagePresent) return { state: 'unprepared' };\n if (!input.fingerprint) return { state: 'unknown' };\n if (!input.stampedSha) return { state: 'stale', reason: 'no docker-prepared.json on disk' };\n if (input.stampedSha !== input.fingerprint) {\n return {\n state: 'stale',\n reason:\n `build context changed (was ${input.stampedSha.slice(0, 12)}, ` +\n `now ${input.fingerprint.slice(0, 12)})`,\n };\n }\n return { state: 'fresh' };\n}\n\n/**\n * Cheap live check: would `ensureImage` bake on the next create? The only\n * docker work is one `docker image inspect`; the rest hashes the ~15 build\n * context files. Never builds, pulls, or writes the prepared stamp.\n */\nexport async function evaluateDockerBaseFreshness(\n opts: { ref?: string; claudeInstall?: 'native' | 'npm'; contextDir?: string } = {},\n): Promise<DockerBaseFreshness> {\n // Lazy import for the same circular-init reason as in ensureImage above.\n const { computeDockerContextFingerprint, readPreparedDockerState } =\n await import('./prepared-state.js');\n const ref = opts.ref ?? DEFAULT_BOX_IMAGE;\n const imagePresent = await imageExists(ref);\n if (!imagePresent) return { state: 'unprepared' };\n const claudeInstall = opts.claudeInstall ?? (await resolveClaudeInstallMode());\n const raw = await computeDockerContextFingerprint({ contextDir: opts.contextDir });\n return classifyDockerBaseFreshness({\n imagePresent,\n fingerprint: raw ? claudeInstallFingerprint(raw.contextSha256, claudeInstall) : null,\n stampedSha: readPreparedDockerState()?.base?.contextSha256 ?? null,\n });\n}\n","/**\n * Why a `docker pull` of the box image failed, and how to retry it authenticated.\n *\n * The box image is published to a PUBLIC GHCR repo, so an anonymous pull works —\n * until it doesn't. GHCR rate-limits anonymous pulls per IP, and a machine that\n * has just baked a few times trips it. `docker pull` then exits non-zero and the\n * caller falls back to a ~10-minute local build of an image that was sitting in\n * the registry all along. Worse, the old code returned a bare boolean, so a\n * rate-limit, a 401 and a genuinely-unpublished tag were indistinguishable and\n * none of them reached the log.\n *\n * So: classify the failure, and when it is a throttle/auth problem on GHCR,\n * borrow the host's `gh` token and retry once.\n *\n * The load-bearing subtlety is the SCOPE. `gh auth token` returns whatever the\n * user's `gh auth login` negotiated — by default `repo`, `read:org`, `gist`,\n * `workflow` and *not* `read:packages`. Logging in to GHCR with such a token is\n * actively worse than staying anonymous: the registry then evaluates an\n * identity that lacks package-read and answers 403, turning a pull that would\n * have succeeded into one that cannot. So we check the scope first and skip the\n * login when it is absent, telling the user the one command that fixes it.\n */\nimport { execa } from 'execa';\n\n/** GHCR is the only registry we know how to authenticate from `gh`. */\nexport const GHCR_HOST = 'ghcr.io';\n\n/** The scope GHCR requires to read a package, public or not. */\nconst PACKAGE_READ_SCOPE = 'read:packages';\n\nexport type PullFailureKind =\n /** GHCR throttled us — the tag exists and an authenticated retry should work. */\n | 'rate-limit'\n /** Credentials rejected or absent where required. */\n | 'unauthorized'\n /** The tag genuinely is not published — a local build is the correct answer. */\n | 'not-found'\n /** DNS / TCP / TLS — nothing to do with the tag. */\n | 'network'\n | 'unknown';\n\nexport interface PullFailure {\n kind: PullFailureKind;\n /** The most useful line of docker's own stderr, for the log. */\n detail: string;\n}\n\n/**\n * Map `docker pull` stderr onto a {@link PullFailureKind}. Substring matching on\n * docker/registry error text rather than exit codes, which are always 1.\n */\nexport function classifyPullFailure(stderr: string): PullFailure {\n const text = stderr.toLowerCase();\n const detail = lastMeaningfulLine(stderr);\n // Order matters: a throttle response also says \"unauthorized\" on some\n // registries, and it is the throttle that decides whether a retry can help.\n if (\n text.includes('toomanyrequests') ||\n text.includes('too many requests') ||\n text.includes('429')\n ) {\n return { kind: 'rate-limit', detail };\n }\n if (\n text.includes('manifest unknown') ||\n text.includes('not found') ||\n text.includes('404') ||\n text.includes('no such manifest')\n ) {\n return { kind: 'not-found', detail };\n }\n if (\n text.includes('unauthorized') ||\n text.includes('authentication required') ||\n text.includes('denied') ||\n text.includes('403')\n ) {\n return { kind: 'unauthorized', detail };\n }\n if (\n text.includes('dial tcp') ||\n text.includes('no such host') ||\n text.includes('timeout') ||\n text.includes('temporary failure in name resolution') ||\n text.includes('connection refused') ||\n text.includes('tls handshake')\n ) {\n return { kind: 'network', detail };\n }\n return { kind: 'unknown', detail };\n}\n\n/** The last non-empty stderr line, trimmed — docker puts the real error last. */\nfunction lastMeaningfulLine(stderr: string): string {\n const lines = stderr\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .filter((l) => l.length > 0);\n return lines.length > 0 ? lines[lines.length - 1]! : 'no error output from docker';\n}\n\n/** Only a throttle or a credential problem can be improved by authenticating. */\nexport function isAuthRetryable(kind: PullFailureKind): boolean {\n return kind === 'rate-limit' || kind === 'unauthorized';\n}\n\n/** True when `target` lives on GHCR, the only host we can log into from `gh`. */\nexport function isGhcrTarget(target: string): boolean {\n return target.startsWith(`${GHCR_HOST}/`);\n}\n\nexport interface GhcrLoginResult {\n ok: boolean;\n /** Why we did not (or could not) log in — always safe to show the user. */\n reason?: string;\n}\n\ninterface Runner {\n (\n file: string,\n args: string[],\n opts?: { input?: string },\n ): Promise<{\n exitCode: number | undefined;\n stdout: string;\n stderr: string;\n }>;\n}\n\nconst realRunner: Runner = async (file, args, opts) => {\n const r = await execa(file, args, {\n reject: false,\n timeout: 30_000,\n ...(opts?.input !== undefined ? { input: opts.input } : {}),\n });\n return { exitCode: r.exitCode, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };\n};\n\n/**\n * Log the local docker engine into GHCR using the host's `gh` token, so the\n * retry is authenticated (and rate-limited far more generously).\n *\n * Refuses rather than risks it when the token lacks `read:packages` — see the\n * module comment. `fetchScopes` is injected so this is testable without network.\n */\nexport async function loginToGhcrWithGh(\n opts: {\n run?: Runner;\n fetchScopes?: (token: string) => Promise<string[]>;\n } = {},\n): Promise<GhcrLoginResult> {\n const run = opts.run ?? realRunner;\n\n // Pinned to github.com: GHCR only accepts github.com tokens, while a bare\n // `gh auth token` returns the DEFAULT host's token — which for someone whose\n // gh is set up against GitHub Enterprise Server is an enterprise credential\n // we would then hand to ghcr.io.\n const tok = await run('gh', ['auth', 'token', '--hostname', 'github.com']);\n const token = tok.stdout.trim();\n if (tok.exitCode !== 0 || token.length === 0) {\n return {\n ok: false,\n reason:\n 'no github.com `gh` token on this machine (run `gh auth login --hostname github.com`)',\n };\n }\n\n const scopes = await (opts.fetchScopes ?? fetchTokenScopes)(token);\n // An empty list means we could not read the header (offline, or a fine-grained\n // token that reports no classic scopes). Attempting the login is then the\n // lesser evil: a fine-grained PAT with package-read is a normal setup, and a\n // failed login leaves us exactly where we already are.\n if (scopes.length > 0 && !scopes.includes(PACKAGE_READ_SCOPE)) {\n return {\n ok: false,\n reason:\n `your \\`gh\\` token lacks the ${PACKAGE_READ_SCOPE} scope, so authenticating would be ` +\n `rejected by ${GHCR_HOST}. Add it with: gh auth refresh -h github.com -s ${PACKAGE_READ_SCOPE}`,\n };\n }\n\n // GHCR ignores the username when the password is a valid token, but docker\n // requires a non-empty one.\n const login = await run('docker', ['login', GHCR_HOST, '-u', 'agentbox', '--password-stdin'], {\n input: token,\n });\n if (login.exitCode !== 0) {\n return { ok: false, reason: lastMeaningfulLine(login.stderr || login.stdout) };\n }\n return { ok: true };\n}\n\n/** Classic OAuth scopes for `token`, from GitHub's `x-oauth-scopes` header. */\nasync function fetchTokenScopes(token: string): Promise<string[]> {\n try {\n const res = await fetch('https://api.github.com/user', {\n headers: {\n Authorization: `Bearer ${token}`,\n Accept: 'application/vnd.github+json',\n 'User-Agent': 'agentbox',\n },\n signal: AbortSignal.timeout(10_000),\n });\n return (res.headers.get('x-oauth-scopes') ?? '')\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,SAAS,WAAAA,UAAS,WAAAC,gBAAe;AACjC,SAAS,iBAAAC,sBAAqB;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G,CAAC;AAEnD,QAAM,cAAcC,SAAQH,OAAM,IAAI;AACtC,SAAO,wBAAwB,yBAAyB;IACtD,YAAY;IACZ,SAAS;EACX,CAAC;AACH;AAUA,eAAsB,gCACpB,OAEI,CAAC,GACgC;AACrC,QAAM,QAAQ,oBAAoB,IAAI;AACtC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,IAAI,MAAM,uBAAuB,KAAK;AAC5C,SAAO,EAAE,eAAe,EAAE,eAAe,OAAO,UAAU,EAAE,MAAM;AACpE;AAQA,eAAsB,8BAAiE;AACrF,MAAI;AACF,UAAM,QAAQ,oBAAoB;AAClC,QAAI,CAAC,MAAO,QAAO;AACnB,YAAQ,MAAM,uBAAuB,KAAK,GAAG;EAC/C,QAAQ;AACN,WAAO;EACT;AACF;AAEO,SAAS,0BAAsD;AACpE,QAAM,MAAM,qBAAqB,QAAQ;AACzC,MAAI,QAAQ,QAAQ,OAAO,QAAQ,SAAU,QAAO;AACpD,QAAM,SAAS;AACf,MAAI,OAAO,WAAW,OAAQ,QAAO;AACrC,SAAO,EAAE,QAAQ,QAAQ,MAAM,OAAO,KAAK;AAC7C;AAEO,SAAS,yBAAyB,MAKhC;AACP,QAAM,QAAQ,aAAa;AAC3B,QAAM,QAA6B;IACjC,QAAQ;IACR,MAAM;MACJ,UAAU,KAAK,YAAY;MAC3B,eAAe,KAAK;MACpB,YAAY,MAAM;MAClB,WAAW,MAAM;MACjB,YAAW,oBAAI,KAAK,GAAE,YAAY;MAClC,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;IAC5C;EACF;AACA,wBAAsB,UAAU,KAAK;AACvC;AAGO,SAAS,gBAAgB,OAAmC,SAA0B;AAC3F,SAAO,OAAO,MAAM,kBAAkB;AACxC;","names":["dirname","resolve","fileURLToPath","execa","execa","writePreparedDockerState","computeDockerContextFingerprint","readPreparedDockerState","preparedMatches","here","dirname","fileURLToPath","resolve"]}
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/control-plane/host-reach-drainer.ts
4
+ async function ensureHostReachDrainer(box) {
5
+ try {
6
+ if ((box.provider ?? "docker") === "docker") return;
7
+ if (!box.cloud?.controlPlaneUrl) return;
8
+ const { ensureRelay } = await import("./dist-C5B6NGBO.js");
9
+ await ensureRelay();
10
+ } catch {
11
+ }
12
+ }
13
+
14
+ export {
15
+ ensureHostReachDrainer
16
+ };
17
+ //# sourceMappingURL=chunk-F4PPZ4SI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/control-plane/host-reach-drainer.ts"],"sourcesContent":["import type { BoxRecord } from '@agentbox/core';\n\n/**\n * Make sure this machine is draining the host actions its control box parks for\n * it, whenever the user starts working with a control-plane box.\n *\n * The drainer lives in the relay daemon, and the paths that only ever touch a\n * hub box — `create --via-hub`, adoption, attaching to a box created from the\n * web UI — never brought one up: every existing `ensureRelay()` call sits on a\n * *local* create/start. So the one workflow that needs the channel most was the\n * one guaranteed not to have it, and an in-box `cp` would fall back to the hub's\n * cache (or fail) while the user sat right there at the machine holding the file.\n *\n * Best-effort by construction: a box with no control box does nothing, and a\n * relay that won't start is not worth failing an attach over — the copy degrades\n * to the cache and says so.\n */\nexport async function ensureHostReachDrainer(\n box: Pick<BoxRecord, 'provider' | 'cloud'>,\n): Promise<void> {\n try {\n if ((box.provider ?? 'docker') === 'docker') return;\n if (!box.cloud?.controlPlaneUrl) return;\n const { ensureRelay } = await import('@agentbox/sandbox-docker');\n await ensureRelay();\n } catch {\n /* best-effort: the copy path reports its own degradation */\n }\n}\n"],"mappings":";;;AAiBA,eAAsB,uBACpB,KACe;AACf,MAAI;AACF,SAAK,IAAI,YAAY,cAAc,SAAU;AAC7C,QAAI,CAAC,IAAI,OAAO,gBAAiB;AACjC,UAAM,EAAE,YAAY,IAAI,MAAM,OAAO,oBAA0B;AAC/D,UAAM,YAAY;AAAA,EACpB,QAAQ;AAAA,EAER;AACF;","names":[]}
@@ -13,22 +13,16 @@ import {
13
13
  renderInnerCommand,
14
14
  resolveCloudCheckpoint,
15
15
  writeCloudCheckpointManifest
16
- } from "./chunk-JQLOGVZK.js";
16
+ } from "./chunk-4KYP775X.js";
17
17
  import {
18
18
  detectPortless,
19
19
  portlessDoctorRow,
20
20
  portlessServiceStatus
21
- } from "./chunk-46NNZMZT.js";
22
- import {
23
- hashProjectPath,
24
- loadEffectiveConfig,
25
- sanitizeMnemonic,
26
- setConfigValue
27
- } from "./chunk-NHVGKFVY.js";
21
+ } from "./chunk-I2DEYQLZ.js";
28
22
  import {
29
23
  BUILD_CONTEXT_DIR,
30
24
  computeDockerContextFingerprint
31
- } from "./chunk-CKD3PRON.js";
25
+ } from "./chunk-CZPVVFCF.js";
32
26
  import {
33
27
  BOX_IMAGE_REGISTRY,
34
28
  SshTunnelManager,
@@ -44,7 +38,13 @@ import {
44
38
  sshExec,
45
39
  sshOptArgs,
46
40
  writePreparedStateRaw
47
- } from "./chunk-GFOWBXV7.js";
41
+ } from "./chunk-XENTK32L.js";
42
+ import {
43
+ hashProjectPath,
44
+ loadEffectiveConfig,
45
+ sanitizeMnemonic,
46
+ setConfigValue
47
+ } from "./chunk-7LNXTPEE.js";
48
48
 
49
49
  // ../../packages/sandbox-remote-docker/dist/chunk-RN5X7NEV.js
50
50
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
@@ -1305,4 +1305,4 @@ export {
1305
1305
  remoteDockerProvider,
1306
1306
  providerModule
1307
1307
  };
1308
- //# sourceMappingURL=chunk-BWM56FKY.js.map
1308
+ //# sourceMappingURL=chunk-FEFLAITR.js.map
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  loadProviderModule
4
- } from "./chunk-OUWVN2F2.js";
4
+ } from "./chunk-I7BSBUPC.js";
5
5
  import {
6
6
  isProviderKind
7
- } from "./chunk-NHVGKFVY.js";
7
+ } from "./chunk-7LNXTPEE.js";
8
8
 
9
9
  // src/provider/cloud-backend.ts
10
10
  async function cloudBackendForProvider(provider) {
@@ -21,4 +21,4 @@ export {
21
21
  cloudBackendForProvider,
22
22
  currentCloudBaseFingerprintLive
23
23
  };
24
- //# sourceMappingURL=chunk-EVT2SNF2.js.map
24
+ //# sourceMappingURL=chunk-FELVUIIM.js.map