/**
 * Browser Manager
 *
 * Manages Puppeteer browser lifecycle: Chrome executable resolution,
 * launch args, pooled browser acquisition/release.
 */
import type { Browser, PuppeteerNode } from "puppeteer-core";
import { type EngineConfig } from "../config.js";
import { type BrowserLaunchFingerprint, type BrowserLease, type CaptureMode } from "./browserLeasePool.js";
export { BrowserLeasePool } from "./browserLeasePool.js";
export type { BrowserLaunchFingerprint, BrowserLease, BrowserPoolState, CaptureMode, } from "./browserLeasePool.js";
export type AcquiredBrowser = BrowserLease;
/**
 * Resolve chrome-headless-shell binary for deterministic BeginFrame rendering.
 * Checks config.chromePath, then PRODUCER_HEADLESS_SHELL_PATH env var,
 * then the CLI browser override, HyperFrames' managed cache, and Puppeteer's cache.
 */
export declare function resolveHeadlessShellPath(config?: Partial<Pick<EngineConfig, "chromePath">>): string | undefined;
export declare const ENABLE_BROWSER_POOL: boolean;
/**
 * Probe the complete HeadlessExperimental.beginFrame runtime contract.
 *
 * Domain registration alone is insufficient: BeginFrame control must be
 * enabled at launch and a renderer-ready target must return a real PNG.
 * Every operation shares one short deadline so a wedged CDP call cannot hold
 * a serverless cold start until Puppeteer's much longer protocol timeout.
 */
interface BeginFrameProbeResult {
    supported: boolean;
    detail: string;
    durationMs: number;
}
declare function closeBrowserAfterFailedProbe(browser: Browser, timeoutMs?: number): Promise<void>;
declare function probeBeginFrameSupport(browser: Browser, timeoutMs?: number): Promise<BeginFrameProbeResult>;
/** Test-only export for the renderer-readiness + PNG capability contract. */
export declare const _probeBeginFrameSupportForTests: typeof probeBeginFrameSupport;
/** Test-only export for the forced browser-cleanup fallback. */
export declare const _closeBrowserAfterFailedProbeForTests: typeof closeBrowserAfterFailedProbe;
/** Test-only: reset the cached probe result. */
export declare function _resetAutoBrowserGpuModeCacheForTests(): void;
/**
 * Resolve `browserGpuMode` to a concrete `"software" | "hardware"` answer.
 *
 * For `"software"` this is a pure pass-through. For `"auto"` it launches a
 * tiny Chrome with the platform's hardware GPU args, runs a one-shot WebGL
 * availability probe, and falls back to `"software"` if hardware-mode WebGL
 * is unavailable. The Promise is cached for the process lifetime, so
 * concurrent callers (parallel workers) share the same probe.
 *
 * `"hardware"` (an explicit `--browser-gpu` / `PRODUCER_BROWSER_GPU_MODE=
 * hardware`) is honoured verbatim — the operator asked for it — but runs the
 * SAME probe to VERIFY it, because Chrome's hardware GL args are advisory:
 * with no usable GPU in the sandbox (no `/dev/dri`, no NVIDIA container
 * runtime, missing EGL/driver libraries) Chrome silently falls back to
 * software WebGL and the render just runs at CPU speed. Without this check
 * the only trace is a buried `Automatic fallback to software WebGL` browser
 * warning — heygen-com/hyperframes#2967 rendered 19186 frames on CPU while
 * `--browser-gpu` was set and nothing said so. The probe result never
 * changes the returned mode; it only makes the fallback loud.
 *
 * Any probe failure (Chrome launch error, navigation timeout, missing canvas
 * API, etc.) is treated as a `"software"` result. The render path with
 * SwiftShader always works, so a misclassification toward software is the
 * safe failure mode; misclassifying toward hardware would error on the real
 * render.
 */
export declare function resolveBrowserGpuMode(mode: EngineConfig["browserGpuMode"], options?: {
    chromePath?: string;
    browserTimeout?: number;
    platform?: NodeJS.Platform;
}): Promise<"software" | "hardware">;
declare function createBrowserLaunchFingerprint(chromeArgs: string[], config?: Partial<Pick<EngineConfig, "browserTimeout" | "protocolTimeout" | "chromePath" | "forceScreenshot">>): BrowserLaunchFingerprint;
/** Test-only export for launch-argument/capture-mode agreement. */
export declare const _createBrowserLaunchFingerprintForTests: typeof createBrowserLaunchFingerprint;
export declare function acquireBrowser(chromeArgs: string[], config?: Partial<Pick<EngineConfig, "browserTimeout" | "protocolTimeout" | "enableBrowserPool" | "chromePath" | "forceScreenshot">>): Promise<AcquiredBrowser>;
export declare function releaseBrowser(browser: Browser, _config?: Partial<Pick<EngineConfig, "enableBrowserPool">>): Promise<void>;
export declare function forceReleaseBrowser(browser: Browser): void;
/**
 * Forcefully close the pooled browser if one exists, regardless of refCount.
 * Used for explicit cleanup at process exit or between independent render jobs
 * that should not share browser state.
 */
export declare function drainBrowserPool(): Promise<void>;
/** Test-only: reset all pool state. */
export declare function _resetBrowserPoolForTests(): void;
/** Test-only: inject a mock PuppeteerNode so tests bypass the dynamic import. */
export declare function _setPuppeteerForTests(mock: PuppeteerNode | undefined): void;
export interface BuildChromeArgsOptions {
    width: number;
    height: number;
    captureMode?: CaptureMode;
    platform?: NodeJS.Platform;
}
export declare function buildChromeArgs(options: BuildChromeArgsOptions, config?: Partial<Pick<EngineConfig, "browserGpuMode" | "disableGpu" | "chromePath">>): string[];
//# sourceMappingURL=browserManager.d.ts.map