# Browser Agent **Regular Chrome. A page your model can read. Real mouse and keyboard.** Browser Agent is browser control for AI models. It reads a live Chrome page into a compact listing, describes what it can do as OpenAI-style tool definitions, and carries out the tool calls a model sends back with OS-level input. The library does not connect to a model. You bring the model — OpenAI, a local Ollama, anything that speaks OpenAI's function-calling schema, or an agent framework — and pass three kinds of objects through: tool definitions out, tool calls in, tool answers out. ```js const { openBrowser } = require('browser-agent'); const browser = await openBrowser(); const page = await browser.observe(); // what the model reads // → give `browser.tools` and `page.text` to your model, get tool calls back const result = await browser.call(toolCall); // real click, real keys messages.push(result.message); // the answer, ready to send back ``` If you would sooner hand it a goal than write that loop, a small runner comes with it: ```bash node runner/cli.js "Collect the name, price and rating of the ten best-selling \ desk lamps on …" ``` ## What the model sees Not the raw DOM, and not a screenshot every turn. A small, deterministic listing of what is on screen, in reading order: ```text URL: https://github.com/trending/javascript Title: Trending JavaScript repositories Viewport: 1280x800, scrolled 0/5200px (0%, at top, more below) Refs (a ref keeps naming the same thing while it is on the page): [@t7] heading "Trending JavaScript repositories" [@e14] link "facebook / react" -> /facebook/react [@t18] "The library for web and native user interfaces." [@t23] "230,000" [@t24] image "React logo" [@r2] image 640×320 — unreadable; take_screenshot @r2 to read ``` Then it acts on refs. Click `@e14`. Read `@r2`. Save the PDF. Every line is written as tightly as it can be without losing what the model needs, because the listing is read again on every step: plain text carries no role word, a link to the same site is shown by its path (`navigate` takes such a path back), and an image the page shows is listed where it is, by its description. The page's image *files* — their addresses, hidden images, other sizes — are listed by `get_files` when the model asks. A ref stays with its element: the link that is `@e14` now is `@e14` in every later listing, for as long as it is on the page and says the same thing. A new page gets new refs, and a number is never used twice. A few more rules shape the listing, all decided by the page's structure, never by which site it is: - **What the page puts in one box stays together.** A product card, a column of text, a menu, a table cell: everything inside one element of the page is listed in one piece, so a card's button stays with that card's title and a sidebar of small links is never dealt in among the content beside it. The boxes inside a box are then read top to bottom, left to right. - **A table row is one line.** Its cells follow one another with ` | ` between them, each thing in a cell written exactly as on a line of its own, ref and all. An empty cell leaves its place empty, so every value stays under its heading; a place taken by a wider cell from the left shows `<`, and one taken by a taller cell from the row above shows `^`: ```text [@e4] columnheader "Name" | [@e5] columnheader "Price" | [@e6] columnheader "Stock" [@t31] "Widget" | [@t32] "$5" | [@t33] "12" [@t34] "Gadget" | | [@t35] "7" ``` What is a table is Chrome's own call (it tells a table of data from one that only lays a page out). - **One line for one thing.** A heading that is just a link, or a box inside a link that only repeats it, is folded into the link's line (`(heading)` marks the first). - **Long addresses are shortened, never lost.** A long query value or path segment is cut short with `…`, every parameter name kept; `navigate` and `save_file` go to the full address when given the shortened one. - **Text a person could not see is left out**: the same colour as what is painted behind it, one-pixel type, pushed off the page, squeezed into a screen-reader-only box. What is behind the text is Chrome's own answer, the one it works out for its contrast checks, so a dark page or a coloured box drawn by a neighbouring element is seen for what it is. A line at the end of the listing says how much was left out and why; hidden text is a classic way to slip instructions to a model. When what is behind the text cannot be told (a photo, say), it is kept. The listing says what a control is and what state it is in — a ticked box, a pressed toggle, a button the page has disabled, what a closed dropdown offers, which field takes several lines — and anything Chrome says can take the keyboard is listed as a control, whatever it is built from (a date field, the triangle that opens a details box, a plain box a page made into a button). It includes what is inside frames from the same site, in place. What it cannot describe (a chart on a canvas, a video, a PDF, a frame from another site) it lists as an unreadable region the model can take a screenshot of. ## Why real input Modern sites do not need to "solve AI" to block browser agents. They just need to notice the harness: headless hints, WebDriver flags, synthetic input, extension residue, strange timing, DOM mutation. Browser Agent uses the Chrome you already have and sends every click, keystroke and wheel scroll through the OS's own trusted input path — macOS's `CGEventPost`, the same channel used by real mouse and keyboard hardware. There is no synthetic-input mode to fall back to. The driver humanizes movement and typing, sends input only to the one Chrome it was started for, and pauses while you use the machine. From the site's side, the important parts look boring: - real Chrome - trusted click and key events - no `navigator.webdriver` - no Playwright or Puppeteer runtime - no script injected to read the page; the one that tells when the page has settled runs where the page's own scripts cannot see it No anti-detection claim is absolute. ## Try it Prerequisites: - Node.js 22 or newer - Google Chrome or Chromium - macOS — input is real, so it needs a real desktop that is awake and unlocked ```bash git clone https://github.com/Taylor-Bayouth/browser-agent.git cd browser-agent npm install ``` Give it a goal: ```bash node runner/cli.js "Go to github.com/trending/javascript and tell me the top \ three repositories." ``` It asks for a model id and an API key, then you see each step as it happens. See [Give it a goal](#give-it-a-goal) below. The first run sets the machine up: - builds the `browser-input` helper, the driver every mouse and keyboard action goes through, from the source in this checkout. That needs the Xcode command-line tools (`xcode-select --install`). On a Mac without them, setup offers a signed helper from GitHub Releases instead; it is used only if Apple's signature check says this project signed it and it is the version this code expects - checks OS input permission: requests Accessibility permission and opens the correct System Settings pane; grant access, then re-run if macOS has not reported it yet - launches regular Chrome with an isolated profile at `~/.browser-agent/profile`, brings it to the front, and makes its window fill the screen (turn that off with `executor.maximizeChromeOnStart: false`) The native helper binary is not committed to git; `native/macos/browser-input/bin/` is a local build/download output. To build it yourself: ```bash xcode-select --install bash native/macos/browser-input/build.sh ``` The helper reports a build version; preflight rebuilds an outdated one on its own, and the executor refuses to run with one. Bump `DRIVER_VERSION` in `native/macos/browser-input/main.swift` and in `lib/driver.js` together whenever the helper's behavior or protocol changes. If Chrome is installed somewhere unusual, set `BROWSER_AGENT_CHROME_PATH` or `chrome.executablePath` in `browser-agent.config.json`. ## Give it a goal The runner is one loop and one folder. A model works the browser toward your goal, and whatever the goal produces is saved as files in a folder for the run: | Goal | What ends up in the folder | |---|---| | "Collect the name and price of every kettle on …" | `kettles.csv`, added to a few rows at a time | | "Research … and write up what you find" | a markdown report with its sources | | "Download ten pictures of cats from …" | the image files | | "What year was Ada Lovelace born?" | nothing: the answer is the summary | ```bash node runner/cli.js [options] "" ``` Installed as a package, the same command is `browser-agent`. Or start it with a page to type into: ```bash npm start ``` That opens a page in Safari with a box for the goal and a Go button. Under Options are the model, the two limits, the signed-in and screenshot switches, and a list of earlier runs to continue. While a run is going the page shows each step, and a box to **tell it something while it works**: a fact, a correction, a place to look. The run reads it before its next step and carries on, so nothing has to be stopped and started again to add to a goal. When the run ends, or the model has a question, the page comes back to the front with the summary, the files that were saved and a button that opens the run's folder. A goal you run again and again can be saved as a **job**: give it a name and press Save as job, and the goal and its options are kept under that name. The jobs are listed at the top of the page, each with Run (starts it as saved, one click), Edit (puts it back in the form; save under the same name to replace it) and Delete. They are kept in `jobs.json` in the folder `npm start` runs in, readable only by your account and left out of git. It uses the settings in `.env`. The page is served to this computer only, and only the page that `npm start` opened can start a run. | Setting | Flag | What it is | |---|---|---| | `OPENAI_MODEL` | `--model ` | The model to use. It must support tool (function) calling. | | `OPENAI_API_KEY` | | The key for it. The command asks for it if it is not set; the start page does not ask, so put it in `.env`. | | `OPENAI_BASE_URL` | `--base-url ` | Optional: another server that speaks the OpenAI Chat Completions API, such as a local Ollama at `http://127.0.0.1:11434/v1` (no key needed). | | `OPENAI_API` | `--api ` | Which OpenAI API that server speaks. Default `chat` (Chat Completions, which most compatible servers offer); `responses` for a server that offers only the Responses API. | | `OPENAI_TEMPERATURE` | | Optional: how much the model's replies vary, 0 to 2. Sent only when set; some models refuse it. | | `OPENAI_REASONING_EFFORT` | | Optional: how hard the model thinks before each step, for example `low`. Sent only when set; some models refuse it. | | `OPENAI_CONTEXT_LIMIT` | | Optional: the model's context window, in tokens (for example `1048576`). With it, a run stops cleanly once the conversation reaches half of it, and the model is warned from 80% of that on so it can save and finish. The folder keeps what was saved, and continuing from it starts a fresh conversation. Without it there is no such stop, and a conversation that grows past what the model takes ends the run with the provider's error. | | `OPENAI_CONTEXT_SHARE` | | Optional: the share of the context window a run may use, more than 0 and at most 1. Default `0.5`. | | `VIEW_PORT` | | Optional, for `npm start`: also serve a page on this port for watching a run from a phone on the same Wi-Fi (three tabs: Watch, with pictures of the screen while a run is going and its latest steps; Prompt, with the goal, the opening message and the standing instructions the model was given, the canary hidden; Notes, with the finish line and the model's note on every step, newest first. Its one control is an emergency Stop, so it cannot start a run, answer a question or make the browser act). The address, with its key, is printed at start; the key is kept in `~/.browser-agent/view-key`. Plain HTTP, so for a home network only. The Mac's firewall asks once whether `node` may accept incoming connections, and the terminal it is started from needs Screen Recording permission (System Settings › Privacy & Security) or the Watch tab gets no pictures. | | | `--out ` | The run's folder. Default: a new one under `runs/`. Name the folder of an earlier run to continue it. | | | `--private` | Work in a private window with no sign-ins, cookies or history, removed when the run ends. Without it (the default) the run works in the agent Chrome's ordinary windows, with whatever is signed in there; when such a run succeeds, the tabs it opened are closed (unless the model leaves a page open for you to finish something on: `done` with `leave_open`); tabs that were already open are left alone, and after a run that fails or is stopped all stay. | | | `--auto-approve` | Do not ask before spending money, sending or posting in your name, or anything that cannot be undone: the model goes ahead when the goal calls for it and lists each such step in its summary. It still asks you to sign in and to make choices only you can make. On the start page: the Auto-approve box, off by default. | | | `--images` | Also show the model the screenshots it takes. Only for a model that can read images. `capture_burst` and `keep_frame` are offered only with it. On the start page this switch, like the signed-in one, is on by default. | | | `--max-turns `, `--minutes ` | Limits. Default 1000 turns and 120 minutes. The minutes are working time: while a question waits for your answer, the clock does not run. | All of these can go in a `.env` file in the folder you run from (see `.env.example`). To keep settings for a second server, put them in a file of their own and start with `node --env-file= runner/cli.js …`: what it sets wins over `.env`. The summary goes to standard output, everything else to standard error, and the exit status is 0 only when the model reports the goal met. Each turn's line in the log gives the tokens in and out, and, when the model's server reports them, how many of the tokens in it had cached and what the reply cost (OpenRouter reports both); the run's totals are in the result. Nothing is worked out from a price list. When the run ends, the terminal you started it from comes back to the front. Chrome must stay in front while it works, because the clicks and keystrokes are real; if you touch the mouse or keyboard, it pauses until you stop. What the runner adds to the browser's own tools is small on purpose: - **A finish line.** Before it does anything else the model says, with `set_finish_line`, what will be true when the goal is finished ("50 image files in the folder, from 3 pet sites"; for an open goal such as "research X" it picks one itself). Until it has, only `ask_user`, `read_file` and `list_files` run. The line is written in the log and shown with the result, next to the number of files in the folder, so you can hold one against the other. The runner itself does not check it. The model can change the line, but only with a reason, and every version is kept: the result, the start page and the log show the first one next to the one it ended with. - **Four file tools** (`write_file`, `append_file`, `read_file`, `list_files`) that work only inside the run's folder. `list_files` gives the count, the count per type and up to 200 names, so the model counts files there and not from memory. Downloads and screenshots land in the same folder. There is no spreadsheet tool and no report tool: a CSV file is the sheet and a markdown file is the report. The model is told to save as it goes, so a run that is stopped keeps what it found, and long text is cut from the conversation once it is in a file. What is appended always starts on a line of its own; a file that `write_file` replaces is kept as a version the model can read back; and the runner's own `run.log` cannot be written or read by the model under any spelling of its name. - **A memo on every browser step.** Only the newest page listing is kept in full, so each browser tool takes a short note of the facts from that page the model will need later (not what it is about to do). Without it a model forgets the previous page and goes round in circles. The same goes for the newest folder listing and the newest file read (every part of it: a long file is read in parts, and they stay together), and for text read from a page and pictures taken of it, which go once the browser is somewhere else. - **A status every turn.** Before each model call the runner adds a short status of its own, last in the conversation and replaced every turn: the goal as you typed it, the finish line (and the first one, if it changed), the turns and minutes used, what the folder holds, where the browser is and how often the run has been there, and how many steps in a row changed nothing or failed. However long a run gets, the goal stays in front of the model, and the counts come from the folder and the browser, not from the model's notes. It reports; it does not stop or steer anything. - **A word from you while it works.** What you tell a run (the box on the start page, or `hear` from code) reaches the model before its next step as your own words, stays in the conversation, and is written in the log, so a run that continues the folder later is told it again. - **`ask_user`**, which brings your terminal to the front, puts a question to you there and waits. The model is told to ask before anything that spends money, sends or posts in your name, or cannot be undone, and to have you sign in yourself, never to ask for a password. With nobody at the terminal it is told to leave such steps undone. - **`new_password`**, for an account the goal asks the model to create. The runner makes a 20-character password, saves it in your macOS keychain as "browser-agent: SITE", and gives the model only `{{password:SITE}}`. In a `type` step the stand-in becomes the real password at the last moment, and only on that site's own pages; every answer has it swapped back out, so the password never reaches the model, the log or the phone page. A later run finds it in the keychain. - **A canary.** Each run gives the model a made-up secret it must never let out. If any step but a question to you or the summary would carry it (as written, in any case, percent-encoded or in base64), something on a page has taken the model over: the run stops before that reply is carried out, with `tripwire: 'canary'` in the result. - **Steps sent together.** The model is told to send steps that do not depend on each other's result in one reply, because every reply resends the whole conversation. They run in order; if one fails, or a field does not end up holding what was typed, the rest are not carried out. A step that sends, posts or buys is to go in a reply of its own. - **`done`**, which ends the run with a summary and whether the goal was met. When a signed-in run succeeds, the tabs it opened are closed, unless the model left a page for you to finish something on (`leave_open`). It does not plan, reflect, detect loops or write reports. A run ends when the model calls `done`, a limit is reached (steps, minutes, or the share of the context window it may use), the canary trips, or you press Ctrl-C. **What a run is allowed to touch.** By default a run works in the agent Chrome's ordinary windows, so it can act as you on any site you are signed in to there, and what it reads there goes to whoever runs the model. Asking before a purchase or a post is an instruction the model is given, not a lock: the runner cannot tell which click pays. `--private` gives the run a private window with no sign-ins, cookies or history instead, so there is no account it could spend from or post as; sites treat it as a brand-new visitor, and some (Reddit, Google) block or challenge it more. **Continuing a run.** The folder is the run's whole state. Start again with `--out ` and the model is told which files are there and to carry on from them. From code: ```js const { run } = require('browser-agent/runner'); const result = await run('Download ten pictures of cats from …', { model, apiKey }); // → { status: 'done' | 'stopped' | 'failed', success, summary, tripwire, finishLine, finishLines, dir, files, turns, // tokens: { in, out, cached }, cost } (cached and cost: as the model's server reported them; cost is null when it did not) ``` `run` takes the same settings as the command (`api`, `dir`, `signedIn` (true unless you pass false), `images`, `autoApprove`, `maxTurns`, `minutes`) and the model settings (`temperature`, `effort`, `contextLimit`, `contextShare`): `run` does not read the `OPENAI_*` variables itself, and `modelSettings()` turns them into these. It also takes `finishedWhen` (a finish line you already know), `canary` (false to leave it out), `ask` (how to put a question to a person), `hear` (what the person has said to the run since it last asked, to pass on), `signal` (an AbortSignal that stops it), `log` (each line of progress), `onStart` and `onStep` (what the model was given, and its notes each turn, for a watcher; the canary is hidden from both), `browser` (a controller you opened yourself) and `complete`: your own function from the conversation and the tools to the model's reply, for a model that does not speak Chat Completions. Without `complete` it uses OpenAI's official Node library, which is installed as an optional dependency: the browser-control library does not load it. ## Use it from your own code ```js const OpenAI = require('openai'); const { openBrowser } = require('browser-agent'); const client = new OpenAI(); const browser = await openBrowser(); const first = await browser.observe(); const messages = [ { role: 'system', content: 'You control a browser with the tools provided. Answer in plain text when done.' }, { role: 'user', content: `${task}\n\nThe browser currently shows:\n\n${first.text}` }, ]; for (;;) { const { choices } = await client.chat.completions.create({ model, messages, tools: browser.tools }); const reply = choices[0].message; if (!reply.tool_calls?.length) { console.log(reply.content); break; } messages.push(reply); for (const call of reply.tool_calls) { const result = await browser.call(call); // result.content already holds the new page messages.push(result.message); } } await browser.close(); ``` | | | |---|---| | `openBrowser(opts)` | Sets up, connects, starts the driver. Options: `port`, `url`, `preflight`, `session`, `config`, `outputDir`, `pageInResults`, `privateWindow`. | | `browser.tools` | Tool definitions in Chat Completions format. `browser.toolsFor('responses')` for the Responses API. | | `browser.observe()` | Reads the page now: `{ url, title, viewport, listing, briefHash, text, addresses }`; `addresses` maps each shortened address in the listing to the full one. | | `browser.call(toolCall)` | Carries out one tool call: `{ ok, name, summary, content, message, page, image?, images?, file?, differs? }`. `images` holds a burst's 25 pictures; `differs` is set when a typed field does not hold what was typed. | | `browser.toFront()` | Brings the browser's window back to the front, after your code sent the person to another app. | | `browser.stepBack()` | Gives the front back to the app the browser took it from at the start, usually your terminal, if the browser is still in front. | | `browser.close()` | Stops the driver and closes the connection it opened. First it gives the front back to the app the work was started from, whatever is in front by then, so the end of the work is never hidden. | Things worth knowing: - **The answer already contains the new page.** After any action that can change the page, `result.content` is `ok: …` followed by the fresh listing, so a plain tool-calling loop needs no extra glue. `result.summary` is the outcome without the listing; keep just that for older steps if you manage your own context (the runner does). Pass `pageInResults: false` to get short answers and call `observe()` yourself. - **Changes the text does not show are seen too.** Before and after each action that can change the page, the controller compares a small picture of it. When the text is the same but the picture changed (a video jumping ahead, a map panning), the answer says so instead of "the page did not change", and `result.page.pictureChanged` is true. The pictures stay in the process. - **Mistakes come back as answers, not exceptions.** A wrong ref, bad JSON, an unknown tool or a covered button is an `ok: false` result worded for the model to act on. Only two things throw: a fatal driver problem, and a call on a controller you have closed. - **One call at a time.** There is one mouse and one keyboard, so calls run in the order you make them, even if you start several at once. - **Refs keep naming their element.** A ref keeps working in later listings for as long as its element is on the page and says the same thing, so several calls written against one listing all work. It is refused when its element is gone or has changed, when its page is no longer open, or when the page was acted on and not read since. A number is never given to a second element, so a model cannot click the wrong thing because a number was recycled. - **Both OpenAI formats are accepted.** A Chat Completions call gets a `{ role: 'tool', … }` answer; a Responses API call gets a `{ type: 'function_call_output', … }` answer. `toolDefinitions()` returns the tool definitions without opening a browser. `connect()` and `extract()` read a page without acting on it. ## The tools | Tool | What it does | |---|---| | `read_page` | The current page listing: the screen and one screen below, or with `whole: true` the whole page. | | `click` | Real mouse click on a node, aimed at where it is now: a control, text, or a picture or video (`@r`). Refuses if it is gone, off the page or covered. On a dropdown, opens its choices and says how to pick one. | | `hover` | Moves the real pointer onto a node and leaves it there, without clicking: for menus and tips that open on hover. | | `upload_file` | Clicks a file field (or the button that opens the file chooser) and gives it a file from the upload folder. Off until `upload.dir` is set. | | `type` | Clicks a field, then types into it key by key. Replaces by default (an empty text empties the field); `submit` presses Enter, but not when the field turns out to hold something other than what was typed, which the answer says. A line break is the Enter key, so text with line breaks needs a multi-line field. | | `press` | One key, or a combination: Enter, Tab, Escape, Backspace, Space, arrows, Home, End, PageUp, PageDown or one character, with Shift, Control, Option or Command held. Combinations that are commands to Chrome or the Mac (quit, close, paste…) are refused. | | `answer_dialog` | Answers the alert, confirmation, question or "leave this page?" the page is showing, with the real keyboard. While one is open, the page cannot be read or used. | | `scroll` | Real wheel scroll: up, down, left, right. With a ref, the frame or the scrolling box under that node scrolls instead of the page. | | `navigate` | Loads a URL, or a path on the current site as the listing shows links (http and https only; local and private addresses only when allowed). A shortened address from a listing (with `…`) goes to the full one; a bare host such as `example.com` gets `https://`. Stops at a "leave this page?" question. | | `back` | The browser Back button. A tab with nothing to go back to is closed instead, when the session has another tab open (in a private window: another tab of that window). | | `list_tabs` | The open tabs, by number; the one being read is marked. | | `switch_tab` | Reads and acts on another tab from now on, and brings it to the front. | | `close_tab` | Closes a tab. The last one is not closed. | | `wait` | Pauses for an animation or a slow update. | | `read_text` | The full text of one node (listing lines are shortened). | | `take_screenshot` | Saves a picture of the page or of one node; offered to the host as `result.image`. | | `capture_burst` | Takes 25 pictures over 5 seconds, one every 0.2 s, of the page or of one node, for what one picture misses (video, animations, things that show briefly). They go in `burst/` in the output folder, which each burst empties first, and are offered to the host as `result.images`, each with its number and time. | | `keep_frame` | Copies one picture of the last burst into the output folder, where the next burst does not touch it. | | `get_files` | Lists the downloadable files linked on the page, and the image files it uses (`@v` refs). | | `save_file` | Downloads a file, or the original of an image (an image line of the listing, or an image file from `get_files`), to disk. Says so when a web page came back instead of the file. | Screenshots and downloads are written to `output/` (or `outputDir`). ## Platform macOS only. Browser Agent has one input path: the `browser-input` driver, a small macOS program. Every click, keystroke and wheel scroll is posted by the operating system (`CGEventPost`), never synthesized over the DevTools connection. It needs Accessibility permission. No other operating system is supported. Because the input is real, it needs a real desktop: the browser-agent Chrome must be the frontmost app on a screen that is awake and unlocked. A running screen saver counts as locked. Input pauses while that Chrome is in the background or while you are using the mouse or keyboard, and resumes on its own. Input is tied to one process. The session asks Chrome for its own process id, and every click, key and scroll carries it: the executor waits for that process to be frontmost, and the driver checks again at the instant it sends — and, for a click or scroll, that the window under the pointer belongs to it. Another Chrome that happens to be in front, your everyday one included, does not count. If another app's window, such as a system alert, lies over the spot while Chrome is in front, the action stops and its answer names that app instead of waiting behind it. Reading the page uses Chrome DevTools Protocol, and so do the actions that are not mouse or keyboard input: loading a URL (a page cannot see the address bar, so nothing is typed there), going back in history, scrolling a click target into view, switching and closing tabs, handing a file to a file chooser, and maximizing the window at the start. ## Configuration Defaults live in `lib/config.js`, and nowhere else; `browser-agent.config.json` in the working directory overrides them, and `openBrowser({ config })` overrides both. The file shipped in this repo lists every setting with its default. There are settings for how the page is read (`page`, `view`), for the driver (`executor`), for screenshots, and for where files go (`output`). There are no model settings. The full table is in [`DESIGN.md`](DESIGN.md). Five settings are taken only from a settings file that is yours: the two that name a program to run (`executor.binPath`, `chrome.executablePath`), the folder files are written to (`output.dir`), the switch for local addresses (`page.allowLocalAddresses`), and the folder files may be uploaded from (`upload.dir`; uploading is off until it is set, and only files in that folder can be given to a page). From a settings file that is merely found in the working directory they are honored only if the file and its folder belong to you and nobody else can write to them; otherwise they are ignored, with a warning. A file you name with `BROWSER_AGENT_CONFIG` is taken as yours. `page.allowLocalAddresses` is off by default: `navigate` and `save_file` refuse addresses on this computer and its network (`localhost`, `192.168.x.x`, …), and a local page reached through a link is held back: it is not shown to the model, and until the browser has left it only `navigate`, `back`, `wait`, `read_page`, the tab tools, `answer_dialog` and `keep_frame` run — no screenshot, no file list, no typing or scrolling. A frame at such an address inside an ordinary page is not read either. Turn the setting on to work on a site you run locally. ## Security and trust Browser Agent lets a model drive a browser. Treat both the page and the model as untrusted. Guardrails today: - dedicated Chrome profile at `~/.browser-agent/profile` - `openBrowser({ privateWindow: true })` works in a window of its own, with none of the sign-ins, cookies or history of the other windows in that Chrome: use it when you are signed in to anything there, since everything the model reads goes to whoever runs the model. Only that window's tabs can be listed, switched to or followed, and the window goes when the controller is closed - navigation and file saving reject everything but http and https (and `data:` for saving), and — unless you allow them — addresses on this computer and its network, judged by where a name actually leads - Chrome is started without `--remote-allow-origins`, so a web page cannot connect to the debugging port - what is typed in a password field never reaches the model: fields of type password, fields the page marks as a password, and fields drawn as dots - reading the page, screenshots, file discovery and downloads inject no script and change nothing in the page. (One exception, measured: a cropped screenshot that reaches past the screen needs Chrome's capture-beyond-the-screen mode, which sends the page a resize event, so it is used only then; crops of what is on screen, and pictures of the screen itself, send nothing.) The only script that runs is the watcher that tells when the page has come to rest after an action: it runs in an isolated world, which shares the page's document but not its scripts, so the page cannot see it, and it only observes - input goes only to the Chrome the session is connected to, identified by its process: it must be the frontmost app and own the window under the pointer, checked by the driver itself as each event is sent; input pauses while the human is actively using the machine - a ref is accepted only while its element is still on the open page, unchanged; a number is never given to a second element - text a person could not see is left out of what the model reads, and the listing says so - a run's canary secret stops it the moment the model tries to let it out - passwords for accounts a run creates are kept in the macOS keychain and typed only on their own site; the model, the log and the phone page never see them - downloaded file names are reduced to a plain name inside the output directory - the model is told a saved file's name, never its location on your disk - `output/` is local and git-ignored Things it does not do for you: - Prompt injection is not solved. Page text is data, but a model may still obey it; say so in your system prompt (the runner does) and do not hand an unattended browser high-stakes accounts. - Chrome's debugging port is open on localhost while it runs. Any program on the same machine can connect to it and control that browser. - The local-address rule covers the addresses given to `navigate` and `save_file`, and keeps the model from reading a local page it reached some other way. It does not stop the request a link or a redirect makes on the way there. ## Tests ```bash npm test # no browser, no model, no real input npm run test:browser # page reading in a hidden Chrome (safe while a run is going) npm run launch # start the browser-agent Chrome (for the real-input test) npm run test:e2e # the hidden-Chrome tests, then real mouse and keyboard npm run test:input # the real mouse-and-keyboard test alone ``` `npm test` runs the real executor against a fake driver, the page reader against canned browser data, the runner against a stand-in browser and a scripted model, and asks the built driver its read-only questions. The page-reading browser tests start their own hidden Chrome on a throwaway profile and touch nothing you have open. The real-input test (`test/input.test.js`) checks that clicks, typing, key presses and scrolling physically reach a page — also at 125% zoom, inside a frame, and on a button half cut off by the window's edge — and that the driver refuses input meant for an app that is not in front. It skips with a reason when the driver, the permission, Chrome, or an awake screen is missing. ## Contributing Good places to push: - reading and acting inside frames from other sites (same-site frames are read) - examples for other hosts: the Responses API, agent frameworks - better detector-facing measurements for humanized input Full contracts live in [`DESIGN.md`](DESIGN.md). MIT.