import type { CDPSession, Page } from "puppeteer-core"; export interface BrowserRuntimeDiagnostic { kind: "pageerror" | "console-error"; at: string; url: string; line?: number; column?: number; class?: string; } interface ExceptionThrownEvent { exceptionDetails?: { url?: string; lineNumber?: number; columnNumber?: number; exception?: { className?: string; }; }; } interface ConsoleCalledEvent { type?: string; stackTrace?: { callFrames?: Array<{ url?: string; lineNumber?: number; columnNumber?: number; }>; }; } /** * Reduce a runtime-event URL to a persisted-safe location. * * http(s) URLs are emitted origin-only: path segments routinely carry tokens (signed * URLs, invite/reset links, per-tenant identifiers), and diagnostics end up in tool * results that are persisted and shareable. Non-parseable values are never echoed * verbatim — known engine literals pass through, everything else becomes an * irreversible bounded hash so entries stay correlatable without leaking. */ export declare function maskBrowserRuntimeUrl(value: string): string; export declare function pageErrorDiagnostic(event: ExceptionThrownEvent, fallbackUrl: string): BrowserRuntimeDiagnostic; export declare function consoleErrorDiagnostic(event: ConsoleCalledEvent, fallbackUrl: string): BrowserRuntimeDiagnostic | undefined; /** * Serialize a drained mailbox into the tool-result text block. * * - Per-field: `url` is capped with a visible `…` marker; every other field is * structurally bounded (ISO timestamp, finite integers, allowlisted class). * - Total: the serialized block is capped at `MAX_RUNTIME_DIAGNOSTICS_BLOCK_BYTES`. * When the budget is tight the oldest entries are shed (newest survive) and the * block carries an explicit `runtimeDiagnosticsTruncated: true` — truncation is * never silent. */ export declare function serializeRuntimeDiagnostics(drained: { runtimeDiagnostics: BrowserRuntimeDiagnostic[]; runtimeDiagnosticsDropped: number; }): string; export declare class BrowserRuntimeDiagnosticsMailbox { #private; push(entry: BrowserRuntimeDiagnostic): void; drain(): { runtimeDiagnostics: BrowserRuntimeDiagnostic[]; runtimeDiagnosticsDropped: number; }; } export declare function instrumentBrowserRuntimeDiagnostics(page: Page, mailbox: BrowserRuntimeDiagnosticsMailbox): Promise; export {};