@@ -33,6 +33,9 @@ export interface Env extends DashboardEnv {
3333 // CF_API_TOKEN and CF_ZONE_ID are optional in DashboardEnv (custom domain
3434 // feature gates on them). Inherited.
3535 ASSETS ?: Fetcher ;
36+ // Optional alpha Burst Sandbox cell. When unset, burst=true creates
37+ // fail closed rather than silently landing on on-demand capacity.
38+ BURST_CELL_ID ?: string ;
3639}
3740
3841// ── small helpers ────────────────────────────────────────────────────────
@@ -440,18 +443,43 @@ async function createSandbox(req: Request, env: Env): Promise<Response> {
440443
441444 // Read body once — used for size-gating, the hard-pin cell peek, and the
442445 // verbatim forward to the CP.
443- const bodyText = await req . text ( ) ;
446+ let bodyText = await req . text ( ) ;
444447 let requestedCellID : string | null = null ;
445448 let bodyCpuCount = 0 ;
446449 let bodyMemoryMB = 0 ;
447450 let bodyDiskMB = 0 ;
451+ let burst = false ;
448452 try {
449453 if ( bodyText ) {
450- const parsed = JSON . parse ( bodyText ) as { cellId ?: unknown ; cpuCount ?: unknown ; memoryMB ?: unknown ; diskMB ?: unknown } ;
454+ const parsed = JSON . parse ( bodyText ) as {
455+ cellId ?: unknown ;
456+ cpuCount ?: unknown ;
457+ memoryMB ?: unknown ;
458+ diskMB ?: unknown ;
459+ burst ?: unknown ;
460+ image ?: unknown ;
461+ snapshot ?: unknown ;
462+ } ;
451463 if ( typeof parsed . cellId === "string" ) requestedCellID = parsed . cellId ;
452464 if ( typeof parsed . cpuCount === "number" ) bodyCpuCount = parsed . cpuCount ;
453465 if ( typeof parsed . memoryMB === "number" ) bodyMemoryMB = parsed . memoryMB ;
454466 if ( typeof parsed . diskMB === "number" ) bodyDiskMB = parsed . diskMB ;
467+ if ( typeof parsed . burst === "boolean" ) burst = parsed . burst ;
468+
469+ if ( burst ) {
470+ if ( ! env . BURST_CELL_ID ) {
471+ return json ( { error : "Burst Sandboxes alpha is not configured" } , 503 ) ;
472+ }
473+ if ( requestedCellID && requestedCellID !== env . BURST_CELL_ID ) {
474+ return json ( { error : "burst cannot be combined with a different cellId" } , 400 ) ;
475+ }
476+ if ( parsed . image != null || parsed . snapshot != null ) {
477+ return json ( { error : "Burst Sandboxes do not support image or snapshot creates in alpha" } , 400 ) ;
478+ }
479+ parsed . burst = true ;
480+ requestedCellID = env . BURST_CELL_ID ;
481+ bodyText = JSON . stringify ( parsed ) ;
482+ }
455483 }
456484 } catch {
457485 /* malformed JSON — let the CP reject with a proper 400 */
0 commit comments