Environment:AIPexStudio AIPex Chrome Debugger
| Knowledge Sources | |
|---|---|
| Domains | CDP, Automation, Chrome_DevTools |
| Last Updated | 2026-10-24 12:00 GMT |
Overview
Chrome DevTools Protocol (CDP) debugger attachment environment required for focus-mode browser automation, accessibility tree snapshots, and precise element interaction.
Description
This environment defines the Chrome DevTools Protocol debugger attachment layer used by the AIPex browser extension in focus mode. When `automationMode` is set to `"focus"`, the extension attaches the Chrome debugger to target tabs using CDP version 1.3, enabling accessibility tree collection, element interaction via backend node IDs, and visual automation effects. The `DebuggerManager` manages the debugger lifecycle with auto-detach after 30 seconds of inactivity and lock-based concurrency control to prevent simultaneous attach/detach races.
= Usage
Use this environment for any Focus Mode Automation that requires CDP-based element interaction via `SmartLocator` or `CdpCommander`. It is the mandatory prerequisite for CDP snapshot collection (`snapshotManager.createSnapshot`) and UID-based element actions (`click`, `fill`, `hover`) that use the `backendDOMNodeId` for precise element targeting.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| Browser | Google Chrome with debugger API | Requires `debugger` permission in MV3 manifest |
| Hardware | Any modern system | Debugger bar visible to user when attached |
| Network | Local CDP connection | No external network required |
Dependencies
Chrome Extension Permissions
- `debugger` — Required for `chrome.debugger.attach` / `detach` / `sendCommand`
- `scripting` — Used for extension iframe cleanup before debugger attach
CDP Version
- Protocol version `1.3` (specified in `chrome.debugger.attach({ tabId }, "1.3", ...)`)
NPM Packages
- `@aipexstudio/browser-runtime` (workspace — provides `DebuggerManager`, `CdpCommander`, `SmartLocator`)
- `@types/chrome` >= 0.1.0
Credentials
No external credentials required. The debugger API is a local Chrome extension capability.
Quick Install
# No separate installation needed — the debugger is built into Chrome.
# Ensure the AIPex extension has the "debugger" permission in manifest.json.
# The debugger attaches automatically when focus-mode automation runs.
Code Evidence
Debugger attach with CDP 1.3 from `packages/browser-runtime/src/automation/debugger-manager.ts:148-160`:
chromeApi.debugger.attach({ tabId }, "1.3", () => {
if (chromeApi.runtime?.lastError) {
console.error(
"❌ [DEBUG] Failed to attach debugger:",
chromeApi.runtime.lastError.message,
);
resolve(false);
} else {
this.debuggerAttachedTabs.add(tabId);
console.log("✅ [DEBUG] Debugger attached successfully");
resolve(true);
}
});
Auto-detach timeout (30 seconds) from `packages/browser-runtime/src/automation/debugger-manager.ts:9`:
const AUTO_DETACH_TIMEOUT = 30 * 1000;
Extension iframe cleanup before debugger attach from `packages/browser-runtime/src/automation/debugger-manager.ts:53-92`:
private async ensureNoExtensionFrame(tabId: number): Promise<boolean> {
// ... queries deep shadow DOM for chrome-extension:// iframes and removes them
// to prevent "Another client is attached" CDP errors.
}
SmartLocator using backendDOMNodeId for element interaction from `packages/browser-runtime/src/automation/smart-locator.ts:13-26`:
export class SmartLocator implements Locator {
#cdpCommander: CdpCommander;
constructor(
private tabId: number,
private node: TextSnapshotNode,
private backendDOMNodeId: number,
) {
this.#cdpCommander = new CdpCommander(tabId);
}
}
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `Another client is attached to the target` | Extension iframe or another DevTools instance is using the debugger | `ensureNoExtensionFrame` auto-removes extension iframes; close DevTools for the target tab |
| `Debugger detached: <reason>` | External detach event (user opened DevTools, tab crashed) | `onDetach` listener auto-cleans state; retry the operation |
| `Failed to attach debugger` | Permission denied or tab already closed | Ensure `debugger` permission in manifest; verify tab still exists |
Compatibility Notes
- Background Mode: CDP is NOT used in background mode — DOM-based snapshots are used instead. Background mode strictly refuses to fall back to CDP.
- Multiple Attach: The `DebuggerManager` uses a per-tab lock (`debuggerLock` map) to prevent concurrent attach races.
- Auto-Detach: Debugger auto-detaches after 30 seconds of inactivity to minimize the visible "debugging this tab" banner.
- Extension Frames: The manager automatically removes `chrome-extension://` iframes from the page before attaching to avoid CDP conflicts.
- Firefox/Safari: Not supported — CDP is Chrome-specific.