import type { BrowserLock } from "./browser-lock.js";
export interface ChromeWatchdogOptions {
    /** How often to check Chrome runtime (ms). */
    checkIntervalMs: number;
    /** Restart Chrome once uptime exceeds this (ms). */
    maxRuntimeMs: number;
    /** Skip restart if a scheduled task is due within this much time (ms). */
    minLeadMs: number;
    /**
     * Close Chrome (keeping workspace lock) once it has been idle this long.
     * The next browser action lazily re-launches in-place. Disabled when
     * null/undefined.
     */
    idleCloseMs?: number | null;
    /** Skip idle-close if a scheduled task is due within this much time. */
    idleCloseMinLeadMs?: number;
    /**
     * Separate, typically faster cadence for idle-close polling. If unset,
     * the watchdog uses checkIntervalMs for both checks. Idle-close benefits
     * from a tighter loop (e.g. 60s) so it doesn't drag past the configured
     * threshold by a full check interval.
     */
    idleCheckIntervalMs?: number;
}
export interface ChromeWatchdogDeps {
    lock: BrowserLock;
    /** Current Chrome uptime in ms, or null if not launched. */
    getUptimeMs: () => number | null;
    /** Ms since last browser-touching operation, or null if not launched. */
    getIdleMs: () => number | null;
    /** Next scheduled task time, or null if none. */
    getNextRun: () => Date | null;
    /** Restart Chrome with the given reason. Caller holds the browser lock. */
    restartBrowser: (reason: string) => Promise<void>;
    /**
     * Close Chrome but keep workspace ownership for in-place relaunch.
     * Caller holds the browser lock. Used by idle-close.
     */
    closeBrowser: (reason: string) => Promise<void>;
}
/**
 * Periodically supervise Chrome:
 *  - Idle-close: if Chrome has been idle past idleCloseMs and nothing else
 *    is using or about to use it, close it (keeping the workspace lock).
 *    The next chat / scheduled task triggers a lazy in-place relaunch.
 *  - Aged-restart: if Chrome uptime exceeds maxRuntimeMs, do a full
 *    restart while idle — long-running renderers accumulate heap /
 *    decoded images / DOM that aren't released until tabs close, so this
 *    bounds memory growth over multi-day sessions.
 *
 * Both checks bail when the browser lock is busy or a scheduled task is
 * within its configured lead time, and both re-check inside the lock to
 * avoid acting on data that changed while queued.
 */
export declare class ChromeWatchdog {
    private readonly options;
    private readonly deps;
    private agedTimer;
    private idleTimer;
    constructor(options: ChromeWatchdogOptions, deps: ChromeWatchdogDeps);
    start(): void;
    stop(): void;
    /**
     * Aged-restart iteration. Exposed for testing / manual triggering;
     * normally driven by the interval timer.
     */
    tickAgedRestart(): Promise<void>;
    /**
     * Idle-close iteration. Only runs when idleCloseMs is configured.
     * Exposed for testing / manual triggering.
     */
    tickIdleClose(): Promise<void>;
    private hasScheduledTaskSoon;
}
