import type { IncomingMessage, ServerResponse } from 'node:http'; import type { WorkspaceSourceRequest } from './dist-lib/types/workspace/source/flowContracts.js'; import type { WorkspaceTokenSourceRequest } from './dist-lib/types/workspace/tokens/contracts.js'; import type { WorkspaceApplicationSurface } from './dist-lib/types/workspace/contracts.js'; export type WorkspaceDraftSourceRequest = WorkspaceSourceRequest | WorkspaceTokenSourceRequest; export interface WorkspaceDraftScreen { id: string; route: string; recipe: import('./dist-lib/types/workspace/source/draftRecipe.js').WorkspaceDraftRecipe; environment?: import('./storyboard.js').StoryboardCaptureOptions['screenCase']['environment']; [key: string]: unknown; } export interface WorkspaceDraftSurface extends WorkspaceApplicationSurface { screens?: readonly WorkspaceDraftScreen[]; screenManifestHash?: string; } export interface WorkspaceDraftPreviewServiceOptions { projectRoot: string; appDirectory?: string; /** Existing node_modules directory reused by the trusted isolated build. */ dependenciesRoot?: string; /** * Stage proven working-copy inputs in the disposable archive. Full request proofs are checked afterward. * `appRoot` holds exactly `sourceRevision` (the request target), materialized from the repository * history rather than the working tree, so another revision than the checkout can be built honestly. */ prepareSource?(context: { appRoot: string; request: WorkspaceDraftSourceRequest; sourceRevision: string; signal: AbortSignal }): Promise; /** Resolve complete impact against the isolated baseline before changes remove dependency edges. */ resolveScreens?(context: { appRoot: string; request: WorkspaceDraftSourceRequest; sourceRevision: string; signal: AbortSignal }): Promise; /** Must stop and settle when aborted; outputDirectory must contain a completed static app. */ build(context: { appRoot: string; outputDirectory: string; request: WorkspaceDraftSourceRequest; sourceRevision: string; documentRevision: string; screens?: readonly WorkspaceDraftScreen[]; signal: AbortSignal }): Promise; /** Return true after handling a host API request. False or void allows static routing. */ handleRequest?(request: IncomingMessage, response: ServerResponse, context: { request: WorkspaceDraftSourceRequest; sourceRevision: string }): boolean | void | Promise; /** * Remote deployment: reverse proxy each dedicated browser origin to its loopback port. * Each origin must differ from the editor and every other entry. Proxy the complete * origin (including root-relative assets and APIs), preserving its Host or rewriting * Host to 127.0.0.1:. Do not forward editor credentials or expose editor routes * on a preview origin. A separate hostname also isolates host-scoped cookies. * Origins are reserved through build and playback, then released on cancellation. * Exhaustion rejects immediately; this service never replaces another active lease. * Omit for local, ephemeral loopback origins. Service worker installation is blocked. */ remoteOrigins?: readonly { port: number; origin: string }[]; /** Active builds and ready origins count toward this bound. Default: min(3, configured origins). */ maxRuns?: number; maxOutputFiles?: number; maxOutputBytes?: number; } export declare function createWorkspaceDraftPreviewService(options: WorkspaceDraftPreviewServiceOptions): { /** The host must validate file-plan requests with its canonical compiler before preparing a build. */ prepare(input: { request: WorkspaceDraftSourceRequest; documentRevision: string; route: string }, options?: { signal?: AbortSignal }): Promise; /** Abort builds, close origins, and remove every temporary archive. */ dispose(): Promise; }; /** Minimal Vite-compatible boundary; headless service consumers do not require Vite types. */ export declare function workspaceDraftPreviewPlugin(options: { service: ReturnType; endpoint?: string; /** The built app reports its recipe result through the workspace ready-message protocol. */ waitForReady?: boolean; /** Validate file-plan source semantics with the host compiler, not only browser-supplied fingerprints. */ resolveRequest(input: unknown, options: { signal: AbortSignal }): { request: WorkspaceDraftSourceRequest; documentRevision: string; route: string } | Promise<{ request: WorkspaceDraftSourceRequest; documentRevision: string; route: string }>; }): { name: string; apply: 'serve'; configureServer(server: { httpServer?: { once(event: 'close', listener: () => void): unknown } | null; config: { logger: { error(message: string): void } }; middlewares: { use(handler: (request: IncomingMessage, response: ServerResponse, next: () => void) => void | Promise): unknown }; }): void; }; export interface WorkspaceRevisionPreviewRequest { sourceKind: 'revision'; target: { sourceRevision: string; screenId: string }; context: unknown; } export interface WorkspaceRevisionPreviewOptions extends Omit { resolveScreens?(context: { appRoot: string; request: WorkspaceRevisionPreviewRequest; sourceRevision: string; signal: AbortSignal }): Promise; build(context: { appRoot: string; outputDirectory: string; request: WorkspaceRevisionPreviewRequest; sourceRevision: string; documentRevision: string; screens?: readonly WorkspaceDraftScreen[]; signal: AbortSignal }): Promise; handleRequest?(request: IncomingMessage, response: ServerResponse, context: { request: WorkspaceRevisionPreviewRequest; sourceRevision: string }): boolean | void | Promise; } /** Server-only zero-change QA; browser draft requests still require complete source proofs. */ export declare function createWorkspaceRevisionPreviewService(options: WorkspaceRevisionPreviewOptions): { prepare(input: { sourceRevision: string; screenId: string; route: string; context?: unknown }, options?: { signal?: AbortSignal }): Promise; dispose(): Promise; };