import { PLAY_RUNTIME_BACKENDS, PLAY_ARTIFACT_KINDS, type PlayArtifactKind, type PlayRuntimeBackendId, } from './backend'; import { PLAY_SCHEDULER_BACKENDS, type PlaySchedulerBackendId, } from './scheduler-backend'; export const PLAY_RUNTIME_PROVIDER_IDS = { absurd: 'absurd', } as const; export type PlayRuntimeProviderId = (typeof PLAY_RUNTIME_PROVIDER_IDS)[keyof typeof PLAY_RUNTIME_PROVIDER_IDS]; export type PlayRuntimeProviderDescriptor = { id: PlayRuntimeProviderId; scheduler: PlaySchedulerBackendId; runner: PlayRuntimeBackendId; artifactKind: PlayArtifactKind; label: string; }; export const PLAY_RUNTIME_PROVIDERS: Record< PlayRuntimeProviderId, PlayRuntimeProviderDescriptor > = { absurd: { id: PLAY_RUNTIME_PROVIDER_IDS.absurd, scheduler: PLAY_SCHEDULER_BACKENDS.absurd, // Server runs execute on Daytona; the local-dev/test shape swaps the runner // axis to local_process (same as the local profile) via an explicit // runtimeBackend override at submit while tests drive local_process. runner: PLAY_RUNTIME_BACKENDS.daytona, artifactKind: PLAY_ARTIFACT_KINDS.cjsNode20, label: 'Absurd (Postgres-native durable) scheduler + one-shot Daytona runner', }, }; export function defaultPlayRuntimeProvider(): PlayRuntimeProviderDescriptor { return PLAY_RUNTIME_PROVIDERS.absurd; } export function resolvePlayRuntimeProvider( override?: string | null, ): PlayRuntimeProviderDescriptor { if (override?.trim()) { const id = override.trim(); if (id in PLAY_RUNTIME_PROVIDERS) { return PLAY_RUNTIME_PROVIDERS[id as PlayRuntimeProviderId]; } throw new Error( `Unsupported play runtime provider "${id}". Expected one of: ${Object.keys( PLAY_RUNTIME_PROVIDERS, ).join(', ')}.`, ); } return defaultPlayRuntimeProvider(); } export function resolveEnabledPlayRuntimeProvider( override?: string | null, ): PlayRuntimeProviderDescriptor { return resolvePlayRuntimeProvider(override); }