/** * Shared types for the raw-CDP toolkit. * * The toolkit speaks the Chrome DevTools Protocol directly over the * remote-debugging WebSocket (default ws://127.0.0.1:9222), with no Puppeteer * / chrome-devtools-mcp layer in between. See CONTRACT.md for the design rules * every tool module follows. */ /** A CDP target as returned by GET /json/list. */ export interface Target { id: string; type: "page" | "background_page" | "service_worker" | "shared_worker" | "browser" | "other" | string; title: string; url: string; webSocketDebuggerUrl: string; /** present on some Chromium builds */ parentId?: string; faviconUrl?: string; /** A hidden tab this process owns (CDP_HIDDEN_TABS, see cdp/hiddenTabs.ts). The browser lists * it as type "other"; listTargets relabels it "page" and sets this. Absent on every other target. */ hidden?: boolean; } /** Raw CDP response envelope. */ export interface CdpResponse { id: number; result?: T; error?: { code: number; message: string; data?: unknown }; } /** Raw CDP event envelope. */ export interface CdpEvent

> { method: string; params: P; /** flat-session id when attached via Target.attachToTarget(flatten:true) */ sessionId?: string; } /** * Target selector grammar accepted by resolveTarget(): * - undefined / "active" -> first page-type target * - "<32-hex targetId>" -> exact target by id * - "index:N" -> Nth page-type target (0-based) * - "url:" -> first page whose url contains substring * - "title:" -> first page whose title contains substring * - "label:" -> the page-type target whose label EXACTLY * matches `name`, checked against both the origin ledger (agent-created * tabs, see src/origins.ts) and live lease records (covers a taken-over * tab claimed with a label, which has no origin record — see * src/leases-tools.ts's claimPage). The resolved id must be present in * the listing this call is resolving against; a label whose tab is gone * falls through to the normal no-match error. A miss enumerates the * labels that DO exist; two live targets sharing a label is an ambiguity * error naming both ids, never a silent first-match. See pickPage in * src/shared-tools.ts. * - "worker:" -> a service_worker/shared_worker target whose * URL contains the substring (an MV3 extension's background worker is * `chrome-extension:///