#!/usr/bin/env tsx import { spawn, type ChildProcess } from "node:child_process"; import http from "node:http"; import { type WorkspaceAppAudience } from "../shared/workspace-app-audience.js"; export interface WorkspaceApp { id: string; name: string; description: string; audience: WorkspaceAppAudience; publicPaths: string[]; protectedPaths: string[]; dir: string; port: number; process?: ChildProcess; restartTimer?: NodeJS.Timeout; restartAttempts?: number; lastFailure?: { code: number | null; signal: NodeJS.Signals | null; at: number; installing: boolean; output: string; nextRetryAt: number; }; outputTail?: string; installing?: boolean; installAttempted?: boolean; /** * Set true once we've successfully connected to the upstream. After that we * skip the readiness probe on every request; the child server stays * listening for the rest of the dev session. */ ready?: boolean; readinessProbe?: Promise; } export interface WorkspaceDevOptions { args?: string[]; env?: NodeJS.ProcessEnv; root?: string; spawnProcess?: typeof spawn; openBrowser?: boolean; stdout?: Pick; stderr?: Pick; } export interface WorkspaceDevHandle { apps: WorkspaceApp[]; defaultApp: string; gatewayUrl: () => string; ready: Promise<{ port: number; url: string; }>; server: http.Server; shutdown: () => void; } export declare function isWorkspaceWatcherLimitError(err: Pick): boolean; export declare function shouldEagerStartWorkspaceApps(args?: string[], env?: NodeJS.ProcessEnv): boolean; /** * Whether the gateway should spawn the rest of the apps in the background * after the default app boots. Lazy spawn already covers correctness — this * is purely a UX optimization so the second/third/Nth app the user clicks * into is already warm instead of paying the Vite + esbuild prebundle cost * on demand. * * Defaults to ON in lazy mode. Off when the user passed --no-prewarm / * WORKSPACE_NO_PREWARM=1, or when eager mode is already starting every app * up front (in which case prewarm would be redundant). */ export declare function shouldPrewarmWorkspaceApps(args?: string[], env?: NodeJS.ProcessEnv): boolean; /** * How many apps to prewarm in parallel. Each Vite spawn briefly maxes out a * CPU core during esbuild prebundling, so booting all 9 templates at once on * a 4-core laptop just produces a thundering herd. Default 2 — gentle on * laptops, fast enough that all apps finish within a few cold-spawn windows. * Override via --prewarm-concurrency=N or WORKSPACE_PREWARM_CONCURRENCY=N. */ export declare function workspacePrewarmConcurrency(args?: string[], env?: NodeJS.ProcessEnv): number; /** * How long the prewarm queue waits after the gateway is ready before kicking * off background spawns. Lets the default app's prebundle get first dibs on * CPU. Override via WORKSPACE_PREWARM_DELAY_MS (mostly for tests). */ export declare function workspacePrewarmDelayMs(env?: NodeJS.ProcessEnv): number; export type PollingFileWatcherMode = "enable" | "disable-explicit" | "disable-default"; /** * Three-way classification of the polling-watcher decision so callers can * tell apart "the user explicitly turned this off" (where we want to override * any inherited chokidar/TSC env vars from the parent shell) from "we just * didn't auto-detect a Builder/Codespaces/Gitpod container" (where the user's * own watcher vars should pass through untouched). */ export declare function pollingFileWatcherMode(env?: NodeJS.ProcessEnv, root?: string): PollingFileWatcherMode; export declare function shouldUsePollingFileWatcher(env?: NodeJS.ProcessEnv, root?: string): boolean; export declare function initialWorkspaceAppIds(apps: Array>, defaultApp: string, eager: boolean, startDefault?: boolean): string[]; export declare function runWorkspaceDev(options?: WorkspaceDevOptions): Promise; //# sourceMappingURL=workspace-dev.d.ts.map