@madarco/agentbox 0.28.1 → 0.29.0

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 +124 -0
  2. package/dist/_cloud-attach-HKRHYCY7.js +30 -0
  3. package/dist/{chunk-JNC7MCWJ.js → chunk-3INUZQTR.js} +10 -10
  4. package/dist/chunk-3INUZQTR.js.map +1 -0
  5. package/dist/{chunk-4PR3KJ5X.js → chunk-6PIGTR4D.js} +20 -20
  6. package/dist/{chunk-NHVGKFVY.js → chunk-7LNXTPEE.js} +340 -22
  7. package/dist/chunk-7LNXTPEE.js.map +1 -0
  8. package/dist/{chunk-WB6S4W7O.js → chunk-7Q6BG5AN.js} +2413 -1012
  9. package/dist/chunk-7Q6BG5AN.js.map +1 -0
  10. package/dist/{chunk-BUMKBUXS.js → chunk-7QU6XENE.js} +3 -3
  11. package/dist/chunk-BWE2I5QG.js +17 -0
  12. package/dist/chunk-BWE2I5QG.js.map +1 -0
  13. package/dist/{chunk-7ABO7OIF.js → chunk-CO2I3CQI.js} +4 -4
  14. package/dist/{chunk-OUF3YTQO.js → chunk-DBXCFLAR.js} +14 -17
  15. package/dist/chunk-DBXCFLAR.js.map +1 -0
  16. package/dist/{chunk-74VIUGY6.js → chunk-DYETLPUT.js} +6 -9
  17. package/dist/chunk-DYETLPUT.js.map +1 -0
  18. package/dist/{chunk-HYXCH4GA.js → chunk-EFVTQ7YB.js} +7 -7
  19. package/dist/{chunk-46NNZMZT.js → chunk-EPFXLXCW.js} +372 -72
  20. package/dist/chunk-EPFXLXCW.js.map +1 -0
  21. package/dist/chunk-GWKGSXDC.js +71 -0
  22. package/dist/chunk-GWKGSXDC.js.map +1 -0
  23. package/dist/{chunk-CKD3PRON.js → chunk-GWYD7YBK.js} +12 -9
  24. package/dist/{chunk-CKD3PRON.js.map → chunk-GWYD7YBK.js.map} +1 -1
  25. package/dist/{chunk-NHTRTST5.js → chunk-HNWZO2XU.js} +38 -15
  26. package/dist/chunk-HNWZO2XU.js.map +1 -0
  27. package/dist/{chunk-EVT2SNF2.js → chunk-HO2ACZES.js} +3 -3
  28. package/dist/{chunk-V5NWSLWD.js → chunk-HP4L45LW.js} +14 -14
  29. package/dist/{chunk-B4DAH2F2.js → chunk-LHOKRCNF.js} +3 -3
  30. package/dist/{chunk-G3H2L3O2.js → chunk-MNDKP4VS.js} +23 -3
  31. package/dist/chunk-MNDKP4VS.js.map +1 -0
  32. package/dist/{chunk-JDSYMTMS.js → chunk-NAT2H7J4.js} +110 -66
  33. package/dist/chunk-NAT2H7J4.js.map +1 -0
  34. package/dist/{chunk-KFLGXE3R.js → chunk-NGERWFSA.js} +133 -22
  35. package/dist/chunk-NGERWFSA.js.map +1 -0
  36. package/dist/{chunk-GFOWBXV7.js → chunk-OKLEPEWZ.js} +460 -253
  37. package/dist/chunk-OKLEPEWZ.js.map +1 -0
  38. package/dist/{chunk-YI4GHC2E.js → chunk-QU5BI2HC.js} +12 -15
  39. package/dist/chunk-QU5BI2HC.js.map +1 -0
  40. package/dist/{chunk-BWM56FKY.js → chunk-RQURMAPA.js} +11 -11
  41. package/dist/{chunk-FPMRFMVK.js → chunk-RZCLRWNY.js} +9 -9
  42. package/dist/{chunk-JQLOGVZK.js → chunk-THUST2QK.js} +85 -21
  43. package/dist/chunk-THUST2QK.js.map +1 -0
  44. package/dist/{chunk-OXKW4GWD.js → chunk-UPVP6YGJ.js} +4 -70
  45. package/dist/chunk-UPVP6YGJ.js.map +1 -0
  46. package/dist/{chunk-7RSE7ESY.js → chunk-VVNXQ4XS.js} +27 -18
  47. package/dist/chunk-VVNXQ4XS.js.map +1 -0
  48. package/dist/{chunk-FGQFVUMH.js → chunk-VY54AX4T.js} +3 -3
  49. package/dist/{chunk-OUWVN2F2.js → chunk-WGNI24H2.js} +16 -13
  50. package/dist/chunk-WGNI24H2.js.map +1 -0
  51. package/dist/{chunk-PSA6GADQ.js → chunk-WHFCJBMO.js} +14 -1
  52. package/dist/chunk-WHFCJBMO.js.map +1 -0
  53. package/dist/{chunk-KJ5TCYNI.js → chunk-WHJYOO5H.js} +7 -6
  54. package/dist/chunk-WHJYOO5H.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-UKKYXHIQ.js} +19 -18
  58. package/dist/cp-hub-upload-BM2OLTOS.js +81 -0
  59. package/dist/cp-hub-upload-BM2OLTOS.js.map +1 -0
  60. package/dist/{custody-client-PNCC2HBJ.js → custody-client-NPXJ46TB.js} +5 -4
  61. package/dist/{deploy-hetzner-SSGSXAKA.js → deploy-hetzner-Y3ILCDRF.js} +10 -10
  62. package/dist/{dist-RN6JOAG4.js → dist-5OGQ3CJQ.js} +81 -45
  63. package/dist/{dist-5OR4QTQW.js → dist-7B3VCLZI.js} +9 -9
  64. package/dist/{dist-EPFS5PRI.js → dist-A5ZEIVAW.js} +10 -10
  65. package/dist/{dist-6PYXFREL.js → dist-DOEGENNW.js} +61 -16
  66. package/dist/dist-DOEGENNW.js.map +1 -0
  67. package/dist/{dist-XQLKK7H3.js → dist-EOGD7KD6.js} +54 -28
  68. package/dist/dist-EOGD7KD6.js.map +1 -0
  69. package/dist/{dist-XATN4ZIR.js → dist-FBM2WS5S.js} +22 -4
  70. package/dist/{dist-POILUDVJ.js → dist-MUTFY7FA.js} +9 -9
  71. package/dist/{dist-ZNQZHTUN.js → dist-SMDXLPZO.js} +35 -6
  72. package/dist/{dist-M4O5MU5K.js → dist-VTLQKZ2E.js} +8 -8
  73. package/dist/{dist-SN2TCRZ5.js → dist-ZJIJHCZB.js} +9 -9
  74. package/dist/{dist-K5M4HKG7.js → dist-ZNYS7CVF.js} +21 -9
  75. package/dist/host-reach-drainer-ZJU2STQQ.js +9 -0
  76. package/dist/hub-Q4VOF4WN.js +37 -0
  77. package/dist/{hub-adopt-I44VGSBL.js → hub-adopt-OA336ZXZ.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-JKFCABK4.js} +16 -16
  80. package/dist/index.js +1321 -882
  81. package/dist/index.js.map +1 -1
  82. package/dist/prepare-GFWWKWGF.js +41 -0
  83. package/dist/prepared-custody-KU4PDVBT.js +36 -0
  84. package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js → prepared-state-LNQ7DYSU-AR5RMXAO.js} +4 -3
  85. package/dist/{publish-credentials-BPHUO5VL.js → publish-credentials-3SQXX45P.js} +11 -11
  86. package/dist/registry-AFKV3EO2.js +18 -0
  87. package/dist/relay-QH6OEY2V.js +20 -0
  88. package/dist/relay-QH6OEY2V.js.map +1 -0
  89. package/dist/{remote-docker-share-RX5ARK45.js → remote-docker-share-RMS6IB5X.js} +11 -11
  90. package/dist/remote-docker-share-RMS6IB5X.js.map +1 -0
  91. package/dist/tool-grant-push-T6DRBY3W.js +90 -0
  92. package/dist/tool-grant-push-T6DRBY3W.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 +6757 -5299
  96. package/runtime/_shared/gh-shim +103 -228
  97. package/runtime/digitalocean/agentbox-tool-shim +21 -0
  98. package/runtime/digitalocean/ctl.cjs +6757 -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 +6757 -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 +6757 -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 +6757 -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-VKOCY6SX.js → chunk-3AD3MYNV.js} +49 -14
  336. package/runtime/hub/apps/hub/{chunk-KTVETF3F.js → chunk-3ZDBZYOY.js} +11 -8
  337. package/runtime/hub/apps/hub/{chunk-LPYK2354.js → chunk-5ABFGGPT.js} +339 -21
  338. package/runtime/hub/apps/hub/{chunk-UMPTTQBE.js → chunk-GBYD2ODL.js} +458 -251
  339. package/runtime/hub/apps/hub/{chunk-5TM7XXLT.js → chunk-H5SUXDZA.js} +2833 -1277
  340. package/runtime/hub/apps/hub/{chunk-QU3FFGJY.js → chunk-UQ5XNPOF.js} +11 -14
  341. package/runtime/hub/apps/hub/{chunk-3LAHFDJF.js → chunk-VWQNSZGI.js} +22 -2
  342. package/runtime/hub/apps/hub/{chunk-EZUK53CC.js → chunk-WHGY7HOC.js} +85 -21
  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-ELZHBQEM.js → dist-37EKQ6RZ.js} +11 -11
  346. package/runtime/hub/apps/hub/{dist-D265LCAN.js → dist-CGH7PEMZ.js} +21 -3
  347. package/runtime/hub/apps/hub/{dist-SYWTB6RD.js → dist-CMVSARW5.js} +15 -18
  348. package/runtime/hub/apps/hub/{dist-5HTJSOHS.js → dist-EGXZRZH2.js} +19 -7
  349. package/runtime/hub/apps/hub/{dist-YK5FFPXZ.js → dist-EOGGFZZS.js} +62 -20
  350. package/runtime/hub/apps/hub/{dist-E2FTSTCY.js → dist-LJBHOO3K.js} +34 -5
  351. package/runtime/hub/apps/hub/{dist-N3E5YAYY.js → dist-R77W6WJ5.js} +53 -26
  352. package/runtime/hub/apps/hub/{dist-JVEDVVVG.js → dist-TH2JZYZY.js} +7 -7
  353. package/runtime/hub/apps/hub/{dist-2YP57GMB.js → dist-XPRGHQH2.js} +13 -13
  354. package/runtime/hub/apps/hub/{dist-NKCXH5DW.js → dist-Z2Y5F7AF.js} +6 -6
  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-DXVMUQWF.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-ABC2EQVI.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 +16623 -14688
  371. package/runtime/vercel/agentbox-tool-shim +21 -0
  372. package/runtime/vercel/ctl.cjs +6757 -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-HKRHYCY7.js.map} +0 -0
  417. /package/dist/{chunk-4PR3KJ5X.js.map → chunk-6PIGTR4D.js.map} +0 -0
  418. /package/dist/{chunk-BUMKBUXS.js.map → chunk-7QU6XENE.js.map} +0 -0
  419. /package/dist/{chunk-7ABO7OIF.js.map → chunk-CO2I3CQI.js.map} +0 -0
  420. /package/dist/{chunk-HYXCH4GA.js.map → chunk-EFVTQ7YB.js.map} +0 -0
  421. /package/dist/{chunk-EVT2SNF2.js.map → chunk-HO2ACZES.js.map} +0 -0
  422. /package/dist/{chunk-V5NWSLWD.js.map → chunk-HP4L45LW.js.map} +0 -0
  423. /package/dist/{chunk-B4DAH2F2.js.map → chunk-LHOKRCNF.js.map} +0 -0
  424. /package/dist/{chunk-BWM56FKY.js.map → chunk-RQURMAPA.js.map} +0 -0
  425. /package/dist/{chunk-FPMRFMVK.js.map → chunk-RZCLRWNY.js.map} +0 -0
  426. /package/dist/{chunk-FGQFVUMH.js.map → chunk-VY54AX4T.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-UKKYXHIQ.js.map} +0 -0
  429. /package/dist/{custody-client-PNCC2HBJ.js.map → custody-client-NPXJ46TB.js.map} +0 -0
  430. /package/dist/{deploy-hetzner-SSGSXAKA.js.map → deploy-hetzner-Y3ILCDRF.js.map} +0 -0
  431. /package/dist/{dist-5OR4QTQW.js.map → dist-5OGQ3CJQ.js.map} +0 -0
  432. /package/dist/{dist-EPFS5PRI.js.map → dist-7B3VCLZI.js.map} +0 -0
  433. /package/dist/{dist-K5M4HKG7.js.map → dist-A5ZEIVAW.js.map} +0 -0
  434. /package/dist/{dist-M4O5MU5K.js.map → dist-FBM2WS5S.js.map} +0 -0
  435. /package/dist/{dist-POILUDVJ.js.map → dist-MUTFY7FA.js.map} +0 -0
  436. /package/dist/{dist-RN6JOAG4.js.map → dist-SMDXLPZO.js.map} +0 -0
  437. /package/dist/{dist-SN2TCRZ5.js.map → dist-VTLQKZ2E.js.map} +0 -0
  438. /package/dist/{dist-XATN4ZIR.js.map → dist-ZJIJHCZB.js.map} +0 -0
  439. /package/dist/{dist-ZNQZHTUN.js.map → dist-ZNYS7CVF.js.map} +0 -0
  440. /package/dist/{hub-MJ7O4WXW.js.map → host-reach-drainer-ZJU2STQQ.js.map} +0 -0
  441. /package/dist/{hub-adopt-I44VGSBL.js.map → hub-Q4VOF4WN.js.map} +0 -0
  442. /package/dist/{hub-api-client-WJPBXZAZ.js.map → hub-adopt-OA336ZXZ.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-JKFCABK4.js.map} +0 -0
  445. /package/dist/{prepared-custody-QIXW7MJM.js.map → prepare-GFWWKWGF.js.map} +0 -0
  446. /package/dist/{prepared-state-PV3GUBHO-MF56HWMZ.js.map → prepared-custody-KU4PDVBT.js.map} +0 -0
  447. /package/dist/{relay-DRDELF6B.js.map → prepared-state-LNQ7DYSU-AR5RMXAO.js.map} +0 -0
  448. /package/dist/{publish-credentials-BPHUO5VL.js.map → publish-credentials-3SQXX45P.js.map} +0 -0
  449. /package/dist/{remote-docker-share-RX5ARK45.js.map → registry-AFKV3EO2.js.map} +0 -0
  450. /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → XIx10ozuCZRzwSsiCF_5t}/_buildManifest.js +0 -0
  451. /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → XIx10ozuCZRzwSsiCF_5t}/_clientMiddlewareManifest.js +0 -0
  452. /package/runtime/hub/apps/hub/.next/static/{z7_2bKU93xE7GwllL1Duv → XIx10ozuCZRzwSsiCF_5t}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[48806,e=>{"use strict";let t={description:"Error",content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}}};e.s(["buildOpenApi",0,function(){return{openapi:"3.1.0",info:{title:"AgentBox Hub API",version:"1.0.0",description:'Launch and manage AgentBox sandboxes ("boxes") programmatically. Every endpoint except /health, /openapi.json and /docs requires an Authorization: Bearer <hub token> header (the token the hub prints on boot, also at ~/.agentbox/hub/token). Errors always return { error: { code, message, details? } }.'},servers:[{url:"/api/v1"}],security:[{bearerAuth:[]}],tags:[{name:"System",description:"Liveness and API version."},{name:"Boxes",description:"Create, inspect, and run lifecycle actions on boxes."},{name:"Box git",description:"Git state and operations on a box's branch."},{name:"Box services",description:"A box's agentbox.yaml service/task/port status."},{name:"Projects",description:"Register folders as projects and list their branches."},{name:"Providers",description:"Sandbox providers: status, credentials, base-image bake."},{name:"Hosts",description:"Remote-docker host aliases (name -> SSH connection)."},{name:"Approvals",description:"Pending host-action approvals."},{name:"Jobs",description:"Async create/bake job status and log streams."},{name:"Checkpoints",description:"Durable per-project checkpoints (docker image / cloud snapshot)."},{name:"Fleet",description:"Fleet-wide maintenance (prune orphan boxes and resources)."},{name:"Custody",description:"What the control box holds in custody (metadata only — never values)."}],paths:{"/health":{get:{tags:["System"],summary:"Get liveness + API version",security:[],responses:{200:{description:"OK",content:{"application/json":{schema:{$ref:"#/components/schemas/Health"}}}}}}},"/boxes":{get:{tags:["Boxes"],summary:"List or resolve boxes",description:"Lists every box (normalized view). ?live=1 refreshes each cloud box state with an SDK probe (opt-in, slower; host topology only). ?ref=<id|name|index> instead resolves a single box server-side (findBox semantics: exact id, unique id prefix, name, displayName, sandbox id); pass ?project=<host-path> for numeric project-index refs. The ref response is the match set in { boxes }: 0 (none), 1 (unique), or >1 (ambiguous prefix).",parameters:[{name:"live",in:"query",required:!1,schema:{type:"string",enum:["1"]}},{name:"ref",in:"query",required:!1,schema:{type:"string"}},{name:"project",in:"query",required:!1,schema:{type:"string"}}],responses:{200:{description:"Boxes",content:{"application/json":{schema:{type:"object",properties:{boxes:{type:"array",items:{$ref:"#/components/schemas/Box"}}},required:["boxes"]}}}},401:t}},post:{tags:["Boxes"],summary:"Create a box",description:'Async — returns a job id. agent "none" just creates the box without starting an agent (prompt ignored). provider defaults to docker; a cloud provider must be configured on the host (see GET /providers).',requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/CreateBox"}}}},responses:{202:{description:"Accepted — build job enqueued",content:{"application/json":{schema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"]}}}},400:t,401:t,404:t,503:t}}},"/boxes/{id}":{get:{tags:["Boxes"],summary:"Get one box",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Box",content:{"application/json":{schema:{$ref:"#/components/schemas/Box"}}}},401:t,404:t}}},"/boxes/{id}/{action}":{post:{tags:["Boxes"],summary:"Run a lifecycle action",description:"One of start | pause | resume | stop | destroy | screen. start brings a stopped box back up (resumes if paused, no-op if already running); it does not restart the agent session — that happens on the next attach. screen is the open-VNC prep step: it points the in-box browser at the box’s web app so the VNC desktop shows the app instead of a blank X screen — call it right before opening the box’s vncUrl.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"action",in:"path",required:!0,schema:{type:"string",enum:["start","pause","resume","stop","destroy","screen"]}}],responses:{200:{description:"Done",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/git":{get:{tags:["Box git"],summary:"Get the box's live git summary",description:"The worktree's current branch, dirty, ahead/behind.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Git info",content:{"application/json":{schema:{$ref:"#/components/schemas/GitInfo"}}}},401:t,404:t,503:t}}},"/boxes/{id}/git/{op}":{post:{tags:["Box git"],summary:"Run a git op on the box branch",description:"checkout {branch}; branch {name, from?} (create+switch a new agentbox/* branch); pull {remote?, ffOnly?}; push {remote?, force?}; push-host {as?, force?} (land in the host repo only, publishes nothing).",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"op",in:"path",required:!0,schema:{type:"string",enum:["checkout","branch","pull","push","push-host"]}}],requestBody:{required:!1,content:{"application/json":{schema:{$ref:"#/components/schemas/GitOpBody"}}}},responses:{200:{description:"Done (git stdout/stderr)",content:{"application/json":{schema:{$ref:"#/components/schemas/GitOpResult"}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/branches":{get:{tags:["Box git"],summary:"List the box project's branches",description:"Local + remote branches and the current HEAD, for the box git-panel branch picker.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Branches",content:{"application/json":{schema:{$ref:"#/components/schemas/BranchList"}}}},400:t,401:t,404:t,503:t}}},"/boxes/{id}/services":{get:{tags:["Box services"],summary:"Get the box's service/task/port status",description:"From the box's agentbox.yaml — live, or the persisted snapshot when the box isn't running.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Services",content:{"application/json":{schema:{$ref:"#/components/schemas/Services"}}}},401:t,503:t}}},"/boxes/{id}/services/restart":{post:{tags:["Box services"],summary:"Restart services",description:"Restart one service (body {name}) or every service (empty body).",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"}}}}}},responses:{200:{description:"Restarted",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/rename":{post:{tags:["Boxes"],summary:"Set or clear a box's display label",description:"Cosmetic only — the container, branch and URLs are untouched. Pass an empty string to clear the label. Backs `agentbox status <box> --set-name/--clear-name`.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{displayName:{type:"string",description:"New label (max 60 chars); empty string clears it."}},required:["displayName"]}}}},responses:{200:{description:"Renamed",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/agent":{get:{tags:["Boxes"],summary:"Get the box's in-box coding-agent status snapshot",description:"The agent's live activity (working / idle / waiting / question / end-plan / …), plan/question payload and session title, from the persisted status store. Backs `agentbox agent state/wait-for/get-plan-question`.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Agent state",content:{"application/json":{schema:{$ref:"#/components/schemas/AgentState"}}}},401:t,404:t,503:t}}},"/boxes/{id}/logs":{get:{tags:["Boxes"],summary:"Read (or follow) a box's service log",description:"One of two shapes on one route. `follow=0` (default) returns a JSON `{ output }` snapshot — a bounded `--tail` dump. `follow=1` returns an SSE stream (`open` / `log`* / `end`) the hub pipes live from the in-box `agentbox-ctl logs --follow`. Pass `service=<name>` for a declared service, or `daemon=1` for the ctl-daemon log.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"service",in:"query",required:!1,schema:{type:"string"},description:"A declared service name (required unless daemon=1)."},{name:"daemon",in:"query",required:!1,schema:{type:"string",enum:["1"]},description:"Tail the ctl-daemon log instead of a service."},{name:"follow",in:"query",required:!1,schema:{type:"string",enum:["1"]},description:"Stream the log as SSE instead of returning a snapshot."},{name:"tail",in:"query",required:!1,schema:{type:"integer"},description:"Lines of history (default 200)."}],responses:{200:{description:"Log snapshot (JSON) or SSE stream (text/event-stream when follow=1)",content:{"application/json":{schema:{type:"object",properties:{output:{type:"string"}},required:["output"]}},"text/event-stream":{schema:{type:"string"}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/checkpoint":{post:{tags:["Checkpoints"],summary:"Capture the box state as a project checkpoint",description:"Commits the box (docker commit / cloud snapshot) into the project checkpoint store on the hub machine, via provider.checkpoint.*. A durable project asset — it survives the box. Backs `agentbox checkpoint create`.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{name:{type:"string",description:"Checkpoint name (auto-generated if omitted)."},merged:{type:"boolean",description:"docker: flatten to a single squashed layer (FROM scratch)."},setDefault:{type:"boolean",description:"Also pin this as the project's default checkpoint."},replace:{type:"boolean",description:"Overwrite an existing checkpoint of the same name."}}}}}},responses:{200:{description:"Checkpoint captured",content:{"application/json":{schema:{$ref:"#/components/schemas/CheckpointCreateResult"}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/open":{post:{tags:["Box services"],summary:"Open the box in a host app",description:"Launch the box in a host GUI app (Codex, VS Code/Cursor, cmux, Herdr, iTerm2) by re-shelling `agentbox open --in <app>`. Only works on a localhost hub running on macOS; a remote hub / non-macOS host refuses. An app must be installed and provider-eligible (e.g. Codex is Hetzner-only) — see GET /open-targets.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{app:{type:"string",enum:["codex","herdr","cmux","vscode","iterm2"]}},required:["app"]}}}},responses:{200:{description:"Launched",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/open-targets":{get:{tags:["Box services"],summary:"Which host apps this hub can open a box in",description:'Reports whether the hub can launch host GUI apps (`supported` — true only on a localhost hub on macOS) and, if so, which of Codex/Herdr/cmux/VS Code/iTerm2 are installed plus their provider eligibility. Backs the box detail page "Apps" launchers.',responses:{200:{description:"Open targets",content:{"application/json":{schema:{type:"object",properties:{supported:{type:"boolean"},targets:{type:["object","null"],additionalProperties:{type:"object",properties:{available:{type:"boolean"},providers:{type:"array",items:{type:"string"}}},required:["available"]}}},required:["supported","targets"]}}}},401:t}}},"/projects":{get:{tags:["Projects"],summary:"List registered projects",responses:{200:{description:"Projects",content:{"application/json":{schema:{type:"object",properties:{projects:{type:"array",items:{$ref:"#/components/schemas/Project"}}},required:["projects"]}}}},401:t}},post:{tags:["Projects"],summary:"Register a folder as a project",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{path:{type:"string",description:"Absolute path to the folder."}},required:["path"]}}}},responses:{200:{description:"Registered",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,503:t}}},"/projects/{id}":{delete:{tags:["Projects"],summary:"Unregister an empty project",description:"Folder/files on disk are untouched.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Removed",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},401:t,404:t,409:t,503:t}}},"/projects/{id}/branches":{get:{tags:["Projects"],summary:"List a project's branches",description:"Local + remote branches and the current HEAD, for the create-box base-branch picker.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Branches",content:{"application/json":{schema:{$ref:"#/components/schemas/BranchList"}}}},400:t,401:t,404:t,503:t}}},"/projects/{id}/seed":{get:{tags:["Projects"],summary:"Get a project's seed / custody status",description:"What `agentbox hub project push` stored on the control box (untracked + env/secret tarballs + manifest), as paths, hashes and timestamps only — never seed contents. `custodyAvailable` is false on a hub that is not a control box.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Seed status",content:{"application/json":{schema:{$ref:"#/components/schemas/ProjectSeed"}}}},401:t,404:t}}},"/providers":{get:{tags:["Providers"],summary:"List sandbox providers",description:"With credential + baked status on this host.",responses:{200:{description:"Providers",content:{"application/json":{schema:{type:"object",properties:{providers:{type:"array",items:{$ref:"#/components/schemas/Provider"}}},required:["providers"]}}}},401:t}}},"/providers/{id}/credentials":{post:{tags:["Providers"],summary:"Set a provider's credentials",description:"API keys/tokens, validated then saved to secrets.env. Never echoes secret values.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"]}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",additionalProperties:{type:"string"},description:"Provider-specific fields, e.g. { apiKey } (e2b), { token } (hetzner), { apiKey } or { jwtToken, organizationId } (daytona), { token, teamId?, projectId? } (vercel)."}}}},responses:{200:{description:"Saved",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,503:t}}},"/providers/{id}/prepare":{post:{tags:["Providers"],summary:"Bake a provider's base image",description:"Async — returns a job id. Progress streams over GET /jobs/{id}/logs.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"]}}],requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{force:{type:"boolean"},claudeInstall:{type:"string",enum:["native","npm"]}}}}}},responses:{202:{description:"Bake enqueued",content:{"application/json":{schema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"]}}}},400:t,401:t,409:t,503:t}}},"/hosts":{get:{tags:["Hosts"],summary:"List remote-docker host aliases",description:"Each with its SSH connection and baked/default state.",responses:{200:{description:"Hosts",content:{"application/json":{schema:{type:"object",properties:{hosts:{type:"array",items:{type:"object",properties:{alias:{type:"string"},ssh:{type:"string"},baked:{type:"boolean"},bakedImageRef:{type:"string"},default:{type:"boolean"}},required:["alias","ssh","baked","default"]}}},required:["hosts"]}}}},401:t,503:t}},post:{tags:["Hosts"],summary:"Register a remote-docker host alias",description:"Probes the host (ssh + docker) before saving. Does not bake the image (builds on first create). `default` also pins box.remoteDockerHost.",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{alias:{type:"string"},ssh:{type:"string",description:"an ~/.ssh/config alias or [user@]host[:port]"},default:{type:"boolean"}},required:["alias","ssh"]}}}},responses:{201:{description:"Registered",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,409:t,503:t}}},"/hosts/{alias}":{delete:{tags:["Hosts"],summary:"Forget a remote-docker host alias",description:"Drops the alias + baked-image record + default. Local record only. Returns boxes created against it (now unreachable).",parameters:[{name:"alias",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Removed",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0},boxesAffected:{type:"array",items:{type:"string"}}},required:["ok","boxesAffected"]}}}},401:t,404:t,503:t}}},"/hosts/{alias}/bake":{post:{tags:["Hosts"],summary:"Bake the box image on a host",description:"Async — returns a job id. Progress streams over GET /jobs/{id}/logs (pull from GHCR is fast; a registry-miss build is slow).",parameters:[{name:"alias",in:"path",required:!0,schema:{type:"string"}}],responses:{202:{description:"Bake enqueued",content:{"application/json":{schema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"]}}}},401:t,404:t,503:t}}},"/checkpoints":{get:{tags:["Checkpoints"],summary:"List a project's (or every project's) checkpoints",description:"The project checkpoint store lives on the hub machine, keyed by the absolute project root. Pass `?project=<abs root>` for one project, or `?global=1` for every project. Backs `agentbox checkpoint ls` / `ls -g`.",parameters:[{name:"project",in:"query",required:!1,schema:{type:"string"},description:"Absolute project root (required unless global=1)."},{name:"global",in:"query",required:!1,schema:{type:"string",enum:["1"]},description:"List checkpoints for every project."}],responses:{200:{description:"Checkpoints",content:{"application/json":{schema:{$ref:"#/components/schemas/CheckpointListing"}}}},400:t,401:t,503:t}},delete:{tags:["Checkpoints"],summary:"Delete a checkpoint",description:"Removes one checkpoint from every store that had it and sweeps any dangling default-checkpoint config pointer. Backs `agentbox checkpoint rm`.",parameters:[{name:"project",in:"query",required:!0,schema:{type:"string"},description:"Absolute project root."},{name:"ref",in:"query",required:!0,schema:{type:"string"},description:"The checkpoint name."},{name:"provider",in:"query",required:!1,schema:{type:"string"},description:"Scope the delete to one provider store."}],responses:{200:{description:"Deleted",content:{"application/json":{schema:{$ref:"#/components/schemas/CheckpointRemoveResult"}}}},400:t,401:t,404:t,503:t}}},"/prune":{post:{tags:["Fleet"],summary:"Prune orphan boxes and resources",description:"Without a provider (or provider `docker`) it reaps orphan docker records, containers, volumes, snapshot/box dirs — and, with `all`, orphan project configs. With a cloud provider it enumerates untracked sandboxes and (when not a `dryRun`) deletes them AND reaps their control-box registrations. Durable project checkpoints are always left intact. Backs `agentbox prune`.",requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{provider:{type:"string",description:"Cloud provider to prune; omit (or `docker`) for the local docker sweep."},all:{type:"boolean",description:"docker: also remove orphan per-project config dirs."},dryRun:{type:"boolean",description:"Report what would be removed without removing anything."}}}}}},responses:{200:{description:"Prune result",content:{"application/json":{schema:{$ref:"#/components/schemas/PruneResult"}}}},400:t,401:t,409:t,503:t}}},"/approvals":{get:{tags:["Approvals"],summary:"List pending host-action approvals",responses:{200:{description:"Approvals",content:{"application/json":{schema:{type:"object",properties:{approvals:{type:"array",items:{$ref:"#/components/schemas/Approval"}}},required:["approvals"]}}}},401:t}}},"/approvals/{id}/answer":{post:{tags:["Approvals"],summary:"Answer a pending approval",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{answer:{type:"string",enum:["y","n"]},cancelled:{type:"boolean",description:"Mark a dismissal distinctly from a plain deny in the audit trail (the `agent approve --cancel` capability). Still leaves the action unapproved."}},required:["answer"]}}}},responses:{200:{description:"Resolved",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,503:t}}},"/boxes/{id}/stream":{get:{tags:["Approvals"],summary:"Subscribe to a box's live event stream (SSE)",description:"Payload-carrying Server-Sent Events for one box — the attach footer's channel. Emits `open` (first frame of every connect, followed by a backlog flush of everything still live), `prompt-ask` (the full pending-approval payload), `prompt-resolved` (`{ id }`), `notice-set`/`notice-clear`, `box-status` (the in-box daemon's latest snapshot: agent activity, session titles, service/task states), and a `ping` heartbeat. `box-status` is the only status source for a box this hub owns but the client does not — the durable status file is written by whichever relay the box reports to. Distinct from GET /api/events, which carries refetch signals only (`data: {}`). Degrades to open + heartbeat on a hub topology with no in-process relay.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"SSE stream (text/event-stream)",content:{"text/event-stream":{schema:{type:"string"}}}},401:t}}},"/jobs":{get:{tags:["Jobs"],summary:"List background jobs",description:"The unified job listing — the local file queue's create jobs merged with, on a control box, the control-plane create queue. Backs `agentbox queue list` and `agentbox hub jobs`.",responses:{200:{description:"Jobs",content:{"application/json":{schema:{type:"object",properties:{jobs:{type:"array",items:{$ref:"#/components/schemas/JobListItem"}}},required:["jobs"]}}}},401:t,503:t}}},"/jobs/{id}":{get:{tags:["Jobs"],summary:"Get a create job status",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Job",content:{"application/json":{schema:{$ref:"#/components/schemas/Job"}}}},401:t,404:t}}},"/jobs/{id}/logs":{get:{tags:["Jobs"],summary:"Stream a create job log (SSE)",description:"text/event-stream. Emits `open`, then `log` events per line, then a terminal `end` event with the final status.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"SSE stream",content:{"text/event-stream":{}}},401:t,404:t,503:t}}},"/jobs/{id}/login-code":{post:{tags:["Jobs"],summary:"Deliver an OAuth login code to a create job",description:"Feeds a pasted Claude OAuth approval code to a create job that is awaiting a re-login. The create worker consumes it and completes the in-box login. The one interactive create affordance that survives.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{code:{type:"string",description:"The OAuth approval code."}},required:["code"]}}}},responses:{200:{description:"Accepted",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,503:t}}},"/custody":{get:{tags:["Custody"],summary:"List the custody manifest (metadata only)",description:"What the hub holds so a box created from either side is usable from both: agent credentials, project seeds, provider bake records, and per-box SSH keys. Returns paths, hashes, sizes and mtimes ONLY — value bytes never leave the box (same contract as `agentbox hub custody list`). Optional `?prefix=` scopes the listing to a custody scope (`agents` | `projects` | `prepared` | `boxes`) or a `scope/subject`.",parameters:[{name:"prefix",in:"query",required:!1,schema:{type:"string"},description:"A custody scope or scope/subject, e.g. `agents` or `boxes/box-abc`."}],responses:{200:{description:"Custody manifest",content:{"application/json":{schema:{$ref:"#/components/schemas/Custody"}}}},400:t,401:t}}},"/custody/{path}":{parameters:[{name:"path",in:"path",required:!0,schema:{type:"string"},description:"Custody path, e.g. `agents/claude/.credentials.json` or `boxes/box-abc/ssh/id_ed25519`."}],get:{tags:["Custody"],summary:"Read a stored blob (ELEVATED — admin token required on a control box)",description:"Returns the entry metadata AND its bytes (`data`, base64). This is the ONE byte-returning custody route, so it is gated beyond the hub API key: on a control box (password profile) it additionally requires the admin token in `X-Agentbox-Admin-Token` — a byte-read with only the API key is `401`, so a value never leaves the box to a thin client. A localhost hub (token profile) needs no admin token: its hub token is a machine-local secret that already gates the whole surface. Backs `agentbox hub credentials pull` / `custody pull` and per-box SSH-key adoption.",responses:{200:{description:"The stored entry + its base64 bytes",content:{"application/json":{schema:{$ref:"#/components/schemas/CustodyValue"}}}},400:t,401:t,404:t}},put:{tags:["Custody"],summary:"Store bytes at a custody path (metadata-only response)",description:"Stores `data` (base64) at the path. Content-addressed: `changed` is false when the identical bytes were already there. The response is METADATA ONLY — it never echoes the stored value. Backs `agentbox hub credentials/secrets/project push`.",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["data"],properties:{data:{type:"string",description:"base64-encoded bytes"}}}}}},responses:{200:{description:"Stored (metadata only)",content:{"application/json":{schema:{$ref:"#/components/schemas/CustodyPutResult"}}}},400:t,401:t}},delete:{tags:["Custody"],summary:"Delete a custody entry",description:"Removes one entry. Backs `agentbox hub custody rm`.",responses:{204:{description:"Deleted"},400:t,401:t,404:t}}},"/custody/blob/{path}":{parameters:[{name:"path",in:"path",required:!0,schema:{type:"string"},description:"Custody path, e.g. `projects/acme__web/seed/carry.tar.gz`."}],get:{tags:["Custody"],summary:"Stream a stored blob (ELEVATED — admin token required on a control box)",description:"Raw `application/octet-stream` counterpart of GET /custody/{path}, for values too large to buffer as base64. Same elevated gate, for the same reason (custody holds credentials and SSH private keys) — streaming changes the transport, never the trust. `X-Agentbox-Sha256` carries the digest.",responses:{200:{description:"The stored bytes",content:{"application/octet-stream":{schema:{type:"string",format:"binary"}}}},400:t,401:t,404:t}},put:{tags:["Custody"],summary:"Stream bytes into a custody path",description:"Raw `application/octet-stream` counterpart of PUT /custody/{path}. The JSON route stays the simple, general-purpose API for small values (credentials, .env, SSH keys); this one exists for payloads where base64-in-JSON costs several times the payload in peak memory on both ends — chiefly a project's `carry:` material, which can run to `box.cpMaxBytes` (100 MiB). Capped by AGENTBOX_CUSTODY_MAX_BLOB_BYTES and enforced mid-stream, so an over-cap upload is cut off rather than landed. Returns metadata only, and is content-addressed (`changed: false` when the bytes were already stored).",requestBody:{required:!0,content:{"application/octet-stream":{schema:{type:"string",format:"binary"}}}},responses:{200:{description:"Stored (metadata only)",content:{"application/json":{schema:{$ref:"#/components/schemas/CustodyPutResult"}}}},400:t,401:t}}},"/system":{get:{tags:["System"],summary:"Get hub build + provider bake status",description:'Answers "what is running here, and do I need to re-bake?": hub version + channel + build source, the deploy record (when this machine is an exposed/deployed control box), each base provider’s baked fingerprint and freshness (`baseStatus` `stale` = re-bake), and the box-image build-context manifest. Freshness is populated only on the in-process host topology (like GET /providers?freshness=1).',responses:{200:{description:"System info",content:{"application/json":{schema:{$ref:"#/components/schemas/System"}}}},401:t}}}},components:{securitySchemes:{bearerAuth:{type:"http",scheme:"bearer",description:"The hub token (Authorization: Bearer <token>)."}},schemas:{Health:{type:"object",properties:{ok:{const:!0},apiVersion:{type:"string"},profile:{type:"string"}},required:["ok","apiVersion"]},CustodyEntry:{type:"object",description:"One stored item — metadata only; the value bytes are never returned.",properties:{path:{type:"string",description:"Custody-relative path, e.g. agents/claude/.credentials.json"},size:{type:"number"},sha256:{type:"string",description:"Hex sha256 of the stored bytes"},mode:{type:"number",description:"POSIX mode of the stored value"},updatedAt:{type:"string",description:"ISO timestamp of the last write"}},required:["path","size","sha256","mode","updatedAt"]},CustodyPutResult:{type:"object",description:"A store result — metadata only, never the stored value.",allOf:[{$ref:"#/components/schemas/CustodyEntry"},{type:"object",properties:{changed:{type:"boolean",description:"false when the identical bytes were already stored (content-addressed)"}},required:["changed"]}]},CustodyValue:{type:"object",description:"A stored entry AND its bytes — only the elevated byte-read GET returns this.",allOf:[{$ref:"#/components/schemas/CustodyEntry"},{type:"object",properties:{data:{type:"string",description:"base64-encoded stored bytes"}},required:["data"]}]},Custody:{type:"object",properties:{enabled:{type:"boolean",description:"false only when this hub has no custody store wired"},entries:{type:"array",items:{$ref:"#/components/schemas/CustodyEntry"}}},required:["enabled","entries"]},ProviderBake:{type:"object",properties:{id:{type:"string"},label:{type:"string"},baked:{type:"boolean"},fingerprint:{type:"string",description:"Short (12-char) build-context fingerprint of the baked base"},cliVersion:{type:"string"},bakedAt:{type:"string"},imageRef:{type:"string"},baseStatus:{type:"string",enum:["fresh","stale","unprepared","unknown"]},baseStaleReason:{type:"string"},bakeDiff:{type:"object",description:"Which files differ, when baseStatus is stale. hasManifest:false means the base was baked before per-file manifests were recorded, so no diff is possible without a re-bake.",properties:{hasManifest:{type:"boolean"},liveUnavailable:{type:"boolean",description:"A manifest exists but the current hashes could not be computed, so no diff is possible. Distinct from hasManifest:false, where a re-bake would help."},changed:{type:"array",items:{type:"object",properties:{rel:{type:"string"},from:{type:"string"},to:{type:"string"}}}},added:{type:"array",items:{type:"string"}},removed:{type:"array",items:{type:"string"}}},required:["hasManifest"]}},required:["id","label","baked"]},System:{type:"object",properties:{hub:{type:"object",properties:{version:{type:["string","null"]},commit:{type:["string","null"]},profile:{type:"string"},apiVersion:{type:"string"}},required:["profile","apiVersion"]},build:{type:"object",properties:{version:{type:["string","null"]},channel:{type:["string","null"],description:"stable | nightly | source (<ref>)"},build:{type:["string","null"],description:"Human build line, e.g. @madarco/agentbox@0.28.0 (npm)"}}},deploy:{type:["object","null"],description:"Present only when this machine is an exposed/deployed control box."},providers:{type:"array",items:{$ref:"#/components/schemas/ProviderBake"}},hostCarried:{type:"array",description:"Agent configs, skills and identity files THIS machine hands to a box. Present-only: a path absent here is one a box will not receive.",items:{type:"object",properties:{agent:{type:"string"},label:{type:"string"},hostPath:{type:"string"},kind:{type:"string",enum:["skills","config","identity"]},skills:{type:"array",items:{type:"string"}}},required:["agent","label","hostPath","kind"]}},boxImage:{type:["object","null"],description:"Box-image resolution: the registry, the exact fingerprint-tag this host pulls, and what it last stamped.",properties:{registry:{type:"string"},pullTag:{type:"string"},stampedFingerprint:{type:"string"},imageRef:{type:"string"},bakedAt:{type:"string"}}}},required:["hub","build","providers","hostCarried"]},Error:{type:"object",properties:{error:{type:"object",properties:{code:{type:"string"},message:{type:"string"},details:{}},required:["code","message"]}},required:["error"]},Box:{type:"object",properties:{id:{type:"string"},projectId:{type:"string"},repo:{type:"string"},branch:{type:"string"},task:{type:"string"},agent:{type:"string"},status:{type:"string",enum:["running","paused","stopped","creating","error"]},createdAt:{type:"number"},lastActivity:{type:"number"},host:{type:"string"},commits:{type:["number","null"]},filesTouched:{type:["number","null"]},error:{type:["string","null"]},displayName:{type:["string","null"],description:"Cosmetic user-set label (rename); null when unset"},webUrl:{type:["string","null"],description:"Host-openable web-service URL; null when absent/unreachable (e.g. paused)"},vncUrl:{type:["string","null"],description:"Host-openable VNC desktop URL; null when absent/unreachable"},state:{type:"string",enum:["running","paused","stopped","missing"],description:"Raw provider runtime state (host topology only). Absent on synthetic creating/error rows — presence distinguishes a real box whose agent errored from a failed create job."},name:{type:"string"},provider:{type:"string",description:"Raw provider id ('docker', 'daytona', …; plugin ids possible)"},projectRoot:{type:"string",description:"Absolute host path of the project. Host topology only — never emitted by the hosted plane"},projectIndex:{type:"number"},vncEnabled:{type:"boolean"},gitWorktrees:{type:"array",items:{type:"object",properties:{kind:{type:"string"},branch:{type:"string"}}}},claudeSessionTitle:{type:"string"},codexSessionTitle:{type:"string"},opencodeSessionTitle:{type:"string"},claudeActivity:{type:"string",description:"working | idle | waiting | end-plan | question | compacting | error | unknown"},codexActivity:{type:"string"},shellCount:{type:"number",description:'Live shell-session count (docker only); absent → the CLI renders "-".'},sandboxId:{type:"string",description:"Provider-native sandbox id (cloud boxes). Part of the non-secret adoption block a thin client rebuilds a drivable local record from — tokens are never serialized, a fresh adoption re-mints them."},originUrl:{type:["string","null"],description:"Box repo's origin remote URL. Lets project-scoped `ls` match a box to the cwd repo by identity when its projectRoot is a remote hub's path. Populated for any registered box, docker included."},publicHost:{type:"string",description:"Public IP/host of the box VM (direct-SSH providers: hetzner/digitalocean)."},image:{type:"string",description:"Base image / snapshot ref the sandbox booted from."},webPort:{type:"number",description:"In-box WebProxy port (cloud boxes bind a non-privileged port)."},previewUrls:{type:"object",additionalProperties:{type:"string"},description:"Token-authed preview URLs keyed by in-box port."},lastAgent:{type:"string",enum:["claude","codex","opencode"],description:"The agent the box was created for."},topology:{type:"string",description:"Sync federation shape ('cloud' | 'control-plane'); absent for docker."}},required:["id","projectId","status","agent"]},Project:{type:"object",properties:{id:{type:"string"},name:{type:"string"},repo:{type:"string"},defaultBranch:{type:"string"},currentBranch:{type:"string",nullable:!0},needsSetup:{type:"boolean",description:"No agentbox.yaml + no default snapshot — the create form offers the setup wizard"},provider:{type:"string"},createdAt:{type:"number"},originUrl:{type:"string",nullable:!0,description:"Repo origin remote URL (hosted source only)"},projectSlug:{type:"string",nullable:!0,description:"Custody projects/<slug> key (hosted source only)"}},required:["id","name"]},ProjectSeed:{type:"object",properties:{custodyAvailable:{type:"boolean",description:"False when this hub is not a control box (no custody store)"},seed:{type:"object",nullable:!0,description:"Null when nothing has been pushed for this project.",properties:{slug:{type:"string"},originUrl:{type:"string"},baseBranch:{type:"string"},repoHeadSha:{type:"string",description:"Full commit the working tree sat on"},capturedAt:{type:"string",description:"ISO timestamp of the last seed push"},hasEnv:{type:"boolean",description:"env/secret tarball present"},hasUntracked:{type:"boolean",description:"untracked-files tarball present"},totalBytes:{type:"number"},entries:{type:"array",items:{type:"object",properties:{name:{type:"string"},size:{type:"number"},sha256:{type:"string"},updatedAt:{type:"string"}},required:["name","size","sha256","updatedAt"]}}},required:["slug","hasEnv","hasUntracked","totalBytes","entries"]}},required:["custodyAvailable","seed"]},BranchList:{type:"object",properties:{current:{type:"string",nullable:!0,description:"The repo's current HEAD (the default base ref)"},branches:{type:"array",items:{type:"string"},description:"Local + remote-tracking branch names"}},required:["branches"]},Approval:{type:"object",properties:{id:{type:"string"},boxId:{type:"string"},message:{type:"string"},detail:{type:"string"},command:{type:"string"},cwd:{type:"string"},argv:{type:"array",items:{type:"string"}},defaultAnswer:{type:"string",enum:["y","n"]},createdAt:{type:"number"}},required:["id","boxId","message","defaultAnswer"]},Job:{type:"object",properties:{id:{type:"string"},status:{type:"string",enum:["queued","running","done","failed","cancelled"]},boxId:{type:"string"},error:{type:"string",description:"A failed job's reason — so a create reports the failure, not a silent 'done'."},provider:{type:"string"},name:{type:"string"},agent:{type:"string"},createdAt:{type:"string"},login:{type:"object",description:"Present when the create is awaiting a Claude re-login (see POST /jobs/{id}/login-code).",properties:{required:{type:"boolean"},phase:{type:"string"},url:{type:"string"},error:{type:"string"},lastError:{type:"string"}}}},required:["id","status"]},JobListItem:{type:"object",description:"One row of GET /jobs — the Job shape without the streamable log path.",properties:{id:{type:"string"},status:{type:"string",enum:["queued","running","done","failed","cancelled"]},boxId:{type:"string"},error:{type:"string"},provider:{type:"string"},name:{type:"string"},agent:{type:"string"},createdAt:{type:"string"}},required:["id","status"]},AgentState:{type:"object",description:"The box's in-box coding-agent status snapshot. `claude` is the raw ctl status payload (activity, plan/question, session title); null when no snapshot exists yet.",properties:{claude:{description:"Raw BoxStatusClaude payload (opaque here)."}},required:["claude"]},CheckpointCreateResult:{type:"object",properties:{ok:{const:!0},name:{type:"string"},kind:{type:"string",description:"docker manifest type ('layered' | 'merged') or 'snapshot' for a cloud backend."},ref:{type:"string",description:"The image tag / snapshot id created."},provider:{type:"string"},dir:{type:"string",description:"Snapshot dir (cloud backends)."},setDefaultKey:{type:"string",description:"The config key written when setDefault was requested."}},required:["ok","name","kind","ref","provider"]},CheckpointItem:{type:"object",properties:{name:{type:"string"},provider:{type:"string",description:"'docker' or the cloud backend name."},kind:{type:"string"},sourceBoxName:{type:"string"},createdAt:{type:"string"},isDefault:{type:"boolean",description:"Resolved server-side against the project's effective config."}},required:["name","provider","kind","isDefault"]},CheckpointListing:{type:"object",properties:{projects:{type:"array",items:{type:"object",properties:{segment:{type:"string",description:"The path-hash store segment."},projectRoot:{type:"string",description:"Absent for an orphan segment whose project config was GC-ed."},label:{type:"string"},items:{type:"array",items:{$ref:"#/components/schemas/CheckpointItem"}}},required:["segment","label","items"]}}},required:["projects"]},CheckpointRemoveResult:{type:"object",properties:{ok:{const:!0},removed:{type:"array",items:{type:"string"},description:"Providers the checkpoint was deleted from."},clearedKeys:{type:"array",items:{type:"string"},description:"Default-checkpoint config pointers cleared in the project layer."},warnedKeys:{type:"array",items:{type:"string"},description:"Dangling pointers in a layer we can't auto-edit (warned, not cleared)."}},required:["ok","removed","clearedKeys","warnedKeys"]},PruneResult:{description:"The prune outcome — discriminated by `kind`: `general` (docker sweep), `cloud` (untracked cloud sandboxes).",oneOf:[{type:"object",properties:{kind:{const:"general"},result:{type:"object",properties:{removedRecords:{type:"array",items:{type:"string"}},removedContainers:{type:"array",items:{type:"string"}},removedVolumes:{type:"array",items:{type:"string"}},removedSnapshotDirs:{type:"array",items:{type:"string"}},removedBoxDirs:{type:"array",items:{type:"string"}},removedCheckpointImages:{type:"array",items:{type:"string"}},dryRun:{type:"boolean"}},required:["dryRun"]},projectConfigs:{type:"array",items:{type:"string"}}},required:["kind","result","projectConfigs"]},{type:"object",properties:{kind:{const:"cloud"},provider:{type:"string"},dryRun:{type:"boolean"},orphans:{type:"array",items:{type:"object",properties:{sandboxId:{type:"string"},name:{type:"string"},state:{type:"string"},createdAt:{type:"string"}},required:["sandboxId"]}},deleted:{type:"number"},failed:{type:"number"},reaped:{type:"number",description:"Control-box registrations reaped for the deleted sandboxes (0 on a dry run)."}},required:["kind","provider","dryRun","orphans","deleted","failed","reaped"]}]},CreateBox:{type:"object",properties:{projectId:{type:"string"},agent:{type:"string",enum:["claude","codex","opencode","none"]},provider:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"],default:"docker"},name:{type:"string"},prompt:{type:"string"},fromBranch:{type:"string",description:"Base ref the box's per-box branch forks from (branch / tag / SHA); default the project's HEAD"},setupWizard:{type:"boolean",description:'Seed the agent\'s first turn to generate agentbox.yaml (for projects with none). Inert for agent "none".'}},required:["projectId","agent"]},Provider:{type:"object",properties:{id:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"]},label:{type:"string"},configured:{type:"boolean",description:"Base image baked (usable for create) on this host."},hasCredentials:{type:"boolean",description:"Credentials present (docker: always true). Can be true while not yet configured (baked)."},jobId:{type:"string",description:"Id of an in-flight bake (prepare) job for this provider, if any."},reason:{type:"string"}},required:["id","label","configured"]},GitOpBody:{type:"object",description:"Union of git-op fields; only those for the chosen {op} are read (extras are ignored).",properties:{branch:{type:"string",description:"checkout: branch to switch to"},name:{type:"string",description:"branch: new branch name (agentbox/ prefix added when missing)"},from:{type:"string",description:"branch: base ref to fork from (default: box's HEAD)"},remote:{type:"string",description:"push/pull: remote name (default: origin)"},force:{type:"boolean",description:"push: force the remote push; push-host: overwrite the destination branch"},ffOnly:{type:"boolean",description:"pull: pass --ff-only to the merge"},as:{type:"string",description:"push-host: destination branch name in the host repo (default: the box's branch)"}}},GitOpResult:{type:"object",properties:{ok:{const:!0},stdout:{type:"string"},stderr:{type:"string"}},required:["ok"]},GitInfo:{type:"object",properties:{ok:{type:"boolean"},branch:{type:"string"},dirty:{type:"boolean"},ahead:{type:"number"},behind:{type:"number"},error:{type:"string"}},required:["ok"]},Services:{type:"object",properties:{source:{type:"string",enum:["live","persisted","unavailable"]},services:{type:"array",items:{type:"object",properties:{name:{type:"string"},state:{type:"string"},pid:{type:["number","null"]},restarts:{type:"number"},lastExitCode:{type:["number","null"]},blockedOn:{type:"array",items:{type:"string"}},command:{type:"string"}},required:["name","state"]}},tasks:{type:"array",items:{type:"object",properties:{name:{type:"string"},state:{type:"string"}},required:["name","state"]}},ports:{type:"array",items:{type:"object",properties:{port:{type:"number"},service:{type:["string","null"]}},required:["port"]}},error:{type:"string"}},required:["source","services","tasks","ports"]}}}}},"docsHtml",0,function(){return`<!doctype html>
1
+ module.exports=[48806,e=>{"use strict";let t={description:"Error",content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}}};e.s(["buildOpenApi",0,function(){return{openapi:"3.1.0",info:{title:"AgentBox Hub API",version:"1.0.0",description:'Launch and manage AgentBox sandboxes ("boxes") programmatically. Every endpoint except /health, /openapi.json and /docs requires an Authorization: Bearer <hub token> header (the token the hub prints on boot, also at ~/.agentbox/hub/token). Errors always return { error: { code, message, details? } }.'},servers:[{url:"/api/v1"}],security:[{bearerAuth:[]}],tags:[{name:"System",description:"Liveness and API version."},{name:"Boxes",description:"Create, inspect, and run lifecycle actions on boxes."},{name:"Box git",description:"Git state and operations on a box's branch."},{name:"Box services",description:"A box's agentbox.yaml service/task/port status."},{name:"Projects",description:"Register folders as projects and list their branches."},{name:"Providers",description:"Sandbox providers: status, credentials, base-image bake."},{name:"Hosts",description:"Remote-docker host aliases (name -> SSH connection)."},{name:"Approvals",description:"Pending host-action approvals."},{name:"Jobs",description:"Async create/bake job status and log streams."},{name:"Checkpoints",description:"Durable per-project checkpoints (docker image / cloud snapshot)."},{name:"Fleet",description:"Fleet-wide maintenance (prune orphan boxes and resources)."},{name:"Custody",description:"What the control box holds in custody (metadata only — never values)."}],paths:{"/health":{get:{tags:["System"],summary:"Get liveness + API version",security:[],responses:{200:{description:"OK",content:{"application/json":{schema:{$ref:"#/components/schemas/Health"}}}}}}},"/boxes":{get:{tags:["Boxes"],summary:"List or resolve boxes",description:"Lists every box (normalized view). ?live=1 refreshes each cloud box state with an SDK probe (opt-in, slower; host topology only). ?ref=<id|name|index> instead resolves a single box server-side (findBox semantics: exact id, unique id prefix, name, displayName, sandbox id); pass ?project=<host-path> for numeric project-index refs. The ref response is the match set in { boxes }: 0 (none), 1 (unique), or >1 (ambiguous prefix).",parameters:[{name:"live",in:"query",required:!1,schema:{type:"string",enum:["1"]}},{name:"ref",in:"query",required:!1,schema:{type:"string"}},{name:"project",in:"query",required:!1,schema:{type:"string"}}],responses:{200:{description:"Boxes",content:{"application/json":{schema:{type:"object",properties:{boxes:{type:"array",items:{$ref:"#/components/schemas/Box"}}},required:["boxes"]}}}},401:t}},post:{tags:["Boxes"],summary:"Create a box",description:'Async — returns a job id. agent "none" just creates the box without starting an agent (prompt ignored). provider defaults to docker; a cloud provider must be configured on the host (see GET /providers).',requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/CreateBox"}}}},responses:{202:{description:"Accepted — build job enqueued",content:{"application/json":{schema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"]}}}},400:t,401:t,404:t,503:t}}},"/boxes/{id}":{get:{tags:["Boxes"],summary:"Get one box",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Box",content:{"application/json":{schema:{$ref:"#/components/schemas/Box"}}}},401:t,404:t}}},"/boxes/{id}/{action}":{post:{tags:["Boxes"],summary:"Run a lifecycle action",description:"One of start | pause | resume | stop | destroy | screen. start brings a stopped box back up (resumes if paused, no-op if already running); it does not restart the agent session — that happens on the next attach. screen is the open-VNC prep step: it points the in-box browser at the box’s web app so the VNC desktop shows the app instead of a blank X screen — call it right before opening the viewer. It does not return a URL; get that from GET /boxes/{id}/vnc.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"action",in:"path",required:!0,schema:{type:"string",enum:["start","pause","resume","stop","destroy","screen"]}}],responses:{200:{description:"Done",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/git":{get:{tags:["Box git"],summary:"Get the box's live git summary",description:"The worktree's current branch, dirty, ahead/behind.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Git info",content:{"application/json":{schema:{$ref:"#/components/schemas/GitInfo"}}}},401:t,404:t,503:t}}},"/boxes/{id}/git/{op}":{post:{tags:["Box git"],summary:"Run a git op on the box branch",description:"checkout {branch}; branch {name, from?} (create+switch a new agentbox/* branch); pull {remote?, ffOnly?}; push {remote?, force?}; push-host {as?, force?} (land in the host repo only, publishes nothing).",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"op",in:"path",required:!0,schema:{type:"string",enum:["checkout","branch","pull","push","push-host"]}}],requestBody:{required:!1,content:{"application/json":{schema:{$ref:"#/components/schemas/GitOpBody"}}}},responses:{200:{description:"Done (git stdout/stderr)",content:{"application/json":{schema:{$ref:"#/components/schemas/GitOpResult"}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/branches":{get:{tags:["Box git"],summary:"List the box project's branches",description:"Local + remote branches and the current HEAD, for the box git-panel branch picker.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Branches",content:{"application/json":{schema:{$ref:"#/components/schemas/BranchList"}}}},400:t,401:t,404:t,503:t}}},"/boxes/{id}/services":{get:{tags:["Box services"],summary:"Get the box's service/task/port status",description:"From the box's agentbox.yaml — live, or the persisted snapshot when the box isn't running.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Services",content:{"application/json":{schema:{$ref:"#/components/schemas/Services"}}}},401:t,503:t}}},"/boxes/{id}/services/restart":{post:{tags:["Box services"],summary:"Restart services",description:"Restart one service (body {name}) or every service (empty body).",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"}}}}}},responses:{200:{description:"Restarted",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/vnc":{get:{tags:["Boxes"],summary:"Mint the box's noVNC viewer URL",description:"A ready-to-open noVNC URL (autoconnect, password in the query). Cloud boxes get a freshly SIGNED preview URL on port 6080 that expires — which is why the Box payload's `vncUrl` is null for daytona/vercel/e2b and this must be called at click time. Docker/hetzner boxes return their stable Portless/OrbStack/loopback URL. Read-only: refused with 409 when the box is not running, has VNC disabled, or has no recorded password. Pair with POST /boxes/{id}/screen to point the in-box browser at the web app first.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"ttl",in:"query",required:!1,description:"Cloud only: signed-URL lifetime in seconds (provider default 3600).",schema:{type:"integer",minimum:1,maximum:86400}},{name:"loopback",in:"query",required:!1,description:"Docker only: prefer the 127.0.0.1 host-port URL over OrbStack/Portless.",schema:{type:"string",enum:["1"]}}],responses:{200:{description:"Viewer URL",content:{"application/json":{schema:{type:"object",properties:{url:{type:"string"},ttl:{type:"integer"}},required:["url"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/rename":{post:{tags:["Boxes"],summary:"Set or clear a box's display label",description:"Cosmetic only — the container, branch and URLs are untouched. Pass an empty string to clear the label. Backs `agentbox status <box> --set-name/--clear-name`.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{displayName:{type:"string",description:"New label (max 60 chars); empty string clears it."}},required:["displayName"]}}}},responses:{200:{description:"Renamed",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/agent":{get:{tags:["Boxes"],summary:"Get the box's in-box coding-agent status snapshot",description:"The agent's live activity (working / idle / waiting / question / end-plan / …), plan/question payload and session title, from the persisted status store. Backs `agentbox agent state/wait-for/get-plan-question`.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Agent state",content:{"application/json":{schema:{$ref:"#/components/schemas/AgentState"}}}},401:t,404:t,503:t}}},"/boxes/{id}/logs":{get:{tags:["Boxes"],summary:"Read (or follow) a box's service log",description:"One of two shapes on one route. `follow=0` (default) returns a JSON `{ output }` snapshot — a bounded `--tail` dump. `follow=1` returns an SSE stream (`open` / `log`* / `end`) the hub pipes live from the in-box `agentbox-ctl logs --follow`. Pass `service=<name>` for a declared service, or `daemon=1` for the ctl-daemon log.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"service",in:"query",required:!1,schema:{type:"string"},description:"A declared service name (required unless daemon=1)."},{name:"daemon",in:"query",required:!1,schema:{type:"string",enum:["1"]},description:"Tail the ctl-daemon log instead of a service."},{name:"follow",in:"query",required:!1,schema:{type:"string",enum:["1"]},description:"Stream the log as SSE instead of returning a snapshot."},{name:"tail",in:"query",required:!1,schema:{type:"integer"},description:"Lines of history (default 200)."}],responses:{200:{description:"Log snapshot (JSON) or SSE stream (text/event-stream when follow=1)",content:{"application/json":{schema:{type:"object",properties:{output:{type:"string"}},required:["output"]}},"text/event-stream":{schema:{type:"string"}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/checkpoint":{post:{tags:["Checkpoints"],summary:"Capture the box state as a project checkpoint",description:"Commits the box (docker commit / cloud snapshot) into the project checkpoint store on the hub machine, via provider.checkpoint.*. A durable project asset — it survives the box. Backs `agentbox checkpoint create`.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{name:{type:"string",description:"Checkpoint name (auto-generated if omitted)."},merged:{type:"boolean",description:"docker: flatten to a single squashed layer (FROM scratch)."},setDefault:{type:"boolean",description:"Also pin this as the project's default checkpoint."},replace:{type:"boolean",description:"Overwrite an existing checkpoint of the same name."}}}}}},responses:{200:{description:"Checkpoint captured",content:{"application/json":{schema:{$ref:"#/components/schemas/CheckpointCreateResult"}}}},400:t,401:t,404:t,409:t,503:t}}},"/boxes/{id}/open":{post:{tags:["Box services"],summary:"Open the box in a host app",description:"Launch the box in a host GUI app (Codex, VS Code/Cursor, cmux, Herdr, iTerm2) by re-shelling `agentbox open --in <app>`. Only works on a localhost hub running on macOS; a remote hub / non-macOS host refuses. An app must be installed and provider-eligible (e.g. Codex is Hetzner-only) — see GET /open-targets.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{app:{type:"string",enum:["codex","herdr","cmux","vscode","iterm2"]}},required:["app"]}}}},responses:{200:{description:"Launched",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,409:t,503:t}}},"/open-targets":{get:{tags:["Box services"],summary:"Which host apps this hub can open a box in",description:'Reports whether the hub can launch host GUI apps (`supported` — true only on a localhost hub on macOS) and, if so, which of Codex/Herdr/cmux/VS Code/iTerm2 are installed plus their provider eligibility. Backs the box detail page "Apps" launchers.',responses:{200:{description:"Open targets",content:{"application/json":{schema:{type:"object",properties:{supported:{type:"boolean"},targets:{type:["object","null"],additionalProperties:{type:"object",properties:{available:{type:"boolean"},providers:{type:"array",items:{type:"string"}}},required:["available"]}}},required:["supported","targets"]}}}},401:t}}},"/projects":{get:{tags:["Projects"],summary:"List registered projects",responses:{200:{description:"Projects",content:{"application/json":{schema:{type:"object",properties:{projects:{type:"array",items:{$ref:"#/components/schemas/Project"}}},required:["projects"]}}}},401:t}},post:{tags:["Projects"],summary:"Register a folder as a project",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{path:{type:"string",description:"Absolute path to the folder."}},required:["path"]}}}},responses:{200:{description:"Registered",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,503:t}}},"/projects/{id}":{delete:{tags:["Projects"],summary:"Unregister an empty project",description:"Folder/files on disk are untouched.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Removed",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},401:t,404:t,409:t,503:t}}},"/projects/{id}/branches":{get:{tags:["Projects"],summary:"List a project's branches",description:"Local + remote branches and the current HEAD, for the create-box base-branch picker.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Branches",content:{"application/json":{schema:{$ref:"#/components/schemas/BranchList"}}}},400:t,401:t,404:t,503:t}}},"/projects/{id}/seed":{get:{tags:["Projects"],summary:"Get a project's seed / custody status",description:"What `agentbox hub project push` stored on the control box (untracked + env/secret tarballs + manifest), as paths, hashes and timestamps only — never seed contents. `custodyAvailable` is false on a hub that is not a control box.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Seed status",content:{"application/json":{schema:{$ref:"#/components/schemas/ProjectSeed"}}}},401:t,404:t}}},"/providers":{get:{tags:["Providers"],summary:"List sandbox providers",description:"With credential + baked status on this host.",responses:{200:{description:"Providers",content:{"application/json":{schema:{type:"object",properties:{providers:{type:"array",items:{$ref:"#/components/schemas/Provider"}}},required:["providers"]}}}},401:t}}},"/providers/{id}/credentials":{post:{tags:["Providers"],summary:"Set a provider's credentials",description:"API keys/tokens, validated then saved to secrets.env. Never echoes secret values.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"]}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",additionalProperties:{type:"string"},description:"Provider-specific fields, e.g. { apiKey } (e2b), { token } (hetzner), { apiKey } or { jwtToken, organizationId } (daytona), { token, teamId?, projectId? } (vercel)."}}}},responses:{200:{description:"Saved",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,503:t}}},"/providers/{id}/prepare":{post:{tags:["Providers"],summary:"Bake a provider's base image",description:"Async — returns a job id. Progress streams over GET /jobs/{id}/logs.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"]}}],requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{force:{type:"boolean"},claudeInstall:{type:"string",enum:["native","npm"]}}}}}},responses:{202:{description:"Bake enqueued",content:{"application/json":{schema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"]}}}},400:t,401:t,409:t,503:t}}},"/hosts":{get:{tags:["Hosts"],summary:"List remote-docker host aliases",description:"Each with its SSH connection and baked/default state.",responses:{200:{description:"Hosts",content:{"application/json":{schema:{type:"object",properties:{hosts:{type:"array",items:{type:"object",properties:{alias:{type:"string"},ssh:{type:"string"},baked:{type:"boolean"},bakedImageRef:{type:"string"},default:{type:"boolean"}},required:["alias","ssh","baked","default"]}}},required:["hosts"]}}}},401:t,503:t}},post:{tags:["Hosts"],summary:"Register a remote-docker host alias",description:"Probes the host (ssh + docker) before saving. Does not bake the image (builds on first create). `default` also pins box.remoteDockerHost.",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{alias:{type:"string"},ssh:{type:"string",description:"an ~/.ssh/config alias or [user@]host[:port]"},default:{type:"boolean"}},required:["alias","ssh"]}}}},responses:{201:{description:"Registered",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,409:t,503:t}}},"/hosts/{alias}":{delete:{tags:["Hosts"],summary:"Forget a remote-docker host alias",description:"Drops the alias + baked-image record + default. Local record only. Returns boxes created against it (now unreachable).",parameters:[{name:"alias",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Removed",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0},boxesAffected:{type:"array",items:{type:"string"}}},required:["ok","boxesAffected"]}}}},401:t,404:t,503:t}}},"/hosts/{alias}/bake":{post:{tags:["Hosts"],summary:"Bake the box image on a host",description:"Async — returns a job id. Progress streams over GET /jobs/{id}/logs (pull from GHCR is fast; a registry-miss build is slow).",parameters:[{name:"alias",in:"path",required:!0,schema:{type:"string"}}],responses:{202:{description:"Bake enqueued",content:{"application/json":{schema:{type:"object",properties:{jobId:{type:"string"}},required:["jobId"]}}}},401:t,404:t,503:t}}},"/checkpoints":{get:{tags:["Checkpoints"],summary:"List a project's (or every project's) checkpoints",description:"The project checkpoint store lives on the hub machine, keyed by the absolute project root. Pass `?project=<abs root>` for one project, or `?global=1` for every project. Backs `agentbox checkpoint ls` / `ls -g`.",parameters:[{name:"project",in:"query",required:!1,schema:{type:"string"},description:"Absolute project root (required unless global=1)."},{name:"global",in:"query",required:!1,schema:{type:"string",enum:["1"]},description:"List checkpoints for every project."}],responses:{200:{description:"Checkpoints",content:{"application/json":{schema:{$ref:"#/components/schemas/CheckpointListing"}}}},400:t,401:t,503:t}},delete:{tags:["Checkpoints"],summary:"Delete a checkpoint",description:"Removes one checkpoint from every store that had it and sweeps any dangling default-checkpoint config pointer. Backs `agentbox checkpoint rm`.",parameters:[{name:"project",in:"query",required:!0,schema:{type:"string"},description:"Absolute project root."},{name:"ref",in:"query",required:!0,schema:{type:"string"},description:"The checkpoint name."},{name:"provider",in:"query",required:!1,schema:{type:"string"},description:"Scope the delete to one provider store."}],responses:{200:{description:"Deleted",content:{"application/json":{schema:{$ref:"#/components/schemas/CheckpointRemoveResult"}}}},400:t,401:t,404:t,503:t}}},"/prune":{post:{tags:["Fleet"],summary:"Prune orphan boxes and resources",description:"Without a provider (or provider `docker`) it reaps orphan docker records, containers, volumes, snapshot/box dirs — and, with `all`, orphan project configs. With a cloud provider it enumerates untracked sandboxes and (when not a `dryRun`) deletes them AND reaps their control-box registrations. Durable project checkpoints are always left intact. Backs `agentbox prune`.",requestBody:{required:!1,content:{"application/json":{schema:{type:"object",properties:{provider:{type:"string",description:"Cloud provider to prune; omit (or `docker`) for the local docker sweep."},all:{type:"boolean",description:"docker: also remove orphan per-project config dirs."},dryRun:{type:"boolean",description:"Report what would be removed without removing anything."}}}}}},responses:{200:{description:"Prune result",content:{"application/json":{schema:{$ref:"#/components/schemas/PruneResult"}}}},400:t,401:t,409:t,503:t}}},"/approvals":{get:{tags:["Approvals"],summary:"List pending host-action approvals",responses:{200:{description:"Approvals",content:{"application/json":{schema:{type:"object",properties:{approvals:{type:"array",items:{$ref:"#/components/schemas/Approval"}}},required:["approvals"]}}}},401:t}}},"/approvals/{id}/answer":{post:{tags:["Approvals"],summary:"Answer a pending approval",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{answer:{type:"string",enum:["y","n"]},cancelled:{type:"boolean",description:"Mark a dismissal distinctly from a plain deny in the audit trail (the `agent approve --cancel` capability). Still leaves the action unapproved."}},required:["answer"]}}}},responses:{200:{description:"Resolved",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,503:t}}},"/boxes/{id}/stream":{get:{tags:["Approvals"],summary:"Subscribe to a box's live event stream (SSE)",description:"Payload-carrying Server-Sent Events for one box — the attach footer's channel. Emits `open` (first frame of every connect, followed by a backlog flush of everything still live), `prompt-ask` (the full pending-approval payload), `prompt-resolved` (`{ id }`), `notice-set`/`notice-clear`, `box-status` (the in-box daemon's latest snapshot: agent activity, session titles, service/task states), and a `ping` heartbeat. `box-status` is the only status source for a box this hub owns but the client does not — the durable status file is written by whichever relay the box reports to. Distinct from GET /api/events, which carries refetch signals only (`data: {}`). Degrades to open + heartbeat on a hub topology with no in-process relay.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"SSE stream (text/event-stream)",content:{"text/event-stream":{schema:{type:"string"}}}},401:t}}},"/jobs":{get:{tags:["Jobs"],summary:"List background jobs",description:"The unified job listing — the local file queue's create jobs merged with, on a control box, the control-plane create queue. Backs `agentbox queue list` and `agentbox hub jobs`.",responses:{200:{description:"Jobs",content:{"application/json":{schema:{type:"object",properties:{jobs:{type:"array",items:{$ref:"#/components/schemas/JobListItem"}}},required:["jobs"]}}}},401:t,503:t}}},"/jobs/{id}":{get:{tags:["Jobs"],summary:"Get a create job status",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"Job",content:{"application/json":{schema:{$ref:"#/components/schemas/Job"}}}},401:t,404:t}}},"/jobs/{id}/logs":{get:{tags:["Jobs"],summary:"Stream a create job log (SSE)",description:"text/event-stream. Emits `open`, then `log` events per line, then a terminal `end` event with the final status.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{description:"SSE stream",content:{"text/event-stream":{}}},401:t,404:t,503:t}}},"/jobs/{id}/login-code":{post:{tags:["Jobs"],summary:"Deliver an OAuth login code to a create job",description:"Feeds a pasted Claude OAuth approval code to a create job that is awaiting a re-login. The create worker consumes it and completes the in-box login. The one interactive create affordance that survives.",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{code:{type:"string",description:"The OAuth approval code."}},required:["code"]}}}},responses:{200:{description:"Accepted",content:{"application/json":{schema:{type:"object",properties:{ok:{const:!0}},required:["ok"]}}}},400:t,401:t,404:t,503:t}}},"/custody":{get:{tags:["Custody"],summary:"List the custody manifest (metadata only)",description:"What the hub holds so a box created from either side is usable from both: agent credentials, project seeds, provider bake records, and per-box SSH keys. Returns paths, hashes, sizes and mtimes ONLY — value bytes never leave the box (same contract as `agentbox hub custody list`). Optional `?prefix=` scopes the listing to a custody scope (`agents` | `projects` | `prepared` | `boxes`) or a `scope/subject`.",parameters:[{name:"prefix",in:"query",required:!1,schema:{type:"string"},description:"A custody scope or scope/subject, e.g. `agents` or `boxes/box-abc`."}],responses:{200:{description:"Custody manifest",content:{"application/json":{schema:{$ref:"#/components/schemas/Custody"}}}},400:t,401:t}}},"/custody/{path}":{parameters:[{name:"path",in:"path",required:!0,schema:{type:"string"},description:"Custody path, e.g. `agents/claude/.credentials.json` or `boxes/box-abc/ssh/id_ed25519`."}],get:{tags:["Custody"],summary:"Read a stored blob (ELEVATED — admin token required on a control box)",description:"Returns the entry metadata AND its bytes (`data`, base64). This is the ONE byte-returning custody route, so it is gated beyond the hub API key: on a control box (password profile) it additionally requires the admin token in `X-Agentbox-Admin-Token` — a byte-read with only the API key is `401`, so a value never leaves the box to a thin client. A localhost hub (token profile) needs no admin token: its hub token is a machine-local secret that already gates the whole surface. Backs `agentbox hub credentials pull` / `custody pull` and per-box SSH-key adoption.",responses:{200:{description:"The stored entry + its base64 bytes",content:{"application/json":{schema:{$ref:"#/components/schemas/CustodyValue"}}}},400:t,401:t,404:t}},put:{tags:["Custody"],summary:"Store bytes at a custody path (metadata-only response)",description:"Stores `data` (base64) at the path. Content-addressed: `changed` is false when the identical bytes were already there. The response is METADATA ONLY — it never echoes the stored value. Backs `agentbox hub credentials/secrets/project push`.",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["data"],properties:{data:{type:"string",description:"base64-encoded bytes"}}}}}},responses:{200:{description:"Stored (metadata only)",content:{"application/json":{schema:{$ref:"#/components/schemas/CustodyPutResult"}}}},400:t,401:t}},delete:{tags:["Custody"],summary:"Delete a custody entry",description:"Removes one entry. Backs `agentbox hub custody rm`.",responses:{204:{description:"Deleted"},400:t,401:t,404:t}}},"/custody/blob/{path}":{parameters:[{name:"path",in:"path",required:!0,schema:{type:"string"},description:"Custody path, e.g. `projects/acme__web/seed/carry.tar.gz`."}],get:{tags:["Custody"],summary:"Stream a stored blob (ELEVATED — admin token required on a control box)",description:"Raw `application/octet-stream` counterpart of GET /custody/{path}, for values too large to buffer as base64. Same elevated gate, for the same reason (custody holds credentials and SSH private keys) — streaming changes the transport, never the trust. `X-Agentbox-Sha256` carries the digest.",responses:{200:{description:"The stored bytes",content:{"application/octet-stream":{schema:{type:"string",format:"binary"}}}},400:t,401:t,404:t}},put:{tags:["Custody"],summary:"Stream bytes into a custody path",description:"Raw `application/octet-stream` counterpart of PUT /custody/{path}. The JSON route stays the simple, general-purpose API for small values (credentials, .env, SSH keys); this one exists for payloads where base64-in-JSON costs several times the payload in peak memory on both ends — chiefly a project's `carry:` material, which can run to `box.cpMaxBytes` (100 MiB). Capped by AGENTBOX_CUSTODY_MAX_BLOB_BYTES and enforced mid-stream, so an over-cap upload is cut off rather than landed. Returns metadata only, and is content-addressed (`changed: false` when the bytes were already stored).",requestBody:{required:!0,content:{"application/octet-stream":{schema:{type:"string",format:"binary"}}}},responses:{200:{description:"Stored (metadata only)",content:{"application/json":{schema:{$ref:"#/components/schemas/CustodyPutResult"}}}},400:t,401:t}}},"/system":{get:{tags:["System"],summary:"Get hub build + provider bake status",description:'Answers "what is running here, and do I need to re-bake?": hub version + channel + build source, the deploy record (when this machine is an exposed/deployed control box), each base provider’s baked fingerprint and freshness (`baseStatus` `stale` = re-bake), and the box-image build-context manifest. Freshness is populated only on the in-process host topology (like GET /providers?freshness=1).',responses:{200:{description:"System info",content:{"application/json":{schema:{$ref:"#/components/schemas/System"}}}},401:t}}}},components:{securitySchemes:{bearerAuth:{type:"http",scheme:"bearer",description:"The hub token (Authorization: Bearer <token>)."}},schemas:{Health:{type:"object",properties:{ok:{const:!0},apiVersion:{type:"string"},profile:{type:"string"}},required:["ok","apiVersion"]},CustodyEntry:{type:"object",description:"One stored item — metadata only; the value bytes are never returned.",properties:{path:{type:"string",description:"Custody-relative path, e.g. agents/claude/.credentials.json"},size:{type:"number"},sha256:{type:"string",description:"Hex sha256 of the stored bytes"},mode:{type:"number",description:"POSIX mode of the stored value"},updatedAt:{type:"string",description:"ISO timestamp of the last write"}},required:["path","size","sha256","mode","updatedAt"]},CustodyPutResult:{type:"object",description:"A store result — metadata only, never the stored value.",allOf:[{$ref:"#/components/schemas/CustodyEntry"},{type:"object",properties:{changed:{type:"boolean",description:"false when the identical bytes were already stored (content-addressed)"}},required:["changed"]}]},CustodyValue:{type:"object",description:"A stored entry AND its bytes — only the elevated byte-read GET returns this.",allOf:[{$ref:"#/components/schemas/CustodyEntry"},{type:"object",properties:{data:{type:"string",description:"base64-encoded stored bytes"}},required:["data"]}]},Custody:{type:"object",properties:{enabled:{type:"boolean",description:"false only when this hub has no custody store wired"},entries:{type:"array",items:{$ref:"#/components/schemas/CustodyEntry"}}},required:["enabled","entries"]},ProviderBake:{type:"object",properties:{id:{type:"string"},label:{type:"string"},baked:{type:"boolean"},fingerprint:{type:"string",description:"Short (12-char) build-context fingerprint of the baked base"},cliVersion:{type:"string"},bakedAt:{type:"string"},imageRef:{type:"string"},baseStatus:{type:"string",enum:["fresh","stale","unprepared","unknown"]},baseStaleReason:{type:"string"},bakeDiff:{type:"object",description:"Which files differ, when baseStatus is stale. hasManifest:false means the base was baked before per-file manifests were recorded, so no diff is possible without a re-bake.",properties:{hasManifest:{type:"boolean"},liveUnavailable:{type:"boolean",description:"A manifest exists but the current hashes could not be computed, so no diff is possible. Distinct from hasManifest:false, where a re-bake would help."},changed:{type:"array",items:{type:"object",properties:{rel:{type:"string"},from:{type:"string"},to:{type:"string"}}}},added:{type:"array",items:{type:"string"}},removed:{type:"array",items:{type:"string"}}},required:["hasManifest"]}},required:["id","label","baked"]},System:{type:"object",properties:{hub:{type:"object",properties:{version:{type:["string","null"]},commit:{type:["string","null"]},profile:{type:"string"},apiVersion:{type:"string"}},required:["profile","apiVersion"]},build:{type:"object",properties:{version:{type:["string","null"]},channel:{type:["string","null"],description:"stable | nightly | source (<ref>)"},build:{type:["string","null"],description:"Human build line, e.g. @madarco/agentbox@0.28.0 (npm)"}}},deploy:{type:["object","null"],description:"Present only when this machine is an exposed/deployed control box."},providers:{type:"array",items:{$ref:"#/components/schemas/ProviderBake"}},hostCarried:{type:"array",description:"Agent configs, skills and identity files THIS machine hands to a box. Present-only: a path absent here is one a box will not receive.",items:{type:"object",properties:{agent:{type:"string"},label:{type:"string"},hostPath:{type:"string"},kind:{type:"string",enum:["skills","config","identity"]},skills:{type:"array",items:{type:"string"}}},required:["agent","label","hostPath","kind"]}},boxImage:{type:["object","null"],description:"Box-image resolution: the registry, the exact fingerprint-tag this host pulls, and what it last stamped.",properties:{registry:{type:"string"},pullTag:{type:"string"},stampedFingerprint:{type:"string"},imageRef:{type:"string"},bakedAt:{type:"string"}}}},required:["hub","build","providers","hostCarried"]},Error:{type:"object",properties:{error:{type:"object",properties:{code:{type:"string"},message:{type:"string"},details:{}},required:["code","message"]}},required:["error"]},Box:{type:"object",properties:{id:{type:"string"},projectId:{type:"string"},repo:{type:"string"},branch:{type:"string"},task:{type:"string"},agent:{type:"string"},status:{type:"string",enum:["running","paused","stopped","creating","error"]},createdAt:{type:"number"},lastActivity:{type:"number"},host:{type:"string"},commits:{type:["number","null"]},filesTouched:{type:["number","null"]},error:{type:["string","null"]},displayName:{type:["string","null"],description:"Cosmetic user-set label (rename); null when unset"},webUrl:{type:["string","null"],description:"Host-openable web-service URL; null when absent/unreachable (e.g. paused)"},vncUrl:{type:["string","null"],description:"Host-openable VNC desktop URL; null when absent/unreachable"},state:{type:"string",enum:["running","paused","stopped","missing"],description:"Raw provider runtime state (host topology only). Absent on synthetic creating/error rows — presence distinguishes a real box whose agent errored from a failed create job."},name:{type:"string"},provider:{type:"string",description:"Raw provider id ('docker', 'daytona', …; plugin ids possible)"},projectRoot:{type:"string",description:"Absolute host path of the project. Host topology only — never emitted by the hosted plane"},projectIndex:{type:"number"},vncEnabled:{type:"boolean"},gitWorktrees:{type:"array",items:{type:"object",properties:{kind:{type:"string"},branch:{type:"string"}}}},claudeSessionTitle:{type:"string"},codexSessionTitle:{type:"string"},opencodeSessionTitle:{type:"string"},claudeActivity:{type:"string",description:"working | idle | waiting | end-plan | question | compacting | error | unknown"},codexActivity:{type:"string"},shellCount:{type:"number",description:'Live shell-session count (docker only); absent → the CLI renders "-".'},sandboxId:{type:"string",description:"Provider-native sandbox id (cloud boxes). Part of the non-secret adoption block a thin client rebuilds a drivable local record from — tokens are never serialized, a fresh adoption re-mints them."},originUrl:{type:["string","null"],description:"Box repo's origin remote URL. Lets project-scoped `ls` match a box to the cwd repo by identity when its projectRoot is a remote hub's path. Populated for any registered box, docker included."},publicHost:{type:"string",description:"Public IP/host of the box VM (direct-SSH providers: hetzner/digitalocean)."},image:{type:"string",description:"Base image / snapshot ref the sandbox booted from."},webPort:{type:"number",description:"In-box WebProxy port (cloud boxes bind a non-privileged port)."},previewUrls:{type:"object",additionalProperties:{type:"string"},description:"Token-authed preview URLs keyed by in-box port."},lastAgent:{type:"string",enum:["claude","codex","opencode"],description:"The agent the box was created for."},topology:{type:"string",description:"Sync federation shape ('cloud' | 'control-plane'); absent for docker."}},required:["id","projectId","status","agent"]},Project:{type:"object",properties:{id:{type:"string"},name:{type:"string"},repo:{type:"string"},defaultBranch:{type:"string"},currentBranch:{type:"string",nullable:!0},needsSetup:{type:"boolean",description:"No agentbox.yaml + no default snapshot — the create form offers the setup wizard"},provider:{type:"string"},createdAt:{type:"number"},originUrl:{type:"string",nullable:!0,description:"Repo origin remote URL (hosted source only)"},projectSlug:{type:"string",nullable:!0,description:"Custody projects/<slug> key (hosted source only)"}},required:["id","name"]},ProjectSeed:{type:"object",properties:{custodyAvailable:{type:"boolean",description:"False when this hub is not a control box (no custody store)"},seed:{type:"object",nullable:!0,description:"Null when nothing has been pushed for this project.",properties:{slug:{type:"string"},originUrl:{type:"string"},baseBranch:{type:"string"},repoHeadSha:{type:"string",description:"Full commit the working tree sat on"},capturedAt:{type:"string",description:"ISO timestamp of the last seed push"},hasEnv:{type:"boolean",description:"env/secret tarball present"},hasUntracked:{type:"boolean",description:"untracked-files tarball present"},totalBytes:{type:"number"},entries:{type:"array",items:{type:"object",properties:{name:{type:"string"},size:{type:"number"},sha256:{type:"string"},updatedAt:{type:"string"}},required:["name","size","sha256","updatedAt"]}}},required:["slug","hasEnv","hasUntracked","totalBytes","entries"]}},required:["custodyAvailable","seed"]},BranchList:{type:"object",properties:{current:{type:"string",nullable:!0,description:"The repo's current HEAD (the default base ref)"},branches:{type:"array",items:{type:"string"},description:"Local + remote-tracking branch names"}},required:["branches"]},Approval:{type:"object",properties:{id:{type:"string"},boxId:{type:"string"},message:{type:"string"},detail:{type:"string"},command:{type:"string"},cwd:{type:"string"},argv:{type:"array",items:{type:"string"}},defaultAnswer:{type:"string",enum:["y","n"]},createdAt:{type:"number"}},required:["id","boxId","message","defaultAnswer"]},Job:{type:"object",properties:{id:{type:"string"},status:{type:"string",enum:["queued","running","done","failed","cancelled"]},boxId:{type:"string"},error:{type:"string",description:"A failed job's reason — so a create reports the failure, not a silent 'done'."},provider:{type:"string"},name:{type:"string"},agent:{type:"string"},createdAt:{type:"string"},login:{type:"object",description:"Present when the create is awaiting a Claude re-login (see POST /jobs/{id}/login-code).",properties:{required:{type:"boolean"},phase:{type:"string"},url:{type:"string"},error:{type:"string"},lastError:{type:"string"}}}},required:["id","status"]},JobListItem:{type:"object",description:"One row of GET /jobs — the Job shape without the streamable log path.",properties:{id:{type:"string"},status:{type:"string",enum:["queued","running","done","failed","cancelled"]},boxId:{type:"string"},error:{type:"string"},provider:{type:"string"},name:{type:"string"},agent:{type:"string"},createdAt:{type:"string"}},required:["id","status"]},AgentState:{type:"object",description:"The box's in-box coding-agent status snapshot. `claude` is the raw ctl status payload (activity, plan/question, session title); null when no snapshot exists yet.",properties:{claude:{description:"Raw BoxStatusClaude payload (opaque here)."}},required:["claude"]},CheckpointCreateResult:{type:"object",properties:{ok:{const:!0},name:{type:"string"},kind:{type:"string",description:"docker manifest type ('layered' | 'merged') or 'snapshot' for a cloud backend."},ref:{type:"string",description:"The image tag / snapshot id created."},provider:{type:"string"},dir:{type:"string",description:"Snapshot dir (cloud backends)."},setDefaultKey:{type:"string",description:"The config key written when setDefault was requested."}},required:["ok","name","kind","ref","provider"]},CheckpointItem:{type:"object",properties:{name:{type:"string"},provider:{type:"string",description:"'docker' or the cloud backend name."},kind:{type:"string"},sourceBoxName:{type:"string"},createdAt:{type:"string"},isDefault:{type:"boolean",description:"Resolved server-side against the project's effective config."}},required:["name","provider","kind","isDefault"]},CheckpointListing:{type:"object",properties:{projects:{type:"array",items:{type:"object",properties:{segment:{type:"string",description:"The path-hash store segment."},projectRoot:{type:"string",description:"Absent for an orphan segment whose project config was GC-ed."},label:{type:"string"},items:{type:"array",items:{$ref:"#/components/schemas/CheckpointItem"}}},required:["segment","label","items"]}}},required:["projects"]},CheckpointRemoveResult:{type:"object",properties:{ok:{const:!0},removed:{type:"array",items:{type:"string"},description:"Providers the checkpoint was deleted from."},clearedKeys:{type:"array",items:{type:"string"},description:"Default-checkpoint config pointers cleared in the project layer."},warnedKeys:{type:"array",items:{type:"string"},description:"Dangling pointers in a layer we can't auto-edit (warned, not cleared)."}},required:["ok","removed","clearedKeys","warnedKeys"]},PruneResult:{description:"The prune outcome — discriminated by `kind`: `general` (docker sweep), `cloud` (untracked cloud sandboxes).",oneOf:[{type:"object",properties:{kind:{const:"general"},result:{type:"object",properties:{removedRecords:{type:"array",items:{type:"string"}},removedContainers:{type:"array",items:{type:"string"}},removedVolumes:{type:"array",items:{type:"string"}},removedSnapshotDirs:{type:"array",items:{type:"string"}},removedBoxDirs:{type:"array",items:{type:"string"}},removedCheckpointImages:{type:"array",items:{type:"string"}},dryRun:{type:"boolean"}},required:["dryRun"]},projectConfigs:{type:"array",items:{type:"string"}}},required:["kind","result","projectConfigs"]},{type:"object",properties:{kind:{const:"cloud"},provider:{type:"string"},dryRun:{type:"boolean"},orphans:{type:"array",items:{type:"object",properties:{sandboxId:{type:"string"},name:{type:"string"},state:{type:"string"},createdAt:{type:"string"}},required:["sandboxId"]}},deleted:{type:"number"},failed:{type:"number"},reaped:{type:"number",description:"Control-box registrations reaped for the deleted sandboxes (0 on a dry run)."}},required:["kind","provider","dryRun","orphans","deleted","failed","reaped"]}]},CreateBox:{type:"object",properties:{projectId:{type:"string"},agent:{type:"string",enum:["claude","codex","opencode","none"]},provider:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"],default:"docker"},name:{type:"string"},prompt:{type:"string"},fromBranch:{type:"string",description:"Base ref the box's per-box branch forks from (branch / tag / SHA); default the project's HEAD"},setupWizard:{type:"boolean",description:'Seed the agent\'s first turn to generate agentbox.yaml (for projects with none). Inert for agent "none".'}},required:["projectId","agent"]},Provider:{type:"object",properties:{id:{type:"string",enum:["docker","daytona","hetzner","vercel","e2b","digitalocean","remote-docker"]},label:{type:"string"},configured:{type:"boolean",description:"Base image baked (usable for create) on this host."},hasCredentials:{type:"boolean",description:"Credentials present (docker: always true). Can be true while not yet configured (baked)."},jobId:{type:"string",description:"Id of an in-flight bake (prepare) job for this provider, if any."},reason:{type:"string"}},required:["id","label","configured"]},GitOpBody:{type:"object",description:"Union of git-op fields; only those for the chosen {op} are read (extras are ignored).",properties:{branch:{type:"string",description:"checkout: branch to switch to"},name:{type:"string",description:"branch: new branch name (agentbox/ prefix added when missing)"},from:{type:"string",description:"branch: base ref to fork from (default: box's HEAD)"},remote:{type:"string",description:"push/pull: remote name (default: origin)"},force:{type:"boolean",description:"push: force the remote push; push-host: overwrite the destination branch"},ffOnly:{type:"boolean",description:"pull: pass --ff-only to the merge"},as:{type:"string",description:"push-host: destination branch name in the host repo (default: the box's branch)"}}},GitOpResult:{type:"object",properties:{ok:{const:!0},stdout:{type:"string"},stderr:{type:"string"}},required:["ok"]},GitInfo:{type:"object",properties:{ok:{type:"boolean"},branch:{type:"string"},dirty:{type:"boolean"},ahead:{type:"number"},behind:{type:"number"},error:{type:"string"}},required:["ok"]},Services:{type:"object",properties:{source:{type:"string",enum:["live","persisted","unavailable"]},services:{type:"array",items:{type:"object",properties:{name:{type:"string"},state:{type:"string"},pid:{type:["number","null"]},restarts:{type:"number"},lastExitCode:{type:["number","null"]},blockedOn:{type:"array",items:{type:"string"}},command:{type:"string"}},required:["name","state"]}},tasks:{type:"array",items:{type:"object",properties:{name:{type:"string"},state:{type:"string"}},required:["name","state"]}},ports:{type:"array",items:{type:"object",properties:{port:{type:"number"},service:{type:["string","null"]}},required:["port"]}},error:{type:"string"}},required:["source","services","tasks","ports"]}}}}},"docsHtml",0,function(){return`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <title>AgentBox Hub API</title>
@@ -1,8 +1,8 @@
1
- module.exports=[71326,t=>t.a(async(e,r)=>{try{var a=t.i(24868),s=t.i(46786),n=t.i(14747),o=t.i(54799);t.i(22734),t.i(33405),t.i(29220),t.i(46063);var i=t.i(8531),d=e([i]);[i]=d.then?(await d)():d;var l=class{map=new Map;register(t){this.map.set(t.boxId,t)}forget(t){return this.map.delete(t)}authenticate(t){if(0===t.length)return null;for(let e of this.map.values())if(e.token===t)return e;return null}get(t){return this.map.get(t)}list(){return[...this.map.values()]}size(){return this.map.size}},u=class{constructor(t=1e3){this.capacity=t}capacity;buf=[];nextId=1;append(t){let e={id:this.nextId++,receivedAt:new Date().toISOString(),...t};return this.buf.push(e),this.buf.length>this.capacity&&this.buf.shift(),e}since(t,e){let r=[];for(let a of this.buf)!(a.id<=t)&&(e&&a.boxId!==e||r.push(a));return r}all(){return this.buf.slice()}size(){return this.buf.length}};function c(t,e,r){let a=e.toLowerCase().replace(/-/g,"_").replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"").slice(0,32)||"unnamed",o="number"==typeof r&&Number.isFinite(r)&&r>0?`${t}-${String(r)}-${a}`:`${t}-${a}`;return(0,n.join)((0,s.homedir)(),".agentbox","boxes",o)}var p=class{map=new Map;get(t){return this.map.get(t)}async set(t,e,r,s){this.map.set(t,s);let o=(0,n.join)(c(t,e,r),"status.json"),i=`${o}.${String(process.pid)}.tmp`;try{await (0,a.mkdir)(c(t,e,r),{recursive:!0}),await (0,a.writeFile)(i,JSON.stringify(s),"utf8"),await (0,a.rename)(i,o)}catch{await (0,a.rm)(i,{force:!0}).catch(()=>{})}}delete(t){this.map.delete(t)}list(){return[...this.map.entries()].map(([t,e])=>({boxId:t,status:e}))}},h=class{registry;events;statusStore;prompts=new Map;createJobs=new Map;constructor(t={}){this.registry=t.registry??new l,this.events=t.events??new u,this.statusStore=t.statusStore??new p}registerBox(t){return this.registry.register(t),Promise.resolve()}getBox(t){return Promise.resolve(this.registry.get(t))}authenticateBox(t){return Promise.resolve(this.registry.authenticate(t))}listBoxes(){return Promise.resolve(this.registry.list())}forgetBox(t){return Promise.resolve(this.registry.forget(t))}countBoxes(){return Promise.resolve(this.registry.size())}appendEvent(t){return Promise.resolve(this.events.append(t))}listEvents(t,e){return Promise.resolve(this.events.since(t,e))}countEvents(){return Promise.resolve(this.events.size())}setStatus(t,e,r,a){return this.statusStore.set(t,e,r,a)}getStatus(t){return Promise.resolve(this.statusStore.get(t))}deleteStatus(t){return this.statusStore.delete(t),Promise.resolve()}listStatuses(){return Promise.resolve(this.statusStore.list())}createPrompt(t){return this.prompts.set(t.id,{...t}),Promise.resolve()}getPrompt(t){let e=this.prompts.get(t);return Promise.resolve(e?{...e}:null)}answerPrompt(t,e,r){let a=this.prompts.get(t);return a&&"pending"===a.status?(a.status="answered",a.answer=e,a.cancelled=r,Promise.resolve(!0)):Promise.resolve(!1)}listPendingPrompts(t){let e=[];for(let r of this.prompts.values())r.boxId===t&&"pending"===r.status&&e.push({...r});return Promise.resolve(e)}setPromptResult(t,e){let r=this.prompts.get(t);return r&&(r.result=e),Promise.resolve()}enqueueCreateJob(t){return this.createJobs.set(t.id,{...t}),Promise.resolve()}getCreateJob(t){let e=this.createJobs.get(t);return Promise.resolve(e?{...e}:null)}listCreateJobs(t){let e=t?.status,r=[...this.createJobs.values()].filter(t=>!e||e.includes(t.status)).sort((t,e)=>e.createdAt.localeCompare(t.createdAt)).map(t=>({...t}));return Promise.resolve(t?.limit?r.slice(0,t.limit):r)}claimNextCreateJob(t){let e=[...this.createJobs.values()].filter(t=>"queued"===t.status).sort((t,e)=>t.createdAt.localeCompare(e.createdAt))[0];return e?(e.status="running",e.claimedBy=t,e.startedAt=new Date().toISOString(),Promise.resolve({...e})):Promise.resolve(null)}completeCreateJob(t,e,r){let a=this.createJobs.get(t);return a&&(a.status=e,a.result=r,a.finishedAt=new Date().toISOString()),Promise.resolve()}};async function m(t,e,r,a,s){if("off"===process.env.AGENTBOX_PROMPT||t.consumeAutoApprove(r,a))return{answer:"y"};let n={id:(0,o.randomUUID)(),...a},i=t.add(r,n);if(e.broadcast(r,"prompt-ask",n),s?.ttlMs!==void 0&&s.ttlMs>0){let o=setTimeout(()=>{t.resolve(n.id,a.defaultAnswer??"n",!0)&&e.broadcast(r,"prompt-resolved",{id:n.id})},s.ttlMs);"function"==typeof o.unref&&o.unref(),i.then(()=>{clearTimeout(o)})}return i}async function g(t,e,r,a,s){if("block"===t.mode){if(!t.prompts||!t.subscribers)return{kind:"deny"};let r=await m(t.prompts,t.subscribers,e,s);return"y"!==r.answer||r.cancelled?{kind:"deny"}:{kind:"allow"}}if("off"===process.env.AGENTBOX_PROMPT)return{kind:"allow"};let n=await t.store.getBox(e);if(n?.autoApproveHostActions)return await t.store.appendEvent({boxId:e,type:"host-action-auto-approved",payload:{command:s.context?.command,argv:s.context?.argv,message:s.message}}),{kind:"allow"};let i=(0,o.randomUUID)(),d={id:i,...s};return await t.store.createPrompt({id:i,boxId:e,ev:d,method:r,params:a,status:"pending",createdAt:new Date().toISOString()}),t.subscribers?.broadcast(e,"prompt-ask",d),{kind:"pending",promptId:i}}function b(t){let e,r,a=t.trim();if(0===a.length)throw Error("empty git remote URL");let s=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/i.exec(a),n=/^(?:[^@/]+@)?([^/:]+):(.+)$/.exec(a);if(s)e=s[1],r=s[2];else if(n&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(a))e=n[1],r=n[2];else throw Error(`unrecognized git remote URL: ${t}`);return{host:e,path:r.replace(/^\/+/,"")}}function y(t,e){let{host:r,path:a}=b(t);return`https://x-access-token:${e}@${r}/${a}`}function x(t){let{host:e,path:r}=b(t),a=r.replace(/\.git$/,"");return"github.com"===e.toLowerCase()?a:`${e}/${a}`}async function w(t,e){if(!t)return{exitCode:64,stdout:"",stderr:"git.lease-token: no GitHub App configured on this relay\n"};let r=e.originUrl;if(!r)return{exitCode:64,stdout:"",stderr:`git.lease-token: box ${e.boxId} has no registered origin URL
1
+ module.exports=[25230,t=>t.a(async(e,r)=>{try{var a=t.i(24868),s=t.i(46786),n=t.i(14747),o=t.i(54799);t.i(22734),t.i(33405),t.i(29220),t.i(46063);var i=t.i(8531),d=e([i]);[i]=d.then?(await d)():d;var l=class{map=new Map;register(t){this.map.set(t.boxId,t)}forget(t){return this.map.delete(t)}authenticate(t){if(0===t.length)return null;for(let e of this.map.values())if(e.token===t)return e;return null}get(t){return this.map.get(t)}list(){return[...this.map.values()]}size(){return this.map.size}},u=class{constructor(t=1e3){this.capacity=t}capacity;buf=[];nextId=1;append(t){let e={id:this.nextId++,receivedAt:new Date().toISOString(),...t};return this.buf.push(e),this.buf.length>this.capacity&&this.buf.shift(),e}since(t,e){let r=[];for(let a of this.buf)!(a.id<=t)&&(e&&a.boxId!==e||r.push(a));return r}all(){return this.buf.slice()}size(){return this.buf.length}};function c(t,e,r){let a=e.toLowerCase().replace(/-/g,"_").replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"").slice(0,32)||"unnamed",o="number"==typeof r&&Number.isFinite(r)&&r>0?`${t}-${String(r)}-${a}`:`${t}-${a}`;return(0,n.join)((0,s.homedir)(),".agentbox","boxes",o)}var p=class{map=new Map;get(t){return this.map.get(t)}async set(t,e,r,s){this.map.set(t,s);let o=(0,n.join)(c(t,e,r),"status.json"),i=`${o}.${String(process.pid)}.tmp`;try{await (0,a.mkdir)(c(t,e,r),{recursive:!0}),await (0,a.writeFile)(i,JSON.stringify(s),"utf8"),await (0,a.rename)(i,o)}catch{await (0,a.rm)(i,{force:!0}).catch(()=>{})}}delete(t){this.map.delete(t)}list(){return[...this.map.entries()].map(([t,e])=>({boxId:t,status:e}))}},h=class{registry;events;statusStore;prompts=new Map;createJobs=new Map;constructor(t={}){this.registry=t.registry??new l,this.events=t.events??new u,this.statusStore=t.statusStore??new p}registerBox(t){return this.registry.register(t),Promise.resolve()}getBox(t){return Promise.resolve(this.registry.get(t))}authenticateBox(t){return Promise.resolve(this.registry.authenticate(t))}listBoxes(){return Promise.resolve(this.registry.list())}forgetBox(t){return Promise.resolve(this.registry.forget(t))}countBoxes(){return Promise.resolve(this.registry.size())}appendEvent(t){return Promise.resolve(this.events.append(t))}listEvents(t,e){return Promise.resolve(this.events.since(t,e))}countEvents(){return Promise.resolve(this.events.size())}setStatus(t,e,r,a){return this.statusStore.set(t,e,r,a)}getStatus(t){return Promise.resolve(this.statusStore.get(t))}deleteStatus(t){return this.statusStore.delete(t),Promise.resolve()}listStatuses(){return Promise.resolve(this.statusStore.list())}createPrompt(t){return this.prompts.set(t.id,{...t}),Promise.resolve()}getPrompt(t){let e=this.prompts.get(t);return Promise.resolve(e?{...e}:null)}answerPrompt(t,e,r){let a=this.prompts.get(t);return a&&"pending"===a.status?(a.status="answered",a.answer=e,a.cancelled=r,Promise.resolve(!0)):Promise.resolve(!1)}listPendingPrompts(t){let e=[];for(let r of this.prompts.values())r.boxId===t&&"pending"===r.status&&e.push({...r});return Promise.resolve(e)}setPromptResult(t,e){let r=this.prompts.get(t);return r&&(r.result=e),Promise.resolve()}enqueueCreateJob(t){return this.createJobs.set(t.id,{...t}),Promise.resolve()}getCreateJob(t){let e=this.createJobs.get(t);return Promise.resolve(e?{...e}:null)}listCreateJobs(t){let e=t?.status,r=[...this.createJobs.values()].filter(t=>!e||e.includes(t.status)).sort((t,e)=>e.createdAt.localeCompare(t.createdAt)).map(t=>({...t}));return Promise.resolve(t?.limit?r.slice(0,t.limit):r)}claimNextCreateJob(t){let e=[...this.createJobs.values()].filter(t=>"queued"===t.status).sort((t,e)=>t.createdAt.localeCompare(e.createdAt))[0];return e?(e.status="running",e.claimedBy=t,e.startedAt=new Date().toISOString(),Promise.resolve({...e})):Promise.resolve(null)}completeCreateJob(t,e,r){let a=this.createJobs.get(t);return a&&(a.status=e,a.result=r,a.finishedAt=new Date().toISOString()),Promise.resolve()}};async function m(t,e,r,a,s){if("off"===process.env.AGENTBOX_PROMPT||t.consumeAutoApprove(r,a))return{answer:"y"};let n={id:(0,o.randomUUID)(),...a},i=t.add(r,n);if(e.broadcast(r,"prompt-ask",n),s?.ttlMs!==void 0&&s.ttlMs>0){let o=setTimeout(()=>{t.resolve(n.id,a.defaultAnswer??"n",!0)&&e.broadcast(r,"prompt-resolved",{id:n.id})},s.ttlMs);"function"==typeof o.unref&&o.unref(),i.then(()=>{clearTimeout(o)})}return i}async function g(t,e,r,a,s){if("block"===t.mode){if(!t.prompts||!t.subscribers)return{kind:"deny"};let r=await m(t.prompts,t.subscribers,e,s);return"y"!==r.answer||r.cancelled?{kind:"deny"}:{kind:"allow"}}if("off"===process.env.AGENTBOX_PROMPT)return{kind:"allow"};let n=await t.store.getBox(e);if(n?.autoApproveHostActions)return await t.store.appendEvent({boxId:e,type:"host-action-auto-approved",payload:{command:s.context?.command,argv:s.context?.argv,message:s.message}}),{kind:"allow"};let i=(0,o.randomUUID)(),d={id:i,...s};return await t.store.createPrompt({id:i,boxId:e,ev:d,method:r,params:a,status:"pending",createdAt:new Date().toISOString()}),t.subscribers?.broadcast(e,"prompt-ask",d),{kind:"pending",promptId:i}}function b(t){let e,r,a,s=t.trim();if(0===s.length)throw Error("empty git remote URL");let n=/^([a-z][a-z0-9+.-]*):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/i.exec(s),o=/^(?:[^@/]+@)?([^/:]+):(.+)$/.exec(s);if(n)a=n[1].toLowerCase(),e=n[2],r=n[3];else if(o&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(s))a=null,e=o[1],r=o[2];else throw Error(`unrecognized git remote URL: ${t}`);return{host:e,path:r.replace(/^\/+/,""),scheme:a}}function y(t,e){let{host:r,path:a}=b(t);return`https://x-access-token:${e}@${r}/${a}`}function x(t){let{host:e,path:r}=b(t),a=r.replace(/\.git$/,"");return"github.com"===e.toLowerCase()?a:`${e}/${a}`}async function w(t,e){if(!t)return{exitCode:64,stdout:"",stderr:"git.lease-token: no GitHub App configured on this relay\n"};let r=e.originUrl;if(!r)return{exitCode:64,stdout:"",stderr:`git.lease-token: box ${e.boxId} has no registered origin URL
2
2
  `};let a="",s="",n="";try{let{path:t}=b(r),[e,o]=t.replace(/\.git$/,"").split("/");a=e??"",s=o??"",n=x(r)}catch{return{exitCode:65,stdout:"",stderr:`git.lease-token: unrecognized origin ${r}
3
3
  `}}if(!a||!s)return{exitCode:65,stdout:"",stderr:`git.lease-token: cannot derive owner/repo from ${r}
4
4
  `};try{let e=await t.leaseRepoToken(a,s),o={token:e.token,expiresAt:e.expiresAt,remoteUrl:y(r,e.token),repo:n};return{exitCode:0,stdout:JSON.stringify(o),stderr:""}}catch(t){return{exitCode:1,stdout:"",stderr:`git.lease-token: ${t instanceof Error?t.message:String(t)}
5
- `}}}var f=new Set(["registerBox","getBox","authenticateBox","listBoxes","forgetBox","countBoxes","appendEvent","listEvents","countEvents","setStatus","getStatus","deleteStatus","listStatuses","createPrompt","getPrompt","answerPrompt","listPendingPrompts","setPromptResult"]);async function v(t,e){var r,a;let s,n;if("/admin/store"!==t.path)return null;let i=e.adminToken??"";if(0===i.length)return{status:503,body:{error:"control plane not configured: admin token unset"}};if(r=t.bearer,s=Buffer.from(r,"utf8"),n=Buffer.from(i,"utf8"),!(s.length===n.length&&(0,o.timingSafeEqual)(s,n)))return{status:401,body:{error:"invalid admin token"}};if("POST"!==t.method)return{status:405,body:{error:"method not allowed"}};let d=function(t){if(0===t.length)return null;try{return JSON.parse(t)}catch{return null}}(t.bodyText);if(!d||"string"!=typeof d.method||!Array.isArray(d.args))return{status:400,body:{error:"expected {method, args}"}};if(a=d.method,!f.has(a))return{status:400,body:{error:`unknown store op: ${d.method}`}};let l=await function(t,e,r){switch(e){case"registerBox":return t.registerBox(r[0]);case"getBox":return t.getBox(r[0]);case"authenticateBox":return t.authenticateBox(r[0]);case"listBoxes":return t.listBoxes();case"forgetBox":return t.forgetBox(r[0]);case"countBoxes":return t.countBoxes();case"appendEvent":return t.appendEvent(r[0]);case"listEvents":return t.listEvents(r[0],r[1]);case"countEvents":return t.countEvents();case"setStatus":return t.setStatus(r[0],r[1],r[2],r[3]);case"getStatus":return t.getStatus(r[0]);case"deleteStatus":return t.deleteStatus(r[0]);case"listStatuses":return t.listStatuses();case"createPrompt":return t.createPrompt(r[0]);case"getPrompt":return t.getPrompt(r[0]);case"answerPrompt":return t.answerPrompt(r[0],r[1],r[2]);case"listPendingPrompts":return t.listPendingPrompts(r[0]);case"setPromptResult":return t.setPromptResult(r[0],r[1]);default:throw Error(`unknown store op: ${e}`)}}(e.store,d.method,d.args);return{status:200,body:{result:l??null}}}var S=["agents","projects","boxes","prepared"],A=["claude","codex","opencode"],I=class extends Error{constructor(t){super(t),this.name="CustodyPathError"}},E=/^[A-Za-z0-9._-]+$/;function T(t){let e=t.replace(/^\/+/,"").replace(/\/+$/,"");if(0===e.length)throw new I("empty custody path");if(e.length>256)throw new I(`custody path too long (max ${String(256)} chars)`);let r=e.split("/");if(r.length<2)throw new I(`custody path needs a scope and a name: '${t}'`);if(r.length>6)throw new I(`custody path too deep (max ${String(6)} segments)`);for(let t of r)if("."===t||".."===t||!E.test(t))throw new I(`illegal custody path segment: '${t}'`);let a=r[0];if(!S.includes(a))throw new I(`unknown custody scope '${a}' (expected ${S.join(" | ")})`);if("agents"===a&&!A.includes(r[1]))throw new I(`unknown agent '${r[1]}' (expected ${A.join(" | ")})`);return r.join("/")}function N(t){let e=t.replace(/^\/+/,"").replace(/\/+$/,"");if(0===e.length)return"";if(e.length>256)throw new I(`custody prefix too long (max ${String(256)} chars)`);let r=e.split("/");if(r.length>6)throw new I(`custody prefix too deep (max ${String(6)} segments)`);for(let t of r)if("."===t||".."===t||!E.test(t))throw new I(`illegal custody prefix segment: '${t}'`);if(!S.includes(r[0]))throw new I(`unknown custody scope '${r[0]}' (expected ${S.join(" | ")})`);return r.join("/")}var P="/admin/custody";async function _(t,e){var r,a;let s,n;if(!((r=t.path)===P||r.startsWith(`${P}/`)))return null;let i=e.log??(()=>{}),d=e.adminToken??"";if(0===d.length)return{status:503,body:{error:"custody not configured: admin token unset"}};if(a=t.bearer,s=Buffer.from(a,"utf8"),n=Buffer.from(d,"utf8"),!(s.length===n.length&&(0,o.timingSafeEqual)(s,n)))return{status:401,body:{error:"invalid admin token"}};let l=e.custody;if(!l)return{status:503,body:{error:"custody store not enabled on this relay"}};try{if(t.path===P){if("GET"!==t.method)return{status:405,body:{error:"method not allowed"}};let e=t.query.get("prefix"),r=e?N(e):void 0,a=await l.list(r);return{status:200,body:{entries:a}}}let e=T(decodeURIComponent(t.path.slice(`${P}/`.length)));if("PUT"===t.method){let r;try{r=JSON.parse(0===t.bodyText.length?"{}":t.bodyText)}catch{return{status:400,body:{error:"expected JSON {data: <base64>}"}}}if("string"!=typeof r.data)return{status:400,body:{error:"expected {data: <base64>}"}};let a=Buffer.from(r.data,"base64");if(a.toString("base64")!==r.data.replace(/\s+/g,""))return{status:400,body:{error:"data is not valid base64"}};let s=await l.put(e,a);return i(`custody put ${e} (${String(s.size)} bytes, ${s.changed?"changed":"unchanged"})`),{status:200,body:s}}if("GET"===t.method){let t=await l.get(e);if(!t)return{status:404,body:{error:"no such custody entry"}};return i(`custody get ${e} (${String(t.entry.size)} bytes)`),{status:200,body:{...t.entry,data:t.data.toString("base64")}}}if("DELETE"===t.method){if(!await l.delete(e))return{status:404,body:{error:"no such custody entry"}};return i(`custody delete ${e}`),{status:204}}return{status:405,body:{error:"method not allowed"}}}catch(e){if(e instanceof I)return{status:400,body:{error:e.message}};let t=e instanceof Error?e.message:String(e);return i(`custody error: ${t}`),{status:500,body:{error:`custody: ${t}`}}}}var $="/remote/boxes";async function k(t,e){var r,a;let s,n;if(!((r=t.path)===$||r.startsWith(`${$}/`)))return null;let i=e.log??(()=>{}),{store:d}=e,l=e.adminToken??"";if(0===l.length)return{status:503,body:{error:"control plane not configured: admin token unset"}};if(a=t.bearer,s=Buffer.from(a,"utf8"),n=Buffer.from(l,"utf8"),!(s.length===n.length&&(0,o.timingSafeEqual)(s,n)))return{status:401,body:{error:"invalid admin token"}};if("POST"===t.method&&t.path===$){if(!d.enqueueCreateJob)return{status:501,body:{error:"create-job queue not available on this store"}};let r=function(t){if(0===t.length)return{};try{return JSON.parse(t)}catch{return null}}(t.bodyText);if(!r||"string"!=typeof r.repoUrl||"string"!=typeof r.provider)return{status:400,body:{error:"expected {repoUrl, provider, branch?, name?, agent?, prompt?}"}};let a=e.createProviders;if(a&&a.length>0&&!a.includes(r.provider))return{status:400,body:{error:`provider '${r.provider}' is not supported by this control plane (allowed: ${a.join(", ")})`}};let s=(0,o.randomUUID)();return await d.enqueueCreateJob({id:s,status:"queued",request:{repoUrl:r.repoUrl,provider:r.provider,branch:r.branch,name:r.name,agent:r.agent,prompt:r.prompt},createdAt:new Date().toISOString()}),i(`enqueued create job ${s} (${r.provider} ${r.repoUrl})`),{status:202,body:{jobId:s}}}if("GET"===t.method&&t.path===$){if(!d.listCreateJobs)return{status:501,body:{error:"create-job queue not available on this store"}};let t=await d.listCreateJobs({limit:100});return{status:200,body:{jobs:t}}}if("GET"===t.method&&t.path.endsWith("/logs")){let r=decodeURIComponent(t.path.slice(`${$}/`.length,-5));if(0===r.length)return{status:404,body:{error:"no such job"}};if(!(r.length>0&&r.length<=128&&/^[A-Za-z0-9._-]+$/.test(r)))return{status:400,body:{error:"invalid job id"}};if(!e.readJobLog)return{status:501,body:{error:"job logs not available on this plane"}};let a=Number.parseInt(t.query?.get("offset")??"0",10),s=await e.readJobLog(r,Number.isFinite(a)?a:0);return{status:200,body:s}}if("GET"===t.method&&t.path.startsWith(`${$}/`)){if(!d.getCreateJob)return{status:501,body:{error:"create-job queue not available on this store"}};let e=decodeURIComponent(t.path.slice(`${$}/`.length)),r=await d.getCreateJob(e);return r?{status:200,body:r}:{status:404,body:{error:"no such job"}}}if("DELETE"===t.method&&t.path.startsWith(`${$}/`)){let r=decodeURIComponent(t.path.slice(`${$}/`.length));if(0===r.length)return{status:404,body:{error:"no such box"}};let a=await d.getBox(r),s=await d.forgetBox(r);await d.deleteStatus(r);let n=0;if(e.custody){let t=a?.sandboxId??r;for(let r of(await e.custody.list(`boxes/${t}`).catch(()=>[])))await e.custody.delete(r.path).catch(()=>!1)&&(n+=1)}let o=await C(r,a?.sandboxId,i);return s||a||0!==n||o?(i(`reaped box ${r} (registration=${String(s)}, custody=${String(n)}, local=${String(o)})`),{status:200,body:{boxId:r,removed:s,custodyRemoved:n,localRemoved:o}}):{status:404,body:{error:"no such box"}}}return{status:405,body:{error:"method not allowed"}}}async function C(e,r,s){let o=!1;try{let{mutateState:s,readState:i,boxSshDirForProvider:d}=await t.A(53982),l=(await i()).boxes.find(t=>t.id===e);if(l){await s(t=>({...t,boxes:t.boxes.filter(t=>t.id!==e)})),o=!0;let t=l.cloud?.sandboxId??r,i=l.provider;if(t&&i){let e=d(i,t);e&&await (0,a.rm)((0,n.dirname)(e),{recursive:!0,force:!0}).catch(()=>{})}}}catch(t){s(`local reap for ${e} failed: ${t instanceof Error?t.message:String(t)}`)}return o}var B=class{inner;registry;events;statusStore;constructor(t,e){this.inner=t,this.registry=e.registry,this.events=e.events,this.statusStore=e.statusStore}async hydrate(){for(let t of(await this.inner.listBoxes()))this.registry.register(t);for(let{boxId:t,status:e}of(await this.inner.listStatuses())){let r=this.registry.get(t);await this.statusStore.set(t,r?.name??t,r?.projectIndex,e)}}migrate(){return this.inner.migrate?.()??Promise.resolve()}async registerBox(t){await this.inner.registerBox(t),this.registry.register(t)}getBox(t){return this.inner.getBox(t)}authenticateBox(t){return this.inner.authenticateBox(t)}listBoxes(){return this.inner.listBoxes()}async forgetBox(t){let e=await this.inner.forgetBox(t);return this.registry.forget(t),e}countBoxes(){return this.inner.countBoxes()}async appendEvent(t){let e=await this.inner.appendEvent(t);return this.events.append(t),e}listEvents(t,e){return this.inner.listEvents(t,e)}countEvents(){return this.inner.countEvents()}async setStatus(t,e,r,a){await this.inner.setStatus(t,e,r,a),await this.statusStore.set(t,e,r,a)}getStatus(t){return this.inner.getStatus(t)}async deleteStatus(t){await this.inner.deleteStatus(t),this.statusStore.delete(t)}listStatuses(){return this.inner.listStatuses()}createPrompt(t){return this.inner.createPrompt(t)}getPrompt(t){return this.inner.getPrompt(t)}answerPrompt(t,e,r){return this.inner.answerPrompt(t,e,r)}listPendingPrompts(t){return this.inner.listPendingPrompts(t)}setPromptResult(t,e){return this.inner.setPromptResult(t,e)}enqueueCreateJob(t){return this.inner.enqueueCreateJob?this.inner.enqueueCreateJob(t):Promise.resolve()}getCreateJob(t){return this.inner.getCreateJob?.(t)??Promise.resolve(null)}listCreateJobs(t){return this.inner.listCreateJobs?.(t)??Promise.resolve([])}claimNextCreateJob(t){return this.inner.claimNextCreateJob?.(t)??Promise.resolve(null)}completeCreateJob(t,e,r){return this.inner.completeCreateJob?this.inner.completeCreateJob(t,e,r):Promise.resolve()}prunePrompts(t){return this.inner.prunePrompts?.(t)??Promise.resolve(0)}pruneCreateJobs(t){return this.inner.pruneCreateJobs?.(t)??Promise.resolve(0)}};function L(t){return Buffer.from(t).toString("base64url")}function O(t,e=Date.now()){let r=Math.floor(e/1e3),a=L(JSON.stringify({alg:"RS256",typ:"JWT"})),s=L(JSON.stringify({iat:r-60,exp:r+540,iss:t.appId})),n=`${a}.${s}`,i=(0,o.createSign)("RSA-SHA256").update(n).sign(t.privateKeyPem);return`${n}.${L(i)}`}var R=class{cfg;fetchImpl;now;apiBase;cache=new Map;installationIds=new Map;constructor(t,e={}){this.cfg=t,this.fetchImpl=e.fetchImpl??fetch,this.now=e.now??Date.now,this.apiBase=(t.apiBaseUrl??"https://api.github.com").replace(/\/$/,"")}headers(t){return{Authorization:`Bearer ${t}`,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"agentbox-relay"}}async lookupInstallationId(t,e){let r=`${t}/${e}`,a=this.installationIds.get(r);if(void 0!==a)return a;let s=O(this.cfg,this.now()),n=await this.fetchImpl(`${this.apiBase}/repos/${t}/${e}/installation`,{headers:this.headers(s)});if(404===n.status)return null;if(!n.ok)throw Error(`GET installation for ${r} \u2192 ${String(n.status)}`);let o=await n.json();if("number"!=typeof o.id)throw Error("installation response missing id");return this.installationIds.set(r,o.id),o.id}async installationId(t,e){let r=await this.lookupInstallationId(t,e);if(null===r)throw Error(`GitHub App is not installed on ${t}/${e}`);return r}async isRepoInstalled(t,e){return await this.lookupInstallationId(t,e)!==null}async leaseRepoToken(t,e){let r=`${t}/${e}`,a=this.cache.get(r);if(a&&a.expiresAtMs-this.now()>3e5)return{token:a.token,expiresAt:a.expiresAt};let s=await this.installationId(t,e),n=O(this.cfg,this.now()),o=await this.fetchImpl(`${this.apiBase}/app/installations/${String(s)}/access_tokens`,{method:"POST",headers:{...this.headers(n),"Content-Type":"application/json"},body:JSON.stringify({repositories:[e],permissions:{contents:"write",pull_requests:"write"}})});if(!o.ok)throw Error(`failed to mint installation token for ${r} (\u2192 ${String(o.status)})`);let i=await o.json();if(!i.token||!i.expires_at)throw Error("access_tokens response missing token/expires_at");return this.cache.set(r,{token:i.token,expiresAt:i.expires_at,expiresAtMs:Date.parse(i.expires_at)}),{token:i.token,expiresAt:i.expires_at}}};(0,n.join)(i.STATE_DIR,"queue");var U=(0,n.join)(i.STATE_DIR,"logs");t.s(["CUSTODY_SCOPES",0,S,"CustodyTooLargeError",0,class extends Error{constructor(t){super(`payload exceeds the custody blob cap of ${String(t)} bytes`),this.maxBytes=t,this.name="CustodyTooLargeError"}maxBytes},"GitHubAppLeaser",0,R,"MemoryStore",0,h,"QUEUE_LOGS_DIR",0,U,"RELAY_EVENT_RING_SIZE",0,1e3,"WriteThroughStore",0,B,"custodyDigest",0,function(t){return(0,o.createHash)("sha256").update(t).digest("hex")},"gateApproval",0,g,"handleCustodyRequest",0,_,"handleRemoteBoxesRequest",0,k,"handleStoreRpcRequest",0,v,"isValidBoxStatus",0,function(t){return"object"==typeof t&&null!==t&&1===t.schema&&"string"==typeof t.boxId&&t.boxId.length>0},"leaseTokenResult",0,w,"loadGitHubAppConfig",0,function(){let t=process.env.GITHUB_APP_ID,e=process.env.GITHUB_APP_PRIVATE_KEY;if(!t||!e)return null;if(!e.includes("BEGIN"))try{e=Buffer.from(e,"base64").toString("utf8")}catch{return null}let r=process.env.GITHUB_API_URL||void 0;return{appId:t,privateKeyPem:e,apiBaseUrl:r}},"normalizeCustodyPath",0,T,"normalizeCustodyPrefix",0,N,"parseGitRemote",0,b,"queueLogPath",0,function(t){return(0,n.join)(U,`queue-${t}.log`)},"repoSlugFromRemote",0,x,"resolveWorktree",0,function(t,e){let r=t.worktrees??[];if(0===r.length)return null;let a=r.find(t=>t.containerPath===e);return a||(r.filter(t=>e===t.containerPath||e.startsWith(t.containerPath+"/")).sort((t,e)=>e.containerPath.length-t.containerPath.length)[0]??r.find(t=>"/workspace"===t.containerPath)??null)},"toAuthedHttpsUrl",0,y,"toHttpsUrl",0,function(t){let{host:e,path:r}=b(t);return`https://${e}/${r}`}]),r()}catch(t){r(t)}},!1),92436,t=>t.a(async(e,r)=>{try{var a=t.i(71326),s=t.i(54799),n=t.i(72939),o=t.i(57743),i=t.i(11205),d=t.i(63080),l=t.i(56698),u=t.i(44946),c=t.i(64645),p=t.i(62160),h=t.i(8614),m=t.i(93540),g=t.i(21918),b=t.i(2340),y=t.i(42631),x=t.i(48771),w=t.i(22734),f=t.i(62562),v=t.i(14747),S=t.i(46063),A=t.i(24868),I=t.i(28065),E=t.i(88947),T=e([a]);[a]=T.then?(await T)():T;let ti={get url(){return`file://${t.P("packages/relay/dist/chunk-DPQ524VB.js")}`}};async function N(t,e,r,a,s,n=()=>{}){await t(s?["clone","--branch",s,e,a]:["clone",e,a],{GIT_LFS_SKIP_SMUDGE:"1"});try{await t(["-C",a,"-c",`lfs.url=${e.replace(/\.git$/,"")}.git/info/lfs`,"lfs","pull"],{GIT_TERMINAL_PROMPT:"0",GIT_SSH_COMMAND:"ssh -o BatchMode=yes -o StrictHostKeyChecking=no"},12e4)}catch(t){n(`git-lfs objects left as pointers (fetch failed): ${t instanceof Error?t.message:String(t)}`)}await t(["-C",a,"remote","set-url","origin",r])}async function P(t,e,r){if(!t.claimNextCreateJob||!t.completeCreateJob)return null;let a=await t.claimNextCreateJob(r);if(!a)return null;try{let{boxId:r,agentStartError:s}=await e(a.request,a.id);s?await t.completeCreateJob(a.id,"failed",{boxId:r,error:s}):await t.completeCreateJob(a.id,"done",{boxId:r})}catch(e){await t.completeCreateJob(a.id,"failed",{error:e instanceof Error?e.message:String(e)})}return a.id}async function _(t,e,r,a=10){let s=0;for(;s<a&&await P(t,e,r);)s++;return s}function $(t,e=200){return{status:e,body:t}}function k(t,e){return{status:t,body:{error:e}}}function C(t){if(0===t.length)return{};try{return JSON.parse(t)}catch{return null}}var B=new Set(["git.push","git.fetch","cp.toHost","cp.fromHost","download.workspace","download.env","download.config","download.claude","checkpoint.create"]);async function L(t,e){var r,n;let o,i,{store:d,leaser:l}=e,u=e.log??(()=>{});if(0===e.adminToken.length)return k(503,"control plane not configured: admin token unset");if("GET"===t.method&&"/healthz"===t.path)return $({ok:!0,boxes:await d.countBoxes(),events:await d.countEvents(),controlPlane:!0});if((t.path.startsWith("/admin/")||t.path.startsWith("/remote/"))&&(r=t.bearer,n=e.adminToken,o=Buffer.from(r,"utf8"),i=Buffer.from(n,"utf8"),!(o.length===i.length&&(0,s.timingSafeEqual)(o,i))))return k(401,"invalid admin token");let c={custody:e.custody,adminToken:e.adminToken,log:u},p=await (0,a.handleCustodyRequest)(t,c);if(p)return void 0===p.body?{status:p.status}:$(p.body,p.status);if("POST"===t.method&&"/events"===t.path){let e=await d.authenticateBox(t.bearer);if(!e)return k(401,"unknown box token");let r=C(t.bodyText);if(!r||"string"!=typeof r.type||0===r.type.length)return k(400,'missing "type" string');if("box-status"===r.type)return(0,a.isValidBoxStatus)(r.payload)?(await d.setStatus(e.boxId,e.name,e.projectIndex,r.payload),$({ok:!0},202)):k(400,"invalid box-status payload");let s=await d.appendEvent({boxId:e.boxId,type:r.type,ts:"string"==typeof r.ts?r.ts:void 0,payload:r.payload});return $({id:s.id},202)}if("POST"===t.method&&"/rpc"===t.path){let r=await d.authenticateBox(t.bearer);if(!r)return k(401,"unknown box token");let a=C(t.bodyText);return a&&"string"==typeof a.method&&0!==a.method.length?(u(`rpc box=${r.boxId} method=${a.method}`),O(r,a.method,a.params,e)):k(400,'missing "method" string')}if("GET"===t.method&&t.path.startsWith("/rpc/status/")){let e=await d.authenticateBox(t.bearer);if(!e)return k(401,"unknown box token");let r=decodeURIComponent(t.path.slice(12)),a=await d.getPrompt(r);if(!a||a.boxId!==e.boxId)return k(404,"no such prompt");if("pending"===a.status)return $({status:"pending"});if("y"!==a.answer||a.cancelled)return $({status:"done",result:{exitCode:10,stdout:"",stderr:"denied by user\n"}});let s=a.result,n=s??await R(e,a.method,l);return s||await d.setPromptResult(r,n),$({status:"done",result:n})}if("POST"===t.method&&"/admin/register-box"===t.path){let e=C(t.bodyText);if(!e||!e.boxId||!e.token||"string"!=typeof e.name)return k(400,"expected {boxId, token, name}");let r={boxId:e.boxId,token:e.token,name:e.name,kind:"cloud"===e.kind?"cloud":"docker",backend:e.backend||void 0,sandboxId:e.sandboxId||void 0,registeredAt:new Date().toISOString(),containerName:e.containerName||void 0,createdAt:e.createdAt||void 0,projectIndex:"number"==typeof e.projectIndex&&e.projectIndex>0?Math.trunc(e.projectIndex):void 0,worktrees:Array.isArray(e.worktrees)?e.worktrees:void 0,previewUrl:e.previewUrl||void 0,previewToken:e.previewToken||void 0,bridgeToken:e.bridgeToken||void 0,autoApproveHostActions:!0===e.autoApproveHostActions,autoApproveSafeHostActions:!1!==e.autoApproveSafeHostActions,originUrl:e.originUrl||void 0};return await d.registerBox(r),u(`registered ${r.kind??"docker"} box ${r.boxId} (${r.name})`),$(null,204)}if("POST"===t.method&&"/admin/forget-box"===t.path){let e=C(t.bodyText);return e?.boxId?(await d.forgetBox(e.boxId),await d.deleteStatus(e.boxId),$(null,204)):k(400,"expected {boxId}")}if("GET"===t.method&&"/admin/box-status"===t.path){let e=t.query.get("box")??"",r=e?await d.getStatus(e):void 0;return r?$(r):k(404,"no status for box")}if("GET"===t.method&&"/admin/events"===t.path){let e=Number.parseInt(t.query.get("since")??"0",10)||0,r=t.query.get("box")??void 0;return $({events:await d.listEvents(e,r??void 0)})}if("GET"===t.method&&"/admin/app/repo-installed"===t.path){if(!l)return k(503,"no GitHub App configured on this control plane");let e=t.query.get("owner")??"",r=t.query.get("repo")??"";if(!e||!r)return k(400,"missing owner/repo query params");try{return $({installed:await l.isRepoInstalled(e,r)})}catch(t){return k(502,`installation check failed: ${t instanceof Error?t.message:String(t)}`)}}if("GET"===t.method&&"/admin/registry"===t.path){let t=(await d.listBoxes()).map(t=>({boxId:t.boxId,name:t.name,kind:t.kind,registeredAt:t.registeredAt,projectIndex:t.projectIndex,originUrl:t.originUrl}));return $({boxes:t})}if("GET"===t.method&&"/admin/prompts"===t.path){let e=t.query.get("boxId")??"";if(0===e.length)return k(400,"missing boxId query param");let r=(await d.listPendingPrompts(e)).map(t=>t.ev);return $({prompts:r})}if("POST"===t.method&&"/admin/prompts/answer"===t.path){let e=C(t.bodyText);return e?.id&&("y"===e.answer||"n"===e.answer)?await d.answerPrompt(e.id,e.answer,e.cancelled)?$(null,204):k(404,"no pending prompt with that id"):k(400,'expected {id, answer:"y"|"n", cancelled?}')}let h=await (0,a.handleStoreRpcRequest)(t,{store:d,adminToken:e.adminToken,log:u});if(h)return void 0===h.body?{status:h.status}:$(h.body,h.status);let m=await (0,a.handleRemoteBoxesRequest)(t,{store:d,adminToken:e.adminToken,createProviders:e.createProviders,custody:e.custody,log:u});return m?void 0===m.body?{status:m.status}:$(m.body,m.status):k(404,"not found")}async function O(t,e,r,s){if("git.lease-token"===e){let o=(0,a.resolveWorktree)(t,r?.path??"/workspace");if(!(0,n.isScratchBranch)(o?.branch)){let n=await (0,a.gateApproval)({mode:"poll",store:s.store},t.boxId,e,r,{kind:"confirm",message:`Allow box ${t.name} to lease a push token for ${t.originUrl??"its repo"}?`,detail:`branch ${o?.branch??"(unregistered)"}`,defaultAnswer:"n",context:{command:"git lease-token",cwd:r?.path}});if("pending"===n.kind)return $({status:"pending",promptId:n.promptId},202);if("deny"===n.kind)return $({exitCode:10,stdout:"",stderr:"denied by user\n"},500)}let i=await (0,a.leaseTokenResult)(s.leaser,t);return $(i,0===i.exitCode?200:500)}return"browser.open"===e?("string"==typeof r?.url&&await s.store.appendEvent({boxId:t.boxId,type:"browser-open",payload:{url:r.url}}),$({exitCode:0,stdout:"",stderr:""})):B.has(e)?$({exitCode:64,stdout:"",stderr:`${e}: not available on the hosted control plane (no host). Cloud boxes push via git.lease-token.
5
+ `}}}var f=new Set(["registerBox","getBox","authenticateBox","listBoxes","forgetBox","countBoxes","appendEvent","listEvents","countEvents","setStatus","getStatus","deleteStatus","listStatuses","createPrompt","getPrompt","answerPrompt","listPendingPrompts","setPromptResult"]);async function v(t,e){var r,a;let s,n;if("/admin/store"!==t.path)return null;let i=e.adminToken??"";if(0===i.length)return{status:503,body:{error:"control plane not configured: admin token unset"}};if(r=t.bearer,s=Buffer.from(r,"utf8"),n=Buffer.from(i,"utf8"),!(s.length===n.length&&(0,o.timingSafeEqual)(s,n)))return{status:401,body:{error:"invalid admin token"}};if("POST"!==t.method)return{status:405,body:{error:"method not allowed"}};let d=function(t){if(0===t.length)return null;try{return JSON.parse(t)}catch{return null}}(t.bodyText);if(!d||"string"!=typeof d.method||!Array.isArray(d.args))return{status:400,body:{error:"expected {method, args}"}};if(a=d.method,!f.has(a))return{status:400,body:{error:`unknown store op: ${d.method}`}};let l=await function(t,e,r){switch(e){case"registerBox":return t.registerBox(r[0]);case"getBox":return t.getBox(r[0]);case"authenticateBox":return t.authenticateBox(r[0]);case"listBoxes":return t.listBoxes();case"forgetBox":return t.forgetBox(r[0]);case"countBoxes":return t.countBoxes();case"appendEvent":return t.appendEvent(r[0]);case"listEvents":return t.listEvents(r[0],r[1]);case"countEvents":return t.countEvents();case"setStatus":return t.setStatus(r[0],r[1],r[2],r[3]);case"getStatus":return t.getStatus(r[0]);case"deleteStatus":return t.deleteStatus(r[0]);case"listStatuses":return t.listStatuses();case"createPrompt":return t.createPrompt(r[0]);case"getPrompt":return t.getPrompt(r[0]);case"answerPrompt":return t.answerPrompt(r[0],r[1],r[2]);case"listPendingPrompts":return t.listPendingPrompts(r[0]);case"setPromptResult":return t.setPromptResult(r[0],r[1]);default:throw Error(`unknown store op: ${e}`)}}(e.store,d.method,d.args);return{status:200,body:{result:l??null}}}var S=["agents","projects","boxes","prepared"],A=["claude","codex","opencode"],I=class extends Error{constructor(t){super(t),this.name="CustodyPathError"}},E=/^[A-Za-z0-9._-]+$/;function T(t){let e=t.replace(/^\/+/,"").replace(/\/+$/,"");if(0===e.length)throw new I("empty custody path");if(e.length>256)throw new I(`custody path too long (max ${String(256)} chars)`);let r=e.split("/");if(r.length<2)throw new I(`custody path needs a scope and a name: '${t}'`);if(r.length>6)throw new I(`custody path too deep (max ${String(6)} segments)`);for(let t of r)if("."===t||".."===t||!E.test(t))throw new I(`illegal custody path segment: '${t}'`);let a=r[0];if(!S.includes(a))throw new I(`unknown custody scope '${a}' (expected ${S.join(" | ")})`);if("agents"===a&&!A.includes(r[1]))throw new I(`unknown agent '${r[1]}' (expected ${A.join(" | ")})`);return r.join("/")}function N(t){let e=t.replace(/^\/+/,"").replace(/\/+$/,"");if(0===e.length)return"";if(e.length>256)throw new I(`custody prefix too long (max ${String(256)} chars)`);let r=e.split("/");if(r.length>6)throw new I(`custody prefix too deep (max ${String(6)} segments)`);for(let t of r)if("."===t||".."===t||!E.test(t))throw new I(`illegal custody prefix segment: '${t}'`);if(!S.includes(r[0]))throw new I(`unknown custody scope '${r[0]}' (expected ${S.join(" | ")})`);return r.join("/")}var P="/admin/custody";async function _(t,e){var r,a;let s,n;if(!((r=t.path)===P||r.startsWith(`${P}/`)))return null;let i=e.log??(()=>{}),d=e.adminToken??"";if(0===d.length)return{status:503,body:{error:"custody not configured: admin token unset"}};if(a=t.bearer,s=Buffer.from(a,"utf8"),n=Buffer.from(d,"utf8"),!(s.length===n.length&&(0,o.timingSafeEqual)(s,n)))return{status:401,body:{error:"invalid admin token"}};let l=e.custody;if(!l)return{status:503,body:{error:"custody store not enabled on this relay"}};try{if(t.path===P){if("GET"!==t.method)return{status:405,body:{error:"method not allowed"}};let e=t.query.get("prefix"),r=e?N(e):void 0,a=await l.list(r);return{status:200,body:{entries:a}}}let e=T(decodeURIComponent(t.path.slice(`${P}/`.length)));if("PUT"===t.method){let r;try{r=JSON.parse(0===t.bodyText.length?"{}":t.bodyText)}catch{return{status:400,body:{error:"expected JSON {data: <base64>}"}}}if("string"!=typeof r.data)return{status:400,body:{error:"expected {data: <base64>}"}};let a=Buffer.from(r.data,"base64");if(a.toString("base64")!==r.data.replace(/\s+/g,""))return{status:400,body:{error:"data is not valid base64"}};let s=await l.put(e,a);return i(`custody put ${e} (${String(s.size)} bytes, ${s.changed?"changed":"unchanged"})`),{status:200,body:s}}if("GET"===t.method){let t=await l.get(e);if(!t)return{status:404,body:{error:"no such custody entry"}};return i(`custody get ${e} (${String(t.entry.size)} bytes)`),{status:200,body:{...t.entry,data:t.data.toString("base64")}}}if("DELETE"===t.method){if(!await l.delete(e))return{status:404,body:{error:"no such custody entry"}};return i(`custody delete ${e}`),{status:204}}return{status:405,body:{error:"method not allowed"}}}catch(e){if(e instanceof I)return{status:400,body:{error:e.message}};let t=e instanceof Error?e.message:String(e);return i(`custody error: ${t}`),{status:500,body:{error:`custody: ${t}`}}}}var $="/remote/boxes";async function k(t,e){var r,a;let s,n;if(!((r=t.path)===$||r.startsWith(`${$}/`)))return null;let i=e.log??(()=>{}),{store:d}=e,l=e.adminToken??"";if(0===l.length)return{status:503,body:{error:"control plane not configured: admin token unset"}};if(a=t.bearer,s=Buffer.from(a,"utf8"),n=Buffer.from(l,"utf8"),!(s.length===n.length&&(0,o.timingSafeEqual)(s,n)))return{status:401,body:{error:"invalid admin token"}};if("POST"===t.method&&t.path===$){if(!d.enqueueCreateJob)return{status:501,body:{error:"create-job queue not available on this store"}};let r=function(t){if(0===t.length)return{};try{return JSON.parse(t)}catch{return null}}(t.bodyText);if(!r||"string"!=typeof r.repoUrl||"string"!=typeof r.provider)return{status:400,body:{error:"expected {repoUrl, provider, branch?, name?, agent?, prompt?}"}};let a=e.createProviders;if(a&&a.length>0&&!a.includes(r.provider))return{status:400,body:{error:`provider '${r.provider}' is not supported by this control plane (allowed: ${a.join(", ")})`}};let s=(0,o.randomUUID)();return await d.enqueueCreateJob({id:s,status:"queued",request:{repoUrl:r.repoUrl,provider:r.provider,branch:r.branch,name:r.name,agent:r.agent,prompt:r.prompt},createdAt:new Date().toISOString()}),i(`enqueued create job ${s} (${r.provider} ${r.repoUrl})`),{status:202,body:{jobId:s}}}if("GET"===t.method&&t.path===$){if(!d.listCreateJobs)return{status:501,body:{error:"create-job queue not available on this store"}};let t=await d.listCreateJobs({limit:100});return{status:200,body:{jobs:t}}}if("GET"===t.method&&t.path.endsWith("/logs")){let r=decodeURIComponent(t.path.slice(`${$}/`.length,-5));if(0===r.length)return{status:404,body:{error:"no such job"}};if(!(r.length>0&&r.length<=128&&/^[A-Za-z0-9._-]+$/.test(r)))return{status:400,body:{error:"invalid job id"}};if(!e.readJobLog)return{status:501,body:{error:"job logs not available on this plane"}};let a=Number.parseInt(t.query?.get("offset")??"0",10),s=await e.readJobLog(r,Number.isFinite(a)?a:0);return{status:200,body:s}}if("GET"===t.method&&t.path.startsWith(`${$}/`)){if(!d.getCreateJob)return{status:501,body:{error:"create-job queue not available on this store"}};let e=decodeURIComponent(t.path.slice(`${$}/`.length)),r=await d.getCreateJob(e);return r?{status:200,body:r}:{status:404,body:{error:"no such job"}}}if("DELETE"===t.method&&t.path.startsWith(`${$}/`)){let r=decodeURIComponent(t.path.slice(`${$}/`.length));if(0===r.length)return{status:404,body:{error:"no such box"}};let a=await d.getBox(r),s=await d.forgetBox(r);await d.deleteStatus(r);let n=0;if(e.custody){let t=a?.sandboxId??r;for(let r of(await e.custody.list(`boxes/${t}`).catch(()=>[])))await e.custody.delete(r.path).catch(()=>!1)&&(n+=1)}let o=await C(r,a?.sandboxId,i);return s||a||0!==n||o?(i(`reaped box ${r} (registration=${String(s)}, custody=${String(n)}, local=${String(o)})`),{status:200,body:{boxId:r,removed:s,custodyRemoved:n,localRemoved:o}}):{status:404,body:{error:"no such box"}}}return{status:405,body:{error:"method not allowed"}}}async function C(e,r,s){let o=!1;try{let{mutateState:s,readState:i,boxSshDirForProvider:d}=await t.A(53982),l=(await i()).boxes.find(t=>t.id===e);if(l){await s(t=>({...t,boxes:t.boxes.filter(t=>t.id!==e)})),o=!0;let t=l.cloud?.sandboxId??r,i=l.provider;if(t&&i){let e=d(i,t);e&&await (0,a.rm)((0,n.dirname)(e),{recursive:!0,force:!0}).catch(()=>{})}}}catch(t){s(`local reap for ${e} failed: ${t instanceof Error?t.message:String(t)}`)}return o}var B=class{inner;registry;events;statusStore;constructor(t,e){this.inner=t,this.registry=e.registry,this.events=e.events,this.statusStore=e.statusStore}async hydrate(){for(let t of(await this.inner.listBoxes()))this.registry.register(t);for(let{boxId:t,status:e}of(await this.inner.listStatuses())){let r=this.registry.get(t);await this.statusStore.set(t,r?.name??t,r?.projectIndex,e)}}migrate(){return this.inner.migrate?.()??Promise.resolve()}async registerBox(t){await this.inner.registerBox(t),this.registry.register(t)}getBox(t){return this.inner.getBox(t)}authenticateBox(t){return this.inner.authenticateBox(t)}listBoxes(){return this.inner.listBoxes()}async forgetBox(t){let e=await this.inner.forgetBox(t);return this.registry.forget(t),e}countBoxes(){return this.inner.countBoxes()}async appendEvent(t){let e=await this.inner.appendEvent(t);return this.events.append(t),e}listEvents(t,e){return this.inner.listEvents(t,e)}countEvents(){return this.inner.countEvents()}async setStatus(t,e,r,a){await this.inner.setStatus(t,e,r,a),await this.statusStore.set(t,e,r,a)}getStatus(t){return this.inner.getStatus(t)}async deleteStatus(t){await this.inner.deleteStatus(t),this.statusStore.delete(t)}listStatuses(){return this.inner.listStatuses()}createPrompt(t){return this.inner.createPrompt(t)}getPrompt(t){return this.inner.getPrompt(t)}answerPrompt(t,e,r){return this.inner.answerPrompt(t,e,r)}listPendingPrompts(t){return this.inner.listPendingPrompts(t)}setPromptResult(t,e){return this.inner.setPromptResult(t,e)}enqueueCreateJob(t){return this.inner.enqueueCreateJob?this.inner.enqueueCreateJob(t):Promise.resolve()}getCreateJob(t){return this.inner.getCreateJob?.(t)??Promise.resolve(null)}listCreateJobs(t){return this.inner.listCreateJobs?.(t)??Promise.resolve([])}claimNextCreateJob(t){return this.inner.claimNextCreateJob?.(t)??Promise.resolve(null)}completeCreateJob(t,e,r){return this.inner.completeCreateJob?this.inner.completeCreateJob(t,e,r):Promise.resolve()}prunePrompts(t){return this.inner.prunePrompts?.(t)??Promise.resolve(0)}pruneCreateJobs(t){return this.inner.pruneCreateJobs?.(t)??Promise.resolve(0)}};function L(t){return Buffer.from(t).toString("base64url")}function O(t,e=Date.now()){let r=Math.floor(e/1e3),a=L(JSON.stringify({alg:"RS256",typ:"JWT"})),s=L(JSON.stringify({iat:r-60,exp:r+540,iss:t.appId})),n=`${a}.${s}`,i=(0,o.createSign)("RSA-SHA256").update(n).sign(t.privateKeyPem);return`${n}.${L(i)}`}var R=class{cfg;fetchImpl;now;apiBase;cache=new Map;installationIds=new Map;constructor(t,e={}){this.cfg=t,this.fetchImpl=e.fetchImpl??fetch,this.now=e.now??Date.now,this.apiBase=(t.apiBaseUrl??"https://api.github.com").replace(/\/$/,"")}headers(t){return{Authorization:`Bearer ${t}`,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"agentbox-relay"}}async lookupInstallationId(t,e){let r=`${t}/${e}`,a=this.installationIds.get(r);if(void 0!==a)return a;let s=O(this.cfg,this.now()),n=await this.fetchImpl(`${this.apiBase}/repos/${t}/${e}/installation`,{headers:this.headers(s)});if(404===n.status)return null;if(!n.ok)throw Error(`GET installation for ${r} \u2192 ${String(n.status)}`);let o=await n.json();if("number"!=typeof o.id)throw Error("installation response missing id");return this.installationIds.set(r,o.id),o.id}async installationId(t,e){let r=await this.lookupInstallationId(t,e);if(null===r)throw Error(`GitHub App is not installed on ${t}/${e}`);return r}async isRepoInstalled(t,e){return await this.lookupInstallationId(t,e)!==null}async leaseRepoToken(t,e){let r=`${t}/${e}`,a=this.cache.get(r);if(a&&a.expiresAtMs-this.now()>3e5)return{token:a.token,expiresAt:a.expiresAt};let s=await this.installationId(t,e),n=O(this.cfg,this.now()),o=await this.fetchImpl(`${this.apiBase}/app/installations/${String(s)}/access_tokens`,{method:"POST",headers:{...this.headers(n),"Content-Type":"application/json"},body:JSON.stringify({repositories:[e],permissions:{contents:"write",pull_requests:"write"}})});if(!o.ok)throw Error(`failed to mint installation token for ${r} (\u2192 ${String(o.status)})`);let i=await o.json();if(!i.token||!i.expires_at)throw Error("access_tokens response missing token/expires_at");return this.cache.set(r,{token:i.token,expiresAt:i.expires_at,expiresAtMs:Date.parse(i.expires_at)}),{token:i.token,expiresAt:i.expires_at}}};(0,n.join)(i.STATE_DIR,"queue");var U=(0,n.join)(i.STATE_DIR,"logs");t.s(["CUSTODY_SCOPES",0,S,"CustodyTooLargeError",0,class extends Error{constructor(t){super(`payload exceeds the custody blob cap of ${String(t)} bytes`),this.maxBytes=t,this.name="CustodyTooLargeError"}maxBytes},"GitHubAppLeaser",0,R,"MemoryStore",0,h,"QUEUE_LOGS_DIR",0,U,"RELAY_EVENT_RING_SIZE",0,1e3,"WriteThroughStore",0,B,"custodyDigest",0,function(t){return(0,o.createHash)("sha256").update(t).digest("hex")},"gateApproval",0,g,"handleCustodyRequest",0,_,"handleRemoteBoxesRequest",0,k,"handleStoreRpcRequest",0,v,"isValidBoxStatus",0,function(t){return"object"==typeof t&&null!==t&&1===t.schema&&"string"==typeof t.boxId&&t.boxId.length>0},"leaseTokenResult",0,w,"loadGitHubAppConfig",0,function(){let t=process.env.GITHUB_APP_ID,e=process.env.GITHUB_APP_PRIVATE_KEY;if(!t||!e)return null;if(!e.includes("BEGIN"))try{e=Buffer.from(e,"base64").toString("utf8")}catch{return null}let r=process.env.GITHUB_API_URL||void 0;return{appId:t,privateKeyPem:e,apiBaseUrl:r}},"normalizeCustodyPath",0,T,"normalizeCustodyPrefix",0,N,"parseGitRemote",0,b,"queueLogPath",0,function(t){return(0,n.join)(U,`queue-${t}.log`)},"repoSlugFromRemote",0,x,"resolveWorktree",0,function(t,e){let r=t.worktrees??[];if(0===r.length)return null;let a=r.find(t=>t.containerPath===e);return a||(r.filter(t=>e===t.containerPath||e.startsWith(t.containerPath+"/")).sort((t,e)=>e.containerPath.length-t.containerPath.length)[0]??r.find(t=>"/workspace"===t.containerPath)??null)},"toAuthedHttpsUrl",0,y,"toHttpsUrl",0,function(t){let{host:e,path:r}=b(t);return`https://${e}/${r}`}]),r()}catch(t){r(t)}},!1),4418,t=>t.a(async(e,r)=>{try{var a=t.i(25230),s=t.i(54799),n=t.i(72939),o=t.i(57743),i=t.i(11205),d=t.i(63080),l=t.i(56698),u=t.i(44946),c=t.i(64645),p=t.i(62160),h=t.i(8614),m=t.i(93540),g=t.i(21918),b=t.i(2340),y=t.i(42631),x=t.i(48771),w=t.i(22734),f=t.i(62562),v=t.i(14747),S=t.i(46063),A=t.i(24868),I=t.i(28065),E=t.i(88947),T=e([a]);[a]=T.then?(await T)():T;let ti={get url(){return`file://${t.P("packages/relay/dist/chunk-FFZRXAUM.js")}`}};async function N(t,e,r,a,s,n=()=>{}){await t(s?["clone","--branch",s,e,a]:["clone",e,a],{GIT_LFS_SKIP_SMUDGE:"1"});try{await t(["-C",a,"-c",`lfs.url=${e.replace(/\.git$/,"")}.git/info/lfs`,"lfs","pull"],{GIT_TERMINAL_PROMPT:"0",GIT_SSH_COMMAND:"ssh -o BatchMode=yes -o StrictHostKeyChecking=no"},12e4)}catch(t){n(`git-lfs objects left as pointers (fetch failed): ${t instanceof Error?t.message:String(t)}`)}await t(["-C",a,"remote","set-url","origin",r])}async function P(t,e,r){if(!t.claimNextCreateJob||!t.completeCreateJob)return null;let a=await t.claimNextCreateJob(r);if(!a)return null;try{let{boxId:r,agentStartError:s}=await e(a.request,a.id);s?await t.completeCreateJob(a.id,"failed",{boxId:r,error:s}):await t.completeCreateJob(a.id,"done",{boxId:r})}catch(e){await t.completeCreateJob(a.id,"failed",{error:e instanceof Error?e.message:String(e)})}return a.id}async function _(t,e,r,a=10){let s=0;for(;s<a&&await P(t,e,r);)s++;return s}function $(t,e=200){return{status:e,body:t}}function k(t,e){return{status:t,body:{error:e}}}function C(t){if(0===t.length)return{};try{return JSON.parse(t)}catch{return null}}var B=new Set(["git.push","git.fetch","cp.toHost","cp.fromHost","download.workspace","download.env","download.config","download.claude","checkpoint.create"]);async function L(t,e){var r,n;let o,i,{store:d,leaser:l}=e,u=e.log??(()=>{});if(0===e.adminToken.length)return k(503,"control plane not configured: admin token unset");if("GET"===t.method&&"/healthz"===t.path)return $({ok:!0,boxes:await d.countBoxes(),events:await d.countEvents(),controlPlane:!0});if((t.path.startsWith("/admin/")||t.path.startsWith("/remote/"))&&(r=t.bearer,n=e.adminToken,o=Buffer.from(r,"utf8"),i=Buffer.from(n,"utf8"),!(o.length===i.length&&(0,s.timingSafeEqual)(o,i))))return k(401,"invalid admin token");let c={custody:e.custody,adminToken:e.adminToken,log:u},p=await (0,a.handleCustodyRequest)(t,c);if(p)return void 0===p.body?{status:p.status}:$(p.body,p.status);if("POST"===t.method&&"/events"===t.path){let e=await d.authenticateBox(t.bearer);if(!e)return k(401,"unknown box token");let r=C(t.bodyText);if(!r||"string"!=typeof r.type||0===r.type.length)return k(400,'missing "type" string');if("box-status"===r.type)return(0,a.isValidBoxStatus)(r.payload)?(await d.setStatus(e.boxId,e.name,e.projectIndex,r.payload),$({ok:!0},202)):k(400,"invalid box-status payload");let s=await d.appendEvent({boxId:e.boxId,type:r.type,ts:"string"==typeof r.ts?r.ts:void 0,payload:r.payload});return $({id:s.id},202)}if("POST"===t.method&&"/rpc"===t.path){let r=await d.authenticateBox(t.bearer);if(!r)return k(401,"unknown box token");let a=C(t.bodyText);return a&&"string"==typeof a.method&&0!==a.method.length?(u(`rpc box=${r.boxId} method=${a.method}`),O(r,a.method,a.params,e)):k(400,'missing "method" string')}if("GET"===t.method&&t.path.startsWith("/rpc/status/")){let e=await d.authenticateBox(t.bearer);if(!e)return k(401,"unknown box token");let r=decodeURIComponent(t.path.slice(12)),a=await d.getPrompt(r);if(!a||a.boxId!==e.boxId)return k(404,"no such prompt");if("pending"===a.status)return $({status:"pending"});if("y"!==a.answer||a.cancelled)return $({status:"done",result:{exitCode:10,stdout:"",stderr:"denied by user\n"}});let s=a.result,n=s??await R(e,a.method,l);return s||await d.setPromptResult(r,n),$({status:"done",result:n})}if("POST"===t.method&&"/admin/register-box"===t.path){let e=C(t.bodyText);if(!e||!e.boxId||!e.token||"string"!=typeof e.name)return k(400,"expected {boxId, token, name}");let r={boxId:e.boxId,token:e.token,name:e.name,kind:"cloud"===e.kind?"cloud":"docker",backend:e.backend||void 0,sandboxId:e.sandboxId||void 0,registeredAt:new Date().toISOString(),containerName:e.containerName||void 0,createdAt:e.createdAt||void 0,projectIndex:"number"==typeof e.projectIndex&&e.projectIndex>0?Math.trunc(e.projectIndex):void 0,worktrees:Array.isArray(e.worktrees)?e.worktrees:void 0,previewUrl:e.previewUrl||void 0,previewToken:e.previewToken||void 0,bridgeToken:e.bridgeToken||void 0,autoApproveHostActions:!0===e.autoApproveHostActions,autoApproveSafeHostActions:!1!==e.autoApproveSafeHostActions,originUrl:e.originUrl||void 0};return await d.registerBox(r),u(`registered ${r.kind??"docker"} box ${r.boxId} (${r.name})`),$(null,204)}if("POST"===t.method&&"/admin/forget-box"===t.path){let e=C(t.bodyText);return e?.boxId?(await d.forgetBox(e.boxId),await d.deleteStatus(e.boxId),$(null,204)):k(400,"expected {boxId}")}if("GET"===t.method&&"/admin/box-status"===t.path){let e=t.query.get("box")??"",r=e?await d.getStatus(e):void 0;return r?$(r):k(404,"no status for box")}if("GET"===t.method&&"/admin/events"===t.path){let e=Number.parseInt(t.query.get("since")??"0",10)||0,r=t.query.get("box")??void 0;return $({events:await d.listEvents(e,r??void 0)})}if("GET"===t.method&&"/admin/app/repo-installed"===t.path){if(!l)return k(503,"no GitHub App configured on this control plane");let e=t.query.get("owner")??"",r=t.query.get("repo")??"";if(!e||!r)return k(400,"missing owner/repo query params");try{return $({installed:await l.isRepoInstalled(e,r)})}catch(t){return k(502,`installation check failed: ${t instanceof Error?t.message:String(t)}`)}}if("GET"===t.method&&"/admin/registry"===t.path){let t=(await d.listBoxes()).map(t=>({boxId:t.boxId,name:t.name,kind:t.kind,registeredAt:t.registeredAt,projectIndex:t.projectIndex,originUrl:t.originUrl}));return $({boxes:t})}if("GET"===t.method&&"/admin/prompts"===t.path){let e=t.query.get("boxId")??"";if(0===e.length)return k(400,"missing boxId query param");let r=(await d.listPendingPrompts(e)).map(t=>t.ev);return $({prompts:r})}if("POST"===t.method&&"/admin/prompts/answer"===t.path){let e=C(t.bodyText);return e?.id&&("y"===e.answer||"n"===e.answer)?await d.answerPrompt(e.id,e.answer,e.cancelled)?$(null,204):k(404,"no pending prompt with that id"):k(400,'expected {id, answer:"y"|"n", cancelled?}')}let h=await (0,a.handleStoreRpcRequest)(t,{store:d,adminToken:e.adminToken,log:u});if(h)return void 0===h.body?{status:h.status}:$(h.body,h.status);let m=await (0,a.handleRemoteBoxesRequest)(t,{store:d,adminToken:e.adminToken,createProviders:e.createProviders,custody:e.custody,log:u});return m?void 0===m.body?{status:m.status}:$(m.body,m.status):k(404,"not found")}async function O(t,e,r,s){if("git.lease-token"===e){let o=(0,a.resolveWorktree)(t,r?.path??"/workspace");if(!(0,n.isScratchBranch)(o?.branch)){let n=await (0,a.gateApproval)({mode:"poll",store:s.store},t.boxId,e,r,{kind:"confirm",message:`Allow box ${t.name} to lease a push token for ${t.originUrl??"its repo"}?`,detail:`branch ${o?.branch??"(unregistered)"}`,defaultAnswer:"n",context:{command:"git lease-token",cwd:r?.path}});if("pending"===n.kind)return $({status:"pending",promptId:n.promptId},202);if("deny"===n.kind)return $({exitCode:10,stdout:"",stderr:"denied by user\n"},500)}let i=await (0,a.leaseTokenResult)(s.leaser,t);return $(i,0===i.exitCode?200:500)}return"browser.open"===e?("string"==typeof r?.url&&await s.store.appendEvent({boxId:t.boxId,type:"browser-open",payload:{url:r.url}}),$({exitCode:0,stdout:"",stderr:""})):B.has(e)?$({exitCode:64,stdout:"",stderr:`${e}: not available on the hosted control plane (no host). Cloud boxes push via git.lease-token.
6
6
  `},501):$({error:"rpc method not implemented",method:e},501)}async function R(t,e,r){return"git.lease-token"===e?(0,a.leaseTokenResult)(r,t):{exitCode:64,stdout:"",stderr:`relay: no approved-action executor for ${e}
7
7
  `}}var U=o.pgTable("boxes",{boxId:i.text("box_id").primaryKey(),token:i.text("token").notNull(),originUrl:i.text("origin_url"),data:d.jsonb("data").$type().notNull(),registeredAt:l.timestamp("registered_at",{withTimezone:!0}).notNull()}),q=o.pgTable("events",{id:u.bigint("id",{mode:"number"}).generatedAlwaysAsIdentity().primaryKey(),boxId:i.text("box_id").notNull(),type:i.text("type").notNull(),ts:i.text("ts"),payload:d.jsonb("payload"),receivedAt:l.timestamp("received_at",{withTimezone:!0}).notNull()}),j=o.pgTable("box_status",{boxId:i.text("box_id").primaryKey(),name:i.text("name"),projectIndex:c.integer("project_index"),status:d.jsonb("status").$type().notNull(),updatedAt:l.timestamp("updated_at",{withTimezone:!0}).notNull()}),D=o.pgTable("prompts",{id:i.text("id").primaryKey(),boxId:i.text("box_id").notNull(),ev:d.jsonb("ev").$type().notNull(),method:i.text("method").notNull(),params:d.jsonb("params"),status:i.text("status").$type().notNull(),answer:i.text("answer").$type(),cancelled:p.boolean("cancelled"),result:d.jsonb("result").$type(),createdAt:l.timestamp("created_at",{withTimezone:!0}).notNull(),expiresAt:l.timestamp("expires_at",{withTimezone:!0})}),J=o.pgTable("create_jobs",{id:i.text("id").primaryKey(),status:i.text("status").$type().notNull(),request:d.jsonb("request").$type().notNull(),result:d.jsonb("result").$type(),claimedBy:i.text("claimed_by"),createdAt:l.timestamp("created_at",{withTimezone:!0}).notNull(),startedAt:l.timestamp("started_at",{withTimezone:!0}),finishedAt:l.timestamp("finished_at",{withTimezone:!0})}),z=`
8
8
  CREATE TABLE IF NOT EXISTS boxes (
@@ -112,6 +112,6 @@ CREATE TABLE IF NOT EXISTS create_jobs (
112
112
  finished_at text
113
113
  );
114
114
  CREATE INDEX IF NOT EXISTS create_jobs_status_idx ON create_jobs (status, created_at);
115
- `;function W(t){return t instanceof Date?t.toISOString():new Date(t).toISOString()}function K(t){return null===t?void 0:W(t)}function V(t){return{id:Number(t.id),boxId:t.boxId,type:t.type,ts:t.ts??void 0,payload:t.payload??void 0,receivedAt:W(t.receivedAt)}}function Q(t){return{id:t.id,boxId:t.boxId,ev:t.ev,method:t.method,params:t.params??void 0,status:t.status,answer:t.answer??void 0,cancelled:t.cancelled??void 0,result:t.result??void 0,createdAt:W(t.createdAt),expiresAt:K(t.expiresAt)}}function Z(t){return{id:t.id,status:t.status,request:t.request,result:t.result??void 0,claimedBy:t.claimedBy??void 0,createdAt:W(t.createdAt),startedAt:K(t.startedAt),finishedAt:K(t.finishedAt)}}var tt=a.RELAY_EVENT_RING_SIZE,te=class{eventCap;connectionString;injectedPool;poolPromise=null;dbPromise=null;constructor(t={}){this.connectionString=t.connectionString,this.injectedPool=t.pool,this.eventCap=t.eventCap??tt}pool(){return this.injectedPool?Promise.resolve(this.injectedPool):(this.poolPromise??=t.A(6194).then(({default:t})=>new t.Pool({connectionString:this.connectionString})),this.poolPromise)}db(){return this.dbPromise??=(async()=>{let e=await this.pool(),{drizzle:r}=await t.A(14788);return r(e)})(),this.dbPromise}async migrate(){let t=await this.pool();await t.query(z)}async close(){if(!this.injectedPool&&this.poolPromise){let t=await this.poolPromise;await t.end(),this.poolPromise=null,this.dbPromise=null}}async registerBox(t){let e=await this.db();await e.insert(U).values({boxId:t.boxId,token:t.token,originUrl:t.originUrl??null,data:t,registeredAt:new Date(t.registeredAt)}).onConflictDoUpdate({target:U.boxId,set:{token:t.token,originUrl:t.originUrl??null,data:t}})}async getBox(t){let e=await this.db(),r=await e.select({data:U.data}).from(U).where((0,y.eq)(U.boxId,t));return r[0]?.data}async authenticateBox(t){if(0===t.length)return null;let e=await this.db(),r=await e.select({data:U.data}).from(U).where((0,y.eq)(U.token,t)).limit(1);return r[0]?.data??null}async listBoxes(){let t=await this.db();return(await t.select({data:U.data}).from(U).orderBy((0,x.asc)(U.registeredAt))).map(t=>t.data)}async forgetBox(t){let e=await this.db();return(await e.delete(U).where((0,y.eq)(U.boxId,t)).returning({boxId:U.boxId})).length>0}async countBoxes(){return(await this.db()).$count(U)}async appendEvent(t){let e=await this.db(),r=(await e.insert(q).values({boxId:t.boxId,type:t.type,ts:t.ts??null,payload:t.payload??null,receivedAt:new Date}).returning({id:q.id,receivedAt:q.receivedAt}))[0];return this.eventCap>0&&await e.delete(q).where((0,y.lte)(q.id,r.id-this.eventCap)),{id:r.id,boxId:t.boxId,type:t.type,ts:t.ts,payload:t.payload,receivedAt:r.receivedAt.toISOString()}}async listEvents(t,e){let r=await this.db(),a=void 0===e?(0,y.gt)(q.id,t):(0,y.and)((0,y.gt)(q.id,t),(0,y.eq)(q.boxId,e));return(await r.select().from(q).where(a).orderBy((0,x.asc)(q.id))).map(V)}async countEvents(){return(await this.db()).$count(q)}async setStatus(t,e,r,a){let s=await this.db(),n=new Date;await s.insert(j).values({boxId:t,name:e,projectIndex:r??null,status:a,updatedAt:n}).onConflictDoUpdate({target:j.boxId,set:{name:e,projectIndex:r??null,status:a,updatedAt:n}})}async getStatus(t){let e=await this.db(),r=await e.select({status:j.status}).from(j).where((0,y.eq)(j.boxId,t));return r[0]?.status}async deleteStatus(t){let e=await this.db();await e.delete(j).where((0,y.eq)(j.boxId,t))}async listStatuses(){return(await this.db()).select({boxId:j.boxId,status:j.status}).from(j)}async createPrompt(t){let e=await this.db();await e.insert(D).values({id:t.id,boxId:t.boxId,ev:t.ev,method:t.method,params:t.params??null,status:t.status,answer:t.answer??null,cancelled:t.cancelled??null,result:t.result??null,createdAt:new Date(t.createdAt),expiresAt:t.expiresAt?new Date(t.expiresAt):null}).onConflictDoNothing({target:D.id})}async getPrompt(t){let e=await this.db(),r=await e.select().from(D).where((0,y.eq)(D.id,t));return r[0]?Q(r[0]):null}async answerPrompt(t,e,r){let a=await this.db();return(await a.update(D).set({status:"answered",answer:e,cancelled:r??null}).where((0,y.and)((0,y.eq)(D.id,t),(0,y.eq)(D.status,"pending"))).returning({id:D.id})).length>0}async listPendingPrompts(t){let e=await this.db();return(await e.select().from(D).where((0,y.and)((0,y.eq)(D.boxId,t),(0,y.eq)(D.status,"pending"))).orderBy((0,x.asc)(D.createdAt))).map(Q)}async setPromptResult(t,e){let r=await this.db();await r.update(D).set({result:e}).where((0,y.eq)(D.id,t))}async enqueueCreateJob(t){let e=await this.db();await e.insert(J).values({id:t.id,status:t.status,request:t.request,result:t.result??null,claimedBy:t.claimedBy??null,createdAt:new Date(t.createdAt),startedAt:t.startedAt?new Date(t.startedAt):null,finishedAt:t.finishedAt?new Date(t.finishedAt):null}).onConflictDoNothing({target:J.id})}async getCreateJob(t){let e=await this.db(),r=await e.select().from(J).where((0,y.eq)(J.id,t));return r[0]?Z(r[0]):null}async listCreateJobs(t){let e=(await this.db()).select().from(J),r=t?.status?.length?e.where((0,y.inArray)(J.status,t.status)):e;return(await r.orderBy((0,x.desc)(J.createdAt)).limit(t?.limit??100)).map(Z)}async claimNextCreateJob(t){let e=await this.db(),r=e.select({id:J.id}).from(J).where((0,y.eq)(J.status,"queued")).orderBy((0,x.asc)(J.createdAt)).limit(1).for("update",{skipLocked:!0}),a=await e.update(J).set({status:"running",claimedBy:t,startedAt:new Date}).where((0,y.inArray)(J.id,r)).returning();return a[0]?Z(a[0]):null}async completeCreateJob(t,e,r){let a=await this.db();await a.update(J).set({status:e,result:r,finishedAt:new Date}).where((0,y.eq)(J.id,t))}async prunePrompts(t){let e=await this.db(),r=new Date(t);return(await e.delete(D).where((0,y.or)((0,y.and)((0,y.eq)(D.status,"answered"),(0,y.lt)(D.createdAt,r)),(0,y.and)((0,y.isNotNull)(D.expiresAt),(0,y.lt)(D.expiresAt,r)))).returning({id:D.id})).length}async pruneCreateJobs(t){let e=await this.db(),r=new Date(t);return(await e.delete(J).where((0,y.and)((0,y.inArray)(J.status,["done","failed"]),(0,y.isNotNull)(J.finishedAt),(0,y.lt)(J.finishedAt,r))).returning({id:J.id})).length}},tr=a.RELAY_EVENT_RING_SIZE,ta=(0,v.join)(S.STATE_DIR,"hub","store.db"),ts=class{path;eventCap;raw=null;dbPromise=null;constructor(t={}){this.path=t.path??ta,this.eventCap=t.eventCap??tr}db(){return this.dbPromise??=(async()=>{!function(){let[t=0,e=0]=process.versions.node.split(".").map(Number);if(!(t>22||22===t&&e>=5))throw Error(`the SQLite store needs Node >= 22.5 for node:sqlite (running ${process.versions.node}). Upgrade Node, or point the hub at a Postgres store (POSTGRES_URL).`)}();let{DatabaseSync:e}=function(){(0,f.createRequire)(ti.url);let t=Error("Cannot find module 'node:sqlite': Unsupported external type Url for commonjs reference");throw t.code="MODULE_NOT_FOUND",t}(),{drizzle:r}=await t.A(86115);":memory:"!==this.path&&(0,w.mkdirSync)((0,v.dirname)(this.path),{recursive:!0});let a=new e(this.path);return a.exec("PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 5000;"),a.exec(Y),this.raw=a,r(async(t,e,r)=>{let s,n=a.prepare(t);return"run"===r?(n.run(...e),{rows:[]}):("function"==typeof n.setReturnArrays?(n.setReturnArrays(!0),s=n.all(...e)):s=n.all(...e).map(t=>Object.values(t)),"get"===r?{rows:s[0]??[]}:{rows:s})})})(),this.dbPromise}async migrate(){await this.db()}async close(){this.dbPromise&&await this.dbPromise.catch(()=>void 0),this.raw?.close(),this.raw=null,this.dbPromise=null}async registerBox(t){let e=await this.db();await e.insert(M).values({boxId:t.boxId,token:t.token,originUrl:t.originUrl??null,data:t,registeredAt:t.registeredAt}).onConflictDoUpdate({target:M.boxId,set:{token:t.token,originUrl:t.originUrl??null,data:t}})}async getBox(t){let e=await this.db(),r=await e.select({data:M.data}).from(M).where((0,y.eq)(M.boxId,t));return r[0]?.data}async authenticateBox(t){if(0===t.length)return null;let e=await this.db(),r=await e.select({data:M.data}).from(M).where((0,y.eq)(M.token,t)).limit(1);return r[0]?.data??null}async listBoxes(){let t=await this.db();return(await t.select({data:M.data}).from(M).orderBy((0,x.asc)(M.registeredAt))).map(t=>t.data)}async forgetBox(t){let e=await this.db();return(await e.delete(M).where((0,y.eq)(M.boxId,t)).returning({boxId:M.boxId})).length>0}async countBoxes(){return(await this.db()).$count(M)}async appendEvent(t){let e=await this.db(),r=new Date().toISOString(),a=(await e.insert(F).values({boxId:t.boxId,type:t.type,ts:t.ts??null,payload:t.payload??null,receivedAt:r}).returning({id:F.id}))[0].id;return this.eventCap>0&&await e.delete(F).where((0,y.lte)(F.id,a-this.eventCap)),{id:a,boxId:t.boxId,type:t.type,ts:t.ts,payload:t.payload,receivedAt:r}}async listEvents(t,e){let r=await this.db(),a=void 0===e?(0,y.gt)(F.id,t):(0,y.and)((0,y.gt)(F.id,t),(0,y.eq)(F.boxId,e));return(await r.select().from(F).where(a).orderBy((0,x.asc)(F.id))).map(V)}async countEvents(){return(await this.db()).$count(F)}async setStatus(t,e,r,a){let s=await this.db(),n=new Date().toISOString();await s.insert(G).values({boxId:t,name:e,projectIndex:r??null,status:a,updatedAt:n}).onConflictDoUpdate({target:G.boxId,set:{name:e,projectIndex:r??null,status:a,updatedAt:n}})}async getStatus(t){let e=await this.db(),r=await e.select({status:G.status}).from(G).where((0,y.eq)(G.boxId,t));return r[0]?.status}async deleteStatus(t){let e=await this.db();await e.delete(G).where((0,y.eq)(G.boxId,t))}async listStatuses(){return(await this.db()).select({boxId:G.boxId,status:G.status}).from(G)}async createPrompt(t){let e=await this.db();await e.insert(H).values({id:t.id,boxId:t.boxId,ev:t.ev,method:t.method,params:t.params??null,status:t.status,answer:t.answer??null,cancelled:t.cancelled??null,result:t.result??null,createdAt:t.createdAt,expiresAt:t.expiresAt??null}).onConflictDoNothing({target:H.id})}async getPrompt(t){let e=await this.db(),r=await e.select().from(H).where((0,y.eq)(H.id,t));return r[0]?Q(r[0]):null}async answerPrompt(t,e,r){let a=await this.db();return(await a.update(H).set({status:"answered",answer:e,cancelled:r??null}).where((0,y.and)((0,y.eq)(H.id,t),(0,y.eq)(H.status,"pending"))).returning({id:H.id})).length>0}async listPendingPrompts(t){let e=await this.db();return(await e.select().from(H).where((0,y.and)((0,y.eq)(H.boxId,t),(0,y.eq)(H.status,"pending"))).orderBy((0,x.asc)(H.createdAt))).map(Q)}async setPromptResult(t,e){let r=await this.db();await r.update(H).set({result:e}).where((0,y.eq)(H.id,t))}async enqueueCreateJob(t){let e=await this.db();await e.insert(X).values({id:t.id,status:t.status,request:t.request,result:t.result??null,claimedBy:t.claimedBy??null,createdAt:t.createdAt,startedAt:t.startedAt??null,finishedAt:t.finishedAt??null}).onConflictDoNothing({target:X.id})}async getCreateJob(t){let e=await this.db(),r=await e.select().from(X).where((0,y.eq)(X.id,t));return r[0]?Z(r[0]):null}async listCreateJobs(t){let e=(await this.db()).select().from(X),r=t?.status?.length?e.where((0,y.inArray)(X.status,t.status)):e;return(await r.orderBy((0,x.desc)(X.createdAt)).limit(t?.limit??100)).map(Z)}async claimNextCreateJob(t){let e=await this.db(),r=e.select({id:X.id}).from(X).where((0,y.eq)(X.status,"queued")).orderBy((0,x.asc)(X.createdAt)).limit(1),a=await e.update(X).set({status:"running",claimedBy:t,startedAt:new Date().toISOString()}).where((0,y.and)((0,y.inArray)(X.id,r),(0,y.eq)(X.status,"queued"))).returning();return a[0]?Z(a[0]):null}async completeCreateJob(t,e,r){let a=await this.db();await a.update(X).set({status:e,result:r,finishedAt:new Date().toISOString()}).where((0,y.eq)(X.id,t))}async prunePrompts(t){let e=await this.db();return(await e.delete(H).where((0,y.or)((0,y.and)((0,y.eq)(H.status,"answered"),(0,y.lt)(H.createdAt,t)),(0,y.and)((0,y.isNotNull)(H.expiresAt),(0,y.lt)(H.expiresAt,t)))).returning({id:H.id})).length}async pruneCreateJobs(t){let e=await this.db();return(await e.delete(X).where((0,y.and)((0,y.inArray)(X.status,["done","failed"]),(0,y.isNotNull)(X.finishedAt),(0,y.lt)(X.finishedAt,t))).returning({id:X.id})).length}},tn=(0,v.join)(S.STATE_DIR,"hub","custody"),to=class{root;constructor(t={}){this.root=t.root??tn}async put(t,e){let r=(0,a.normalizeCustodyPath)(t),n=(0,v.join)(this.root,r),o=(0,a.custodyDigest)(e),i=await this.readEntry(r);if(i&&i.entry.sha256===o)return{...i.entry,changed:!1};await (0,A.mkdir)((0,v.dirname)(n),{recursive:!0,mode:448});let d=`${n}.${(0,s.randomBytes)(6).toString("hex")}.tmp`;try{await (0,A.writeFile)(d,e,{mode:384}),await (0,A.chmod)(d,384),await (0,A.rename)(d,n)}catch(t){throw await (0,A.rm)(d,{force:!0}),t}let l=await (0,A.stat)(n);return{path:r,size:e.length,sha256:o,mode:511&l.mode,updatedAt:l.mtime.toISOString(),changed:!0}}async get(t){return this.readEntry((0,a.normalizeCustodyPath)(t))}async stat(t){let e=await this.readEntry((0,a.normalizeCustodyPath)(t));return e?e.entry:null}async list(t){let e=void 0===t?"":(0,a.normalizeCustodyPrefix)(t),r=[];for(let t of(await this.walk(this.root))){if(e.length>0&&t!==e&&!t.startsWith(`${e}/`))continue;let a=await this.readEntry(t);a&&r.push(a.entry)}return r.sort((t,e)=>t.path<e.path?-1:+(t.path>e.path)),r}async delete(t){let e=(0,a.normalizeCustodyPath)(t),r=(0,v.join)(this.root,e);try{return await (0,A.rm)(r),!0}catch(t){if("ENOENT"===t.code)return!1;throw t}}async putStream(t,e,r={}){let n=(0,a.normalizeCustodyPath)(t),o=(0,v.join)(this.root,n);await (0,A.mkdir)((0,v.dirname)(o),{recursive:!0,mode:448});let i=`${o}.${(0,s.randomBytes)(6).toString("hex")}.tmp`,d=(0,s.createHash)("sha256"),l=0,u=new E.Transform({transform(t,e,s){(l+=t.length,void 0!==r.maxBytes&&l>r.maxBytes)?s(new a.CustodyTooLargeError(r.maxBytes)):(d.update(t),s(null,t))}});try{await (0,I.pipeline)(e,u,(0,w.createWriteStream)(i,{mode:384}))}catch(t){throw await (0,A.rm)(i,{force:!0}),t}let c=d.digest("hex"),p=await this.readEntryMeta(n);if(p&&p.sha256===c)return await (0,A.rm)(i,{force:!0}),{...p,changed:!1};try{await (0,A.chmod)(i,384),await (0,A.rename)(i,o)}catch(t){throw await (0,A.rm)(i,{force:!0}),t}let h=await (0,A.stat)(o);return{path:n,size:l,sha256:c,mode:511&h.mode,updatedAt:h.mtime.toISOString(),changed:!0}}async getStream(t){let e=(0,a.normalizeCustodyPath)(t),r=await this.readEntryMeta(e);return r?{entry:r,data:(0,w.createReadStream)((0,v.join)(this.root,e))}:null}async readEntryMeta(t){let e=(0,v.join)(this.root,t);try{let r=await (0,A.stat)(e);if(!r.isFile())return null;let a=(0,s.createHash)("sha256");return await (0,I.pipeline)((0,w.createReadStream)(e),new E.Transform({transform(t,e,r){a.update(t),r()}})),{path:t,size:r.size,sha256:a.digest("hex"),mode:511&r.mode,updatedAt:r.mtime.toISOString()}}catch(t){if("ENOENT"===t.code)return null;throw t}}async readEntry(t){let e=(0,v.join)(this.root,t);try{let[r,s]=await Promise.all([(0,A.readFile)(e),(0,A.stat)(e)]);return{entry:{path:t,size:r.length,sha256:(0,a.custodyDigest)(r),mode:511&s.mode,updatedAt:s.mtime.toISOString()},data:r}}catch(e){let t=e.code;if("ENOENT"===t||"EISDIR"===t)return null;throw e}}async walk(t){let e;try{e=await (0,A.readdir)(t,{withFileTypes:!0})}catch(t){if("ENOENT"===t.code)return[];throw t}let r=[];for(let a of e){let e=(0,v.join)(t,a.name);a.isDirectory()?r.push(...await this.walk(e)):a.isFile()&&!a.name.endsWith(".tmp")&&r.push((0,v.relative)(this.root,e).split(v.sep).join("/"))}return r}};t.s(["DEFAULT_CUSTODY_DIR",0,tn,"DEFAULT_SQLITE_STORE_PATH",0,ta,"FsCustodyStore",0,to,"PG_SCHEMA_SQL",0,z,"PostgresStore",0,te,"SQLITE_SCHEMA_SQL",0,Y,"SqliteStore",0,ts,"cloneRepoWithLfs",0,N,"drainCreateJobs",0,_,"drainOneCreateJob",0,P,"handleRelayRequest",0,L,"makeControlPlaneCreateBox",0,function(t){return async(e,r)=>{let a=t.logFor?.(r)??t.log??(()=>{}),s=t.tmpDir(r);try{let r;a(`leasing a push token for ${e.repoUrl}`);let n=await t.leaseRemoteUrl(e.repoUrl);if(a(`cloning ${e.repoUrl}${e.branch?`@${e.branch}`:""} into ${s}`),await t.cloneRepo(n,e.repoUrl,s,e.branch),t.fetchSeedMaterial)try{let n=await t.fetchSeedMaterial(e.repoUrl,s);if(r=n?.carry?.length?n.carry:void 0,n&&n.files>0){let t=[n.repoHeadSha?`at ${n.repoHeadSha.slice(0,8)}`:null,n.capturedAt?`captured ${n.capturedAt}`:null].filter(Boolean).join(", ");a(`applied ${String(n.files)} seed file(s) from custody${t?` (${t})`:""}`)}}catch(e){if(e instanceof Error&&"CarrySeedError"===e.name)throw e;let t=e instanceof Error?e.message:String(e);a(`seed material unavailable (continuing with a bare clone): ${t}`)}a(`provisioning ${e.provider} box from the clone`);let o=await t.createBox({workspacePath:s,name:e.name,repoUrl:e.repoUrl,provider:e.provider,...r?{carry:r}:{},agent:e.agent,prompt:e.prompt,agentArgs:e.agentArgs,startAgent:e.startAgent,opts:e.opts,onLog:a});return a(`created box ${o.id}`),{boxId:o.id,agentStartError:o.agentStartError}}finally{await t.cleanup(s)}}},"makeStore",0,function(t){if(!t||"memory"===t)return new a.MemoryStore;if(t.startsWith("postgres://")||t.startsWith("postgresql://"))return new te({connectionString:t});if(t.startsWith("sqlite:")){let e=t.slice(7).replace(/^\/\//,"");if(!e)throw Error(`store spec has no path: ${t}`);return new ts({path:e})}if(":memory:"===t||t.startsWith("/")||t.startsWith(".")||t.endsWith(".db"))return new ts({path:t});throw Error(`unknown store spec: ${t}`)}]),r()}catch(t){r(t)}},!1),7876,t=>t.a(async(e,r)=>{try{var a=t.i(92436),s=t.i(71326),n=e([a,s]);[a,s]=n.then?(await n)():n,t.s([]),r()}catch(t){r(t)}},!1)];
115
+ `;function W(t){return t instanceof Date?t.toISOString():new Date(t).toISOString()}function K(t){return null===t?void 0:W(t)}function V(t){return{id:Number(t.id),boxId:t.boxId,type:t.type,ts:t.ts??void 0,payload:t.payload??void 0,receivedAt:W(t.receivedAt)}}function Q(t){return{id:t.id,boxId:t.boxId,ev:t.ev,method:t.method,params:t.params??void 0,status:t.status,answer:t.answer??void 0,cancelled:t.cancelled??void 0,result:t.result??void 0,createdAt:W(t.createdAt),expiresAt:K(t.expiresAt)}}function Z(t){return{id:t.id,status:t.status,request:t.request,result:t.result??void 0,claimedBy:t.claimedBy??void 0,createdAt:W(t.createdAt),startedAt:K(t.startedAt),finishedAt:K(t.finishedAt)}}var tt=a.RELAY_EVENT_RING_SIZE,te=class{eventCap;connectionString;injectedPool;poolPromise=null;dbPromise=null;constructor(t={}){this.connectionString=t.connectionString,this.injectedPool=t.pool,this.eventCap=t.eventCap??tt}pool(){return this.injectedPool?Promise.resolve(this.injectedPool):(this.poolPromise??=t.A(6194).then(({default:t})=>new t.Pool({connectionString:this.connectionString})),this.poolPromise)}db(){return this.dbPromise??=(async()=>{let e=await this.pool(),{drizzle:r}=await t.A(14788);return r(e)})(),this.dbPromise}async migrate(){let t=await this.pool();await t.query(z)}async close(){if(!this.injectedPool&&this.poolPromise){let t=await this.poolPromise;await t.end(),this.poolPromise=null,this.dbPromise=null}}async registerBox(t){let e=await this.db();await e.insert(U).values({boxId:t.boxId,token:t.token,originUrl:t.originUrl??null,data:t,registeredAt:new Date(t.registeredAt)}).onConflictDoUpdate({target:U.boxId,set:{token:t.token,originUrl:t.originUrl??null,data:t}})}async getBox(t){let e=await this.db(),r=await e.select({data:U.data}).from(U).where((0,y.eq)(U.boxId,t));return r[0]?.data}async authenticateBox(t){if(0===t.length)return null;let e=await this.db(),r=await e.select({data:U.data}).from(U).where((0,y.eq)(U.token,t)).limit(1);return r[0]?.data??null}async listBoxes(){let t=await this.db();return(await t.select({data:U.data}).from(U).orderBy((0,x.asc)(U.registeredAt))).map(t=>t.data)}async forgetBox(t){let e=await this.db();return(await e.delete(U).where((0,y.eq)(U.boxId,t)).returning({boxId:U.boxId})).length>0}async countBoxes(){return(await this.db()).$count(U)}async appendEvent(t){let e=await this.db(),r=(await e.insert(q).values({boxId:t.boxId,type:t.type,ts:t.ts??null,payload:t.payload??null,receivedAt:new Date}).returning({id:q.id,receivedAt:q.receivedAt}))[0];return this.eventCap>0&&await e.delete(q).where((0,y.lte)(q.id,r.id-this.eventCap)),{id:r.id,boxId:t.boxId,type:t.type,ts:t.ts,payload:t.payload,receivedAt:r.receivedAt.toISOString()}}async listEvents(t,e){let r=await this.db(),a=void 0===e?(0,y.gt)(q.id,t):(0,y.and)((0,y.gt)(q.id,t),(0,y.eq)(q.boxId,e));return(await r.select().from(q).where(a).orderBy((0,x.asc)(q.id))).map(V)}async countEvents(){return(await this.db()).$count(q)}async setStatus(t,e,r,a){let s=await this.db(),n=new Date;await s.insert(j).values({boxId:t,name:e,projectIndex:r??null,status:a,updatedAt:n}).onConflictDoUpdate({target:j.boxId,set:{name:e,projectIndex:r??null,status:a,updatedAt:n}})}async getStatus(t){let e=await this.db(),r=await e.select({status:j.status}).from(j).where((0,y.eq)(j.boxId,t));return r[0]?.status}async deleteStatus(t){let e=await this.db();await e.delete(j).where((0,y.eq)(j.boxId,t))}async listStatuses(){return(await this.db()).select({boxId:j.boxId,status:j.status}).from(j)}async createPrompt(t){let e=await this.db();await e.insert(D).values({id:t.id,boxId:t.boxId,ev:t.ev,method:t.method,params:t.params??null,status:t.status,answer:t.answer??null,cancelled:t.cancelled??null,result:t.result??null,createdAt:new Date(t.createdAt),expiresAt:t.expiresAt?new Date(t.expiresAt):null}).onConflictDoNothing({target:D.id})}async getPrompt(t){let e=await this.db(),r=await e.select().from(D).where((0,y.eq)(D.id,t));return r[0]?Q(r[0]):null}async answerPrompt(t,e,r){let a=await this.db();return(await a.update(D).set({status:"answered",answer:e,cancelled:r??null}).where((0,y.and)((0,y.eq)(D.id,t),(0,y.eq)(D.status,"pending"))).returning({id:D.id})).length>0}async listPendingPrompts(t){let e=await this.db();return(await e.select().from(D).where((0,y.and)((0,y.eq)(D.boxId,t),(0,y.eq)(D.status,"pending"))).orderBy((0,x.asc)(D.createdAt))).map(Q)}async setPromptResult(t,e){let r=await this.db();await r.update(D).set({result:e}).where((0,y.eq)(D.id,t))}async enqueueCreateJob(t){let e=await this.db();await e.insert(J).values({id:t.id,status:t.status,request:t.request,result:t.result??null,claimedBy:t.claimedBy??null,createdAt:new Date(t.createdAt),startedAt:t.startedAt?new Date(t.startedAt):null,finishedAt:t.finishedAt?new Date(t.finishedAt):null}).onConflictDoNothing({target:J.id})}async getCreateJob(t){let e=await this.db(),r=await e.select().from(J).where((0,y.eq)(J.id,t));return r[0]?Z(r[0]):null}async listCreateJobs(t){let e=(await this.db()).select().from(J),r=t?.status?.length?e.where((0,y.inArray)(J.status,t.status)):e;return(await r.orderBy((0,x.desc)(J.createdAt)).limit(t?.limit??100)).map(Z)}async claimNextCreateJob(t){let e=await this.db(),r=e.select({id:J.id}).from(J).where((0,y.eq)(J.status,"queued")).orderBy((0,x.asc)(J.createdAt)).limit(1).for("update",{skipLocked:!0}),a=await e.update(J).set({status:"running",claimedBy:t,startedAt:new Date}).where((0,y.inArray)(J.id,r)).returning();return a[0]?Z(a[0]):null}async completeCreateJob(t,e,r){let a=await this.db();await a.update(J).set({status:e,result:r,finishedAt:new Date}).where((0,y.eq)(J.id,t))}async prunePrompts(t){let e=await this.db(),r=new Date(t);return(await e.delete(D).where((0,y.or)((0,y.and)((0,y.eq)(D.status,"answered"),(0,y.lt)(D.createdAt,r)),(0,y.and)((0,y.isNotNull)(D.expiresAt),(0,y.lt)(D.expiresAt,r)))).returning({id:D.id})).length}async pruneCreateJobs(t){let e=await this.db(),r=new Date(t);return(await e.delete(J).where((0,y.and)((0,y.inArray)(J.status,["done","failed"]),(0,y.isNotNull)(J.finishedAt),(0,y.lt)(J.finishedAt,r))).returning({id:J.id})).length}},tr=a.RELAY_EVENT_RING_SIZE,ta=(0,v.join)(S.STATE_DIR,"hub","store.db"),ts=class{path;eventCap;raw=null;dbPromise=null;constructor(t={}){this.path=t.path??ta,this.eventCap=t.eventCap??tr}db(){return this.dbPromise??=(async()=>{!function(){let[t=0,e=0]=process.versions.node.split(".").map(Number);if(!(t>22||22===t&&e>=5))throw Error(`the SQLite store needs Node >= 22.5 for node:sqlite (running ${process.versions.node}). Upgrade Node, or point the hub at a Postgres store (POSTGRES_URL).`)}();let{DatabaseSync:e}=function(){(0,f.createRequire)(ti.url);let t=Error("Cannot find module 'node:sqlite': Unsupported external type Url for commonjs reference");throw t.code="MODULE_NOT_FOUND",t}(),{drizzle:r}=await t.A(86115);":memory:"!==this.path&&(0,w.mkdirSync)((0,v.dirname)(this.path),{recursive:!0});let a=new e(this.path);return a.exec("PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 5000;"),a.exec(Y),this.raw=a,r(async(t,e,r)=>{let s,n=a.prepare(t);return"run"===r?(n.run(...e),{rows:[]}):("function"==typeof n.setReturnArrays?(n.setReturnArrays(!0),s=n.all(...e)):s=n.all(...e).map(t=>Object.values(t)),"get"===r?{rows:s[0]??[]}:{rows:s})})})(),this.dbPromise}async migrate(){await this.db()}async close(){this.dbPromise&&await this.dbPromise.catch(()=>void 0),this.raw?.close(),this.raw=null,this.dbPromise=null}async registerBox(t){let e=await this.db();await e.insert(M).values({boxId:t.boxId,token:t.token,originUrl:t.originUrl??null,data:t,registeredAt:t.registeredAt}).onConflictDoUpdate({target:M.boxId,set:{token:t.token,originUrl:t.originUrl??null,data:t}})}async getBox(t){let e=await this.db(),r=await e.select({data:M.data}).from(M).where((0,y.eq)(M.boxId,t));return r[0]?.data}async authenticateBox(t){if(0===t.length)return null;let e=await this.db(),r=await e.select({data:M.data}).from(M).where((0,y.eq)(M.token,t)).limit(1);return r[0]?.data??null}async listBoxes(){let t=await this.db();return(await t.select({data:M.data}).from(M).orderBy((0,x.asc)(M.registeredAt))).map(t=>t.data)}async forgetBox(t){let e=await this.db();return(await e.delete(M).where((0,y.eq)(M.boxId,t)).returning({boxId:M.boxId})).length>0}async countBoxes(){return(await this.db()).$count(M)}async appendEvent(t){let e=await this.db(),r=new Date().toISOString(),a=(await e.insert(F).values({boxId:t.boxId,type:t.type,ts:t.ts??null,payload:t.payload??null,receivedAt:r}).returning({id:F.id}))[0].id;return this.eventCap>0&&await e.delete(F).where((0,y.lte)(F.id,a-this.eventCap)),{id:a,boxId:t.boxId,type:t.type,ts:t.ts,payload:t.payload,receivedAt:r}}async listEvents(t,e){let r=await this.db(),a=void 0===e?(0,y.gt)(F.id,t):(0,y.and)((0,y.gt)(F.id,t),(0,y.eq)(F.boxId,e));return(await r.select().from(F).where(a).orderBy((0,x.asc)(F.id))).map(V)}async countEvents(){return(await this.db()).$count(F)}async setStatus(t,e,r,a){let s=await this.db(),n=new Date().toISOString();await s.insert(G).values({boxId:t,name:e,projectIndex:r??null,status:a,updatedAt:n}).onConflictDoUpdate({target:G.boxId,set:{name:e,projectIndex:r??null,status:a,updatedAt:n}})}async getStatus(t){let e=await this.db(),r=await e.select({status:G.status}).from(G).where((0,y.eq)(G.boxId,t));return r[0]?.status}async deleteStatus(t){let e=await this.db();await e.delete(G).where((0,y.eq)(G.boxId,t))}async listStatuses(){return(await this.db()).select({boxId:G.boxId,status:G.status}).from(G)}async createPrompt(t){let e=await this.db();await e.insert(H).values({id:t.id,boxId:t.boxId,ev:t.ev,method:t.method,params:t.params??null,status:t.status,answer:t.answer??null,cancelled:t.cancelled??null,result:t.result??null,createdAt:t.createdAt,expiresAt:t.expiresAt??null}).onConflictDoNothing({target:H.id})}async getPrompt(t){let e=await this.db(),r=await e.select().from(H).where((0,y.eq)(H.id,t));return r[0]?Q(r[0]):null}async answerPrompt(t,e,r){let a=await this.db();return(await a.update(H).set({status:"answered",answer:e,cancelled:r??null}).where((0,y.and)((0,y.eq)(H.id,t),(0,y.eq)(H.status,"pending"))).returning({id:H.id})).length>0}async listPendingPrompts(t){let e=await this.db();return(await e.select().from(H).where((0,y.and)((0,y.eq)(H.boxId,t),(0,y.eq)(H.status,"pending"))).orderBy((0,x.asc)(H.createdAt))).map(Q)}async setPromptResult(t,e){let r=await this.db();await r.update(H).set({result:e}).where((0,y.eq)(H.id,t))}async enqueueCreateJob(t){let e=await this.db();await e.insert(X).values({id:t.id,status:t.status,request:t.request,result:t.result??null,claimedBy:t.claimedBy??null,createdAt:t.createdAt,startedAt:t.startedAt??null,finishedAt:t.finishedAt??null}).onConflictDoNothing({target:X.id})}async getCreateJob(t){let e=await this.db(),r=await e.select().from(X).where((0,y.eq)(X.id,t));return r[0]?Z(r[0]):null}async listCreateJobs(t){let e=(await this.db()).select().from(X),r=t?.status?.length?e.where((0,y.inArray)(X.status,t.status)):e;return(await r.orderBy((0,x.desc)(X.createdAt)).limit(t?.limit??100)).map(Z)}async claimNextCreateJob(t){let e=await this.db(),r=e.select({id:X.id}).from(X).where((0,y.eq)(X.status,"queued")).orderBy((0,x.asc)(X.createdAt)).limit(1),a=await e.update(X).set({status:"running",claimedBy:t,startedAt:new Date().toISOString()}).where((0,y.and)((0,y.inArray)(X.id,r),(0,y.eq)(X.status,"queued"))).returning();return a[0]?Z(a[0]):null}async completeCreateJob(t,e,r){let a=await this.db();await a.update(X).set({status:e,result:r,finishedAt:new Date().toISOString()}).where((0,y.eq)(X.id,t))}async prunePrompts(t){let e=await this.db();return(await e.delete(H).where((0,y.or)((0,y.and)((0,y.eq)(H.status,"answered"),(0,y.lt)(H.createdAt,t)),(0,y.and)((0,y.isNotNull)(H.expiresAt),(0,y.lt)(H.expiresAt,t)))).returning({id:H.id})).length}async pruneCreateJobs(t){let e=await this.db();return(await e.delete(X).where((0,y.and)((0,y.inArray)(X.status,["done","failed"]),(0,y.isNotNull)(X.finishedAt),(0,y.lt)(X.finishedAt,t))).returning({id:X.id})).length}},tn=(0,v.join)(S.STATE_DIR,"hub","custody"),to=class{root;constructor(t={}){this.root=t.root??tn}async put(t,e){let r=(0,a.normalizeCustodyPath)(t),n=(0,v.join)(this.root,r),o=(0,a.custodyDigest)(e),i=await this.readEntry(r);if(i&&i.entry.sha256===o)return{...i.entry,changed:!1};await (0,A.mkdir)((0,v.dirname)(n),{recursive:!0,mode:448});let d=`${n}.${(0,s.randomBytes)(6).toString("hex")}.tmp`;try{await (0,A.writeFile)(d,e,{mode:384}),await (0,A.chmod)(d,384),await (0,A.rename)(d,n)}catch(t){throw await (0,A.rm)(d,{force:!0}),t}let l=await (0,A.stat)(n);return{path:r,size:e.length,sha256:o,mode:511&l.mode,updatedAt:l.mtime.toISOString(),changed:!0}}async get(t){return this.readEntry((0,a.normalizeCustodyPath)(t))}async stat(t){let e=await this.readEntry((0,a.normalizeCustodyPath)(t));return e?e.entry:null}async list(t){let e=void 0===t?"":(0,a.normalizeCustodyPrefix)(t),r=[];for(let t of(await this.walk(this.root))){if(e.length>0&&t!==e&&!t.startsWith(`${e}/`))continue;let a=await this.readEntry(t);a&&r.push(a.entry)}return r.sort((t,e)=>t.path<e.path?-1:+(t.path>e.path)),r}async delete(t){let e=(0,a.normalizeCustodyPath)(t),r=(0,v.join)(this.root,e);try{return await (0,A.rm)(r),!0}catch(t){if("ENOENT"===t.code)return!1;throw t}}async putStream(t,e,r={}){let n=(0,a.normalizeCustodyPath)(t),o=(0,v.join)(this.root,n);await (0,A.mkdir)((0,v.dirname)(o),{recursive:!0,mode:448});let i=`${o}.${(0,s.randomBytes)(6).toString("hex")}.tmp`,d=(0,s.createHash)("sha256"),l=0,u=new E.Transform({transform(t,e,s){(l+=t.length,void 0!==r.maxBytes&&l>r.maxBytes)?s(new a.CustodyTooLargeError(r.maxBytes)):(d.update(t),s(null,t))}});try{await (0,I.pipeline)(e,u,(0,w.createWriteStream)(i,{mode:384}))}catch(t){throw await (0,A.rm)(i,{force:!0}),t}let c=d.digest("hex"),p=await this.readEntryMeta(n);if(p&&p.sha256===c)return await (0,A.rm)(i,{force:!0}),{...p,changed:!1};try{await (0,A.chmod)(i,384),await (0,A.rename)(i,o)}catch(t){throw await (0,A.rm)(i,{force:!0}),t}let h=await (0,A.stat)(o);return{path:n,size:l,sha256:c,mode:511&h.mode,updatedAt:h.mtime.toISOString(),changed:!0}}async getStream(t){let e=(0,a.normalizeCustodyPath)(t),r=await this.readEntryMeta(e);return r?{entry:r,data:(0,w.createReadStream)((0,v.join)(this.root,e))}:null}async readEntryMeta(t){let e=(0,v.join)(this.root,t);try{let r=await (0,A.stat)(e);if(!r.isFile())return null;let a=(0,s.createHash)("sha256");return await (0,I.pipeline)((0,w.createReadStream)(e),new E.Transform({transform(t,e,r){a.update(t),r()}})),{path:t,size:r.size,sha256:a.digest("hex"),mode:511&r.mode,updatedAt:r.mtime.toISOString()}}catch(t){if("ENOENT"===t.code)return null;throw t}}async readEntry(t){let e=(0,v.join)(this.root,t);try{let[r,s]=await Promise.all([(0,A.readFile)(e),(0,A.stat)(e)]);return{entry:{path:t,size:r.length,sha256:(0,a.custodyDigest)(r),mode:511&s.mode,updatedAt:s.mtime.toISOString()},data:r}}catch(e){let t=e.code;if("ENOENT"===t||"EISDIR"===t)return null;throw e}}async walk(t){let e;try{e=await (0,A.readdir)(t,{withFileTypes:!0})}catch(t){if("ENOENT"===t.code)return[];throw t}let r=[];for(let a of e){let e=(0,v.join)(t,a.name);a.isDirectory()?r.push(...await this.walk(e)):a.isFile()&&!a.name.endsWith(".tmp")&&r.push((0,v.relative)(this.root,e).split(v.sep).join("/"))}return r}};t.s(["DEFAULT_CUSTODY_DIR",0,tn,"DEFAULT_SQLITE_STORE_PATH",0,ta,"FsCustodyStore",0,to,"PG_SCHEMA_SQL",0,z,"PostgresStore",0,te,"SQLITE_SCHEMA_SQL",0,Y,"SqliteStore",0,ts,"cloneRepoWithLfs",0,N,"drainCreateJobs",0,_,"drainOneCreateJob",0,P,"handleRelayRequest",0,L,"makeControlPlaneCreateBox",0,function(t){return async(e,r)=>{let a=t.logFor?.(r)??t.log??(()=>{}),s=t.tmpDir(r);try{let r;a(`leasing a push token for ${e.repoUrl}`);let n=await t.leaseRemoteUrl(e.repoUrl);if(a(`cloning ${e.repoUrl}${e.branch?`@${e.branch}`:""} into ${s}`),await t.cloneRepo(n,e.repoUrl,s,e.branch),t.fetchSeedMaterial)try{let n=await t.fetchSeedMaterial(e.repoUrl,s);if(r=n?.carry?.length?n.carry:void 0,n&&n.files>0){let t=[n.repoHeadSha?`at ${n.repoHeadSha.slice(0,8)}`:null,n.capturedAt?`captured ${n.capturedAt}`:null].filter(Boolean).join(", ");a(`applied ${String(n.files)} seed file(s) from custody${t?` (${t})`:""}`)}}catch(e){if(e instanceof Error&&"CarrySeedError"===e.name)throw e;let t=e instanceof Error?e.message:String(e);a(`seed material unavailable (continuing with a bare clone): ${t}`)}a(`provisioning ${e.provider} box from the clone`);let o=await t.createBox({workspacePath:s,name:e.name,repoUrl:e.repoUrl,provider:e.provider,...r?{carry:r}:{},agent:e.agent,prompt:e.prompt,agentArgs:e.agentArgs,startAgent:e.startAgent,opts:e.opts,onLog:a});return a(`created box ${o.id}`),{boxId:o.id,agentStartError:o.agentStartError}}finally{await t.cleanup(s)}}},"makeStore",0,function(t){if(!t||"memory"===t)return new a.MemoryStore;if(t.startsWith("postgres://")||t.startsWith("postgresql://"))return new te({connectionString:t});if(t.startsWith("sqlite:")){let e=t.slice(7).replace(/^\/\//,"");if(!e)throw Error(`store spec has no path: ${t}`);return new ts({path:e})}if(":memory:"===t||t.startsWith("/")||t.startsWith(".")||t.endsWith(".db"))return new ts({path:t});throw Error(`unknown store spec: ${t}`)}]),r()}catch(t){r(t)}},!1),7876,t=>t.a(async(e,r)=>{try{var a=t.i(4418),s=t.i(25230),n=e([a,s]);[a,s]=n.then?(await n)():n,t.s([]),r()}catch(t){r(t)}},!1)];
116
116
 
117
- //# sourceMappingURL=packages_relay_dist_0eg7ay1._.js.map
117
+ //# sourceMappingURL=packages_relay_dist_0p8dnf4._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[54799,(a,b,c)=>{b.exports=a.x("crypto",()=>require("crypto"))},24868,(a,b,c)=>{b.exports=a.x("fs/promises",()=>require("fs/promises"))},46786,(a,b,c)=>{b.exports=a.x("os",()=>require("os"))},29220,(a,b,c)=>{b.exports=a.x("timers/promises",()=>require("timers/promises"))},5365,(a,b,c)=>{b.exports=a.x("process",()=>require("process"))},874,(a,b,c)=>{b.exports=a.x("buffer",()=>require("buffer"))},50227,(a,b,c)=>{b.exports=a.x("node:path",()=>require("node:path"))},8187,a=>{"use strict";a.s(["HubShell",()=>b]);let b=(0,a.i(71210).registerClientReference)(function(){throw Error("Attempted to call HubShell() from the server but HubShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/apps/hub/components/hub-shell.tsx <module evaluation>","HubShell")},65317,a=>{"use strict";a.s(["HubShell",()=>b]);let b=(0,a.i(71210).registerClientReference)(function(){throw Error("Attempted to call HubShell() from the server but HubShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/apps/hub/components/hub-shell.tsx","HubShell")},56045,a=>{"use strict";a.i(8187);var b=a.i(65317);a.n(b)},89754,a=>{"use strict";var b=a.i(14435),c=a.i(56045),d=a.i(50227),e=a.i(2876);function f(){let a;return"off"===process.env.AGENTBOX_HUB_AUTH?"off":"localhost"===("hetzner"===(a=process.env.AGENTBOX_HUB_PROFILE)||"vercel"===a?a:"localhost")?process.env.AGENTBOX_HUB_TOKEN?"token":"off":"off"!==process.env.AGENTBOX_HUB_AUTH&&("on"===process.env.AGENTBOX_HUB_AUTH||process.env.BETTER_AUTH_SECRET)?"password":"off"}function g(a){return function(a){if(a.originUrl){let b,c=(b=a.originUrl.trim().replace(/\/+$/,"").replace(/\.git$/i,"").split(/[/:]/).filter(a=>a.length>0).pop())&&b.length>0?b:void 0;if(c)return c}if(a.projectSlug){let b,c=(b=a.projectSlug.split("__").filter(a=>a.length>0).pop())&&b.length>0?b:void 0;if(c)return c}return a.name}({originUrl:a.originUrl,projectSlug:a.projectSlug,name:a.name})}function h(a){var b;return b=a.originUrl??a.name,Buffer.from(b).toString("base64url")}function i(a){return{claude:a?.claude,codex:a?.codex,opencode:a?.opencode}}function j(a){if(!a)return"stopped";let{claude:b,codex:c,opencode:d}=i(a);return[b?.state,c?.state,d?.state].includes("error")?"error":b?.sessionRunning||c?.sessionRunning||d?.sessionRunning?"running":"stopped"}(0,d.join)(e.STATE_DIR,"hub","auth.db"),(0,d.join)(e.STATE_DIR,"hub","store.db"),(0,d.join)(e.STATE_DIR,"hub","token");let k=null;async function l(){var b;let c=process.env.POSTGRES_URL??process.env.RELAY_STORE_URL;if(!c)throw Error("hub: POSTGRES_URL required for the hosted source");let d=await (!k&&(k=(async()=>{let{PostgresStore:b}=await a.A(73901),d=new b({connectionString:c});return await d.migrate(),d})().catch(a=>{throw k=null,a})),k),e=await d.listBoxes(),f=new Map((await d.listStatuses()).map(a=>[a.boxId,a.status])),l=[];for(let a of e)for(let c of(await d.listPendingPrompts(a.boxId)))l.push((b=a.boxId,{id:c.ev.id,boxId:b,message:c.ev.message,detail:c.ev.detail,command:c.ev.context?.command,cwd:c.ev.context?.cwd,argv:c.ev.context?.argv,defaultAnswer:c.ev.defaultAnswer??"n",createdAt:Date.parse(c.createdAt)||Date.now()}));return{user:{login:"hub",name:"hub"},github:{available:!1,installed:!1,appName:"GitHub App",account:"",installedAt:0,repos:[]},projects:function(a){let b=new Map;for(let c of a){let a=h(c),d=Date.parse(c.createdAt??c.registeredAt)||Date.now(),e=b.get(a);e?(d<e.createdAt&&(e.createdAt=d),e.originUrl??=c.originUrl,e.projectSlug??=c.projectSlug):b.set(a,{key:a,name:g(c),createdAt:d,originUrl:c.originUrl,projectSlug:c.projectSlug})}return[...b.values()].map(a=>({id:a.key,name:a.name,repo:a.name,defaultBranch:"main",provider:"cloud",createdAt:a.createdAt,originUrl:a.originUrl??null,projectSlug:a.projectSlug??null})).sort((a,b)=>b.createdAt-a.createdAt)}(e),boxes:e.map(a=>(function(a,b){let{claude:c,codex:d,opencode:e}=i(b),f=Date.parse(a.createdAt??a.registeredAt)||Date.now();return{id:a.boxId,projectId:h(a),repo:g(a),branch:a.worktrees?.[0]?.branch??"",task:c?.sessionTitle??d?.sessionTitle??e?.sessionTitle??a.name,agent:d?.sessionRunning?"codex":e?.sessionRunning?"opencode":"claude",status:j(b),createdAt:f,lastActivity:f,host:a.backend?`${a.kind??"cloud"} \xb7 ${a.backend}`:a.kind??"cloud",provider:a.kind??"docker",commits:null,filesTouched:null,error:"error"===j(b)?c?.sessionTitle??"Agent reported an error":null,webUrl:null,vncUrl:null,name:a.name,sandboxId:a.sandboxId,originUrl:a.originUrl,publicHost:a.publicHost,image:a.image,webPort:a.webPort,lastAgent:"claude"===a.agent||"codex"===a.agent||"opencode"===a.agent?a.agent:void 0,topology:"control-plane"}})(a,f.get(a.boxId))),approvals:l,controlPlane:null,providers:[]}}async function m(a){let b=globalThis.__AGENTBOX_HUB_BACKEND;return b?{...await b.getData(a),authMode:f()}:process.env.POSTGRES_URL??process.env.RELAY_STORE_URL?{...await l(),authMode:f()}:{user:{login:"user",name:"user"},github:{available:!1,installed:!1,appName:"GitHub App",account:"",installedAt:0,repos:[]},projects:[],boxes:[],approvals:[],providers:[],controlPlane:null,authMode:f()}}async function n({children:a}){let d=await m();return(0,b.jsx)(c.HubShell,{data:d,children:a})}a.s(["default",0,n,"dynamic",0,"force-dynamic"],89754)},48685,a=>{a.n(a.i(89754))},73901,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[root-of-the-server]__1aw6a7b._.js","server/chunks/ssr/1w4z_drizzle-orm_1tfla2w._.js","server/chunks/ssr/packages_relay_dist_1z9j3g0._.js","server/chunks/ssr/_19vy9ni._.js"].map(b=>a.l(b))).then(()=>b(41503)))}];
1
+ module.exports=[5365,(a,b,c)=>{b.exports=a.x("process",()=>require("process"))},874,(a,b,c)=>{b.exports=a.x("buffer",()=>require("buffer"))},54799,(a,b,c)=>{b.exports=a.x("crypto",()=>require("crypto"))},24868,(a,b,c)=>{b.exports=a.x("fs/promises",()=>require("fs/promises"))},46786,(a,b,c)=>{b.exports=a.x("os",()=>require("os"))},29220,(a,b,c)=>{b.exports=a.x("timers/promises",()=>require("timers/promises"))},50227,(a,b,c)=>{b.exports=a.x("node:path",()=>require("node:path"))},8187,a=>{"use strict";a.s(["HubShell",()=>b]);let b=(0,a.i(71210).registerClientReference)(function(){throw Error("Attempted to call HubShell() from the server but HubShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/apps/hub/components/hub-shell.tsx <module evaluation>","HubShell")},65317,a=>{"use strict";a.s(["HubShell",()=>b]);let b=(0,a.i(71210).registerClientReference)(function(){throw Error("Attempted to call HubShell() from the server but HubShell is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/apps/hub/components/hub-shell.tsx","HubShell")},56045,a=>{"use strict";a.i(8187);var b=a.i(65317);a.n(b)},89754,a=>{"use strict";var b=a.i(14435),c=a.i(56045),d=a.i(50227),e=a.i(2876);function f(){let a;return"off"===process.env.AGENTBOX_HUB_AUTH?"off":"localhost"===("hetzner"===(a=process.env.AGENTBOX_HUB_PROFILE)||"vercel"===a?a:"localhost")?process.env.AGENTBOX_HUB_TOKEN?"token":"off":"off"!==process.env.AGENTBOX_HUB_AUTH&&("on"===process.env.AGENTBOX_HUB_AUTH||process.env.BETTER_AUTH_SECRET)?"password":"off"}function g(a){return function(a){if(a.originUrl){let b,c=(b=a.originUrl.trim().replace(/\/+$/,"").replace(/\.git$/i,"").split(/[/:]/).filter(a=>a.length>0).pop())&&b.length>0?b:void 0;if(c)return c}if(a.projectSlug){let b,c=(b=a.projectSlug.split("__").filter(a=>a.length>0).pop())&&b.length>0?b:void 0;if(c)return c}return a.name}({originUrl:a.originUrl,projectSlug:a.projectSlug,name:a.name})}function h(a){var b;return b=a.originUrl??a.name,Buffer.from(b).toString("base64url")}function i(a){return{claude:a?.claude,codex:a?.codex,opencode:a?.opencode}}function j(a){if(!a)return"stopped";let{claude:b,codex:c,opencode:d}=i(a);return[b?.state,c?.state,d?.state].includes("error")?"error":b?.sessionRunning||c?.sessionRunning||d?.sessionRunning?"running":"stopped"}(0,d.join)(e.STATE_DIR,"hub","auth.db"),(0,d.join)(e.STATE_DIR,"hub","store.db"),(0,d.join)(e.STATE_DIR,"hub","token");let k=null;async function l(){var b;let c=process.env.POSTGRES_URL??process.env.RELAY_STORE_URL;if(!c)throw Error("hub: POSTGRES_URL required for the hosted source");let d=await (!k&&(k=(async()=>{let{PostgresStore:b}=await a.A(73901),d=new b({connectionString:c});return await d.migrate(),d})().catch(a=>{throw k=null,a})),k),e=await d.listBoxes(),f=new Map((await d.listStatuses()).map(a=>[a.boxId,a.status])),l=[];for(let a of e)for(let c of(await d.listPendingPrompts(a.boxId)))l.push((b=a.boxId,{id:c.ev.id,boxId:b,message:c.ev.message,detail:c.ev.detail,command:c.ev.context?.command,cwd:c.ev.context?.cwd,argv:c.ev.context?.argv,defaultAnswer:c.ev.defaultAnswer??"n",createdAt:Date.parse(c.createdAt)||Date.now()}));return{user:{login:"hub",name:"hub"},github:{available:!1,installed:!1,appName:"GitHub App",account:"",installedAt:0,repos:[]},projects:function(a){let b=new Map;for(let c of a){let a=h(c),d=Date.parse(c.createdAt??c.registeredAt)||Date.now(),e=b.get(a);e?(d<e.createdAt&&(e.createdAt=d),e.originUrl??=c.originUrl,e.projectSlug??=c.projectSlug):b.set(a,{key:a,name:g(c),createdAt:d,originUrl:c.originUrl,projectSlug:c.projectSlug})}return[...b.values()].map(a=>({id:a.key,name:a.name,repo:a.name,defaultBranch:"main",provider:"cloud",createdAt:a.createdAt,originUrl:a.originUrl??null,projectSlug:a.projectSlug??null})).sort((a,b)=>b.createdAt-a.createdAt)}(e),boxes:e.map(a=>(function(a,b){let{claude:c,codex:d,opencode:e}=i(b),f=Date.parse(a.createdAt??a.registeredAt)||Date.now();return{id:a.boxId,projectId:h(a),repo:g(a),branch:a.worktrees?.[0]?.branch??"",task:c?.sessionTitle??d?.sessionTitle??e?.sessionTitle??a.name,agent:d?.sessionRunning?"codex":e?.sessionRunning?"opencode":"claude",status:j(b),createdAt:f,lastActivity:f,host:a.backend?`${a.kind??"cloud"} \xb7 ${a.backend}`:a.kind??"cloud",provider:a.kind??"docker",commits:null,filesTouched:null,error:"error"===j(b)?c?.sessionTitle??"Agent reported an error":null,webUrl:null,vncUrl:null,name:a.name,sandboxId:a.sandboxId,originUrl:a.originUrl,publicHost:a.publicHost,image:a.image,webPort:a.webPort,lastAgent:"claude"===a.agent||"codex"===a.agent||"opencode"===a.agent?a.agent:void 0,topology:"control-plane"}})(a,f.get(a.boxId))),approvals:l,controlPlane:null,providers:[]}}async function m(a){let b=globalThis.__AGENTBOX_HUB_BACKEND;return b?{...await b.getData(a),authMode:f()}:process.env.POSTGRES_URL??process.env.RELAY_STORE_URL?{...await l(),authMode:f()}:{user:{login:"user",name:"user"},github:{available:!1,installed:!1,appName:"GitHub App",account:"",installedAt:0,repos:[]},projects:[],boxes:[],approvals:[],providers:[],controlPlane:null,authMode:f()}}async function n({children:a}){let d=await m();return(0,b.jsx)(c.HubShell,{data:d,children:a})}a.s(["default",0,n,"dynamic",0,"force-dynamic"],89754)},48685,a=>{a.n(a.i(89754))},73901,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[root-of-the-server]__1aw6a7b._.js","server/chunks/ssr/1w4z_drizzle-orm_1tfla2w._.js","server/chunks/ssr/packages_relay_dist_0sap-2l._.js","server/chunks/ssr/_19vy9ni._.js"].map(b=>a.l(b))).then(()=>b(41503)))}];
2
2
 
3
- //# sourceMappingURL=%5Broot-of-the-server%5D__1plrs94._.js.map
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__0-c5j6l._.js.map