Chrome Extension
A Chrome Extension that enables AI-powered browser automation through the Chrome DevTools Protocol (CDP) with multi-layer persistence for reliable connections.Quick Start
1
Install
2
Create a browser automation agent
Architecture Overview
The extension uses a multi-layer architecture to ensure reliable browser automation: The user asks for a browser task; the Chrome extension and agent automate the page via CDP.Multi-Layer Connection Strategy
Chrome Manifest V3 service workers terminate after 30 seconds of inactivity, which can kill WebSocket connections. We use a three-layer approach to maintain persistent connections:Layer 1: Offscreen Document (PRIMARY)
The offscreen document is the primary method for maintaining WebSocket connections:- Lives longer than service workers
- Can maintain WebSocket connections indefinitely
- Auto-reconnects when bridge server restarts
- Sends heartbeats to keep connection alive
Layer 2: Service Worker Bridge (FALLBACK)
If the offscreen document fails, the service worker maintains its own WebSocket:- Offscreen document creation fails
- Chrome doesn’t support offscreen API
- Temporary connection until offscreen is ready
Layer 3: Content Script Keep-Alive (BACKUP)
Content scripts open persistent ports to keep the service worker alive:Internal Message Flow
When using extension mode, messages flow through multiple components:Message Types
Why This Architecture?
The offscreen document holds the actual WebSocket connection because:- Service workers may terminate after 30s of inactivity
- Offscreen documents persist longer
- All outgoing messages route through offscreen
bridgeClient handles:
- Parsing incoming messages
- Calling appropriate handlers (e.g.,
onStartAutomation) - Forwarding outgoing messages to offscreen
Key Insight: The
bridgeClient in the background script doesn’t have its own WebSocket. It routes all messages through the offscreen document’s WebSocket connection.Browser Automation Engines
Extension Mode (PRIMARY)
Extension mode uses the WebSocket bridge for AI-driven browser automation:- Bridge server starts on
localhost:8765 - Chrome launches with extension loaded
- Extension connects to bridge via WebSocket
- AI agent sends actions, extension executes them
- ✅ Full browser context (cookies, sessions)
- ✅ Access to all tabs
- ✅ User-like interactions
CDP Mode (FALLBACK)
CDP mode uses direct Chrome DevTools Protocol for reliable automation:- Chrome launches with
--remote-debugging-port - Python connects directly via CDP
- No extension needed
- Direct browser control
- ✅ Always reliable
- ✅ No extension required
- ✅ Faster for simple tasks
Browser Subagent
The browser subagent is a specialized AI agent that handles browser interactions:What Is It?
The browser subagent is a secondary agent with browser-specific tools:click- Click elementstype- Enter textnavigate- Go to URLsscroll- Scroll pagesscreenshot- Capture screenshotswait- Wait for elements
How It’s Used
- Main agent delegates browser tasks to browser subagent
- Browser subagent uses CDP to control Chrome
- Results returned to main agent
Is It a Fallback?
No - The browser subagent is the main agent for browser control. It’s used by both:- Extension mode (via WebSocket bridge)
- CDP mode (direct control)
Technology Stack
Project Structure
Installation
From Source
- Clone and build:
- Load in Chrome:
- Open
chrome://extensions - Enable “Developer mode”
- Click “Load unpacked”
- Select the
distfolder
- Open
Via CLI
The CLI automatically loads the extension:Manual Load Recovery (Chrome 137+ / Windows)
The CLI’s auto-load can silently fail on Chrome 137+ / Windows, which blocks automated--load-extension. When that happens, launch prints a manual “Load unpacked” flow — load the extension into your daily “Work” Chrome instead.
1
Open chrome://extensions
Use your normal Chrome (Work profile) and enable Developer mode.
2
Load unpacked
Click Load unpacked and select the
dist/ folder.3
Verify the connection
If you launched with
--no-server, start the bridge first (praisonai browser start), then re-run praisonai browser doctor extension. See the full flow in Manual Extension Load.Keyboard Shortcuts
Mac users: Use
Cmd instead of Ctrl
Configuration
Profile Persistence
By default, PraisonAI uses a persistent Chrome profile at~/.praisonai/browser_profile. This provides:
- ✅ Consistent Extension ID: Same ID across runs for reliable automation
- ✅ Session Persistence: Cookies, login state, and history preserved
- ✅ Faster Startup: No need to re-initialize extension settings
Default Behavior (Persistent)
Custom Profile Path
Temporary Profile
For isolated testing or clean sessions, use--temp-profile:
Troubleshooting
Extension Not Connecting
If you see “Timeout after 30s” errors:-
Check bridge server:
-
Check extension console:
- Go to
chrome://extensions - Find “PraisonAI Browser Agent”
- Click “Inspect views: service worker”
- Look for connection errors
- Go to
-
Use CDP fallback:
CLI says “No automation steps in 30s”
Thepraisonai browser run first-step watchdog fired because start_automation was not confirmed delivered to an extension. Verify the bridge sees an extension and that no other client holds it:
--engine cdp.
”Receiving End Does Not Exist” Error
This occurs when the offscreen document isn’t ready. The extension now:- Waits 1 second after creating offscreen document
- Retries 3 times with 500ms delay
- Falls back to service worker bridge
Chrome Instance Management
The CLI only manages its own Chrome instance:- ✅ Only kills the Chrome window it launched
- ✅ Does NOT kill your manually opened Chrome windows
- ✅ Reuses existing session when possible
Permissions
The extension requires:Development
Best Practices
Use for browser automation
Use for browser automation
The Chrome extension is ideal for sites that require login or render content with JavaScript.
Handle authentication flows
Handle authentication flows
The extension preserves browser session cookies - use it for sites requiring authentication.
Minimize extension permissions
Minimize extension permissions
Request only the browser permissions your automation needs to reduce security risk.
Test in headless mode
Test in headless mode
Run in headless mode for CI/CD pipelines and server-side automation without a display.
Related
Custom Tools
Build your own agent tools
Tools Overview
Browse PraisonAI tool documentation

