Headless Playwright browser extension for pi.
This extension makes browser automation a first-class pi capability with a persistent headless browser session and browser-specific tools:
browser_navigatebrowser_snapshotbrowser_clickbrowser_typebrowser_press_keybrowser_wait_forbrowser_evaluatebrowser_consolebrowser_networkbrowser_screenshotbrowser_video_startbrowser_video_stopbrowser_video_statusbrowser_run_summarybrowser_tabsbrowser_close
It also adds these commands:
/browser/browser-open <url>/browser-reset/browser-close/browser-video-start/browser-video-stop/browser-clean
From this directory:
npm installThe postinstall script runs playwright install chromium, which downloads the Chromium browser binaries required by browser_navigate and the other browser tools into Playwright's cache (usually ~/.cache/ms-playwright). If the cache is deleted or Playwright is upgraded, rerun:
npx playwright install chromiumThen load it from pi:
pi -e /absolute/path/to/pi-playwright-extensionOr add it to your pi package list/settings.
This repo is intended for git-based installation in pi.
Pi runs npm install when setting up git packages, so the extension's postinstall hook also installs the required Playwright Chromium browser binaries.
pi install git:github.com/SamuelLHuber/pi-playwright-extensionTo pin a tag or commit:
pi install git:github.com/SamuelLHuber/pi-playwright-extension@<tag-or-commit>If your environment already has GitHub SSH access configured:
pi install git:git@github.com:SamuelLHuber/pi-playwright-extension.gitOr pinned:
pi install git:git@github.com:SamuelLHuber/pi-playwright-extension.git@<tag-or-commit>If you prefer to keep the repo checked out locally:
git clone git@github.com:SamuelLHuber/pi-playwright-extension.git
cd pi-playwright-extension
npm install
pi -e .To install it only for the current project:
pi install -l git:github.com/SamuelLHuber/pi-playwright-extensionThis extension takes inspiration from Playwright MCP, but presents a pi-native tool surface instead of exposing a generic MCP bridge. The main goal is reliable headless webpage testing with a stable browser session across turns.
- Lazy-loads the Playwright runtime on first browser use, keeping Pi startup fast while still registering all browser tools and flags.
- Headless by default
- Chromium by default
- Persistent browser session within the current pi session
- Browser reset on pi session switch, fork, or tree navigation
- Snapshot output includes stable element refs for later clicks and typing
- Screenshots and finalized video artifacts are written to the output directory
- Video recording can be enabled per session or at startup
- Artifact cleanup is handled by the extension using retention settings
- A consolidated run summary can bundle screenshot, video, logs, and a markdown report
--browser-headless- defaults totrue--browser-engine-chromium,firefox, orwebkit--browser-output-dir- defaults to.pi/browser--browser-storage-state- optional Playwright storage state JSON file--browser-viewport- defaults to1440x960--browser-record-video- defaults tofalse--browser-video-size- defaults to1440x960--browser-retention-max-artifacts- defaults to50--browser-retention-max-bytes- defaults to536870912(512MB)--browser-retention-max-days- defaults to7--browser-timeout-action- defaults to5000--browser-timeout-navigation- defaults to30000
browser_navigatebrowser_snapshotbrowser_click/browser_typeusing returned refsbrowser_wait_forbrowser_console/browser_networkwhen debuggingbrowser_screenshotwhen a file artifact is neededbrowser_video_startbefore a flow andbrowser_video_stopafter it when you want a full replay artifactbrowser_run_summaryat the end when you want one bundled artifact block with screenshot, video paths, diagnostics, and a markdown report/browser-cleanwhen you want to force pruning immediately
npm install
npm run check
npm testnpm install also provisions the Chromium browser binary through the package postinstall hook. To refresh only browser binaries during development, run:
npx playwright install chromiumArtifacts are written into the browser output directory, which defaults to .pi/browser.
The extension owns cleanup. When it writes screenshots, videos, or summary artifacts, it prunes old files using the configured retention policy.
Cleanup controls:
--browser-retention-max-artifacts--browser-retention-max-bytes--browser-retention-max-days/browser-clean
This keeps browser output from growing without bound while still preserving recent evidence for debugging.
browser_run_summary is an end-of-run packaging tool.
It can:
- capture a final screenshot
- optionally finalize active video recording
- include console output
- include network output
- optionally include a fresh browser snapshot
- write a markdown summary artifact
- return the key artifact paths in one compact tool result
Use it when the user asks for a report, evidence, or a bundled summary of a browser run.
The test suite launches a real headless Chromium instance against a local HTTP server and verifies:
- navigation
- snapshot generation
- stable refs
- typing and clicking
- console capture
- network capture
- tab management
- video recording and artifact finalization
- bundled run summary generation
- artifact cleanup
- extension registration
Playwright ships browser-driving libraries through npm, but the actual browser executables are downloaded separately. This package installs Chromium automatically during setup via:
playwright install chromiumThat hook is intentionally scoped to Chromium because it is the default engine and keeps installation size lower than installing every Playwright-supported browser. If you use --browser-engine=firefox or --browser-engine=webkit, install the matching browser manually:
npx playwright install firefox
npx playwright install webkitIf browser_navigate fails with browserType.launch: Executable doesn't exist, the browser cache is missing or out of sync with the installed Playwright version. Re-run:
npx playwright install chromium- Optimized for headless automation, not interactive desktop browsing.
- Snapshot refs are intended to be used soon after
browser_snapshot; page changes can invalidate them. - Video recording recreates the browser context to ensure clean recordings.
- Browser state is intentionally reset on pi session switch, fork, and tree navigation.