@madarco/agentbox 0.27.1 → 0.28.0-nightly.202607251721

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/CHANGELOG.md +87 -4
  2. package/README.md +7 -3
  3. package/dist/_cloud-attach-XZYF324R.js +26 -0
  4. package/dist/admin-client-NOZ5CCAH.js +15 -0
  5. package/dist/chunk-2VW37PW4.js +1694 -0
  6. package/dist/chunk-2VW37PW4.js.map +1 -0
  7. package/dist/{chunk-HR7NHH5J.js → chunk-3UMM4VJH.js} +808 -57
  8. package/dist/chunk-3UMM4VJH.js.map +1 -0
  9. package/dist/chunk-5U5QOFL5.js +20 -0
  10. package/dist/chunk-5U5QOFL5.js.map +1 -0
  11. package/dist/chunk-6P6D77QP.js +285 -0
  12. package/dist/chunk-6P6D77QP.js.map +1 -0
  13. package/dist/chunk-6V366IZC.js +2892 -0
  14. package/dist/chunk-6V366IZC.js.map +1 -0
  15. package/dist/{chunk-KWOEUFVA.js → chunk-7J6G526Q.js} +6 -14
  16. package/dist/{chunk-KWOEUFVA.js.map → chunk-7J6G526Q.js.map} +1 -1
  17. package/dist/{chunk-IDH5A4RR.js → chunk-AYPAYY5R.js} +17 -4
  18. package/dist/chunk-AYPAYY5R.js.map +1 -0
  19. package/dist/{chunk-JGZSA5ZI.js → chunk-BHJCMTHP.js} +58 -15
  20. package/dist/chunk-BHJCMTHP.js.map +1 -0
  21. package/dist/{chunk-26IKZRTT.js → chunk-BLWAWGFX.js} +297 -1217
  22. package/dist/chunk-BLWAWGFX.js.map +1 -0
  23. package/dist/chunk-CGPUFXET.js +95 -0
  24. package/dist/chunk-CGPUFXET.js.map +1 -0
  25. package/dist/{chunk-SJ75AIA2.js → chunk-D6AODRNA.js} +12 -9
  26. package/dist/{chunk-SJ75AIA2.js.map → chunk-D6AODRNA.js.map} +1 -1
  27. package/dist/chunk-DPJMEG7U.js +11 -0
  28. package/dist/chunk-DPJMEG7U.js.map +1 -0
  29. package/dist/chunk-E2ITEZAQ.js +148 -0
  30. package/dist/chunk-E2ITEZAQ.js.map +1 -0
  31. package/dist/{chunk-JE6UI5YR.js → chunk-NKVCIH6N.js} +89 -223
  32. package/dist/chunk-NKVCIH6N.js.map +1 -0
  33. package/dist/chunk-OEYAVBA6.js +120 -0
  34. package/dist/chunk-OEYAVBA6.js.map +1 -0
  35. package/dist/{chunk-UJEH2NJT.js → chunk-PXYPQ5BO.js} +64 -264
  36. package/dist/chunk-PXYPQ5BO.js.map +1 -0
  37. package/dist/chunk-QESXSSO6.js +670 -0
  38. package/dist/chunk-QESXSSO6.js.map +1 -0
  39. package/dist/{chunk-NEF6MDJO.js → chunk-QJCK2AFX.js} +128 -26
  40. package/dist/chunk-QJCK2AFX.js.map +1 -0
  41. package/dist/chunk-RUJJY23M.js +84 -0
  42. package/dist/chunk-RUJJY23M.js.map +1 -0
  43. package/dist/{chunk-LL7NCMUU.js → chunk-SKNJRYM5.js} +7 -13
  44. package/dist/chunk-SKNJRYM5.js.map +1 -0
  45. package/dist/chunk-WFGAMJ5Q.js +689 -0
  46. package/dist/chunk-WFGAMJ5Q.js.map +1 -0
  47. package/dist/chunk-ZJL56TJD.js +1444 -0
  48. package/dist/chunk-ZJL56TJD.js.map +1 -0
  49. package/dist/{chunk-V5XXJH63.js → chunk-ZXOP4LBG.js} +5 -8
  50. package/dist/chunk-ZXOP4LBG.js.map +1 -0
  51. package/dist/control-plane-2VEM2KCL.js +31 -0
  52. package/dist/custody-client-P6XIXHRG.js +16 -0
  53. package/dist/{dist-TSFVB7AI.js → dist-2SYQI5S2.js} +11 -7
  54. package/dist/dist-2SYQI5S2.js.map +1 -0
  55. package/dist/{dist-KQTMCVME.js → dist-6QZMZEL7.js} +18 -11
  56. package/dist/dist-6QZMZEL7.js.map +1 -0
  57. package/dist/{dist-FTKS2GI4.js → dist-JHMILJUT.js} +10 -6
  58. package/dist/{dist-OO52HARR.js → dist-JOFZOZCY.js} +41 -25
  59. package/dist/{dist-O3LKOIE7.js → dist-KZ2GEEEX.js} +11 -7
  60. package/dist/dist-KZ2GEEEX.js.map +1 -0
  61. package/dist/{dist-Z6L5MM5D.js → dist-Q5NY4CF6.js} +10 -6
  62. package/dist/{dist-U2SVLJUQ.js → dist-SKMNEDVW.js} +8 -2
  63. package/dist/dist-SKMNEDVW.js.map +1 -0
  64. package/dist/dist-SRCKO7ZV.js +197 -0
  65. package/dist/dist-SRCKO7ZV.js.map +1 -0
  66. package/dist/{dist-WVYAURMF.js → dist-UXZQWKY6.js} +10 -6
  67. package/dist/dist-UXZQWKY6.js.map +1 -0
  68. package/dist/env-file-UDUDQMP4.js +11 -0
  69. package/dist/env-file-UDUDQMP4.js.map +1 -0
  70. package/dist/hub-adopt-ZS5CREYF.js +21 -0
  71. package/dist/hub-adopt-ZS5CREYF.js.map +1 -0
  72. package/dist/index.js +2461 -1905
  73. package/dist/index.js.map +1 -1
  74. package/dist/node-postgres-6JUOVUN5.js +3584 -0
  75. package/dist/node-postgres-6JUOVUN5.js.map +1 -0
  76. package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js → prepared-state-75DIZ55S-P6LE4N64.js} +3 -2
  77. package/dist/prepared-state-75DIZ55S-P6LE4N64.js.map +1 -0
  78. package/dist/remote-hub-SJ4XWBA5.js +9 -0
  79. package/dist/remote-hub-SJ4XWBA5.js.map +1 -0
  80. package/dist/sqlite-proxy-53E5D2VM.js +2882 -0
  81. package/dist/sqlite-proxy-53E5D2VM.js.map +1 -0
  82. package/package.json +1 -1
  83. package/runtime/_shared/ctl.cjs +29199 -16813
  84. package/runtime/digitalocean/ctl.cjs +29199 -16813
  85. package/runtime/docker/packages/ctl/dist/bin.cjs +29199 -16813
  86. package/runtime/e2b/ctl.cjs +29199 -16813
  87. package/runtime/hetzner/ctl.cjs +29199 -16813
  88. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  89. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  90. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js +5 -5
  91. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +1 -1
  92. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js +2 -2
  93. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/[id]/answer/route.js.nft.json +1 -1
  94. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js +2 -2
  95. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/approvals/route.js.nft.json +1 -1
  96. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js +2 -2
  97. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/[action]/route.js.nft.json +1 -1
  98. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js +2 -2
  99. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/branches/route.js.nft.json +1 -1
  100. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js +2 -2
  101. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/[op]/route.js.nft.json +1 -1
  102. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js +2 -2
  103. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/git/route.js.nft.json +1 -1
  104. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js +2 -2
  105. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.nft.json +1 -1
  106. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +2 -2
  107. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -1
  108. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js +2 -2
  109. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/route.js.nft.json +1 -1
  110. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js +2 -2
  111. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/restart/route.js.nft.json +1 -1
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js +4 -4
  113. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/services/route.js.nft.json +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js +2 -2
  115. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/route.js.nft.json +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js +2 -2
  117. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/health/route.js.nft.json +1 -1
  118. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js +2 -2
  119. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js.nft.json +1 -1
  120. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js +2 -2
  121. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js.nft.json +1 -1
  122. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js +2 -2
  123. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js.nft.json +1 -1
  124. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js +2 -2
  125. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/login-code/route.js.nft.json +1 -1
  126. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js +2 -2
  127. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/logs/route.js.nft.json +1 -1
  128. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js +2 -2
  129. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/jobs/[id]/route.js.nft.json +1 -1
  130. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js +2 -2
  131. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.nft.json +1 -1
  132. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js +2 -2
  133. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/branches/route.js.nft.json +1 -1
  134. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js +2 -2
  135. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/[id]/route.js.nft.json +1 -1
  136. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js +2 -2
  137. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/projects/route.js.nft.json +1 -1
  138. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js +2 -2
  139. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/credentials/route.js.nft.json +1 -1
  140. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js +2 -2
  141. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/[id]/prepare/route.js.nft.json +1 -1
  142. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js +2 -2
  143. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/providers/route.js.nft.json +1 -1
  144. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js +2 -2
  145. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page.js.nft.json +1 -1
  146. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
  147. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js +2 -2
  148. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js.nft.json +1 -1
  149. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  150. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js +2 -2
  151. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  152. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  153. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js +2 -2
  154. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.nft.json +1 -1
  155. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
  156. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js +2 -2
  157. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js.nft.json +1 -1
  158. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  159. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js +4 -2
  160. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js.nft.json +1 -1
  161. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  162. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  163. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  164. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  165. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  166. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  167. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  168. package/runtime/hub/apps/hub/.next/server/chunks/0-fj_better-auth_dist_adapters_kysely-adapter_index_mjs_0btft52._.js +3 -0
  169. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_0gvv4ct._.js +4 -0
  170. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_0pn9b49._.js +4 -0
  171. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_145bz8z._.js +9 -0
  172. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_14y990b._.js +3 -0
  173. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_1nl4l3q._.js +3 -0
  174. package/runtime/hub/apps/hub/.next/server/chunks/1w4z_drizzle-orm_sqlite-proxy_index_05v_j5r.js +15 -0
  175. package/runtime/hub/apps/hub/.next/server/chunks/{[externals]__12m3qoa._.js → [externals]__0f3aqcx._.js} +2 -2
  176. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0-9g1s8._.js +3 -0
  177. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0-pvfxg._.js +3 -0
  178. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__01amzh6._.js +3 -0
  179. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__02q799_._.js +3 -0
  180. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__03k22rl._.js +3 -0
  181. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04tqk-j._.js +3 -0
  182. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__05ovf1y._.js +3 -0
  183. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__05s-_x7._.js +3 -0
  184. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07dnyfi._.js +3 -0
  185. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07zk6qo._.js +3 -0
  186. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0_59yi6._.js +3 -0
  187. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ajlo3d._.js +3 -0
  188. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0b5s54n._.js +3 -0
  189. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c4fiez._.js +3 -0
  190. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0c9iff1._.js +3 -0
  191. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +5 -5
  192. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0dh6lzr._.js +3 -0
  193. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ey83ai._.js +3 -0
  194. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0h6vdvr._.js +3 -0
  195. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0lup7p4._.js +3 -0
  196. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0luxuu4._.js +3 -0
  197. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0nl2u6u._.js +3 -0
  198. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0nonp-6._.js +3 -0
  199. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0oplozy._.js +3 -0
  200. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0p-6wgd._.js +3 -0
  201. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0rcnwbw._.js +3 -0
  202. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0tuz1am._.js +3 -0
  203. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-9g0ae._.js +1 -1
  204. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__10ry4ss._.js +3 -0
  205. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__11hv164._.js +3 -0
  206. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__154_i13._.js +3 -0
  207. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__17676rc._.js +3 -0
  208. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bg1alc._.js +3 -0
  209. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1cvqb1d._.js +3 -0
  210. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d60gbz._.js +3 -0
  211. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dm0jmw._.js +6 -0
  212. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dv_b1t._.js +3 -0
  213. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1fzxip4._.js +3 -0
  214. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4oj-e._.js +3 -0
  215. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1i4gq_2._.js +3 -0
  216. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v1p7in._.js +3 -0
  217. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9_her._.js +4 -0
  218. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1x1jkpb._.js +3 -0
  219. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1yd8n5l._.js +3 -0
  220. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20t_rs8._.js +3 -0
  221. package/runtime/hub/apps/hub/.next/server/chunks/_033w048._.js +1 -1
  222. package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
  223. package/runtime/hub/apps/hub/.next/server/chunks/{_0760z6y._.js → _0907rw0._.js} +15 -15
  224. package/runtime/hub/apps/hub/.next/server/chunks/_0f3molr._.js +1 -1
  225. package/runtime/hub/apps/hub/.next/server/chunks/_0lgs9kd._.js +1 -1
  226. package/runtime/hub/apps/hub/.next/server/chunks/_0pyhcqe._.js +1 -1
  227. package/runtime/hub/apps/hub/.next/server/chunks/_1-42ili._.js +1 -1
  228. package/runtime/hub/apps/hub/.next/server/chunks/_11__3wi._.js +1 -1
  229. package/runtime/hub/apps/hub/.next/server/chunks/_12flzuh._.js +1 -1
  230. package/runtime/hub/apps/hub/.next/server/chunks/_1bng7w9._.js +1 -1
  231. package/runtime/hub/apps/hub/.next/server/chunks/_1rpkqst._.js +1 -1
  232. package/runtime/hub/apps/hub/.next/server/chunks/_1wt72m1._.js +1 -1
  233. package/runtime/hub/apps/hub/.next/server/chunks/_1x3l5t8._.js +1 -1
  234. package/runtime/hub/apps/hub/.next/server/chunks/packages_relay_dist_control-plane_03a-9aj.js +62 -31
  235. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0xy-j7z._.js +1 -1
  236. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_1uccfbf._.js +1 -1
  237. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_010858m.js +1 -1
  238. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_04zwxnx.js +1 -1
  239. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_06exuc7.js +1 -1
  240. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2ldrt.js +1 -1
  241. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2tzep.js +1 -1
  242. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_116nh32.js +1 -1
  243. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_11dyjcb.js +1 -1
  244. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_1_4knli.js +1 -1
  245. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0ebuy19._.js +3 -0
  246. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0wxhi0-._.js +3 -0
  247. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_0xe4ick._.js +9 -0
  248. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_14oaveu._.js +4 -0
  249. package/runtime/hub/apps/hub/.next/server/chunks/ssr/1w4z_drizzle-orm_sqlite-proxy_index_1a6wfdg.js +15 -0
  250. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0-pm2yl._.js +3 -0
  251. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__08-1wwu._.js +1 -1
  252. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0c9mbcn._.js +1 -1
  253. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0gdfxj4._.js +1 -1
  254. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0kc-hwp._.js +1 -1
  255. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0lu73p6._.js +1 -1
  256. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0m1yf2b._.js +4 -0
  257. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0wv-3zo._.js +3 -0
  258. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__10bfmwi._.js +1 -1
  259. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__18qvdzb._.js +2 -2
  260. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1l2urlw._.js +1 -1
  261. package/runtime/hub/apps/hub/.next/server/chunks/ssr/{_0ro6vh6._.js → _0r2xlss._.js} +3 -3
  262. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +1 -1
  263. package/runtime/hub/apps/hub/.next/server/chunks/ssr/packages_relay_dist_control-plane_0ve-wz4.js +2 -25
  264. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  265. package/runtime/hub/apps/hub/.next/server/middleware.js +1 -1
  266. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  267. package/runtime/hub/apps/hub/.next/static/chunks/{2xc1sm79a6tsb.js → 2gsrna76i1d80.js} +1 -1
  268. package/runtime/hub/apps/hub/attach-helper.cjs +191 -0
  269. package/runtime/hub/apps/hub/{auth-DC44GQZY.js → auth-IRNNO3IK.js} +2 -2
  270. package/runtime/hub/apps/hub/{auth-config-LALRDYDO.js → auth-config-WJHIMGUE.js} +4 -2
  271. package/runtime/hub/apps/hub/{chunk-YJ5MJOXK.js → chunk-4LYVBRBC.js} +2094 -220
  272. package/runtime/hub/apps/hub/chunk-6AVSKCZJ.js +669 -0
  273. package/runtime/hub/apps/hub/{chunk-QSMPSV5Z.js → chunk-A5Y7LJMU.js} +57 -14
  274. package/runtime/hub/apps/hub/chunk-EDRFXO2M.js +35 -0
  275. package/runtime/hub/apps/hub/chunk-F2JI4GMX.js +2891 -0
  276. package/runtime/hub/apps/hub/{chunk-EHBJKZCL.js → chunk-O3K3ZGFF.js} +500 -35
  277. package/runtime/hub/apps/hub/chunk-RII6IKNJ.js +688 -0
  278. package/runtime/hub/apps/hub/{chunk-RXYOWSSN.js → chunk-RMEUA6PA.js} +120 -14
  279. package/runtime/hub/apps/hub/{chunk-3FJNKSNZ.js → chunk-SCHQR5KR.js} +3 -1
  280. package/runtime/hub/apps/hub/{dist-6FPPUSWZ.js → dist-2GEAA7QA.js} +15 -3
  281. package/runtime/hub/apps/hub/{dist-JG45OFT2.js → dist-36O6F6M3.js} +39 -24
  282. package/runtime/hub/apps/hub/{dist-3I7KUI6W.js → dist-IWLEL2TO.js} +21 -24
  283. package/runtime/hub/apps/hub/{dist-G6TXUSPZ.js → dist-NYKIT5W5.js} +10 -11
  284. package/runtime/hub/apps/hub/{dist-EQV4L7KP.js → dist-QB2IJ7OD.js} +7 -1
  285. package/runtime/hub/apps/hub/{dist-LYDHYTP2.js → dist-RBBXXGLI.js} +129 -26
  286. package/runtime/hub/apps/hub/{dist-GTVVXCBP.js → dist-RRJN2U5P.js} +10 -14
  287. package/runtime/hub/apps/hub/{dist-DX6IYMAH.js → dist-UWXGDCK4.js} +14 -11
  288. package/runtime/hub/apps/hub/{hub-token-COBZGSLS.js → hub-token-6USIMBPQ.js} +2 -2
  289. package/runtime/hub/apps/hub/hub-worker-SOFWVTWU.js +215 -0
  290. package/runtime/hub/apps/hub/node-postgres-DIU2H5VP.js +3583 -0
  291. package/runtime/hub/apps/hub/package.json +5 -2
  292. package/runtime/hub/apps/hub/{prepared-state-75DIZ55S-2IFNUHHM.js → prepared-state-75DIZ55S-P5FHEORG.js} +1 -1
  293. package/runtime/hub/apps/hub/server.js +247 -66
  294. package/runtime/hub/apps/hub/sqlite-proxy-VJS3HIOV.js +2881 -0
  295. package/runtime/relay/bin.cjs +694 -13
  296. package/runtime/vercel/ctl.cjs +29199 -16813
  297. package/dist/_cloud-attach-WDGM6FL5.js +0 -19
  298. package/dist/chunk-26IKZRTT.js.map +0 -1
  299. package/dist/chunk-HR7NHH5J.js.map +0 -1
  300. package/dist/chunk-IDH5A4RR.js.map +0 -1
  301. package/dist/chunk-JE6UI5YR.js.map +0 -1
  302. package/dist/chunk-JGZSA5ZI.js.map +0 -1
  303. package/dist/chunk-LL7NCMUU.js.map +0 -1
  304. package/dist/chunk-NEF6MDJO.js.map +0 -1
  305. package/dist/chunk-UJEH2NJT.js.map +0 -1
  306. package/dist/chunk-V5XXJH63.js.map +0 -1
  307. package/dist/dist-KQTMCVME.js.map +0 -1
  308. package/dist/dist-O3LKOIE7.js.map +0 -1
  309. package/dist/dist-TSFVB7AI.js.map +0 -1
  310. package/runtime/hub/apps/hub/.next/server/chunks/0zhp_better-auth_dist_adapters_kysely-adapter_index_mjs_1rl4qnh._.js +0 -3
  311. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04h15ml._.js +0 -3
  312. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04jgk9x._.js +0 -3
  313. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07ednlo._.js +0 -3
  314. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0a7djvw._.js +0 -3
  315. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ig1bot._.js +0 -3
  316. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +0 -3
  317. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ql4fjo._.js +0 -3
  318. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +0 -3
  319. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0t7o5ed._.js +0 -3
  320. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vs8fma._.js +0 -3
  321. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w9ud8u._.js +0 -3
  322. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0xh14bo._.js +0 -3
  323. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yhb0gc._.js +0 -3
  324. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-0flwc._.js +0 -3
  325. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13ioh5z._.js +0 -3
  326. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13jwk_k._.js +0 -3
  327. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16_uteg._.js +0 -3
  328. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16p2m-g._.js +0 -3
  329. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__19pc87s._.js +0 -3
  330. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_gu2yk._.js +0 -3
  331. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1a50b07._.js +0 -3
  332. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ai-945._.js +0 -3
  333. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bu2zio._.js +0 -3
  334. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ctczev._.js +0 -3
  335. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1d6mtlk._.js +0 -3
  336. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dn_3i1._.js +0 -3
  337. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1e4z_-v._.js +0 -3
  338. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f2sueq._.js +0 -3
  339. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f9zctr._.js +0 -3
  340. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4xycg._.js +0 -3
  341. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +0 -3
  342. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1js2jdv._.js +0 -3
  343. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1md9kdw._.js +0 -3
  344. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mttufy._.js +0 -3
  345. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1nepkp-._.js +0 -6
  346. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1pp5oib._.js +0 -3
  347. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q5bqse._.js +0 -3
  348. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qwhzmi._.js +0 -3
  349. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thipug._.js +0 -3
  350. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9om6g._.js +0 -3
  351. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1xeczo7._.js +0 -3
  352. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20503l7._.js +0 -3
  353. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[externals]_pg_20c820g._.js +0 -3
  354. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0j0tjwn._.js +0 -3
  355. /package/dist/{_cloud-attach-WDGM6FL5.js.map → _cloud-attach-XZYF324R.js.map} +0 -0
  356. /package/dist/{dist-FTKS2GI4.js.map → admin-client-NOZ5CCAH.js.map} +0 -0
  357. /package/dist/{dist-OO52HARR.js.map → control-plane-2VEM2KCL.js.map} +0 -0
  358. /package/dist/{dist-U2SVLJUQ.js.map → custody-client-P6XIXHRG.js.map} +0 -0
  359. /package/dist/{dist-WVYAURMF.js.map → dist-JHMILJUT.js.map} +0 -0
  360. /package/dist/{dist-Z6L5MM5D.js.map → dist-JOFZOZCY.js.map} +0 -0
  361. /package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js.map → dist-Q5NY4CF6.js.map} +0 -0
  362. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_buildManifest.js +0 -0
  363. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_clientMiddlewareManifest.js +0 -0
  364. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → B4bEtdig9I9joQFHDOjX3}/_ssgManifest.js +0 -0
