@dieulc/browser-inspector

extensionmaintained

Pi extension: inspect browser DevTools (console, network, performance) via CDP

by — · v0.2.1 · published 6d ago

$ pi install npm:@dieulc/browser-inspector
downloads/mo
319
stars
0
last push
6d ago
open issues
0

Signals

license: MITtestspi manifest: missinginstall size: —deps: 0peer deps: 0

Download trend

333 downloads · last 12 weeks (weekly)

README

@dieulc/browser-inspector

Pi extension that lets the agent inspect a live browser — console logs, network requests, and screenshots — via the Chrome DevTools Protocol (CDP).

pi-package

Two modes

ModeUse caseHow
Fresh browser (default)Automate & test a web appThe agent launches its own Chromium with a temporary profile
Real sessionDebug your actual logged-in appA bundled Chrome extension relays DevTools events from your real browser

Why two modes? Chrome 136+ blocks remote debugging on your default (logged-in) profile. Inspecting your real session therefore requires a Chrome extension. Fresh-browser mode needs no browser-side setup.

Install

pi install npm:@dieulc/browser-inspector          # latest
pi install npm:@dieulc/browser-inspector@0.1.0    # pinned
pi install -l npm:@dieulc/browser-inspector       # project-local (.pi/settings.json)
pi -e npm:@dieulc/browser-inspector               # try without installing

The package declares chrome-launcher, chrome-remote-interface, and ws as runtime dependencies; Pi installs them automatically. Manage it with pi list, pi update --extensions, pi remove npm:@dieulc/browser-inspector.

Usage

Fresh browser (no setup)

pi --browser-inspector

With an initial URL:

pi --browser-inspector --browser-url https://localhost:3000

Requirements: Node 18+, Chromium/Chrome installed.

Real session (Chrome extension required)

  1. Load the extension in Chrome:
    • Open chrome://extensions → enable Developer mode → Load unpacked
    • Select the extension/ directory shipped with this package (repo: agent/extensions/browser-inspector/extension/; installed: <pi config dir>/agent/npm/node_modules/@dieulc/browser-inspector/extension/)
  2. Start Pi (the extension is active once installed).
  3. Ask the agent to attach — it calls browser_attach and gives you a relay port.
  4. Open DevTools (F12) on the tab to inspect → Pi Browser Inspector panel → connect with that port.

Tools

ToolModePurpose
browser_launchfreshLaunch Chromium, start capturing
browser_navigatefreshNavigate to a URL
browser_console_logsbothConsole logs (filter by level/text)
browser_console_errorsbothErrors only, grouped by signature
browser_network_requestsbothNetwork requests (filter by URL/status/type)
browser_screenshotfreshTake a screenshot
browser_closefreshClose the browser
browser_attachrealStart the WebSocket relay, returns the port
browser_detachrealStop the relay

Run /browser-doctor in the Pi TUI to check Node version, installed dependencies, Chrome path, extension presence, and current state.

Examples

// Fresh browser
browser_launch: { url: "https://localhost:3000", headed: true }
browser_navigate: { url: "https://localhost:3000/dashboard" }
browser_console_errors: { groupBy: true }
browser_network_requests: { status: "5xx" }
browser_screenshot: { fullPage: false }

// Real session
browser_attach: { port: 9234 }
browser_console_logs: { level: "error", limit: 20 }
browser_network_requests: { filter: "/api/", status: "4xx" }

Notes

  • Console and network logs are buffered in memory (up to 2000 entries each) while the browser/relay is active.
  • Output is capped at 50,000 characters. Truncation is reported.
  • Fresh-browser mode uses a temporary profile — no cookies, logins, or extensions from your real browser.
  • Real-session mode captures events while DevTools is open on the inspected tab.

Development

cd agent/extensions/browser-inspector
npm install
npm run typecheck

Plain TypeScript, no build step — Pi loads src/index.ts directly. Live check:

pi -e ./src/index.ts --browser-inspector

License

MIT — see LICENSE.