import type { Browser } from 'playwright';
import type { BrowserSetupCandidate, BrowserSetupDriver } from './types.js';
import { type BrowserProcessLease } from './pool.js';
/** Owner for private pools keyed by one driver, source, and generation. */
export interface BrowserReuseManager {
    /** Acquires only from the exact key, retiring a previous generation first. */
    acquire: (key: string, launch: () => Promise<Browser>) => Promise<BrowserProcessLease>;
    /** Retires the current pool without interrupting an already-issued lease. */
    invalidate: () => void;
    /** Confirms cleanup of the current pool and any completed retirements. */
    close: () => Promise<void>;
}
/** Dependencies for generation-scoped optional browser reuse. */
export interface BrowserReuseManagerOptions {
    /** Maximum idle lifetime for each retained process. */
    readonly idleTimeoutMs: number;
    /** Confirmed browser-process close; production uses the shared Playwright cleanup helper. */
    readonly closeBrowser?: (browser: Browser) => Promise<unknown>;
    /** Clears cached setup proof when an owned browser exits unexpectedly. */
    readonly onBrowserDisconnected?: (key: string, browser: Browser) => void;
    /** Resets selected-candidate proof before publishing a disconnected observation. */
    readonly resetCandidate?: () => void;
    /** Suppresses stale-process observations after its owner revision changes. */
    readonly isCurrentKey?: (key: string) => boolean;
    /** Makes idle-expiry cleanup uncertainty terminal for the setup owner. */
    readonly onCleanupFailure?: (error: unknown) => void;
}
/** Optional exact identity required before a candidate may use a retained process. */
export interface BrowserReuseIdentity {
    /** Current owner generation. */
    readonly generation: number;
    /** Selected private Playwright package identity. */
    readonly driver: BrowserSetupDriver;
    /** Candidate renderer identity. */
    readonly candidate: BrowserSetupCandidate;
}
/** Acquires one process; every new process receives the neutral candidate probe. */
export declare function acquireCandidateBrowser(options: {
    driver: BrowserSetupDriver;
    candidate: BrowserSetupCandidate;
    signal: AbortSignal;
    deadline: number;
    isActive: () => boolean;
    probe: boolean;
    manager?: BrowserReuseManager;
    generation?: number;
}): Promise<BrowserProcessLease>;
/** Creates lazy browser pools without allowing refresh to reassign active captures. */
export declare function createBrowserReuseManager(options: BrowserReuseManagerOptions): BrowserReuseManager;
/** Releases an acquired handle if cancellation or deadline wins before owner handoff. */
export declare function assertAcquiredCandidateAuthority(options: {
    lease: BrowserProcessLease;
    signal: AbortSignal;
    deadline: number;
    isActive: () => boolean;
}): Promise<void>;
//# sourceMappingURL=reuse.d.ts.map