Python SDK for controlling the native agent-browser engine in-process
Project description
pyagentbrowser
The pyagentbrowser distribution drives the native Rust agent-browser engine
from Python. Import it as agentbrowser. It exposes page navigation, browser
snapshots, element refs, action evidence, screenshots, cookies, storage, native
active-frame state, and CDP helpers through one Python package.
python -m pip install pyagentbrowser
Requires Python 3.11 through 3.14 on macOS or Linux, with Chrome or Chromium available on the host.
Usage
from agentbrowser import Browser, LaunchOptions
with Browser.launch(LaunchOptions(headless=True)) as browser:
browser.page.set_content(
"""
<h1>Example catalog</h1>
<button>More information</button>
<p id="status"></p>
<script>
document.querySelector("button").addEventListener("click", () => {
document.querySelector("#status").textContent = "Details loaded"
})
</script>
"""
)
page = browser.agent.observe()
print(page.text)
browser.find.text("More information").click()
print(browser.find.css("#status").text())
Snapshot refs stay tied to the page state that created them. After navigation
or a large DOM update, call browser.agent.observe() again and continue from
the new snapshot.
For notebooks and REPL sessions, agentbrowser.notebook exposes one process-local
default browser:
import agentbrowser as ab
from agentbrowser import LaunchOptions
ab.notebook.configure(launch_options=LaunchOptions(headless=True))
ab.notebook.page.set_content(
"""
<h1>Notebook page</h1>
<button>More information</button>
<p id="status"></p>
<script>
document.querySelector("button").addEventListener("click", () => {
document.querySelector("#status").textContent = "Notebook details loaded"
})
</script>
"""
)
page = ab.notebook.agent.observe()
ab.notebook.find.text("More information").click()
print(page.text)
print(ab.notebook.find.css("#status").text())
ab.notebook.close()
Use ab.notebook.reset(force=True) after an interrupted notebook run when the native
browser state should be discarded.
Capabilities
- Native browser control: Launch Chrome, attach over CDP, navigate pages, switch tabs, wait for readiness, and close sessions.
- Snapshot-driven actions: Observe an accessibility snapshot, find refs by text, role, name, CSS, or XPath, then fill, click, press, or inspect the matching element.
- Evidence after actions: Use
click_and_observe()to capture the next page snapshot and a text diff after a click. - Artifacts and state: Capture screenshots, save and restore browser state, derive stable session ids, inspect cookies, storage, network entries, CDP frames, and native active-frame state.
- Typed escape hatches: Call
browser.native.execute(action, **params)for raw native responses, or usebrowser.cdpfor CDP frame and execution-context work.
Optional Extras
python -m pip install "pyagentbrowser[images]"
python -m pip install "pyagentbrowser[cdp]"
images adds Pillow helpers for screenshots. cdp adds websocket-backed CDP
frame and context evaluation.
Resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyagentbrowser-0.31.1rc0.tar.gz.
File metadata
- Download URL: pyagentbrowser-0.31.1rc0.tar.gz
- Upload date:
- Size: 712.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76263e0c85d8cdc61275b2af9a5b606a4e61bbe8d958cf94117441bfec2fe823
|
|
| MD5 |
c169051d0d21aa4240a78d79c0c1cfc6
|
|
| BLAKE2b-256 |
7a8141c0d8a2e3d46353be30c5be43cb9b77d847266c1ba14edb85708398511c
|
File details
Details for the file pyagentbrowser-0.31.1rc0-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyagentbrowser-0.31.1rc0-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8219cce316a823ad9d46291a7d2086d8953f58824160f97c9bddc3a6768332bc
|
|
| MD5 |
75922b9f45f09bc2559d47d6362146fe
|
|
| BLAKE2b-256 |
b6839e1f5310ba43d58aa27b7e449923eae6314dee745600db1dc7dfc1989a00
|
File details
Details for the file pyagentbrowser-0.31.1rc0-cp311-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pyagentbrowser-0.31.1rc0-cp311-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7b69573e39cce72f4a1fbaf589f8bedd04d1777366d36f06f79ec96ac572451
|
|
| MD5 |
6f53de88f3a4d39c55c27bb5f2260cd4
|
|
| BLAKE2b-256 |
f00c2d36a67c32e993fe3fdaa1b13a54e72b388f5cb4cc56c191b7e1c7bb7309
|
File details
Details for the file pyagentbrowser-0.31.1rc0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyagentbrowser-0.31.1rc0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03a17f4eb52330802b703a315fa3f39ecfd31fadee2de39f0fbd6473458f8697
|
|
| MD5 |
d374f5fa5eb01808f9da63431b251d32
|
|
| BLAKE2b-256 |
819385b0fe0eee521dd8d38933364eaa334cb461c21f22cac64890c1064c8b75
|
File details
Details for the file pyagentbrowser-0.31.1rc0-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pyagentbrowser-0.31.1rc0-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f8d672a86a0a5cc85395ffcbae875e4c7968ce859f062c4caa97858372798d4
|
|
| MD5 |
335bf59439c44a253909ba1d4e3fb8df
|
|
| BLAKE2b-256 |
0d91a436a560d142b943c98e42ed4d852a9eb85ef50f9fe2e8dc0efff4cc29c7
|