@oya-ai/browser 0.1.0 → 1.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +104 -0
  2. package/package.json +10 -4
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # @oya-ai/browser
2
+
3
+ Thousands of browsers behind one API: personas, proxies, stealth, CAPTCHA and MFA. The browser can run on Oya Cloud, Browserbase, Steel, Anchor, Browser Use, your own machines, or any CDP URL. Which one is a setting on your API key, so your code never changes.
4
+
5
+ ```bash
6
+ npm i @oya-ai/browser
7
+ ```
8
+
9
+ Get an API key at [browser.getoya.ai](https://browser.getoya.ai) and export it as `OYA_API_KEY`. Every snippet below runs as-is.
10
+
11
+ ## Quickstart
12
+
13
+ ```ts
14
+ import { Oya } from '@oya-ai/browser';
15
+
16
+ const oya = new Oya(); // reads OYA_API_KEY
17
+ await using browser = await oya.browser.start(); // stopped when the block exits, even on error
18
+ await browser.goto('https://news.ycombinator.com');
19
+ console.log(await browser.ask('What are the top 3 stories?'));
20
+ ```
21
+
22
+ `await using` needs Node 24+ or TypeScript 5.2+. Otherwise call `await browser.stop()` in a `finally` block. `ask()` uses the AI model set on your key in the dashboard.
23
+
24
+ ## Personas
25
+
26
+ A persona is one device: fingerprint, cookie jar and exit IP, the same on every run.
27
+
28
+ ```ts
29
+ import { Oya } from '@oya-ai/browser';
30
+
31
+ const oya = new Oya();
32
+ const persona = await oya.personas.create({
33
+ name: 'us-shopper',
34
+ prefs: { platform: 'MacIntel', timezone: 'America/New_York', locale: 'en-US' }, // fixed for life
35
+ proxy: { geo: 'US' },
36
+ });
37
+ await using browser = await oya.browser.start({ persona: persona.id }); // or persona: 'auto' to rotate
38
+ await browser.goto('https://example.com');
39
+ console.log(persona.fingerprint.platform, persona.fingerprint.timezone); // the same on every run
40
+ ```
41
+
42
+ ## CAPTCHA
43
+
44
+ The vendor's own solver when it has one, otherwise your CapSolver or 2Captcha key.
45
+
46
+ ```ts
47
+ import { Oya } from '@oya-ai/browser';
48
+
49
+ const oya = new Oya();
50
+ await using browser = await oya.browser.start(); // or start({ captcha: 'auto' }) to clear them on every goto()
51
+ await browser.goto('https://www.google.com/recaptcha/api2/demo');
52
+ console.log(await browser.solveCaptcha()); // { present, solved, method: 'provider' | 'solver' | 'none' }
53
+ ```
54
+
55
+ ## MFA
56
+
57
+ The TOTP seed is sealed on the persona, and `completeMfa()` enters the code.
58
+
59
+ ```ts
60
+ import { Oya } from '@oya-ai/browser';
61
+
62
+ const oya = new Oya();
63
+ const persona = await oya.personas.create({ name: 'billing-admin' });
64
+ await oya.personas.setMfa(persona.id, { type: 'totp', secret: process.env.TOTP_SECRET! }); // sealed, never read back
65
+
66
+ await using browser = await oya.browser.start({ persona: persona.id });
67
+ await browser.goto(process.env.MFA_URL!); // after your login step: the page asking for the code
68
+ const mfa = await browser.completeMfa(); // method: 'totp' | 'email' | 'sms' | 'handoff'
69
+ if (!mfa.completed) console.log('A person can finish it here:', mfa.liveViewUrl);
70
+ ```
71
+
72
+ ## Playwright, Puppeteer, Stagehand
73
+
74
+ `browser.cdpUrl` is a standard CDP endpoint on any CDP vendor.
75
+
76
+ ```ts
77
+ import { chromium } from 'playwright-core';
78
+ import { Oya } from '@oya-ai/browser';
79
+
80
+ const oya = new Oya();
81
+ await using browser = await oya.browser.start({ provider: 'browserbase' }); // or steel, anchor, browseruse
82
+ const context = (await chromium.connectOverCDP(browser.cdpUrl!)).contexts()[0];
83
+ const page = context.pages()[0] ?? await context.newPage();
84
+ await page.goto('https://example.com');
85
+ console.log(await page.title());
86
+ ```
87
+
88
+ Vendor keys are set once on your Oya key in the dashboard. They never appear in code.
89
+
90
+ ## API
91
+
92
+ | | |
93
+ |---|---|
94
+ | `new Oya({ apiKey?, baseUrl?, timeoutMs? })` | Defaults to `OYA_API_KEY` and `OYA_BASE_URL` |
95
+ | `oya.browser` | `start(options)`, `get(id)`, `list()`, `stop(ids \| 'all')`, `stopAll()` |
96
+ | `browser` | `goto`, `ask`, `analyze`, `elements`, `click`, `type`, `pressKey`, `scroll`, `waitFor`, `screenshot`, `url`, `tabs`, `openTab`, `switchTab`, `closeTab`, `solveCaptcha`, `completeMfa`, `liveViewUrl`, `status`, `stop`, `cdpUrl` |
97
+ | `oya.personas` | `list`, `get`, `create`, `update`, `clone`, `preview`, `options`, `pinProxy`, `remove`, `setMfa`, `clearMfa` |
98
+ | `oya.config` | `get()`, `set(values)`: model, provider and solver keys for this API key |
99
+ | `oya.control` | Sessions, human takeover, events, members, credentials and webhooks |
100
+ | `oya.usage()` | What this key has spent |
101
+
102
+ Errors are thrown as `OyaError` with `status` and `body`. ESM and CommonJS, fully typed, no runtime dependencies, Node 18+.
103
+
104
+ More: [examples](https://github.com/OyadotAI/AgentChrome/tree/main/examples) · [docs](https://browser.getoya.ai/docs) · [CLI](https://www.npmjs.com/package/@oya-ai/cli)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oya-ai/browser",
3
- "version": "0.1.0",
3
+ "version": "1.0.57",
4
4
  "description": "Rotate thousands of browsers behind one API — personas, proxies, stealth, CAPTCHA and MFA.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,14 +14,20 @@
14
14
  "require": "./dist/index.cjs"
15
15
  }
16
16
  },
17
- "files": ["dist"],
17
+ "files": [
18
+ "dist"
19
+ ],
18
20
  "sideEffects": false,
19
21
  "scripts": {
20
22
  "build": "tsup src/index.ts --format esm,cjs --dts --clean",
21
23
  "prepublishOnly": "npm run build"
22
24
  },
23
- "engines": { "node": ">=18" },
24
- "publishConfig": { "access": "public" },
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
25
31
  "devDependencies": {
26
32
  "tsup": "^8.0.0",
27
33
  "typescript": "^5.4.0"