import { type Express } from "express"; import http from "node:http"; import { TelemetryStore, type ConsoleEntry, type ConsoleQuery, type NetworkEntry, type NetworkQuery, type QueryResult, type TabId } from "./store.js"; import { type AuditHooks } from "../lighthouse/runner.js"; import { type AuditCategory, type AuditReport } from "../lighthouse/types.js"; export declare const SERVER_SIGNATURE = "mcp-browser-connector-24x7"; export declare const SERVER_VERSION = "2.0.0"; export declare class NoExtensionError extends Error { constructor(); } export declare class UnknownTabError extends Error { constructor(message: string); } export declare class ExtensionRequestError extends Error { constructor(message: string); } export declare class ExtensionTimeoutError extends Error { constructor(message: string); } export interface ConnectorConfig { /** Loopback address to bind. Non-loopback requires allowNonLoopback. */ host?: string; /** 0 picks an ephemeral port; otherwise the first free port from here. */ port?: number; token?: string; screenshotDir?: string; redact?: boolean; heartbeatIntervalMs?: number; requestTimeoutMs?: number; maxBodySize?: string; /** Escape hatch, off by default, for users who knowingly expose the server. */ allowNonLoopback?: boolean; /** * Print each captured entry as it arrives. * * Off by default: this is a debugging aid for confirming capture works, and * on a busy page it is a lot of output. */ verbose?: boolean; /** Injectable so audits can be exercised without launching a browser. */ auditRunner?: (options: { url: string; category: AuditCategory; }, hooks?: AuditHooks) => Promise; } export interface TabView { tabId: TabId; url: string; /** True for the tab that tools act on when no tabId is given. */ isCurrent: boolean; consoleCount: number; networkCount: number; } export interface ExportResult { tabId: TabId | null; url: string; entries: T[]; } export interface Artifact { mimeType: string; /** Text artifacts carry `text`; binary ones carry base64 `blob`. */ text?: string; blob?: string; } /** A query result, plus which tab it describes. */ export interface TabScopedResult extends QueryResult { tabId: TabId | null; url: string; /** Connected tabs this result does NOT cover. */ otherTabs: number; } export interface ScreenshotCapture { path: string; /** Data URL, carrying whichever format the browser settled on. */ data: string; name: string; mimeType: string; bytes: number; /** False when the browser could not get the image under the byte budget. */ withinBudget: boolean; /** Which tab was captured, so a wrong-tab shot is obvious rather than silent. */ tabId: TabId | null; url: string; } export interface Connector { app: Express; server: http.Server; store: TelemetryStore; port: number; host: string; token: string; screenshotDir: string; hasExtension(): boolean; /** Tabs with DevTools open right now. */ listTabs(): TabView[]; getCurrentTabId(): TabId | null; setCurrentTab(tabId: TabId): void; queryConsole(query: ConsoleQuery & { allTabs?: boolean; }): TabScopedResult; queryNetwork(query: NetworkQuery & { allTabs?: boolean; }): TabScopedResult; getSelectedElement(options?: { tabId?: TabId; }): unknown; /** Complete history, with no per-call budget applied. Backs the resources. */ exportConsole(options?: { tabId?: TabId; allTabs?: boolean; }): ExportResult; exportNetwork(options?: { tabId?: TabId; allTabs?: boolean; }): ExportResult; readArtifact(kind: "screenshot" | "audit", name: string): Promise; captureScreenshot(options?: { name?: string; tabId?: TabId; }): Promise; refreshTab(options?: { tabId?: TabId; }): Promise; readStorage(kinds: string[], options?: { tabId?: TabId; }): Promise>; runAudit(category: AuditCategory, options?: { url?: string; tabId?: TabId; }): Promise; close(): Promise; } export declare function createConnector(config?: ConnectorConfig): Promise;