diff --git a/.a2a/agent.dsl.json b/.a2a/agent.dsl.json index cf64474..da3965f 100644 --- a/.a2a/agent.dsl.json +++ b/.a2a/agent.dsl.json @@ -3,7 +3,7 @@ "language": "python", "name": "seleniumbase-website-scraper", "description": "SeleniumBase-style browser agent that turns observed website traffic into OpenAPI specs, coverage reports, samples, and a replay client.", - "version": "0.2.0", + "version": "0.2.1", "entrypoint": { "module": "agent", "class_name": "BrowserToApiAgent", @@ -344,7 +344,7 @@ "source": "python-a2a-pack", "project_manifest": { "name": "seleniumbase-website-scraper", - "version": "0.2.0", + "version": "0.2.1", "entrypoint": "agent:BrowserToApiAgent" } } diff --git a/a2a.yaml b/a2a.yaml index dad8a46..87e8eb1 100644 --- a/a2a.yaml +++ b/a2a.yaml @@ -1,5 +1,5 @@ name: seleniumbase-website-scraper -version: 0.2.0 +version: 0.2.1 entrypoint: agent:BrowserToApiAgent expose: public: true @@ -15,6 +15,7 @@ runtime: deny_internet_by_default: false apt_packages: - ca-certificates + - chromium - fonts-liberation - libasound2 - libatk-bridge2.0-0 @@ -38,5 +39,3 @@ runtime: - libxkbcommon0 - libxrandr2 - xdg-utils - install_commands: - - python -m playwright install chromium diff --git a/agent.py b/agent.py index 013a337..b55ae38 100644 --- a/agent.py +++ b/agent.py @@ -13,6 +13,7 @@ import html import json import os import re +import shutil import subprocess import sys import time @@ -118,7 +119,7 @@ class BrowserToApiAgent(A2AAgent[BrowserToApiConfig, NoAuth]): "SeleniumBase-style browser agent that turns observed website traffic " "into OpenAPI specs, coverage reports, samples, and a replay client." ) - version = "0.2.0" + version = "0.2.1" config_model = BrowserToApiConfig auth_model = NoAuth @@ -338,6 +339,13 @@ def _launch_chromium(p: Any, log: list[str]) -> Any: "--no-sandbox", ], } + system_chromium = _system_chromium_path() + if system_chromium: + try: + log.append(f"browser: using system chromium at {system_chromium}") + return p.chromium.launch(executable_path=system_chromium, **launch_kwargs) + except Exception as exc: # noqa: BLE001 + log.append(f"browser warning: system chromium failed: {type(exc).__name__}: {exc}") try: return p.chromium.launch(**launch_kwargs) except Exception as exc: # noqa: BLE001 @@ -359,6 +367,17 @@ def _launch_chromium(p: Any, log: list[str]) -> Any: return p.chromium.launch(**launch_kwargs) +def _system_chromium_path() -> str | None: + for candidate in ("chromium", "chromium-browser", "google-chrome", "google-chrome-stable"): + path = shutil.which(candidate) + if path: + return path + for path in ("/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/google-chrome"): + if Path(path).exists(): + return path + return None + + def _fill_search_inputs(page: Any, search_term: str | None, log: list[str]) -> None: if not search_term: return