the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

run sandbox configs in background on start

+47 -41
+47 -41
apps/cf-sandbox/src/index.ts
··· 378 378 .execute(), 379 379 ]); 380 380 381 - await sandbox.setEnvs({ 382 - ...params[0] 383 - .map(({ variables }) => variables) 384 - .filter((v) => v !== null) 385 - .reduce( 386 - (acc, v) => { 387 - acc[v.name] = v.value; 388 - return acc; 389 - }, 390 - {} as Record<string, string>, 391 - ), 392 - ...Object.fromEntries( 393 - await Promise.all( 394 - params[1] 395 - .map(({ secrets }) => secrets) 396 - .filter((v) => v !== null) 397 - .map(async (v) => [v.name, await decrypt(v.value)] as const), 381 + c.executionCtx.waitUntil( 382 + sandbox.setEnvs({ 383 + ...params[0] 384 + .map(({ variables }) => variables) 385 + .filter((v) => v !== null) 386 + .reduce( 387 + (acc, v) => { 388 + acc[v.name] = v.value; 389 + return acc; 390 + }, 391 + {} as Record<string, string>, 392 + ), 393 + ...Object.fromEntries( 394 + await Promise.all( 395 + params[1] 396 + .map(({ secrets }) => secrets) 397 + .filter((v) => v !== null) 398 + .map(async (v) => [v.name, await decrypt(v.value)] as const), 399 + ), 398 400 ), 399 - ), 400 - }); 401 + }), 402 + ); 401 403 402 - await sandbox.sh`[ -f /root/.ssh/id_ed25519 ] || ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -q -N "" || true`; 404 + c.executionCtx.waitUntil( 405 + sandbox.sh`[ -f /root/.ssh/id_ed25519 ] || ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -q -N "" || true`, 406 + ); 403 407 404 408 const { hostname } = new URL(c.req.url); 405 409 406 - await Promise.all([ 407 - ...params[2] 408 - .filter((x) => x.files !== null) 409 - .map(async (record) => 410 - sandbox?.writeFile( 411 - record.sandbox_files.path, 412 - await decrypt(record.files!.content), 410 + c.executionCtx.waitUntil( 411 + Promise.all([ 412 + ...params[2] 413 + .filter((x) => x.files !== null) 414 + .map(async (record) => 415 + sandbox?.writeFile( 416 + record.sandbox_files.path, 417 + await decrypt(record.files!.content), 418 + ), 413 419 ), 414 - ), 415 - ...params[3].map(async (record) => 416 - sandbox?.setupSshKeys( 417 - await decrypt(record.privateKey), 418 - record.publicKey, 420 + ...params[3].map(async (record) => 421 + sandbox?.setupSshKeys( 422 + await decrypt(record.privateKey), 423 + record.publicKey, 424 + ), 419 425 ), 420 - ), 421 - params[4].length > 0 && 422 - sandbox?.setupTailscale(await decrypt(params[4][0].authKey)), 423 - ...params[5].map((volume) => 424 - sandbox?.mount( 425 - volume.sandbox_volumes.path, 426 - `/${volume.users?.did || ""}${volume.users?.did ? "/" : ""}${volume.sandbox_volumes.id}/`, 426 + params[4].length > 0 && 427 + sandbox?.setupTailscale(await decrypt(params[4][0].authKey)), 428 + ...params[5].map((volume) => 429 + sandbox?.mount( 430 + volume.sandbox_volumes.path, 431 + `/${volume.users?.did || ""}${volume.users?.did ? "/" : ""}${volume.sandbox_volumes.id}/`, 432 + ), 427 433 ), 428 - ), 429 - ]); 434 + ]), 435 + ); 430 436 431 437 if (record.repo) { 432 438 c.executionCtx.waitUntil(