import { type Hello, type PageInfo, type FrameInfo } from "./browser-protocol.js";
export interface BrowserHandoff {
    t: number;
    kind: "take" | "release" | "help";
    reason?: string;
}
export interface RecordingMeta {
    id: string;
    browserId: string;
    session: string;
    cwd: string;
    engine: string;
    headless: boolean;
    startedAt: number;
    endedAt: number | null;
    frames: number;
    bytes: number;
    pages: {
        pageId: string;
        url: string;
        title: string;
        t: number;
    }[];
    handoffs: BrowserHandoff[];
    navigations: {
        t: number;
        pageId: string;
        url: string;
        title: string;
    }[];
}
/**
 * What a watched page can make the Hook keep. Its URL, title and navigations
 * are the page's to choose, so each is cut to a size and the lists to a length:
 * the metadata file, rewritten whole on every change, stays under about 1 MB.
 */
export declare const RECORDING_LIMITS: {
    readonly url: 1024;
    readonly title: 200;
    readonly reason: 1024;
    readonly navigations: 500;
    readonly navigationsPerSecond: 10;
    readonly pages: 100;
    readonly handoffs: 500;
    readonly saveEveryMs: 1000;
};
interface IndexFrame {
    t: number;
    pageId: string;
    offset: number;
    length: number;
    width: number;
    height: number;
}
export declare function browserId(value: string | null): string;
export declare class BrowserRecordings {
    readonly root: string;
    private active;
    constructor(root: string);
    private dir;
    private save;
    /** Frames arrive up to four times a second; their counters reach the file at most once a second, and at the end. */
    private saveSoon;
    private saveNow;
    private forget;
    start(hello: Hello, now?: number): void;
    page(page: PageInfo, now?: number): void;
    frame(info: FrameInfo, jpeg: Buffer): void;
    handoff(id: string, kind: BrowserHandoff["kind"], reason?: string): void;
    end(id: string, now?: number): void;
    list(): RecordingMeta[];
    index(id: string): {
        meta: RecordingMeta;
        frames: IndexFrame[];
    };
    frameAt(id: string, n: number): Buffer;
    remove(id: string): void;
    /** Recover archives left open by a Hook crash before accepting new producers. */
    recover(now?: number): void;
    retain(now?: number, budget?: number): void;
}
export {};
