wb-browser-runtime 0.6.0 → 0.7.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 CHANGED
@@ -1,10 +1,12 @@
1
1
  # wb-browser-runtime
2
2
 
3
- Browser sidecar for `wb` — deterministic Playwright slices over Browserbase.
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 Browserbase session via CDP. Sessions are cached by `session:`
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.
@@ -20,11 +22,54 @@ npm link # exposes `wb-browser-runtime` on $PATH
20
22
  Or set `WB_BROWSER_RUNTIME=/absolute/path/to/bin/wb-browser-runtime.js` for a
21
23
  specific run.
22
24
 
23
- ## Required env
25
+ ## Vendor selection
26
+
27
+ `WB_BROWSER_VENDOR` — `browserbase` (default) or `browser-use`. Resolved once
28
+ at sidecar boot; there is no per-slice override.
29
+
30
+ ### Browserbase (default)
24
31
 
25
32
  - `BROWSERBASE_API_KEY`
26
33
  - `BROWSERBASE_PROJECT_ID`
27
34
 
35
+ ### browser-use
36
+
37
+ - `BROWSER_USE_API_KEY`
38
+ - `BROWSER_USE_PROXY_COUNTRY` *(optional)* — ISO country code for the cloud's
39
+ built-in residential proxy (defaults to `us` on the vendor side). Set to
40
+ `null` to disable the proxy.
41
+ - `BROWSER_USE_TIMEOUT_MIN` *(optional, 1–240)* — session TTL. Vendor default
42
+ is 60 minutes; unused time is refunded if the session ran less than an hour.
43
+
44
+ Profile (auth state) is selected per-runbook via the `profile_id:` field on a
45
+ `browser` block — see "Profiles" below.
46
+
47
+ ## Profiles
48
+
49
+ Some vendors expose persistent browser profiles — cookies, localStorage, saved
50
+ auth — that bind a session to a previously-logged-in identity so the
51
+ runbook can skip login. The current support matrix:
52
+
53
+ | Vendor | Profile field | Source of profile id |
54
+ |--------------|---------------|----------------------------------------------|
55
+ | browser-use | `profileId` | `curl -fsSL https://browser-use.com/profile.sh \| sh` |
56
+ | browserbase | n/a | logged + ignored |
57
+
58
+ A runbook pins a profile via `profile_id:` on the `browser` block:
59
+
60
+ ```browser
61
+ session: airbase
62
+ profile_id: 550e8400-e29b-41d4-a716-446655440000
63
+ verbs:
64
+ - goto: https://dashboard.airbase.io/home
65
+ ```
66
+
67
+ The id is an opaque UUID that the runbook generator (UI editor, codegen, or
68
+ hand-author) bakes in. Rotating the underlying auth state means re-emitting
69
+ the runbook with a fresh id — no env-var shuffle and no in-place edits at
70
+ run time. Browserbase runs ignore the field with an info-level log so the
71
+ same runbook executes against either vendor.
72
+
28
73
  Verb arguments support two substitutions at dispatch time:
29
74
 
30
75
  - `{{ env.NAME }}` — reads `process.env.NAME`. Use for static secrets injected via Doppler / the agent's env.
@@ -38,7 +83,13 @@ Both forms are redacted in stdout summaries — only the verb name + selector ma
38
83
  - `error` — throw, failing the slice. Use in CI so a missing OTP doesn't silently dispatch an empty selector.
39
84
  - `empty` — substitute empty silently (suppresses the warning).
40
85
 
41
- ## Optional: anti-detection
86
+ **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).
87
+
88
+ **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.
89
+
90
+ **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.
91
+
92
+ ## Optional: anti-detection (Browserbase only)
42
93
 
43
94
  Targets behind Cloudflare / Kasada / DataDome (e.g. Airbase) will reject the
44
95
  default Browserbase session fingerprint and serve a non-interactive challenge
@@ -51,7 +102,9 @@ page. Flip either flag on for the affected runs.
51
102
 
52
103
  Set `=1` (or `=true`) to enable. `proxies: true` alone clears most Cloudflare
53
104
  challenges; add `advancedStealth: true` on top when the target still blocks.
54
- The sidecar logs the resolved config at session create.
105
+ The sidecar logs the resolved config at session create. Ignored when
106
+ `WB_BROWSER_VENDOR=browser-use` — that vendor has stealth + residential
107
+ proxies on by default.
55
108
 
56
109
  ## Optional: session recording (rrweb + CDP screencast)
57
110