Wink Pings

Let the Agent Write Its Own JavaScript to Control Chrome: Getting Started with browser-use-pi

Gregor Zunic's recommended browser-use-pi combines Pi Mono, a persistent V8 REPL, and raw CDP. The Agent writes JavaScript inside it to control Chrome, creating helper functions on the spot as needed.

On X, Gregor Zunic suggested a combination for people building personal agents: browser use pi plus browser use cloud browser. According to him, if you want to push browser interaction to SOTA, you can use this stack. The project is called browser-use-pi on GitHub, is based on Pi Mono, and is written in TypeScript.

Browser Use Pi banner

A common approach for browser agents is to give the model a fixed set of actions: click buttons, fill forms, read pages. Once a page gets complex, the tools are not enough, and you have to keep adding tools. Browser Use Pi takes a different path. It puts browser operations into a persistent V8 REPL, and the Agent directly writes JavaScript to control Chrome, writing whatever helper it needs on the spot. The architecture is roughly: the task goes into Pi Mono, then to the persistent V8 REPL, then uses raw CDP to control Chrome; page state is sent back via the accessibility tree and screenshots. CDP is the Chrome DevTools Protocol, which can be understood as a low-level interface for directly controlling the browser.

This design pushes "calling tools" toward "generating tools". The benefits are concrete: complex pages can be worked around by writing code, repeated operations can be turned into reusable functions, and login state and sessions can be preserved. The project docs list sessions, saved logins, streaming, and typed results, all available through one SDK you put into your app. When building personal agents, login state and continuous sessions are often more critical than one more click tool.

Installation is not complicated:

npm install @browser_use/pi
# 或 pnpm add @browser_use/pi
# 或 bun add @browser_use/pi
export OPENROUTER_API_KEY=...
export BROWSER_USE_API_KEY=...

A minimal example:

import { Browser, BrowserUse } from '@browser_use/pi';

const agent = await BrowserUse.create({
  model: 'openrouter/openai/gpt-5.6-luna',
  reasoning: 'xhigh',
  browser: Browser.cloud({ apiKey: process.env.BROWSER_USE_API_KEY! }),
  workspace: './work',
});

try {
  const result = await agent.run('Find the top story on Hacker News.');
  console.log(result.status, result.text);
  await agent.followUp('Summarize the comments.');
} finally {
  await agent.close();
}

Save it as agent.ts and run it with node agent.ts or bun agent.ts. It uses Browser Use Cloud, so you do not need to install Chrome locally. The environment requirements are Node 22.19+ or Bun 1.3.14+; Bun also needs Node to run the V8 worker.

In terms of capabilities, a few points are worth noting. mode: 'ultrafast' prints a compact accessibility tree state, operates by id, and waits only briefly after each action, making it suitable for interaction-heavy tasks. There are also controls such as streaming, hooks, typed results, and compaction, which can limit steps, time, or cost and preserve part of the work. During debugging, you can enable interaction highlights, recording, and GIF export. These are more useful to developers than marketing phrases.

Do not skip security. JavaScript runs in a killable worker, but it has filesystem and network access. Use an isolated machine when handling untrusted tasks. Anonymous run counting is enabled by default and can be turned off with telemetry: false or DO_NOT_TRACK=1.

In the comments, Artale replied, 'finally why this long,' complaining that it came late. This reaction is quite real: many people have been waiting for browser agents that can write their own code. Browser Use Pi combines the REPL, CDP, sessions, and cloud browser, and the direction is clear. Who is it for? People building personal agents who do not want to be stuck with fixed browser tools can start with the docs and examples. Do not treat it as a universal speed-up switch; ultrafast has its scenarios, and code execution has its boundaries.

Project: https://github.com/browser-use/browser-use-pi
Original tweet: https://x.com/gregpr07/status/2115897584216883340

发布时间: 2026-10-30 20:37