pi-chrome-use

extensionmaintained

Pi coding-agent extension exposing BrowserCode CDP browser_execute

by · v1.1.1 · published 1w ago

$ pi install npm:pi-chrome-use
downloads/mo
163
stars
17
last push
1w ago
open issues
1

Signals

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

Download trend

163 downloads · last 12 weeks (weekly)

README

pi-chrome-use

A real-browser CDP execution extension for Pi agents.

npm version Pi package Node.js CI License GitHub stars

A CDP-powered browser execution extension for Pi. It adds a BrowserCode-style browser_execute tool to pi-coding-agent, allowing Pi to connect to Chromium/Chrome through the DevTools Protocol, run JavaScript, drive pages, inspect the DOM, capture screenshots, and return screenshots as image results.

The motivation is simple: pi-coding-agent is excellent for code work, but it does not provide built-in web search or browser access. This project gives Pi a small, explicit bridge to a user-authorized browser, so an agent can work with live web pages when the task requires it.

This is not a standalone browser testing framework and does not host a daemon. It is a Pi extension that reuses a persistent CDP session inside the Pi process.

Quick Start

1. Install the extension

pi install npm:pi-chrome-use

From GitHub:

pi install git:github.com/citrolabs/pi-chrome-use

For local development:

pi install .

After installation, talk to Pi normally and ask it to use the browser. Pi can call the extension's browser_execute tool when it needs to operate a real page.

Example:

Open https://example.com in the browser, tell me the page title, and return a screenshot.

Pi will connect to an authorized Chromium browser, drive the page, inspect the result, and attach the screenshot.

What it gives Pi

  • browser_execute: Pi-callable tool name.
  • session: persistent CDP session; multiple calls in the same Pi session reuse browser state.
  • console: captures log, error, warn, info, and debug output and streams it back in the tool result.
  • Screenshot collection: successful Page.captureScreenshot calls are automatically converted into Pi image content.
  • Workspace support: reusable scripts can live in .pi/browser-execute-workspace and be loaded from snippets with await import(...).

Why not just web search?

Web-search tools help Pi find and summarize information. pi-chrome-use gives Pi hands-on control of a real Chromium browser, so it can complete tasks that search/fetch tools cannot represent as plain text.

Capabilitypi-web-access / @ollama/pi-web-searchpi-chrome-use
Search the public webStrong fitNot the primary goal
Fetch and summarize static pagesStrong fitPossible, but usually overkill
Click buttons, type into forms, and follow UI flowsLimited or unavailableNative browser automation through CDP
Use authenticated sessionsUsually requires API-level access or copied cookiesReuses the user's authorized browser profile/session
Work with browser extensions and real browser behaviorNoYes, because Pi drives the actual browser
Inspect dynamic DOM state after JavaScript runsLimited to fetched HTML or rendered textDirect live DOM and DevTools Protocol access
Verify what the user would actually seeText-firstScreenshots returned as Pi image results
Keep state across multiple agent stepsTool/backend dependentPersistent CDP session inside the Pi process

Use web-search packages when the task is "find information." Use this extension when the task is "operate the website."

Who should use this

Use this when you need:

  • Pi to operate a real Chrome page instead of only reading HTML.
  • Login state, browser extensions, real browser behavior, or direct DevTools Protocol access.
  • A coding agent to reuse one browser session across multiple tool calls.

Do not use this for:

  • Pure unit testing; Playwright or Vitest is more direct.
  • Untrusted pages or untrusted CDP endpoints. CDP can control the connected browser, so only connect to browsers you authorize.

Configuration

Environment variables:

  • BU_CDP_WS / BU_CDP_URL: default browser WebSocket endpoint used by session.connect().
  • BCODE_SCREENSHOT_DIR: optional directory where screenshots are also dumped locally.

One-off extension load:

pi -e ./extensions/browser-execute.ts

Validation

The repository covers core execution, CDP session helpers, and the Pi extension adapter.

npm run typecheck
npm test

Current tests cover session reuse/isolation, workspace imports, console streaming, timeout handling, screenshot collection, CDP target filtering, active sessionId routing, and Pi image content conversion.

Acknowledgements

The shape of this project was inspired by the following work:

Star History

Star History Chart