import { type ChildProcess } from "node:child_process"; import type { Readable, Transform, Writable } from "node:stream"; export interface RuntimeCommandResult { ok: boolean; stdout: string; stderr: string; code?: number | null; error?: string; } export interface RuntimeCommandOptions { env?: NodeJS.ProcessEnv; onOutput?: (chunk: string) => void; } export type RuntimeCommandRunner = (command: string, args: string[], options?: RuntimeCommandOptions) => Promise; export interface RuntimeCommandRunnerLimits { timeoutMs: number; killGraceMs: number; maxOutputUnits?: number; } /** * Build a runtime-management command runner with one bounded process lifecycle. * Output is retained as chunk tails and flattened once, after the child reaches a terminal state. */ export declare function createRuntimeCommandRunner(limits: RuntimeCommandRunnerLimits): RuntimeCommandRunner; type RuntimeCommandProbe = (command: string, args: string[], options: { encoding: "utf8"; timeout: number; }) => { error?: unknown; }; export declare function runtimeCommandAvailable(command: string, probe?: RuntimeCommandProbe): boolean; export declare function runtimeSleep(ms: number): Promise; export type ManagedRuntimeChild = Pick; export interface ManagedRuntimeSpawnOptions { detached?: boolean; stdio?: "ignore"; env: NodeJS.ProcessEnv; } export type ManagedRuntimeSpawn = (command: string, args: string[], options: ManagedRuntimeSpawnOptions) => ManagedRuntimeChild; export declare function spawnManagedRuntime(command: string, args: string[], options: ManagedRuntimeSpawnOptions): ManagedRuntimeChild; export interface RuntimeLifecycleDependencyOverrides { fetchFn?: typeof fetch; spawnFn?: ManagedRuntimeSpawn; existsFn?: (path: string) => boolean; sleepFn?: (ms: number) => Promise; } export type RuntimeLifecycleDependencies = readonly [ fetchFn: typeof fetch, spawnFn: ManagedRuntimeSpawn, existsFn: (path: string) => boolean, sleepFn: (ms: number) => Promise ]; /** Resolve the common runtime lifecycle boundary once, during construction. */ export declare function resolveRuntimeLifecycleDependencies(overrides?: RuntimeLifecycleDependencyOverrides): RuntimeLifecycleDependencies; export type RuntimeDownloadResult = { ok: true; response: Response; body: ReadableStream; } | { ok: false; error: string; }; type RuntimeFetch = (input: string | URL | Request, init?: RequestInit) => Promise; /** Validate a runtime download without consuming, decoding, or copying its response body. */ export declare function fetchRuntimeDownload(fetchFn: RuntimeFetch, url: string, init?: RequestInit): Promise; /** Download and extract a runtime archive without materializing or copying its body. */ export declare function installRuntimeArchive(fetchFn: RuntimeFetch, downloadUrl: string, destDir: string, asset: { name: string; kind: TKind; }, extractArchive: (input: TInput, destDir: string, kind: TKind) => Promise<{ ok: boolean; error?: string; }>, onProgress?: (status: string) => void): Promise<{ ok: boolean; error?: string; }>; export declare function tryFileSizeBytes(path: string): number | undefined; export declare function removePartialDownload(path: string): void; /** Wait for a failed pipeline's file descriptor to close before deleting its partial output. */ export declare function waitForWritableClosed(stream: Writable & { closed?: boolean; }): Promise; /** Stream a runtime payload to disk, closing and deleting partial output on any failure. */ export declare function writeRuntimeDownload(input: Readable, destPath: string, transform?: Transform): Promise<{ ok: true; } | { ok: false; error: string; }>; export declare function requireRuntimeStdin(proc: ChildProcess, label: string): Writable; export interface ExtractZipArchiveOptions { input: Readable; destDir: string; tempPrefix: string; platform: () => string; hasCommand: (command: string) => boolean; timeoutMs: number; killGraceMs: number; } /** Shared seekable-file extraction path for managed runtime zip archives. */ export declare function extractZipArchive(options: ExtractZipArchiveOptions): Promise<{ ok: boolean; error?: string; }>; export {}; //# sourceMappingURL=runtime-process.d.ts.map