deepline 0.3.542 → 0.3.544

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 (246) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +112 -2
  2. package/dist/bundling-sources/sdk/src/index.ts +7 -0
  3. package/dist/bundling-sources/sdk/src/integrations.ts +198 -0
  4. package/dist/bundling-sources/sdk/src/plays/run-request.ts +3 -0
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/tool-calls.ts +35 -11
  7. package/dist/bundling-sources/sdk/src/types.ts +10 -0
  8. package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +132 -0
  9. package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +3 -1
  10. package/dist/bundling-sources/shared_libs/integration-contracts/tool-connection.ts +13 -0
  11. package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +108 -1
  12. package/dist/bundling-sources/shared_libs/monitors/package.json +1 -1
  13. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
  14. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  15. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +5 -5
  16. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +34 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +11 -5
  18. package/dist/bundling-sources/shared_libs/play-runtime/baked-runner-image.ts +9 -7
  19. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +235 -12
  20. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +20 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +39 -30
  22. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +29 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/event-wait-tools.ts +2 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +10 -4
  25. package/dist/bundling-sources/shared_libs/play-runtime/fleet-sandbox-sweep.ts +209 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +4 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +24 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +2 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +6 -1
  30. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +37 -0
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +43 -3
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +7 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +15 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +23 -5
  35. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +320 -836
  36. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/vercel-sandbox.ts +1061 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +862 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +45 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/sandbox-create-outcome.ts +3 -1
  40. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +11 -5
  41. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-contract.ts +20 -2
  42. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-placement-policy.ts +71 -34
  43. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-provider-profile.ts +286 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +4 -1
  45. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +12 -3
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +7 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +49 -55
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +127 -5
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +7 -1
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +214 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/managed-sandbox-resource-sql.ts +118 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +1 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +229 -144
  54. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +2 -2
  55. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +2 -1
  56. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +11 -13
  57. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +42 -7
  58. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +2 -1
  59. package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +2 -2
  60. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +17 -0
  61. package/dist/bundling-sources/shared_libs/play-runtime/vercel-sandbox-runtime-config.ts +217 -0
  62. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +23 -0
  63. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +1 -0
  64. package/dist/bundling-sources/shared_libs/plays/script-entry.ts +76 -6
  65. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +1 -0
  66. package/dist/bundling-sources/shared_libs/security/credential-revision.ts +50 -0
  67. package/dist/bundling-sources/shared_libs/security/internal-actor.ts +2 -1
  68. package/dist/bundling-sources/shared_libs/security/receipt-admission-token.ts +37 -0
  69. package/dist/cli/auth-ENBXAKQS.js +43 -0
  70. package/dist/cli/{auth-IGBGOB4E.mjs → auth-IMWJAHPU.mjs} +5 -5
  71. package/dist/cli/{billing-IB2TWE74.js → billing-Y55PR2PV.js} +101 -101
  72. package/dist/cli/{billing-N37W2I62.mjs → billing-YQMW3QJI.mjs} +12 -12
  73. package/dist/cli/chunk-22OBDYHP.js +455 -0
  74. package/dist/cli/{chunk-GBAT5NMI.mjs → chunk-2HSZCQMT.mjs} +48 -6
  75. package/dist/cli/{chunk-VLEVVDWG.js → chunk-2JHYYB3F.js} +3 -3
  76. package/dist/cli/{chunk-D44DP4KJ.js → chunk-3I26HMJ7.js} +37 -17
  77. package/dist/cli/{chunk-B5NP3SHX.mjs → chunk-3JDA23NN.mjs} +2 -2
  78. package/dist/cli/{chunk-QXNOSCYL.js → chunk-3KGMM4KS.js} +1 -1
  79. package/dist/cli/{chunk-6WQDHEVF.mjs → chunk-456RRXAP.mjs} +5 -5
  80. package/dist/cli/{chunk-V4EYJKGJ.js → chunk-4JQEAYN3.js} +156 -17
  81. package/dist/cli/{chunk-FGGPCAGC.js → chunk-4PKHFW56.js} +18 -18
  82. package/dist/cli/{chunk-QONO7FRF.mjs → chunk-57G4NYOL.mjs} +1 -1
  83. package/dist/cli/{chunk-46V7QSJE.mjs → chunk-5PR4VLLL.mjs} +3 -3
  84. package/dist/cli/{chunk-OLH2PHMC.mjs → chunk-6P7TGCHQ.mjs} +1 -1
  85. package/dist/cli/{chunk-AKY7KZRJ.js → chunk-7GNZEOTH.js} +6 -6
  86. package/dist/cli/{chunk-LFMQVSEI.js → chunk-7HMMTSDA.js} +5 -5
  87. package/dist/cli/{chunk-ORA5TMML.mjs → chunk-BEQ7RQLT.mjs} +5 -5
  88. package/dist/cli/{chunk-KQSTV4MW.js → chunk-BLYW6FFB.js} +60 -18
  89. package/dist/cli/{chunk-GM73TZ2W.js → chunk-C4P2KLWT.js} +41 -41
  90. package/dist/cli/{chunk-DNGACHFX.js → chunk-COJHT2KF.js} +22 -22
  91. package/dist/cli/{chunk-6SLEHAXX.js → chunk-DF2X7GJG.js} +5 -5
  92. package/dist/cli/{chunk-TT4JUUC3.mjs → chunk-DVDWAC2M.mjs} +7 -3
  93. package/dist/cli/{chunk-5CAVURVS.js → chunk-DYDHLBSK.js} +53 -53
  94. package/dist/cli/{chunk-UNDLNT3V.js → chunk-ECWOIXAV.js} +1 -1
  95. package/dist/cli/{chunk-EHLCWGWN.js → chunk-G26VJCNT.js} +4 -4
  96. package/dist/cli/{chunk-WL2GUGNZ.js → chunk-GQHRGBHV.js} +7 -7
  97. package/dist/cli/{chunk-DADH3WPE.mjs → chunk-GV45TTI6.mjs} +2 -2
  98. package/dist/cli/{chunk-OVX3Q5Q3.mjs → chunk-GWNYLIF7.mjs} +1 -1
  99. package/dist/cli/{chunk-EGOCGWCI.mjs → chunk-H4SAHB3Q.mjs} +3 -3
  100. package/dist/cli/{chunk-FX4OWXKK.mjs → chunk-HAQRF6DJ.mjs} +2 -2
  101. package/dist/cli/{chunk-NLZHLEHD.mjs → chunk-HBSWATOU.mjs} +6 -6
  102. package/dist/cli/{chunk-ACVTMAW4.mjs → chunk-HVJQF5BI.mjs} +2 -2
  103. package/dist/cli/{chunk-L2VKAASU.mjs → chunk-HXIR3VQL.mjs} +21 -0
  104. package/dist/cli/{chunk-Z5YRKX7K.mjs → chunk-HXM2JUGD.mjs} +1 -1
  105. package/dist/cli/{chunk-JPT6VE54.js → chunk-IFIJ4DBJ.js} +2 -2
  106. package/dist/cli/{chunk-HAITCPCG.js → chunk-JBWOE6AP.js} +16 -16
  107. package/dist/cli/{chunk-AWLPERL3.js → chunk-JWVG7ZPX.js} +3 -3
  108. package/dist/cli/{chunk-3XXXMSSP.js → chunk-KE6CSCUF.js} +44 -44
  109. package/dist/cli/{chunk-2ZGSHVZE.mjs → chunk-LPUBBUKX.mjs} +24 -4
  110. package/dist/cli/{chunk-PLIKPGOO.mjs → chunk-LQ6RRYXN.mjs} +5 -5
  111. package/dist/cli/{chunk-FFDZT255.mjs → chunk-LW274RO7.mjs} +1 -1
  112. package/dist/cli/{chunk-Z2XA6YU4.mjs → chunk-LX35AXTN.mjs} +1 -0
  113. package/dist/cli/{chunk-FANIRW74.mjs → chunk-NIPLY25A.mjs} +0 -2
  114. package/dist/cli/{chunk-VHJUH3TB.js → chunk-ON56ISO6.js} +3 -3
  115. package/dist/cli/{chunk-4I47NCRI.js → chunk-PDJ4UDCO.js} +498 -328
  116. package/dist/cli/{chunk-SWO5QOXB.mjs → chunk-PFGOCUH3.mjs} +1 -1
  117. package/dist/cli/{chunk-Q7WDXLYO.js → chunk-PKRW76XG.js} +2 -2
  118. package/dist/cli/{chunk-YK7NNZD4.mjs → chunk-PMW5YP72.mjs} +37 -190
  119. package/dist/cli/{chunk-5APOJWJF.mjs → chunk-Q7ZOWNKR.mjs} +183 -13
  120. package/dist/cli/{chunk-WACIN4PR.mjs → chunk-REEOMNCO.mjs} +3 -3
  121. package/dist/cli/{chunk-DMXLZ57N.js → chunk-RG34YBDE.js} +2 -2
  122. package/dist/cli/{chunk-3LEUSRV3.mjs → chunk-RJPDCSTD.mjs} +4 -4
  123. package/dist/cli/{chunk-IPVRMYWT.js → chunk-RKF263LR.js} +5 -5
  124. package/dist/cli/{chunk-AUFE624T.js → chunk-RUFR4PUO.js} +10 -10
  125. package/dist/cli/{chunk-I5EAIFGO.mjs → chunk-SK3HPU2J.mjs} +1 -1
  126. package/dist/cli/{chunk-ZVNYBQ77.mjs → chunk-SKS53WM6.mjs} +4 -4
  127. package/dist/cli/{chunk-CQDQNZGH.js → chunk-SL6MYJYM.js} +1 -0
  128. package/dist/cli/{chunk-E4CABWXL.js → chunk-TI6DTURF.js} +22 -1
  129. package/dist/cli/{chunk-CFZCRM6R.js → chunk-UHIAQPVA.js} +26 -26
  130. package/dist/cli/{chunk-D7GWEBMF.js → chunk-UNMNGRPB.js} +7 -7
  131. package/dist/cli/{chunk-GWHA4DAC.js → chunk-UV4RU2TE.js} +0 -2
  132. package/dist/cli/{chunk-TTBHOMAA.js → chunk-W7X4KH45.js} +316 -469
  133. package/dist/cli/chunk-WBSGPLH5.mjs +455 -0
  134. package/dist/cli/{chunk-SCLP5H4P.mjs → chunk-WUEORIOY.mjs} +1 -1
  135. package/dist/cli/{chunk-IDDKNMFX.mjs → chunk-Y3T5GWYK.mjs} +153 -14
  136. package/dist/cli/{chunk-P4MDTBAA.mjs → chunk-YIRVKMON.mjs} +1 -1
  137. package/dist/cli/{chunk-NDNEARE3.js → chunk-Z44YTSTA.js} +13 -13
  138. package/dist/cli/{chunk-F6QV42MC.mjs → chunk-Z7SXGOIQ.mjs} +1 -1
  139. package/dist/cli/{chunk-2VRKBHMD.mjs → chunk-ZHY4T5M6.mjs} +1 -1
  140. package/dist/cli/{chunk-E7B73LGT.js → chunk-ZY6FL4O4.js} +24 -20
  141. package/dist/cli/command-docs.js +3 -3
  142. package/dist/cli/command-docs.mjs +2 -2
  143. package/dist/cli/{concurrent-runs-help-DIBGMEIN.mjs → concurrent-runs-help-KBWPKSTP.mjs} +7 -7
  144. package/dist/cli/concurrent-runs-help-TOMLCMV7.js +21 -0
  145. package/dist/cli/{csv-CAVA3EMS.mjs → csv-M5EBEMZH.mjs} +4 -4
  146. package/dist/cli/{csv-XZAM7EYZ.js → csv-XGGDZTQI.js} +13 -13
  147. package/dist/cli/{db-PPGEOBNG.js → db-CVPR54XK.js} +29 -29
  148. package/dist/cli/{db-HD332QI7.mjs → db-M6FJ6J6E.mjs} +8 -8
  149. package/dist/cli/describe-RUODIS6M.js +50 -0
  150. package/dist/cli/describe-X6QA2U3C.mjs +50 -0
  151. package/dist/cli/describe-core.d.mts +3 -3
  152. package/dist/cli/describe-core.d.ts +3 -3
  153. package/dist/cli/describe-core.js +3 -3
  154. package/dist/cli/describe-core.mjs +2 -2
  155. package/dist/cli/{executions-AFEOLB4A.mjs → executions-EHTS2XJX.mjs} +8 -8
  156. package/dist/cli/{executions-4ZKBL7IC.js → executions-VJEEWN22.js} +10 -10
  157. package/dist/cli/{feedback-J2YPLKMF.mjs → feedback-76VGY4GP.mjs} +6 -6
  158. package/dist/cli/{feedback-M6Y33JKT.js → feedback-DQPUCUXO.js} +14 -14
  159. package/dist/cli/{git-632RYEF6.mjs → git-IY6DKKLR.mjs} +5 -5
  160. package/dist/cli/git-RLHTSYRY.js +25 -0
  161. package/dist/cli/index.js +150 -146
  162. package/dist/cli/index.mjs +49 -45
  163. package/dist/cli/integrations-242LE3TQ.mjs +98 -0
  164. package/dist/cli/integrations-CQSTIKFY.js +98 -0
  165. package/dist/cli/{legacy-noops-KWZMXYAU.mjs → legacy-noops-SWTSTMRY.mjs} +6 -6
  166. package/dist/cli/{legacy-noops-4Y62TKPC.js → legacy-noops-U72DO6ZF.js} +9 -9
  167. package/dist/cli/{mcp-PESLHAAC.mjs → mcp-JJH6JR52.mjs} +72 -15
  168. package/dist/cli/{mcp-35QA6YG7.js → mcp-L473BKLJ.js} +89 -32
  169. package/dist/cli/{monitors-4DTUZLAI.js → monitors-3TF2DOFD.js} +119 -104
  170. package/dist/cli/{monitors-YVBKBJBU.mjs → monitors-VSYHUBKC.mjs} +26 -11
  171. package/dist/cli/{org-DJNKMFCZ.mjs → org-S5VIKU2E.mjs} +8 -8
  172. package/dist/cli/{org-FWCBZMER.js → org-YKVI2ZTI.js} +90 -90
  173. package/dist/cli/{play-PHVQEEEZ.mjs → play-C7T5A3QM.mjs} +44 -25
  174. package/dist/cli/{play-FZ45M4KD.js → play-DOWEG45Y.js} +374 -355
  175. package/dist/cli/{providers-46E67QG7.mjs → providers-BMVVX3VD.mjs} +10 -9
  176. package/dist/cli/{providers-QJU6FMDD.js → providers-TAZPPFTB.js} +13 -12
  177. package/dist/cli/{quickstart-6HMJJ4RR.mjs → quickstart-A3WKMKTW.mjs} +4 -4
  178. package/dist/cli/{quickstart-HOL7H5FS.js → quickstart-HD6FQXGR.js} +6 -6
  179. package/dist/cli/{run-WKSIRXEC.js → run-BVVV2UX7.js} +49 -48
  180. package/dist/cli/{run-2W2TJ6QA.mjs → run-FV7TWNOC.mjs} +28 -27
  181. package/dist/cli/{search-Y2CFLSYB.mjs → search-MGK6WIKS.mjs} +9 -9
  182. package/dist/cli/search-VJFCWUZN.js +32 -0
  183. package/dist/cli/{search-output-2IK6ZZDY.js → search-output-6Y7KEPIE.js} +6 -6
  184. package/dist/cli/{search-output-FCZ35PHF.mjs → search-output-GM7LDZKE.mjs} +4 -4
  185. package/dist/cli/{secrets-PNPNUZLX.mjs → secrets-4RFAR7YI.mjs} +8 -8
  186. package/dist/cli/{secrets-JVJIHGU4.js → secrets-SISXIXSZ.js} +17 -17
  187. package/dist/cli/{sessions-GY5VVQGO.mjs → sessions-CE3OMEG7.mjs} +6 -6
  188. package/dist/cli/sessions-OWWZJZXH.js +22 -0
  189. package/dist/cli/{settings-5WHMFRNQ.js → settings-4HPM3K4A.js} +89 -89
  190. package/dist/cli/{settings-YQOPF3AI.mjs → settings-E22IDSX2.mjs} +16 -16
  191. package/dist/cli/{setup-3VJMKDEU.js → setup-BDRSNLKX.js} +49 -49
  192. package/dist/cli/{setup-O5U5IEVW.mjs → setup-BK65MDZ6.mjs} +9 -9
  193. package/dist/cli/{skills-G6J5PF35.mjs → skills-FI2GZMR4.mjs} +7 -7
  194. package/dist/cli/skills-ZLBFUAFR.js +36 -0
  195. package/dist/cli/tools-3K72VE33.js +57 -0
  196. package/dist/cli/{tools-AG7SWL5Y.mjs → tools-HMMWYUNW.mjs} +20 -19
  197. package/dist/cli/update-QZV6DH5V.js +34 -0
  198. package/dist/cli/{update-K73DD6CR.mjs → update-WDKBSXV5.mjs} +9 -9
  199. package/dist/cli/{views-4D2OTLIO.js → views-775AUDWQ.js} +23 -23
  200. package/dist/cli/{views-MO6DIOMR.mjs → views-JYIJCO23.mjs} +8 -8
  201. package/dist/cli/{workflow-ZEMFCS4Y.js → workflow-4H6KQRFQ.js} +19 -19
  202. package/dist/cli/{workflow-MMZMAELI.mjs → workflow-FKKHE3IU.mjs} +9 -9
  203. package/dist/{client-DLG9mHDh.d.mts → client-ANT3pyoa.d.mts} +1 -1
  204. package/dist/{client-X-FJD5Dp.d.ts → client-DD_FyJVd.d.ts} +1 -1
  205. package/dist/{client-core-WtnqyBwY.d.mts → client-core-Dg9tKhdB.d.mts} +339 -3
  206. package/dist/{client-core-0jmHfFBv.d.ts → client-core-QHmo73k1.d.ts} +339 -3
  207. package/dist/{compiler-manifest-Cys06iYg.d.mts → compiler-manifest-BWFtsQIC.d.mts} +21 -0
  208. package/dist/{compiler-manifest-Cys06iYg.d.ts → compiler-manifest-BWFtsQIC.d.ts} +21 -0
  209. package/dist/{errors-B6eMjKcr.d.mts → errors-CwKXXtuu.d.mts} +1 -1
  210. package/dist/{errors-rdOUqcU2.d.ts → errors-Lm9_vJHZ.d.ts} +1 -1
  211. package/dist/{index-ejWadAL5.d.ts → index-3vJ-V9yw.d.ts} +1 -1
  212. package/dist/{index-CZdYO81A.d.mts → index-DjwsAt82.d.mts} +1 -1
  213. package/dist/index.d.mts +7 -7
  214. package/dist/index.d.ts +7 -7
  215. package/dist/index.js +12 -12
  216. package/dist/index.mjs +8 -8
  217. package/dist/install-integrity.json +147 -133
  218. package/dist/plays/bundle-play-file.d.mts +3 -3
  219. package/dist/plays/bundle-play-file.d.ts +3 -3
  220. package/dist/plays/bundle-play-file.mjs +23 -4
  221. package/dist/plays/play-description.d.mts +2 -2
  222. package/dist/plays/play-description.d.ts +2 -2
  223. package/dist/plays/run-request.d.mts +2 -2
  224. package/dist/plays/run-request.d.ts +2 -2
  225. package/dist/plays/run-request.js +2 -2
  226. package/dist/plays/run-request.mjs +1 -1
  227. package/dist/release.d.mts +1 -1
  228. package/dist/release.d.ts +1 -1
  229. package/dist/release.js +2 -2
  230. package/dist/release.mjs +1 -1
  231. package/dist/server.d.mts +4 -4
  232. package/dist/server.d.ts +4 -4
  233. package/dist/server.js +7 -7
  234. package/dist/server.mjs +5 -5
  235. package/package.json +1 -1
  236. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal-resource-usage.ts +0 -222
  237. package/dist/cli/auth-2PH6RSKL.js +0 -43
  238. package/dist/cli/concurrent-runs-help-BNIDBKML.js +0 -21
  239. package/dist/cli/describe-5TFFB2PM.js +0 -49
  240. package/dist/cli/describe-THQU7N47.mjs +0 -49
  241. package/dist/cli/git-AQLQYWRI.js +0 -25
  242. package/dist/cli/search-YLJFCJTK.js +0 -32
  243. package/dist/cli/sessions-TZ33UCPS.js +0 -22
  244. package/dist/cli/skills-WZY3XDT3.js +0 -36
  245. package/dist/cli/tools-BXQBL72Q.js +0 -56
  246. package/dist/cli/update-XYP5EII6.js +0 -34
