@@ -257,6 +257,10 @@ export default Alchemy.Stack(
257257 workspaceInactivityMs : Config . option (
258258 Config . number ( "DX_DEPLOYMENT_WORKSPACE_INACTIVITY_MS" ) ,
259259 ) ,
260+ turnstileTestKeys : Config . withDefault (
261+ Config . boolean ( "DX_DEPLOYMENT_TURNSTILE_TEST_KEYS" ) ,
262+ false ,
263+ ) ,
260264 e2bApiKey : Config . option ( Config . redacted ( "E2B_API_KEY" ) ) ,
261265 githubApp : Config . option ( Config . redacted ( "DX_INTEGRATION_GITHUB_APP" ) ) ,
262266 sarvamApiKey : Config . option ( Config . redacted ( "SARVAM_API_KEY" ) ) ,
@@ -269,6 +273,13 @@ export default Alchemy.Stack(
269273 deploymentZone : Config . option (
270274 Config . nonEmptyString ( "DX_DEPLOYMENT_ZONE" ) ,
271275 ) ,
276+ workersDevSubdomain : Config . option (
277+ Config . nonEmptyString ( "DX_DEPLOYMENT_WORKERS_DEV_SUBDOMAIN" ) ,
278+ ) ,
279+ daemonIngressName : Config . withDefault (
280+ Config . nonEmptyString ( "DX_DEPLOYMENT_DAEMON_INGRESS_NAME" ) ,
281+ "dx-dxd" ,
282+ ) ,
272283 signupEnabled : Config . withDefault (
273284 Config . boolean ( "DX_SIGNUP_ENABLED" ) ,
274285 false ,
@@ -357,6 +368,14 @@ export default Alchemy.Stack(
357368 } as never )
358369 : undefined ;
359370
371+ if (
372+ configuration . turnstileTestKeys &&
373+ configuration . environment !== "preview"
374+ )
375+ return yield * Effect . die (
376+ "DX_DEPLOYMENT_TURNSTILE_TEST_KEYS is restricted to previews." ,
377+ ) ;
378+
360379 if ( Option . isSome ( configuration . workspaceInactivityMs ) ) {
361380 const inactivityMs = configuration . workspaceInactivityMs . value ;
362381 if ( configuration . environment !== "preview" )
@@ -390,6 +409,15 @@ export default Alchemy.Stack(
390409 }
391410
392411 const deploymentHostname = new URL ( configuration . origin ) . hostname ;
412+ // A resumed guest's daemon reconnects through a dependency-free Worker on
413+ // the account's workers.dev subdomain. Its isolate starts in milliseconds,
414+ // where the Core bundle's cold start (about a second) otherwise sits on
415+ // every wake. Without a workers.dev subdomain Core serves ingress itself.
416+ const daemonIngressName = configuration . daemonIngressName ;
417+ const daemonIngressOrigin = Option . map (
418+ configuration . workersDevSubdomain ,
419+ ( subdomain ) => `https://${ daemonIngressName } .${ subdomain } .workers.dev/` ,
420+ ) ;
393421 const database = yield * Cloudflare . D1 . Database ( "Database" , {
394422 name : configuration . databaseName ,
395423 migrations : `apps/core/${ migrationManifest . d1Directory } ` ,
@@ -398,13 +426,20 @@ export default Alchemy.Stack(
398426 name : configuration . bucketName ,
399427 forceDestroy : false ,
400428 } ) ;
401- const turnstile = hostedAuthentication
402- ? yield * Cloudflare . Turnstile . Widget ( "AccessTurnstile" , {
403- name : `dx access · ${ deploymentHostname } ` ,
404- domains : [ deploymentHostname ] ,
405- mode : "managed" ,
406- } )
407- : undefined ;
429+ // Previews may use Cloudflare's published always-pass test keys instead of
430+ // creating a widget, because the account caps widgets at 20.
431+ const turnstile = ! hostedAuthentication
432+ ? undefined
433+ : configuration . turnstileTestKeys
434+ ? {
435+ sitekey : "1x00000000000000000000AA" ,
436+ secret : "1x0000000000000000000000000000000AA" ,
437+ }
438+ : yield * Cloudflare . Turnstile . Widget ( "AccessTurnstile" , {
439+ name : `dx access · ${ deploymentHostname } ` ,
440+ domains : [ deploymentHostname ] ,
441+ mode : "managed" ,
442+ } ) ;
408443 const email = hostedAuthentication
409444 ? yield * Cloudflare . Email . SendEmail ( "MagicLinkEmail" , {
410445 allowedSenderAddresses : [
@@ -465,7 +500,7 @@ export default Alchemy.Stack(
465500 `${ configuration . e2bTemplate } -${ defaultE2BOrbProfile . templateSuffix } ` ,
466501 DX_E2B_TEMPLATE_BUILD_ID :
467502 selfhostProfiles ?. defaultBuildId ?? configuration . e2bTemplateBuildId ,
468- DX_E2B_TIMEOUT_MS : "600000 " ,
503+ DX_E2B_TIMEOUT_MS : "300000 " ,
469504 ...( Option . isSome ( configuration . workspaceInactivityMs )
470505 ? {
471506 DX_WORKSPACE_INACTIVITY_MS : String (
@@ -474,7 +509,10 @@ export default Alchemy.Stack(
474509 }
475510 : { } ) ,
476511 DX_DEPLOYMENT_REVISION : configuration . revision ,
477- DX_DXD_PUBLIC_URL : configuration . origin ,
512+ DX_DXD_PUBLIC_URL : Option . getOrElse (
513+ daemonIngressOrigin ,
514+ ( ) => configuration . origin ,
515+ ) ,
478516 DX_DXD_RELEASE_URL : configuration . dxdReleaseUrl ,
479517 DX_DXD_RELEASE_SHA256 : configuration . dxdChecksum ,
480518 DX_MIGRATION_MANIFEST_VERSION : String ( migrationManifest . version ) ,
@@ -670,6 +708,25 @@ export default Alchemy.Stack(
670708 : { } ) ,
671709 } ) ;
672710
711+ // The Thread execution object checks the key; this Worker only forwards.
712+ if ( Option . isSome ( daemonIngressOrigin ) )
713+ yield * Cloudflare . Worker ( "DaemonIngress" , {
714+ name : daemonIngressName ,
715+ main : "apps/core/src/threads/daemon-ingress.ts" ,
716+ compatibility : { date : "2026-08-20" } ,
717+ env : {
718+ THREAD_EXECUTION : Cloudflare . DurableObject ( "THREAD_EXECUTION" , {
719+ className : "ThreadExecutionObject" ,
720+ scriptName : worker . workerName ,
721+ } ) ,
722+ } ,
723+ workersDev : true ,
724+ observability : {
725+ enabled : true ,
726+ logs : { enabled : true , invocationLogs : true } ,
727+ } ,
728+ } ) ;
729+
673730 if ( ! selfhost )
674731 yield * Command . Exec ( "Verify" , {
675732 command : "node scripts/verify-alchemy-preview.mjs" ,
0 commit comments