@@ -18998,6 +18998,9 @@ var PROVIDER_NAMES = PROVIDERS.map((p) => p.name);
18998
18998
  var CLOUD_PROVIDER_NAMES = PROVIDERS.filter(
18999
18999
  (p) => p.kind === "cloud"
19000
19000
  ).map((p) => p.name);
19001
+ var HUB_ROUTABLE_PROVIDER_NAMES = CLOUD_PROVIDER_NAMES.filter(
19002
+ (n2) => n2 !== "remote-docker"
19003
+ );
19001
19004
  function providerKeyCap(name) {
19002
19005
  return name.split("-").filter((seg) => seg.length > 0).map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1)).join("");
19003
19006
  }
@@ -19116,7 +19119,8 @@ var BUILT_IN_DEFAULTS = {
19116
19119
  },
19117
19120
  relay: {
19118
19121
  port: 8787,
19119
- controlPlaneUrl: void 0
19122
+ controlPlaneUrl: void 0,
19123
+ custodyMaxBodyBytes: 32 * 1024 * 1024
19120
19124
  },
19121
19125
  git: {
19122
19126
  pushMode: "auto"
@@ -19141,14 +19145,16 @@ var BUILT_IN_DEFAULTS = {
19141
19145
  openIn: "none"
19142
19146
  },
19143
19147
  cloud: {
19144
- useCurrentBranch: false
19148
+ useCurrentBranch: false,
19149
+ viaHub: true
19145
19150
  },
19146
19151
  maintenance: {
19147
19152
  pruneProjectConfigs: true,
19148
19153
  pruneProjectConfigsEvery: 50
19149
19154
  },
19150
19155
  update: {
19151
- check: true
19156
+ check: true,
19157
+ channel: "auto"
19152
19158
  },
19153
19159
  integrations: {
19154
19160
  notion: { enabled: false },
@@ -19482,7 +19488,13 @@ var KEY_REGISTRY = [
19482
19488
  {
19483
19489
  key: "relay.controlPlaneUrl",
19484
19490
  type: "string",
19485
- description: "Public HTTPS URL of a deployed control plane (hosted Next.js + Postgres app). When set, new cloud boxes point at it for git-token leasing, permission state, and the box registry/events, and push to GitHub directly with a leased token so they keep working with the laptop off. Set via `agentbox control-plane set-url`."
19491
+ description: "Public HTTPS URL of a deployed control plane (hosted Next.js + Postgres app). When set, new cloud boxes point at it for git-token leasing, permission state, and the box registry/events, and push to GitHub directly with a leased token so they keep working with the laptop off. Set via `agentbox hub set-url`."
19492
+ },
19493
+ {
19494
+ key: "relay.custodyMaxBodyBytes",
19495
+ type: "int",
19496
+ description: "Per-request body cap (bytes) for custody PUTs (default 33554432 = 32 MiB). Custody carries a project's untracked-files seed tar, which the relay's 1 MiB control-plane body cap is too small for; this cap applies only to custody, so every other relay route keeps the smaller one. On a PC it governs how large a seed blob the client will upload; a control box enforces its own cap via AGENTBOX_CUSTODY_MAX_BODY_BYTES, so raise both to admit a bigger seed (a blob the control box refuses is dropped and the rest of the seed still pushes).",
19497
+ advanced: true
19486
19498
  },
19487
19499
  {
19488
19500
  key: "git.pushMode",
@@ -19553,6 +19565,11 @@ var KEY_REGISTRY = [
19553
19565
  type: "bool",
19554
19566
  description: "On cloud providers (daytona/hetzner), start new boxes on the host's current branch instead of forking a new agentbox/<box-name> branch. Overridden by an explicit --use-branch / --from-branch."
19555
19567
  },
19568
+ {
19569
+ key: "cloud.viaHub",
19570
+ type: "bool",
19571
+ description: "When a control box is configured (relay.controlPlaneUrl), create cloud boxes ON the control box by default instead of on this machine (so they keep running with the laptop off). On by default; set false to always build cloud boxes locally. Overridden per-command by --via-hub / --local. Docker and remote-docker always build locally regardless."
19572
+ },
19556
19573
  {
19557
19574
  key: "maintenance.pruneProjectConfigs",
19558
19575
  type: "bool",
@@ -19568,6 +19585,12 @@ var KEY_REGISTRY = [
19568
19585
  type: "bool",
19569
19586
  description: 'Daily background check for a newer published agentbox (npm registry) and menu-bar app (release sha sidecar), plus the "newer version available" nudge. At most one network probe per 24h; false disables both.'
19570
19587
  },
19588
+ {
19589
+ key: "update.channel",
19590
+ type: "enum",
19591
+ enumValues: ["auto", "stable", "nightly"],
19592
+ description: "Which release channel `agentbox self-update` and `install app` follow: `auto` (default) follows the installed build, `nightly` opts into pre-release builds cut from the nightly branch, `stable` opts back out. Nightly always installs the newest build of EITHER channel, so a stable release supersedes the nightlies that preceded it."
19593
+ },
19571
19594
  {
19572
19595
  key: "integrations.notion.enabled",
19573
19596
  type: "bool",
@@ -21790,6 +21813,7 @@ async function gateApproval(deps, boxId, method, params, promptParams) {
21790
21813
  }
21791
21814
 
21792
21815
  // src/worktree.ts
21816
+ var import_node_fs6 = require("fs");
21793
21817
  function resolveWorktree(reg, containerPath) {
21794
21818
  const trees = reg.worktrees ?? [];
21795
21819
  if (trees.length === 0) return null;
@@ -21800,6 +21824,398 @@ function resolveWorktree(reg, containerPath) {
21800
21824
  ).sort((a2, b) => b.containerPath.length - a2.containerPath.length);
21801
21825
  return prefixMatches[0] ?? trees.find((w) => w.containerPath === "/workspace") ?? null;
21802
21826
  }
21827
+ function hostRepoUnavailableReason(worktree, boxId, op) {
21828
+ if (worktree.hostMainRepo.length > 0 && (0, import_node_fs6.existsSync)(worktree.hostMainRepo)) return null;
21829
+ return `host-side ${op} is unavailable for box ${boxId}: its host repo (${worktree.hostMainRepo || "<unset>"}) does not exist on this host. Boxes created by the control-box worker have no host working copy \u2014 push from inside the box (leased) or adopt the box on this host first.`;
21830
+ }
21831
+
21832
+ // src/admin-gate.ts
21833
+ var import_node_crypto7 = require("crypto");
21834
+ function timingSafeEqualStr(a2, b) {
21835
+ const ab = Buffer.from(a2, "utf8");
21836
+ const bb = Buffer.from(b, "utf8");
21837
+ if (ab.length !== bb.length) return false;
21838
+ return (0, import_node_crypto7.timingSafeEqual)(ab, bb);
21839
+ }
21840
+ function adminGateAllows(isLoopback, bearer, adminToken) {
21841
+ if (isLoopback) return true;
21842
+ if (adminToken.length === 0) return false;
21843
+ return Boolean(bearer) && timingSafeEqualStr(bearer ?? "", adminToken);
21844
+ }
21845
+
21846
+ // src/custody/routes.ts
21847
+ var import_node_crypto9 = require("crypto");
21848
+
21849
+ // src/custody/store.ts
21850
+ var import_node_crypto8 = require("crypto");
21851
+ var CUSTODY_SCOPES = ["agents", "projects", "boxes", "prepared"];
21852
+ var AGENT_IDS = ["claude", "codex", "opencode"];
21853
+ var CustodyPathError = class extends Error {
21854
+ constructor(message) {
21855
+ super(message);
21856
+ this.name = "CustodyPathError";
21857
+ }
21858
+ };
21859
+ var SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
21860
+ var MAX_SEGMENTS = 6;
21861
+ var MAX_PATH_LENGTH = 256;
21862
+ function normalizeCustodyPath(raw) {
21863
+ const trimmed = raw.replace(/^\/+/, "").replace(/\/+$/, "");
21864
+ if (trimmed.length === 0) throw new CustodyPathError("empty custody path");
21865
+ if (trimmed.length > MAX_PATH_LENGTH) {
21866
+ throw new CustodyPathError(`custody path too long (max ${String(MAX_PATH_LENGTH)} chars)`);
21867
+ }
21868
+ const segments = trimmed.split("/");
21869
+ if (segments.length < 2) {
21870
+ throw new CustodyPathError(`custody path needs a scope and a name: '${raw}'`);
21871
+ }
21872
+ if (segments.length > MAX_SEGMENTS) {
21873
+ throw new CustodyPathError(`custody path too deep (max ${String(MAX_SEGMENTS)} segments)`);
21874
+ }
21875
+ for (const seg of segments) {
21876
+ if (seg === "." || seg === ".." || !SEGMENT_RE.test(seg)) {
21877
+ throw new CustodyPathError(`illegal custody path segment: '${seg}'`);
21878
+ }
21879
+ }
21880
+ const scope = segments[0];
21881
+ if (!CUSTODY_SCOPES.includes(scope)) {
21882
+ throw new CustodyPathError(
21883
+ `unknown custody scope '${scope}' (expected ${CUSTODY_SCOPES.join(" | ")})`
21884
+ );
21885
+ }
21886
+ if (scope === "agents" && !AGENT_IDS.includes(segments[1])) {
21887
+ throw new CustodyPathError(
21888
+ `unknown agent '${segments[1]}' (expected ${AGENT_IDS.join(" | ")})`
21889
+ );
21890
+ }
21891
+ return segments.join("/");
21892
+ }
21893
+ function normalizeCustodyPrefix(raw) {
21894
+ const trimmed = raw.replace(/^\/+/, "").replace(/\/+$/, "");
21895
+ if (trimmed.length === 0) return "";
21896
+ if (trimmed.length > MAX_PATH_LENGTH) {
21897
+ throw new CustodyPathError(`custody prefix too long (max ${String(MAX_PATH_LENGTH)} chars)`);
21898
+ }
21899
+ const segments = trimmed.split("/");
21900
+ if (segments.length > MAX_SEGMENTS) {
21901
+ throw new CustodyPathError(`custody prefix too deep (max ${String(MAX_SEGMENTS)} segments)`);
21902
+ }
21903
+ for (const seg of segments) {
21904
+ if (seg === "." || seg === ".." || !SEGMENT_RE.test(seg)) {
21905
+ throw new CustodyPathError(`illegal custody prefix segment: '${seg}'`);
21906
+ }
21907
+ }
21908
+ if (!CUSTODY_SCOPES.includes(segments[0])) {
21909
+ throw new CustodyPathError(
21910
+ `unknown custody scope '${segments[0]}' (expected ${CUSTODY_SCOPES.join(" | ")})`
21911
+ );
21912
+ }
21913
+ return segments.join("/");
21914
+ }
21915
+
21916
+ // src/custody/routes.ts
21917
+ var CUSTODY_PATH_PREFIX = "/admin/custody";
21918
+ function isCustodyPath(path6) {
21919
+ return path6 === CUSTODY_PATH_PREFIX || path6.startsWith(`${CUSTODY_PATH_PREFIX}/`);
21920
+ }
21921
+ function timingSafeEqualStr2(a2, b) {
21922
+ const ab = Buffer.from(a2, "utf8");
21923
+ const bb = Buffer.from(b, "utf8");
21924
+ if (ab.length !== bb.length) return false;
21925
+ return (0, import_node_crypto9.timingSafeEqual)(ab, bb);
21926
+ }
21927
+ async function handleCustodyRequest(req, deps) {
21928
+ if (!isCustodyPath(req.path)) return null;
21929
+ const log = deps.log ?? (() => {
21930
+ });
21931
+ const adminToken = deps.adminToken ?? "";
21932
+ if (adminToken.length === 0) {
21933
+ return { status: 503, body: { error: "custody not configured: admin token unset" } };
21934
+ }
21935
+ if (!timingSafeEqualStr2(req.bearer, adminToken)) {
21936
+ return { status: 401, body: { error: "invalid admin token" } };
21937
+ }
21938
+ const store = deps.custody;
21939
+ if (!store) {
21940
+ return { status: 503, body: { error: "custody store not enabled on this relay" } };
21941
+ }
21942
+ try {
21943
+ if (req.path === CUSTODY_PATH_PREFIX) {
21944
+ if (req.method !== "GET") return { status: 405, body: { error: "method not allowed" } };
21945
+ const rawPrefix = req.query.get("prefix");
21946
+ const prefix = rawPrefix ? normalizeCustodyPrefix(rawPrefix) : void 0;
21947
+ const entries = await store.list(prefix);
21948
+ return { status: 200, body: { entries } };
21949
+ }
21950
+ const path6 = normalizeCustodyPath(
21951
+ decodeURIComponent(req.path.slice(`${CUSTODY_PATH_PREFIX}/`.length))
21952
+ );
21953
+ if (req.method === "PUT") {
21954
+ let parsed;
21955
+ try {
21956
+ parsed = JSON.parse(req.bodyText.length === 0 ? "{}" : req.bodyText);
21957
+ } catch {
21958
+ return { status: 400, body: { error: "expected JSON {data: <base64>}" } };
21959
+ }
21960
+ if (typeof parsed.data !== "string") {
21961
+ return { status: 400, body: { error: "expected {data: <base64>}" } };
21962
+ }
21963
+ const buf = Buffer.from(parsed.data, "base64");
21964
+ if (buf.toString("base64") !== parsed.data.replace(/\s+/g, "")) {
21965
+ return { status: 400, body: { error: "data is not valid base64" } };
21966
+ }
21967
+ const result = await store.put(path6, buf);
21968
+ log(
21969
+ `custody put ${path6} (${String(result.size)} bytes, ${result.changed ? "changed" : "unchanged"})`
21970
+ );
21971
+ return { status: 200, body: result };
21972
+ }
21973
+ if (req.method === "GET") {
21974
+ const found = await store.get(path6);
21975
+ if (!found) return { status: 404, body: { error: "no such custody entry" } };
21976
+ log(`custody get ${path6} (${String(found.entry.size)} bytes)`);
21977
+ return { status: 200, body: { ...found.entry, data: found.data.toString("base64") } };
21978
+ }
21979
+ if (req.method === "DELETE") {
21980
+ const hit = await store.delete(path6);
21981
+ if (!hit) return { status: 404, body: { error: "no such custody entry" } };
21982
+ log(`custody delete ${path6}`);
21983
+ return { status: 204 };
21984
+ }
21985
+ return { status: 405, body: { error: "method not allowed" } };
21986
+ } catch (err) {
21987
+ if (err instanceof CustodyPathError) return { status: 400, body: { error: err.message } };
21988
+ const msg = err instanceof Error ? err.message : String(err);
21989
+ log(`custody error: ${msg}`);
21990
+ return { status: 500, body: { error: `custody: ${msg}` } };
21991
+ }
21992
+ }
21993
+
21994
+ // src/remote-boxes.ts
21995
+ var import_node_crypto10 = require("crypto");
21996
+ var import_node_crypto11 = require("crypto");
21997
+ var REMOTE_BOXES_PREFIX = "/remote/boxes";
21998
+ function isRemoteBoxesPath(path6) {
21999
+ return path6 === REMOTE_BOXES_PREFIX || path6.startsWith(`${REMOTE_BOXES_PREFIX}/`);
22000
+ }
22001
+ function timingSafeEqualStr3(a2, b) {
22002
+ const ab = Buffer.from(a2, "utf8");
22003
+ const bb = Buffer.from(b, "utf8");
22004
+ if (ab.length !== bb.length) return false;
22005
+ return (0, import_node_crypto11.timingSafeEqual)(ab, bb);
22006
+ }
22007
+ function parseJson(text) {
22008
+ if (text.length === 0) return {};
22009
+ try {
22010
+ return JSON.parse(text);
22011
+ } catch {
22012
+ return null;
22013
+ }
22014
+ }
22015
+ async function handleRemoteBoxesRequest(req, deps) {
22016
+ if (!isRemoteBoxesPath(req.path)) return null;
22017
+ const log = deps.log ?? (() => {
22018
+ });
22019
+ const { store } = deps;
22020
+ const adminToken = deps.adminToken ?? "";
22021
+ if (adminToken.length === 0) {
22022
+ return { status: 503, body: { error: "control plane not configured: admin token unset" } };
22023
+ }
22024
+ if (!timingSafeEqualStr3(req.bearer, adminToken)) {
22025
+ return { status: 401, body: { error: "invalid admin token" } };
22026
+ }
22027
+ if (req.method === "POST" && req.path === REMOTE_BOXES_PREFIX) {
22028
+ if (!store.enqueueCreateJob) {
22029
+ return { status: 501, body: { error: "create-job queue not available on this store" } };
22030
+ }
22031
+ const body = parseJson(req.bodyText);
22032
+ if (!body || typeof body.repoUrl !== "string" || typeof body.provider !== "string") {
22033
+ return { status: 400, body: { error: "expected {repoUrl, provider, branch?, name?, agent?, prompt?}" } };
22034
+ }
22035
+ const allowed = deps.createProviders;
22036
+ if (allowed && allowed.length > 0 && !allowed.includes(body.provider)) {
22037
+ return {
22038
+ status: 400,
22039
+ body: {
22040
+ error: `provider '${body.provider}' is not supported by this control plane (allowed: ${allowed.join(", ")})`
22041
+ }
22042
+ };
22043
+ }
22044
+ const id = (0, import_node_crypto10.randomUUID)();
22045
+ await store.enqueueCreateJob({
22046
+ id,
22047
+ status: "queued",
22048
+ request: {
22049
+ repoUrl: body.repoUrl,
22050
+ provider: body.provider,
22051
+ branch: body.branch,
22052
+ name: body.name,
22053
+ agent: body.agent,
22054
+ prompt: body.prompt
22055
+ },
22056
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
22057
+ });
22058
+ log(`enqueued create job ${id} (${body.provider} ${body.repoUrl})`);
22059
+ return { status: 202, body: { jobId: id } };
22060
+ }
22061
+ if (req.method === "GET" && req.path === REMOTE_BOXES_PREFIX) {
22062
+ if (!store.listCreateJobs) {
22063
+ return { status: 501, body: { error: "create-job queue not available on this store" } };
22064
+ }
22065
+ const jobs = await store.listCreateJobs({ limit: 100 });
22066
+ return { status: 200, body: { jobs } };
22067
+ }
22068
+ if (req.method === "GET" && req.path.startsWith(`${REMOTE_BOXES_PREFIX}/`)) {
22069
+ if (!store.getCreateJob) {
22070
+ return { status: 501, body: { error: "create-job queue not available on this store" } };
22071
+ }
22072
+ const id = decodeURIComponent(req.path.slice(`${REMOTE_BOXES_PREFIX}/`.length));
22073
+ const job = await store.getCreateJob(id);
22074
+ return job ? { status: 200, body: job } : { status: 404, body: { error: "no such job" } };
22075
+ }
22076
+ if (req.method === "DELETE" && req.path.startsWith(`${REMOTE_BOXES_PREFIX}/`)) {
22077
+ const boxId = decodeURIComponent(req.path.slice(`${REMOTE_BOXES_PREFIX}/`.length));
22078
+ if (boxId.length === 0) return { status: 404, body: { error: "no such box" } };
22079
+ const reg = await store.getBox(boxId);
22080
+ const existed = await store.forgetBox(boxId);
22081
+ await store.deleteStatus(boxId);
22082
+ let custodyRemoved = 0;
22083
+ if (deps.custody) {
22084
+ const key = reg?.sandboxId ?? boxId;
22085
+ const entries = await deps.custody.list(`boxes/${key}`).catch(() => []);
22086
+ for (const e of entries) {
22087
+ if (await deps.custody.delete(e.path).catch(() => false)) custodyRemoved += 1;
22088
+ }
22089
+ }
22090
+ if (!existed && !reg && custodyRemoved === 0) {
22091
+ return { status: 404, body: { error: "no such box" } };
22092
+ }
22093
+ log(`reaped box ${boxId} (registration=${String(existed)}, custody=${String(custodyRemoved)})`);
22094
+ return { status: 200, body: { boxId, removed: existed, custodyRemoved } };
22095
+ }
22096
+ return { status: 405, body: { error: "method not allowed" } };
22097
+ }
22098
+
22099
+ // src/store/store-rpc-routes.ts
22100
+ var import_node_crypto12 = require("crypto");
22101
+
22102
+ // src/store/store-rpc.ts
22103
+ function isStoreRpcMethod(method) {
22104
+ return STORE_RPC_METHODS.has(method);
22105
+ }
22106
+ var STORE_RPC_METHODS = /* @__PURE__ */ new Set([
22107
+ "registerBox",
22108
+ "getBox",
22109
+ "authenticateBox",
22110
+ "listBoxes",
22111
+ "forgetBox",
22112
+ "countBoxes",
22113
+ "appendEvent",
22114
+ "listEvents",
22115
+ "countEvents",
22116
+ "setStatus",
22117
+ "getStatus",
22118
+ "deleteStatus",
22119
+ "listStatuses",
22120
+ "createPrompt",
22121
+ "getPrompt",
22122
+ "answerPrompt",
22123
+ "listPendingPrompts",
22124
+ "setPromptResult"
22125
+ ]);
22126
+ function applyStoreOp(store, method, args) {
22127
+ switch (method) {
22128
+ case "registerBox":
22129
+ return store.registerBox(args[0]);
22130
+ case "getBox":
22131
+ return store.getBox(args[0]);
22132
+ case "authenticateBox":
22133
+ return store.authenticateBox(args[0]);
22134
+ case "listBoxes":
22135
+ return store.listBoxes();
22136
+ case "forgetBox":
22137
+ return store.forgetBox(args[0]);
22138
+ case "countBoxes":
22139
+ return store.countBoxes();
22140
+ case "appendEvent":
22141
+ return store.appendEvent(args[0]);
22142
+ case "listEvents":
22143
+ return store.listEvents(args[0], args[1]);
22144
+ case "countEvents":
22145
+ return store.countEvents();
22146
+ case "setStatus":
22147
+ return store.setStatus(
22148
+ args[0],
22149
+ args[1],
22150
+ args[2],
22151
+ args[3]
22152
+ );
22153
+ case "getStatus":
22154
+ return store.getStatus(args[0]);
22155
+ case "deleteStatus":
22156
+ return store.deleteStatus(args[0]);
22157
+ case "listStatuses":
22158
+ return store.listStatuses();
22159
+ case "createPrompt":
22160
+ return store.createPrompt(args[0]);
22161
+ case "getPrompt":
22162
+ return store.getPrompt(args[0]);
22163
+ case "answerPrompt":
22164
+ return store.answerPrompt(
22165
+ args[0],
22166
+ args[1],
22167
+ args[2]
22168
+ );
22169
+ case "listPendingPrompts":
22170
+ return store.listPendingPrompts(args[0]);
22171
+ case "setPromptResult":
22172
+ return store.setPromptResult(args[0], args[1]);
22173
+ default:
22174
+ throw new Error(`unknown store op: ${method}`);
22175
+ }
22176
+ }
22177
+
22178
+ // src/store/store-rpc-routes.ts
22179
+ var STORE_RPC_PATH = "/admin/store";
22180
+ function isStoreRpcPath(path6) {
22181
+ return path6 === STORE_RPC_PATH;
22182
+ }
22183
+ function timingSafeEqualStr4(a2, b) {
22184
+ const ab = Buffer.from(a2, "utf8");
22185
+ const bb = Buffer.from(b, "utf8");
22186
+ if (ab.length !== bb.length) return false;
22187
+ return (0, import_node_crypto12.timingSafeEqual)(ab, bb);
22188
+ }
22189
+ function parseJson2(text) {
22190
+ if (text.length === 0) return null;
22191
+ try {
22192
+ return JSON.parse(text);
22193
+ } catch {
22194
+ return null;
22195
+ }
22196
+ }
22197
+ async function handleStoreRpcRequest(req, deps) {
22198
+ if (!isStoreRpcPath(req.path)) return null;
22199
+ const adminToken = deps.adminToken ?? "";
22200
+ if (adminToken.length === 0) {
22201
+ return { status: 503, body: { error: "control plane not configured: admin token unset" } };
22202
+ }
22203
+ if (!timingSafeEqualStr4(req.bearer, adminToken)) {
22204
+ return { status: 401, body: { error: "invalid admin token" } };
22205
+ }
22206
+ if (req.method !== "POST") {
22207
+ return { status: 405, body: { error: "method not allowed" } };
22208
+ }
22209
+ const body = parseJson2(req.bodyText);
22210
+ if (!body || typeof body.method !== "string" || !Array.isArray(body.args)) {
22211
+ return { status: 400, body: { error: "expected {method, args}" } };
22212
+ }
22213
+ if (!isStoreRpcMethod(body.method)) {
22214
+ return { status: 400, body: { error: `unknown store op: ${body.method}` } };
22215
+ }
22216
+ const result = await applyStoreOp(deps.store, body.method, body.args);
22217
+ return { status: 200, body: { result: result ?? null } };
22218
+ }
21803
22219
 
21804
22220
  // src/registry.ts
21805
22221
  var BoxRegistry = class {
@@ -21990,6 +22406,10 @@ var BoxStatusStore = class {
21990
22406
  delete(boxId) {
21991
22407
  this.map.delete(boxId);
21992
22408
  }
22409
+ /** Every box's latest snapshot in one pass (backs `Store.listStatuses`). */
22410
+ list() {
22411
+ return [...this.map.entries()].map(([boxId, status]) => ({ boxId, status }));
22412
+ }
21993
22413
  };
21994
22414
 
21995
22415
  // src/store/memory-store.ts
@@ -22042,6 +22462,9 @@ var MemoryStore = class {
22042
22462
  this.statusStore.delete(boxId);
22043
22463
  return Promise.resolve();
22044
22464
  }
22465
+ listStatuses() {
22466
+ return Promise.resolve(this.statusStore.list());
22467
+ }
22045
22468
  createPrompt(row) {
22046
22469
  this.prompts.set(row.id, { ...row });
22047
22470
  return Promise.resolve();
@@ -22078,6 +22501,11 @@ var MemoryStore = class {
22078
22501
  const job = this.createJobs.get(id);
22079
22502
  return Promise.resolve(job ? { ...job } : null);
22080
22503
  }
22504
+ listCreateJobs(opts) {
22505
+ const wanted = opts?.status;
22506
+ const rows = [...this.createJobs.values()].filter((j) => !wanted || wanted.includes(j.status)).sort((a2, b) => b.createdAt.localeCompare(a2.createdAt)).map((j) => ({ ...j }));
22507
+ return Promise.resolve(opts?.limit ? rows.slice(0, opts.limit) : rows);
22508
+ }
22081
22509
  claimNextCreateJob(workerId) {
22082
22510
  const queued = [...this.createJobs.values()].filter((j) => j.status === "queued").sort((a2, b) => a2.createdAt.localeCompare(b.createdAt));
22083
22511
  const job = queued[0];
@@ -22098,9 +22526,129 @@ var MemoryStore = class {
22098
22526
  }
22099
22527
  };
22100
22528
 
22529
+ // src/store/write-through-store.ts
22530
+ var WriteThroughStore = class {
22531
+ inner;
22532
+ registry;
22533
+ events;
22534
+ statusStore;
22535
+ constructor(inner, parts) {
22536
+ this.inner = inner;
22537
+ this.registry = parts.registry;
22538
+ this.events = parts.events;
22539
+ this.statusStore = parts.statusStore;
22540
+ }
22541
+ /**
22542
+ * Load the durable store's boxes + statuses into the in-memory instances, once
22543
+ * at boot, so the loops start against a populated registry after a restart.
22544
+ * Events are a ring buffer (ephemeral) and are not hydrated.
22545
+ */
22546
+ async hydrate() {
22547
+ for (const reg of await this.inner.listBoxes()) this.registry.register(reg);
22548
+ for (const { boxId, status } of await this.inner.listStatuses()) {
22549
+ const reg = this.registry.get(boxId);
22550
+ await this.statusStore.set(boxId, reg?.name ?? boxId, reg?.projectIndex, status);
22551
+ }
22552
+ }
22553
+ migrate() {
22554
+ return this.inner.migrate?.() ?? Promise.resolve();
22555
+ }
22556
+ // --- boxes ---
22557
+ async registerBox(reg) {
22558
+ await this.inner.registerBox(reg);
22559
+ this.registry.register(reg);
22560
+ }
22561
+ getBox(boxId) {
22562
+ return this.inner.getBox(boxId);
22563
+ }
22564
+ authenticateBox(token) {
22565
+ return this.inner.authenticateBox(token);
22566
+ }
22567
+ listBoxes() {
22568
+ return this.inner.listBoxes();
22569
+ }
22570
+ async forgetBox(boxId) {
22571
+ const existed = await this.inner.forgetBox(boxId);
22572
+ this.registry.forget(boxId);
22573
+ return existed;
22574
+ }
22575
+ countBoxes() {
22576
+ return this.inner.countBoxes();
22577
+ }
22578
+ // --- events ---
22579
+ async appendEvent(input) {
22580
+ const ev = await this.inner.appendEvent(input);
22581
+ this.events.append(input);
22582
+ return ev;
22583
+ }
22584
+ listEvents(since, boxId) {
22585
+ return this.inner.listEvents(since, boxId);
22586
+ }
22587
+ countEvents() {
22588
+ return this.inner.countEvents();
22589
+ }
22590
+ // --- status ---
22591
+ async setStatus(boxId, name, projectIndex, status) {
22592
+ await this.inner.setStatus(boxId, name, projectIndex, status);
22593
+ await this.statusStore.set(boxId, name, projectIndex, status);
22594
+ }
22595
+ getStatus(boxId) {
22596
+ return this.inner.getStatus(boxId);
22597
+ }
22598
+ async deleteStatus(boxId) {
22599
+ await this.inner.deleteStatus(boxId);
22600
+ this.statusStore.delete(boxId);
22601
+ }
22602
+ listStatuses() {
22603
+ return this.inner.listStatuses();
22604
+ }
22605
+ // --- prompt mailbox (pure delegation; no in-memory mirror the loops read) ---
22606
+ createPrompt(row) {
22607
+ return this.inner.createPrompt(row);
22608
+ }
22609
+ getPrompt(promptId) {
22610
+ return this.inner.getPrompt(promptId);
22611
+ }
22612
+ answerPrompt(promptId, answer, cancelled) {
22613
+ return this.inner.answerPrompt(promptId, answer, cancelled);
22614
+ }
22615
+ listPendingPrompts(boxId) {
22616
+ return this.inner.listPendingPrompts(boxId);
22617
+ }
22618
+ setPromptResult(promptId, result) {
22619
+ return this.inner.setPromptResult(promptId, result);
22620
+ }
22621
+ // --- box-create job queue (pure delegation) ---
22622
+ enqueueCreateJob(job) {
22623
+ if (!this.inner.enqueueCreateJob) return Promise.resolve();
22624
+ return this.inner.enqueueCreateJob(job);
22625
+ }
22626
+ getCreateJob(id) {
22627
+ return this.inner.getCreateJob?.(id) ?? Promise.resolve(null);
22628
+ }
22629
+ listCreateJobs(opts) {
22630
+ return this.inner.listCreateJobs?.(opts) ?? Promise.resolve([]);
22631
+ }
22632
+ claimNextCreateJob(workerId) {
22633
+ return this.inner.claimNextCreateJob?.(workerId) ?? Promise.resolve(null);
22634
+ }
22635
+ completeCreateJob(id, status, result) {
22636
+ if (!this.inner.completeCreateJob) return Promise.resolve();
22637
+ return this.inner.completeCreateJob(id, status, result);
22638
+ }
22639
+ // --- retention (forwarded; blocker B) ---
22640
+ prunePrompts(beforeIso) {
22641
+ return this.inner.prunePrompts?.(beforeIso) ?? Promise.resolve(0);
22642
+ }
22643
+ pruneCreateJobs(beforeIso) {
22644
+ return this.inner.pruneCreateJobs?.(beforeIso) ?? Promise.resolve(0);
22645
+ }
22646
+ };
22647
+
22101
22648
  // src/server.ts
22102
22649
  var BOX_STATUS_EVENT = "box-status";
22103
22650
  var MAX_BODY_BYTES = 1024 * 1024;
22651
+ var DEFAULT_CUSTODY_MAX_BODY_BYTES = 32 * 1024 * 1024;
22104
22652
  var GIT_RPC_TIMEOUT_MS = 12e4;
22105
22653
  var CHECKPOINT_RPC_TIMEOUT_MS = 6e5;
22106
22654
  var DOWNLOAD_RPC_TIMEOUT_MS = 6e5;
@@ -22147,6 +22695,23 @@ async function readJsonBody(req) {
22147
22695
  req.on("error", reject);
22148
22696
  });
22149
22697
  }
22698
+ async function readRawBody(req, maxBytes = MAX_BODY_BYTES) {
22699
+ return new Promise((resolve4, reject) => {
22700
+ let total = 0;
22701
+ const chunks = [];
22702
+ req.on("data", (chunk) => {
22703
+ total += chunk.length;
22704
+ if (total > maxBytes) {
22705
+ reject(new Error("request body too large"));
22706
+ req.destroy();
22707
+ return;
22708
+ }
22709
+ chunks.push(chunk);
22710
+ });
22711
+ req.on("end", () => resolve4(Buffer.concat(chunks).toString("utf8")));
22712
+ req.on("error", reject);
22713
+ });
22714
+ }
22150
22715
  function bearerToken(req) {
22151
22716
  const raw = req.headers.authorization;
22152
22717
  if (typeof raw !== "string") return "";
@@ -22168,7 +22733,7 @@ function createRelayServer(opts) {
22168
22733
  const notices = new BoxNotices(subscribers);
22169
22734
  const hubNotifier = new HubNotifier();
22170
22735
  prompts.setOnChange(() => hubNotifier.notify());
22171
- const store = opts.store ?? new MemoryStore({ registry, events, statusStore });
22736
+ const store = opts.store ? new WriteThroughStore(opts.store, { registry, events, statusStore }) : new MemoryStore({ registry, events, statusStore });
22172
22737
  prompts.setAutoApprovePolicy({
22173
22738
  shouldAutoApprove: (boxId) => registry.get(boxId)?.autoApproveHostActions === true,
22174
22739
  audit: (boxId, params, reason) => {
@@ -22201,6 +22766,9 @@ function createRelayServer(opts) {
22201
22766
  const gateDeps = { mode: promptMode, store, prompts, subscribers };
22202
22767
  const githubAppConfig = opts.githubApp === void 0 ? loadGitHubAppConfig() : opts.githubApp;
22203
22768
  const leaser = githubAppConfig ? new GitHubAppLeaser(githubAppConfig) : null;
22769
+ const custody = opts.custody ?? null;
22770
+ const custodyAdminToken = opts.adminToken ?? "";
22771
+ const custodyMaxBodyBytes = typeof opts.custodyMaxBodyBytes === "number" && opts.custodyMaxBodyBytes > 0 ? opts.custodyMaxBodyBytes : DEFAULT_CUSTODY_MAX_BODY_BYTES;
22204
22772
  const uiHandler = opts.uiHandler;
22205
22773
  let pollers = null;
22206
22774
  async function getPollers() {
@@ -22290,12 +22858,62 @@ function createRelayServer(opts) {
22290
22858
  send(res, 404, { error: "not found", route });
22291
22859
  return;
22292
22860
  }
22861
+ if (url.pathname === "/admin/custody" || url.pathname.startsWith("/admin/custody/")) {
22862
+ const bodyText = req.method === "PUT" || req.method === "POST" ? await readRawBody(req, custodyMaxBodyBytes) : "";
22863
+ const custodyRes = await handleCustodyRequest(
22864
+ {
22865
+ method: req.method ?? "GET",
22866
+ path: url.pathname,
22867
+ query: url.searchParams,
22868
+ bearer: bearerToken(req),
22869
+ bodyText
22870
+ },
22871
+ { custody, adminToken: custodyAdminToken, log }
22872
+ );
22873
+ if (custodyRes) {
22874
+ send(res, custodyRes.status, custodyRes.body ?? null);
22875
+ return;
22876
+ }
22877
+ }
22878
+ if (isRemoteBoxesPath(url.pathname)) {
22879
+ const bodyText = req.method === "POST" ? await readRawBody(req) : "";
22880
+ const remoteRes = await handleRemoteBoxesRequest(
22881
+ {
22882
+ method: req.method ?? "GET",
22883
+ path: url.pathname,
22884
+ bearer: bearerToken(req),
22885
+ bodyText
22886
+ },
22887
+ { store, adminToken: custodyAdminToken, custody, log }
22888
+ );
22889
+ if (remoteRes) {
22890
+ send(res, remoteRes.status, remoteRes.body ?? null);
22891
+ return;
22892
+ }
22893
+ }
22894
+ if (isStoreRpcPath(url.pathname)) {
22895
+ const bodyText = req.method === "POST" ? await readRawBody(req) : "";
22896
+ const storeRpcRes = await handleStoreRpcRequest(
22897
+ {
22898
+ method: req.method ?? "GET",
22899
+ path: url.pathname,
22900
+ bearer: bearerToken(req),
22901
+ bodyText
22902
+ },
22903
+ { store, adminToken: custodyAdminToken, log }
22904
+ );
22905
+ if (storeRpcRes) {
22906
+ send(res, storeRpcRes.status, storeRpcRes.body ?? null);
22907
+ return;
22908
+ }
22909
+ }
22293
22910
  if (url.pathname.startsWith("/admin/") || url.pathname.startsWith("/remote/")) {
22294
22911
  if (url.pathname.startsWith("/remote/")) {
22295
22912
  send(res, 404, { error: "not found", route });
22296
22913
  return;
22297
22914
  }
22298
- if (!isLoopbackAddress(req.socket.remoteAddress)) {
22915
+ const loopback = isLoopbackAddress(req.socket.remoteAddress);
22916
+ if (!adminGateAllows(loopback, bearerToken(req), custodyAdminToken)) {
22299
22917
  send(res, 403, { error: "admin endpoints are loopback-only" });
22300
22918
  return;
22301
22919
  }
@@ -22732,6 +23350,7 @@ function createRelayServer(opts) {
22732
23350
  name: body.name,
22733
23351
  kind,
22734
23352
  backend: typeof body.backend === "string" && body.backend.length > 0 ? body.backend : void 0,
23353
+ sandboxId: typeof body.sandboxId === "string" && body.sandboxId.length > 0 ? body.sandboxId : void 0,
22735
23354
  registeredAt: (/* @__PURE__ */ new Date()).toISOString(),
22736
23355
  containerName: typeof body.containerName === "string" && body.containerName.length > 0 ? body.containerName : void 0,
22737
23356
  createdAt: typeof body.createdAt === "string" && body.createdAt.length > 0 ? body.createdAt : void 0,
@@ -22744,7 +23363,12 @@ function createRelayServer(opts) {
22744
23363
  // Default on: only an explicit `false` disables the safe subset, so an
22745
23364
  // older wire body without the field stays relaxed.
22746
23365
  autoApproveSafeHostActions: body.autoApproveSafeHostActions !== false,
22747
- originUrl: typeof body.originUrl === "string" && body.originUrl.length > 0 ? body.originUrl : void 0
23366
+ originUrl: typeof body.originUrl === "string" && body.originUrl.length > 0 ? body.originUrl : void 0,
23367
+ publicHost: typeof body.publicHost === "string" && body.publicHost.length > 0 ? body.publicHost : void 0,
23368
+ image: typeof body.image === "string" && body.image.length > 0 ? body.image : void 0,
23369
+ webPort: typeof body.webPort === "number" && Number.isFinite(body.webPort) && body.webPort > 0 ? Math.trunc(body.webPort) : void 0,
23370
+ agent: typeof body.agent === "string" && body.agent.length > 0 ? body.agent : void 0,
23371
+ projectSlug: typeof body.projectSlug === "string" && body.projectSlug.length > 0 ? body.projectSlug : void 0
22748
23372
  };
22749
23373
  await store.registerBox(reg);
22750
23374
  log(
@@ -23044,6 +23668,7 @@ data: {"ts":"${(/* @__PURE__ */ new Date()).toISOString()}"}
23044
23668
  subscribers,
23045
23669
  notices,
23046
23670
  hubNotifier,
23671
+ custody,
23047
23672
  hostActions: hostActions ?? void 0,
23048
23673
  url: `http://${host}:${String(opts.port)}`,
23049
23674
  setQueuePoke: (fn) => {
@@ -23127,6 +23752,10 @@ async function handleGitRpc(reg, method, params) {
23127
23752
  stderr: `no worktree registered for box ${reg.boxId} matching ${containerPath}`
23128
23753
  };
23129
23754
  }
23755
+ const unavailable = hostRepoUnavailableReason(worktree, reg.boxId, method);
23756
+ if (unavailable) {
23757
+ return { exitCode: 64, stdout: "", stderr: unavailable };
23758
+ }
23130
23759
  const op = method === "git.push" ? "push" : "fetch";
23131
23760
  const remote = resolveRemote(params?.remote);
23132
23761
  const pushBranch = worktree.sanctionedBranch ?? worktree.branch;
@@ -23469,6 +24098,7 @@ relay: command timed out after ${String(timeoutMs)}ms
23469
24098
  }
23470
24099
  async function startRelayServer(opts) {
23471
24100
  const handle = createRelayServer(opts);
24101
+ if (handle.store instanceof WriteThroughStore) await handle.store.hydrate();
23472
24102
  await new Promise((resolve4, reject) => {
23473
24103
  handle.server.once("error", reject);
23474
24104
  handle.server.listen(opts.port, opts.host ?? "0.0.0.0", () => {
@@ -23485,9 +24115,9 @@ var import_promises23 = require("fs/promises");
23485
24115
 
23486
24116
  // src/queue.ts
23487
24117
  var import_node_child_process9 = require("child_process");
23488
- var import_node_crypto7 = require("crypto");
24118
+ var import_node_crypto13 = require("crypto");
23489
24119
  var import_promises21 = require("fs/promises");
23490
- var import_node_fs6 = require("fs");
24120
+ var import_node_fs7 = require("fs");
23491
24121
  var import_node_path8 = require("path");
23492
24122
  var import_promises22 = require("timers/promises");
23493
24123
  var QUEUE_DIR = (0, import_node_path8.join)(STATE_DIR, "queue");
@@ -23948,13 +24578,13 @@ function inspectDockerState(containerName) {
23948
24578
  }
23949
24579
  async function defaultSpawnWorker(job) {
23950
24580
  const entry = process.env.AGENTBOX_CLI_ENTRY;
23951
- if (!entry || !(0, import_node_fs6.existsSync)(entry)) {
24581
+ if (!entry || !(0, import_node_fs7.existsSync)(entry)) {
23952
24582
  throw new Error(
23953
24583
  `AGENTBOX_CLI_ENTRY not set or missing (${String(entry)}); cannot spawn queue worker`
23954
24584
  );
23955
24585
  }
23956
24586
  await (0, import_promises21.mkdir)((0, import_node_path8.join)(STATE_DIR, "logs"), { recursive: true });
23957
- const fd = (0, import_node_fs6.openSync)(job.logPath, "a");
24587
+ const fd = (0, import_node_fs7.openSync)(job.logPath, "a");
23958
24588
  const command = job.kind === "prepare" ? "_run-queued-prepare" : "_run-queued-job";
23959
24589
  const child = (0, import_node_child_process9.spawn)(process.execPath, [entry, command, job.id], {
23960
24590
  detached: true,
@@ -23964,7 +24594,7 @@ async function defaultSpawnWorker(job) {
23964
24594
  });
23965
24595
  child.unref();
23966
24596
  try {
23967
- (0, import_node_fs6.closeSync)(fd);
24597
+ (0, import_node_fs7.closeSync)(fd);
23968
24598
  } catch {
23969
24599
  }
23970
24600
  return typeof child.pid === "number" ? child.pid : null;
@@ -24392,6 +25022,51 @@ async function defaultFallbackCreateTimeoutMs(backend) {
24392
25022
  }
24393
25023
  }
24394
25024
 
25025
+ // src/retention.ts
25026
+ var DEFAULT_RETENTION_MS = 24 * 60 * 6e4;
25027
+ var DEFAULT_INTERVAL_MS4 = 60 * 6e4;
25028
+ function startRetentionLoop(deps) {
25029
+ const { store, log } = deps;
25030
+ const retentionMs = deps.retentionMs ?? DEFAULT_RETENTION_MS;
25031
+ const intervalMs = deps.intervalMs ?? DEFAULT_INTERVAL_MS4;
25032
+ const nowFn = deps.now ?? Date.now;
25033
+ if (!store.prunePrompts && !store.pruneCreateJobs) {
25034
+ return { stop: () => Promise.resolve() };
25035
+ }
25036
+ let ticking = false;
25037
+ let stopped = false;
25038
+ let inFlight = Promise.resolve();
25039
+ async function tick() {
25040
+ if (ticking) return;
25041
+ ticking = true;
25042
+ try {
25043
+ const before = new Date(nowFn() - retentionMs).toISOString();
25044
+ const prompts = await store.prunePrompts?.(before) ?? 0;
25045
+ const jobs = await store.pruneCreateJobs?.(before) ?? 0;
25046
+ if (prompts > 0 || jobs > 0) {
25047
+ log(`retention: pruned ${String(prompts)} prompt(s), ${String(jobs)} create job(s)`);
25048
+ }
25049
+ } catch (err) {
25050
+ log(`retention: tick error: ${err instanceof Error ? err.message : String(err)}`);
25051
+ } finally {
25052
+ ticking = false;
25053
+ }
25054
+ }
25055
+ const timer = setInterval(() => {
25056
+ if (stopped) return;
25057
+ inFlight = tick();
25058
+ }, intervalMs);
25059
+ timer.unref();
25060
+ return {
25061
+ stop: async () => {
25062
+ stopped = true;
25063
+ clearInterval(timer);
25064
+ await inFlight.catch(() => {
25065
+ });
25066
+ }
25067
+ };
25068
+ }
25069
+
24395
25070
  // src/daemon.ts
24396
25071
  async function startRelayDaemon(opts) {
24397
25072
  const handle = await startRelayServer(opts);
@@ -24417,13 +25092,19 @@ async function startRelayDaemon(opts) {
24417
25092
  // then transitions creating → running without waiting for the 15s SSE ping.
24418
25093
  onStatusChange: () => handle.hubNotifier.notify()
24419
25094
  });
25095
+ const retention = startRetentionLoop({ store: handle.store, log });
24420
25096
  handle.setQueuePoke(() => {
24421
25097
  queue.poke?.();
24422
25098
  });
24423
25099
  return {
24424
25100
  handle,
24425
25101
  stop: async () => {
24426
- await Promise.allSettled([autopause.stop(), cloudKeepalive.stop(), queue.stop()]);
25102
+ await Promise.allSettled([
25103
+ autopause.stop(),
25104
+ cloudKeepalive.stop(),
25105
+ queue.stop(),
25106
+ retention.stop()
25107
+ ]);
24427
25108
  await handle.close();
24428
25109
  }
24429
25110
  };