import { type CaptureSettings } from "./settings.js"; export type TabId = number | string; export interface ConsoleEntry { type: string; level: string; message: string; timestamp: number; /** The browser tab this came from, when known. */ tabId?: TabId | null; url?: string; stackTrace?: unknown; } export interface NetworkEntry { type: string; url: string; method: string; status: number; /** When the request completed. */ timestamp: number; /** When the request started, if the capture could determine it. */ startedAt?: number; tabId?: TabId | null; durationMs?: number; error?: string; requestHeaders?: Record; responseHeaders?: Record; requestBody?: string; responseBody?: string; } export interface SelectedElement { [key: string]: unknown; } export interface PageState { url: string; tabId: TabId | null; } export interface QueryResult { entries: T[]; /** Entries matching the filter before pagination and budget clipping. */ total: number; /** Entries actually returned. */ returned: number; /** True when the caller is not seeing every matching entry. */ truncated: boolean; } export interface ConsoleQuery { errorsOnly?: boolean; keywords?: string[]; /** Restrict to one tab. Omit to read across every tab. */ tabId?: TabId; limit?: number; offset?: number; } export interface NetworkQuery { errorsOnly?: boolean; urlKeywords?: string[]; bodyKeywords?: string[]; tabId?: TabId; limit?: number; offset?: number; } export interface TelemetryStoreOptions { settings?: Partial; /** Set false to keep raw credentials in captured data. */ redact?: boolean; } /** * In-memory telemetry captured from the browser. * * Entries are attributed to the tab that produced them, because DevTools can be * open on several tabs at once and merging their output leaves an agent unable * to tell which page it is looking at. Retention is per tab too, so a noisy tab * cannot evict a quiet one's history. * * Everything is scrubbed and size-capped on the way in, so nothing downstream * has to remember to do it, and a hostile page cannot grow the process without * bound. */ export declare class TelemetryStore { #private; constructor(options?: TelemetryStoreOptions); get settings(): Readonly; updateSettings(patch: unknown): CaptureSettings; addConsole(raw: unknown, tabId?: TabId | null): ConsoleEntry | null; addNetwork(raw: unknown, tabId?: TabId | null): NetworkEntry | null; setSelectedElement(element: unknown, tabId?: TabId | null): void; /** The element selected in a given tab, or the most recent one overall. */ getSelectedElement(tabId?: TabId | null): SelectedElement | null; setCurrentPage(page: { url?: unknown; tabId?: unknown; }): void; getCurrentPage(): PageState; /** Clears one tab's telemetry, or everything when no tab is named. */ wipe(tabId?: TabId | null): void; queryConsole(query: ConsoleQuery): QueryResult; queryNetwork(query: NetworkQuery): QueryResult; /** * Every matching console entry, with no query budget applied. * * Used to back a resource, where the caller has explicitly asked for the * whole thing rather than a context-sized sample. */ allConsole(tabId?: TabId): ConsoleEntry[]; allNetwork(tabId?: TabId): NetworkEntry[]; /** Tabs that have produced telemetry, newest activity first. */ knownTabs(): TabId[]; }