INNER CODE UNIT · TypeScript
resolveSandbox
bex-co/beancount-io · backend-cluster/agent-box/src/features/control-plane/index.ts:40
function resolveSandbox(c: Context): SandboxLike {
const env = c.env as Env;
const name = c.req.param('name')!;
// getSandbox returns the concrete Sandbox; SandboxLike is the structural
// subset the handlers touch.
//
// Local dev only: keepAlive stops `wrangler dev` from idle-stopping the
// container mid-turn (which would make the harness bridge's preview URL
// "stale"). Gated on LOCAL_KEEP_ALIVE so production keeps its default,
// self-sleeping lifecycle.
const options = env.LOCAL_KEEP_ALIVE ? { keepAlive: true } : undefined;
return getSandbox(env.Sandbox, name, options) as unknown as SandboxLike;
}
async function parseBody<T>(
c: Context,
schema: ZodType<T>,
): Promise<{ ok: true; data: T } | { ok: false; response: Response }> {