### Setup and run fastbrowse CLI and MCP server Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/AGENTS.md Sets up the environment with all extras and runs the main CLI or the MCP server over stdio. The first command installs the browser-use SDK and the mcp extra, which ty checks. ```sh uv sync --all-extras # the browser-use SDK and the mcp extra too, which ty checks uv run fastbrowse "..." --start https://example.com/ uv run fastbrowse-mcp # the MCP server, stdio ``` -------------------------------- ### Set up development environment Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/CONTRIBUTING.md Sets up the development environment and installs the pre-commit hooks. Run this before making changes. ```sh uv sync --all-extras uv run pre-commit install ``` -------------------------------- ### Set up and run fastbrowse from source Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Set up a development environment for fastbrowse: clone the repository, sync dependencies with all extras, copy the .env.example file, and run the tool with uv run. The --all-extras flag installs mcp and browser_use_sdk needed for tests and evals. ```sh git clone https://github.com/agent-labs-dev/fastbrowse.git && cd fastbrowse uv sync --all-extras # the extras carry mcp and browser_use_sdk, which the tests and evals import cp .env.example .env # then fill in the keys, BROWSER_USE_API_KEY included, or pass --local uv run fastbrowse "What is the title of the top story right now?" --start https://news.ycombinator.com/ ``` -------------------------------- ### Run fastbrowse with uvx Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Run fastbrowse with uvx, using the default cloud browser and OpenRouter for the LLM. Requires uv and the BROWSER_USE_API_KEY; OPENROUTER_API_KEY is needed unless TYPESAFE_API_KEY is set. The --start flag specifies the initial page. ```sh export OPENROUTER_API_KEY=... # for Jev and the LLM that plans and reads # export AI_GATEWAY_API_KEY=... # optional Jev backup through the Vercel AI Gateway export BROWSER_USE_API_KEY=... # the cloud browser; or pass --local to use Chrome uvx fastbrowse "What is the title of the top story right now?" --start https://news.ycombinator.com/ ``` -------------------------------- ### Shadow DOM button setup and click handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Attaches an open shadow root, injects a button, and sets a global flag when clicked. ```javascript const host = document.getElementById('shadow-host').attachShadow({mode: 'open'}); host.innerHTML = ''; document.getElementById('shadow-host').shadowRoot.getElementById('shadow-button') .addEventListener('click', () => { window.__shadowClicked = true; }); ``` -------------------------------- ### Run fastbrowse with Bitwarden credentials Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Use Bitwarden CLI to supply credentials. First unlock the vault and export BW_SESSION, then run fastbrowse with --bitwarden and the item name. The item's saved URIs must match --start; values are typed only on that origin, and models see only the names username, password, and one_time_code when an authenticator key is present. ```sh export BW_SESSION="$(bw unlock --raw)" uv run fastbrowse "Add a UGREEN USB-A to USB-C cable, 2m, to my cart." \ --start https://www.amazon.com/ --bitwarden Amazon --profile ~/.fastbrowse/amazon --headed ``` -------------------------------- ### Run a task with run_task and output_schema Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Shows the basic usage of `run_task` after installing with `uv add fastbrowse`. It defines a Pydantic `Release` model for the output schema, sets a cost limit with `Limits(max_dollars=0.10)`, and prints the result status, data, cost, and evidence quotes. ```python import asyncio from pydantic import BaseModel from fastbrowse import run_task from fastbrowse.models import Limits class Release(BaseModel): package: str version: str async def main() -> None: result = await run_task( "Find the httpx package and report its name and latest released version.", start="https://pypi.org/", output_schema=Release, limits=Limits(max_dollars=0.10), ) print(result.status, result.data, f"${result.cost.known_dollars:.4f}") for evidence in result.evidence: print(f' "{evidence.quote}" from {evidence.url}') asyncio.run(main()) ``` -------------------------------- ### Sign in manually and run fastbrowse with a local profile Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Sign in once manually in a dedicated Chrome profile, then run fastbrowse with that profile. The first command opens Chrome with a custom user data directory; after signing in, close Chrome. The second command runs fastbrowse with --start, --profile, and --headed. ```sh google-chrome --user-data-dir="$HOME/.fastbrowse/amazon" https://www.amazon.com/ # sign in, then close Chrome uv run fastbrowse "Add a UGREEN USB-A to USB-C cable, 2m, to my cart." \ --start https://www.amazon.com/ --profile ~/.fastbrowse/amazon --headed ``` -------------------------------- ### Run fastbrowse with a secret and --authorize Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Run fastbrowse with a secret environment variable and the --authorize flag to allow actions like adding to cart. The --secret flag lets the agent type the value of SAUCE_PASSWORD on the --start origin. Requires the environment variable to be set. ```sh export SAUCE_PASSWORD=secret_sauce uv run fastbrowse "Log in as standard_user with the saved password and add the backpack to the cart." \ --start https://www.saucedemo.com/ --secret password=SAUCE_PASSWORD --authorize ``` -------------------------------- ### Attach fastbrowse to an Electron app via DevTools port Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Attach fastbrowse to an Electron app (e.g., VS Code) via a DevTools port. Quit the app first, then start it with --remote-debugging-port; an already-running app ignores the flag. The run connects with --cdp-port and --target-match to select the window by title or URL. ```sh open -a "Visual Studio Code" --args --remote-debugging-port=9222 ~/code/my-project # elsewhere, pass the flag to the binary uv run fastbrowse "Open the Extensions view and report how many extensions are installed." \ --cdp-port 9222 --target-match my-project ``` -------------------------------- ### Run evaluation suites with uv Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/agents/evals.md Commands to run the evaluation suites. The first runs local fixtures with headless Chrome at about $0.005 per task. The second runs a live head-to-head with three arms. The third runs a live comparison with the fastbrowse arm, the heldout suite, and three repeats. ```sh uv run python -m fastbrowse.evals.runner # local fixtures, headless Chrome, ~$0.005 a task uv run --extra browser-use python -m fastbrowse.evals.live # live head-to-head, three arms uv run --extra browser-use python -m fastbrowse.evals.live --arms fastbrowse --suite heldout --repeat 3 ``` -------------------------------- ### Run live evaluation with --suite core --category navigate Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/evals.md Run a live head-to-head evaluation comparing fastbrowse with Browser Use Ultrafast on all six shared navigation tasks, three times each. Requires OPENROUTER_API_KEY for both agents' models and BROWSER_USE_API_KEY for fresh cloud browsers. The command uses --suite, --category, --arms, --repeat, --concurrency, and --out flags. ```sh uv run python -m fastbrowse.evals.live --suite core --category navigate \ --arms fastbrowse jev-ultrafast --repeat 3 --concurrency 2 \ --out artifacts/evals/ultrafast.jsonl ``` -------------------------------- ### Run local and mock fixture suites Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/CONTRIBUTING.md Runs the local and mock fixture suites that drive a real browser, Jev and the LLM. Run this before a change to browsing behaviour or to the fixtures. ```sh just evals-local --suite local mock --repeat 3 ``` -------------------------------- ### Run stateful mock comparison with uv Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/evals.md Runs the stateful mock comparison for both cloud agents (fastbrowse and Browser Use) with three repeats and four concurrent attempts. Requires cloudflared on PATH and the same keys as the live suite; each worker exposes a synthetic fixture through a temporary public tunnel and resets site state between attempts. ```sh uv run --extra browser-use python -m fastbrowse.evals.compare_mock --repeat 3 --concurrency 4 ``` -------------------------------- ### Run probe with repeat and task Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/evals.md Loads the given pages once and repeats the reading stages 6 times, printing facts, drafted answer, and claim-check scores as one JSON line per run. Does not navigate, so click/read decisions still require the live eval. ```sh uv run --extra browser-use python -m fastbrowse.evals.probe --repeat 6 \ --task "How many quotes by Albert Einstein are on the first two pages of quotes.toscrape.com?" \ https://quotes.toscrape.com/ https://quotes.toscrape.com/page/2/ ``` -------------------------------- ### Connect to a browser with connect_cdp Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Connects to an existing browser via `connect_cdp()` and hands the attached page to your own script without the agent. Downloads go to `downloads=`, or to a scratch directory removed on exit. ```python from fastbrowse import connect_cdp async def main() -> None: async with connect_cdp(9222, target_match="my-project") as page: print(await page.observe()) ``` -------------------------------- ### Run the fastbrowse audit suite Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/CHANGELOG.md Run the tiered audit suite for terminal, MCP, and embed surfaces. Tier 0 covers the terminal contract without calling a model; paid tiers are refused unless --spend is passed. ```bash python -m fastbrowse.audit ``` -------------------------------- ### Configure fastbrowse MCP server in Claude Desktop JSON Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Configures the fastbrowse MCP server for JSON-based clients like Claude Desktop. Uses `uvx` to run `fastbrowse-mcp` from the `fastbrowse[mcp]` package and sets the required API keys in the `env` block. ```json { "mcpServers": { "fastbrowse": { "command": "uvx", "args": ["--from", "fastbrowse[mcp]", "fastbrowse-mcp"], "env": { "OPENROUTER_API_KEY": "...", "BROWSER_USE_API_KEY": "..." } } } } ``` -------------------------------- ### Fetch external benchmark data with just evals-data Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/evals.md Commands to download and prepare the two external benchmark datasets. The first requires an authorized HF_TOKEN and the gated file's verified SHA-256; the second needs a JSON mapping site ids to local URLs of already booted upstream capsules. Both write JSONL output files. ```sh just evals-data online-mind2web --sha256 VERIFIED_SHA256 --per-stratum 50 --seed 20260925 --out /tmp/om2w.jsonl just evals-data windtunnel --site-urls /tmp/windtunnel-sites.json --out /tmp/windtunnel.jsonl ``` -------------------------------- ### Run the pre-push gate Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/CONTRIBUTING.md Runs the full gate of checks that CI also runs and that `main` requires. The JavaScript check needs Node.js 22 or newer. ```sh uv run ruff check . && uv run ruff format --check . uv run ty check uv run python scripts/changelog.py --check "$(uv version --short)" uv run python scripts/no_slop.py uv run vale sync && uv run vale README.md CHANGELOG.md AGENTS.md CONTRIBUTING.md docs src scripts tests uv run pytest -q npm ci --ignore-scripts && npm run check:browser uv run actionlint uv run python .sift/agents.py check uv run python .sift/gate.py --base origin/main ``` -------------------------------- ### Wayfinding operations with gh CLI Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/agents/issue-tracker.md Commands for wayfinding: create the map issue, add blocking dependencies via the sub-issues endpoint, fetch the blocker's database id (not the #number or node_id), list open issues for the frontier query, claim a ticket, and resolve by commenting, closing, and appending a context pointer to the map's Decisions-so-far. ```bash gh issue create --label wayfinder:map ``` ```bash gh api --method POST repos///issues//dependencies/blocked_by -F issue_id= ``` ```bash gh api repos///issues/ --jq .id ``` ```bash gh issue list --state open ``` ```bash gh issue edit --add-assignee @me ``` ```bash gh issue comment --body "" ``` ```bash gh issue close ``` -------------------------------- ### Run fastbrowse with a cloud profile Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Run fastbrowse using a cloud profile stored on the Browser Use Cloud account. The profile ID is passed with --cloud-profile; the run inherits the cookies from that profile and no model sees the credentials. ```sh uv run fastbrowse "Add a UGREEN USB-A to USB-C cable, 2m, to my cart." \ --start https://www.amazon.com/ --cloud-profile prof_1234 ``` -------------------------------- ### POST https://openrouter.ai/api/v1/systemone Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/jev.md OpenRouter endpoint for the Jev systemone API, used by fastbrowse as the default when OPENROUTER_API_KEY is set. ```APIDOC ## POST https://openrouter.ai/api/v1/systemone ### Description Sends a systemone request to the OpenRouter API using the TypeSafe SDK. Requires a bearer key and returns TypeSafe request and response shapes, including usage cost, id, and provider. ### Method POST ### Endpoint https://openrouter.ai/api/v1/systemone ### Parameters #### Headers - **Authorization** (string) - Required - Bearer key for authentication. ### Request Example { "model": "typesafe/jev", "state": "...", "questions": [...] } ### Response #### Success Response (200) - **model** (string) - The model used. - **answers** (array) - The answers to the questions. - **usage** (object) - Usage details including cost in dollars. - **id** (string) - Identifier for the request. - **provider** (string) - Provider information. #### Response Example { "model": "typesafe/jev", "answers": [...], "usage": { "cost": 0.001 }, "id": "...", "provider": "..." } ``` -------------------------------- ### Verify SHA-256 checksum of vendored autoconsent bundle Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/src/fastbrowse/browser/autoconsent/SOURCE.txt Run this command to verify the integrity of the vendored bundle. The expected SHA-256 is cc50f2114cce0bdaf4f7da703cae4467a84d609d234f3ccb69c5ec0f071aca97. Use after any re-sync to ensure the bundle matches the tracked version. ```bash sha256sum src/fastbrowse/browser/autoconsent/autoconsent.standalone.js ``` -------------------------------- ### Run the full CI gate Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/AGENTS.md The full CI gate, run in this order on Python 3.13 and 3.14 (browser and sift checks on 3.13). Includes ruff, ty (not pyright), changelog check, no_slop, vale, pytest, browser checks, actionlint, and sift checks. ```sh uv run ruff check . && uv run ruff format --check . uv run ty check # ty, not pyright uv run python scripts/changelog.py --check "$(uv version --short)" uv run python scripts/no_slop.py uv run vale sync && uv run vale README.md CHANGELOG.md AGENTS.md CONTRIBUTING.md docs src scripts tests uv run pytest -q npm ci --ignore-scripts && npm run check:browser uv run actionlint uv run python .sift/agents.py check uv run python .sift/gate.py --base origin/main ``` -------------------------------- ### Create vault items for Bitwarden credential lookup Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/evals.md Run these commands once with your vault unlocked to create the vault items used by the --bitwarden arm. The first command unlocks the Bitwarden CLI and exports the session key; the second runs the script that creates the items. ```sh export BW_SESSION=$(bw unlock --raw) uv run python scripts/eval_vault.py ``` -------------------------------- ### Evals workflow commands Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/evals.md Commands to run live suites, local fixtures, publish results, and regenerate docs. These wrap module CLIs and require a separate approved run budget for paid APIs. ```bash just evals-run dev --arms fastbrowse --repeat 3 ``` ```bash just evals-local --only search-price ``` ```bash just evals-publish artifacts/evals/live.jsonl ``` ```bash just evals-docs ``` ```bash just evals-docs --bump TASK_ID ``` ```bash just evals-local --suite local mock --repeat 3 ``` -------------------------------- ### POST https://api.typesafe.ai/v1/systemone Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/jev.md Direct TypeSafe API endpoint for Jev systemone requests, used when FASTBROWSE_JEV_SOURCE=typesafe or TYPESAFE_API_KEY is set. ```APIDOC ## POST https://api.typesafe.ai/v1/systemone ### Description Direct API endpoint for the Jev systemone request. Requires a bearer key and accepts a body with model, state, and questions. Returns model, answers, and usage. ### Method POST ### Endpoint https://api.typesafe.ai/v1/systemone ### Parameters #### Headers - **Authorization** (string) - Required - Bearer key for authentication. #### Request Body - **model** (string) - Required - The model identifier. - **state** (object) - Required - The state to evaluate. - **questions** (array) - Required - List of questions. ### Request Example { "model": "typesafe/jev", "state": {}, "questions": [] } ### Response #### Success Response (200) - **model** (string) - The model used. - **answers** (array) - The answers to the questions. - **usage** (object) - Usage details. #### Response Example { "model": "typesafe/jev", "answers": [], "usage": {} } ``` -------------------------------- ### Add fastbrowse MCP server to Claude Code Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Adds the fastbrowse MCP server to Claude Code via the `claude mcp add` command. Requires `OPENROUTER_API_KEY` and `BROWSER_USE_API_KEY` environment variables and runs `fastbrowse-mcp` with a `--max-dollars` ceiling of 0.25. ```sh claude mcp add fastbrowse -e OPENROUTER_API_KEY=... -e BROWSER_USE_API_KEY=... \ -- uvx --from 'fastbrowse[mcp]' fastbrowse-mcp --max-dollars 0.25 ``` -------------------------------- ### run_task Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Documentation for the run_task function, which executes a browsing task and returns a structured result. ```APIDOC ## [run_task] run_task(...) ### Description Runs a task in a browser, starting a local Chrome or attaching to an existing browser, and returns a RunResult with status, data, cost, and evidence. ### Method async function ### Endpoint run_task(task, start, output_schema, limits, cdp_url, cdp_port, attach, target_match, browser_api_key, on_event, jev, llm) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **task** (string) - Required - The task description to execute. - **start** (string) - Required - The starting URL. - **output_schema** (Pydantic model) - Required - The output schema for the result data. - **limits** (Limits) - Required - Limits for the run, e.g., max_dollars. - **cdp_url** (string) - Optional - URL of a running browser's DevTools endpoint. - **cdp_port** (int) - Optional - DevTools port on 127.0.0.1 to find the browser. - **attach** (bool) - Optional - Attach to an already open window and leave it open. - **target_match** (string) - Optional - Match a specific target when attaching. - **browser_api_key** (string) - Optional - API key to start a cloud browser. - **on_event** (callable) - Optional - Handler for browser and step events. - **jev** (object) - Optional - Custom Jev implementation. - **llm** (object) - Optional - Custom LLM client implementation. ### Request Example ```python result = await run_task( "Find the httpx package and report its name and latest released version.", start="https://pypi.org/", output_schema=Release, limits=Limits(max_dollars=0.10), ) ``` ### Response #### Success Response (200) - **status** (string) - The status of the run. - **data** (object) - The structured output data. - **cost** (object) - Cost information with known_dollars. - **evidence** (list) - List of evidence objects with quote and url. #### Response Example ```python print(result.status, result.data, f"${result.cost.known_dollars:.4f}") for evidence in result.evidence: print(f' "{evidence.quote}" from {evidence.url}') ``` ``` -------------------------------- ### Run heldout and dev eval suites Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/CONTRIBUTING.md Runs the `heldout` and `dev` eval suites for changes to agent behaviour. Run `heldout` on `main` as a baseline, then `dev` while iterating, then `heldout` again on the finished change. Paste the pass counts, time and cost from the final `dev` run and both `heldout` runs. ```sh uv run --extra browser-use python -m fastbrowse.evals.live --arms fastbrowse --suite heldout --repeat 3 uv run --extra browser-use python -m fastbrowse.evals.live --arms fastbrowse --suite dev --repeat 3 ``` -------------------------------- ### Probe TypeSafeModel retry and usage behavior Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/native-typesafe.md Probe that simulates a transport outage (first request returns HTTP 503) and verifies the TypeSafe SDK retries, returning a valid answer with usage but no cost or request count. Uses a synthetic key and in-memory MockTransport, so it makes no paid or network requests. Run with `uv run --isolated --no-project --with 'pydantic-ai-slim[typesafe]==2.51.0' probe.py`. ```python import asyncio import httpx2 from pydantic_ai.models.decision import DecisionRequest, NoulQuestion from pydantic_ai.models.typesafe import TypeSafeModel from pydantic_ai.providers.typesafe import TypeSafeProvider from typesafe_sdk import AsyncTypeSafeClient async def check(): attempts = 0 async def respond(request): nonlocal attempts attempts += 1 if attempts == 1: return httpx2.Response(503, json={"error": {"message": "temporary outage"}}) return httpx2.Response( 200, json={ "model": "jev-1.13", "answers": {"q": {"type": "noul", "noul": 0.8}}, "usage": {"input_tokens": 100, "output_tokens": 2, "cost": 0.0123}, }, ) async with httpx2.AsyncClient(transport=httpx2.MockTransport(respond)) as http: client = AsyncTypeSafeClient(api_key="synthetic", http_client=http, base_url="https://provider.test") model = TypeSafeModel("jev-1.13", provider=TypeSafeProvider(typesafe_client=client)) result = await model.decide(DecisionRequest(state="green", questions={"q": NoulQuestion()}), {}) assert attempts == 2 and result.usage.cost is None assert not hasattr(result, "requests") asyncio.run(check()) ``` -------------------------------- ### Lazy menu open handler with delayed content Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Simulates a lazy-loaded menu: sets a pressed flag immediately, then after 400ms injects the menu markup and updates aria-expanded. ```javascript document.getElementById('open-lazy').addEventListener('click', () => { // The header reacts at once; the menu's own markup arrives later, as a lazily loaded bundle's would. document.getElementById('open-lazy').dataset.pressed = 'true'; setTimeout(() => { const menu = document.getElementById('lazy-menu'); menu.innerHTML = ''; menu.hidden = false; document.getElementById('open-lazy').setAttribute('aria-expanded', 'true'); }, 400); }); ``` -------------------------------- ### Open popup window handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Opens a popup window to /popup.html in a new tab when the open-popup button is clicked. ```javascript document.getElementById('open-popup').addEventListener('click', () => { window.open(location.origin + '/popup.html', '_blank'); }); ``` -------------------------------- ### GitHub issue operations with gh CLI Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/agents/issue-tracker.md Commands for creating, viewing, listing, commenting, labeling, and closing GitHub issues using the gh CLI. Use a heredoc for multi-line bodies. The list command filters by state and label and extracts number, title, body, labels, and comments via jq. ```bash gh issue create --title "..." --body "..." ``` ```bash gh issue view --comments ``` ```bash gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]' ``` ```bash gh issue comment --body "..." ``` ```bash gh issue edit --add-label "..." ``` ```bash gh issue edit --remove-label "..." ``` ```bash gh issue close --comment "..." ``` -------------------------------- ### Open modal click handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Shows a modal by setting its display style to block when the open button is clicked. ```javascript document.getElementById('open-modal').addEventListener('click', () => { document.getElementById('modal').style.display = 'block'; }); ``` -------------------------------- ### connect_cdp Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Documentation for the connect_cdp function, which provides direct access to a browser page via CDP. ```APIDOC ## [connect_cdp] connect_cdp(...) ### Description Connects to an existing browser via CDP and provides a page object for direct control without the agent. ### Method async context manager ### Endpoint connect_cdp(port, target_match, downloads) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **port** (int) - Required - The DevTools port. - **target_match** (string) - Optional - Match a specific target. - **downloads** (string) - Optional - Directory for downloads; defaults to a scratch directory removed on exit. ### Request Example ```python async with connect_cdp(9222, target_match="my-project") as page: print(await page.observe()) ``` ### Response #### Success Response (200) - **page** (object) - The attached page object with methods like observe(). #### Response Example ```python async with connect_cdp(9222, target_match="my-project") as page: print(await page.observe()) ``` ``` -------------------------------- ### Login form submit handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Handles the login form submission, preventing default behavior and displaying the signed-in username. ```javascript document.getElementById('login').addEventListener('submit', e => { e.preventDefault(); document.getElementById('login-result').textContent = 'signed in as ' + document.getElementById('username').value; }); ``` -------------------------------- ### POST https://ai-gateway.vercel.sh/v4/ai/evaluation-model Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/jev.md Vercel AI Gateway endpoint for the Jev evaluation model, used with AI_GATEWAY_API_KEY as a backup provider. ```APIDOC ## POST https://ai-gateway.vercel.sh/v4/ai/evaluation-model ### Description Gateway endpoint for the Jev evaluation model. Accepts a body with state and questions, and returns evaluation results. Used as a backup for OpenRouter and direct TypeSafe. ### Method POST ### Endpoint https://ai-gateway.vercel.sh/v4/ai/evaluation-model ### Parameters #### Headers - **Authorization** (string) - Required - Bearer key for authentication. #### Request Body - **state** (object) - Required - The state to evaluate. - **questions** (array) - Required - List of questions. ### Request Example { "state": {}, "questions": [] } ### Response #### Success Response (200) - **answers** (array) - The answers to the questions. - **usage** (object) - Usage details. #### Response Example { "answers": [], "usage": {} } ``` -------------------------------- ### Run targeted pytest commands Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/AGENTS.md Runs a single test file, tests filtered by name, and the browser test suite. The browser tests require Chrome and skip when it is not available. ```sh uv run pytest tests/test_agent.py -q uv run pytest -k "next_page" -q uv run pytest tests/browser -q # needs Chrome; skips without it ``` -------------------------------- ### Rejecting field beforeinput handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Prevents input, replaces the field with an empty clone, and focuses a decoy field. ```javascript document.getElementById('rejecting').addEventListener('beforeinput', e => { // Refuses the value, replaces itself with an empty copy, and focuses a field already holding it. e.preventDefault(); const old = e.target; const fresh = old.cloneNode(); old.replaceWith(fresh); document.getElementById('decoy').focus(); }); ``` -------------------------------- ### File upload SHA-256 hash computation Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Computes the SHA-256 hash of the selected file and displays it as a hex string in the upload-sha element. ```javascript document.getElementById('file-input').addEventListener('change', async e => { const file = e.target.files[0]; if (!file) return; const buf = await file.arrayBuffer(); const digest = await crypto.subtle.digest('SHA-256', buf); document.getElementById('upload-sha').textContent = [...new Uint8Array(digest)] .map(b => b.toString(16).padStart(2, '0')).join(''); }); ``` -------------------------------- ### Pull request operations with gh CLI Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/docs/agents/issue-tracker.md Commands for viewing, listing, commenting, labeling, and closing pull requests with gh. The list command returns JSON including authorAssociation; keep only CONTRIBUTOR, FIRST_TIME_CONTRIBUTOR, or NONE for external PRs. GitHub shares one number space across issues and PRs, so resolve bare numbers with gh pr view and fall back to gh issue view. ```bash gh pr view --comments ``` ```bash gh pr diff ``` ```bash gh pr list --state open --json number,title,body,labels,author,authorAssociation,comments ``` ```bash gh pr comment ``` ```bash gh pr edit --add-label ``` ```bash gh pr edit --remove-label ``` ```bash gh pr close ``` -------------------------------- ### Swap target replacement handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Replaces the swap target button with a new button with the same id and different text when the trigger is clicked. ```javascript document.getElementById('swap-trigger').addEventListener('click', () => { const old = document.getElementById('swap-target'); const fresh = document.createElement('button'); fresh.id = 'swap-target'; fresh.textContent = 'Replaced target'; old.replaceWith(fresh); }); ``` -------------------------------- ### Open dialog confirm handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Shows a confirmation dialog and updates the result text based on the user's choice. ```javascript document.getElementById('open-dialog').addEventListener('click', () => { const ok = confirm('Proceed?'); document.getElementById('dialog-result').textContent = ok ? 'confirmed' : 'cancelled'; }); ``` -------------------------------- ### resolve_cdp_port Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/README.md Documentation for the resolve_cdp_port function, which returns the WebSocket URL for a DevTools port. ```APIDOC ## [resolve_cdp_port] resolve_cdp_port(port) ### Description Resolves a DevTools port to its WebSocket URL for use with cdp_url. ### Method function ### Endpoint resolve_cdp_port(port) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **port** (int) - Required - The DevTools port. ### Request Example ```python ws_url = resolve_cdp_port(9222) ``` ### Response #### Success Response (200) - **ws_url** (string) - The ws:// URL for the DevTools endpoint. #### Response Example ```python ws_url = resolve_cdp_port(9222) ``` ``` -------------------------------- ### Hydrating field input handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html On first input, clones the field, removes its id, marks it hydrated, replaces the original, and focuses the clone. ```javascript document.getElementById('hydrating').addEventListener('input', e => { // A component that re-renders on first input, detaching the very node that was typed into. const old = e.target; if (old.dataset.hydrated) return; const fresh = old.cloneNode(); fresh.removeAttribute('id'); // as Wikipedia's does, so identity cannot rest on the id fresh.dataset.hydrated = 'true'; fresh.value = old.value; old.replaceWith(fresh); fresh.focus(); }); ``` -------------------------------- ### Covered target click handler Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html Marks the covered target as clicked by setting a data attribute when clicked. ```javascript document.getElementById('covered-target').addEventListener('click', () => { document.getElementById('covered-target').dataset.clicked = 'true'; }); ``` -------------------------------- ### Python function f(x) returns x + 1 Source: https://github.com/agent-labs-dev/fastbrowse/blob/main/tests/browser/sites/main/index.html A simple Python function that increments its argument by one. ```python def f(x): return x + 1 ```