@@ -0,0 +1,1061 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import type { Sandbox as VercelSandbox } from '@vercel/sandbox';
3
+ import type { PlayRunnerBackend, PlayRunnerCallbacks } from '../types';
4
+ import {
5
+ isRuntimeSandboxCapacityLimitError,
6
+ RuntimeResourceFenceLostError,
7
+ SandboxRunnerPreCodeDeferralError,
8
+ } from '../types';
9
+ import { buildPlayRunnerBundle } from '../bundle';
10
+ import { findPlayRunnerResult, parsePlayRunnerEvents } from '../runner-events';
11
+ import { logSandboxCreateOutcome } from '../sandbox-create-outcome';
12
+ import type {
13
+ PlayRunnerExecutionConfig,
14
+ PlayRunnerResult,
15
+ } from '../../protocol';
16
+ import { PLAY_RUNNER_TERMINAL_GRACE_SECONDS } from '../../runtime-constants';
17
+ import {
18
+ isPlayRunRecoveryError,
19
+ recoveryForRunnerStartupNotLive,
20
+ recoveryForVercelSandboxUnavailable,
21
+ } from '../../play-run-recovery-policy';
22
+ import {
23
+ isVercelSandboxPreviewLane,
24
+ loadVercelSandboxRequiredConfig,
25
+ VERCEL_SANDBOX_PROJECT_ID,
26
+ VERCEL_SANDBOX_TEAM_ID,
27
+ VERCEL_SANDBOX_TOKEN_ENV,
28
+ vercelSandboxLaneTag,
29
+ vercelSandboxName,
30
+ type VercelSandboxRequiredConfig,
31
+ } from '../../vercel-sandbox-runtime-config';
32
+ import { runtimeSandboxRef } from '../../runtime-sandbox-contract';
33
+ import { validateDaytonaExecutionContext } from './daytona-lifecycle';
34
+ import {
35
+ stageRunnerPayload,
36
+ withRunnerSandboxProvider,
37
+ type BakedRunnerExpectation,
38
+ type StagedDaytonaPayload,
39
+ } from './daytona-payload-transport';
40
+ import {
41
+ bakedRunnerPlanForLaunch,
42
+ bakedVerdictRequiresFallback,
43
+ configuredBakedRunnerHash,
44
+ parseBakedRunnerVerdict,
45
+ type BakedRunnerVerdict,
46
+ } from '../../baked-runner-image';
47
+ import { captureDetachedDaytonaRunnerReadinessBaseline } from './daytona-session-execution';
48
+ import { confirmDetachedModalRunnerReady } from './modal';
49
+
50
+ /**
51
+ * Vercel Sandbox runner Adapter (`vercel_sandbox_only@1`, Preview only).
52
+ *
53
+ * Lifecycle, in order:
54
+ * 1. Admission: Preview-lane check, plan-limit check, then the scheduler's
55
+ * shared sandbox capacity ledger (the same per-org reservation Daytona and
56
+ * Modal take). Nothing is created when any of these refuse.
57
+ * 2. Intent: the sandbox name is chosen here and recorded as the attempt's
58
+ * resource fact BEFORE the create request is sent. Every later outcome
59
+ * (rejection, timeout, crash) therefore leaves an exact name to delete.
60
+ * 3. Create, stage (upload, as Daytona), launch detached, readiness, park.
61
+ * 4. Any failure before park deletes the sandbox and confirms its absence,
62
+ * then releases its capacity lease. Everything else (terminal, cancel,
63
+ * reclaim, a create whose outcome stayed unknown) goes through the shared
64
+ * durable cleanup, which finds the recorded name. Vercel's session timeout
65
+ * is the provider-side bound.
66
+ *
67
+ * The executor token travels only inside the uploaded envelope file; it is
68
+ * never in argv, the command environment, a tag, or a log line.
69
+ */
70
+
71
+ const VERCEL_SANDBOX_CREATE_TIMEOUT_MS = 60_000;
72
+ const VERCEL_SANDBOX_UPLOAD_TIMEOUT_MS = 90_000;
73
+ const VERCEL_SANDBOX_COMMAND_START_TIMEOUT_MS = 30_000;
74
+ const VERCEL_SANDBOX_CONTROL_TIMEOUT_MS = 10_000;
75
+ /** Whole delete-and-confirm budget, including the absence read-back. */
76
+ export const VERCEL_SANDBOX_DELETE_TIMEOUT_MS = 30_000;
77
+ const VERCEL_SANDBOX_INSPECTION_TIMEOUT_MS = 10_000;
78
+ const VERCEL_SANDBOX_SOURCE_TAG = 'deepline-play-runner';
79
+ /** Bounds for the baked-runner verdict line and the fallback's guard exit. */
80
+ const VERCEL_SANDBOX_BAKED_VERDICT_TIMEOUT_MS = 30_000;
81
+ const VERCEL_SANDBOX_SNAPSHOT_LOOKUP_TIMEOUT_MS = 5_000;
82
+ const VERCEL_SANDBOX_SNAPSHOT_LOOKUP_TTL_MS = 10 * 60_000;
83
+ const VERCEL_SANDBOX_SNAPSHOT_ABSENT_TTL_MS = 30_000;
84
+
85
+ /**
86
+ * Name of the stopped sandbox whose snapshot carries the baked runner for one
87
+ * bundle hash (`scripts/publish-baked-runner-vercel-snapshot.ts`). The name is
88
+ * derived from the hash, like Modal's `deepline-play-runner:<hash[:32]>`.
89
+ */
90
+ export function vercelBakedRunnerSandboxName(hash: string): string {
91
+ return `dl-baked-runner-${hash.slice(0, 32)}`;
92
+ }
93
+
94
+ const snapshotLookups = new Map<
95
+ string,
96
+ { snapshotId: string | null; expiresAtMs: number }
97
+ >();
98
+
99
+ /**
100
+ * The snapshot that carries the baked runner, or null. Only consulted when an
101
+ * operator configured DEEPLINE_BAKED_RUNNER_HASH for this exact bundle; the
102
+ * runner file is still verified inside the sandbox before it is used.
103
+ */
104
+ async function resolveBakedRunnerSnapshot(input: {
105
+ hash: string;
106
+ credentials: VercelCredentials;
107
+ }): Promise<string | null> {
108
+ const cached = snapshotLookups.get(input.hash);
109
+ if (cached && cached.expiresAtMs > Date.now()) return cached.snapshotId;
110
+ const { Sandbox } = await loadVercelSdk();
111
+ let snapshotId: string | null = null;
112
+ try {
113
+ snapshotId = await withDeadline(
114
+ 'Vercel baked-runner snapshot lookup',
115
+ VERCEL_SANDBOX_SNAPSHOT_LOOKUP_TIMEOUT_MS,
116
+ async (signal) => {
117
+ const sandbox = await Sandbox.get({
118
+ name: vercelBakedRunnerSandboxName(input.hash),
119
+ signal,
120
+ ...input.credentials,
121
+ });
122
+ return sandbox.currentSnapshotId ?? null;
123
+ },
124
+ );
125
+ } catch (error) {
126
+ if (!isVercelSandboxNotFoundError(error)) {
127
+ console.warn('[play-runner.vercel.baked_snapshot_lookup_failed]', {
128
+ error: errorMessage(error),
129
+ });
130
+ }
131
+ }
132
+ snapshotLookups.set(input.hash, {
133
+ snapshotId,
134
+ expiresAtMs:
135
+ Date.now() +
136
+ (snapshotId
137
+ ? VERCEL_SANDBOX_SNAPSHOT_LOOKUP_TTL_MS
138
+ : VERCEL_SANDBOX_SNAPSHOT_ABSENT_TTL_MS),
139
+ });
140
+ return snapshotId;
141
+ }
142
+
143
+ /**
144
+ * The verdict line of a detached command, bounded; `late` on timeout. Output
145
+ * printed before the guard's line is skipped, so `no_verdict` means the
146
+ * stream ended without one.
147
+ */
148
+ export async function readBakedVerdict(input: {
149
+ command: {
150
+ logs(opts?: {
151
+ signal?: AbortSignal;
152
+ }): AsyncIterable<{ stream: string; data: string }>;
153
+ };
154
+ cancellation: Promise<never>;
155
+ }): Promise<BakedRunnerVerdict> {
156
+ try {
157
+ return await withDeadline(
158
+ 'Vercel baked-runner verdict',
159
+ VERCEL_SANDBOX_BAKED_VERDICT_TIMEOUT_MS,
160
+ async (signal) => {
161
+ let buffered = '';
162
+ for await (const line of input.command.logs({ signal })) {
163
+ if (line.stream !== 'stdout') continue;
164
+ buffered += line.data;
165
+ const lastNewline = buffered.lastIndexOf('\n');
166
+ if (
167
+ lastNewline >= 0 &&
168
+ parseBakedRunnerVerdict(buffered.slice(0, lastNewline)) !==
169
+ 'no_verdict'
170
+ ) {
171
+ break;
172
+ }
173
+ }
174
+ return parseBakedRunnerVerdict(buffered);
175
+ },
176
+ input.cancellation,
177
+ );
178
+ } catch (error) {
179
+ if (errorMessage(error).startsWith('VERCEL_SANDBOX_TIMEOUT')) return 'late';
180
+ throw error;
181
+ }
182
+ }
183
+
184
+ type VercelSdk = typeof import('@vercel/sandbox');
185
+ let vercelSdk: Promise<VercelSdk> | null = null;
186
+ /** Loaded lazily so only a lane that selects this Adapter pays for it. */
187
+ function loadVercelSdk(): Promise<VercelSdk> {
188
+ vercelSdk ??= import('@vercel/sandbox');
189
+ return vercelSdk;
190
+ }
191
+
192
+ type VercelCredentials = { token: string; teamId: string; projectId: string };
193
+
194
+ function credentialsFromEnv(
195
+ env: Readonly<Record<string, string | undefined>> = process.env,
196
+ ): VercelCredentials {
197
+ const token = env[VERCEL_SANDBOX_TOKEN_ENV]?.trim();
198
+ if (!token) {
199
+ throw new Error(
200
+ `${VERCEL_SANDBOX_TOKEN_ENV} is required to reach Vercel Sandbox.`,
201
+ );
202
+ }
203
+ return {
204
+ token,
205
+ teamId: VERCEL_SANDBOX_TEAM_ID,
206
+ projectId: VERCEL_SANDBOX_PROJECT_ID,
207
+ };
208
+ }
209
+
210
+ function httpStatus(error: unknown): number | null {
211
+ const response = (error as { response?: { status?: unknown } } | null)
212
+ ?.response;
213
+ return typeof response?.status === 'number' ? response.status : null;
214
+ }
215
+
216
+ export function isVercelSandboxNotFoundError(error: unknown): boolean {
217
+ return httpStatus(error) === 404 || httpStatus(error) === 410;
218
+ }
219
+
220
+ /**
221
+ * A create the provider definitively refused: nothing was created. A 409 is
222
+ * not one: the SDK retries a create POST after a transport error or 5xx, so a
223
+ * conflict can mean an earlier try of this same name succeeded.
224
+ */
225
+ export function isVercelSandboxCreateRejected(error: unknown): boolean {
226
+ const status = httpStatus(error);
227
+ return (
228
+ status !== null &&
229
+ status >= 400 &&
230
+ status < 500 &&
231
+ status !== 408 &&
232
+ status !== 409
233
+ );
234
+ }
235
+
236
+ function errorMessage(error: unknown): string {
237
+ return error instanceof Error ? error.message : String(error);
238
+ }
239
+
240
+ function emitVercelStage(
241
+ context: PlayRunnerExecutionConfig['context'],
242
+ stage: string,
243
+ extra: Record<string, unknown> = {},
244
+ ): void {
245
+ try {
246
+ console.info(
247
+ '[play-runner.vercel.stage]',
248
+ JSON.stringify({
249
+ workflowId: context.workflowId ?? null,
250
+ runId: context.runId ?? null,
251
+ playName: context.playName ?? null,
252
+ stage,
253
+ ...extra,
254
+ atMs: Date.now(),
255
+ }),
256
+ );
257
+ } catch {
258
+ // Diagnostic delivery never changes the launch it describes.
259
+ }
260
+ }
261
+
262
+ function failed(
263
+ config: PlayRunnerExecutionConfig,
264
+ error: unknown,
265
+ ): PlayRunnerResult {
266
+ return {
267
+ status: 'failed',
268
+ error: errorMessage(error),
269
+ logs: [],
270
+ stats: {},
271
+ steps: [],
272
+ checkpoint: config.checkpoint ?? null,
273
+ tableNamespace: null,
274
+ };
275
+ }
276
+
277
+ async function withDeadline<T>(
278
+ label: string,
279
+ timeoutMs: number,
280
+ run: (signal: AbortSignal) => Promise<T>,
281
+ cancellation?: Promise<never>,
282
+ ): Promise<T> {
283
+ const controller = new AbortController();
284
+ let timer: ReturnType<typeof setTimeout> | undefined;
285
+ const deadline = new Promise<never>((_resolve, reject) => {
286
+ timer = setTimeout(() => {
287
+ const error = new Error(
288
+ `VERCEL_SANDBOX_TIMEOUT: ${label} did not complete within ${timeoutMs}ms.`,
289
+ );
290
+ controller.abort(error);
291
+ reject(error);
292
+ }, timeoutMs);
293
+ });
294
+ try {
295
+ return await Promise.race([
296
+ run(controller.signal),
297
+ deadline,
298
+ ...(cancellation ? [cancellation] : []),
299
+ ]);
300
+ } finally {
301
+ if (timer) clearTimeout(timer);
302
+ if (!controller.signal.aborted) controller.abort();
303
+ }
304
+ }
305
+
306
+ export type VercelSandboxDeleteOutcome =
307
+ | { kind: 'deleted' | 'already_absent'; projectId: string }
308
+ | {
309
+ kind: 'timed_out' | 'failed';
310
+ projectId: string | null;
311
+ code: string;
312
+ detail: string;
313
+ };
314
+
315
+ /**
316
+ * Stop, delete, then read back absence. Only a read-back 404 counts as
317
+ * confirmed: a delete that returned but left the sandbox visible is `failed`,
318
+ * so no caller can mark it deleted.
319
+ */
320
+ export async function deleteVercelSandboxByName(input: {
321
+ name: string;
322
+ expectedProjectId?: string | null;
323
+ credentials?: VercelCredentials;
324
+ timeoutMs?: number;
325
+ }): Promise<VercelSandboxDeleteOutcome> {
326
+ const expectedProjectId = input.expectedProjectId?.trim() || null;
327
+ if (expectedProjectId !== VERCEL_SANDBOX_PROJECT_ID) {
328
+ return {
329
+ kind: 'failed',
330
+ projectId: expectedProjectId,
331
+ code: 'routing_domain_mismatch',
332
+ detail: `Vercel Sandbox cleanup requires the persisted project ${VERCEL_SANDBOX_PROJECT_ID}.`,
333
+ };
334
+ }
335
+ try {
336
+ const credentials = input.credentials ?? credentialsFromEnv();
337
+ const { Sandbox } = await loadVercelSdk();
338
+ return await withDeadline(
339
+ `Vercel Sandbox delete of ${input.name}`,
340
+ input.timeoutMs ?? VERCEL_SANDBOX_DELETE_TIMEOUT_MS,
341
+ async (signal) => {
342
+ let sandbox: VercelSandbox;
343
+ try {
344
+ sandbox = await Sandbox.get({
345
+ name: input.name,
346
+ signal,
347
+ ...credentials,
348
+ });
349
+ } catch (error) {
350
+ if (isVercelSandboxNotFoundError(error)) {
351
+ return { kind: 'already_absent', projectId: expectedProjectId };
352
+ }
353
+ throw error;
354
+ }
355
+ // Stop first so the VM stops billing even if the delete call races.
356
+ await sandbox.stop({ signal }).catch((error: unknown) => {
357
+ if (!isVercelSandboxNotFoundError(error)) throw error;
358
+ });
359
+ await sandbox.delete({ signal }).catch((error: unknown) => {
360
+ if (!isVercelSandboxNotFoundError(error)) throw error;
361
+ });
362
+ try {
363
+ await Sandbox.get({ name: input.name, signal, ...credentials });
364
+ } catch (error) {
365
+ if (isVercelSandboxNotFoundError(error)) {
366
+ return { kind: 'deleted', projectId: expectedProjectId };
367
+ }
368
+ throw error;
369
+ }
370
+ return {
371
+ kind: 'failed',
372
+ projectId: expectedProjectId,
373
+ code: 'delete_unconfirmed',
374
+ detail: `Vercel Sandbox ${input.name} is still visible after delete.`,
375
+ };
376
+ },
377
+ );
378
+ } catch (error) {
379
+ const timedOut = errorMessage(error).startsWith('VERCEL_SANDBOX_TIMEOUT');
380
+ console.warn('[play-runner.vercel.sandbox_delete_failed]', {
381
+ sandbox: input.name,
382
+ error: errorMessage(error),
383
+ });
384
+ return {
385
+ kind: timedOut ? 'timed_out' : 'failed',
386
+ projectId: expectedProjectId,
387
+ code: timedOut ? 'delete_timed_out' : 'provider_delete_failed',
388
+ detail: errorMessage(error),
389
+ };
390
+ }
391
+ }
392
+
393
+ /**
394
+ * Read the detached runner's captured files without executing anything.
395
+ * Like Modal, a stopped sandbox has no readable files left.
396
+ */
397
+ export async function inspectDetachedVercelRunner(input: {
398
+ name: string;
399
+ outputPath: string;
400
+ exitCodePath: string;
401
+ expectedProjectId?: string | null;
402
+ skipCapturedOutput?: boolean;
403
+ }): Promise<{
404
+ exitCode: number | null;
405
+ result: PlayRunnerResult | null;
406
+ diagnosis: { stage: string; detail: string | null };
407
+ }> {
408
+ if (input.expectedProjectId?.trim() !== VERCEL_SANDBOX_PROJECT_ID) {
409
+ return {
410
+ exitCode: null,
411
+ result: null,
412
+ diagnosis: {
413
+ stage: 'missing_routing_domain',
414
+ detail: 'Vercel Sandbox inspection requires the launch-pinned project.',
415
+ },
416
+ };
417
+ }
418
+ try {
419
+ const credentials = credentialsFromEnv();
420
+ const { Sandbox } = await loadVercelSdk();
421
+ return await withDeadline(
422
+ `Vercel Sandbox inspection of ${input.name}`,
423
+ VERCEL_SANDBOX_INSPECTION_TIMEOUT_MS,
424
+ async (signal) => {
425
+ let sandbox: VercelSandbox;
426
+ try {
427
+ sandbox = await Sandbox.get({
428
+ name: input.name,
429
+ signal,
430
+ ...credentials,
431
+ });
432
+ } catch (error) {
433
+ if (isVercelSandboxNotFoundError(error)) {
434
+ return {
435
+ exitCode: null,
436
+ result: null,
437
+ diagnosis: {
438
+ stage: 'sandbox_missing',
439
+ detail: 'Vercel has no sandbox with this name.',
440
+ },
441
+ };
442
+ }
443
+ throw error;
444
+ }
445
+ if (sandbox.status !== 'running' && sandbox.status !== 'pending') {
446
+ return {
447
+ exitCode: null,
448
+ result: null,
449
+ diagnosis: {
450
+ stage: 'sandbox_stopped',
451
+ detail: `Vercel sandbox status is ${sandbox.status}.`,
452
+ },
453
+ };
454
+ }
455
+ if (input.skipCapturedOutput) {
456
+ return {
457
+ exitCode: null,
458
+ result: null,
459
+ diagnosis: { stage: 'sandbox_not_ended', detail: null },
460
+ };
461
+ }
462
+ const [output, exitCode] = await Promise.allSettled([
463
+ sandbox.readFileToBuffer({ path: input.outputPath }, { signal }),
464
+ sandbox.readFileToBuffer({ path: input.exitCodePath }, { signal }),
465
+ ]);
466
+ if (output.status !== 'fulfilled' || !output.value) {
467
+ return {
468
+ exitCode: null,
469
+ result: null,
470
+ diagnosis: {
471
+ stage: 'result_missing',
472
+ detail: 'Captured runner output is unavailable.',
473
+ },
474
+ };
475
+ }
476
+ const exitText =
477
+ exitCode.status === 'fulfilled' && exitCode.value
478
+ ? exitCode.value.toString('utf8').trim()
479
+ : '';
480
+ const parsedExit = /^-?\d+$/u.test(exitText) ? Number(exitText) : null;
481
+ const result =
482
+ findPlayRunnerResult(
483
+ parsePlayRunnerEvents(output.value.toString('utf8')),
484
+ ) ?? null;
485
+ return {
486
+ exitCode:
487
+ parsedExit !== null && Number.isSafeInteger(parsedExit)
488
+ ? parsedExit
489
+ : null,
490
+ result,
491
+ diagnosis: result
492
+ ? { stage: 'salvaged', detail: null }
493
+ : { stage: 'result_missing', detail: null },
494
+ };
495
+ },
496
+ );
497
+ } catch (error) {
498
+ console.warn('[play-runner.vercel.detached_inspect_failed]', {
499
+ sandbox: input.name,
500
+ error: errorMessage(error),
501
+ });
502
+ return {
503
+ exitCode: null,
504
+ result: null,
505
+ diagnosis: {
506
+ stage: 'sandbox_lookup_failed',
507
+ detail: 'Vercel Sandbox inspection could not complete.',
508
+ },
509
+ };
510
+ }
511
+ }
512
+
513
+ /** Telemetry-only completion marker; any failure is `null`, never a stall. */
514
+ export async function readDetachedVercelRuntimeCompletion(input: {
515
+ name: string;
516
+ runtimeCompletedPath: string;
517
+ expectedProjectId?: string | null;
518
+ }): Promise<number | null> {
519
+ if (input.expectedProjectId?.trim() !== VERCEL_SANDBOX_PROJECT_ID) {
520
+ return null;
521
+ }
522
+ try {
523
+ const credentials = credentialsFromEnv();
524
+ const { Sandbox } = await loadVercelSdk();
525
+ return await withDeadline(
526
+ `Vercel Sandbox completion marker of ${input.name}`,
527
+ VERCEL_SANDBOX_INSPECTION_TIMEOUT_MS,
528
+ async (signal) => {
529
+ const sandbox = await Sandbox.get({
530
+ name: input.name,
531
+ signal,
532
+ ...credentials,
533
+ });
534
+ if (sandbox.status !== 'running') return null;
535
+ const raw = await sandbox.readFileToBuffer(
536
+ { path: input.runtimeCompletedPath },
537
+ { signal },
538
+ );
539
+ if (!raw) return null;
540
+ const marker = JSON.parse(raw.toString('utf8')) as { at?: unknown };
541
+ return typeof marker.at === 'number' && Number.isFinite(marker.at)
542
+ ? marker.at
543
+ : null;
544
+ },
545
+ );
546
+ } catch (error) {
547
+ console.warn('[play-runner.vercel.runtime_completion_marker_unavailable]', {
548
+ sandbox: input.name,
549
+ error: errorMessage(error),
550
+ });
551
+ return null;
552
+ }
553
+ }
554
+
555
+ export const vercelSandboxPlayRunnerBackend: PlayRunnerBackend = {
556
+ async execute(config, callbacks) {
557
+ let runtimeResourceRegistrationError: unknown;
558
+ try {
559
+ validateDaytonaExecutionContext(config.context);
560
+ const push = config.context.runnerPushExecution;
561
+ if (!push) {
562
+ return failed(
563
+ config,
564
+ 'Vercel Sandbox runner backend requires push-execution config (context.runnerPushExecution).',
565
+ );
566
+ }
567
+ const readRunnerReadiness = callbacks?.readDetachedRunnerReadiness;
568
+ if (!readRunnerReadiness) {
569
+ return failed(
570
+ config,
571
+ 'Vercel Sandbox runner backend requires the scheduler-owned detached-runner readiness port.',
572
+ );
573
+ }
574
+ if (!callbacks?.onRuntimeResourceAcquired) {
575
+ return failed(
576
+ config,
577
+ 'Vercel Sandbox runner backend requires a durable resource recorder: the sandbox name is recorded before create.',
578
+ );
579
+ }
580
+ const runId = config.context.runId ?? push.runId;
581
+ const runAttempt = Math.max(
582
+ 0,
583
+ Math.floor(config.context.runAttempt ?? 0),
584
+ );
585
+ const startedAt = Date.now();
586
+ // Persisted runtime timing is a closed Daytona/Modal shape; Vercel
587
+ // timings are the `[play-runner.vercel.stage]` lines only.
588
+ emitVercelStage(config.context, 'create:start');
589
+
590
+ // Admission. Each check fails before any provider call.
591
+ const vercelConfig: VercelSandboxRequiredConfig =
592
+ loadVercelSandboxRequiredConfig({
593
+ runtimeSchedulerSchema: config.context.runtimeSchedulerSchema,
594
+ limits: config.context.sandboxRuntimeLimits,
595
+ });
596
+ const bundlePromise = buildPlayRunnerBundle();
597
+ bundlePromise.catch(() => undefined);
598
+ const providerCircuitClaim =
599
+ await callbacks.shouldAttemptSandboxProvider?.('vercel');
600
+ if (providerCircuitClaim && !providerCircuitClaim.allowed) {
601
+ throw recoveryForVercelSandboxUnavailable(
602
+ new Error('Sandbox provider circuit is open.'),
603
+ );
604
+ }
605
+ emitVercelStage(config.context, 'config:resolved', {
606
+ vcpus: vercelConfig.vcpus,
607
+ memoryGiB: vercelConfig.memoryGiB,
608
+ timeoutSeconds: vercelConfig.limits.timeoutSeconds,
609
+ region: vercelConfig.region,
610
+ networkRestricted: vercelConfig.networkPolicy !== 'allow-all',
611
+ elapsedMs: Date.now() - startedAt,
612
+ });
613
+
614
+ const name = vercelSandboxName({
615
+ runId,
616
+ attempt: runAttempt,
617
+ nonce: randomUUID(),
618
+ });
619
+ const credentials: VercelCredentials = {
620
+ token: vercelConfig.token,
621
+ teamId: vercelConfig.teamId,
622
+ projectId: vercelConfig.projectId,
623
+ };
624
+ // The shared per-org capacity ledger, as for Daytona and Modal. A full
625
+ // organization raises the scheduler's typed capacity error, rethrown
626
+ // below as a pre-code deferral.
627
+ const capacityReservation =
628
+ await callbacks.reserveSandboxCapacity?.('vercel');
629
+ emitVercelStage(config.context, 'capacity:reserved', {
630
+ reserved: Boolean(capacityReservation),
631
+ elapsedMs: Date.now() - startedAt,
632
+ });
633
+ const releaseCapacityAfterConfirmedAbsence = async (
634
+ outcome: VercelSandboxDeleteOutcome['kind'],
635
+ ) => {
636
+ if (
637
+ !capacityReservation ||
638
+ !callbacks.releaseSandboxCapacity ||
639
+ (outcome !== 'deleted' && outcome !== 'already_absent')
640
+ ) {
641
+ return;
642
+ }
643
+ try {
644
+ await callbacks.releaseSandboxCapacity(capacityReservation.leaseId);
645
+ } catch (releaseError) {
646
+ // Durable cleanup of the recorded name releases it later.
647
+ console.warn('[play-runner.vercel] capacity_release_failed', {
648
+ sandbox: name,
649
+ error: errorMessage(releaseError),
650
+ });
651
+ }
652
+ };
653
+ const createRequestedAt = Date.now();
654
+ // Intent before effect: the exact name is durable before the create is
655
+ // sent, so a lost response, a crash, or a timeout leaves a precise
656
+ // deletion target instead of an invisible sandbox.
657
+ try {
658
+ await callbacks.onRuntimeResourceAcquired({
659
+ kind: 'vercel_sandbox',
660
+ sandboxId: name,
661
+ runtimeEnvironment: 'preview',
662
+ vercelProjectId: vercelConfig.projectId,
663
+ billingStartedAt: createRequestedAt,
664
+ maxBillingDurationSeconds:
665
+ vercelConfig.limits.timeoutSeconds +
666
+ PLAY_RUNNER_TERMINAL_GRACE_SECONDS,
667
+ cpu: vercelConfig.vcpus,
668
+ memoryGiB: vercelConfig.memoryGiB,
669
+ diskGiB: 0,
670
+ ...(capacityReservation
671
+ ? { sandboxCapacityLeaseId: capacityReservation.leaseId }
672
+ : {}),
673
+ });
674
+ } catch (error) {
675
+ runtimeResourceRegistrationError = error;
676
+ throw error;
677
+ }
678
+ emitVercelStage(config.context, 'create:intent_recorded', {
679
+ sandboxId: name,
680
+ elapsedMs: Date.now() - startedAt,
681
+ });
682
+
683
+ const { Sandbox } = await loadVercelSdk();
684
+ // Baked runner (opt-in): only when the operator pinned this bundle's
685
+ // hash and a published snapshot for it resolves.
686
+ const bakedPlan = await bakedRunnerPlanForLaunch({
687
+ bundlePromise,
688
+ configuredHash: configuredBakedRunnerHash(),
689
+ onStale: (stale) =>
690
+ emitVercelStage(config.context, 'runner:baked_config_stale', {
691
+ configuredHashPrefix: stale.configuredHash.slice(0, 12),
692
+ bundleHashPrefix: stale.bundleHash.slice(0, 12),
693
+ }),
694
+ });
695
+ const bakedSnapshotId = bakedPlan
696
+ ? await resolveBakedRunnerSnapshot({
697
+ hash: bakedPlan.hash,
698
+ credentials,
699
+ })
700
+ : null;
701
+ const bakedRunner: BakedRunnerExpectation | undefined =
702
+ bakedPlan && bakedSnapshotId
703
+ ? {
704
+ ...bakedPlan,
705
+ verified: Promise.resolve(true),
706
+ verifyInCommand: true,
707
+ }
708
+ : undefined;
709
+ if (bakedPlan && !bakedSnapshotId) {
710
+ emitVercelStage(config.context, 'runner:baked_skipped', {
711
+ reason: 'snapshot_absent',
712
+ });
713
+ }
714
+ let sandbox: VercelSandbox;
715
+ emitVercelStage(config.context, 'create:requested', {
716
+ sandboxId: name,
717
+ elapsedMs: Date.now() - startedAt,
718
+ });
719
+ try {
720
+ sandbox = await withDeadline(
721
+ 'Vercel Sandbox create',
722
+ VERCEL_SANDBOX_CREATE_TIMEOUT_MS,
723
+ (signal) =>
724
+ Sandbox.create({
725
+ name,
726
+ ...(bakedSnapshotId
727
+ ? {
728
+ source: {
729
+ type: 'snapshot' as const,
730
+ snapshotId: bakedSnapshotId,
731
+ },
732
+ }
733
+ : { image: vercelConfig.image }),
734
+ region: vercelConfig.region,
735
+ resources: { vcpus: vercelConfig.vcpus },
736
+ timeout: vercelConfig.sessionTimeoutMs,
737
+ persistent: false,
738
+ networkPolicy: vercelConfig.networkPolicy,
739
+ tags: {
740
+ source: VERCEL_SANDBOX_SOURCE_TAG,
741
+ lane: vercelSandboxLaneTag(
742
+ config.context.runtimeSchedulerSchema,
743
+ ),
744
+ runId,
745
+ attempt: String(runAttempt),
746
+ },
747
+ signal,
748
+ ...credentials,
749
+ }),
750
+ );
751
+ } catch (error) {
752
+ const rejected = isVercelSandboxCreateRejected(error);
753
+ emitVercelStage(config.context, 'create:failed', {
754
+ sandboxId: name,
755
+ outcome: rejected ? 'rejected' : 'unknown',
756
+ status: httpStatus(error),
757
+ errorName: error instanceof Error ? error.name : null,
758
+ elapsedMs: Date.now() - startedAt,
759
+ });
760
+ logSandboxCreateOutcome({
761
+ provider: 'vercel',
762
+ outcome: rejected ? 'failed' : 'unknown',
763
+ runId,
764
+ reason: rejected ? `http_${httpStatus(error)}` : null,
765
+ });
766
+ // A timeout or transport error may still create the sandbox. Ask for
767
+ // its confirmed deletion now; if that cannot be confirmed, durable
768
+ // cleanup deletes the recorded name when the attempt ends.
769
+ if (!rejected) {
770
+ const cleanup = await deleteVercelSandboxByName({
771
+ name,
772
+ expectedProjectId: vercelConfig.projectId,
773
+ credentials,
774
+ });
775
+ emitVercelStage(config.context, 'create:unknown_cleanup', {
776
+ sandboxId: name,
777
+ outcome: cleanup.kind,
778
+ });
779
+ await releaseCapacityAfterConfirmedAbsence(cleanup.kind);
780
+ } else {
781
+ // Vercel refused the create: no sandbox exists.
782
+ await releaseCapacityAfterConfirmedAbsence('already_absent');
783
+ }
784
+ // An account refusal (plan, spend or quota limit) defers with
785
+ // Vercel's own words, as a Daytona or Modal account refusal does.
786
+ // Rate limits, conflicts and outages defer too. Any other 4xx (a
787
+ // malformed request, a bad credential) would repeat on every attempt,
788
+ // so it stays loud.
789
+ const status = httpStatus(error);
790
+ if (
791
+ rejected &&
792
+ status !== 429 &&
793
+ status !== 402 &&
794
+ status !== 403
795
+ ) {
796
+ throw new Error(
797
+ `VERCEL_SANDBOX_CREATE_REJECTED: Vercel refused the sandbox create (HTTP ${status}): ${errorMessage(error)}`,
798
+ );
799
+ }
800
+ throw recoveryForVercelSandboxUnavailable(error);
801
+ }
802
+ const createdAt = Date.now();
803
+ emitVercelStage(config.context, 'create:done', {
804
+ sandboxId: name,
805
+ baked: Boolean(bakedRunner),
806
+ region: sandbox.region,
807
+ createMs: createdAt - createRequestedAt,
808
+ elapsedMs: createdAt - startedAt,
809
+ });
810
+ logSandboxCreateOutcome({
811
+ provider: 'vercel',
812
+ outcome: 'succeeded',
813
+ runId,
814
+ });
815
+ try {
816
+ await callbacks.markSandboxProviderHealthy?.(
817
+ 'vercel',
818
+ providerCircuitClaim?.probeToken ?? null,
819
+ );
820
+ } catch (circuitError) {
821
+ console.warn('[play-runner.vercel] recovery_circuit_close_failed', {
822
+ sandbox: name,
823
+ error: errorMessage(circuitError),
824
+ });
825
+ }
826
+
827
+ let detached = false;
828
+ let cancelExecution!: (error: Error) => void;
829
+ const cancellationPromise = new Promise<never>((_resolve, reject) => {
830
+ cancelExecution = reject;
831
+ });
832
+ cancellationPromise.catch(() => undefined);
833
+ const onCancel = () =>
834
+ cancelExecution(new Error('Vercel Sandbox play runner cancelled'));
835
+ callbacks.cancellationSignal?.addEventListener('abort', onCancel, {
836
+ once: true,
837
+ });
838
+ try {
839
+ if (callbacks.cancellationSignal?.aborted) onCancel();
840
+ const baselineHeartbeatRead =
841
+ captureDetachedDaytonaRunnerReadinessBaseline({
842
+ readiness: readRunnerReadiness,
843
+ });
844
+ baselineHeartbeatRead.catch(() => undefined);
845
+ const uploadStartedAt = Date.now();
846
+ const stage = (baked: BakedRunnerExpectation | undefined) =>
847
+ withDeadline(
848
+ 'Vercel Sandbox payload upload',
849
+ VERCEL_SANDBOX_UPLOAD_TIMEOUT_MS,
850
+ (signal) =>
851
+ stageRunnerPayload({
852
+ sandbox: {
853
+ id: name,
854
+ uploadFile: (content, path) =>
855
+ sandbox.writeFiles([{ path, content }], { signal }),
856
+ },
857
+ bundlePromise,
858
+ config: withRunnerSandboxProvider(config, 'vercel'),
859
+ workDir: vercelConfig.workdir,
860
+ startedAt,
861
+ // Baked: upload only the envelope; the launch command checks
862
+ // its size and verifies the baked runner before running it.
863
+ ...(baked ? { bakedRunner: baked } : {}),
864
+ emitStage: (stageName, extra) =>
865
+ emitVercelStage(config.context, stageName, extra),
866
+ }),
867
+ cancellationPromise,
868
+ ).catch((error: unknown) => {
869
+ // Nothing ran: the runner never reached this sandbox.
870
+ if (callbacks.cancellationSignal?.aborted) throw error;
871
+ // A refusal every sandbox would repeat (a 4xx other than a rate
872
+ // limit or timeout) fails loudly on this one sandbox.
873
+ const status = httpStatus(error);
874
+ if (
875
+ status !== null &&
876
+ status >= 400 &&
877
+ status < 500 &&
878
+ status !== 408 &&
879
+ status !== 429
880
+ ) {
881
+ throw error;
882
+ }
883
+ throw recoveryForRunnerStartupNotLive(error);
884
+ });
885
+ const staged = await stage(bakedRunner);
886
+ emitVercelStage(config.context, 'upload:payload_staged', {
887
+ sandboxId: name,
888
+ uploadMs: Date.now() - uploadStartedAt,
889
+ elapsedMs: Date.now() - startedAt,
890
+ });
891
+ const baselineHeartbeatAt = await Promise.race([
892
+ baselineHeartbeatRead,
893
+ cancellationPromise,
894
+ ]);
895
+ let payload: Pick<
896
+ StagedDaytonaPayload,
897
+ 'command' | 'outputPath' | 'exitCodePath' | 'runtimeCompletedPath'
898
+ > = staged;
899
+ emitVercelStage(config.context, 'execute:start', {
900
+ sandboxId: name,
901
+ mode: 'detached',
902
+ elapsedMs: Date.now() - startedAt,
903
+ });
904
+ const executeStartedAt = Date.now();
905
+ const startCommand = (command: string) =>
906
+ withDeadline(
907
+ 'Vercel Sandbox detached command start',
908
+ VERCEL_SANDBOX_COMMAND_START_TIMEOUT_MS,
909
+ (signal) =>
910
+ sandbox.runCommand({
911
+ cmd: 'bash',
912
+ args: ['-lc', command],
913
+ detached: true,
914
+ signal,
915
+ }),
916
+ cancellationPromise,
917
+ );
918
+ if (bakedRunner) {
919
+ // The guarded command prints the verdict first and exits 98 before
920
+ // running anything unless the baked file hashes to the pin. A
921
+ // baked launch without the guard is a bug, never an unverified run.
922
+ if (!staged.bakedGuardedCommand) {
923
+ throw new Error(
924
+ 'Vercel baked-runner staging produced no guarded command.',
925
+ );
926
+ }
927
+ const launched = await startCommand(staged.bakedGuardedCommand);
928
+ const verdict = await readBakedVerdict({
929
+ command: launched,
930
+ cancellation: cancellationPromise,
931
+ });
932
+ emitVercelStage(config.context, 'runtime:baked_verified_in_command', {
933
+ sandboxId: name,
934
+ bakedRunnerVerdict: verdict,
935
+ elapsedMs: Date.now() - executeStartedAt,
936
+ });
937
+ if (bakedVerdictRequiresFallback(verdict)) {
938
+ await withDeadline(
939
+ 'Vercel baked-runner guard exit',
940
+ VERCEL_SANDBOX_BAKED_VERDICT_TIMEOUT_MS,
941
+ (signal) => launched.wait({ signal }),
942
+ cancellationPromise,
943
+ );
944
+ emitVercelStage(config.context, 'runner:placement', {
945
+ sandboxId: name,
946
+ source: 'uploaded_fallback',
947
+ bakedRunnerVerdict: verdict,
948
+ });
949
+ payload = await stage(undefined);
950
+ await startCommand(payload.command);
951
+ }
952
+ } else {
953
+ await startCommand(payload.command);
954
+ }
955
+ const commandAcceptedAtMs = Date.now();
956
+ emitVercelStage(config.context, 'execute:accepted', {
957
+ sandboxId: name,
958
+ execMs: commandAcceptedAtMs - executeStartedAt,
959
+ elapsedMs: commandAcceptedAtMs - startedAt,
960
+ });
961
+ await callbacks.onRunnerCommandAccepted?.({
962
+ provider: 'vercel',
963
+ sandboxId: name,
964
+ });
965
+ await confirmDetachedModalRunnerReady({
966
+ readiness: readRunnerReadiness,
967
+ baselineHeartbeatAt,
968
+ cancellation: cancellationPromise,
969
+ });
970
+ const heartbeatReadyAtMs = Date.now();
971
+ emitVercelStage(config.context, 'execute:heartbeat_ready', {
972
+ sandboxId: name,
973
+ elapsedMs: heartbeatReadyAtMs - startedAt,
974
+ commandAcceptedToHeartbeatMs:
975
+ heartbeatReadyAtMs - commandAcceptedAtMs,
976
+ });
977
+ const boundaryId = `detached-runner:${push.runId}:${runAttempt}`;
978
+ await callbacks.onDetachedRunnerReady?.({
979
+ provider: 'vercel',
980
+ sandboxId: name,
981
+ boundaryId,
982
+ baselineHeartbeatAt,
983
+ });
984
+ if (callbacks.cancellationSignal?.aborted) {
985
+ throw new Error('Vercel Sandbox play runner cancelled');
986
+ }
987
+ detached = true;
988
+ emitVercelStage(config.context, 'execute:detached', {
989
+ sandboxId: name,
990
+ runnerAttempt: runAttempt,
991
+ elapsedMs: Date.now() - startedAt,
992
+ });
993
+ return {
994
+ status: 'suspended',
995
+ suspension: {
996
+ kind: 'detached_runner',
997
+ boundaryId,
998
+ runnerAttempt: runAttempt,
999
+ sandboxProvider: 'vercel',
1000
+ runtimeSandboxRef: runtimeSandboxRef({
1001
+ provider: 'vercel',
1002
+ resourceId: name,
1003
+ routingDomain: vercelConfig.projectId,
1004
+ }),
1005
+ sandboxId: name,
1006
+ sessionId: 'vercel',
1007
+ cmdId: name,
1008
+ outputPath: payload.outputPath,
1009
+ exitCodePath: payload.exitCodePath,
1010
+ runtimeCompletedPath: payload.runtimeCompletedPath,
1011
+ startedAtMs: Date.now(),
1012
+ heartbeatTimeoutMs: push.leaseSeconds * 1_000,
1013
+ runtimeLimitSeconds: vercelConfig.limits.timeoutSeconds,
1014
+ ceilingMs:
1015
+ (vercelConfig.limits.timeoutSeconds +
1016
+ PLAY_RUNNER_TERMINAL_GRACE_SECONDS) *
1017
+ 1_000,
1018
+ },
1019
+ logs: [],
1020
+ stats: {},
1021
+ steps: [],
1022
+ checkpoint: config.checkpoint ?? {
1023
+ completedBatches: {},
1024
+ completedToolBatches: {},
1025
+ resolvedWaterfalls: {},
1026
+ resolvedBoundaries: {},
1027
+ },
1028
+ tableNamespace: null,
1029
+ };
1030
+ } finally {
1031
+ callbacks.cancellationSignal?.removeEventListener('abort', onCancel);
1032
+ if (!detached) {
1033
+ const cleanup = await deleteVercelSandboxByName({
1034
+ name,
1035
+ expectedProjectId: vercelConfig.projectId,
1036
+ credentials,
1037
+ });
1038
+ emitVercelStage(config.context, 'cleanup:before_park', {
1039
+ sandboxId: name,
1040
+ outcome: cleanup.kind,
1041
+ });
1042
+ await releaseCapacityAfterConfirmedAbsence(cleanup.kind);
1043
+ }
1044
+ }
1045
+ } catch (error) {
1046
+ if (
1047
+ error === runtimeResourceRegistrationError ||
1048
+ error instanceof RuntimeResourceFenceLostError ||
1049
+ error instanceof SandboxRunnerPreCodeDeferralError ||
1050
+ isRuntimeSandboxCapacityLimitError(error) ||
1051
+ isPlayRunRecoveryError(error)
1052
+ ) {
1053
+ throw error;
1054
+ }
1055
+ emitVercelStage(config.context, 'execute:error', {
1056
+ error: errorMessage(error),
1057
+ });
1058
+ return failed(config, error);
1059
+ }
1060
+ },
1061
+ };