原始内容
pi-agent-browser
English | 日本語
Typed browser automation tools for Pi, powered by agent-browser.
Use this package when Pi needs to operate real web pages, extract rendered context, keep login sessions, or capture visual evidence without falling back to ad-hoc shell commands.
What you get
- Rendered-page context extraction — read text from public pages or the active authenticated browser tab.
- Reliable interaction handles — use accessibility snapshots with stable
@reftargets for clicks and form fills. - Evidence capture — save screenshots and extracted text to predictable artifact paths.
- Session persistence — reuse login state with named
agent-browsersessions and restore support. - Safer browsing controls — constrain work with
allowedDomains,maxOutput, and explicit state management. - Typed Pi tools — each browser action has its own schema instead of one free-form command string.
Requirements
- Pi / Feynman runtime with package support
agent-browserinstalled and available onPATH- Chrome for Testing installed through
agent-browser install
Check your local setup:
agent-browser doctor
If agent-browser is installed outside PATH, set:
export AGENT_BROWSER_BIN=/absolute/path/to/agent-browser
Installation
Install from npm:
pi install npm:@53able/pi-agent-browser
Install from GitHub:
pi install https://github.com/53able/pi-agent-browser
Install from a local checkout:
git clone https://github.com/53able/pi-agent-browser.git
pi install ./pi-agent-browser
Registered tools
agent_browser_open— open a URL or launchabout:blankagent_browser_read— extract text or JSON from a URL or active rendered tabagent_browser_snapshot— get accessibility tree refs for interactionagent_browser_click— click by@refor CSS selectoragent_browser_fill— fill an input by@refor CSS selectoragent_browser_screenshot— capture screenshots to diskagent_browser_eval— evaluate JavaScript in the active tabagent_browser_state— save, load, list, show, rename, clear, or clean saved stateagent_browser_close— close a browser sessionagent_browser_handoff— pause and hand control to a human for 2FA, CAPTCHA, or identity verificationagent_browser_commit— confirmation gate for irreversible actions (payment, delete, publish, send)agent_browser_doctor— runagent-browser doctor
Common workflows
Read a page and save the extracted source
Ask Pi:
Read https://example.com through the browser and save the extracted text to outputs/browser/example.md.
Equivalent agent_browser_read arguments:
{
"url": "https://example.com",
"outputPath": "outputs/browser/example.md",
"allowedDomains": ["example.com"]
}
Interact with a rendered page
- Open the page.
{
"url": "https://example.com",
"session": "research-example",
"allowedDomains": ["example.com"]
}
- Call
agent_browser_snapshotto get fresh@refvalues. - Use
agent_browser_clickoragent_browser_fillwith those refs. - Call
agent_browser_readfor text oragent_browser_screenshotfor visual evidence. - Close the session with
agent_browser_closewhen finished.
Keep login state across runs
Use a stable session name and restore: true:
{
"url": "https://example.com",
"session": "work-example",
"restore": true,
"headed": true
}
After logging in once, future opens with the same session and restore can reuse saved browser state.
Inspect or clear saved state
List saved states:
{
"operation": "list"
}
Clear one saved session state:
{
"operation": "clear",
"sessionName": "work-example"
}
Clear all saved states only when intentionally resetting everything:
{
"operation": "clear",
"all": true
}
Safety guidance
- Pass
allowedDomainswhenever the browsing scope is known. - Use
outputPathwhen extracted content supports a report, audit, or later verification. - Take a fresh snapshot after navigation, form submission, modal dismissal, or a failed click.
- Prefer
agent_browser_readfor textual evidence andagent_browser_screenshotfor visual evidence. - Use
agent_browser_evalonly whenreadorsnapshotcannot expose the required state. - Review saved browser state before clearing broadly.
Human handoff
Not every step should run unattended. Two tools hand control back to a human at the right moments:
- Safe boundaries —
agent_browser_handoffpauses the agent for steps it cannot or should not perform itself: 2FA/OTP entry, CAPTCHA, identity verification. It captures a screenshot for context, then blocks on a real confirmation dialog until a human resumes or aborts.agent_browser_readandagent_browser_snapshotalso run a lightweight keyword scan and flag likely checkpoints in their output as a nudge to call this tool. - Stop before commit —
agent_browser_commitis a dedicated gate for irreversible actions: payment, deletion, publishing, sending. It captures evidence, requires explicit human confirmation before clicking, and refuses outright (without clicking) if no interactive UI is available to ask. Use it instead ofagent_browser_clickfor the final confirming step of any such action.
Both tools require an interactive session (TUI or RPC with UI support); in headless/unattended runs they refuse rather than proceed silently.
agent_browser_open also remembers whether each named session was launched with headed: true. If agent_browser_handoff is called for a session that was not opened headed, it automatically warns the human and includes the exact agent_browser_open arguments (session name, headed: true, restore: true, and the last known URL) needed to reopen a visible window — no more guessing which command to rerun. Prefer headed: true up front for any task that might hit a login, 2FA, CAPTCHA, or identity-verification step, since some challenges are single-use and reopening mid-flow may require restarting the login.
Troubleshooting
Run:
agent-browser doctor
Or ask Pi to run agent_browser_doctor.
Common fixes:
npm install -g agent-browser
agent-browser install
Project history
If you maintain or contribute to this package, read the project history in English or Japanese for the package-name decision, npm Trusted Publishing setup, and semantic-release workflow.
Release automation
Releases are automated with semantic-release. Maintainers merge Conventional Commits into main; GitHub Actions runs npx semantic-release@25, determines the next version, publishes to npm through Trusted Publishing, creates the Git tag, and writes the GitHub Release.
Commit message examples:
fix: handle empty snapshot output→ patch releasefeat: add browser state export tool→ minor releasefeat!: rename tool argumentsorBREAKING CHANGE:→ major release
The npm Trusted Publisher should continue to point at .github/workflows/publish.yml. No long-lived NPM_TOKEN is required.
License
MIT