feat(browser): add Lightpanda headless browser backend with fallback chain#10871
feat(browser): add Lightpanda headless browser backend with fallback chain#10871thapecroth wants to merge 1 commit into
Conversation
5a2f61d to
9fdc85a
Compare
…chain Add Lightpanda as a lightweight, self-hosted headless browser alternative. Lightpanda is a fast open-source browser written in Zig that exposes a CDP server, making it ideal for resource-constrained environments like Raspberry Pi. - LightpandaProvider: spawns lightpanda binary per session, polls CDP readiness, manages process lifecycle. Supports external CDP URL mode for Docker. - lightpanda_adapter.js: daemon+socket pattern (mirrors agent-browser) with playwright-core CDP connection. Auto-reconnects on page/context disconnect. - Provider fallback chain: lightpanda → camofox → local chromium → browserbase. When lightpanda crashes, the next command automatically advances backends. - Binary discovery: checks ~/.cache/lightpanda-node/lightpanda (native binary from npm postinstall) before PATH, avoiding Node.js wrapper issues on Node 18. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9fdc85a to
fcd2ec8
Compare
|
@thapecroth did you see #7144? |
|
Hey @krichprollsch, thanks for the heads up! Yes, #7144 covers our needs — the A couple of things from our testing on Raspberry Pi that might be useful for #7144: Binary discovery on Node 18: The Process crashes on certain sites: Lightpanda segfaults (rc=-11) on some bot-protected pages (e.g. Amazon 503 responses). The per-command fallback in #7144 should catch this, but the failure mode is a full process crash, not just an empty response — worth verifying the fallback still kicks in when the daemon dies mid-session. Closing this one in favor of #7144. |
Summary
lightpanda serveprocess per session, connects via CDP. Ideal for resource-constrained hosts like Raspberry Pi.lightpanda_adapter.js) — playwright-core bridge with daemon+socket pattern matching agent-browser's architecture. Handles Lightpanda'snewContext→newPageinit sequence and auto-reconnects on CDP disconnect.~/.cache/lightpanda-node/lightpanda(native binary from npm postinstall) before PATH search, avoiding Node.js wrapper incompatibility on Node 18._PROVIDER_VISION_MODELSmapping so providers with dedicated vision models (e.g. zai → glm-4.6v-flash) use the right model.Config
New files
tools/browser_providers/lightpanda.pytools/lightpanda_adapter.jstests/tools/test_browser_lightpanda.pytests/tools/test_browser_lightpanda_integration.pytests/tools/helpers/mock_lightpanda.pyTest plan
pytest tests/tools/test_browser_lightpanda*.py)~/.cache/lightpanda-node/lightpandafound withoutLIGHTPANDA_PATH🤖 Generated with Claude Code