Migrate this codebase from Browser Use Cloud to pre.dev Browser Agents.
## Why
pre.dev Browser Agents is a drop-in replacement for Browser Use Cloud's
task API: same URL + instruction + JSON-schema contract, structured JSON
output, 12× cheaper at 100/100 pass on the public benchmark. Docs:
https://docs.pre.dev/browser-agents/migrate-from-browser-use
## Do this
1. **Find call sites.** Search the entire repo (not just `src/`) for:
- Imports: `browser-use-sdk`, `from browser_use`, `BrowserUse`,
`browser_use_sdk`.
- Env refs: `BROWSER_USE_API_KEY` in code, `.env`, `.env.example`,
`.env.*`, CI configs (`.github/workflows/*`, `render.yaml`,
`vercel.json`, `docker-compose*.yml`, `Dockerfile*`, `fly.toml`),
README, internal docs.
- Any `cloud.browser-use.com` or `api.browser-use.com` URLs.
2. **Swap the SDK.**
- Node/TS/Bun: replace `browser-use-sdk` dependency with
`predev-api` in `package.json`, `bun.lockb`, `yarn.lock`, or
`pnpm-lock.yaml` (let the user run the install).
- Python: replace `browser-use-sdk` with `predev-api` in
`requirements.txt`, `pyproject.toml`, `poetry.lock`, or
`Pipfile` (let the user run the install).
3. **Rewrite calls** per these rules. Full mapping at
https://docs.pre.dev/browser-agents/migrate-from-browser-use — read
it once before editing.
| Browser Use | pre.dev |
|---|---|
| `import { BrowserUse } from 'browser-use-sdk/v3'` | `import { PredevAPI } from 'predev-api'` |
| `new BrowserUse({ apiKey })` | `new PredevAPI({ apiKey })` |
| `client.run(taskStr, { llm })` | `client.browserAgent([{ url, instruction, output }])` |
| `response.output` (JSON string) | `result.results[0].data` (already parsed) |
| Python `from browser_use_sdk import BrowserUse` | `from predev_api import PredevAPI` |
| Python `BrowserUse(api_key=...)` | `PredevAPI(api_key=...)` |
| Python `client.run(task, llm=...)` | `client.browser_agent([{...}])` |
| Python `json.loads(response.output)` | `result["results"][0]["data"]` |
| Embedded URL in task string | first-class `url` field |
| Zod/Pydantic schema | JSON Schema in `output` field |
| Parallel via `Promise.all(client.run(...))` | single call with `client.browserAgent([...])` + `{ concurrency }` |
| `handle.sessionId` + session polling | `client.browserAgent([...], { async: true })` + `client.getBrowserAgent(id)` |
| Python async equivalent | `client.browser_agent([...], run_async=True)` + `client.get_browser_agent(id)` |
4. **Env vars.** Rename `BROWSER_USE_API_KEY` → `PREDEV_API_KEY`
everywhere (code, env files, CI, docker). Base URL is
`https://api.pre.dev` if it's referenced explicitly.
5. **Unsupported features — leave TODOs, don't delete.** For any of:
- `client.sessions.*` (persistent sessions)
- `client.agent_profiles.*` / `AgentProfile`
- `client.schedules.*`
- raw Playwright handoff
Leave a comment above the call:
`// TODO: pre.dev equivalent not yet available — see https://docs.pre.dev/browser-agents/migrate-from-browser-use#whats-different--not-yet-supported`
and keep the original code path so tests don't explode. We'll
hand-migrate these.
6. **Verify.** After edits, run the project's typecheck and test
commands (infer them from `package.json` scripts,
`pyproject.toml`, or a `Makefile`). Fix anything that breaks.
Do not skip this step.
7. **Report.** At the end, print:
- Files changed (grouped: imports, env, call sites).
- Count of migrated calls.
- Count of TODO-comments left for unsupported features.
- Any test/typecheck failures you couldn't fix, with exact
file:line and why.
## Constraints
- **Don't delete** any original code until the replacement is verified
working. If unsure of a mapping, leave the old call with a TODO
and surface it in the final report.
- **Don't guess** the pre.dev SDK name — it's `predev-api` on both
npm and pip. If that's not what the project's package manager
resolves, stop and ask.
- **Respect the user's existing code style** — don't reformat files
you didn't otherwise change.