wb-browser-runtime 0.6.1 → 0.10.0
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 +71 -7
- package/bin/wb-browser-runtime.js +184 -1003
- package/lib/http.js +63 -0
- package/lib/io.js +56 -0
- package/lib/providers/browser-use.js +133 -0
- package/lib/providers/browserbase.js +120 -0
- package/lib/providers/index.js +43 -0
- package/lib/recording-manager.js +620 -0
- package/lib/session-manager.js +101 -0
- package/lib/stub-page.js +112 -0
- package/lib/util.js +33 -0
- package/package.json +25 -3
- package/verbs/announce_artifact.js +74 -0
- package/verbs/assert.js +23 -0
- package/verbs/click.js +8 -0
- package/verbs/eval.js +20 -0
- package/verbs/extract.js +38 -0
- package/verbs/fill.js +13 -0
- package/verbs/goto.js +10 -0
- package/verbs/index.js +81 -0
- package/verbs/pause_for_human.js +60 -0
- package/verbs/press.js +9 -0
- package/verbs/save.js +55 -0
- package/verbs/screenshot.js +48 -0
- package/verbs/wait_for.js +13 -0
- package/verbs/wait_for_drop.js +235 -0
package/README.md
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
# wb-browser-runtime
|
|
2
2
|
|
|
3
|
-
Browser sidecar for `wb` — deterministic Playwright slices over
|
|
3
|
+
Browser sidecar for `wb` — deterministic Playwright slices over a CDP-exposing
|
|
4
|
+
vendor. Browserbase is the default; browser-use cloud is supported via
|
|
5
|
+
`WB_BROWSER_VENDOR=browser-use`.
|
|
4
6
|
|
|
5
7
|
Each `browser` fenced block in a workbook arrives as one `slice` message;
|
|
6
8
|
this sidecar dispatches its `verbs` against a `playwright-core` `Page`
|
|
7
|
-
connected to a
|
|
9
|
+
connected to a vendor-provided CDP endpoint. Sessions are cached by `session:`
|
|
8
10
|
name across slices for the lifetime of the sidecar process so a runbook with
|
|
9
11
|
multiple browser blocks against the same vendor reuses one logged-in browser
|
|
10
12
|
context.
|
|
11
13
|
|
|
12
|
-
## Install
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
From npm:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g wb-browser-runtime
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
From source (local dev):
|
|
13
23
|
|
|
14
24
|
```bash
|
|
15
|
-
|
|
25
|
+
git clone https://github.com/workbooks-dev/wb-browser-runtime.git
|
|
26
|
+
cd wb-browser-runtime
|
|
16
27
|
npm install # installs playwright-core
|
|
17
28
|
npm link # exposes `wb-browser-runtime` on $PATH
|
|
18
29
|
```
|
|
@@ -20,11 +31,56 @@ npm link # exposes `wb-browser-runtime` on $PATH
|
|
|
20
31
|
Or set `WB_BROWSER_RUNTIME=/absolute/path/to/bin/wb-browser-runtime.js` for a
|
|
21
32
|
specific run.
|
|
22
33
|
|
|
23
|
-
##
|
|
34
|
+
## Vendor selection
|
|
35
|
+
|
|
36
|
+
`WB_BROWSER_VENDOR` — `browserbase` (default) or `browser-use`. Resolved once
|
|
37
|
+
at sidecar boot; there is no per-slice override.
|
|
38
|
+
|
|
39
|
+
### Browserbase (default)
|
|
24
40
|
|
|
25
41
|
- `BROWSERBASE_API_KEY`
|
|
26
42
|
- `BROWSERBASE_PROJECT_ID`
|
|
27
43
|
|
|
44
|
+
### browser-use
|
|
45
|
+
|
|
46
|
+
- `BROWSER_USE_API_KEY`
|
|
47
|
+
- `BROWSER_USE_PROXY_COUNTRY` *(optional)* — ISO country code for the cloud's
|
|
48
|
+
built-in residential proxy (defaults to `us` on the vendor side). Set to
|
|
49
|
+
`null` to disable the proxy.
|
|
50
|
+
- `BROWSER_USE_TIMEOUT_MIN` *(optional, 1–240)* — session TTL. Vendor default
|
|
51
|
+
is 60 minutes; unused time is refunded if the session ran less than an hour.
|
|
52
|
+
|
|
53
|
+
Profile (auth state) is selected per-runbook via the `profile_id:` field on a
|
|
54
|
+
`browser` block — see "Profiles" below. `BROWSER_USE_PROFILE_ID` is read as a
|
|
55
|
+
default when the browser block omits `profile_id:`; a per-runbook `profile_id:`
|
|
56
|
+
always wins over the env var.
|
|
57
|
+
|
|
58
|
+
## Profiles
|
|
59
|
+
|
|
60
|
+
Some vendors expose persistent browser profiles — cookies, localStorage, saved
|
|
61
|
+
auth — that bind a session to a previously-logged-in identity so the
|
|
62
|
+
runbook can skip login. The current support matrix:
|
|
63
|
+
|
|
64
|
+
| Vendor | Profile field | Source of profile id |
|
|
65
|
+
|--------------|---------------|----------------------------------------------|
|
|
66
|
+
| browser-use | `profileId` | `curl -fsSL https://browser-use.com/profile.sh \| sh` |
|
|
67
|
+
| browserbase | n/a | logged + ignored |
|
|
68
|
+
|
|
69
|
+
A runbook pins a profile via `profile_id:` on the `browser` block:
|
|
70
|
+
|
|
71
|
+
```browser
|
|
72
|
+
session: airbase
|
|
73
|
+
profile_id: 550e8400-e29b-41d4-a716-446655440000
|
|
74
|
+
verbs:
|
|
75
|
+
- goto: https://dashboard.airbase.io/home
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The id is an opaque UUID that the runbook generator (UI editor, codegen, or
|
|
79
|
+
hand-author) bakes in. Rotating the underlying auth state means re-emitting
|
|
80
|
+
the runbook with a fresh id — no env-var shuffle and no in-place edits at
|
|
81
|
+
run time. Browserbase runs ignore the field with an info-level log so the
|
|
82
|
+
same runbook executes against either vendor.
|
|
83
|
+
|
|
28
84
|
Verb arguments support two substitutions at dispatch time:
|
|
29
85
|
|
|
30
86
|
- `{{ env.NAME }}` — reads `process.env.NAME`. Use for static secrets injected via Doppler / the agent's env.
|
|
@@ -38,7 +94,13 @@ Both forms are redacted in stdout summaries — only the verb name + selector ma
|
|
|
38
94
|
- `error` — throw, failing the slice. Use in CI so a missing OTP doesn't silently dispatch an empty selector.
|
|
39
95
|
- `empty` — substitute empty silently (suppresses the warning).
|
|
40
96
|
|
|
41
|
-
|
|
97
|
+
**Slice wall-clock cap.** `WB_SLICE_DEADLINE_MS` (default `120000` = 2 min) aborts a slice if aggregate verb time exceeds it. This is an independent bound from each verb's own `timeout:` — a chain of 25 × 15s `wait_for`s all emitting events would never trip `wb`'s 300s per-event sidecar timeout, so the sidecar applies its own total-time cap. Set higher for legitimately long slices (long polling across multiple `wait_for`s).
|
|
98
|
+
|
|
99
|
+
**Log level.** `WB_LOG_LEVEL` (`trace` | `debug` | `info` | `warn` | `error`, default `info`) filters stderr diagnostic output. Existing `[recording]` / `[retry]` / `[shutdown]` lines are info-level; unknown values fall back to info with a one-shot warning.
|
|
100
|
+
|
|
101
|
+
**Per-verb + session timings.** `verb.complete` and `verb.failed` frames include `duration_ms`. `slice.session_started` includes a `timings` object with `allocate_ms` (bbCreateSession), `connect_ms` (bbGetLiveUrl + CDP connect), `page_ready_ms` (context/page setup), and `total_ms`. Graph these to see where slow sessions spend time — usually `connect_ms` on a cold Browserbase region.
|
|
102
|
+
|
|
103
|
+
## Optional: anti-detection (Browserbase only)
|
|
42
104
|
|
|
43
105
|
Targets behind Cloudflare / Kasada / DataDome (e.g. Airbase) will reject the
|
|
44
106
|
default Browserbase session fingerprint and serve a non-interactive challenge
|
|
@@ -51,7 +113,9 @@ page. Flip either flag on for the affected runs.
|
|
|
51
113
|
|
|
52
114
|
Set `=1` (or `=true`) to enable. `proxies: true` alone clears most Cloudflare
|
|
53
115
|
challenges; add `advancedStealth: true` on top when the target still blocks.
|
|
54
|
-
The sidecar logs the resolved config at session create.
|
|
116
|
+
The sidecar logs the resolved config at session create. Ignored when
|
|
117
|
+
`WB_BROWSER_VENDOR=browser-use` — that vendor has stealth + residential
|
|
118
|
+
proxies on by default.
|
|
55
119
|
|
|
56
120
|
## Optional: session recording (rrweb + CDP screencast)
|
|
57
121
|
|