@oya-ai/browser 1.0.249 → 1.0.250
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.
- package/README.md +15 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,7 +59,6 @@ Node.js 20 or newer; the examples are ES modules. `OYA_BASE_URL` points at a sel
|
|
|
59
59
|
control plane. On Node.js 24+, `await using browser = await oya.browser.start()` stops it
|
|
60
60
|
when the scope exits, errors included.
|
|
61
61
|
|
|
62
|
-
|
|
63
62
|
## For AI agents
|
|
64
63
|
|
|
65
64
|
No key yet? Get your own, and use your person's own browser with their logins:
|
|
@@ -73,7 +72,7 @@ Written for agents: [oyabrowser.com/llms.txt](https://oyabrowser.com/llms.txt).
|
|
|
73
72
|
|
|
74
73
|
## Portal automation: record once, replay with new inputs
|
|
75
74
|
|
|
76
|
-
|
|
75
|
+
Reuse a persona, attach to an existing browser or start one, run a prompt the first time, then replay its saved playbook. The portal, workflow names, and request values below are fictional. Supply your own test portal and credentials through environment variables; adapt the task to its actual pages.
|
|
77
76
|
|
|
78
77
|
Save as `portal.mjs` and run `node portal.mjs` after setting `OYA_API_KEY`, `PORTAL_URL`, `PORTAL_USERNAME`, and `PORTAL_PASSWORD`. Set `OYA_BROWSER_ID` only to reuse an already running browser.
|
|
79
78
|
|
|
@@ -119,6 +118,8 @@ if (existingId) {
|
|
|
119
118
|
const persona =
|
|
120
119
|
(await oya.personas.list()).find((p) => p.name === 'portal-demo') ??
|
|
121
120
|
(await oya.personas.create({ name: 'portal-demo' }));
|
|
121
|
+
// The login lives on the persona, sealed: every run and replay as it signs in on its own.
|
|
122
|
+
await oya.personas.setCredentials(persona.id, { domain: new URL(portalUrl).hostname, ...secrets });
|
|
122
123
|
browser = await oya.browser.start({ persona: persona.id, captcha: 'auto' });
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -165,7 +166,9 @@ try {
|
|
|
165
166
|
}
|
|
166
167
|
```
|
|
167
168
|
|
|
168
|
-
|
|
169
|
+
**Signing in.** A login saved on the persona (`oya.personas.setCredentials`) is the one to use for portals: every run and replay as that persona signs in with it on its own, before the agent starts, and a second factor set with `setMfa` is answered the same way. A run that brings its login in `secrets` instead (here, when you attach with `OYA_BROWSER_ID`) types it itself, through the placeholders in the prompt.
|
|
170
|
+
|
|
171
|
+
`submit()` starts a background run and returns a `Run` handle. The SDK polls every two seconds by default (`pollMs` overrides this). `run.done` resolves with the result or rejects with an error; `run.status()` reads the run record. Attention reasons are `captcha`, `login`, `mfa`, `agent`, and `heal_failed`. `login` comes from the run's own sign-in check: a page asks for a login and the profile has none saved (`oya.personas.setCredentials`). A run waits up to 30 minutes for `request.respond()` or `run.respond()`. Run records are held in server memory for one hour after completion; they do not survive a server restart.
|
|
169
172
|
|
|
170
173
|
### Data, secrets, and reusable placeholders
|
|
171
174
|
|
|
@@ -193,7 +196,7 @@ A string argument is a path on disk (Node only); a `Blob`, a `File`, or a `Uint8
|
|
|
193
196
|
parse prose:
|
|
194
197
|
|
|
195
198
|
```ts
|
|
196
|
-
const { title, price } = await browser.extract('What is the product on this page?', {
|
|
199
|
+
const { title, price } = await browser.extract<{ title: string; price: string }>('What is the product on this page?', {
|
|
197
200
|
type: 'object',
|
|
198
201
|
properties: { title: { type: 'string' }, price: { type: 'string' } },
|
|
199
202
|
required: ['title', 'price'],
|
|
@@ -225,7 +228,7 @@ A field the agent wrote itself (a comment, the reason for a request, a question'
|
|
|
225
228
|
### Move a playbook to another environment
|
|
226
229
|
|
|
227
230
|
```js
|
|
228
|
-
const doc = await oya.playbooks.export('new-request');
|
|
231
|
+
const doc = await oya.playbooks.export('new-request'); // JSON: steps, defaults, secret names (never values)
|
|
229
232
|
await prodOya.playbooks.import(doc, { name: 'new-request', overwrite: false });
|
|
230
233
|
```
|
|
231
234
|
|
|
@@ -233,7 +236,7 @@ The CLI does the same with `oya playbooks export <name> --out file.json` and `oy
|
|
|
233
236
|
|
|
234
237
|
## Use your own model key
|
|
235
238
|
|
|
236
|
-
|
|
239
|
+
Configure the model on your Oya API key once, for every agent run after it:
|
|
237
240
|
|
|
238
241
|
```js
|
|
239
242
|
import { Oya } from '@oya-ai/browser';
|
|
@@ -348,8 +351,8 @@ const oya = new Oya();
|
|
|
348
351
|
await using browser = await oya.browser.start();
|
|
349
352
|
await browser.goto('https://github.com/trending');
|
|
350
353
|
|
|
351
|
-
// Analyze page:
|
|
352
|
-
const { markdown, elements } = await browser.analyze();
|
|
354
|
+
// Analyze page: the page as markdown (TOON in `page` by default) and its numbered elements
|
|
355
|
+
const { markdown, elements } = await browser.analyze({ format: 'markdown' });
|
|
353
356
|
console.log((markdown ?? '').slice(0, 300));
|
|
354
357
|
|
|
355
358
|
// Interact using numbered element IDs:
|
|
@@ -377,7 +380,8 @@ await oya.personas.setMfa(persona.id, {
|
|
|
377
380
|
|
|
378
381
|
await using browser = await oya.browser.start({ persona: persona.id });
|
|
379
382
|
|
|
380
|
-
// 2. Clear CAPTCHAs
|
|
383
|
+
// 2. Clear CAPTCHAs: a provider that solves natively, else the solver set on your key
|
|
384
|
+
// (oya.config.set({ captcha_solver: 'capsolver', captcha_api_key: '...' }))
|
|
381
385
|
await browser.goto('https://www.google.com/recaptcha/api2/demo');
|
|
382
386
|
const captcha = await browser.solveCaptcha();
|
|
383
387
|
console.log('CAPTCHA Solved:', captcha.solved, 'via', captcha.method);
|
|
@@ -404,7 +408,8 @@ import { Oya } from '@oya-ai/browser';
|
|
|
404
408
|
|
|
405
409
|
const oya = new Oya();
|
|
406
410
|
|
|
407
|
-
// Run on any underlying provider: browserbase, steel, anchor, browseruse, or oya-cloud
|
|
411
|
+
// Run on any underlying provider: browserbase, steel, anchor, browseruse, or oya-cloud.
|
|
412
|
+
// A vendor needs its key on your Oya key first, e.g. oya.config.set({ browserbase_api_key: '...' }).
|
|
408
413
|
await using browser = await oya.browser.start({ provider: 'browserbase' });
|
|
409
414
|
|
|
410
415
|
// Connect Playwright directly over Oya's gateway
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oya-ai/browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.250",
|
|
4
4
|
"description": "TypeScript SDK for Oya, the HIPAA-compliant agentic browser: start cloud browsers, run playbooks, attach Playwright.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://oyabrowser.com",
|