evOo-local/packages/adapters/src/sandbox-provider-env.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

25 lines
1.0 KiB
TypeScript

/** Empty or remote provider without a key becomes none so services can boot for signup. */
export function resolveSandboxProvider(source: NodeJS.ProcessEnv = process.env): string {
const configured = source.SANDBOX_PROVIDER;
if (configured !== undefined && !configured.trim()) return "none";
const requested = configured?.trim() || "docker";
if (requested === "none") return "none";
if (requested === "e2b" && !optional(source.E2B_API_KEY)) return "none";
if (requested === "daytona" && !optional(source.DAYTONA_API_KEY)) return "none";
if (requested === "box" && !optional(source.BOX_API_KEY)) return "none";
// Production without a supervisor token cannot run Docker computers; boot as none instead of exiting.
if (
requested === "docker" &&
source.NODE_ENV === "production" &&
!optional(source.SANDBOX_SUPERVISOR_TOKEN)
) {
return "none";
}
return requested;
}
function optional(value: string | undefined): string | undefined {
const trimmed = value?.trim();
return trimmed || undefined;
}