When your browser automation gets stuck, send a link to a human. They see the live page, click and type to fix it, press Done, and your script carries on in the same browser with everything they did still in place.
const result = await pilot.rescue(page, "Log in with the ops account and approve the 2FA prompt"); if (result.solved) { // same page, now logged in }
Animated walkthrough of the whole flow.
It's for the moments only a person can handle: a login that needs real credentials, an SMS or authenticator code, a CAPTCHA your solver can't do, a consent wall, a page layout your agent has never seen. Pilot works with Puppeteer, Playwright and Browser Use, with a local Chrome or a cloud browser, and the link can go to the console, Slack, Discord, Telegram or your own code.
git clone https://github.com/rozetyp/pilot && cd pilot npm install npm run demo
The demo starts a Pilot server, opens a test page in a headless Chrome, and prints a rescue link. Open it, do what it asks, press Done, and the script prints what it now sees on the page.
Needs Node 18+ and Google Chrome. If you don't have Chrome, run npx puppeteer browsers install chrome first (npm 11 skips that download by default).
your script Pilot server a person
─────────── ──────────── ────────
rescue(page, "...") ──────▶ attaches to the browser over CDP
starts a live screencast
sends the link ─────────────────▶ opens it, sees the page live
relays clicks, keys, scroll, drag ◀─ fixes the problem
waits (polls status) marks it solved ◀───────────────── presses Done
returns { solved: true } ◀─── detaches; your browser keeps running
Pilot never launches or closes your browser. It attaches to the one you already have through the Chrome DevTools Protocol (CDP), so cookies, the logged-in session and the page state all stay where your script expects them.
The server must be able to reach the browser's CDP address. For a Chrome on your laptop, run the server on the same machine; for a cloud browser, use the wss:// URL the provider gives you.
Start the server (npm start, port 3001), then copy sdk.js into your project or require it from this repo. It's a single file with no dependencies.
The SDK reads the CDP address from the page, so this is all you need, whether the browser is local (puppeteer.launch) or remote (puppeteer.connect).
const pilot = require("./sdk")("http://localhost:3001"); const result = await pilot.rescue(page, "Solve the CAPTCHA"); if (!result.solved) console.log(result.error, result.message);
Playwright doesn't expose the CDP address, so launch Chromium with a debugging port and pass it in. Full example: examples/playwright.js.
const browser = await chromium.launch({ args: ["--remote-debugging-port=9222"] }); // ... const result = await pilot.rescue(page, "Log in", { cdpUrl: "http://127.0.0.1:9222" });
The same cdpUrl option works for anything else that speaks CDP: a cloud browser's wss:// URL, or a Chrome started by hand with --remote-debugging-port.
browser_use_plugin.py adds a request_human_help action that the agent calls by itself when it's stuck. The result tells the agent whether the human solved it, or their note if they couldn't. Tested with browser-use 0.13.
from browser_use import Agent, ChatOpenAI from browser_use_plugin import create_pilot_tools agent = Agent( task="...", llm=ChatOpenAI(model="gpt-4.1-mini"), tools=create_pilot_tools("http://localhost:3001"), )
LLMs often try CAPTCHAs and logins themselves before asking. examples/browser_use_agent.py shows a system-prompt line that makes the agent hand over straight away.
It's plain HTTP. Create a rescue, poll until it's no longer PAUSED_NEEDS_HUMAN, then release it:
curl -s localhost:3001/sessions -H 'Content-Type: application/json' \ -d '{"cdp_url": "http://127.0.0.1:9222", "context": "Accept the cookie banner"}' # {"session_id":"pilot_...","pilot_url":"http://localhost:3001/pilot/...","streaming":true,"expires_in":600} curl -s localhost:3001/sessions/pilot_... # {"status":"PAUSED_NEEDS_HUMAN", ...} until the human finishes curl -s -X DELETE localhost:3001/sessions/pilot_...
{ solved: true, session_id, pilot_url } { solved: false, error: "unsolvable", message: "need the SMS code" } // the human pressed "Can't solve"
error is one of unsolvable, timeout, browser_died, session_lost, server_unreachable, no_cdp_endpoint, session_create_failed or unexpected. rescue() never throws.
Options: cdpUrl, timeout (ms, default 10 minutes), poll (ms, default 1000), onRescueUrl(url, context) to send the link somewhere yourself, and quiet to stop it printing the link.
The rescue page works on desktop and phone. It shows the page live, with the task at the top, and lets the person:
- click, scroll, and Ctrl/Cmd/Shift-click
- type straight into the page, or use the input bar (easier on a phone); Tab, Enter, Escape, Backspace, Delete, the arrow keys and paging keys are forwarded
- drag, for slider CAPTCHAs (the movement is eased with jitter so it looks human)
- go to a URL with the navigation bar
- press Done, or Can't solve with a note that is passed back to your script
The link is always printed to the server log and, by the SDK, to your script's console. To send it further:
| Where | How |
|---|---|
| Slack or Discord | Set PILOT_WEBHOOK_URL to an incoming-webhook URL. The JSON body has text (Slack) and content (Discord), plus pilot_url, context and session_id for your own receivers. |
| Telegram | Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID. |
| Anything else | Pass onRescueUrl to rescue(), or on_rescue_url to the Browser Use plugin. |
All optional.
| Variable | Default | What it does |
|---|---|---|
PORT |
3001 |
Server port. |
PUBLIC_URL |
http://localhost:$PORT |
Base of the rescue links. Set it when the person opening the link isn't on the same machine. |
PILOT_API_KEY |
none | If set, creating and reading sessions needs an X-API-Key header with this value. Set it whenever the server is reachable by anyone else. |
PILOT_SECRET |
random per start | Signs rescue links. Set it so links survive a restart. |
PILOT_WEBHOOK_URL |
none | Where to POST each rescue link (Slack, Discord, or your own endpoint). |
TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID |
none | Send each rescue link to a Telegram chat. |
To open links from a phone or from another network, put the server behind HTTPS (any reverse proxy, or a tunnel such as cloudflared or ngrok) and set PUBLIC_URL to that address.
- Rescue links are HMAC-signed and expire after 10 minutes. Whoever holds the link can control that browser tab until they press Done, so send it only to people you'd trust with the session.
- Sessions are private. Only the API key (if you set one) and the holder of that session's link can see or touch a session; everyone else gets 404.
- After Done, nobody can drive the browser. Input, screenshots and the live stream are refused once a rescue is resolved.
- Pilot can connect to any address it's given, including private ones; that's what makes local browsers work. If the server is exposed, set
PILOT_API_KEYso strangers can't make it connect anywhere.
- Sessions live in memory: restarting the server ends any open rescue.
- Pilot follows the tab that was open when
rescue()was called. If the site opens a new tab, use the navigation bar instead. - Browserless allows one CDP client at a time. Pilot's connection can drop your script's, so on Browserless call
rescue()and let it finish before using the page again. - A person driving an automated browser is still using that browser's fingerprint and IP, so the strictest bot checks may block them too.
- The stream is a JPEG screencast, capped at 1280x800 and usually a few frames per second. It's fine for forms and CAPTCHAs, not for video.
A hosted version of Pilot runs at pilotapp.dev. It's the same rescue mechanism with a different arrangement:
| This repo (self-hosted) | pilotapp.dev (hosted) | |
|---|---|---|
| Who solves the problem | You or your team | Pilot's operator |
| Which browsers | Anything your server can reach, including Chrome on your laptop | Cloud browsers with a public CDP URL (Browserbase, Browserless and similar); it can't reach your localhost |
| Where the link goes | Console, webhook, Telegram, or your own code | Pilot's operator; your script just waits |
| Accounts and cost | None, free, MIT | API key; 10 free rescues, then $49 for 50, charged only when solved |
| Who runs the server | You | Pilot |
The SDK and the Browser Use plugin work with both: point them at https://pilotapp.dev and pass your API key.
| Method | Path | Who can call | What it does |
|---|---|---|---|
POST |
/sessions |
agent | Start a rescue: { cdp_url, context?, target_url?, viewport? } returns { session_id, pilot_url, streaming, expires_in } |
GET |
/sessions/:id |
agent or link holder | { status, context, message, viewport, actions, created_at, resolved_at } |
GET |
/sessions/:id/screenshot |
agent, or link holder while open | One JPEG frame as base64 |
POST |
/sessions/:id/act |
link holder while open | One input action (below) |
POST |
/sessions/:id/resume |
link holder while open | Finish: { solved: true } or { solved: false, message } |
DELETE |
/sessions/:id |
agent or link holder | Release the session; the browser keeps running |
GET |
/pilot/:token |
anyone with the link | The rescue page |
GET |
/health |
anyone | { status, sessions, uptime } |
"Agent" means a request with the X-API-Key header when PILOT_API_KEY is set (anyone otherwise). "Link holder" means Authorization: Bearer <token>, where the token is the last part of the rescue link.
cdp_url can be ws://, wss://, or http://host:port (the browser's debugging address). target_url picks which tab to use if there are several.
Status is PAUSED_NEEDS_HUMAN while waiting, then RUNNING (solved), UNSOLVABLE, or DEAD (the browser went away).
Actions for /act: click_coords {x, y, modifiers?}, click {selector}, type {selector, text}, type_focused {text}, key {key}, scroll {x, y, deltaX, deltaY}, drag {x, y, toX, toY, steps?}, navigate {url}, screenshot. Each returns a fresh screenshot.
npm test # end to end, no human needed (about 15 seconds) python test/test_browser_use_plugin.py # the Browser Use plugin, no LLM needed
npm test runs a real server, a headless Chrome as the agent, and a second headless Chrome that uses the actual rescue page as the person would: it clicks through the live stream, types, and presses Done. It also checks access control, the "Can't solve" note, timeouts, the http:// CDP path and webhooks.
The server is server.js (Express, ws and puppeteer-core), and the rescue page is public/rescue.html. There's no build step.
MIT
