import { a as ProjectRuntimeDatabase, c as ProjectRuntimeInput, d as ProjectRuntimeSleepInput, f as ProjectRuntimeWakeInput, i as ProjectRuntime, l as ProjectRuntimeReconcileInput, m as parseOrgArtifactsFromEnv, n as OrgProjectDeploy, o as ProjectRuntimeDestroyInput, p as encodeOrgArtifacts, r as ProjectPingTarget, s as ProjectRuntimeHosting, t as OrgArtifactSpec, u as ProjectRuntimeResult } from "./runtime-Cp906goK.mjs"; import { a as WorkerRuntimeConfig, i as OrganizationHostingResult, n as HostingPlugin, o as WorkerRuntimeConfigError, r as OrganizationHostingInput, s as resolveWorkerRuntimeConfig, t as HostingOptions } from "./plugin-eiAXqE7P.mjs"; //#region src/constants.d.ts declare const PROJECT_SERVER_IMAGE = "keystroke/project-server:local"; declare const PROJECT_SERVER_PORT = 3000; declare const PROJECT_SERVER_ROOT = "/app"; declare const PROJECT_SERVER_FRAMEWORK_ROOT = "/opt/keystroke"; declare const PROJECT_SERVER_FRAMEWORK_NODE_MODULES = "/opt/keystroke/node_modules"; declare const PROJECT_SERVER_HEALTH: { readonly path: "/health"; readonly port: 3000; }; declare const PROJECT_SERVER_DEPLOY_STATUS: { readonly path: "/deploy-status"; readonly port: 3000; }; //#endregion //#region src/runtime-control.d.ts declare const PROJECT_SERVER_CONTROL: { readonly load: "/control/projects/load"; readonly promote: "/control/projects/promote"; readonly unload: "/control/projects/unload"; readonly port: 3000; }; type LoadProjectOnRuntimeInput = { projectId: string; artifactId: string; artifactVersion: number; storageKey: string; activate?: boolean; }; type RuntimeControlOptions = { fetchImpl?: typeof fetch; timeoutMs?: number; /** Bearer token — typically the org's WORKER_INTERNAL_TOKEN. */ workerToken?: string; }; declare class RuntimeControlUnavailableError extends Error { readonly status: number | undefined; constructor(message: string, options?: { status?: number; cause?: unknown; }); } declare function loadProjectOnRuntime(baseUrl: string, input: LoadProjectOnRuntimeInput, options?: RuntimeControlOptions): Promise; declare function promoteProjectOnRuntime(baseUrl: string, input: { projectId: string; artifactId: string; }, options?: RuntimeControlOptions): Promise; declare function unloadProjectOnRuntime(baseUrl: string, input: { projectId: string; artifactId: string; force?: boolean; }, options?: RuntimeControlOptions): Promise; /** True when the org runtime answers /health. */ declare function pingRuntimeHealth(baseUrl: string, options?: RuntimeControlOptions): Promise; //#endregion //#region src/runtime-env.d.ts /** Env keys that must never be forwarded into untrusted org workers. */ declare const FORBIDDEN_WORKER_ENV_KEYS: readonly ["BETTER_AUTH_SECRET", "BETTER_AUTH_API_KEY", "DATABASE_URL", "POSTHOG_API_KEY", "POSTGRES_PASSWORD", "PLATFORM_WORKER_TOKEN", "STRIPE_SECRET_KEY", "CREDENTIAL_ENCRYPTION_KEY", "MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET", "MODEL_TOKEN_SECRET", "TURNSTILE_SECRET", "UPSTASH_REDIS_URL"]; /** Shared dev token when `PLATFORM_WORKER_TOKEN` is unset (non-production only). */ declare const DEV_PLATFORM_WORKER_TOKEN = "dev-platform-worker-token"; type RuntimeLaunchSpec = { image: string; env: Record; port: number; health: typeof PROJECT_SERVER_HEALTH; }; /** * Builds the launch spec for an org worker. Each deploy artifact is encoded in * `KEYSTROKE_ORG_ARTIFACTS` — there is no base image, so at least one artifact is required. */ declare function resolveRuntimeLaunch(options: HostingOptions, artifacts: OrgArtifactSpec[], database: ProjectRuntimeDatabase, extraEnv?: Record): RuntimeLaunchSpec; /** Env vars passed into the org worker container/machine. */ declare function buildRuntimeEnv(source: NodeJS.ProcessEnv, artifacts: OrgArtifactSpec[], database: ProjectRuntimeDatabase, extraEnv?: Record): Record; declare function resolvePlatformWorkerToken(source?: NodeJS.ProcessEnv): string | undefined; /** Platform API URL reachable from a project-server container. */ declare function resolveWorkerPlatformUrl(source?: NodeJS.ProcessEnv): string | undefined; /** Rewrite loopback hosts so containers can reach Postgres and other host services. */ declare function rewriteLoopbackHost(host: string): string; declare function rewriteLoopbackUrl(url: string): string; /** dockerode expects `KEY=value` strings. */ declare function formatDockerEnv(env: Record): string[]; declare function resolveProjectServerImage(env?: NodeJS.ProcessEnv, override?: string): string; //#endregion //#region src/org-worker-token.d.ts /** * Per-org worker token: `{organizationId}.{hmac}`. Self-describing so the * platform can tell which org a machine is calling as, and stateless — verified * by re-signing with the shared `PLATFORM_WORKER_TOKEN` secret. */ declare function mintOrgWorkerToken(secret: string, organizationId: string): string; type VerifiedOrgWorkerToken = { organizationId: string; }; declare function verifyOrgWorkerToken(secret: string | undefined, token: string | undefined): VerifiedOrgWorkerToken | undefined; //#endregion //#region src/wait-for-health.d.ts type WaitForHealthOptions = { timeoutMs?: number; intervalMs?: number; fetchImpl?: typeof fetch; }; declare function waitForHealth(baseUrl: string, options?: WaitForHealthOptions): Promise; //#endregion //#region src/runtime-constants.d.ts /** Timeout for a single project runtime `/health` probe. */ declare const RUNTIME_PING_TIMEOUT_MS = 15000; //#endregion //#region src/ping-project.d.ts type PingProjectOptions = { runtimeId?: string | null; fetchImpl?: typeof fetch; timeoutMs?: number; plugin?: Pick; }; declare function pingProject(baseUrl: string, options?: PingProjectOptions): Promise; //#endregion //#region src/ping-project-target.d.ts declare function canPingProjectTarget(target: ProjectPingTarget, plugin?: Pick): target is { baseUrl: string; runtimeId: string | null; }; declare function pingProjectTarget(target: ProjectPingTarget, options?: PingProjectOptions & { plugin?: Pick; }): Promise; //#endregion //#region src/deploy-status.d.ts /** Per-project bootstrap outcome reported by an org runtime machine. */ type ProjectDeployStatus = { projectId: string; ok: boolean; error?: string; }; type VersionDeployStatus = { projectId: string; artifactId: string; state: "active" | "resident" | "indexed"; ok: boolean; activeJobCount?: number; error?: string; }; type DeployStatusResponse = { projects: ProjectDeployStatus[]; versions?: VersionDeployStatus[]; }; type FetchDeployStatusOptions = { fetchImpl?: typeof fetch; timeoutMs?: number; }; type WaitForDeployStatusOptions = { fetchImpl?: typeof fetch; timeoutMs?: number; intervalMs?: number; }; /** * Ask a running org machine which projects bootstrapped and which failed. * Returns undefined when the endpoint is unreachable, non-OK, times out, or * returns an unusable payload — callers must treat that as non-affirmative * health for every pending project (never promote on silence). */ declare function fetchDeployStatus(baseUrl: string, options?: FetchDeployStatusOptions): Promise; /** * Poll `/deploy-status` until the real worker returns a usable payload or the * deadline expires. Retries only transient unavailability (network errors, * non-2xx including early-health 404, timeouts, malformed bodies). Any valid * `{ projects: [...] }` response — including empty or explicit failures — is * terminal so genuine bootstrap errors surface immediately. */ declare function waitForDeployStatus(baseUrl: string, options?: WaitForDeployStatusOptions): Promise; type DeployHealthVerdict = { ok: true; } | { ok: false; error: string; }; /** * Require an explicit `{ projectId, ok: true }` entry for each candidate. * Missing entries, `ok: false`, empty `projects`, or an unavailable status * response all fail closed for that project. */ declare function classifyDeployHealth(input: { projectIds: string[]; deployStatus: DeployStatusResponse | undefined; }): Map; //#endregion export { DEV_PLATFORM_WORKER_TOKEN, type DeployHealthVerdict, type DeployStatusResponse, FORBIDDEN_WORKER_ENV_KEYS, type FetchDeployStatusOptions, type HostingOptions, type HostingPlugin, type LoadProjectOnRuntimeInput, type OrgArtifactSpec, type OrgProjectDeploy, type OrganizationHostingInput, type OrganizationHostingResult, PROJECT_SERVER_CONTROL, PROJECT_SERVER_DEPLOY_STATUS, PROJECT_SERVER_FRAMEWORK_NODE_MODULES, PROJECT_SERVER_FRAMEWORK_ROOT, PROJECT_SERVER_HEALTH, PROJECT_SERVER_IMAGE, PROJECT_SERVER_PORT, PROJECT_SERVER_ROOT, type PingProjectOptions, type ProjectDeployStatus, type ProjectPingTarget, type ProjectRuntime, type ProjectRuntimeDatabase, type ProjectRuntimeDestroyInput, type ProjectRuntimeHosting, type ProjectRuntimeInput, type ProjectRuntimeReconcileInput, type ProjectRuntimeResult, type ProjectRuntimeSleepInput, type ProjectRuntimeWakeInput, RUNTIME_PING_TIMEOUT_MS, type RuntimeControlOptions, RuntimeControlUnavailableError, type RuntimeLaunchSpec, type VerifiedOrgWorkerToken, type VersionDeployStatus, type WaitForDeployStatusOptions, type WaitForHealthOptions, type WorkerRuntimeConfig, WorkerRuntimeConfigError, buildRuntimeEnv, canPingProjectTarget, classifyDeployHealth, encodeOrgArtifacts, fetchDeployStatus, formatDockerEnv, loadProjectOnRuntime, mintOrgWorkerToken, parseOrgArtifactsFromEnv, pingProject, pingProjectTarget, pingRuntimeHealth, promoteProjectOnRuntime, resolvePlatformWorkerToken, resolveProjectServerImage, resolveRuntimeLaunch, resolveWorkerPlatformUrl, resolveWorkerRuntimeConfig, rewriteLoopbackHost, rewriteLoopbackUrl, unloadProjectOnRuntime, verifyOrgWorkerToken, waitForDeployStatus, waitForHealth }; //# sourceMappingURL=index.d.mts.map