export declare const LOG_EVENT_VERSION: 1; export declare const CONTROL_ENVELOPE_VERSION: 1; export type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'trace'; export declare const LOG_CONTEXTS: readonly ['background', 'content', 'page', 'popup', 'options', 'sidebar', 'devtools', 'newtab', 'history', 'bookmarks']; export type LogContext = (typeof LOG_CONTEXTS)[number]; export type LogEventType = 'log' | 'dx.signal'; export type DxSignalStatus = 'ok' | 'warn' | 'fail'; export interface LogEvent { v: typeof LOG_EVENT_VERSION; id: string; seq: number; timestamp: number; level: LogLevel; context: LogContext; messageParts: unknown[]; eventType?: LogEventType; code?: string; status?: DxSignalStatus; remediation?: string; data?: Record; url?: string; hostname?: string; tabId?: number; frameId?: number; windowId?: number; title?: string; stack?: string; errorName?: string; sourceExtensionId?: string; incognito?: boolean; runId: string; repeat?: number; } export type IncomingLogEvent = Omit & { seq?: number; }; export type BridgeRole = 'producer' | 'consumer' | 'controller' | 'viewer'; export type BridgeEngine = 'chromium' | 'firefox' | 'webkit' | 'emulator'; export interface BridgeTarget { context: LogContext; url?: string; tabId?: number; } export type CommandOp = 'eval' | 'storage.get' | 'storage.set' | 'reload' | 'open' | 'tabs.query' | 'tabs.navigate' | 'inspect'; /** * Granularity of a dev-loop reload. Mirrors `ReloadType` in * plugin-reload/classify-reload.ts: the launched-browser path feeds this * decision to the CDP controller; the `--no-browser` path feeds the same * decision to the broker, which broadcasts a {@link ReloadFrame} to the SW * producer. */ export type ReloadType = 'full' | 'service-worker' | 'content-scripts'; /** * Everything a {@link ReloadFrame} can carry in `reloadType`: the extension * reload granularities plus `'page'`, a notify-only signal for page-only * edits (popup/options/sidebar/devtools/newtab). For `'page'` the producer * performs NO reload (livereload owns the refresh); it only forwards the * announcement so the devtools pill mirrors the dev loop. */ export type DevReloadKind = ReloadType | 'page'; export type GapReason = 'ring_overflow' | 'rate_limit' | 'disk_slow' | 'slow_consumer'; export interface HelloFrame { type: 'hello'; v: typeof CONTROL_ENVELOPE_VERSION; role: BridgeRole; instanceId: string; token?: string; acksReloads?: boolean; build?: string; } export interface ReadyFrame { type: 'ready'; runId: string; bufferedFrom?: number; evicted?: number; engine?: BridgeEngine; capabilities?: { eval?: boolean; storage?: boolean; reload?: boolean; open?: Array<'popup' | 'options' | 'sidebar' | 'action' | 'command'>; deepDom?: boolean; }; } export interface LogFrame { type: 'log'; event: LogEvent; } export interface GapFrame { type: 'gap'; dropped: number; reason: GapReason; sinceSeq: number; } export interface CommandFrame { type: 'command'; cmdId: string; op: CommandOp; target: BridgeTarget; args?: Record; timeoutMs?: number; } export declare const REFUSAL_NEEDS_HEADED_WINDOW = "needs_headed_window"; export declare const REFUSAL_NEEDS_USER_GESTURE = "needs_user_gesture"; export declare const REFUSAL_SURFACE_NOT_OPEN = "surface_not_open"; export declare const REFUSAL_SURFACE_REPLY_FAILED = "surface_reply_failed"; export declare const REFUSAL_API_UNAVAILABLE = "api_unavailable"; export declare const REFUSAL_URL_REFUSED = "url_refused"; export declare const REFUSAL_TAB_NOT_FOUND = "tab_not_found"; export declare const REFUSAL_SURFACE_NOT_DECLARED = "surface_not_declared"; export declare const REFUSAL_EXTENSION_LOAD_REFUSED = "extension_load_refused"; export declare const REFUSAL_NO_BACKGROUND = "no_background"; export type BridgeRefusalCode = typeof REFUSAL_NEEDS_HEADED_WINDOW | typeof REFUSAL_NEEDS_USER_GESTURE | typeof REFUSAL_SURFACE_NOT_OPEN | typeof REFUSAL_SURFACE_REPLY_FAILED | typeof REFUSAL_API_UNAVAILABLE | typeof REFUSAL_URL_REFUSED | typeof REFUSAL_TAB_NOT_FOUND | typeof REFUSAL_SURFACE_NOT_DECLARED | typeof REFUSAL_EXTENSION_LOAD_REFUSED | typeof REFUSAL_NO_BACKGROUND; export interface ResultFrame { type: 'result'; cmdId: string; ok: boolean; value?: unknown; truncated?: boolean; durationMs?: number; error?: { name: string; message: string; stack?: string; engine?: string; code?: BridgeRefusalCode; hint?: string; }; } /** * Dev-loop reload broadcast, server → producer. Sent by the broker on a compile * that completed without a CDP controller (`--no-browser`, headless/CI, remote) * so the service-worker producer can self-reload. Unlike a `reload` CommandFrame * (a controller-issued, `--allow-control`-gated act verb that expects a result), * this is a fire-and-forget dev-server signal, no cmdId, no result. */ export interface ReloadFrame { type: 'reload'; reloadType: DevReloadKind; reloadId?: string; changedContentScriptEntries?: string[]; /** * Server-built human context label, e.g. "content_script (content/scripts.tsx)". * Shown VERBATIM by every announcement surface (CLI stdout, the page's * devtools console line, the devtools-extension pill) so the three can * never disagree about what is reloading. */ label?: string; /** Project-relative source files that triggered this reload. */ changedFiles?: string[]; /** Emitted scripts/ bundles the SW should replay its executeScript calls for. */ changedScriptFiles?: string[]; /** Declared stylesheets rewritten under the same name, to swap on open tabs. */ refreshedStylesheets?: { file: string; digest: string; }[]; /** Pages shipped as written, with no dev client, whose open tabs reload. */ standalonePages?: string[]; /** The build this reload ships, compared with the one a returning worker runs. */ build?: string; } export interface ReloadAckFrame { type: 'reload-ack'; reloadType: DevReloadKind; reloadId?: string; label?: string; replayedTabs?: number; } export interface BootRegistrationsFrame { type: 'boot-registrations'; calls?: number; landed?: boolean; pending?: boolean; late?: boolean; afterMs?: number; } export type BootRegistrationsOutcome = 'settled' | 'timeout'; export type ReloadAckOutcome = 'acked' | 'unacked' | 'not-expected'; export type ReloadRestartOutcome = 'restarted' | 'not-restarted' | 'not-expected'; export interface LateReloadRestart { afterMs: number; runsBuild: boolean; } /** * Server → producer keepalive. An MV3 service worker idles out after ~30s * without events, and a stopped SW holds no control socket, reload * broadcasts would reach zero producers and silently apply to nothing * (quiet extensions lost SW/manifest reloads once >30s passed between * edits). Receiving any WebSocket message resets the SW idle timer * (Chrome 116+), so a periodic ping keeps the dev extension's SW * responsive for the whole dev session. Producers ignore the frame. */ export interface PingFrame { type: 'ping'; } export type ClientFrame = HelloFrame | LogFrame | CommandFrame | ReloadAckFrame | BootRegistrationsFrame; export type ServerFrame = ReadyFrame | LogFrame | GapFrame | ResultFrame | ReloadFrame | PingFrame; export type AnyFrame = ClientFrame | ServerFrame; export declare const CONTROL_WS_PATH = "/extjs-control"; /** The hello named an instanceId from a previous dev session. */ export declare const CLOSE_BAD_INSTANCE = 4001; /** The hello was malformed: wrong envelope version, or an unknown role. */ export declare const CLOSE_BAD_HELLO = 4002; /** A controller dialed a session started without `--allow-control`. */ export declare const CLOSE_CONTROL_UNAVAILABLE = 4003; /** A consumer or controller beyond loopback sent no session token, or the wrong one. */ export declare const CLOSE_TOKEN_REQUIRED = 4004; /** The socket fell far enough behind that it was dropped to protect the broker. */ export declare const CLOSE_SLOW_CONSUMER = 4008;